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

« back to all changes in this revision

Viewing changes to app/actions/vectors-actions.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 "actions-types.h"
 
26
 
 
27
#include "core/gimpchannel.h"
 
28
#include "core/gimpimage.h"
 
29
#include "core/gimplist.h"
 
30
 
 
31
#include "widgets/gimpactiongroup.h"
 
32
#include "widgets/gimphelp-ids.h"
 
33
 
 
34
#include "actions.h"
 
35
#include "vectors-actions.h"
 
36
#include "vectors-commands.h"
 
37
 
 
38
#include "gimp-intl.h"
 
39
 
 
40
 
 
41
static GimpActionEntry vectors_actions[] =
 
42
{
 
43
  { "vectors-popup", GIMP_STOCK_PATHS,
 
44
    N_("Paths Menu"), NULL, NULL, NULL,
 
45
    GIMP_HELP_PATH_DIALOG },
 
46
 
 
47
  { "vectors-path-tool", GIMP_STOCK_TOOL_PATH,
 
48
    N_("Path _Tool"), NULL, NULL,
 
49
    G_CALLBACK (vectors_vectors_tool_cmd_callback),
 
50
    GIMP_HELP_TOOL_VECTORS },
 
51
 
 
52
  { "vectors-edit-attributes", GIMP_STOCK_EDIT,
 
53
    N_("_Edit Path Attributes..."), NULL,
 
54
    N_("Edit path attributes"),
 
55
    G_CALLBACK (vectors_edit_attributes_cmd_callback),
 
56
    GIMP_HELP_PATH_EDIT },
 
57
 
 
58
  { "vectors-new", GTK_STOCK_NEW,
 
59
    N_("_New Path..."), "",
 
60
    N_("New path..."),
 
61
    G_CALLBACK (vectors_new_cmd_callback),
 
62
    GIMP_HELP_PATH_NEW },
 
63
 
 
64
  { "vectors-new-last-values", GTK_STOCK_NEW,
 
65
    N_("_New Path"), "",
 
66
    N_("New path with last values"),
 
67
    G_CALLBACK (vectors_new_last_vals_cmd_callback),
 
68
    GIMP_HELP_PATH_NEW },
 
69
 
 
70
  { "vectors-duplicate", GIMP_STOCK_DUPLICATE,
 
71
    N_("D_uplicate Path"), NULL,
 
72
    N_("Duplicate path"),
 
73
    G_CALLBACK (vectors_duplicate_cmd_callback),
 
74
    GIMP_HELP_PATH_DUPLICATE },
 
75
 
 
76
  { "vectors-delete", GTK_STOCK_DELETE,
 
77
    N_("_Delete Path"), "",
 
78
    N_("Delete path"),
 
79
    G_CALLBACK (vectors_delete_cmd_callback),
 
80
    GIMP_HELP_PATH_DELETE },
 
81
 
 
82
  { "vectors-merge-visible", NULL,
 
83
    N_("Merge _Visible Paths"), NULL, NULL,
 
84
    G_CALLBACK (vectors_merge_visible_cmd_callback),
 
85
    GIMP_HELP_PATH_MERGE_VISIBLE },
 
86
 
 
87
  { "vectors-raise", GTK_STOCK_GO_UP,
 
88
    N_("_Raise Path"), "",
 
89
    N_("Raise path"),
 
90
    G_CALLBACK (vectors_raise_cmd_callback),
 
91
    GIMP_HELP_PATH_RAISE },
 
92
 
 
93
  { "vectors-raise-to-top", GTK_STOCK_GOTO_TOP,
 
94
    N_("Raise Path to _Top"), "",
 
95
    N_("Raise path to top"),
 
96
    G_CALLBACK (vectors_raise_to_top_cmd_callback),
 
97
    GIMP_HELP_PATH_RAISE_TO_TOP },
 
98
 
 
99
  { "vectors-lower", GTK_STOCK_GO_DOWN,
 
100
    N_("_Lower Path"), "",
 
101
    N_("Lower path"),
 
102
    G_CALLBACK (vectors_lower_cmd_callback),
 
103
    GIMP_HELP_PATH_LOWER },
 
104
 
 
105
  { "vectors-lower-to-bottom", GTK_STOCK_GOTO_BOTTOM,
 
106
    N_("Lower Path to _Bottom"), "",
 
107
    N_("Lower path to bottom"),
 
108
    G_CALLBACK (vectors_lower_to_bottom_cmd_callback),
 
109
    GIMP_HELP_PATH_LOWER_TO_BOTTOM },
 
110
 
 
111
  { "vectors-stroke", GIMP_STOCK_PATH_STROKE,
 
112
    N_("Stro_ke Path..."), NULL,
 
113
    N_("Stroke path..."),
 
114
    G_CALLBACK (vectors_stroke_cmd_callback),
 
115
    GIMP_HELP_PATH_STROKE },
 
116
 
 
117
  { "vectors-stroke-last-values", GIMP_STOCK_PATH_STROKE,
 
118
    N_("Stro_ke Path"), NULL,
 
119
    N_("Stroke path with last values"),
 
120
    G_CALLBACK (vectors_stroke_last_vals_cmd_callback),
 
121
    GIMP_HELP_PATH_STROKE },
 
122
 
 
123
  { "vectors-copy", GTK_STOCK_COPY,
 
124
    N_("Co_py Path"), "", NULL,
 
125
    G_CALLBACK (vectors_copy_cmd_callback),
 
126
    GIMP_HELP_PATH_COPY },
 
127
 
 
128
  { "vectors-paste", GTK_STOCK_PASTE,
 
129
    N_("Paste Pat_h"), "", NULL,
 
130
    G_CALLBACK (vectors_paste_cmd_callback),
 
131
    GIMP_HELP_PATH_PASTE },
 
132
 
 
133
  { "vectors-import", GTK_STOCK_OPEN,
 
134
    N_("I_mport Path..."), "", NULL,
 
135
    G_CALLBACK (vectors_import_cmd_callback),
 
136
    GIMP_HELP_PATH_IMPORT },
 
137
 
 
138
  { "vectors-export", GTK_STOCK_SAVE,
 
139
    N_("E_xport Path..."), "", NULL,
 
140
    G_CALLBACK (vectors_export_cmd_callback),
 
141
    GIMP_HELP_PATH_EXPORT }
 
142
};
 
