Clipboard: check mime type before pasting image.
[gnumeric.git] / src / input-msg.c
blob493baa3ab9caed0cbc00f63bdeb1e33e62f7e0d1
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 if (msg->title != NULL) {
47 go_string_unref (msg->title);
48 msg->title = NULL;
50 if (msg->msg != NULL) {
51 go_string_unref (msg->msg);
52 msg->msg = NULL;
55 parent_class = g_type_class_peek (G_TYPE_OBJECT);
56 parent_class->finalize (obj);
59 static void
60 gnm_input_msg_class_init (GObjectClass *object_class)
62 object_class->finalize = gnm_input_msg_finalize;
64 static void
65 gnm_input_msg_init (GObject *obj)
67 GnmInputMsg *msg = (GnmInputMsg * )obj;
68 msg->title = NULL;
69 msg->msg = NULL;
72 GSF_CLASS (GnmInputMsg, gnm_input_msg,
73 gnm_input_msg_class_init, gnm_input_msg_init, G_TYPE_OBJECT)
75 /**
76 * gnm_input_msg_new :
77 * @msg:
78 * @title:
80 * Returns: a ref to new #GnmInputMsg.
81 **/
82 GnmInputMsg *
83 gnm_input_msg_new (char const *msg, char const *title)
85 GnmInputMsg *res = g_object_new (GNM_INPUT_MSG_TYPE, NULL);
87 if (msg != NULL)
88 res->msg = go_string_new (msg);
89 if (title != NULL)
90 res->title = go_string_new (title);
92 return res;
95 gboolean
96 gnm_input_msg_equal (GnmInputMsg const *a,
97 GnmInputMsg const *b)
99 g_return_val_if_fail (GNM_IS_INPUT_MSG (a), FALSE);
100 g_return_val_if_fail (GNM_IS_INPUT_MSG (b), FALSE);
102 return (g_strcmp0 (a->title ? a->title->str : NULL,
103 b->title ? b->title->str : NULL) == 0 &&
104 g_strcmp0 (a->msg ? a->msg->str : NULL,
105 b->msg ? b->msg->str : NULL) == 0);
109 char const *
110 gnm_input_msg_get_msg (GnmInputMsg const *imsg)
112 return (imsg->msg != NULL) ? imsg->msg->str : "";
115 char const *
116 gnm_input_msg_get_title (GnmInputMsg const *imsg)
118 return (imsg->title != NULL) ? imsg->title->str : "";