~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to app/actions/plug-in-actions.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* The GIMP -- an image manipulation program
 
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify
31
31
#include "core/gimpdrawable.h"
32
32
#include "core/gimpimage.h"
33
33
 
34
 
#include "plug-in/plug-ins.h"
35
 
#include "plug-in/plug-in-proc-def.h"
 
34
#include "plug-in/gimppluginmanager.h"
 
35
#include "plug-in/gimppluginmanager-help-domain.h"
 
36
#include "plug-in/gimppluginmanager-history.h"
 
37
#include "plug-in/gimppluginmanager-locale-domain.h"
 
38
#include "plug-in/gimppluginmanager-menu-branch.h"
 
39
#include "plug-in/gimppluginprocedure.h"
36
40
 
37
41
#include "widgets/gimpactiongroup.h"
38
42
#include "widgets/gimphelp-ids.h"
46
50
 
47
51
/*  local function prototypes  */
48
52
 
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);
 
69
 
 
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);
56
77
 
57
78
 
58
79
/*  private variables  */
59
80
 
60
 
static GimpActionEntry plug_in_actions[] =
 
81
static const GimpActionEntry plug_in_actions[] =
61
82
{
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")        },
83
101
 
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 }
88
107
};
89
108
 
90
 
static GimpEnumActionEntry plug_in_repeat_actions[] =
 
109
static const GimpEnumActionEntry plug_in_repeat_actions[] =
91
110
{
92
111
  { "plug-in-repeat", GTK_STOCK_EXECUTE,
93
 
    N_("Repeat Last"), "<control>F", NULL,
94
 
    FALSE, FALSE,
 
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 },
96
116
 
97
117
  { "plug-in-reshow", GIMP_STOCK_RESHOW_FILTER,
98
 
    N_("Re-Show Last"), "<control><shift>F", NULL,
99
 
    TRUE, FALSE,
 
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 }
101
122
};
102
123
 
106
127
void
107
128
plug_in_actions_setup (GimpActionGroup *group)
108
129
{
109
 
  GSList *list;
 
130
  GimpPlugInActionEntry *entries;
 
131
  GSList                *list;
 
132
  gint                   n_entries;
 
133
  gint                   i;
110
134
 
111
135
  gimp_action_group_add_actions (group,
112
136
                                 plug_in_actions,
117
141
                                      G_N_ELEMENTS (plug_in_repeat_actions),
118
142
                                      G_CALLBACK (plug_in_repeat_cmd_callback));
119
143
 
120
 
  for (list = group->gimp->plug_in_proc_defs;
121
 
       list;
122
 
       list = g_slist_next (list))
123
 
    {
124
 
      PlugInProcDef *proc_def = list->data;
125
 
 
126
 
      if (proc_def->prog         &&
127
 
          proc_def->menu_paths   &&
128
 
          ! proc_def->extensions &&
129
 
          ! proc_def->prefixes   &&
130
 
          ! proc_def->magics)
131
 
        {
132
 
          plug_in_actions_add_proc (group, proc_def);
133
 
        }
134
 
    }
135
 
 
136
 
  g_signal_connect_object (group->gimp, "last-plug-in-changed",
137
 
                           G_CALLBACK (plug_in_actions_last_changed),
138
 
                           group, 0);
139
 
  plug_in_actions_last_changed (group->gimp, group);
 
144
  for (list = group->gimp->plug_in_manager->menu_branches;
 
145
       list;
 
146
       list = g_slist_next (list))
 
147
    {
 
148
      GimpPlugInMenuBranch *branch = list->data;
 
149
 
 
150
      plug_in_actions_menu_branch_added (group->gimp->plug_in_manager,
 
151
                                         branch->prog_name,
 
152
                                         branch->menu_path,
 
153
                                         branch->menu_label,
 
154
                                         group);
 
155
    }
 
156
 
 
157
  g_signal_connect_object (group->gimp->plug_in_manager,
 
158
                           "menu-branch-added",
 
159
                           G_CALLBACK (plug_in_actions_menu_branch_added),
 
160
                           group, 0);
 
161
 
 
162
  for (list = group->gimp->plug_in_manager->plug_in_procedures;
 
163
       list;
 
164
       list = g_slist_next (list))
 
165
    {
 
166
      GimpPlugInProcedure *plug_in_proc = list->data;
 
167
 
 
168
      if (plug_in_proc->prog)
 
169
        plug_in_actions_register_procedure (group->gimp->pdb,
 
170
                                            GIMP_PROCEDURE (plug_in_proc),
 
171
                                            group);
 
172
    }
 
173
 
 
174
  g_signal_connect_object (group->gimp->pdb, "register-procedure",
 
175
                           G_CALLBACK (plug_in_actions_register_procedure),
 
176
                           group, 0);
 
177
  g_signal_connect_object (group->gimp->pdb, "unregister-procedure",
 
178
                           G_CALLBACK (plug_in_actions_unregister_procedure),
 
179
                           group, 0);
 
180
 
 
181
  n_entries = gimp_plug_in_manager_history_size (group->gimp->plug_in_manager);
 
182
 
 
183
  entries = g_new0 (GimpPlugInActionEntry, n_entries);
 
184
 
 
185
  for (i = 0; i < n_entries; i++)
 
186
    {
 
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;
 
194
    }
 
195
 
 
196
  gimp_action_group_add_plug_in_actions (group, entries, n_entries,
 
197
                                         G_CALLBACK (plug_in_history_cmd_callback));
 
198
 
 
199
  for (i = 0; i < n_entries; i++)
 
200
    {
 
201
      gimp_action_group_set_action_visible (group, entries[i].name, FALSE);
 
202
      g_free ((gchar *) entries[i].name);
 
203
    }
 
204
 
 
205
  g_free (entries);
 
206
 
 
207
  g_signal_connect_object (group->gimp->plug_in_manager, "history-changed",
 
208
                           G_CALLBACK (plug_in_actions_history_changed),
 
209
                           group, 0);
 
210
 
 
211
  plug_in_actions_history_changed (group->gimp->plug_in_manager, group);
140
212
}
141
213
 
