[gdm] Drop "user-login-frequency-changed" signal in favor of "changed"



commit a4f59673325ba5aeba0381ffd889bb61bbbaff9f
Author: Ray Strode <rstrode redhat com>
Date:   Mon Mar 15 23:30:01 2010 -0400

    Drop "user-login-frequency-changed" signal in favor of "changed"
    
    It's less specific and will let us handle the other properties changes
    at the same time.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=610179

 gui/simple-greeter/gdm-user-chooser-widget.c |   58 ++++++++++++++++++++------
 gui/simple-greeter/gdm-user-manager.c        |   24 ++++++++---
 gui/simple-greeter/gdm-user-manager.h        |    2 +-
 gui/simple-greeter/gdm-user-private.h        |    4 ++
 gui/simple-greeter/gdm-user.c                |   22 ++++++++++
 5 files changed, 90 insertions(+), 20 deletions(-)
---
diff --git a/gui/simple-greeter/gdm-user-chooser-widget.c b/gui/simple-greeter/gdm-user-chooser-widget.c
index a17ea92..d5e0827 100644
--- a/gui/simple-greeter/gdm-user-chooser-widget.c
+++ b/gui/simple-greeter/gdm-user-chooser-widget.c
@@ -461,21 +461,53 @@ on_user_is_logged_in_changed (GdmUserManager       *manager,
 }
 
 static void
-on_user_login_frequency_changed (GdmUserManager       *manager,
-                                 GdmUser              *user,
-                                 GdmUserChooserWidget *widget)
+on_user_changed (GdmUserManager       *manager,
+                 GdmUser              *user,
+                 GdmUserChooserWidget *widget)
 {
-        const char *user_name;
-        gulong      freq;
+        GdkPixbuf    *pixbuf;
+        char         *tooltip;
+        gboolean      is_logged_in;
+        int           size;
 
-        g_debug ("GdmUserChooserWidget: User login frequency changed: %s", gdm_user_get_user_name (user));
+        /* wait for all users to be loaded */
+        if (! widget->priv->loaded) {
+                return;
+        }
+        if (! widget->priv->show_normal_users) {
+                return;
+        }
 
-        user_name = gdm_user_get_user_name (user);
-        freq = gdm_user_get_login_frequency (user);
+        size = get_icon_height_for_widget (GTK_WIDGET (widget));
+        pixbuf = gdm_user_render_icon (user, size);
 
-        gdm_chooser_widget_set_item_priority (GDM_CHOOSER_WIDGET (widget),
-                                              user_name,
-                                              freq);
+        if (pixbuf == NULL && widget->priv->stock_person_pixbuf != NULL) {
+                pixbuf = g_object_ref (widget->priv->stock_person_pixbuf);
+        }
+
+        tooltip = g_strdup_printf (_("Log in as %s"),
+                                   gdm_user_get_user_name (user));
+
+        is_logged_in = gdm_user_is_logged_in (user);
+
+        g_debug ("GdmUserChooserWidget: User added name:%s logged-in:%d pixbuf:%p",
+                 gdm_user_get_user_name (user),
+                 is_logged_in,
+                 pixbuf);
+
+        gdm_chooser_widget_update_item (GDM_CHOOSER_WIDGET (widget),
+                                        gdm_user_get_user_name (user),
+                                        pixbuf,
+                                        gdm_user_get_real_name (user),
+                                        tooltip,
+                                        gdm_user_get_login_frequency (user),
+                                        is_logged_in,
+                                        FALSE);
+        g_free (tooltip);
+
+        if (pixbuf != NULL) {
+                g_object_unref (pixbuf);
+        }
 }
 
 static void
@@ -527,8 +559,8 @@ load_users (GdmUserChooserWidget *widget)
                                   G_CALLBACK (on_user_is_logged_in_changed),
                                   widget);
                 g_signal_connect (widget->priv->manager,
-                                  "user-login-frequency-changed",
-                                  G_CALLBACK (on_user_login_frequency_changed),
+                                  "user-changed",
+                                  G_CALLBACK (on_user_changed),
                                   widget);
         } else {
                 gdm_chooser_widget_loaded (GDM_CHOOSER_WIDGET (widget));
diff --git a/gui/simple-greeter/gdm-user-manager.c b/gui/simple-greeter/gdm-user-manager.c
index f1cd6b6..e8f1a9b 100644
--- a/gui/simple-greeter/gdm-user-manager.c
+++ b/gui/simple-greeter/gdm-user-manager.c
@@ -112,7 +112,7 @@ enum {
         USER_ADDED,
         USER_REMOVED,
         USER_IS_LOGGED_IN_CHANGED,
-        USER_LOGIN_FREQUENCY_CHANGED,
+        USER_CHANGED,
         LAST_SIGNAL
 };
 
@@ -448,6 +448,15 @@ on_user_sessions_changed (GdmUser        *user,
         g_signal_emit (manager, signals [USER_IS_LOGGED_IN_CHANGED], 0, user);
 }
 
+static void
+on_user_changed (GdmUser        *user,
+                 GdmUserManager *manager)
+{
+        g_debug ("GdmUserManager: user changed");
+
+        g_signal_emit (manager, signals[USER_CHANGED], 0, user);
+}
+
 static char *
 get_seat_id_for_session (DBusGConnection *connection,
                          const char      *session_id)
@@ -595,6 +604,10 @@ create_user (GdmUserManager *manager)
                           "sessions-changed",
                           G_CALLBACK (on_user_sessions_changed),
                           manager);
