From 9562a48abbbf143a03aacbb4a698c3892db5ee17 Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Wed, 11 Feb 2004 20:25:18 +0000 Subject: [PATCH] New ::map() handler. If no widget has the focus, try to give it to the 2004-02-11 Federico Mena Quintero * gtk/gtkmessagedialog.c (gtk_message_dialog_map): New ::map() handler. If no widget has the focus, try to give it to the default widget. If there is no default widget, give it to the first button. Fixes the cause for which #59707 was reopened. --- ChangeLog | 7 +++++++ ChangeLog.pre-2-10 | 7 +++++++ ChangeLog.pre-2-4 | 7 +++++++ ChangeLog.pre-2-6 | 7 +++++++ ChangeLog.pre-2-8 | 7 +++++++ gtk/gtkmessagedialog.c | 41 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 76 insertions(+) diff --git a/ChangeLog b/ChangeLog index b73af077b1..6b2d5c8ee4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2004-02-11 Federico Mena Quintero + + * gtk/gtkmessagedialog.c (gtk_message_dialog_map): New ::map() + handler. If no widget has the focus, try to give it to the + default widget. If there is no default widget, give it to the + first button. Fixes the cause for which #59707 was reopened. + 2004-02-11 Federico Mena Quintero Fixes #134051. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index b73af077b1..6b2d5c8ee4 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,10 @@ +2004-02-11 Federico Mena Quintero + + * gtk/gtkmessagedialog.c (gtk_message_dialog_map): New ::map() + handler. If no widget has the focus, try to give it to the + default widget. If there is no default widget, give it to the + first button. Fixes the cause for which #59707 was reopened. + 2004-02-11 Federico Mena Quintero Fixes #134051. diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index b73af077b1..6b2d5c8ee4 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,10 @@ +2004-02-11 Federico Mena Quintero + + * gtk/gtkmessagedialog.c (gtk_message_dialog_map): New ::map() + handler. If no widget has the focus, try to give it to the + default widget. If there is no default widget, give it to the + first button. Fixes the cause for which #59707 was reopened. + 2004-02-11 Federico Mena Quintero Fixes #134051. diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index b73af077b1..6b2d5c8ee4 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,10 @@ +2004-02-11 Federico Mena Quintero + + * gtk/gtkmessagedialog.c (gtk_message_dialog_map): New ::map() + handler. If no widget has the focus, try to give it to the + default widget. If there is no default widget, give it to the + first button. Fixes the cause for which #59707 was reopened. + 2004-02-11 Federico Mena Quintero Fixes #134051. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index b73af077b1..6b2d5c8ee4 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,10 @@ +2004-02-11 Federico Mena Quintero + + * gtk/gtkmessagedialog.c (gtk_message_dialog_map): New ::map() + handler. If no widget has the focus, try to give it to the + default widget. If there is no default widget, give it to the + first button. Fixes the cause for which #59707 was reopened. + 2004-02-11 Federico Mena Quintero Fixes #134051. diff --git a/gtk/gtkmessagedialog.c b/gtk/gtkmessagedialog.c index ac8a39bc58..441c0cda92 100644 --- a/gtk/gtkmessagedialog.c +++ b/gtk/gtkmessagedialog.c @@ -35,6 +35,8 @@ static void gtk_message_dialog_class_init (GtkMessageDialogClass *klass); static void gtk_message_dialog_init (GtkMessageDialog *dialog); + +static void gtk_message_dialog_map (GtkWidget *widget); static void gtk_message_dialog_style_set (GtkWidget *widget, GtkStyle *prev_style); @@ -96,6 +98,7 @@ gtk_message_dialog_class_init (GtkMessageDialogClass *class) parent_class = g_type_class_peek_parent (class); + widget_class->map = gtk_message_dialog_map; widget_class->style_set = gtk_message_dialog_style_set; gobject_class->set_property = gtk_message_dialog_set_property; @@ -511,6 +514,44 @@ gtk_message_dialog_add_buttons (GtkMessageDialog* message_dialog, g_object_notify (G_OBJECT (message_dialog), "buttons"); } +static void +gtk_message_dialog_map (GtkWidget *widget) +{ + GtkWindow *window; + + window = GTK_WINDOW (widget); + + /* If a default button has not been chosen, then the selectable label will get + * the focus. This looks bad, so give the focus to a button in this case. + */ + + if (!gtk_window_get_focus (window)) + { + GtkWidget *focus_widget; + + if (window->default_widget) + focus_widget = window->default_widget; + else + { + GList *children; + + children = gtk_container_get_children (GTK_CONTAINER (GTK_DIALOG (widget)->action_area)); + + if (children) + focus_widget = GTK_WIDGET (children->data); + else + focus_widget = NULL; + + g_list_free (children); + } + + if (focus_widget) + gtk_widget_grab_focus (focus_widget); + } + + GTK_WIDGET_CLASS (parent_class)->map (widget); +} + static void gtk_message_dialog_style_set (GtkWidget *widget, GtkStyle *prev_style)