142
214
void
143
215
plug_in_actions_update (GimpActionGroup *group,
144
216
                        gpointer         data)
145
217
{
146
 
  GimpImage     *gimage = action_data_get_image (data);
147
 
  GimpImageType  type   = -1;
148
 
  GSList        *list;
149
 
 
150
 
  if (gimage)
 
218
  GimpImage         *image = action_data_get_image (data);
 
219
  GimpPlugInManager *manager;
 
220
  GimpImageType      type  = -1;
 
221
  GSList            *list;
 
222
  gint               i;
 
223
 
 
224
  manager = group->gimp->plug_in_manager;
 
225
 
 
226
  if (image)
151
227
    {
152
 
      GimpDrawable *drawable = gimp_image_active_drawable (gimage);
 
228
      GimpDrawable *drawable = gimp_image_active_drawable (image);
153
229
 
154
230
      if (drawable)
155
231
        type = gimp_drawable_type (drawable);
156
232
    }
157
233
 
158
 
  for (list = group->gimp->plug_in_proc_defs;
159
 
       list;
160
 
       list = g_slist_next (list))
 
234
  for (list = manager->plug_in_procedures; list; list = g_slist_next (list))
161
235
    {
162
 
      PlugInProcDef *proc_def = list->data;
 
236
      GimpPlugInProcedure *proc = list->data;
163
237
 
164
 
      if (proc_def->menu_paths      &&
165
 
          proc_def->image_types_val &&
166
 
          ! proc_def->extensions    &&
167
 
          ! proc_def->prefixes      &&
168
 
          ! proc_def->magics)
 
238
      if ((proc->menu_label || proc->menu_paths) &&
 
239
          ! proc->file_proc                      &&
 
240
          proc->image_types_val)
169
241
        {
170
 
          gboolean sensitive = plug_in_proc_def_get_sensitive (proc_def, type);
 
242
          gboolean sensitive = gimp_plug_in_procedure_get_sensitive (proc, type);
171
243
 
172
244
          gimp_action_group_set_action_sensitive (group,
173
 
                                                  proc_def->db_info.name,
 
245
                                                  GIMP_OBJECT (proc)->name,
174
246
                                                  sensitive);
175
 
        }
 
247
        }
176
248
    }
177
249
 
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))
180
252
    {
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);
188
260
    }
189
 
}
190
 
 
191
 
void
192
 
