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.
This commit is contained in:
Federico Mena Quintero 2004-02-11 20:25:18 +00:00 committed by Federico Mena Quintero
parent 520ef9c665
commit 9562a48abb
6 changed files with 76 additions and 0 deletions

View File

@ -1,3 +1,10 @@
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.
2004-02-11 Federico Mena Quintero <federico@ximian.com>
Fixes #134051.

View File

@ -1,3 +1,10 @@
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.
2004-02-11 Federico Mena Quintero <federico@ximian.com>
Fixes #134051.

View File

@ -1,3 +1,10 @@
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.
2004-02-11 Federico Mena Quintero <federico@ximian.com>
Fixes #134051.

View File

@ -1,3 +1,10 @@
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.
2004-02-11 Federico Mena Quintero <federico@ximian.com>
Fixes #134051.

View File

@ -1,3 +1,10 @@
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.
2004-02-11 Federico Mena Quintero <federico@ximian.com>
Fixes #134051.

View File

@ -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)