GUI: Move .ui files from goffice resources to glib resources
[gnumeric.git] / src / input-msg.c
blob5fd70f9c00871f2531b139b3ab2f5b0800f87b70
1 /* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 /*
4 * input-msg.c: Input Message
6 * Copyright (C) 2002 Jody Goldberg (jody@gnome.org)
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) version 3.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
21 * USA
23 #include <gnumeric-config.h>
24 #include <glib/gi18n-lib.h>
25 #include "gnumeric.h"
26 #include "input-msg.h"
28 #include <gsf/gsf-impl-utils.h>
30 struct _GnmInputMsg {
31 GObject obj;
32 GOString *title;
33 GOString *msg;
36 typedef struct {
37 GObjectClass obj;
38 } GnmInputMsgClass;
40 static void
41 gnm_input_msg_finalize (GObject *obj)
43 GObjectClass *parent_class;
44 GnmInputMsg *msg = (GnmInputMsg *)obj;
46 go_string_unref (msg->title);
47 msg->title = NULL;
49 go_string_unref (msg->msg);
50 msg->msg = NULL;
52 parent_class = g_type_class_peek (G_TYPE_OBJECT);
53 parent_class->finalize (obj);
56 static void
57 gnm_input_msg_class_init (GObjectClass *object_class)
59 object_class->finalize = gnm_input_msg_finalize;
61 static void
62 gnm_input_msg_init (GObject *obj)
64 GnmInputMsg *msg = (GnmInputMsg * )obj;
65 msg->title = NULL;
66 msg->msg = NULL;
69 GSF_CLASS (GnmInputMsg, gnm_input_msg,
70 gnm_input_msg_class_init, gnm_input_msg_init, G_TYPE_OBJECT)
72 /**
73 * gnm_input_msg_new:
74 * @msg: (nullable): A message to show
75 * @title: (nullable): A title to show for the message
77 * Returns: a ref to new #GnmInputMsg.
78 **/
79 GnmInputMsg *
80 gnm_input_msg_new (char const *msg, char const *title)
82 GnmInputMsg *res = g_object_new (GNM_INPUT_MSG_TYPE, NULL);
84 if (msg != NULL)
85 res->msg = go_string_new (msg);
86 if (title != NULL)
87 res->title = go_string_new (title);
89 return res;
92 gboolean
93 gnm_input_msg_equal (GnmInputMsg const *a,
94 GnmInputMsg const *b)
96 g_return_val_if_fail (GNM_IS_INPUT_MSG (a), FALSE);
97 g_return_val_if_fail (GNM_IS_INPUT_MSG (b), FALSE);
99 return (g_strcmp0 (a->title ? a->title->str : NULL,
100 b->title ? b->title->str : NULL) == 0 &&
101 g_strcmp0 (a->msg ? a->msg->str : NULL,
102 b->msg ? b->msg->str : NULL) == 0);
107 * gnm_input_msg_get_msg:
108 * @msg: #GnmInputMsg
110 * Returns: (transfer none): The message to show
112 char const *
113 gnm_input_msg_get_msg (GnmInputMsg const *msg)
115 return (msg->msg != NULL) ? msg->msg->str : "";
119 * gnm_input_msg_get_title:
120 * @msg: #GnmInputMsg
122 * Returns: (transfer none): The title of the message to show
124 char const *
125 gnm_input_msg_get_title (GnmInputMsg const *msg)
127 return (msg->title != NULL) ? msg->title->str : "";