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 "actions-types.h"
27
#include "core/gimpchannel.h"
28
#include "core/gimpimage.h"
29
#include "core/gimplist.h"
31
#include "widgets/gimpactiongroup.h"
32
#include "widgets/gimphelp-ids.h"
35
#include "vectors-actions.h"
36
#include "vectors-commands.h"
38
#include "gimp-intl.h"
41
static GimpActionEntry vectors_actions[] =
43
{ "vectors-popup", GIMP_STOCK_PATHS,
44
N_("Paths Menu"), NULL, NULL, NULL,
45
GIMP_HELP_PATH_DIALOG },
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 },
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 },
58
{ "vectors-new", GTK_STOCK_NEW,
59
N_("_New Path..."), "",
61
G_CALLBACK (vectors_new_cmd_callback),
64
{ "vectors-new-last-values", GTK_STOCK_NEW,
66
N_("New path with last values"),
67
G_CALLBACK (vectors_new_last_vals_cmd_callback),
70
{ "vectors-duplicate", GIMP_STOCK_DUPLICATE,
71
N_("D_uplicate Path"), NULL,
73
G_CALLBACK (vectors_duplicate_cmd_callback),
74
GIMP_HELP_PATH_DUPLICATE },
76
{ "vectors-delete", GTK_STOCK_DELETE,
77
N_("_Delete Path"), "",
79
G_CALLBACK (vectors_delete_cmd_callback),
80
GIMP_HELP_PATH_DELETE },
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 },
87
{ "vectors-raise", GTK_STOCK_GO_UP,
88
N_("_Raise Path"), "",
90
G_CALLBACK (vectors_raise_cmd_callback),
91
GIMP_HELP_PATH_RAISE },
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 },
99
{ "vectors-lower", GTK_STOCK_GO_DOWN,
100
N_("_Lower Path"), "",
102
G_CALLBACK (vectors_lower_cmd_callback),
103
GIMP_HELP_PATH_LOWER },
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 },
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 },
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 },
123
{ "vectors-copy", GTK_STOCK_COPY,
124
N_("Co_py Path"), "", NULL,
125
G_CALLBACK (vectors_copy_cmd_callback),
126
GIMP_HELP_PATH_COPY },
128
{ "vectors-paste", GTK_STOCK_PASTE,
129
N_("Paste Pat_h"), "", NULL,
130
G_CALLBACK (vectors_paste_cmd_callback),
131
GIMP_HELP_PATH_PASTE },
133
{ "vectors-import", GTK_STOCK_OPEN,
134
N_("I_mport Path..."), "", NULL,
135
G_CALLBACK (vectors_import_cmd_callback),
136
GIMP_HELP_PATH_IMPORT },
138
{ "vectors-export", GTK_STOCK_SAVE,
139
N_("E_xport Path..."), "", NULL,
140
G_CALLBACK (vectors_export_cmd_callback),
141
GIMP_HELP_PATH_EXPORT }
144
static GimpToggleActionEntry vectors_toggle_actions[] =
146
{ "vectors-visible", GIMP_STOCK_VISIBLE,
147
N_("_Visible"), NULL, NULL,
148
G_CALLBACK (vectors_visible_cmd_callback),
150
GIMP_HELP_PATH_VISIBLE },
152
{ "vectors-linked", GIMP_STOCK_LINKED,
153
N_("_Linked"), NULL, NULL,
154
G_CALLBACK (vectors_linked_cmd_callback),
156
GIMP_HELP_PATH_LINKED }
159
static GimpEnumActionEntry vectors_to_selection_actions[] =
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 },
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 },
172
{ "vectors-selection-add", GIMP_STOCK_SELECTION_ADD,
173
N_("_Add to Selection"), NULL,
175
GIMP_CHANNEL_OP_ADD, FALSE,
176
GIMP_HELP_PATH_SELECTION_ADD },
178
{ "vectors-selection-subtract", GIMP_STOCK_SELECTION_SUBTRACT,
179
N_("_Subtract from Selection"), NULL,
181
GIMP_CHANNEL_OP_SUBTRACT, FALSE,
182
GIMP_HELP_PATH_SELECTION_SUBTRACT },
184
{ "vectors-selection-intersect", GIMP_STOCK_SELECTION_INTERSECT,
185
N_("_Intersect with Selection"), NULL,
187
GIMP_CHANNEL_OP_INTERSECT, FALSE,
188
GIMP_HELP_PATH_SELECTION_INTERSECT }
191
static GimpEnumActionEntry vectors_selection_to_vectors_actions[] =
193
{ "vectors-selection-to-vectors", GIMP_STOCK_SELECTION_TO_PATH,
194
N_("Selecti_on to Path"), NULL,
195
N_("Selection to path"),
197
GIMP_HELP_SELECTION_TO_PATH },
199
{ "vectors-selection-to-vectors-short", GIMP_STOCK_SELECTION_TO_PATH,
200
N_("To _Path"), NULL, NULL,
202
GIMP_HELP_SELECTION_TO_PATH },
204
{ "vectors-selection-to-vectors-advanced", GIMP_STOCK_SELECTION_TO_PATH,
205
N_("Selection to Path (_Advanced)"), NULL,
206
N_("Advanced options"),
208
GIMP_HELP_SELECTION_TO_PATH }
213
vectors_actions_setup (GimpActionGroup *group)
215
gimp_action_group_add_actions (group,
217
G_N_ELEMENTS (vectors_actions));
219
gimp_action_group_add_toggle_actions (group,
220
vectors_toggle_actions,
221
G_N_ELEMENTS (vectors_toggle_actions));
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));
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));
235
vectors_actions_update (GimpActionGroup *group,
238
GimpImage *gimage = action_data_get_image (data);
239
GimpVectors *vectors = NULL;
241
gboolean mask_empty = TRUE;
242
gboolean global_buf = FALSE;
243
gboolean visible = FALSE;
244
gboolean linked = FALSE;
250
n_vectors = gimp_container_num_children (gimage->vectors);
251
mask_empty = gimp_channel_is_empty (gimp_image_get_mask (gimage));
254
vectors = gimp_image_get_active_vectors (gimage);
258
GimpItem *item = GIMP_ITEM (vectors);
261
visible = gimp_item_get_visible (item);
262
linked = gimp_item_get_linked (item);
264
list = g_list_find (GIMP_LIST (gimage->vectors)->list, vectors);
268
prev = g_list_previous (list);
269
next = g_list_next (list);
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)
279
SET_SENSITIVE ("vectors-path-tool", vectors);
280
SET_SENSITIVE ("vectors-edit-attributes", vectors);
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);
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);
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);
298
SET_SENSITIVE ("vectors-visible", vectors);
299
SET_SENSITIVE ("vectors-linked", vectors);
301
SET_ACTIVE ("vectors-visible", visible);
302
SET_ACTIVE ("vectors-linked", linked);
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);
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);