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

« back to all changes in this revision

Viewing changes to app/menus/menus.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
19
19
#include "config.h"
20
20
 
21
21
#include <errno.h>
 
22
 
22
23
#ifdef HAVE_UNISTD_H
23
24
#include <unistd.h>
24
25
#endif
25
26
 
 
27
#include <glib/gstdio.h>
26
28
#include <gtk/gtk.h>
27
29
 
28
30
#include "libgimpbase/gimpbase.h"
40
42
#include "widgets/gimpactionfactory.h"
41
43
#include "widgets/gimpmenufactory.h"
42
44
 
 
45
#include "dockable-menu.h"
43
46
#include "image-menu.h"
44
47
#include "menus.h"
 
48
#include "plug-in-menus.h"
45
49
#include "tool-options-menu.h"
46
50
#include "toolbox-menu.h"
47
51
 
50
54
 
51
55
/*  local function prototypes  */
52
56
 
53
 
static void   menu_can_change_accels (GimpGuiConfig *config);
 
57
static void   menus_can_change_accels (GimpGuiConfig   *config);
 
58
static void   menus_remove_accels     (gpointer         data,
 
59
                                       const gchar     *accel_path,
 
60
                                       guint            accel_key,
 
61
                                       GdkModifierType  accel_mods,
 
62
                                       gboolean         changed);
54
63
 
55
64
 
56
65
/*  global variables  */
76
85
  /* We need to make sure the property is installed before using it */
77
86
  g_type_class_ref (GTK_TYPE_MENU);
78
87
 
79
 
  menu_can_change_accels (GIMP_GUI_CONFIG (gimp->config));
 
88
  menus_can_change_accels (GIMP_GUI_CONFIG (gimp->config));
80
89
 
81
90
  g_signal_connect (gimp->config, "notify::can-change-accels",
82
 
                    G_CALLBACK (menu_can_change_accels), NULL);
 
91
                    G_CALLBACK (menus_can_change_accels), NULL);
83
92
 
84
93
  global_menu_factory = gimp_menu_factory_new (gimp, action_factory);
85
94
 
86
95
  gimp_menu_factory_manager_register (global_menu_factory, "<Image>",
87
96
                                      "file",
88
97
                                      "context",
 
98
                                      "edit",
 
99
                                      "select",
 
100
                                      "view",
 
101
                                      "image",
 
102
                                      "drawable",
 
103
                                      "layers",
 
104
                                      "channels",
 
105
                                      "vectors",
 
106
                                      "tools",
 
107
                                      "dialogs",
 
108
                                      "plug-in",
 
109
                                      "quick-mask",
 
110
                                      NULL,
 
111
                                      "/image-menubar",
 
112
                                      "image-menu.xml", image_menu_setup,
 
113
                                      "/dummy-menubar",
 
114
                                      "image-menu.xml", image_menu_setup,
 
115
                                      "/quick-mask-popup",
 
116
                                      "quick-mask-menu.xml", NULL,
 
117
                                      NULL);
 
118
 
 
119
  gimp_menu_factory_manager_register (global_menu_factory, "<Toolbox>",
 
120
                                      "file",
 
121
                                      "context",
89
122
                                      "debug",
90
123
                                      "help",
91
124
                                      "edit",
92
125
                                      "select",
93
 
                                      "view",
94
126
                                      "image",
95
127
                                      "drawable",
96
128
                                      "layers",
99
131
                                      "tools",
100
132
                                      "dialogs",
101
133
                                      "plug-in",
102
 
                                      "qmask",
 
134
                                      "quick-mask",
103
135
                                      NULL,
104
136
                                      "/toolbox-menubar",
105
137
                                      "toolbox-menu.xml", toolbox_menu_setup,
106
 
                                      "/image-menubar",
107
 
                                      "image-menu.xml", image_menu_setup,
108
 
                                      "/dummy-menubar",
109
 
                                      "image-menu.xml", image_menu_setup,
110
 
                                      "/qmask-popup",
111
 
                                      "qmask-menu.xml", NULL,
112
138
                                      NULL);
113
139
 
114
140
  gimp_menu_factory_manager_register (global_menu_factory, "<Dock>",
124
150
                                      "tools",
125
151
                                      "dialogs",
126
152
                                      "plug-in",
127
 
                                      "qmask",
 
153
                                      "quick-mask",
 
154
                                      "dock",
128
155
                                      NULL,
129
156
                                      NULL);
130
157
 
131
158
  gimp_menu_factory_manager_register (global_menu_factory, "<Layers>",
132
159
                                      "layers",
 
160
                                      "plug-in",
133
161
                                      NULL,
134
162
                                      "/layers-popup",
135
 
                                      "layers-menu.xml", NULL,
 
163
                                      "layers-menu.xml", plug_in_menus_setup,
136
164
                                      NULL);
137
165
 
