Update Spanish translation
[gnumeric.git] / src / input-msg.c
blob5ecb5733e1df72f85ce59ad11c72b179320ab675
2 /*
3 * input-msg.c: Input Message
5 * Copyright (C) 2002 Jody Goldberg (jody@gnome.org)
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) version 3.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
20 * USA
22 #include <gnumeric-config.h>
23 #include <glib/gi18n-lib.h>
24 #include <gnumeric.h>
25 #include <input-msg.h>
27 #include <gsf/gsf-impl-utils.h>
29 struct _GnmInputMsg {
30 GObject obj;
31 GOString *title;
32 GOString *msg;
35 typedef struct {
36 GObjectClass obj;
37 } GnmInputMsgClass;
39 static void
40 gnm_input_msg_finalize (GObject *obj)
42 GObjectClass *parent_class;
43 GnmInputMsg *msg = (GnmInputMsg *)obj;
45 go_string_unref (msg->title);
46 msg->title = NULL;
48 go_string_unref (msg->msg);
49 msg->msg = NULL;
51 parent_class = g_type_class_peek (G_TYPE_OBJECT);
52 parent_class->finalize (obj);
55 static void
56 gnm_input_msg_class_init (GObjectClass *object_class)
58 object_class->finalize = gnm_input_msg_finalize;
60 static void
61 gnm_input_msg_init (GObject *obj)
63 GnmInputMsg *msg = (GnmInputMsg * )obj;
64 msg->title = NULL;
65 msg->msg = NULL;
68 GSF_CLASS (GnmInputMsg, gnm_input_msg,
69 gnm_input_msg_class_init, gnm_input_msg_init, G_TYPE_OBJECT)
71 /**
72 * gnm_input_msg_new:
73 * @msg: (nullable): A message to show
74 * @title: (nullable): A title to show for the message
76 * Returns: a ref to new #GnmInputMsg.
77 **/
78 GnmInputMsg *
79 gnm_input_msg_new (char const *msg, char const *title)
81 GnmInputMsg *res = g_object_new (GNM_INPUT_MSG_TYPE, NULL);
83 if (msg != NULL)
84 res->msg = go_string_new (msg);
85 if (title != NULL)
86 res->title = go_string_new (title);
88 return res;
91 gboolean
92 gnm_input_msg_equal (GnmInputMsg const *a,
93 GnmInputMsg const *b)
95 g_return_val_if_fail (GNM_IS_INPUT_MSG (a), FALSE);
96 g_return_val_if_fail (GNM_IS_INPUT_MSG (b), FALSE);
98 return (g_strcmp0 (a->title ? a->title->str : NULL,
99 b->title ? b->title->str : NULL) == 0 &&
100 g_strcmp0 (a->msg ? a->msg->str : NULL,
101 b->msg ? b->msg->str : NULL) == 0);
106 * gnm_input_msg_get_msg:
107 * @msg: #GnmInputMsg
109 * Returns: (transfer none): The message to show
111 char const *
112 gnm_input_msg_get_msg (GnmInputMsg const *msg)
114 return (msg->msg != NULL) ? msg->msg->str : "";
118 * gnm_input_msg_get_title:
119 * @msg: #GnmInputMsg
121 * Returns: (transfer none): The title of the message to show
123 char const *
124 gnm_input_msg_get_title (GnmInputMsg const *msg)
126 return (msg->title != NULL) ? msg->title->str : "";