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

« back to all changes in this revision

Viewing changes to libgimpwidgets/gimpdialog.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:
38
38
};
39
39
 
40
40
 
41
 
static void       gimp_dialog_class_init   (GimpDialogClass *klass);
42
 
static void       gimp_dialog_init         (GimpDialog      *dialog);
43
 
 
44
41
static GObject  * gimp_dialog_constructor  (GType            type,
45
42
                                            guint            n_params,
46
43
                                            GObjectConstructParam *params);
58
55
static gboolean   gimp_dialog_delete_event (GtkWidget       *widget,
59
56
                                            GdkEventAny     *event);
60
57
static void       gimp_dialog_close        (GtkDialog       *dialog);
 
58
 
61
59
static void       gimp_dialog_help         (GObject         *dialog);
62
 
 
63
 
 
64
 
static GtkDialogClass *parent_class     = NULL;
65
 
static gboolean        show_help_button = TRUE;
66
 
 
67
 
 
68
 
GType
69
 
gimp_dialog_get_type (void)
70
 
{
71
 
  static GType dialog_type = 0;
72
 
 
73
 
  if (! dialog_type)
74
 
    {
75
 
      static const GTypeInfo dialog_info =
76
 
      {
77
 
        sizeof (GimpDialogClass),
78
 
        (GBaseInitFunc) NULL,
79
 
        (GBaseFinalizeFunc) NULL,
80
 
        (GClassInitFunc) gimp_dialog_class_init,
81
 
        NULL,           /* class_finalize */
82
 
        NULL,           /* class_data     */
83
 
        sizeof (GimpDialog),
84
 
        0,              /* n_preallocs    */
85
 
        (GInstanceInitFunc) gimp_dialog_init,
86
 
      };
87
 
 
88
 
      dialog_type = g_type_register_static (GTK_TYPE_DIALOG,
89
 
                                            "GimpDialog",
90
 
                                            &dialog_info, 0);
91
 
    }
92
 
 
93
 
  return dialog_type;
94
 
}
 
60
static void       gimp_dialog_response     (GtkDialog       *dialog,
 
61
                                            gint             response_id);
 
62
 
 
63
 
 
64
G_DEFINE_TYPE (GimpDialog, gimp_dialog, GTK_TYPE_DIALOG)
 
65
 
 
66
#define parent_class gimp_dialog_parent_class
 
67
 
 
68
static gboolean show_help_button = TRUE;
 
69
 
95
70
 
96
71
static void
97
72
gimp_dialog_class_init (GimpDialogClass *klass)
100
75
  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
101
76
  GtkDialogClass *dialog_class = GTK_DIALOG_CLASS (klass);
102
77
 
103
 
  parent_class = g_type_class_peek_parent (klass);
104
 
 
105
78
  object_class->constructor  = gimp_dialog_constructor;
106
79
  object_class->dispose      = gimp_dialog_dispose;
107
80
  object_class->set_property = gimp_dialog_set_property;
119
92
   **/
120
93
  g_object_class_install_property (object_class, PROP_HELP_FUNC,
121
94
                                   g_param_spec_pointer ("help-func", NULL, NULL,
122
 
                                                         G_PARAM_READWRITE |
 
95
                                                         GIMP_PARAM_READWRITE |
123
96
                                                         G_PARAM_CONSTRUCT_ONLY));
124
97
 
125
98
  /**
130
103
  g_object_class_install_property (object_class, PROP_HELP_ID,
131
104
                                   g_param_spec_string ("help-id", NULL, NULL,
132
105
                                                        NULL,
133
 
                                                        G_PARAM_READWRITE |
 
106
                                                        GIMP_PARAM_READWRITE |
134
107
                                                        G_PARAM_CONSTRUCT_ONLY));
135
108
}
136
109
 
 
110
static void
 
111
gimp_dialog_init (GimpDialog *dialog)
 
112
{
 
113
  gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
 
114
 
 
115
  g_signal_connect (dialog, "response",
 
116
                    G_CALLBACK (gimp_dialog_response),
 
117
                    NULL);
 
118
}
 
119
 
137
120
static GObject *
138
121
gimp_dialog_constructor (GType                  type,
139
122
                         guint                  n_params,
245
228
  GTK_WIDGET_CLASS (parent_class)->hide (widget);
246
229
}
247
230
 
248
 
static void
249
 
gimp_dialog_init (GimpDialog *dialog)
250
 
{
251
 
  gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
252
 
}
253
 
 
254
231
static gboolean
255
232
gimp_dialog_delete_event (GtkWidget   *widget,
256
233
                          GdkEventAny *event)
286
263
    help_func (g_object_get_data (dialog, "gimp-dialog-help-id"), dialog);
287
264
}
288
265
 
 
266
static void
 
267
gimp_dialog_response (GtkDialog *dialog,
 
268
                      gint       response_id)
 
269
{
 
270
  GList *children;
 
271
  GList *list;
 
272
 
 
273
  children = gtk_container_get_children (GTK_CONTAINER (dialog->action_area));
 
274
 
 
275
  for (list = children; list; list = g_list_next (list))
 
276
    {
 
277
      GtkWidget *widget = list->data;
 
278
 
 
279
      if (gtk_dialog_get_response_for_widget (dialog, widget) == response_id)
 
280
        {
 
281
          if (! GTK_IS_BUTTON (widget) ||
 
282
              gtk_button_get_focus_on_click (GTK_BUTTON (widget)))
 
283
            {
 
284
              gtk_widget_grab_focus (widget);
 
285
            }
 
286
 
 
287
          break;
 
288
        }
 
289
    }
 
290
 
 
291
  g_list_free (children);
 
292
}
 
293
 
289
294
 
290
295
/**
291
296
 * gimp_dialog_new:
406
411
}
407
412
 
408
413
/**
 
414
 * gimp_dialog_add_button:
 
415
 * @dialog: The @dialog to add a button to.
 
416
 * @button_text: text of button, or stock ID.
 
417
 * @response_id: response ID for the button.
 
418
 *
 
419
 * This function is essentially the same as gtk_dialog_add_button()
 
420
 * except it ensures there is only one help button and automatically
 
421
 * sets the RESPONSE_OK widget as the default response.
 
422
 *
 
423
 * Return value: the button widget that was added.
 
424
 **/
 
