~ubuntu-branches/ubuntu/maverick/gimp/maverick-updates

« back to all changes in this revision

Viewing changes to app/tools/gimpmoveoptions.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2005-12-09 19:44:52 UTC
  • Revision ID: james.westby@ubuntu.com-20051209194452-yggpemjlofpjqyf4
Tags: upstream-2.2.9
ImportĀ upstreamĀ versionĀ 2.2.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* The GIMP -- an image manipulation program
 
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 
3
 *
 
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.
 
8
 *
 
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.
 
13
 *
 
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.
 
17
 */
 
18
 
 
19
#include "config.h"
 
20
 
 
21
#include <gtk/gtk.h>
 
22
 
 
23
#include "libgimpwidgets/gimpwidgets.h"
 
24
 
 
25
#include "tools-types.h"
 
26
 
 
27
#include "config/gimpconfig-params.h"
 
28
 
 
29
#include "core/gimptoolinfo.h"
 
30
 
 
31
#include "widgets/gimppropwidgets.h"
 
32
#include "widgets/gimpwidgets-utils.h"
 
33
 
 
34
#include "gimpmoveoptions.h"
 
35
#include "gimptooloptions-gui.h"
 
36
 
 
37
#include "gimp-intl.h"
 
38
 
 
39
 
 
40
enum
 
41
{
 
42
  PROP_0,
 
43
  PROP_MOVE_TYPE,
 
44
  PROP_MOVE_CURRENT
 
45
};
 
46
 
 
47
 
 
48
static void   gimp_move_options_class_init (GimpMoveOptionsClass *options_class);
 
49
 
 
50
static void   gimp_move_options_set_property (GObject         *object,
 
51
                                              guint            property_id,
 
52
                                              const GValue    *value,
 
53
                                              GParamSpec      *pspec);
 
54
static void   gimp_move_options_get_property (GObject         *object,
 
55
                                              guint            property_id,
 
56
                                              GValue          *value,
 
57
                                              GParamSpec      *pspec);
 
58
 
 
59
 
 
60
static GimpToolOptionsClass *parent_class = NULL;
 
61
 
 
62
 
 
63
GType
 
64
gimp_move_options_get_type (void)
 
65
{
 
66
  static GType type = 0;
 
67
 
 
68
  if (! type)
 
69
    {
 
70
      static const GTypeInfo info =
 
71
      {
 
72
        sizeof (GimpMoveOptionsClass),
 
73
        (GBaseInitFunc) NULL,
 
74
        (GBaseFinalizeFunc) NULL,
 
75
        (GClassInitFunc) gimp_move_options_class_init,
 
76
        NULL,           /* class_finalize */
 
77
        NULL,           /* class_data     */
 
78
        sizeof (GimpMoveOptions),
 
79
        0,              /* n_preallocs    */
 
80
        (GInstanceInitFunc) NULL
 
81
      };
 
82
 
 
83
      type = g_type_register_static (GIMP_TYPE_TOOL_OPTIONS,
 
84
                                     "GimpMoveOptions",
 
85
                                     &info, 0);
 
86
    }
 
87
 
 
88
  return type;
 
89
}
 
90
 
 
91
static void
 
92
gimp_move_options_class_init (GimpMoveOptionsClass *klass)
 
93
{
 
94
  GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
95
 
 
96
  parent_class = g_type_class_peek_parent (klass);
 
97
 
 
98
  object_class->set_property = gimp_move_options_set_property;
 
99
  object_class->get_property = gimp_move_options_get_property;
 
100
 
 
101
  GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_MOVE_TYPE,
 
102
                                 "move-type", NULL,
 
103
                                 GIMP_TYPE_TRANSFORM_TYPE,
 
104
                                 GIMP_TRANSFORM_TYPE_LAYER,
 
105
                                 0);
 
106
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_MOVE_CURRENT,
 
107
                                    "move-current", NULL,
 
108
                                    FALSE,
 
109
                                    0);
 
110
}
 
111
 
 
112
static void
 
113
gimp_move_options_set_property (GObject      *object,
 
114
                                guint         property_id,
 
115
                                const GValue *value,
 
116
                                GParamSpec   *pspec)
 
