aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2012-06-03 15:30:28 -0500
committerCharles Kerr <charles.kerr@canonical.com>2012-06-03 15:30:28 -0500
commit3d6809119b9bdc0d144b7e4a3c23bca7ec2c3136 (patch)
treec4dc4622c7c762bb32612e36cd0e1c8bfccbb4bd /src
parent4823f27147e1a7a604d511acde9750d65190c865 (diff)
downloadayatana-indicator-session-3d6809119b9bdc0d144b7e4a3c23bca7ec2c3136.tar.gz
ayatana-indicator-session-3d6809119b9bdc0d144b7e4a3c23bca7ec2c3136.tar.bz2
ayatana-indicator-session-3d6809119b9bdc0d144b7e4a3c23bca7ec2c3136.zip
Remove the seemingly-pointless MINIMUM_USERS constant
Diffstat (limited to 'src')
-rw-r--r--src/user-menu-mgr.c94
-rw-r--r--src/users-service-dbus.c145
-rw-r--r--src/users-service-dbus.h5
3 files changed, 116 insertions, 128 deletions
diff --git a/src/user-menu-mgr.c b/src/user-menu-mgr.c
index 86d3035..e965094 100644
--- a/src/user-menu-mgr.c
+++ b/src/user-menu-mgr.c
@@ -193,9 +193,7 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self, gboolean greeter_mode)
- if (self->user_count > MINIMUM_USERS) {
- users = g_list_sort (users, (GCompareFunc)compare_users_by_username);
- }
+ users = g_list_sort (users, (GCompareFunc)compare_users_by_username);
for (u = users; u != NULL; u = g_list_next (u)) {
UserData *user;
@@ -208,54 +206,52 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self, gboolean greeter_mode)
session_dbus_set_users_real_name (self->session_dbus_interface, user->real_name);
}
- if (self->user_count > MINIMUM_USERS) {
- DbusmenuMenuitem * mi = dbusmenu_menuitem_new ();
+ DbusmenuMenuitem * mi = dbusmenu_menuitem_new ();
+ dbusmenu_menuitem_property_set (mi,
+ DBUSMENU_MENUITEM_PROP_TYPE,
+ USER_ITEM_TYPE);
+ if (user->real_name_conflict) {
+ gchar * conflictedname = g_strdup_printf("%s (%s)", user->real_name, user->user_name);
+ dbusmenu_menuitem_property_set (mi, USER_ITEM_PROP_NAME, conflictedname);
+ g_free(conflictedname);
+ } else {
+ //g_debug ("%p: %s", user, user->real_name);
+ dbusmenu_menuitem_property_set (mi,
+ USER_ITEM_PROP_NAME,
+ user->real_name);
+ }
+ dbusmenu_menuitem_property_set_bool (mi,
+ USER_ITEM_PROP_LOGGED_IN,
+ user->sessions != NULL);
+ if (user->icon_file != NULL && user->icon_file[0] != '\0') {
+ g_debug ("user %s has this icon : %s",
+ user->user_name,
+ user->icon_file);
+ dbusmenu_menuitem_property_set (mi,
+ USER_ITEM_PROP_ICON,
+ user->icon_file);
+ } else {
dbusmenu_menuitem_property_set (mi,
- DBUSMENU_MENUITEM_PROP_TYPE,
- USER_ITEM_TYPE);
- if (user->real_name_conflict) {
- gchar * conflictedname = g_strdup_printf("%s (%s)", user->real_name, user->user_name);
- dbusmenu_menuitem_property_set (mi, USER_ITEM_PROP_NAME, conflictedname);
- g_free(conflictedname);
- } else {
- //g_debug ("%p: %s", user, user->real_name);
- dbusmenu_menuitem_property_set (mi,
- USER_ITEM_PROP_NAME,
- user->real_name);
- }
- dbusmenu_menuitem_property_set_bool (mi,
- USER_ITEM_PROP_LOGGED_IN,
- user->sessions != NULL);
- if (user->icon_file != NULL && user->icon_file[0] != '\0') {
- g_debug ("user %s has this icon : %s",
- user->user_name,
- user->icon_file);
- dbusmenu_menuitem_property_set (mi,
- USER_ITEM_PROP_ICON,
- user->icon_file);
- } else {
- dbusmenu_menuitem_property_set (mi,
- USER_ITEM_PROP_ICON,
- USER_ITEM_ICON_DEFAULT);
- }
-
-
- /*g_debug ("user name = %s and g user name = %s",
- user->user_name,
- g_get_user_name());*/
-
- dbusmenu_menuitem_property_set_bool (mi,
- USER_ITEM_PROP_IS_CURRENT_USER,
- current_user);
- dbusmenu_menuitem_child_append (self->root_item, mi);
-
- struct ActivateUserSessionData * data = g_new (struct ActivateUserSessionData, 1);
- data->user = user;
- data->menu_mgr = self;
- g_signal_connect_data (mi, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
- G_CALLBACK (activate_user_session),
- data, (GClosureNotify)g_free, 0);
+ USER_ITEM_PROP_ICON,
+ USER_ITEM_ICON_DEFAULT);
}
+
+
+ /*g_debug ("user name = %s and g user name = %s",
+ user->user_name,
+ g_get_user_name());*/
+
+ dbusmenu_menuitem_property_set_bool (mi,
+ USER_ITEM_PROP_IS_CURRENT_USER,
+ current_user);
+ dbusmenu_menuitem_child_append (self->root_item, mi);
+
+ struct ActivateUserSessionData * data = g_new (struct ActivateUserSessionData, 1);
+ data->user = user;
+ data->menu_mgr = self;
+ g_signal_connect_data (mi, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
+ G_CALLBACK (activate_user_session),
+ data, (GClosureNotify)g_free, 0);
}
g_list_free(users);
}
diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c
index 09f916d..e6d094c 100644
--- a/src/users-service-dbus.c
+++ b/src/users-service-dbus.c
@@ -718,91 +718,88 @@ sync_users (UsersServiceDbus *self)
g_return_if_fail(IS_USERS_SERVICE_DBUS(self));
UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (self);
- if (priv->count > MINIMUM_USERS)
+ GPtrArray *users = NULL;
+ GError *error = NULL;
+ gint i;
+
+ users = g_ptr_array_new ();
+
+ if (!org_freedesktop_Accounts_list_cached_users (priv->accounts_service_proxy,
+ &users,
+ &error))
+ {
+ g_warning ("failed to retrieve user list: %s", error->message);
+ g_error_free (error);
+
+ return;
+ }
+
+ for (i = 0; i < users->len; i++)
{
- GPtrArray *users = NULL;
+ gchar *id;
+ DBusGProxy *proxy;
+ UserData *user;
GError *error = NULL;
- gint i;
- users = g_ptr_array_new ();
+ id = g_ptr_array_index (users, i);
+
+ proxy = dbus_g_proxy_new_for_name (priv->system_bus,
+ "org.freedesktop.Accounts",
+ id,
+ "org.freedesktop.DBus.Properties");
- if (!org_freedesktop_Accounts_list_cached_users (priv->accounts_service_proxy,
- &users,
- &error))
+ GHashTable *properties;
+ if (!dbus_g_proxy_call (proxy, "GetAll", &error,
+ G_TYPE_STRING, "org.freedesktop.Accounts.User", G_TYPE_INVALID,
+ dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), &properties, G_TYPE_INVALID))
{
- g_warning ("failed to retrieve user list: %s", error->message);
+ g_warning ("unable to retrieve user info: %s", error->message);
g_error_free (error);
- return;
+ continue;
}
-
- for (i = 0; i < users->len; i++)
+
+ user = g_hash_table_lookup (priv->users, id);
+ // Double check we havent processed this user already
+ if (user != NULL)
{
- gchar *id;
- DBusGProxy *proxy;
- UserData *user;
- GError *error = NULL;
-
- id = g_ptr_array_index (users, i);
-
- proxy = dbus_g_proxy_new_for_name (priv->system_bus,
- "org.freedesktop.Accounts",
- id,
- "org.freedesktop.DBus.Properties");
-
- GHashTable *properties;
- if (!dbus_g_proxy_call (proxy, "GetAll", &error,
- G_TYPE_STRING, "org.freedesktop.Accounts.User", G_TYPE_INVALID,
- dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), &properties, G_TYPE_INVALID))
- {
- g_warning ("unable to retrieve user info: %s", error->message);
- g_error_free (error);
-
- continue;
- }
-
- user = g_hash_table_lookup (priv->users, id);
- // Double check we havent processed this user already
- if (user != NULL)
- {
- g_free(user->user_name);
- g_free(user->real_name);
- g_free(user->icon_file);
- user->real_name_conflict = FALSE;
- //continue;
- }
- else
- {
- user = g_new0 (UserData, 1);
- }
- // Can't subscribe to the Changed signal on each individual user path
- // for some reason.
- dbus_g_proxy_add_signal (proxy,
- "Changed",
- G_TYPE_INVALID);
-
- dbus_g_proxy_connect_signal (proxy, "Changed",
- G_CALLBACK(user_changed),
- self,
- NULL);
- user->uid = g_value_get_uint64 (g_hash_table_lookup (properties, "Uid"));
- user->user_name = g_strdup (g_value_get_string (g_hash_table_lookup (properties, "UserName")));
- user->real_name = g_strdup (g_value_get_string (g_hash_table_lookup (properties, "RealName")));
- user->icon_file = g_strdup (g_value_get_string (g_hash_table_lookup (properties, "IconFile")));
- user->real_name_conflict = FALSE;
- user->menuitem = NULL;
-
- g_hash_table_unref (properties);
-
- g_hash_table_insert (priv->users,
- g_strdup (id),
- user);
-
- add_sessions_for_user (self, user);
+ g_free(user->user_name);
+ g_free(user->real_name);
+ g_free(user->icon_file);
+ user->real_name_conflict = FALSE;
+ //continue;
}
-
- g_ptr_array_free (users, TRUE);
+ else
+ {
+ user = g_new0 (UserData, 1);
+ }
+ // Can't subscribe to the Changed signal on each individual user path
+ // for some reason.
+ dbus_g_proxy_add_signal (proxy,
+ "Changed",
+ G_TYPE_INVALID);
+
+ dbus_g_proxy_connect_signal (proxy, "Changed",
+ G_CALLBACK(user_changed),
+ self,
+ NULL);
+ user->uid = g_value_get_uint64 (g_hash_table_lookup (properties, "Uid"));
+ user->user_name = g_strdup (g_value_get_string (g_hash_table_lookup (properties, "UserName")));
+ user->real_name = g_strdup (g_value_get_string (g_hash_table_lookup (properties, "RealName")));
+ user->icon_file = g_strdup (g_value_get_string (g_hash_table_lookup (properties, "IconFile")));
+ user->real_name_conflict = FALSE;
+ user->menuitem = NULL;
+
+ g_hash_table_unref (properties);
+
+ g_hash_table_insert (priv->users,
+ g_strdup (id),
+ user);
+
+ add_sessions_for_user (self, user);
}
+
+ g_ptr_array_free (users, TRUE);
}
static void
diff --git a/src/users-service-dbus.h b/src/users-service-dbus.h
index c81e768..66f3b9d 100644
--- a/src/users-service-dbus.h
+++ b/src/users-service-dbus.h
@@ -52,11 +52,6 @@ struct _UserData
DbusmenuMenuitem * menuitem;
};
-/* XXX - MAXIMUM_USERS should be set to 7 once we've
- * got some gdm issues worked out.
- */
-#define MINIMUM_USERS 0
-
struct _UsersServiceDbus {
GObject parent;
};