143
 
 
144
static GimpToggleActionEntry vectors_toggle_actions[] =
 
145
{
 
146
  { "vectors-visible", GIMP_STOCK_VISIBLE,
 
147
    N_("_Visible"), NULL, NULL,
 
148
    G_CALLBACK (vectors_visible_cmd_callback),
 
149
    FALSE,
 
150
    GIMP_HELP_PATH_VISIBLE },
 
151
 
 
152
  { "vectors-linked", GIMP_STOCK_LINKED,
 
153
    N_("_Linked"), NULL, NULL,
 
154
    G_CALLBACK (vectors_linked_cmd_callback),
 
155
    FALSE,
 
156
    GIMP_HELP_PATH_LINKED }
 
157
};
 
158
 
 
159
static GimpEnumActionEntry vectors_to_selection_actions[] =
 
160
{
 
161
  { "vectors-selection-replace", GIMP_STOCK_SELECTION_REPLACE,
 
162
    N_("Path to Sele_ction"), NULL,
 
163
    N_("Path to selection"),
 
164
    GIMP_CHANNEL_OP_REPLACE, FALSE,
 
165
    GIMP_HELP_PATH_SELECTION_REPLACE },
 
166
 
 
167
  { "vectors-selection-from-vectors", GIMP_STOCK_SELECTION_REPLACE,
 
168
    N_("Fr_om Path"), "<shift>V", NULL,
 
169
    GIMP_CHANNEL_OP_REPLACE, FALSE,
 
170
    GIMP_HELP_PATH_SELECTION_REPLACE },
 
171
 
 
172
  { "vectors-selection-add", GIMP_STOCK_SELECTION_ADD,
 
173
    N_("_Add to Selection"), NULL,
 
174
    N_("Add"),
 
175
    GIMP_CHANNEL_OP_ADD, FALSE,
 
176
    GIMP_HELP_PATH_SELECTION_ADD },
 
177
 
 
178
  { "vectors-selection-subtract", GIMP_STOCK_SELECTION_SUBTRACT,
 
179
    N_("_Subtract from Selection"), NULL,
 
180
    N_("Subtract"),
 
181
    GIMP_CHANNEL_OP_SUBTRACT, FALSE,
 
182
    GIMP_HELP_PATH_SELECTION_SUBTRACT },
 
183
 
 
184
  { "vectors-selection-intersect", GIMP_STOCK_SELECTION_INTERSECT,
 
185
    N_("_Intersect with Selection"), NULL,
 
186
    N_("Intersect"),
 
187
    GIMP_CHANNEL_OP_INTERSECT, FALSE,
 
188
    GIMP_HELP_PATH_SELECTION_INTERSECT }
 
189
};
 