138
166
  gimp_menu_factory_manager_register (global_menu_factory, "<Channels>",
139
167
                                      "channels",
 
168
                                      "plug-in",
140
169
                                      NULL,
141
170
                                      "/channels-popup",
142
 
                                      "channels-menu.xml", NULL,
 
171
                                      "channels-menu.xml", plug_in_menus_setup,
143
172
                                      NULL);
144
173
 
145
174
  gimp_menu_factory_manager_register (global_menu_factory, "<Vectors>",
146
175
                                      "vectors",
 
176
                                      "plug-in",
147
177
                                      NULL,
148
178
                                      "/vectors-popup",
149
 
                                      "vectors-menu.xml", NULL,
 
179
                                      "vectors-menu.xml", plug_in_menus_setup,
 
180
                                      NULL);
 
181
 
 
182
  gimp_menu_factory_manager_register (global_menu_factory, "<Colormap>",
 
183
                                      "colormap",
 
184
                                      "plug-in",
 
185
                                      NULL,
 
186
                                      "/colormap-popup",
 
187
                                      "colormap-menu.xml", plug_in_menus_setup,
150
188
                                      NULL);
151
189
 
152
190
  gimp_menu_factory_manager_register (global_menu_factory, "<Dockable>",
153
191
                                      "dockable",
 
192
                                      "dock",
154
193
                                      NULL,
155
194
                                      "/dockable-popup",
156
 
                                      "dockable-menu.xml", NULL,
 
195
                                      "dockable-menu.xml", dockable_menu_setup,
157
196
                                      NULL);
158
197
 
159
198
  gimp_menu_factory_manager_register (global_menu_factory, "<Brushes>",
160
199
                                      "brushes",
 
200
                                      "plug-in",
161
201
                                      NULL,
162
202
                                      "/brushes-popup",
163
 
                                      "brushes-menu.xml", NULL,
 
203
                                      "brushes-menu.xml", plug_in_menus_setup,
164
204
                                      NULL);
165
205
 
166
206
  gimp_menu_factory_manager_register (global_menu_factory, "<Patterns>",
167
207
                                      "patterns",
 
208
                                      "plug-in",
168
209
                                      NULL,
169
210
                                      "/patterns-popup",
170
 
                                      "patterns-menu.xml", NULL,
 
211
                                      "patterns-menu.xml", plug_in_menus_setup,
171
212
                                      NULL);
172
213
 
173
214
  gimp_menu_factory_manager_register (global_menu_factory, "<Gradients>",
174
215
                                      "gradients",
 
216
                                      "plug-in",
175
217
                                      NULL,
176
218
                                      "/gradients-popup",
177
 
                                      "gradients-menu.xml", NULL,
 
219
                                      "gradients-menu.xml", plug_in_menus_setup,
178
220
                                      NULL);
179
221
 
180
222
  gimp_menu_factory_manager_register (global_menu_factory, "<Palettes>",
181
223
                                      "palettes",
 
224
                                      "plug-in",
182
225
                                      NULL,
183
226
                                      "/palettes-popup",
184
 
                                      "palettes-menu.xml", NULL,
 
227
                                      "palettes-menu.xml", plug_in_menus_setup,
185
228
                                      NULL);
186
229
 
187
230
  gimp_menu_factory_manager_register (global_menu_factory, "<Fonts>",
188
231
                                      "fonts",
 
232
                                      "plug-in",
189
233
                                      NULL,
190
234
                                      "/fonts-popup",
191
 
                                      "fonts-menu.xml", NULL,
 
235
                                      "fonts-menu.xml", plug_in_menus_setup,
192
236
                                      NULL);
193
237
 
194
238
  gimp_menu_factory_manager_register (global_menu_factory, "<Buffers>",
195
239
                                      "buffers",
 
240
                                      "plug-in",
196
241
                                      NULL,
197
242
                                      "/buffers-popup",
198
 
                                      "buffers-menu.xml", NULL,
 
243
                                      "buffers-menu.xml", plug_in_menus_setup,
199
244
                                      NULL);
200
245
 
201
246
  gimp_menu_factory_manager_register (global_menu_factory, "<Documents>",
226
271
                                      "tools-menu.xml", NULL,
227
272
                                      NULL);
228
273
 
 
274
  gimp_menu_factory_manager_register (global_menu_factory, "<BrushEditor>",
 
275
                                      "brush-editor",
 
276
                                      NULL,
 
277
                                      "/brush-editor-popup",
 
278
                                      "brush-editor-menu.xml", NULL,
 
279
                                      NULL);
 
280
 
229
281
  gimp_menu_factory_manager_register (global_menu_factory, "<GradientEditor>",
230
282
                                      "gradient-editor",
231
283
                                      NULL,
240
292
                                      "palette-editor-menu.xml", NULL,
241
293
                                      NULL);
242
294
 