plug_in_actions_add_proc (GimpActionGroup *group,
193
 
                          PlugInProcDef   *proc_def)
 
261
 
 
262
  for (list = manager->history, i = 0; list; list = list->next, i++)
 
263
    {
 
264
      GimpPlugInProcedure *proc = list->data;
 
265
      gchar               *name = g_strdup_printf ("plug-in-recent-%02d",
 
266
                                                   i + 1);
 
267
      gboolean             sensitive;
 
268
 
 
269
      sensitive = gimp_plug_in_procedure_get_sensitive (proc, type);
 
270
 
 
271
      gimp_action_group_set_action_sensitive (group, name, sensitive);
 
272
 
 
273
      g_free (name);
 
274
    }
 
275
}
 
276
 
 
277
 
 
278
/*  private functions  */
 
279
 
 
280
static void
 
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)
 
286
{
 
287
  const gchar *locale_domain;
 
288
  const gchar *path_translated;
 
289
  const gchar *label_translated;
 
290
  gchar       *full;
 
291
  gchar       *full_translated;
 
292
 
 
293
  locale_domain =
 
294
    gimp_plug_in_manager_get_locale_domain (group->gimp->plug_in_manager,
 
295
                                            progname, NULL);
 
296
 
 
297
  path_translated  = dgettext (locale_domain, menu_path);
 
298
  label_translated = dgettext (locale_domain, menu_label);
 
299
 
 
300
  full            = g_strconcat (menu_path,       "/", menu_label,       NULL);
 
301
  full_translated = g_strconcat (path_translated, "/", label_translated, NULL);
 
302
 
 
303
  if (plug_in_actions_check_translation (full, full_translated))
 
304
    plug_in_actions_build_path (group, full, full_translated);
 
305
  else
 
306
    plug_in_actions_build_path (group, full, full);
 
307
 
 
308
  g_free (full_translated);
 
309
  g_free (full);
 
310
}
 
311
 
 
312
static void
 
313
plug_in_actions_register_procedure (GimpPDB         *pdb,
 
314
                                    GimpProcedure   *procedure,
 
315
                                    GimpActionGroup *group)
 
316
{
 
317
  if (GIMP_IS_PLUG_IN_PROCEDURE (procedure))
 
318
    {
 
319
      GimpPlugInProcedure *plug_in_proc = GIMP_PLUG_IN_PROCEDURE (procedure);
 
320
 
 
321
      g_signal_connect_object (plug_in_proc, "menu-path-added",
 
322
                               G_CALLBACK (plug_in_actions_menu_path_added),
 
323
                               group, 0);
 
324
 
 
325
      if ((plug_in_proc->menu_label || plug_in_proc->menu_paths) &&
 
326
          ! plug_in_proc->file_proc)
 
327
        {
 
328
#if 0
 
329
          g_print ("%s: %s\n", G_STRFUNC,
 
330
                   gimp_object_get_name (GIMP_OBJECT (procedure)));
 
331
#endif
 
332
 
 
333
          plug_in_actions_add_proc (group, plug_in_proc);
 
334
        }
 
335
    }
 
336
}
 
337
 
 
338
static void
 
339
plug_in_actions_unregister_procedure (GimpPDB         *pdb,
 
340
                                      GimpProcedure   *procedure,
 
341
                                      GimpActionGroup *group)
 
342
{
 
343
  if (GIMP_IS_PLUG_IN_PROCEDURE (procedure))
 
344
    {
 
345
      GimpPlugInProcedure *plug_in_proc = GIMP_PLUG_IN_PROCEDURE (procedure);
 
346
 
 
347
      g_signal_handlers_disconnect_by_func (plug_in_proc,
 
348
                                            plug_in_actions_menu_path_added,
 
349
                                            group);
 
350
 
 
351
      if ((plug_in_proc->menu_label || plug_in_proc->menu_paths) &&
 
352
          ! plug_in_proc->file_proc)
 
353
        {
 
354
          GtkAction *action;
 
355
 
 
356
#if 0
 
357
          g_print ("%s: %s\n", G_STRFUNC,
 
358
                   gimp_object_get_name (GIMP_OBJECT (procedure)));
 
359
#endif
 
360
 
 
361
          action = gtk_action_group_get_action (GTK_ACTION_GROUP (group),
 
362
                                                GIMP_OBJECT (procedure)->name);
 
363
 
 
364
          if (action)
 
365
            gtk_action_group_remove_action (GTK_ACTION_GROUP (group), action);
 
366
        }
 
367
    }
 
368
}
 
