[gdm] Don't try to grab focus before the widget is shown



commit 6d77405e6d9ae41554b8c485852a476f3736cf36
Author: William Jon McCann <jmccann redhat com>
Date:   Mon Jun 28 11:58:42 2010 -0400

    Don't try to grab focus before the widget is shown
    
    Instead of trying to grab focus when the users are loaded
    react to list-visible property changes.
    (cherry picked from commit 279f71a2b5255689d5865993ff19e83640ba131d)

 gui/simple-greeter/gdm-chooser-widget.c      |    6 +++---
 gui/simple-greeter/gdm-user-chooser-widget.c |   25 ++++++++++++++++++-------
 2 files changed, 21 insertions(+), 10 deletions(-)
---
diff --git a/gui/simple-greeter/gdm-chooser-widget.c b/gui/simple-greeter/gdm-chooser-widget.c
index 113fa88..f67a811 100644
--- a/gui/simple-greeter/gdm-chooser-widget.c
+++ b/gui/simple-greeter/gdm-chooser-widget.c
@@ -698,12 +698,12 @@ update_chooser_visibility (GdmChooserWidget *widget)
 
         if (gdm_chooser_widget_get_number_of_items (widget) > 0) {
                 gtk_widget_show (widget->priv->frame);
+                set_chooser_list_visible (widget, TRUE);
         } else {
                 gtk_widget_hide (widget->priv->frame);
+                set_chooser_list_visible (widget, FALSE);
         }
 
-        set_chooser_list_visible (widget, TRUE);
-
         widget->priv->update_visibility_idle_id = 0;
 
         return FALSE;
@@ -2752,7 +2752,7 @@ gdm_chooser_widget_propagate_pending_key_events (GdmChooserWidget *widget)
 void
 gdm_chooser_widget_loaded (GdmChooserWidget *widget)
 {
-        update_chooser_visibility (widget);
         g_signal_emit (widget, signals[LOADED], 0);
+        update_chooser_visibility (widget);
         queue_move_cursor_to_top (widget);
 }
diff --git a/gui/simple-greeter/gdm-user-chooser-widget.c b/gui/simple-greeter/gdm-user-chooser-widget.c
index 483abfe..48c1285 100644
--- a/gui/simple-greeter/gdm-user-chooser-widget.c
+++ b/gui/simple-greeter/gdm-user-chooser-widget.c
@@ -595,7 +595,6 @@ on_is_loaded_changed (GdmUserManager       *manager,
                       GdmUserChooserWidget *widget)
 {
         GSList *users;
-        gboolean list_visible;
 
         /* FIXME: handle is-loaded=FALSE */
 
@@ -606,12 +605,6 @@ on_is_loaded_changed (GdmUserManager       *manager,
         widget->priv->users_to_add = g_slist_concat (widget->priv->users_to_add, g_slist_copy (users));
 
         queue_add_users (widget);
-
-        g_object_get (G_OBJECT (widget), "list-visible", &list_visible, NULL);
-
-        if (list_visible) {
-                gtk_widget_grab_focus (GTK_WIDGET (widget));
-        }
 }
 
 static void
@@ -962,6 +955,19 @@ setup_icons (GdmUserChooserWidget *widget)
 }
 
 static void
+on_list_visible_changed (GdmChooserWidget *widget,
+                         GParamSpec       *pspec,
+                         gpointer          data)
+{
+        gboolean is_visible;
+
+        g_object_get (G_OBJECT (widget), "list-visible", &is_visible, NULL);
+        if (is_visible) {
+                gtk_widget_grab_focus (GTK_WIDGET (widget));
+        }
+}
+
+static void
 gdm_user_chooser_widget_init (GdmUserChooserWidget *widget)
 {
         widget->priv = GDM_USER_CHOOSER_WIDGET_GET_PRIVATE (widget);
@@ -971,6 +977,11 @@ gdm_user_chooser_widget_init (GdmUserChooserWidget *widget)
         gdm_chooser_widget_set_in_use_message (GDM_CHOOSER_WIDGET (widget),
                                                _("Currently logged in"));
 
+        g_signal_connect (widget,
+                          "notify::list-visible",
+                          G_CALLBACK (on_list_visible_changed),
+                          NULL);
+
         setup_icons (widget);
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]