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

« back to all changes in this revision

Viewing changes to app/widgets/gimptooloptionseditor.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
 * gimptooloptionseditor.c
32
32
#include "core/gimplist.h"
33
33
#include "core/gimptoolinfo.h"
34
34
#include "core/gimptooloptions.h"
 
35
#include "core/gimptoolpresets.h"
35
36
 
36
37
#include "gimpdnd.h"
37
38
#include "gimpdocked.h"
38
39
#include "gimphelp-ids.h"
39
40
#include "gimpmenufactory.h"
 
41
#include "gimppropwidgets.h"
40
42
#include "gimpview.h"
41
43
#include "gimpviewrenderer.h"
42
 
#include "gimppropwidgets.h"
43
44
#include "gimptooloptionseditor.h"
44
45
#include "gimpuimanager.h"
45
46
#include "gimpwidgets-utils.h"
47
48
#include "gimp-intl.h"
48
49
 
49
50
 
50
 
static void   gimp_tool_options_editor_class_init        (GimpToolOptionsEditorClass *klass);
51
 
static void   gimp_tool_options_editor_init              (GimpToolOptionsEditor      *editor);
52
 
static void   gimp_tool_options_editor_docked_iface_init (GimpDockedInterface        *docked_iface);
 
51
static void   gimp_tool_options_editor_docked_iface_init (GimpDockedInterface *iface);
53
52
 
54
53
static GObject * gimp_tool_options_editor_constructor  (GType                  type,
55
54
                                                        guint                  n_params,
69
68
static void   gimp_tool_options_editor_delete_clicked  (GtkWidget             *widget,
70
69
                                                        GimpToolOptionsEditor *editor);
71
70
static void   gimp_tool_options_editor_drop_tool       (GtkWidget             *widget,
 
71
                                                        gint                   x,
 
72
                                                        gint                   y,
72
73
                                                        GimpViewable          *viewable,
73
74
                                                        gpointer               data);
74
75
 
76
77
                                                        GimpToolInfo          *tool_info,
77
78
                                                        GimpToolOptionsEditor *editor);
78
79
 
79
 
static void   gimp_tool_options_editor_presets_changed (GimpContainer         *container,
80
 
                                                        GimpToolOptions       *options,
 
80
static void   gimp_tool_options_editor_presets_changed (GimpToolPresets       *presets,
81
81
                                                        GimpToolOptionsEditor *editor);
82
 
 
83
 
 
84
 
static GimpEditorClass *parent_class = NULL;
85
 
 
86
 
 
87
 
GType
88
 
gimp_tool_options_editor_get_type (void)
89
 
{
90
 
  static GType type = 0;
91
 
 
92
 
  if (! type)
93
 
    {
94
 
      static const GTypeInfo editor_info =
95
 
      {
96
 
        sizeof (GimpToolOptionsEditorClass),
97
 
        NULL,           /* base_init */
98
 
        NULL,           /* base_finalize */
99
 
        (GClassInitFunc) gimp_tool_options_editor_class_init,
100
 
        NULL,           /* class_finalize */
101
 
        NULL,           /* class_tool */
102
 
        sizeof (GimpToolOptionsEditor),
103
 
        0,              /* n_preallocs */
104
 
        (GInstanceInitFunc) gimp_tool_options_editor_init,
105
 
      };
106
 
      static const GInterfaceInfo docked_iface_info =
107
 
      {
108
 
        (GInterfaceInitFunc) gimp_tool_options_editor_docked_iface_init,
109
 
        NULL,           /* iface_finalize */
110
 
        NULL            /* iface_data     */
111
 
      };
112
 
 
113
 
      type = g_type_register_static (GIMP_TYPE_EDITOR,
114
 
                                     "GimpToolOptionsEditor",
115
 
                                     &editor_info, 0);
116
 
 
117
 
      g_type_add_interface_static (type, GIMP_TYPE_DOCKED,
118
 
                                   &docked_iface_info);
119
 
    }
120
 
 
121
 
  return type;
122
 
}
 
82
static void   gimp_tool_options_editor_presets_update  (GimpToolOptionsEditor *editor,
 
83
                                                        GimpToolPresets       *presets);
 
84
static void   gimp_tool_options_editor_save_presets    (GimpToolOptionsEditor *editor);
 
85
 
 
86
 
 
87
G_DEFINE_TYPE_WITH_CODE (GimpToolOptionsEditor, gimp_tool_options_editor,
 
88
                         GIMP_TYPE_EDITOR,
 
89
                         G_IMPLEMENT_INTERFACE (GIMP_TYPE_DOCKED,
 
90
                                                gimp_tool_options_editor_docked_iface_init))
 
91
 
 
92
#define parent_class gimp_tool_options_editor_parent_class
 
93
 
123
94
 
124
95
static void
125
96
gimp_tool_options_editor_class_init (GimpToolOptionsEditorClass *klass)
127
98
  GObjectClass   *object_class     = G_OBJECT_CLASS (klass);
128
99
  GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (klass);
129
100
 
130
 
  parent_class = g_type_class_peek_parent (klass);
131
 
 
132
101
  object_class->constructor = gimp_tool_options_editor_constructor;
133
102
 
134
103
  gtk_object_class->destroy = gimp_tool_options_editor_destroy;
159
128
  gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw),