369
 
 
370
static void
 
371
plug_in_actions_menu_path_added (GimpPlugInProcedure *plug_in_proc,
 
372
                                 const gchar         *menu_path,
 
373
                                 GimpActionGroup     *group)
 
374
{
 
375
  const gchar *locale_domain;
 
376
  const gchar *path_translated;
 
377
 
 
378
#if 0
 
379
  g_print ("%s: %s (%s)\n", G_STRFUNC,
 
380
           gimp_object_get_name (GIMP_OBJECT (plug_in_proc)), menu_path);
 
381
#endif
 
382
 
 
383
  locale_domain = gimp_plug_in_procedure_get_locale_domain (plug_in_proc);
 
384
 
 
385
  path_translated = dgettext (locale_domain, menu_path);
 
386
 
 
387
  if (plug_in_actions_check_translation (menu_path, path_translated))
 
388
    plug_in_actions_build_path (group, menu_path, path_translated);
 
389
  else
 
390
    plug_in_actions_build_path (group, menu_path, menu_path);
 
391
}
 
392
 
 
393
static void
 
394
plug_in_actions_add_proc (GimpActionGroup     *group,
 
395
                          GimpPlugInProcedure *proc)
194
396
{
195
397
  GimpPlugInActionEntry  entry;
196
 
  const gchar           *progname;
197
398
  const gchar           *locale_domain;
198
 
  const gchar           *help_domain;
199
 
  const gchar           *label_translated;
 
399
  const gchar           *label;
200
400
  gchar                 *path_original    = NULL;
201
401
  gchar                 *path_translated  = NULL;
202
402
 
203
 
  g_return_if_fail (GIMP_IS_ACTION_GROUP (group));
204
 
  g_return_if_fail (proc_def != NULL);
205
 
 
206
 
  progname = plug_in_proc_def_get_progname (proc_def);
207
 
 
208
 
  locale_domain = plug_ins_locale_domain (group->gimp, progname, NULL);
209
 
  help_domain   = plug_ins_help_domain (group->gimp, progname, NULL);
210
 
 
211
 
  if (proc_def->menu_label)
 
403
  locale_domain = gimp_plug_in_procedure_get_locale_domain (proc);
 
404
 
 
405
  if (proc->menu_label)
212
406
    {
213
 
      label_translated = dgettext (locale_domain, proc_def->menu_label);
 
407
      label = dgettext (locale_domain, proc->menu_label);
214
408
    }
215
409
  else
216
410
    {
217
411
      gchar *p1, *p2;
218
412
 
219
 
      path_original   = proc_def->menu_paths->data;
 
413
      path_original   = proc->menu_paths->data;
220
414
      path_translated = dgettext (locale_domain, path_original);
221
415
 
222
416
      path_original = g_strdup (path_original);
232
426
      *p1 = '\0';
233
427
      *p2 = '\0';
234
428
 
235
 
      label_translated = p2 + 1;
 
429
      label = p2 + 1;
236
430
    }
237
431
 
238
 
  entry.name        = proc_def->db_info.name;
239
 
  entry.stock_id    = plug_in_proc_def_get_stock_id (proc_def);
240
 
  entry.label       = label_translated;
 
432
  entry.name        = GIMP_OBJECT (proc)->name;
 
433
  entry.stock_id    = gimp_plug_in_procedure_get_stock_id (proc);
 
434
  entry.label       = label;
241
435
  entry.accelerator = NULL;
242
 
  entry.tooltip     = NULL;
243
 
  entry.proc_def    = proc_def;
244
 
  entry.help_id     = plug_in_proc_def_get_help_id (proc_def, help_domain);
 
436
  entry.tooltip     = gimp_plug_in_procedure_get_blurb (proc);
 
437
  entry.procedure   = proc;
 
438
  entry.help_id     = gimp_plug_in_procedure_get_help_id (proc);
245
439
 
246
440
#if 0
247
441
  g_print ("adding plug-in action '%s' (%s)\n",
248
 
           proc_def->db_info.name, label_translated);
 
442
           GIMP_OBJECT (proc)->name, label);
