summaryrefslogtreecommitdiff
path: root/gtk/gtkmessagedialog.c
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@ximian.com>2004-02-11 20:25:18 +0000
committerFederico Mena Quintero <federico@src.gnome.org>2004-02-11 20:25:18 +0000
commit9562a48abbbf143a03aacbb4a698c3892db5ee17 (patch)
tree3ebca6b782cbff658235899c633588cca7cd5cc8 /gtk/gtkmessagedialog.c
parent520ef9c665d072ac8013c83d1fdf8548378673b1 (diff)
downloadgtk+-9562a48abbbf143a03aacbb4a698c3892db5ee17.tar.gz
New ::map() handler. If no widget has the focus, try to give it to the
2004-02-11 Federico Mena Quintero <federico@ximian.com> * 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.
Diffstat (limited to 'gtk/gtkmessagedialog.c')
-rw-r--r--gtk/gtkmessagedialog.c41
1 files changed, 41 insertions, 0 deletions
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;
@@ -512,6 +515,44 @@ gtk_message_dialog_add_buttons (GtkMessageDialog* message_dialog,
}
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)
{