Some cleanups to the GtkDialog code: (#170746, Morten Welinder) Simplify,

2005-03-23  Matthias Clasen  <mclasen@redhat.com>

	Some cleanups to the GtkDialog code:  (#170746,
	Morten Welinder)
	* gtk/gtkdialog.c (action_widget_activated): Simplify,
	use _gtk_dialog_get_response_for_widget.
	(gtk_dialog_add_action_widget): Use the correct signal
	id for non-buttons.
	(gtk_dialog_set_response_sensitive):
	(gtk_dialog_set_default_response): Use get_response_data.
	(gtk_dialog_run): Don't disconnect the signals if the
	dialog was destroyed while running.
This commit is contained in:
Matthias Clasen 2005-03-23 14:03:43 +00:00 committed by Matthias Clasen
parent edc3b13575
commit c43673f17f
4 changed files with 45 additions and 18 deletions

View File

@ -1,3 +1,16 @@
2005-03-23 Matthias Clasen <mclasen@redhat.com>
Some cleanups to the GtkDialog code: (#170746,
Morten Welinder)
* gtk/gtkdialog.c (action_widget_activated): Simplify,
use _gtk_dialog_get_response_for_widget.
(gtk_dialog_add_action_widget): Use the correct signal
id for non-buttons.
(gtk_dialog_set_response_sensitive):
(gtk_dialog_set_default_response): Use get_response_data.
(gtk_dialog_run): Don't disconnect the signals if the
dialog was destroyed while running.
Tue Mar 22 14:16:31 2005 Manish Singh <yosh@gimp.org> Tue Mar 22 14:16:31 2005 Manish Singh <yosh@gimp.org>
* gtk/gtkfilesystem.c (gtk_file_system_set_bookmark_label): * gtk/gtkfilesystem.c (gtk_file_system_set_bookmark_label):

View File

@ -1,3 +1,16 @@
2005-03-23 Matthias Clasen <mclasen@redhat.com>
Some cleanups to the GtkDialog code: (#170746,
Morten Welinder)
* gtk/gtkdialog.c (action_widget_activated): Simplify,
use _gtk_dialog_get_response_for_widget.
(gtk_dialog_add_action_widget): Use the correct signal
id for non-buttons.
(gtk_dialog_set_response_sensitive):
(gtk_dialog_set_default_response): Use get_response_data.
(gtk_dialog_run): Don't disconnect the signals if the
dialog was destroyed while running.
Tue Mar 22 14:16:31 2005 Manish Singh <yosh@gimp.org> Tue Mar 22 14:16:31 2005 Manish Singh <yosh@gimp.org>
* gtk/gtkfilesystem.c (gtk_file_system_set_bookmark_label): * gtk/gtkfilesystem.c (gtk_file_system_set_bookmark_label):

View File

@ -1,3 +1,16 @@
2005-03-23 Matthias Clasen <mclasen@redhat.com>
Some cleanups to the GtkDialog code: (#170746,
Morten Welinder)
* gtk/gtkdialog.c (action_widget_activated): Simplify,
use _gtk_dialog_get_response_for_widget.
(gtk_dialog_add_action_widget): Use the correct signal
id for non-buttons.
(gtk_dialog_set_response_sensitive):
(gtk_dialog_set_default_response): Use get_response_data.
(gtk_dialog_run): Don't disconnect the signals if the
dialog was destroyed while running.
Tue Mar 22 14:16:31 2005 Manish Singh <yosh@gimp.org> Tue Mar 22 14:16:31 2005 Manish Singh <yosh@gimp.org>
* gtk/gtkfilesystem.c (gtk_file_system_set_bookmark_label): * gtk/gtkfilesystem.c (gtk_file_system_set_bookmark_label):

View File

@ -553,18 +553,9 @@ get_response_data (GtkWidget *widget,
static void static void
action_widget_activated (GtkWidget *widget, GtkDialog *dialog) action_widget_activated (GtkWidget *widget, GtkDialog *dialog)
{ {
ResponseData *ad;
gint response_id; gint response_id;
g_return_if_fail (GTK_IS_DIALOG (dialog)); response_id = _gtk_dialog_get_response_for_widget (dialog, widget);
response_id = GTK_RESPONSE_NONE;
ad = get_response_data (widget, TRUE);
g_assert (ad != NULL);
response_id = ad->response_id;
gtk_dialog_response (dialog, response_id); gtk_dialog_response (dialog, response_id);
} }
@ -588,7 +579,7 @@ gtk_dialog_add_action_widget (GtkDialog *dialog,
gint response_id) gint response_id)
{ {
ResponseData *ad; ResponseData *ad;
gint signal_id = 0; guint signal_id;
g_return_if_fail (GTK_IS_DIALOG (dialog)); g_return_if_fail (GTK_IS_DIALOG (dialog));
g_return_if_fail (GTK_IS_WIDGET (child)); g_return_if_fail (GTK_IS_WIDGET (child));
@ -600,7 +591,7 @@ gtk_dialog_add_action_widget (GtkDialog *dialog,
if (GTK_IS_BUTTON (child)) if (GTK_IS_BUTTON (child))
signal_id = g_signal_lookup ("clicked", GTK_TYPE_BUTTON); signal_id = g_signal_lookup ("clicked", GTK_TYPE_BUTTON);
else else
signal_id = GTK_WIDGET_GET_CLASS (child)->activate_signal != 0; signal_id = GTK_WIDGET_GET_CLASS (child)->activate_signal;
if (signal_id) if (signal_id)
{ {
@ -742,8 +733,7 @@ gtk_dialog_set_response_sensitive (GtkDialog *dialog,
while (tmp_list != NULL) while (tmp_list != NULL)
{ {
GtkWidget *widget = tmp_list->data; GtkWidget *widget = tmp_list->data;
ResponseData *rd = g_object_get_data (G_OBJECT (widget), ResponseData *rd = get_response_data (widget, FALSE);
"gtk-dialog-response-data");
if (rd && rd->response_id == response_id) if (rd && rd->response_id == response_id)
gtk_widget_set_sensitive (widget, setting); gtk_widget_set_sensitive (widget, setting);
@ -778,8 +768,7 @@ gtk_dialog_set_default_response (GtkDialog *dialog,
while (tmp_list != NULL) while (tmp_list != NULL)
{ {
GtkWidget *widget = tmp_list->data; GtkWidget *widget = tmp_list->data;
ResponseData *rd = g_object_get_data (G_OBJECT (widget), ResponseData *rd = get_response_data (widget, FALSE);
"gtk-dialog-response-data");
if (rd && rd->response_id == response_id) if (rd && rd->response_id == response_id)
gtk_widget_grab_default (widget); gtk_widget_grab_default (widget);
@ -985,7 +974,7 @@ run_destroy_handler (GtkDialog *dialog, gpointer data)
gint gint
gtk_dialog_run (GtkDialog *dialog) gtk_dialog_run (GtkDialog *dialog)
{ {
RunInfo ri = { NULL, GTK_RESPONSE_NONE, NULL }; RunInfo ri = { NULL, GTK_RESPONSE_NONE, NULL, FALSE };
gboolean was_modal; gboolean was_modal;
gulong response_handler; gulong response_handler;
gulong unmap_handler; gulong unmap_handler;
@ -1036,7 +1025,6 @@ gtk_dialog_run (GtkDialog *dialog)
g_main_loop_unref (ri.loop); g_main_loop_unref (ri.loop);
ri.loop = NULL; ri.loop = NULL;
ri.destroyed = FALSE;
if (!ri.destroyed) if (!ri.destroyed)
{ {