160
129
                                         editor->options_vbox);
161
130
  gtk_widget_show (editor->options_vbox);
 
131
 
 
132
  editor->save_queue   = NULL;
 
133
  editor->save_idle_id = 0;
162
134
}
163
135
 
164
136
static void
238
210
      editor->options_vbox = NULL;
239
211
    }
240
212
 
 
213
  gimp_tool_options_editor_save_presets (editor);
 
214
 
241
215
  GTK_OBJECT_CLASS (parent_class)->destroy (object);
242
216
}
243
217
 
246
220
                                      GimpContext  *context,
247
221
                                      GtkIconSize   size)
248
222
{
249
 
  GdkScreen *screen;
250
 
  GtkWidget *view;
251
 
  gint       width;
252
 
  gint       height;
253
 
 
254
 
  screen = gtk_widget_get_screen (GTK_WIDGET (docked));
255
 
  gtk_icon_size_lookup_for_settings (gtk_settings_get_for_screen (screen),
256
 
                                     size, &width, &height);
257
 
 
258
 
  view = gimp_prop_preview_new (G_OBJECT (context), "tool", height);
 
223
  GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (docked));
 
224
  GtkWidget   *view;
 
225
  gint         width;
 
226
  gint         height;
 
227
 
 
228
  gtk_icon_size_lookup_for_settings (settings, size, &width, &height);
 
229
 
 
230
  view = gimp_prop_view_new (G_OBJECT (context), "tool", context, height);
259
231
  GIMP_VIEW (view)->renderer->size = -1;
260
232
  gimp_view_renderer_set_size_full (GIMP_VIEW (view)->renderer,
261
233
                                    width, height, 0);
300
272
 
301
273
  user_context = gimp_get_user_context (gimp);
302
274
 
