1
/* The GIMP -- an image manipulation program
2
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
#include "libgimpwidgets/gimpwidgets.h"
25
#include "tools-types.h"
27
#include "config/gimpconfig-params.h"
29
#include "core/gimptoolinfo.h"
31
#include "widgets/gimppropwidgets.h"
32
#include "widgets/gimpwidgets-utils.h"
34
#include "gimpmoveoptions.h"
35
#include "gimptooloptions-gui.h"
37
#include "gimp-intl.h"
48
static void gimp_move_options_class_init (GimpMoveOptionsClass *options_class);
50
static void gimp_move_options_set_property (GObject *object,
54
static void gimp_move_options_get_property (GObject *object,
60
static GimpToolOptionsClass *parent_class = NULL;
64
gimp_move_options_get_type (void)
66
static GType type = 0;
70
static const GTypeInfo info =
72
sizeof (GimpMoveOptionsClass),
74
(GBaseFinalizeFunc) NULL,
75
(GClassInitFunc) gimp_move_options_class_init,
76
NULL, /* class_finalize */
77
NULL, /* class_data */
78
sizeof (GimpMoveOptions),
80
(GInstanceInitFunc) NULL
83
type = g_type_register_static (GIMP_TYPE_TOOL_OPTIONS,
92
gimp_move_options_class_init (GimpMoveOptionsClass *klass)
94
GObjectClass *object_class = G_OBJECT_CLASS (klass);
96
parent_class = g_type_class_peek_parent (klass);
98
object_class->set_property = gimp_move_options_set_property;
99
object_class->get_property = gimp_move_options_get_property;
101
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_MOVE_TYPE,
103
GIMP_TYPE_TRANSFORM_TYPE,
104
GIMP_TRANSFORM_TYPE_LAYER,
106
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_MOVE_CURRENT,
107
"move-current", NULL,
113
gimp_move_options_set_property (GObject *object,
118
GimpMoveOptions *options = GIMP_MOVE_OPTIONS (object);
123
options->move_type = g_value_get_enum (value);
125
case PROP_MOVE_CURRENT:
126
options->move_current = g_value_get_boolean (value);
129
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
135
gimp_move_options_get_property (GObject *object,
140
GimpMoveOptions *options = GIMP_MOVE_OPTIONS (object);
145
g_value_set_enum (value, options->move_type);
147
case PROP_MOVE_CURRENT:
148
g_value_set_boolean (value, options->move_current);
151
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
157
gimp_move_options_notify_type (GimpMoveOptions *move_options,
161
const gchar *false_label = NULL;
162
const gchar *true_label = NULL;
166
button = g_object_get_data (G_OBJECT (frame), "radio-button");
168
switch (move_options->move_type)
170
case GIMP_TRANSFORM_TYPE_LAYER:
171
false_label = _("Pick a layer or guide");
172
true_label = _("Move the current layer");
175
case GIMP_TRANSFORM_TYPE_SELECTION:
176
false_label = true_label = _("Move selection");
179
case GIMP_TRANSFORM_TYPE_PATH:
180
false_label = _("Pick a path");
181
true_label = _("Move the current path");
185
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
186
gtk_button_set_label (GTK_BUTTON (group->data), true_label);
188
group = g_slist_next (group);
189
gtk_button_set_label (GTK_BUTTON (group->data), false_label);
191
gtk_widget_set_sensitive (frame,
192
move_options->move_type != GIMP_TRANSFORM_TYPE_SELECTION);
196
gimp_move_options_gui (GimpToolOptions *tool_options)
198
GObject *config = G_OBJECT (tool_options);
205
vbox = gimp_tool_options_gui (tool_options);
207
hbox = gimp_prop_enum_stock_box_new (config, "move-type", "gimp", 0, 0);
208
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
209
gtk_widget_show (hbox);
211
label = gtk_label_new (_("Affect:"));
212
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
213
gtk_box_reorder_child (GTK_BOX (hbox), label, 0);
214
gtk_widget_show (label);
217
title = g_strdup_printf (_("Tool Toggle %s"),
218
gimp_get_mod_string (GDK_SHIFT_MASK));
220
frame = gimp_prop_boolean_radio_frame_new (config, "move-current",
221
title, "true", "false");
223
gimp_move_options_notify_type (GIMP_MOVE_OPTIONS (config), NULL, frame);
225
g_signal_connect_object (config, "notify::move-type",
226
G_CALLBACK (gimp_move_options_notify_type),
229
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
230
gtk_widget_show (frame);