From b7cf18835931d5e68cd85cdae11a21417f8c8362 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Mon, 14 Apr 2003 14:15:20 +0000 Subject: [PATCH] don't try to reparent the children of GtkInputDialog but simply pop up the 2003-04-14 Sven Neumann * app/gui/preferences-dialog.c: don't try to reparent the children of GtkInputDialog but simply pop up the dialog as provided by GTK+. Looks ugly but shouldn't crash any longer. Fixes bug #104423. --- ChangeLog | 6 +++ app/dialogs/preferences-dialog.c | 82 +++++++++++++++++++------------- app/gui/preferences-dialog.c | 82 +++++++++++++++++++------------- 3 files changed, 104 insertions(+), 66 deletions(-) diff --git a/ChangeLog b/ChangeLog index 48caff34cf..2a30fcb636 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2003-04-14 Sven Neumann + + * app/gui/preferences-dialog.c: don't try to reparent the children + of GtkInputDialog but simply pop up the dialog as provided by + GTK+. Looks ugly but shouldn't crash any longer. Fixes bug #104423. + 2003-04-14 Simon Budig * app/vectors/gimpstroke.[ch] diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c index e5f03fc1d3..fd6cd1ad6f 100644 --- a/app/dialogs/preferences-dialog.c +++ b/app/dialogs/preferences-dialog.c @@ -73,6 +73,7 @@ static void prefs_res_source_callback (GtkWidget *widget, GObject *config); static void prefs_resolution_calibrate_callback (GtkWidget *widget, GtkWidget *sizeentry); +static void prefs_input_devices_dialog (GtkWidget *widget); static void prefs_input_dialog_able_callback (GtkWidget *widget, GdkDevice *device, gpointer data); @@ -409,6 +410,43 @@ prefs_resolution_calibrate_callback (GtkWidget *widget, NULL, NULL, NULL); } +static void +prefs_input_devices_dialog (GtkWidget *widget) +{ + static GtkWidget *input_dialog = NULL; + + if (input_dialog) + { + gtk_window_present (GTK_WINDOW (input_dialog)); + return; + } + + input_dialog = gtk_input_dialog_new (); + + g_object_add_weak_pointer (G_OBJECT (input_dialog), + (gpointer *) &input_dialog); + + gtk_window_set_transient_for (GTK_WINDOW (input_dialog), + GTK_WINDOW (prefs_dialog)); + gtk_window_set_destroy_with_parent (GTK_WINDOW (input_dialog), TRUE); + + gtk_widget_hide (GTK_INPUT_DIALOG (input_dialog)->save_button); + + g_signal_connect_swapped (GTK_INPUT_DIALOG (input_dialog)->close_button, + "clicked", + G_CALLBACK (gtk_widget_destroy), + input_dialog); + + g_signal_connect (input_dialog, "enable_device", + G_CALLBACK (prefs_input_dialog_able_callback), + NULL); + g_signal_connect (input_dialog, "disable_device", + G_CALLBACK (prefs_input_dialog_able_callback), + NULL); + + gtk_widget_show (input_dialog); +} + static void prefs_input_dialog_able_callback (GtkWidget *widget, GdkDevice *device, @@ -1281,41 +1319,19 @@ prefs_dialog_new (Gimp *gimp, page_index++); /* Input Device Settings */ - vbox2 = prefs_frame_new (_("Input Device Settings"), - GTK_CONTAINER (vbox), FALSE); + hbox = gtk_hbox_new (FALSE, 2); + gtk_container_set_border_width (GTK_CONTAINER (hbox), 4); + gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); + gtk_widget_show (hbox); - { - GtkWidget *input_dialog; - GtkWidget *input_vbox; - GList *input_children; + button = gtk_button_new_with_label (_("Configure Input Devices")); + gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0); + gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); + gtk_widget_show (button); - input_dialog = gtk_input_dialog_new (); - - input_children = gtk_container_get_children (GTK_CONTAINER (GTK_DIALOG (input_dialog)->vbox)); - - input_vbox = GTK_WIDGET (input_children->data); - - g_list_free (input_children); - - g_object_ref (input_vbox); - - gtk_container_remove (GTK_CONTAINER (GTK_DIALOG (input_dialog)->vbox), - input_vbox); - gtk_box_pack_start (GTK_BOX (vbox2), input_vbox, TRUE, TRUE, 0); - - g_object_unref (input_vbox); - - g_object_weak_ref (G_OBJECT (input_vbox), - (GWeakNotify) gtk_widget_destroy, - input_dialog); - - g_signal_connect (input_dialog, "enable_device", - G_CALLBACK (prefs_input_dialog_able_callback), - NULL); - g_signal_connect (input_dialog, "disable_device", - G_CALLBACK (prefs_input_dialog_able_callback), - NULL); - } + g_signal_connect (button, "clicked", + G_CALLBACK (prefs_input_devices_dialog), + NULL); prefs_check_button_add (config, "save-device-status", _("Save Input Device Settings on Exit"), diff --git a/app/gui/preferences-dialog.c b/app/gui/preferences-dialog.c index e5f03fc1d3..fd6cd1ad6f 100644 --- a/app/gui/preferences-dialog.c +++ b/app/gui/preferences-dialog.c @@ -73,6 +73,7 @@ static void prefs_res_source_callback (GtkWidget *widget, GObject *config); static void prefs_resolution_calibrate_callback (GtkWidget *widget, GtkWidget *sizeentry); +static void prefs_input_devices_dialog (GtkWidget *widget); static void prefs_input_dialog_able_callback (GtkWidget *widget, GdkDevice *device, gpointer data); @@ -409,6 +410,43 @@ prefs_resolution_calibrate_callback (GtkWidget *widget, NULL, NULL, NULL); } +static void +prefs_input_devices_dialog (GtkWidget *widget) +{ + static GtkWidget *input_dialog = NULL; + + if (input_dialog) + { + gtk_window_present (GTK_WINDOW (input_dialog)); + return; + } + + input_dialog = gtk_input_dialog_new (); + + g_object_add_weak_pointer (G_OBJECT (input_dialog), + (gpointer *) &input_dialog); + + gtk_window_set_transient_for (GTK_WINDOW (input_dialog), + GTK_WINDOW (prefs_dialog)); + gtk_window_set_destroy_with_parent (GTK_WINDOW (input_dialog), TRUE); + + gtk_widget_hide (GTK_INPUT_DIALOG (input_dialog)->save_button); + + g_signal_connect_swapped (GTK_INPUT_DIALOG (input_dialog)->close_button, + "clicked", + G_CALLBACK (gtk_widget_destroy), + input_dialog); + + g_signal_connect (input_dialog, "enable_device", + G_CALLBACK (prefs_input_dialog_able_callback), + NULL); + g_signal_connect (input_dialog, "disable_device", + G_CALLBACK (prefs_input_dialog_able_callback), + NULL); + + gtk_widget_show (input_dialog); +} + static void prefs_input_dialog_able_callback (GtkWidget *widget, GdkDevice *device, @@ -1281,41 +1319,19 @@ prefs_dialog_new (Gimp *gimp, page_index++); /* Input Device Settings */ - vbox2 = prefs_frame_new (_("Input Device Settings"), - GTK_CONTAINER (vbox), FALSE); + hbox = gtk_hbox_new (FALSE, 2); + gtk_container_set_border_width (GTK_CONTAINER (hbox), 4); + gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); + gtk_widget_show (hbox); - { - GtkWidget *input_dialog; - GtkWidget *input_vbox; - GList *input_children; + button = gtk_button_new_with_label (_("Configure Input Devices")); + gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0); + gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); + gtk_widget_show (button); - input_dialog = gtk_input_dialog_new (); - - input_children = gtk_container_get_children (GTK_CONTAINER (GTK_DIALOG (input_dialog)->vbox)); - - input_vbox = GTK_WIDGET (input_children->data); - - g_list_free (input_children); - - g_object_ref (input_vbox); - - gtk_container_remove (GTK_CONTAINER (GTK_DIALOG (input_dialog)->vbox), - input_vbox); - gtk_box_pack_start (GTK_BOX (vbox2), input_vbox, TRUE, TRUE, 0); - - g_object_unref (input_vbox); - - g_object_weak_ref (G_OBJECT (input_vbox), - (GWeakNotify) gtk_widget_destroy, - input_dialog); - - g_signal_connect (input_dialog, "enable_device", - G_CALLBACK (prefs_input_dialog_able_callback), - NULL); - g_signal_connect (input_dialog, "disable_device", - G_CALLBACK (prefs_input_dialog_able_callback), - NULL); - } + g_signal_connect (button, "clicked", + G_CALLBACK (prefs_input_devices_dialog), + NULL); prefs_check_button_add (config, "save-device-status", _("Save Input Device Settings on Exit"),