diff options
author | Owen Taylor <otaylor@redhat.com> | 2002-01-30 18:58:31 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2002-01-30 18:58:31 +0000 |
commit | 2a9af2ff42e5ee117075301720ba0011ef046402 (patch) | |
tree | 064751a92d8dc30ab00dba606a45b77882aef4cb /gtk/gtkdialog.c | |
parent | 4e8a284f8659eb86e5096311299a68025868e83f (diff) | |
download | gdk-pixbuf-2a9af2ff42e5ee117075301720ba0011ef046402.tar.gz |
Try to make sure that we have some focused widget on map. (#50339)
Wed Jan 30 13:55:59 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwindow.c (gtk_window_show): Try to make
sure that we have some focused widget on map. (#50339)
* gtk/gtkdialog.c (gtk_dialog_map): Handling picking
a focus widget here differently so that if a
response button gets picked, it's the default one.
* tests/testgtk.c (make_message_dialog): Set the
default response for the dialogs.
Diffstat (limited to 'gtk/gtkdialog.c')
-rw-r--r-- | gtk/gtkdialog.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/gtk/gtkdialog.c b/gtk/gtkdialog.c index dec95d524..db87ce5b8 100644 --- a/gtk/gtkdialog.c +++ b/gtk/gtkdialog.c @@ -57,6 +57,7 @@ static void gtk_dialog_get_property (GObject *object, GParamSpec *pspec); static void gtk_dialog_style_set (GtkWidget *widget, GtkStyle *prev_style); +static void gtk_dialog_map (GtkWidget *widget); static void gtk_dialog_close (GtkDialog *dialog); @@ -116,6 +117,7 @@ gtk_dialog_class_init (GtkDialogClass *class) gobject_class->set_property = gtk_dialog_set_property; gobject_class->get_property = gtk_dialog_get_property; + widget_class->map = gtk_dialog_map; widget_class->style_set = gtk_dialog_style_set; class->close = gtk_dialog_close; @@ -296,6 +298,45 @@ gtk_dialog_delete_event_handler (GtkWidget *widget, return FALSE; } +/* A far too tricky heuristic for getting the right initial + * focus widget if none was set. What we do is we focus the first + * widget in the tab chain, but if this results in the focus + * ending up on one of the response widgets _other_ than the + * default response, we focus the default response instead. + */ +static void +gtk_dialog_map (GtkWidget *widget) +{ + GtkWindow *window = GTK_WINDOW (widget); + GtkDialog *dialog = GTK_DIALOG (widget); + + GTK_WIDGET_CLASS (parent_class)->map (widget); + + if (!window->focus_widget) + { + GList *children, *tmp_list; + + g_signal_emit_by_name (window, "move_focus", GTK_DIR_TAB_FORWARD); + + tmp_list = children = gtk_container_get_children (GTK_CONTAINER (dialog->action_area)); + + while (tmp_list) + { + GtkWidget *child = tmp_list->data; + + if (child == window->focus_widget && child != window->default_widget && window->default_widget) + { + gtk_widget_grab_focus (window->default_widget); + break; + } + + tmp_list = tmp_list->next; + } + + g_list_free (children); + } +} + static void gtk_dialog_style_set (GtkWidget *widget, GtkStyle *prev_style) |