190
 
 
191
static GimpEnumActionEntry vectors_selection_to_vectors_actions[] =
 
192
{
 
193
  { "vectors-selection-to-vectors", GIMP_STOCK_SELECTION_TO_PATH,
 
194
    N_("Selecti_on to Path"), NULL,
 
195
    N_("Selection to path"),
 
196
    FALSE, FALSE,
 
197
    GIMP_HELP_SELECTION_TO_PATH },
 
198
 
 
199
  { "vectors-selection-to-vectors-short", GIMP_STOCK_SELECTION_TO_PATH,
 
200
    N_("To _Path"), NULL, NULL,
 
201
    FALSE, FALSE,
 
202
    GIMP_HELP_SELECTION_TO_PATH },
 
203
 
 
204
  { "vectors-selection-to-vectors-advanced", GIMP_STOCK_SELECTION_TO_PATH,
 
205
    N_("Selection to Path (_Advanced)"), NULL,
 
206
    N_("Advanced options"),
 
207
    TRUE, FALSE,
 
208
    GIMP_HELP_SELECTION_TO_PATH }
 
209
};
 
210
 
 
211
 
 
212
void
 
213
vectors_actions_setup (GimpActionGroup *group)
 
214
{
 
215
  gimp_action_group_add_actions (group,
 
216
                                 vectors_actions,
 
217
                                 G_N_ELEMENTS (vectors_actions));
 
218
 
 
219
  gimp_action_group_add_toggle_actions (group,
 
220
                                        vectors_toggle_actions,
 
221
                                        G_N_ELEMENTS (vectors_toggle_actions));
 
222
 
 
223
  gimp_action_group_add_enum_actions (group,
 
224
                                      vectors_to_selection_actions,
 
225
                                      G_N_ELEMENTS (vectors_to_selection_actions),
 
226
                                      G_CALLBACK (vectors_to_selection_cmd_callback));
 
227
 
 
228
  gimp_action_group_add_enum_actions (group,
 
229
                                      vectors_selection_to_vectors_actions,
 
230
                                      G_N_ELEMENTS (vectors_selection_to_vectors_actions),
 
231
                                      G_CALLBACK (vectors_selection_to_vectors_cmd_callback));
 
232
}
 
233
 
 
234
void
 
235
vectors_actions_update (GimpActionGroup *group,
 
236
                        gpointer         data)
 
