[gdm/gnome-2-30] Drop user properties in favor of a "changed" signal
- From: William Jon McCann <mccann src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdm/gnome-2-30] Drop user properties in favor of a "changed" signal
- Date: Fri, 11 Jun 2010 01:50:39 +0000 (UTC)
commit f5742b27d6921858e27d53a07c11793c34423b9a
Author: Ray Strode <rstrode redhat com>
Date: Mon Mar 15 14:21:56 2010 -0400
Drop user properties in favor of a "changed" signal
This is less specific, but good enough, and will make
changing out the backend easier.
https://bugzilla.gnome.org/show_bug.cgi?id=610179
gui/simple-greeter/gdm-user.c | 147 +++++----------------------------------
gui/user-switch-applet/applet.c | 28 ++------
2 files changed, 26 insertions(+), 149 deletions(-)
---
diff --git a/gui/simple-greeter/gdm-user.c b/gui/simple-greeter/gdm-user.c
index 3dcf932..c2faf0f 100644
--- a/gui/simple-greeter/gdm-user.c
+++ b/gui/simple-greeter/gdm-user.c
@@ -42,16 +42,7 @@
#define MINIMAL_UID 100
enum {
- PROP_0,
- PROP_REAL_NAME,
- PROP_USER_NAME,
- PROP_UID,
- PROP_HOME_DIR,
- PROP_SHELL,
- PROP_LOGIN_FREQUENCY,
-};
-
-enum {
+ CHANGED,
SESSIONS_CHANGED,
LAST_SIGNAL
};
@@ -146,125 +137,22 @@ gdm_user_get_sessions (GdmUser *user)
}
static void
-_gdm_user_set_login_frequency (GdmUser *user,
- gulong login_frequency)
-{
- user->login_frequency = login_frequency;
- g_object_notify (G_OBJECT (user), "login-frequency");
-}
-
-static void
-gdm_user_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GdmUser *user;
-
- user = GDM_USER (object);
-
- switch (param_id) {
- case PROP_LOGIN_FREQUENCY:
- _gdm_user_set_login_frequency (user, g_value_get_ulong (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- }
-}
-
-static void
-gdm_user_get_property (GObject *object,
- guint param_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GdmUser *user;
-
- user = GDM_USER (object);
-
- switch (param_id) {
- case PROP_USER_NAME:
- g_value_set_string (value, user->user_name);
- break;
- case PROP_REAL_NAME:
- g_value_set_string (value, user->real_name);
- break;
- case PROP_HOME_DIR:
- g_value_set_string (value, user->home_dir);
- break;
- case PROP_UID:
- g_value_set_ulong (value, user->uid);
- break;
- case PROP_SHELL:
- g_value_set_string (value, user->shell);
- break;
- case PROP_LOGIN_FREQUENCY:
- g_value_set_ulong (value, user->login_frequency);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- }
-}
-
-static void
gdm_user_class_init (GdmUserClass *class)
{
GObjectClass *gobject_class;
gobject_class = G_OBJECT_CLASS (class);
- gobject_class->set_property = gdm_user_set_property;
- gobject_class->get_property = gdm_user_get_property;
gobject_class->finalize = gdm_user_finalize;
- g_object_class_install_property (gobject_class,
- PROP_REAL_NAME,
- g_param_spec_string ("real-name",
- "Real Name",
- "The real name to display for this user.",
- NULL,
- G_PARAM_READABLE));
-
- g_object_class_install_property (gobject_class,
- PROP_UID,
- g_param_spec_ulong ("uid",
- "User ID",
- "The UID for this user.",
- 0, G_MAXULONG, 0,
- G_PARAM_READABLE));
- g_object_class_install_property (gobject_class,
- PROP_USER_NAME,
- g_param_spec_string ("user-name",
- "User Name",
- "The login name for this user.",
- NULL,
- G_PARAM_READABLE));
- g_object_class_install_property (gobject_class,
- PROP_HOME_DIR,
- g_param_spec_string ("home-directory",
- "Home Directory",
- "The home directory for this user.",
- NULL,
- G_PARAM_READABLE));
- g_object_class_install_property (gobject_class,
- PROP_SHELL,
- g_param_spec_string ("shell",
- "Shell",
- "The shell for this user.",
- NULL,
- G_PARAM_READABLE));
- g_object_class_install_property (gobject_class,
- PROP_LOGIN_FREQUENCY,
- g_param_spec_ulong ("login-frequency",
- "login frequency",
- "login frequency",
- 0,
- G_MAXULONG,
- 0,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
+ signals [CHANGED] =
+ g_signal_new ("changed",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
signals [SESSIONS_CHANGED] =
g_signal_new ("sessions-changed",
G_TYPE_FROM_CLASS (class),
@@ -311,11 +199,12 @@ _gdm_user_update (GdmUser *user,
const struct passwd *pwent)
{
gchar *real_name = NULL;
+ gboolean changed;
g_return_if_fail (GDM_IS_USER (user));
g_return_if_fail (pwent != NULL);
- g_object_freeze_notify (G_OBJECT (user));
+ changed = FALSE;
/* Display Name */
if (pwent->pw_gecos && pwent->pw_gecos[0] != '\0') {
@@ -355,7 +244,7 @@ _gdm_user_update (GdmUser *user,
strcmp (real_name, user->real_name) != 0)) {
g_free (user->real_name);
user->real_name = real_name;
- g_object_notify (G_OBJECT (user), "real-name");
+ changed = TRUE;
} else {
g_free (real_name);
}
@@ -363,7 +252,7 @@ _gdm_user_update (GdmUser *user,
/* UID */
if (pwent->pw_uid != user->uid) {
user->uid = pwent->pw_uid;
- g_object_notify (G_OBJECT (user), "uid");
+ changed = TRUE;
}
/* Username */
@@ -374,7 +263,7 @@ _gdm_user_update (GdmUser *user,
strcmp (user->user_name, pwent->pw_name) != 0)) {
g_free (user->user_name);
user->user_name = g_strdup (pwent->pw_name);
- g_object_notify (G_OBJECT (user), "user-name");
+ changed = TRUE;
}
/* Home Directory */
@@ -383,7 +272,7 @@ _gdm_user_update (GdmUser *user,
strcmp (user->home_dir, pwent->pw_dir) != 0) {
g_free (user->home_dir);
user->home_dir = g_strdup (pwent->pw_dir);
- g_object_notify (G_OBJECT (user), "home-directory");
+ changed = TRUE;
}
/* Shell */
@@ -394,10 +283,12 @@ _gdm_user_update (GdmUser *user,
strcmp (user->shell, pwent->pw_shell) != 0)) {
g_free (user->shell);
user->shell = g_strdup (pwent->pw_shell);
- g_object_notify (G_OBJECT (user), "shell");
+ changed = TRUE;
}
- g_object_thaw_notify (G_OBJECT (user));
+ if (changed) {
+ g_signal_emit (user, signals[CHANGED], 0);
+ }
}
/**
diff --git a/gui/user-switch-applet/applet.c b/gui/user-switch-applet/applet.c
index f0c005f..5bc2b6c 100644
--- a/gui/user-switch-applet/applet.c
+++ b/gui/user-switch-applet/applet.c
@@ -80,7 +80,6 @@ typedef struct _GdmAppletData
guint client_notify_lockdown_id;
guint current_status;
- guint user_icon_changed_id;
guint user_notify_id;
gint8 pixel_size;
gint panel_size;
@@ -482,7 +481,6 @@ gdm_applet_data_free (GdmAppletData *adata)
gconf_client_notify_remove (adata->client, adata->client_notify_lockdown_id);
g_signal_handler_disconnect (adata->user, adata->user_notify_id);
- g_signal_handler_disconnect (adata->user, adata->user_icon_changed_id);
#ifdef BUILD_PRESENSE_STUFF
if (adata->presence_proxy != NULL) {
@@ -581,11 +579,12 @@ menuitem_style_set_cb (GtkWidget *menuitem,
}
static void
-user_notify_display_name_cb (GObject *object,
- GParamSpec *pspec,
- GdmAppletData *adata)
+on_user_changed (GdmUser *user,
+ GdmAppletData *adata)
{
+ g_debug ("user changed");
update_label (adata);
+ reset_icon (adata);
}
/* Called every time the menu is displayed (and also for some reason
@@ -1284,14 +1283,6 @@ reset_icon (GdmAppletData *adata)
}
static void
-on_user_icon_changed (GdmUser *user,
- GdmAppletData *adata)
-{
- g_debug ("User icon changed");
- reset_icon (adata);
-}
-
-static void
setup_current_user (GdmAppletData *adata)
{
const char *name;
@@ -1319,16 +1310,11 @@ setup_current_user (GdmAppletData *adata)
if (adata->user != NULL) {
reset_icon (adata);
- adata->user_icon_changed_id =
- g_signal_connect (adata->user,
- "icon-changed",
- G_CALLBACK (on_user_icon_changed),
- adata);
adata->user_notify_id =
g_signal_connect (adata->user,
- "notify::display-name",
- G_CALLBACK (user_notify_display_name_cb),
- adata);
+ "changed",
+ G_CALLBACK (on_user_changed),
+ adata);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]