+        g_signal_connect (user,
+                          "changed",
+                          G_CALLBACK (on_user_changed),
+                          manager);
         return user;
 }
 
@@ -1092,8 +1105,7 @@ process_ck_history_line (GdmUserManager *manager,
                 return;
         }
 
-        g_object_set (user, "login-frequency", frequency, NULL);
-        g_signal_emit (manager, signals [USER_LOGIN_FREQUENCY_CHANGED], 0, user);
+        _gdm_user_update_login_frequency (user, frequency);
         g_free (username);
 }
 
@@ -1586,11 +1598,11 @@ gdm_user_manager_class_init (GdmUserManagerClass *klass)
                               NULL, NULL,
                               g_cclosure_marshal_VOID__OBJECT,
                               G_TYPE_NONE, 1, GDM_TYPE_USER);
-        signals [USER_LOGIN_FREQUENCY_CHANGED] =
-                g_signal_new ("user-login-frequency-changed",
+        signals [USER_CHANGED] =
+                g_signal_new ("user-changed",
                               G_TYPE_FROM_CLASS (klass),
                               G_SIGNAL_RUN_LAST,
-                              G_STRUCT_OFFSET (GdmUserManagerClass, user_login_frequency_changed),
+                              G_STRUCT_OFFSET (GdmUserManagerClass, user_changed),
                               NULL, NULL,
                               g_cclosure_marshal_VOID__OBJECT,
                               G_TYPE_NONE, 1, GDM_TYPE_USER);
diff --git a/gui/simple-greeter/gdm-user-manager.h b/gui/simple-greeter/gdm-user-manager.h
index ffccea1..79fac06 100644
--- a/gui/simple-greeter/gdm-user-manager.h
+++ b/gui/simple-greeter/gdm-user-manager.h
@@ -53,7 +53,7 @@ typedef struct
                                                      GdmUser        *user);
         void          (* user_is_logged_in_changed) (GdmUserManager *user_manager,
                                                      GdmUser        *user);
-        void          (* user_login_frequency_changed) (GdmUserManager *user_manager,
+        void          (* user_changed)              (GdmUserManager *user_manager,
                                                         GdmUser        *user);
 } GdmUserManagerClass;
 
diff --git a/gui/simple-greeter/gdm-user-private.h b/gui/simple-greeter/gdm-user-private.h
index a765199..a132dcd 100644
--- a/gui/simple-greeter/gdm-user-private.h
+++ b/gui/simple-greeter/gdm-user-private.h
@@ -32,6 +32,10 @@ G_BEGIN_DECLS
 
 void _gdm_user_update           (GdmUser             *user,
                                  const struct passwd *pwent);
+
+void _gdm_user_update_login_frequency (GdmUser *user,
+                                       guint64  login_frequency);
+
 void _gdm_user_add_session      (GdmUser             *user,
                                  const char          *session_id);
 void _gdm_user_remove_session   (GdmUser             *user,
diff --git a/gui/simple-greeter/gdm-user.c b/gui/simple-greeter/gdm-user.c
index 7efb9b6..4ff7a19 100644
--- a/gui/simple-greeter/gdm-user.c
+++ b/gui/simple-greeter/gdm-user.c
@@ -264,6 +264,28 @@ _gdm_user_update (GdmUser             *user,
 }
 
 /**
+ * _gdm_user_update_login_frequency:
+ * @user: the user object to update
+ *
+ * Updates the login frequency of @user
+ *
+ * Since: 1.0
+ **/
+void
+_gdm_user_update_login_frequency (GdmUser *user,
+                                  guint64  login_frequency)
+{
+        g_return_if_fail (GDM_IS_USER (user));
+
+        if (login_frequency == user->login_frequency) {
+                return;
+        }
+
+        user->login_frequency = login_frequency;
+        g_signal_emit (user, signals[CHANGED], 0);
+}
+
+/**
  * gdm_user_get_uid:
  * @user: the user object to examine.
  *



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