243
 
  gimp_menu_factory_manager_register (global_menu_factory, "<ColormapEditor>",
244
 
                                      "colormap-editor",
245
 
                                      NULL,
246
 
                                      "/colormap-editor-popup",
247
 
                                      "colormap-editor-menu.xml", NULL,
248
 
                                      NULL);
249
 
 
250
 
  gimp_menu_factory_manager_register (global_menu_factory, "<SelectionEditor>",
 
295
  gimp_menu_factory_manager_register (global_menu_factory, "<Selection>",
251
296
                                      "select",
252
297
                                      "vectors",
253
298
                                      NULL,
254
 
                                      "/selection-editor-popup",
255
 
                                      "selection-editor-menu.xml", NULL,
 
299
                                      "/selection-popup",
 
300
                                      "selection-menu.xml", NULL,
256
301
                                      NULL);
257
302
 
258
303
  gimp_menu_factory_manager_register (global_menu_factory, "<NavigationEditor>",
260
305
                                      NULL,
261
306
                                      NULL);
262
307
 
263
 
  gimp_menu_factory_manager_register (global_menu_factory, "<UndoEditor>",
 
308
  gimp_menu_factory_manager_register (global_menu_factory, "<Undo>",
264
309
                                      "edit",
265
310
                                      NULL,
 
311
                                      "/undo-popup",
 
312
                                      "undo-menu.xml", NULL,
266
313
                                      NULL);
267
314
 
268
315
  gimp_menu_factory_manager_register (global_menu_factory, "<ErrorConsole>",
287
334
                                      "text-editor-toolbar.xml",
288
335
                                      NULL,
289
336
                                      NULL);
 
337
 
 
338
  gimp_menu_factory_manager_register (global_menu_factory, "<CursorInfo>",
 
339
                                      "cursor-info",
 
340
                                      NULL,
 
341
                                      "/cursor-info-popup",
 
342
                                      "cursor-info-menu.xml",
 
343
                                      NULL,
 
344
                                      NULL);
 
345
 
 
346
  gimp_menu_factory_manager_register (global_menu_factory, "<SamplePoints>",
 
347
                                      "sample-points",
 
348
                                      NULL,
 
349
                                      "/sample-points-popup",
 
350
                                      "sample-points-menu.xml",
 
351
                                      NULL,
 
352
                                      NULL);
290
353
}
291
354
 
292
355
void
300
363
  global_menu_factory = NULL;
301
364
 
302
365
  g_signal_handlers_disconnect_by_func (gimp->config,
303
 
                                        menu_can_change_accels,
 
366
                                        menus_can_change_accels,
304
367
                                        NULL);
305
368
}
306
369
 
312
375
  g_return_if_fail (GIMP_IS_GIMP (gimp));
313
376
 
314
377
  filename = gimp_personal_rc_file ("menurc");
 
378
 
 
379
  if (gimp->be_verbose)
 
380
    g_print ("Parsing '%s'\n", gimp_filename_to_utf8 (filename));
 
381
 
315
382
  gtk_accel_map_load (filename);
316
383
  g_free (filename);
317
384
}
328
395
    return;
329
396
 
330
397
  filename = gimp_personal_rc_file ("menurc");
 
398
 
 
399
  if (gimp->be_verbose)
 
400
    g_print ("Writing '%s'\n", gimp_filename_to_utf8 (filename));
 
401
 
331
402
  gtk_accel_map_save (filename);
332
403
  g_free (filename);
333
404
 
346
417
 
347
418
  filename = gimp_personal_rc_file ("menurc");
348
419
 
349
 
  if (unlink (filename) != 0 && errno != ENOENT)
 
420
  if (g_unlink (filename) != 0 && errno != ENOENT)
350
421
    {
351
422
      g_set_error (error, 0, 0, _("Deleting \"%s\" failed: %s"),
352
423
                   gimp_filename_to_utf8 (filename), g_strerror (errno));
362
433
  return success;
363
434
}
364
435
 
 
436
void
 
437
menus_remove (Gimp *gimp)
 
438
{
 
439
  g_return_if_fail (GIMP_IS_GIMP (gimp));
 
440
 
 
441
  gtk_accel_map_foreach (gimp, menus_remove_accels);
 
442
}
 
443
 
365
444
 
366
445
/*  private functions  */
367
446
 
368
447
static void
369
 
menu_can_change_accels (GimpGuiConfig *config)
 
448
menus_can_change_accels (GimpGuiConfig *config)
370
449
{
371
450
  g_object_set (gtk_settings_get_for_screen (gdk_screen_get_default ()),
372
451
                "gtk-can-change-accels", config->can_change_accels,
373
452
                NULL);
374
453
}
 
454
 
 
455
static void
 
456
menus_remove_accels (gpointer        data,
 
457
                     const gchar    *accel_path,
 
458
                     guint           accel_key,
 
459
                     GdkModifierType accel_mods,
 
460
                     gboolean        changed)
 
461
{
 
462
  gtk_accel_map_change_entry (accel_path, 0, 0, TRUE);
 
463
}