1
/* The GIMP -- an image manipulation program
2
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
5
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2 of the License, or
10
* (at your option) any later version.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26
#include "widgets-types.h"
28
#include "core/gimpmarshal.h"
30
#include "gimpstringaction.h"
46
static void gimp_string_action_init (GimpStringAction *action);
47
static void gimp_string_action_class_init (GimpStringActionClass *klass);
49
static void gimp_string_action_finalize (GObject *object);
50
static void gimp_string_action_set_property (GObject *object,
54
static void gimp_string_action_get_property (GObject *object,
59
static void gimp_string_action_activate (GtkAction *action);
62
static GtkActionClass *parent_class = NULL;
63
static guint action_signals[LAST_SIGNAL] = { 0 };
67
gimp_string_action_get_type (void)
69
static GType type = 0;
73
static const GTypeInfo type_info =
75
sizeof (GimpStringActionClass),
77
(GBaseFinalizeFunc) NULL,
78
(GClassInitFunc) gimp_string_action_class_init,
79
(GClassFinalizeFunc) NULL,
81
sizeof (GimpStringAction),
83
(GInstanceInitFunc) gimp_string_action_init,
86
type = g_type_register_static (GIMP_TYPE_ACTION,
95
gimp_string_action_class_init (GimpStringActionClass *klass)
97
GObjectClass *object_class = G_OBJECT_CLASS (klass);
98
GtkActionClass *action_class = GTK_ACTION_CLASS (klass);
100
parent_class = g_type_class_peek_parent (klass);
102
object_class->finalize = gimp_string_action_finalize;
103
object_class->set_property = gimp_string_action_set_property;
104
object_class->get_property = gimp_string_action_get_property;
106
action_class->activate = gimp_string_action_activate;
108
g_object_class_install_property (object_class, PROP_VALUE,
109
g_param_spec_string ("value",
114
action_signals[SELECTED] =
115
g_signal_new ("selected",
116
G_TYPE_FROM_CLASS (klass),
118
G_STRUCT_OFFSET (GimpStringActionClass, selected),
120
gimp_marshal_VOID__STRING,
126
gimp_string_action_init (GimpStringAction *action)
128
action->value = NULL;
132
gimp_string_action_finalize (GObject *object)
134
GimpStringAction *action = GIMP_STRING_ACTION (object);
138
g_free (action->value);
139
action->value = NULL;
142
G_OBJECT_CLASS (parent_class)->finalize (object);
146
gimp_string_action_get_property (GObject *object,
151
GimpStringAction *action = GIMP_STRING_ACTION (object);
156
g_value_set_string (value, action->value);
159
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
165
gimp_string_action_set_property (GObject *object,
170
GimpStringAction *action = GIMP_STRING_ACTION (object);
175
g_free (action->value);
176
action->value = g_value_dup_string (value);
179
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
185
gimp_string_action_new (const gchar *name,
187
const gchar *tooltip,
188
const gchar *stock_id,
191
return g_object_new (GIMP_TYPE_STRING_ACTION,
195
"stock_id", stock_id,
201
gimp_string_action_activate (GtkAction *action)
203
GimpStringAction *string_action = GIMP_STRING_ACTION (action);
205
gimp_string_action_selected (string_action, string_action->value);
209
gimp_string_action_selected (GimpStringAction *action,
212
g_return_if_fail (GIMP_IS_STRING_ACTION (action));
214
g_signal_emit (action, action_signals[SELECTED], 0, value);