41
static void gimp_dialog_class_init (GimpDialogClass *klass);
42
static void gimp_dialog_init (GimpDialog *dialog);
44
41
static GObject * gimp_dialog_constructor (GType type,
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);
61
59
static void gimp_dialog_help (GObject *dialog);
64
static GtkDialogClass *parent_class = NULL;
65
static gboolean show_help_button = TRUE;
69
gimp_dialog_get_type (void)
71
static GType dialog_type = 0;
75
static const GTypeInfo dialog_info =
77
sizeof (GimpDialogClass),
79
(GBaseFinalizeFunc) NULL,
80
(GClassInitFunc) gimp_dialog_class_init,
81
NULL, /* class_finalize */
82
NULL, /* class_data */
85
(GInstanceInitFunc) gimp_dialog_init,
88
dialog_type = g_type_register_static (GTK_TYPE_DIALOG,
60
static void gimp_dialog_response (GtkDialog *dialog,
64
G_DEFINE_TYPE (GimpDialog, gimp_dialog, GTK_TYPE_DIALOG)
66
#define parent_class gimp_dialog_parent_class
68
static gboolean show_help_button = TRUE;
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);
103
parent_class = g_type_class_peek_parent (klass);
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;
120
93
g_object_class_install_property (object_class, PROP_HELP_FUNC,
121
94
g_param_spec_pointer ("help-func", NULL, NULL,
95
GIMP_PARAM_READWRITE |
123
96
G_PARAM_CONSTRUCT_ONLY));
130
103
g_object_class_install_property (object_class, PROP_HELP_ID,
131
104
g_param_spec_string ("help-id", NULL, NULL,
106
GIMP_PARAM_READWRITE |
134
107
G_PARAM_CONSTRUCT_ONLY));
111
gimp_dialog_init (GimpDialog *dialog)
113
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
115
g_signal_connect (dialog, "response",
116
G_CALLBACK (gimp_dialog_response),
138
121
gimp_dialog_constructor (GType type,
245
228
GTK_WIDGET_CLASS (parent_class)->hide (widget);
249
gimp_dialog_init (GimpDialog *dialog)
251
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
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);
267
gimp_dialog_response (GtkDialog *dialog,
273
children = gtk_container_get_children (GTK_CONTAINER (dialog->action_area));
275
for (list = children; list; list = g_list_next (list))
277
GtkWidget *widget = list->data;
279
if (gtk_dialog_get_response_for_widget (dialog, widget) == response_id)
281
if (! GTK_IS_BUTTON (widget) ||
282
gtk_button_get_focus_on_click (GTK_BUTTON (widget)))
284
gtk_widget_grab_focus (widget);
291
g_list_free (children);
291
296
* gimp_dialog_new:
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.
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.
423
* Return value: the button widget that was added.
426
gimp_dialog_add_button (GimpDialog *dialog,
427
const gchar *button_text,
432
/* hide the automatically added help button if another one is added */
433
if (response_id == GTK_RESPONSE_HELP)
435
GtkWidget *help_button = g_object_get_data (G_OBJECT (dialog),
436
"gimp-dialog-help-button");
438
gtk_widget_hide (help_button);
441
button = gtk_dialog_add_button (GTK_DIALOG (dialog), button_text,
444
if (response_id == GTK_RESPONSE_OK)
446
gtk_dialog_set_default_response (GTK_DIALOG (dialog),
454
* gimp_dialog_add_buttons:
455
* @dialog: The @dialog to add buttons to.
456
* @Varargs: button_text-response_id pairs.
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()
462
gimp_dialog_add_buttons (GimpDialog *dialog,
467
va_start (args, dialog);
469
gimp_dialog_add_buttons_valist (dialog, args);
409
475
* gimp_dialog_add_buttons_valist:
410
476
* @dialog: The @dialog to add buttons to.
411
477
* @args: The buttons as va_list.
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 '...'
427
493
response_id = va_arg (args, gint);
429
/* hide the automatically added help button if another one is added */
430
if (response_id == GTK_RESPONSE_HELP)
432
GtkWidget *button = g_object_get_data (G_OBJECT (dialog),
433
"gimp-dialog-help-button");
434
gtk_widget_hide (button);
437
gtk_dialog_add_button (GTK_DIALOG (dialog), button_text, response_id);
439
if (response_id == GTK_RESPONSE_OK)
441
gtk_dialog_set_default_response (GTK_DIALOG (dialog),
495
gimp_dialog_add_button (dialog, button_text, response_id);
526
578
unmap_handler = g_signal_connect (dialog, "unmap",
527
579
G_CALLBACK (run_unmap_handler),
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),
532
584
destroy_handler = g_signal_connect (dialog, "destroy",