425
GtkWidget *
 
426
gimp_dialog_add_button (GimpDialog  *dialog,
 
427
                        const gchar *button_text,
 
428
                        gint         response_id)
 
429
{
 
430
  GtkWidget *button;
 
431
 
 
432
  /*  hide the automatically added help button if another one is added  */
 
433
  if (response_id == GTK_RESPONSE_HELP)
 
434
    {
 
435
      GtkWidget *help_button = g_object_get_data (G_OBJECT (dialog),
 
436
                                                  "gimp-dialog-help-button");
 
437
      if (help_button)
 
438
        gtk_widget_hide (help_button);
 
439
    }
 
440
 
 
441
  button = gtk_dialog_add_button (GTK_DIALOG (dialog), button_text,
 
442
                                  response_id);
 
443
 
 
444
  if (response_id == GTK_RESPONSE_OK)
 
445
    {
 
446
      gtk_dialog_set_default_response (GTK_DIALOG (dialog),
 
447
                                       GTK_RESPONSE_OK);
 
448
    }
 
449
 
 
450
  return button;
 
451
}
 
452
 
 
453
/**
 
454
 * gimp_dialog_add_buttons:
 
455
 * @dialog: The @dialog to add buttons to.
 
456
 * @Varargs: button_text-response_id pairs.
 
457
 *
 
458
 * This function is essentially the same as gtk_dialog_add_buttons()
 
459
 * except it calls gimp_dialog_add_button() instead of gtk_dialog_add_button()
 
460
 **/
 
461
void
 
462
gimp_dialog_add_buttons (GimpDialog *dialog,
 
463
                         ...)
 
464
{
 
465
  va_list args;
 
466
 
 
467
  va_start (args, dialog);
 
468
 
 
469
  gimp_dialog_add_buttons_valist (dialog, args);
 
470
 
 
471
  va_end (args);
 
472
}
 
473
 
 
474
/**
409
475
 * gimp_dialog_add_buttons_valist:
410
476
 * @dialog: The @dialog to add buttons to.
411
477
 * @args:   The buttons as va_list.
412
478
 *
413
 
 * This function is essentially the same as gtk_dialog_add_buttons()
 
479
 * This function is essentially the same as gimp_dialog_add_buttons()
414
480
 * except it takes a va_list instead of '...'
415
481
 **/
416
482
void
426
492
    {
427
493
      response_id = va_arg (args, gint);
428
494
 
429
 
      /*  hide the automatically added help button if another one is added  */
430
 
      if (response_id == GTK_RESPONSE_HELP)
431
 
        {
432
 
          GtkWidget *button = g_object_get_data (G_OBJECT (dialog),
433
 
                                                 "gimp-dialog-help-button");
434
 
          gtk_widget_hide (button);
435
 
        }
436
 
 
437
 
      gtk_dialog_add_button (GTK_DIALOG (dialog), button_text, response_id);
438
 
 
439
 
      if (response_id == GTK_RESPONSE_OK)
440
 
        {
441
 
          gtk_dialog_set_default_response (GTK_DIALOG (dialog),
442
 
                                           GTK_RESPONSE_OK);
443
 
        }
 
495
      gimp_dialog_add_button (dialog, button_text, response_id);
444
496
    }
445
497
}
446
498
 
526
578
  unmap_handler    = g_signal_connect (dialog, "unmap",
527
579
                                       G_CALLBACK (run_unmap_handler),
528
580
                                       &ri);
529
 
  delete_handler   = g_signal_connect (dialog, "delete_event",
 
581
  delete_handler   = g_signal_connect (dialog, "delete-event",
530
582
                                       G_CALLBACK (run_delete_handler),
531
583
                                       &ri);
532
584
  destroy_handler  = g_signal_connect (dialog, "destroy",