aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCody Russell <crussell@canonical.com>2009-09-24 10:31:55 -0500
committerCody Russell <crussell@canonical.com>2009-09-24 10:31:55 -0500
commit62f44cf97e38da112c70afeb8545d87042d251e2 (patch)
treeee521fbca703825b7d11ec8339a1f24d34b3a73a /src
parent3e9432a11979cc8909c8a4db3c0b22651e11e638 (diff)
downloadayatana-indicator-session-62f44cf97e38da112c70afeb8545d87042d251e2.tar.gz
ayatana-indicator-session-62f44cf97e38da112c70afeb8545d87042d251e2.tar.bz2
ayatana-indicator-session-62f44cf97e38da112c70afeb8545d87042d251e2.zip
only add menuitems if the current seat can activate new sessions
Diffstat (limited to 'src')
-rw-r--r--src/users-service.c70
1 files changed, 38 insertions, 32 deletions
diff --git a/src/users-service.c b/src/users-service.c
index 1fb8d36..51c6c5d 100644
--- a/src/users-service.c
+++ b/src/users-service.c
@@ -183,6 +183,9 @@ rebuild_items (DbusmenuMenuitem *root,
DbusmenuMenuitem *mi = NULL;
GList *u;
UserData *user;
+ gboolean can_activate;
+
+ can_activate = users_service_dbus_can_activate_session (service);
dbusmenu_menuitem_foreach (root, remove_menu_item, NULL);
@@ -191,55 +194,58 @@ rebuild_items (DbusmenuMenuitem *root,
g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(lock_screen), NULL);
dbusmenu_menuitem_child_append(root, mi);
- if (check_guest_session ())
+ if (can_activate == TRUE)
{
- mi = dbusmenu_menuitem_new ();
- dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Guest Session"));
- dbusmenu_menuitem_child_append (root, mi);
- g_signal_connect (G_OBJECT (mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_guest_session), NULL);
- }
+ if (check_guest_session ())
+ {
+ mi = dbusmenu_menuitem_new ();
+ dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Guest Session"));
+ dbusmenu_menuitem_child_append (root, mi);
+ g_signal_connect (G_OBJECT (mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_guest_session), NULL);
+ }
- if (count > 1 && count < 7)
- {
- if (count > MINIMUM_USERS && count < MAXIMUM_USERS)
+ if (count > 1 && count < 7)
{
- if (users != NULL)
+ if (count > MINIMUM_USERS && count < MAXIMUM_USERS)
{
- GList *l = NULL;
-
- for (l = users; l != NULL; l = l->next)
+ if (users != NULL)
{
- users = g_list_delete_link (users, l);
+ GList *l = NULL;
+
+ for (l = users; l != NULL; l = l->next)
+ {
+ users = g_list_delete_link (users, l);
+ }
+
+ users = NULL;
}
- users = NULL;
+ users = users_service_dbus_get_user_list (service);
}
- users = users_service_dbus_get_user_list (service);
- }
+ 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))
+ {
+ user = u->data;
- for (u = users; u != NULL; u = g_list_next (u))
- {
- user = u->data;
+ user->service = service;
- user->service = service;
+ mi = dbusmenu_menuitem_new ();
+ dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_LABEL, user->real_name);
+ dbusmenu_menuitem_child_append (root, mi);
+ g_signal_connect (G_OBJECT (mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_user_session), user);
+ }
+ }
+ if (check_new_session ())
+ {
mi = dbusmenu_menuitem_new ();
- dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_LABEL, user->real_name);
+ dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_LABEL, _("New Session..."));
dbusmenu_menuitem_child_append (root, mi);
- g_signal_connect (G_OBJECT (mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_user_session), user);
+ g_signal_connect (G_OBJECT (mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_new_session), NULL);
}
}
-
- if (check_new_session ())
- {
- mi = dbusmenu_menuitem_new ();
- dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_LABEL, _("New Session..."));
- dbusmenu_menuitem_child_append (root, mi);
- g_signal_connect (G_OBJECT (mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_new_session), NULL);
- }
}
static void