249
443
#endif
250
444
 
251
445
  gimp_action_group_add_plug_in_actions (group, &entry, 1,
253
447
 
254
448
  g_free ((gchar *) entry.help_id);
255
449
 
256
 
  if (proc_def->menu_label)
 
450
  if (proc->menu_label)
257
451
    {
258
452
      GList *list;
259
453
 
260
 
      for (list = proc_def->menu_paths; list; list = g_list_next (list))
 
454
      for (list = proc->menu_paths; list; list = g_list_next (list))
261
455
        {
262
456
          const gchar *original   = list->data;
263
457
          const gchar *translated = dgettext (locale_domain, original);
277
471
    }
278
472
}
279
473
 
280
 
void
281
 
plug_in_actions_add_path (GimpActionGroup *group,
282
 
                          PlugInProcDef   *proc_def,
283
 
                          const gchar     *menu_path)
284
 
{
285
 
  const gchar *progname;
286
 
  const gchar *locale_domain;
287
 
  gchar       *path_translated  = NULL;
288
 
 
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);
292
 
 
293
 
  progname = plug_in_proc_def_get_progname (proc_def);
294
 
 
295
 
  locale_domain = plug_ins_locale_domain (group->gimp, progname, NULL);
296
 
 
297
 
  path_translated = dgettext (locale_domain, menu_path);
298
 
 
299
 
  if (plug_in_actions_check_translation (menu_path, path_translated))
300
 
    plug_in_actions_build_path (group, menu_path, path_translated);
301
 
  else
302
 
    plug_in_actions_build_path (group, menu_path, menu_path);
303
 
}
304
 
 
305
 
void
306
 
plug_in_actions_remove_proc (GimpActionGroup *group,
307
 
                             PlugInProcDef   *proc_def)
308
 
{
309
 
  GtkAction *action;
310
 
 
311
 
  g_return_if_fail (GIMP_IS_ACTION_GROUP (group));
312
 
  g_return_if_fail (proc_def != NULL);
313
 
 
314
 
  action = gtk_action_group_get_action (GTK_ACTION_GROUP (group),
315
 
                                        proc_def->db_info.name);
316
 
 
317
 
  if (action)
318
 
    {
319
 
#if 0
320
 
      g_print ("removing plug-in action '%s'\n",
321
 
               proc_def->db_info.name);
322
 
#endif
323
 
 
324
 
      gtk_action_group_remove_action (GTK_ACTION_GROUP (group), action);
325
 
    }
326
 
}
327
 
 
328
 
 
329
 
/*  private functions  */
330
 
 
331
474
static void
332
 
plug_in_actions_last_changed (Gimp            *gimp,
333
 
                              GimpActionGroup *group)
 
475
plug_in_actions_history_changed (GimpPlugInManager *manager,
 
476
                                 GimpActionGroup   *group)
334
477
{
335
 
  if (gimp->last_plug_in)
 
478
  GimpPlugInProcedure *proc;
 
479
  gint                 i;
 
480
 
 
481
  proc = gimp_plug_in_manager_history_nth (manager, 0);
 
482
 
 
483
  if (proc)
336
484
    {
337
 
      PlugInProcDef *proc_def = gimp->last_plug_in;
338
 
      const gchar   *progname;
339
 
      const gchar   *domain;
340
 
      gchar         *label;
341
 
      gchar         *repeat;
342
 
      gchar         *reshow;
343
 
 
344
 
      progname = plug_in_proc_def_get_progname (proc_def);
345
 
      domain   = plug_ins_locale_domain (group->gimp, progname, NULL);
346
 
 
347
 
      label = plug_in_proc_def_get_label (proc_def, domain);
 
485
      const gchar *label;
 
486
      gchar       *repeat;
 
487
      gchar       *reshow;
 
488
 
 
489
      label = gimp_plug_in_procedure_get_label (proc);
348
490
 
349
491
      repeat = g_strdup_printf (_("Re_peat \"%s\""),  label);
350
 
      reshow = g_strdup_printf (_("R_e-show \"%s\""), label);
351
 
 
352
 
      g_free (label);
 
492
      reshow = g_strdup_printf (_("R_e-Show \"%s\""), label);
353
493
 
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);
364
504
      gimp_action_group_set_action_label (group, "plug-in-reshow",
365
505
                                          _("Re-Show Last"));
366
506
    }
 
