[gdm] Convert users-loaded signal to an is-loaded property



commit 42326a025406611aff8cbbb556205a4a859e0f8e
Author: William Jon McCann <jmccann redhat com>
Date:   Tue Jun 8 14:39:01 2010 -0400

    Convert users-loaded signal to an is-loaded property
    
    https://bugzilla.gnome.org/show_bug.cgi?id=620908

 gui/simple-greeter/gdm-user-chooser-widget.c |    9 ++--
 gui/simple-greeter/gdm-user-manager.c        |   60 ++++++++++++++++++++------
 gui/simple-greeter/test-user-manager.c       |    9 ++--
 gui/user-switch-applet/applet.c              |    9 ++--
 4 files changed, 62 insertions(+), 25 deletions(-)
---
diff --git a/gui/simple-greeter/gdm-user-chooser-widget.c b/gui/simple-greeter/gdm-user-chooser-widget.c
index 1a9b80c..755d49f 100644
--- a/gui/simple-greeter/gdm-user-chooser-widget.c
+++ b/gui/simple-greeter/gdm-user-chooser-widget.c
@@ -479,8 +479,9 @@ on_user_login_frequency_changed (GdmUserManager       *manager,
 }
 
 static void
-on_users_loaded (GdmUserManager       *manager,
-                 GdmUserChooserWidget *widget)
+on_is_loaded_changed (GdmUserManager       *manager,
+                      GParamSpec           *pspec,
+                      GdmUserChooserWidget *widget)
 {
         GSList *users;
         gboolean list_visible;
@@ -518,8 +519,8 @@ load_users (GdmUserChooserWidget *widget)
                                   G_CALLBACK (on_user_removed),
                                   widget);
                 g_signal_connect (widget->priv->manager,
-                                  "users-loaded",
-                                  G_CALLBACK (on_users_loaded),
+                                  "notify::is-loaded",
+                                  G_CALLBACK (on_is_loaded_changed),
                                   widget);
                 g_signal_connect (widget->priv->manager,
                                   "user-is-logged-in-changed",
diff --git a/gui/simple-greeter/gdm-user-manager.c b/gui/simple-greeter/gdm-user-manager.c
index d71fb72..a381643 100644
--- a/gui/simple-greeter/gdm-user-manager.c
+++ b/gui/simple-greeter/gdm-user-manager.c
@@ -99,7 +99,12 @@ struct GdmUserManagerPrivate
         guint                  reload_passwd_id;
         guint                  ck_history_id;
 
-        guint8                 users_dirty : 1;
+        gboolean               is_loaded;
+};
+
+enum {
+        PROP_0,
+        PROP_IS_LOADED
 };
 
 enum {
@@ -1246,6 +1251,16 @@ process_ck_history_line (GdmUserManager *manager,
         g_free (username);
 }
 
+static void
+set_is_loaded (GdmUserManager *manager,
+               gboolean        is_loaded)
+{
+        if (manager->priv->is_loaded != is_loaded) {
+                manager->priv->is_loaded = is_loaded;
+                g_object_notify (G_OBJECT (manager), "is-loaded");
+        }
+}
+
 static gboolean
 ck_history_watch (GIOChannel     *source,
                   GIOCondition    condition,
@@ -1280,7 +1295,7 @@ ck_history_watch (GIOChannel     *source,
         }
 
         if (done) {
-                g_signal_emit (G_OBJECT (manager), signals[USERS_LOADED], 0);
+                set_is_loaded (manager, TRUE);
 
                 manager->priv->ck_history_id = 0;
                 return FALSE;
@@ -1533,7 +1548,7 @@ load_users (GdmUserManager *manager)
         res = load_ck_history (manager);
         reload_passwd (manager);
         if (! res) {
-                g_signal_emit (G_OBJECT (manager), signals[USERS_LOADED], 0);
+                set_is_loaded (manager, TRUE);
         }
 }
 
@@ -1632,11 +1647,40 @@ on_passwd_monitor_changed (GFileMonitor     *monitor,
 }
 
 static void
+gdm_user_manager_get_property (GObject        *object,
+                               guint           prop_id,
+                               GValue         *value,
+                               GParamSpec     *pspec)
+{
+        GdmUserManager *manager;
+
+        manager = GDM_USER_MANAGER (object);
+
+        switch (prop_id) {
+        case PROP_IS_LOADED:
+                g_value_set_boolean (value, manager->priv->is_loaded);
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
 gdm_user_manager_class_init (GdmUserManagerClass *klass)
 {
         GObjectClass   *object_class = G_OBJECT_CLASS (klass);
 
         object_class->finalize = gdm_user_manager_finalize;
+        object_class->get_property = gdm_user_manager_get_property;
+
+        g_object_class_install_property (object_class,
+                                         PROP_IS_LOADED,
+                                         g_param_spec_boolean ("is-loaded",
+                                                               NULL,
+                                                               NULL,
+                                                               FALSE,
+                                                               G_PARAM_READABLE));
 
         signals [LOADING_USERS] =
                 g_signal_new ("loading-users",
@@ -1646,14 +1690,6 @@ gdm_user_manager_class_init (GdmUserManagerClass *klass)
                               NULL, NULL,
                               g_cclosure_marshal_VOID__VOID,
                               G_TYPE_NONE, 0);
-        signals [USERS_LOADED] =
-                g_signal_new ("users-loaded",
-                              G_TYPE_FROM_CLASS (klass),
-                              G_SIGNAL_RUN_LAST,
-                              G_STRUCT_OFFSET (GdmUserManagerClass, users_loaded),
-                              NULL, NULL,
-                              g_cclosure_marshal_VOID__VOID,
-                              G_TYPE_NONE, 0);
         signals [USER_ADDED] =
                 g_signal_new ("user-added",
                               G_TYPE_FROM_CLASS (klass),
@@ -1796,8 +1832,6 @@ gdm_user_manager_init (GdmUserManager *manager)
         get_seat_proxy (manager);
 
         queue_load_users (manager);
-
-        manager->priv->users_dirty = FALSE;
 }
 
 static void
diff --git a/gui/simple-greeter/test-user-manager.c b/gui/simple-greeter/test-user-manager.c
index e4c2952..a115f29 100644
--- a/gui/simple-greeter/test-user-manager.c
+++ b/gui/simple-greeter/test-user-manager.c
@@ -36,8 +36,9 @@
 static GdmUserManager *manager = NULL;
 
 static void
-on_users_loaded (GdmUserManager *manager,
-                 gpointer        data)
+on_is_loaded_changed (GdmUserManager *manager,
+                      GParamSpec     *pspec,
+                      gpointer        data)
 {
         GSList *users;
 
@@ -86,8 +87,8 @@ main (int argc, char *argv[])
 
         manager = gdm_user_manager_ref_default ();
         g_signal_connect (manager,
-                          "users-loaded",
-                          G_CALLBACK (on_users_loaded),
+                          "notify::is-loaded",
+                          G_CALLBACK (on_is_loaded_changed),
                           NULL);
         g_signal_connect (manager,
                           "user-added",
diff --git a/gui/user-switch-applet/applet.c b/gui/user-switch-applet/applet.c
index 0d766a2..6e744bf 100644
--- a/gui/user-switch-applet/applet.c
+++ b/gui/user-switch-applet/applet.c
@@ -741,8 +741,9 @@ on_manager_user_removed (GdmUserManager *manager,
 }
 
 static void
-on_manager_users_loaded (GdmUserManager *manager,
-                         GdmAppletData  *adata)
+on_manager_is_loaded_changed (GdmUserManager *manager,
+                              GParamSpec     *pspec,
+                              GdmAppletData  *adata)
 {
         update_switch_user (adata);
 }
@@ -1066,8 +1067,8 @@ create_sub_menu (GdmAppletData *adata)
         gtk_widget_show (adata->menu);
 
         g_signal_connect (adata->manager,
-                          "users-loaded",
-                          G_CALLBACK (on_manager_users_loaded),
+                          "notify::is-loaded",
+                          G_CALLBACK (on_manager_is_loaded_changed),
                           adata);
         g_signal_connect (adata->manager,
                           "user-added",



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