117
{
 
118
  GimpMoveOptions *options = GIMP_MOVE_OPTIONS (object);
 
119
 
 
120
  switch (property_id)
 
121
    {
 
122
    case PROP_MOVE_TYPE:
 
123
      options->move_type = g_value_get_enum (value);
 
124
      break;
 
125
    case PROP_MOVE_CURRENT:
 
126
      options->move_current = g_value_get_boolean (value);
 
127
      break;
 
128
    default:
 
129
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 
130
      break;
 
131
    }
 
132
}
 
133
 
 
134
static void
 
135
gimp_move_options_get_property (GObject    *object,
 
136
                                guint       property_id,
 
137
                                GValue     *value,
 
138
                                GParamSpec *pspec)
 
139
{
 
140
  GimpMoveOptions *options = GIMP_MOVE_OPTIONS (object);
 
141
 
 
142
  switch (property_id)
 
143
    {
 
144
    case PROP_MOVE_TYPE:
 
145
      g_value_set_enum (value, options->move_type);
 
146
      break;
 
147
    case PROP_MOVE_CURRENT:
 
148
      g_value_set_boolean (value, options->move_current);
 
149
      break;
 
150
    default:
 
151
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 
152
      break;
 
153
    }
 
154
}
 
155
 
 
156
static void
 
157
gimp_move_options_notify_type (GimpMoveOptions *move_options,
 
158
                               GParamSpec      *pspec,
 
159
                               GtkWidget       *frame)
 
160
{
 
161
  const gchar *false_label = NULL;
 
162
  const gchar *true_label  = NULL;
 
163
  GtkWidget   *button;
 
164
  GSList      *group;
 
165
 
 
166
  button = g_object_get_data (G_OBJECT (frame), "radio-button");
 
167
 
 
168
  switch (move_options->move_type)
 
169
    {
 
170
    case GIMP_TRANSFORM_TYPE_LAYER:
 
171
      false_label = _("Pick a layer or guide");
 
172
      true_label  = _("Move the current layer");
 
173
      break;
 
174
 
 
175
    case GIMP_TRANSFORM_TYPE_SELECTION:
 
176
      false_label = true_label = _("Move selection");
 
177
      break;
 
178
 
 
179
    case GIMP_TRANSFORM_TYPE_PATH:
 
180
      false_label = _("Pick a path");
 
181
      true_label  = _("Move the current path");
 
182
     break;
 
183
    }
 
184
 
 
185
  group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
 
186
  gtk_button_set_label (GTK_BUTTON (group->data), true_label);
 
187
 
 
188
  group = g_slist_next (group);
 
189
  gtk_button_set_label (GTK_BUTTON (group->data), false_label);
 
190
 
 
191
  gtk_widget_set_sensitive (frame,
 
192
                            move_options->move_type != GIMP_TRANSFORM_TYPE_SELECTION);
 
193
}
 
194
 
 
195
GtkWidget *
 
196
gimp_move_options_gui (GimpToolOptions *tool_options)
 
197
{
 
198
  GObject   *config = G_OBJECT (tool_options);
 
199
  GtkWidget *vbox;
 
200
  GtkWidget *hbox;
 
201
  GtkWidget *label;
 
202
  GtkWidget *frame;
 
203
  gchar     *title;
 
204
 
 
205
  vbox = gimp_tool_options_gui (tool_options);
 
206
 
 
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);
 
210
 
 
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);
 
215
 
 
216
  /*  tool toggle  */
 
217
  title = g_strdup_printf (_("Tool Toggle  %s"),
 
218
                           gimp_get_mod_string (GDK_SHIFT_MASK));
 
219
 
 
220
  frame = gimp_prop_boolean_radio_frame_new (config, "move-current",
 
221
                                             title, "true", "false");
 
222
 
 
223
  gimp_move_options_notify_type (GIMP_MOVE_OPTIONS (config), NULL, frame);
 
224
 
 
225
  g_signal_connect_object (config, "notify::move-type",
 
226
                           G_CALLBACK (gimp_move_options_notify_type),
 
227
                           frame, 0);
 
228
 
 
229
  gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
 
230
  gtk_widget_show (frame);
 
231
 
 
232
  g_free (title);
 
233
 
 
234
  return vbox;
 
235
}