]> Pileus Git - ~andy/gtk/commitdiff
New ::map() handler. If no widget has the focus, try to give it to the
authorFederico Mena Quintero <federico@ximian.com>
Wed, 11 Feb 2004 20:25:18 +0000 (20:25 +0000)
committerFederico Mena Quintero <federico@src.gnome.org>
Wed, 11 Feb 2004 20:25:18 +0000 (20:25 +0000)
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.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkmessagedialog.c

index b73af077b1fdfd5781c8044c80d55cc6e6868e97..6b2d5c8ee41a06c9ac1b8c6bde0c155f882e1bf2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
index b73af077b1fdfd5781c8044c80d55cc6e6868e97..6b2d5c8ee41a06c9ac1b8c6bde0c155f882e1bf2 100644 (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.
index b73af077b1fdfd5781c8044c80d55cc6e6868e97..6b2d5c8ee41a06c9ac1b8c6bde0c155f882e1bf2 100644 (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.
index b73af077b1fdfd5781c8044c80d55cc6e6868e97..6b2d5c8ee41a06c9ac1b8c6bde0c155f882e1bf2 100644 (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.
index b73af077b1fdfd5781c8044c80d55cc6e6868e97..6b2d5c8ee41a06c9ac1b8c6bde0c155f882e1bf2 100644 (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.
index ac8a39bc580f6d650a899ee2d3eeddeee34909c6..441c0cda92d58504338a0c65d3056f6c7893a285 100644 (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)