303
 
  g_signal_connect_object (user_context, "tool_changed",
 
275
  g_signal_connect_object (user_context, "tool-changed",
304
276
                           G_CALLBACK (gimp_tool_options_editor_tool_changed),
305
277
                           editor,
306
278
                           0);
331
303
{
332
304
  GimpEditor *gimp_editor = GIMP_EDITOR (editor);
333
305
 
334
 
  gimp_ui_manager_ui_get (gimp_editor->ui_manager, gimp_editor->ui_path);
 
306
  gtk_ui_manager_get_widget (GTK_UI_MANAGER (gimp_editor->ui_manager),
 
307
                             gimp_editor->ui_path);
335
308
  gimp_ui_manager_update (gimp_editor->ui_manager, gimp_editor->popup_data);
336
309
 
337
310
  gimp_ui_manager_ui_popup (gimp_editor->ui_manager, path,
351
324
    }
352
325
  else
353
326
    {
354
 
      GtkAction *action;
355
 
 
356
 
      action = gimp_ui_manager_find_action (GIMP_EDITOR (editor)->ui_manager,
357
 
                                            "tool-options",
358
 
                                            "tool-options-save-new");
359
 
 
360
 
      if (action)
361
 
        gtk_action_activate (action);
 
327
      gimp_ui_manager_activate_action (GIMP_EDITOR (editor)->ui_manager,
 
328
                                       "tool-options",
 
329
                                       "tool-options-save-new");
362
330
    }
363
331
}
364
332
 
380
348
 
381
349
static void
382
350
gimp_tool_options_editor_drop_tool (GtkWidget    *widget,
 
351
                                    gint          x,
 
352
                                    gint          y,
383
353
                                    GimpViewable *viewable,
384
354
                                    gpointer      data)
385
355
{
396
366
                                       GimpToolInfo          *tool_info,
397
367
                                       GimpToolOptionsEditor *editor)
398
368
{
399
 
  GimpContainer *presets;
400
 
  GtkWidget     *options_gui;
 
369
  GimpToolPresets *presets;
 
370
  GtkWidget       *options_gui;
401
371
 
402
372
  if (tool_info && tool_info->tool_options == editor->visible_tool_options)
403
373
    return;
404
374
 
405
375
  if (editor->visible_tool_options)
406
376
    {
407
 
      presets = editor->visible_tool_options->tool_info->options_presets;
 
377
      presets = editor->visible_tool_options->tool_info->presets;
408
378
 
409
379
      if (presets)
410
380
        g_signal_handlers_disconnect_by_func (presets,
422
392
 
423
393
  if (tool_info && tool_info->tool_options)
424
394
    {
425
 
      presets = tool_info->options_presets;
 
395
      presets = tool_info->presets;
426
396
 
427
397
      if (presets)
428
 
        {
429
 
          g_signal_connect_object (presets, "add",
430
 
                                   G_CALLBACK (gimp_tool_options_editor_presets_changed),
431
 
                                   G_OBJECT (editor), 0);
432
 
          g_signal_connect_object (presets, "remove",
433
 
                                   G_CALLBACK (gimp_tool_options_editor_presets_changed),
434
 
                                   G_OBJECT (editor), 0);
435
 
        }
 
398
        g_signal_connect_object (presets, "changed",
 
399
                                 G_CALLBACK (gimp_tool_options_editor_presets_changed),
 
400
                                 G_OBJECT (editor), 0);
436
401
 
437
402
      options_gui = g_object_get_data (G_OBJECT (tool_info->tool_options),
438
403
                                       "gimp-tool-options-gui");
453
418
      presets = NULL;
454
419
    }
455
420
 
456
 
  gimp_tool_options_editor_presets_changed (presets, NULL, editor);
 
421
  gimp_tool_options_editor_presets_update (editor, presets);
457
422
 
458
423
  gimp_docked_title_changed (GIMP_DOCKED (editor));
459
424
}
460
425
 
461
 
static void
462
 
gimp_tool_options_editor_presets_changed (GimpContainer         *container,
463
 
                                          GimpToolOptions       *options,
 
426
static gboolean
 
427
gimp_tool_options_editor_save_presets_idle (GimpToolOptionsEditor *editor)
 
428
{
 
429
  editor->save_idle_id = 0;
 
430
 
 
431
  gimp_tool_options_editor_save_presets (editor);
 
432
 
 
433
  return FALSE;
 
434
}
 
435
 
 
436
static void
 
437
gimp_tool_options_editor_queue_save_presets (GimpToolOptionsEditor *editor,
 
438
                                             GimpToolPresets       *presets)
 
439
{
 
440
  if (g_list_find (editor->save_queue, presets))
 
441
    return;
 
442
 
 
443
  editor->save_queue = g_list_append (editor->save_queue, presets);
 
444
 
 
445
  if (! editor->save_idle_id)
 
446
    {
 
447
      editor->save_idle_id =
 
448
        g_idle_add ((GSourceFunc) gimp_tool_options_editor_save_presets_idle,
 
449
                    editor);
 
450
    }
 
451
}
 
452
 
 
453
static void
 
454
gimp_tool_options_editor_save_presets (GimpToolOptionsEditor *editor)
 
455
{
 
456
  GList *list;
 
457
 
 
458
  if (editor->save_idle_id)
 
459
    {
 
460
      g_source_remove (editor->save_idle_id);
 
461
      editor->save_idle_id = 0;
 
462
    }
 
463
 
 
464
  for (list = editor->save_queue; list; list = list->next)
 
465
    {
 
466
      GimpToolPresets *presets = list->data;
 
467
      GError          *error   = NULL;
 
468
 
 
469
      if (! gimp_tool_presets_save (presets, &error))
 
470
        {
 
471
          gimp_message (editor->gimp, G_OBJECT (editor), GIMP_MESSAGE_ERROR,
 
472
                        _("Error saving tool options presets: %s"),
 
473
                        error->message);
 
474
          g_error_free (error);
 
475
        }
 
476
    }
 
477
 
 
478
  g_list_free (editor->save_queue);
 
479
 
 
480
  editor->save_queue = NULL;
 
481
}
 
482
 
 
483
static void
 
484
gimp_tool_options_editor_presets_changed (GimpToolPresets       *presets,
464
485
                                          GimpToolOptionsEditor *editor)
465
486
{
 
487
  gimp_tool_options_editor_queue_save_presets (editor, presets);
 
488
 
 
489
  gimp_tool_options_editor_presets_update (editor, presets);
 
490
}
 
491
 
 
492
static void
 
493
gimp_tool_options_editor_presets_update (GimpToolOptionsEditor *editor,
 
494
                                         GimpToolPresets       *presets)
 
495
{
466
496
  gboolean save_sensitive    = FALSE;
467
497
  gboolean restore_sensitive = FALSE;
468
498
  gboolean delete_sensitive  = FALSE;
469
499
  gboolean reset_sensitive   = FALSE;
470
500
 
471
 
  if (container)
 
501
  if (presets)
472
502
    {
473
503
      save_sensitive  = TRUE;
474
504
      reset_sensitive = TRUE;
475
505
 
476
 
      if (gimp_container_num_children (container))
 
506
      if (! gimp_container_is_empty (GIMP_CONTAINER (presets)))
477
507
        {
478
508
          restore_sensitive = TRUE;
479
509
          delete_sensitive  = TRUE;