47
51
/* local function prototypes */
49
static void plug_in_actions_last_changed (Gimp *gimp,
50
GimpActionGroup *group);
51
static gboolean plug_in_actions_check_translation (const gchar *original,
52
const gchar *translated);
53
static void plug_in_actions_build_path (GimpActionGroup *group,
54
const gchar *original,
55
const gchar *translated);
53
static void plug_in_actions_menu_branch_added (GimpPlugInManager *manager,
54
const gchar *progname,
55
const gchar *menu_path,
56
const gchar *menu_label,
57
GimpActionGroup *group);
58
static void plug_in_actions_register_procedure (GimpPDB *pdb,
59
GimpProcedure *procedure,
60
GimpActionGroup *group);
61
static void plug_in_actions_unregister_procedure (GimpPDB *pdb,
62
GimpProcedure *procedure,
63
GimpActionGroup *group);
64
static void plug_in_actions_menu_path_added (GimpPlugInProcedure *proc,
65
const gchar *menu_path,
66
GimpActionGroup *group);
67
static void plug_in_actions_add_proc (GimpActionGroup *group,
68
GimpPlugInProcedure *proc);
70
static void plug_in_actions_history_changed (GimpPlugInManager *manager,
71
GimpActionGroup *group);
72
static gboolean plug_in_actions_check_translation (const gchar *original,
73
const gchar *translated);
74
static void plug_in_actions_build_path (GimpActionGroup *group,
75
const gchar *original,
76
const gchar *translated);
58
79
/* private variables */
60
static GimpActionEntry plug_in_actions[] =
81
static const GimpActionEntry plug_in_actions[] =
62
{ "plug-in-menu", NULL, N_("Filte_rs") },
63
{ "plug-in-blur-menu", NULL, N_("_Blur") },
64
{ "plug-in-colors-menu", NULL, N_("_Colors") },
65
{ "plug-in-colors-map-menu", NULL, N_("Ma_p") },
66
{ "plug-in-noise-menu", NULL, N_("_Noise") },
67
{ "plug-in-edge-detect-menu", NULL, N_("Edge-De_tect") },
68
{ "plug-in-enhance-menu", NULL, N_("En_hance") },
69
{ "plug-in-generic-menu", NULL, N_("_Generic") },
70
{ "plug-in-glass-effects-menu", NULL, N_("Gla_ss Effects") },
71
{ "plug-in-light-effects-menu", NULL, N_("_Light Effects") },
72
{ "plug-in-distorts-menu", NULL, N_("_Distorts") },
73
{ "plug-in-artistic-menu", NULL, N_("_Artistic") },
74
{ "plug-in-map-menu", NULL, N_("_Map") },
75
{ "plug-in-render-menu", NULL, N_("_Render") },
76
{ "plug-in-render-clouds-menu", NULL, N_("_Clouds") },
77
{ "plug-in-render-nature-menu", NULL, N_("_Nature") },
78
{ "plug-in-render-pattern-menu", NULL, N_("_Pattern") },
79
{ "plug-in-web-menu", NULL, N_("_Web") },
80
{ "plug-in-animation-menu", NULL, N_("An_imation") },
81
{ "plug-in-combine-menu", NULL, N_("C_ombine") },
82
{ "plug-in-toys-menu", NULL, N_("To_ys") },
83
{ "plug-in-menu", NULL, N_("Filte_rs") },
84
{ "plug-in-recent-menu", NULL, N_("Recently Used") },
85
{ "plug-in-blur-menu", NULL, N_("_Blur") },
86
{ "plug-in-noise-menu", NULL, N_("_Noise") },
87
{ "plug-in-edge-detect-menu", NULL, N_("Edge-De_tect") },
88
{ "plug-in-enhance-menu", NULL, N_("En_hance") },
89
{ "plug-in-combine-menu", NULL, N_("C_ombine") },
90
{ "plug-in-generic-menu", NULL, N_("_Generic") },
91
{ "plug-in-light-shadow-menu", NULL, N_("_Light and Shadow") },
92
{ "plug-in-distorts-menu", NULL, N_("_Distorts") },
93
{ "plug-in-artistic-menu", NULL, N_("_Artistic") },
94
{ "plug-in-map-menu", NULL, N_("_Map") },
95
{ "plug-in-render-menu", NULL, N_("_Render") },
96
{ "plug-in-render-clouds-menu", NULL, N_("_Clouds") },
97
{ "plug-in-render-nature-menu", NULL, N_("_Nature") },
98
{ "plug-in-render-pattern-menu", NULL, N_("_Pattern") },
99
{ "plug-in-web-menu", NULL, N_("_Web") },
100
{ "plug-in-animation-menu", NULL, N_("An_imation") },
84
102
{ "plug-in-reset-all", GIMP_STOCK_RESET,
85
N_("Reset all Filters..."), NULL, NULL,
103
N_("Reset all _Filters"), NULL,
104
N_("Reset all plug-ins to their default settings"),
86
105
G_CALLBACK (plug_in_reset_all_cmd_callback),
87
106
GIMP_HELP_FILTER_RESET_ALL }
90
static GimpEnumActionEntry plug_in_repeat_actions[] =
109
static const GimpEnumActionEntry plug_in_repeat_actions[] =
92
111
{ "plug-in-repeat", GTK_STOCK_EXECUTE,
93
N_("Repeat Last"), "<control>F", NULL,
112
N_("Re_peat Last"), "<control>F",
113
N_("Rerun the last used plug-in using the same settings"),
114
GIMP_RUN_WITH_LAST_VALS, FALSE,
95
115
GIMP_HELP_FILTER_REPEAT },
97
117
{ "plug-in-reshow", GIMP_STOCK_RESHOW_FILTER,
98
N_("Re-Show Last"), "<control><shift>F", NULL,
118
N_("R_e-Show Last"), "<control><shift>F",
119
N_("Show the last used plug-in dialog again"),
120
GIMP_RUN_INTERACTIVE, FALSE,
100
121
GIMP_HELP_FILTER_RESHOW }
117
141
G_N_ELEMENTS (plug_in_repeat_actions),
118
142
G_CALLBACK (plug_in_repeat_cmd_callback));
120
for (list = group->gimp->plug_in_proc_defs;
122
list = g_slist_next (list))
124
PlugInProcDef *proc_def = list->data;
126
if (proc_def->prog &&
127
proc_def->menu_paths &&
128
! proc_def->extensions &&
129
! proc_def->prefixes &&
132
plug_in_actions_add_proc (group, proc_def);
136
g_signal_connect_object (group->gimp, "last-plug-in-changed",
137
G_CALLBACK (plug_in_actions_last_changed),
139
plug_in_actions_last_changed (group->gimp, group);
144
for (list = group->gimp->plug_in_manager->menu_branches;
146
list = g_slist_next (list))
148
GimpPlugInMenuBranch *branch = list->data;
150
plug_in_actions_menu_branch_added (group->gimp->plug_in_manager,
157
g_signal_connect_object (group->gimp->plug_in_manager,
159
G_CALLBACK (plug_in_actions_menu_branch_added),
162
for (list = group->gimp->plug_in_manager->plug_in_procedures;
164
list = g_slist_next (list))
166
GimpPlugInProcedure *plug_in_proc = list->data;
168
if (plug_in_proc->prog)
169
plug_in_actions_register_procedure (group->gimp->pdb,
170
GIMP_PROCEDURE (plug_in_proc),
174
g_signal_connect_object (group->gimp->pdb, "register-procedure",
175
G_CALLBACK (plug_in_actions_register_procedure),
177
g_signal_connect_object (group->gimp->pdb, "unregister-procedure",
178
G_CALLBACK (plug_in_actions_unregister_procedure),
181
n_entries = gimp_plug_in_manager_history_size (group->gimp->plug_in_manager);
183
entries = g_new0 (GimpPlugInActionEntry, n_entries);
185
for (i = 0; i < n_entries; i++)
187
entries[i].name = g_strdup_printf ("plug-in-recent-%02d", i + 1);
188
entries[i].stock_id = NULL;
189
entries[i].label = "";
190
entries[i].accelerator = "";
191
entries[i].tooltip = NULL;
192
entries[i].procedure = NULL;
193
entries[i].help_id = GIMP_HELP_FILTER_RESHOW;
196
gimp_action_group_add_plug_in_actions (group, entries, n_entries,
197
G_CALLBACK (plug_in_history_cmd_callback));
199
for (i = 0; i < n_entries; i++)
201
gimp_action_group_set_action_visible (group, entries[i].name, FALSE);
202
g_free ((gchar *) entries[i].name);
207
g_signal_connect_object (group->gimp->plug_in_manager, "history-changed",
208
G_CALLBACK (plug_in_actions_history_changed),
211
plug_in_actions_history_changed (group->gimp->plug_in_manager, group);
143
215
plug_in_actions_update (GimpActionGroup *group,
146
GimpImage *gimage = action_data_get_image (data);
147
GimpImageType type = -1;
218
GimpImage *image = action_data_get_image (data);
219
GimpPlugInManager *manager;
220
GimpImageType type = -1;
224
manager = group->gimp->plug_in_manager;
152
GimpDrawable *drawable = gimp_image_active_drawable (gimage);
228
GimpDrawable *drawable = gimp_image_active_drawable (image);
155
231
type = gimp_drawable_type (drawable);
158
for (list = group->gimp->plug_in_proc_defs;
160
list = g_slist_next (list))
234
for (list = manager->plug_in_procedures; list; list = g_slist_next (list))
162
PlugInProcDef *proc_def = list->data;
236
GimpPlugInProcedure *proc = list->data;
164
if (proc_def->menu_paths &&
165
proc_def->image_types_val &&
166
! proc_def->extensions &&
167
! proc_def->prefixes &&
238
if ((proc->menu_label || proc->menu_paths) &&
240
proc->image_types_val)
170
gboolean sensitive = plug_in_proc_def_get_sensitive (proc_def, type);
242
gboolean sensitive = gimp_plug_in_procedure_get_sensitive (proc, type);
172
244
gimp_action_group_set_action_sensitive (group,
173
proc_def->db_info.name,
245
GIMP_OBJECT (proc)->name,
178
if (group->gimp->last_plug_in &&
179
plug_in_proc_def_get_sensitive (group->gimp->last_plug_in, type))
250
if (manager->history &&
251
gimp_plug_in_procedure_get_sensitive (manager->history->data, type))
181
253
gimp_action_group_set_action_sensitive (group, "plug-in-repeat", TRUE);
182
254
gimp_action_group_set_action_sensitive (group, "plug-in-reshow", TRUE);
186
258
gimp_action_group_set_action_sensitive (group, "plug-in-repeat", FALSE);
187
259
gimp_action_group_set_action_sensitive (group, "plug-in-reshow", FALSE);
192
plug_in_actions_add_proc (GimpActionGroup *group,
193
PlugInProcDef *proc_def)
262
for (list = manager->history, i = 0; list; list = list->next, i++)
264
GimpPlugInProcedure *proc = list->data;
265
gchar *name = g_strdup_printf ("plug-in-recent-%02d",
269
sensitive = gimp_plug_in_procedure_get_sensitive (proc, type);
271
gimp_action_group_set_action_sensitive (group, name, sensitive);
278
/* private functions */
281
plug_in_actions_menu_branch_added (GimpPlugInManager *manager,
282
const gchar *progname,
283
const gchar *menu_path,
284
const gchar *menu_label,
285
GimpActionGroup *group)
287
const gchar *locale_domain;
288
const gchar *path_translated;
289
const gchar *label_translated;
291
gchar *full_translated;
294
gimp_plug_in_manager_get_locale_domain (group->gimp->plug_in_manager,
297
path_translated = dgettext (locale_domain, menu_path);
298
label_translated = dgettext (locale_domain, menu_label);
300
full = g_strconcat (menu_path, "/", menu_label, NULL);
301
full_translated = g_strconcat (path_translated, "/", label_translated, NULL);
303
if (plug_in_actions_check_translation (full, full_translated))
304
plug_in_actions_build_path (group, full, full_translated);
306
plug_in_actions_build_path (group, full, full);
308
g_free (full_translated);
313
plug_in_actions_register_procedure (GimpPDB *pdb,
314
GimpProcedure *procedure,
315
GimpActionGroup *group)
317
if (GIMP_IS_PLUG_IN_PROCEDURE (procedure))
319
GimpPlugInProcedure *plug_in_proc = GIMP_PLUG_IN_PROCEDURE (procedure);
321
g_signal_connect_object (plug_in_proc, "menu-path-added",
322
G_CALLBACK (plug_in_actions_menu_path_added),
325
if ((plug_in_proc->menu_label || plug_in_proc->menu_paths) &&
326
! plug_in_proc->file_proc)
329
g_print ("%s: %s\n", G_STRFUNC,
330
gimp_object_get_name (GIMP_OBJECT (procedure)));
333
plug_in_actions_add_proc (group, plug_in_proc);
339
plug_in_actions_unregister_procedure (GimpPDB *pdb,
340
GimpProcedure *procedure,
341
GimpActionGroup *group)
343
if (GIMP_IS_PLUG_IN_PROCEDURE (procedure))
345
GimpPlugInProcedure *plug_in_proc = GIMP_PLUG_IN_PROCEDURE (procedure);
347
g_signal_handlers_disconnect_by_func (plug_in_proc,
348
plug_in_actions_menu_path_added,
351
if ((plug_in_proc->menu_label || plug_in_proc->menu_paths) &&
352
! plug_in_proc->file_proc)
357
g_print ("%s: %s\n", G_STRFUNC,
358
gimp_object_get_name (GIMP_OBJECT (procedure)));
361
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group),
362
GIMP_OBJECT (procedure)->name);
365
gtk_action_group_remove_action (GTK_ACTION_GROUP (group), action);
371
plug_in_actions_menu_path_added (GimpPlugInProcedure *plug_in_proc,
372
const gchar *menu_path,
373
GimpActionGroup *group)
375
const gchar *locale_domain;
376
const gchar *path_translated;
379
g_print ("%s: %s (%s)\n", G_STRFUNC,
380
gimp_object_get_name (GIMP_OBJECT (plug_in_proc)), menu_path);
383
locale_domain = gimp_plug_in_procedure_get_locale_domain (plug_in_proc);
385
path_translated = dgettext (locale_domain, menu_path);
387
if (plug_in_actions_check_translation (menu_path, path_translated))
388
plug_in_actions_build_path (group, menu_path, path_translated);
390
plug_in_actions_build_path (group, menu_path, menu_path);
394
plug_in_actions_add_proc (GimpActionGroup *group,
395
GimpPlugInProcedure *proc)
195
397
GimpPlugInActionEntry entry;
196
const gchar *progname;
197
398
const gchar *locale_domain;
198
const gchar *help_domain;
199
const gchar *label_translated;
200
400
gchar *path_original = NULL;
201
401
gchar *path_translated = NULL;
203
g_return_if_fail (GIMP_IS_ACTION_GROUP (group));
204
g_return_if_fail (proc_def != NULL);
206
progname = plug_in_proc_def_get_progname (proc_def);
208
locale_domain = plug_ins_locale_domain (group->gimp, progname, NULL);
209
help_domain = plug_ins_help_domain (group->gimp, progname, NULL);
211
if (proc_def->menu_label)
403
locale_domain = gimp_plug_in_procedure_get_locale_domain (proc);
405
if (proc->menu_label)
213
label_translated = dgettext (locale_domain, proc_def->menu_label);
407
label = dgettext (locale_domain, proc->menu_label);
219
path_original = proc_def->menu_paths->data;
413
path_original = proc->menu_paths->data;
220
414
path_translated = dgettext (locale_domain, path_original);
222
416
path_original = g_strdup (path_original);
281
plug_in_actions_add_path (GimpActionGroup *group,
282
PlugInProcDef *proc_def,
283
const gchar *menu_path)
285
const gchar *progname;
286
const gchar *locale_domain;
287
gchar *path_translated = NULL;
289
g_return_if_fail (GIMP_IS_ACTION_GROUP (group));
290
g_return_if_fail (proc_def != NULL);
291
g_return_if_fail (menu_path != NULL);
293
progname = plug_in_proc_def_get_progname (proc_def);
295
locale_domain = plug_ins_locale_domain (group->gimp, progname, NULL);
297
path_translated = dgettext (locale_domain, menu_path);
299
if (plug_in_actions_check_translation (menu_path, path_translated))
300
plug_in_actions_build_path (group, menu_path, path_translated);
302
plug_in_actions_build_path (group, menu_path, menu_path);
306
plug_in_actions_remove_proc (GimpActionGroup *group,
307
PlugInProcDef *proc_def)
311
g_return_if_fail (GIMP_IS_ACTION_GROUP (group));
312
g_return_if_fail (proc_def != NULL);
314
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group),
315
proc_def->db_info.name);
320
g_print ("removing plug-in action '%s'\n",
321
proc_def->db_info.name);
324
gtk_action_group_remove_action (GTK_ACTION_GROUP (group), action);
329
/* private functions */
332
plug_in_actions_last_changed (Gimp *gimp,
333
GimpActionGroup *group)
475
plug_in_actions_history_changed (GimpPlugInManager *manager,
476
GimpActionGroup *group)
335
if (gimp->last_plug_in)
478
GimpPlugInProcedure *proc;
481
proc = gimp_plug_in_manager_history_nth (manager, 0);
337
PlugInProcDef *proc_def = gimp->last_plug_in;
338
const gchar *progname;
344
progname = plug_in_proc_def_get_progname (proc_def);
345
domain = plug_ins_locale_domain (group->gimp, progname, NULL);
347
label = plug_in_proc_def_get_label (proc_def, domain);
489
label = gimp_plug_in_procedure_get_label (proc);
349
491
repeat = g_strdup_printf (_("Re_peat \"%s\""), label);
350
reshow = g_strdup_printf (_("R_e-show \"%s\""), label);
492
reshow = g_strdup_printf (_("R_e-Show \"%s\""), label);
354
494
gimp_action_group_set_action_label (group, "plug-in-repeat", repeat);
355
495
gimp_action_group_set_action_label (group, "plug-in-reshow", reshow);