aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gconf-helper.c4
-rw-r--r--src/gtk-logout-helper.c2
-rw-r--r--src/session-service.c161
-rw-r--r--src/users-service-dbus.c1
-rw-r--r--src/users-service-dbus.h2
5 files changed, 83 insertions, 87 deletions
diff --git a/src/gconf-helper.c b/src/gconf-helper.c
index 213592e..9262b19 100644
--- a/src/gconf-helper.c
+++ b/src/gconf-helper.c
@@ -51,11 +51,11 @@ static void update_menu_entries_callback (GConfClient *client, guint cnxn_id, GC
if (gconf_value_get_bool (value)) {
dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->logout_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Log Out"));
dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->restart_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Restart"));
- dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Shutdown"));
+ dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Switch Off"));
} else {
dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->logout_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Log Out..."));
dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->restart_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Restart..."));
- dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Shutdown..."));
+ dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Switch Off..."));
}
}
}
diff --git a/src/gtk-logout-helper.c b/src/gtk-logout-helper.c
index bf37ca7..64fba14 100644
--- a/src/gtk-logout-helper.c
+++ b/src/gtk-logout-helper.c
@@ -158,7 +158,7 @@ option_restart (const gchar * arg, const gchar * value, gpointer data, GError *
static GOptionEntry options[] = {
{"logout", 'l', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, option_logout, "Log out of the current session", NULL},
- {"shutdown", 's', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, option_shutdown, "Shutdown the entire system", NULL},
+ {"shutdown", 's', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, option_shutdown, "Switch off the entire system", NULL},
{"restart", 'r', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, option_restart, "Restart the system", NULL},
{NULL}
diff --git a/src/session-service.c b/src/session-service.c
index af3c3e5..88a79fe 100644
--- a/src/session-service.c
+++ b/src/session-service.c
@@ -68,9 +68,6 @@ static UsersServiceDbus *dbus_interface = NULL;
static DbusmenuMenuitem *lock_menuitem = NULL;
static DbusmenuMenuitem *switch_menuitem = NULL;
-static gint count;
-static GList *users;
-
static DbusmenuMenuitem * root_menuitem = NULL;
static GMainLoop * mainloop = NULL;
static DBusGProxy * up_main_proxy = NULL;
@@ -406,7 +403,15 @@ compare_users_by_username (const gchar *a,
UserData *user1 = (UserData *)a;
UserData *user2 = (UserData *)b;
- return g_strcmp0 (user1->user_name, user2->user_name);
+ gint retval = g_strcmp0 (user1->real_name, user2->real_name);
+
+ /* If they're the same, they're both in conflict. */
+ if (retval == 0) {
+ user1->real_name_conflict = TRUE;
+ user2->real_name_conflict = TRUE;
+ }
+
+ return retval;
}
/* Builds up the menu for us */
@@ -415,6 +420,7 @@ rebuild_items (DbusmenuMenuitem *root,
UsersServiceDbus *service)
{
DbusmenuMenuitem *mi = NULL;
+ DbusmenuMenuitem * guest_mi = NULL;
GList *u;
UserData *user;
gboolean can_activate;
@@ -444,12 +450,12 @@ rebuild_items (DbusmenuMenuitem *root,
if (check_guest_session ())
{
- mi = dbusmenu_menuitem_new ();
- dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_TYPE, USER_ITEM_TYPE);
- dbusmenu_menuitem_property_set (mi, USER_ITEM_PROP_NAME, _("Guest Session"));
- dbusmenu_menuitem_property_set_bool (mi, USER_ITEM_PROP_LOGGED_IN, FALSE);
- dbusmenu_menuitem_child_append (root, mi);
- g_signal_connect (G_OBJECT (mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_guest_session), NULL);
+ guest_mi = dbusmenu_menuitem_new ();
+ dbusmenu_menuitem_property_set (guest_mi, DBUSMENU_MENUITEM_PROP_TYPE, USER_ITEM_TYPE);
+ dbusmenu_menuitem_property_set (guest_mi, USER_ITEM_PROP_NAME, _("Guest Session"));
+ dbusmenu_menuitem_property_set_bool (guest_mi, USER_ITEM_PROP_LOGGED_IN, FALSE);
+ dbusmenu_menuitem_child_append (root, guest_mi);
+ g_signal_connect (G_OBJECT (guest_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_guest_session), NULL);
}
if (check_new_session ())
@@ -472,39 +478,55 @@ rebuild_items (DbusmenuMenuitem *root,
}
}
- if (count > MINIMUM_USERS && count < MAXIMUM_USERS)
- {
- if (users != NULL)
- {
- GList *l = NULL;
-
- for (l = users; l != NULL; l = l->next)
- {
- users = g_list_delete_link (users, l);
- }
-
- users = NULL;
- }
-
- users = users_service_dbus_get_user_list (service);
-
- users = g_list_sort (users, (GCompareFunc)compare_users_by_username);
-
- for (u = users; u != NULL; u = g_list_next (u))
- {
- user = u->data;
-
- user->service = service;
-
- mi = dbusmenu_menuitem_new ();
- dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_TYPE, USER_ITEM_TYPE);
- 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);
- dbusmenu_menuitem_child_append (root, mi);
- g_signal_connect (G_OBJECT (mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_user_session), user);
- }
- }
- }
+ GList * users = NULL;
+ users = users_service_dbus_get_user_list (service);
+ guint user_count = g_list_length(users);
+
+ if (user_count > MINIMUM_USERS && user_count < MAXIMUM_USERS) {
+ users = g_list_sort (users, (GCompareFunc)compare_users_by_username);
+ }
+
+ for (u = users; u != NULL; u = g_list_next (u)) {
+ user = u->data;
+ user->service = service;
+
+ if (user->uid == getuid()) {
+ /* Hide me from the list */
+ continue;
+ }
+
+ if (g_strcmp0(user->user_name, "guest") == 0) {
+ /* Check to see if the guest has sessions and so therefore should
+ get a check mark. */
+ if (user->sessions != NULL) {
+ dbusmenu_menuitem_property_set_bool (guest_mi, USER_ITEM_PROP_LOGGED_IN, TRUE);
+ }
+ /* If we're showing user accounts, keep going through the list */
+ if (user_count > MINIMUM_USERS && user_count < MAXIMUM_USERS) {
+ continue;
+ }
+ /* If not, we can stop here */
+ break;
+ }
+
+ if (user_count > MINIMUM_USERS && user_count < MAXIMUM_USERS) {
+ 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 {
+ 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);
+ dbusmenu_menuitem_child_append (root, mi);
+ g_signal_connect (G_OBJECT (mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_user_session), user);
+ }
+ }
+
+ g_list_free(users);
+ }
DbusmenuMenuitem * separator = dbusmenu_menuitem_new();
dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR);
@@ -521,7 +543,7 @@ rebuild_items (DbusmenuMenuitem *root,
suspend_mi = dbusmenu_menuitem_new();
dbusmenu_menuitem_property_set_bool(suspend_mi, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
- dbusmenu_menuitem_property_set(suspend_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Suspend"));
+ dbusmenu_menuitem_property_set(suspend_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Sleep"));
dbusmenu_menuitem_child_append(root, suspend_mi);
g_signal_connect(G_OBJECT(suspend_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(machine_sleep), "Suspend");
@@ -542,9 +564,9 @@ rebuild_items (DbusmenuMenuitem *root,
shutdown_mi = dbusmenu_menuitem_new();
if (supress_confirmations()) {
- dbusmenu_menuitem_property_set(shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Shut Down"));
+ dbusmenu_menuitem_property_set(shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Switch Off"));
} else {
- dbusmenu_menuitem_property_set(shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Shut Down..."));
+ dbusmenu_menuitem_property_set(shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Switch Off..."));
}
dbusmenu_menuitem_child_append(root, shutdown_mi);
g_signal_connect(G_OBJECT(shutdown_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_dialog), "shutdown");
@@ -562,42 +584,13 @@ rebuild_items (DbusmenuMenuitem *root,
/* Signal called when a user is added. It updates the count and
rebuilds the menu */
static void
-user_added (UsersServiceDbus *service,
- UserData *user,
- gpointer user_data)
+user_change (UsersServiceDbus *service,
+ UserData *user,
+ gpointer user_data)
{
- DbusmenuMenuitem *root = (DbusmenuMenuitem *)user_data;
-
- count++;
-
- rebuild_items (root, service);
-}
-
-/* Signal called when a user is deleted. It updates the count and
- rebuilds the menu */
-static void
-user_removed (UsersServiceDbus *service,
- UserData *user,
- gpointer user_data)
-{
- DbusmenuMenuitem *root = (DbusmenuMenuitem *)user_data;
-
- count--;
-
- rebuild_items (root, service);
-}
-
-/* Wrapper around rebuild_items that is used on the first call
- so that we can initialize the count variable. */
-static void
-create_items (DbusmenuMenuitem *root,
- UsersServiceDbus *service)
-{
- g_return_if_fail (IS_USERS_SERVICE_DBUS (service));
-
- count = users_service_dbus_get_user_count (service);
-
- rebuild_items (root, service);
+ DbusmenuMenuitem *root = (DbusmenuMenuitem *)user_data;
+ rebuild_items (root, service);
+ return;
}
/* When the service interface starts to shutdown, we
@@ -638,15 +631,15 @@ main (int argc, char ** argv)
dbus_interface = g_object_new (USERS_SERVICE_DBUS_TYPE, NULL);
- create_items (root_menuitem, dbus_interface);
+ rebuild_items (root_menuitem, dbus_interface);
g_signal_connect (G_OBJECT (dbus_interface),
"user-added",
- G_CALLBACK (user_added),
+ G_CALLBACK (user_change),
root_menuitem);
g_signal_connect (G_OBJECT (dbus_interface),
"user-removed",
- G_CALLBACK (user_removed),
+ G_CALLBACK (user_change),
root_menuitem);
setup_up();
diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c
index 2b984cd..4aefdff 100644
--- a/src/users-service-dbus.c
+++ b/src/users-service-dbus.c
@@ -656,6 +656,7 @@ sync_users (UsersServiceDbus *self)
user->shell = g_strdup (g_value_get_string (g_value_array_get_nth (values, 3)));
user->login_count = g_value_get_int (g_value_array_get_nth (values, 4));
user->icon_url = g_strdup (g_value_get_string (g_value_array_get_nth (values, 5)));
+ user->real_name_conflict = FALSE;
g_hash_table_insert (priv->users,
g_strdup (user->user_name),
diff --git a/src/users-service-dbus.h b/src/users-service-dbus.h
index 41052f8..bba88a7 100644
--- a/src/users-service-dbus.h
+++ b/src/users-service-dbus.h
@@ -47,6 +47,8 @@ struct _UserData
GList *sessions;
+ gboolean real_name_conflict;
+
UsersServiceDbus *service;
};