237
{
 
238
  GimpImage   *gimage     = action_data_get_image (data);
 
239
  GimpVectors *vectors    = NULL;
 
240
  gint         n_vectors  = 0;
 
241
  gboolean     mask_empty = TRUE;
 
242
  gboolean     global_buf = FALSE;
 
243
  gboolean     visible    = FALSE;
 
244
  gboolean     linked     = FALSE;
 
245
  GList       *next       = NULL;
 
246
  GList       *prev       = NULL;
 
247
 
 
248
  if (gimage)
 
249
    {
 
250
      n_vectors  = gimp_container_num_children (gimage->vectors);
 
251
      mask_empty = gimp_channel_is_empty (gimp_image_get_mask (gimage));
 
252
      global_buf = FALSE;
 
253
 
 
254
      vectors = gimp_image_get_active_vectors (gimage);
 
255
 
 
256
      if (vectors)
 
257
        {
 
258
          GimpItem *item = GIMP_ITEM (vectors);
 
259
          GList    *list;
 
260
 
 
261
          visible = gimp_item_get_visible (item);
 
262
          linked  = gimp_item_get_linked  (item);
 
263
 
 
264
          list = g_list_find (GIMP_LIST (gimage->vectors)->list, vectors);
 
265
 
 
266
          if (list)
 
267
            {
 
268
              prev = g_list_previous (list);
 
269
              next = g_list_next (list);
 
270
            }
 
271
        }
 
272
    }
 
273
 
 
274
#define SET_SENSITIVE(action,condition) \
 
275
        gimp_action_group_set_action_sensitive (group, action, (condition) != 0)
 
276
#define SET_ACTIVE(action,condition) \
 
277
        gimp_action_group_set_action_active (group, action, (condition) != 0)
 
278
 
 
279
  SET_SENSITIVE ("vectors-path-tool",       vectors);
 
280
  SET_SENSITIVE ("vectors-edit-attributes", vectors);
 
281
 
 
282
  SET_SENSITIVE ("vectors-new",             gimage);
 
283
  SET_SENSITIVE ("vectors-new-last-values", gimage);
 
284
  SET_SENSITIVE ("vectors-duplicate",       vectors);
 
285
  SET_SENSITIVE ("vectors-delete",          vectors);
 
286
  SET_SENSITIVE ("vectors-merge-visible",   n_vectors > 1);
 
287
 
 
288
  SET_SENSITIVE ("vectors-raise",           vectors && prev);
 
289
  SET_SENSITIVE ("vectors-raise-to-top",    vectors && prev);
 
290
  SET_SENSITIVE ("vectors-lower",           vectors && next);
 
291
  SET_SENSITIVE ("vectors-lower-to-bottom", vectors && next);
 
292
 
 
293
  SET_SENSITIVE ("vectors-copy",   vectors);
 
294
  SET_SENSITIVE ("vectors-paste",  global_buf);
 
295
  SET_SENSITIVE ("vectors-import", gimage);
 
296
  SET_SENSITIVE ("vectors-export", vectors);
 
297
 
 
298
  SET_SENSITIVE ("vectors-visible", vectors);
 
299
  SET_SENSITIVE ("vectors-linked",  vectors);
 
300
 
 
301
  SET_ACTIVE ("vectors-visible", visible);
 
302
  SET_ACTIVE ("vectors-linked",  linked);
 
303
 
 
304
  SET_SENSITIVE ("vectors-selection-to-vectors",          gimage && !mask_empty);
 
305
  SET_SENSITIVE ("vectors-selection-to-vectors-short",    gimage && !mask_empty);
 
306
  SET_SENSITIVE ("vectors-selection-to-vectors-advanced", gimage && !mask_empty);
 
307
  SET_SENSITIVE ("vectors-stroke",                        vectors);
 
308
  SET_SENSITIVE ("vectors-stroke-last-values",            vectors);
 
309
 
 
310
  SET_SENSITIVE ("vectors-selection-replace",      vectors);
 
311
  SET_SENSITIVE ("vectors-selection-from-vectors", vectors);
 
312
  SET_SENSITIVE ("vectors-selection-add",          vectors);
 
313
  SET_SENSITIVE ("vectors-selection-subtract",     vectors);
 
314
  SET_SENSITIVE ("vectors-selection-intersect",    vectors);
 
315
 
 
316
#undef SET_SENSITIVE
 
317
#undef SET_ACTIVE
 
318
}