507
 
 
508
  for (i = 0; i < gimp_plug_in_manager_history_length (manager); i++)
 
509
    {
 
510
      GtkAction *action;
 
511
      gchar     *name = g_strdup_printf ("plug-in-recent-%02d", i + 1);
 
512
 
 
513
      action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), name);
 
514
      g_free (name);
 
515
 
 
516
      proc = gimp_plug_in_manager_history_nth (manager, i);
 
517
 
 
518
      g_object_set (action,
 
519
                    "visible",   TRUE,
 
520
                    "procedure", proc,
 
521
                    "label",     gimp_plug_in_procedure_get_label (proc),
 
522
                    "stock-id",  gimp_plug_in_procedure_get_stock_id (proc),
 
523
                    "tooltip",   gimp_plug_in_procedure_get_blurb (proc),
 
524
                    NULL);
 
525
    }
 
526
 
 
527
  for (; i < gimp_plug_in_manager_history_size (manager); i++)
 
528
    {
 
529
      GtkAction *action;
 
530
      gchar     *name = g_strdup_printf ("plug-in-recent-%02d", i + 1);
 
531
 
 
532
      action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), name);
 
533
      g_free (name);
 
534
 
 
535
      g_object_set (action,
 
536
                    "visible",   FALSE,
 
537
                    "procedure", NULL,
 
538
                    NULL);
 
539
    }
 
540
 
 
541
  /* update sensitivity of the actions */
 
542
  plug_in_actions_update (group, manager->gimp);
367
543
}
368
544
 
369
545
static gboolean
430
606
                            const gchar     *path_translated)
431
607
{
432
608
  GHashTable *path_table;
 
609
  gchar      *copy_original;
 
610
  gchar      *copy_translated;
433
611
  gchar      *p1, *p2;
434
612
 
435
613
  path_table = g_object_get_data (G_OBJECT (group), "plug-in-path-table");
444
622
                              (GDestroyNotify) g_hash_table_destroy);
445
623
    }
446
624
 
447
 
  p1 = strrchr (path_original, '/');
448
 
  p2 = strrchr (path_translated, '/');
449
 
 
450
 
  if (p1 && p2 && ! g_hash_table_lookup (path_table, path_original))
 
625
  copy_original   = gimp_strip_uline (path_original);
 
626
  copy_translated = g_strdup (path_translated);
 
627
 
 
628
  p1 = strrchr (copy_original, '/');
 
629
  p2 = strrchr (copy_translated, '/');
 
630
 
 
631
  if (p1 && p2 && ! g_hash_table_lookup (path_table, copy_original))
451
632
    {
452
 
      gchar     *copy_original   = g_strdup (path_original);
453
 
      gchar     *copy_translated = g_strdup (path_translated);
454
633
      gchar     *label;
455
634
      GtkAction *action;
456
635
 
458
637
 
459
638
#if 0
460
639
      g_print ("adding plug-in submenu '%s' (%s)\n",
461
 
               path_original, label);
 
640
               copy_original, label);
462
641
#endif
463
642
 
464
 
      action = gtk_action_new (path_original, label, NULL, NULL);
 
643
      action = gtk_action_new (copy_original, label, NULL, NULL);
465
644
      gtk_action_group_add_action (GTK_ACTION_GROUP (group), action);
466
645
      g_object_unref (action);
467
646
 
468
 
      g_hash_table_insert (path_table, g_strdup (path_original), action);
469
 
 
470
 
      p1 = strrchr (copy_original, '/');
471
 
      p2 = strrchr (copy_translated, '/');
 
647
      g_hash_table_insert (path_table, g_strdup (copy_original), action);
472
648
 
473
649
      *p1 = '\0';
474
650
      *p2 = '\0';
475
651
 
476
652
      plug_in_actions_build_path (group, copy_original, copy_translated);
 
653
    }
477
654
 
478
 
      g_free (copy_original);
479
 
      g_free (copy_translated);
480
 
    }
 
655
  g_free (copy_original);
 
656
  g_free (copy_translated);
481
657
}