aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-02-08 16:42:43 -0600
committerTed Gould <ted@gould.cx>2010-02-08 16:42:43 -0600
commit3ac26591413939bbf52e2303eb5ba5010c28d71b (patch)
tree18455ac8192f0da0be55d857e1b78613c8eeaf0f /src
parent4b6ca8a15df3a57ba2a54c76a90090f9360709a7 (diff)
parent19ebc417eafb4cea2e9e1d5656c46148d8f100ed (diff)
downloadayatana-indicator-session-3ac26591413939bbf52e2303eb5ba5010c28d71b.tar.gz
ayatana-indicator-session-3ac26591413939bbf52e2303eb5ba5010c28d71b.tar.bz2
ayatana-indicator-session-3ac26591413939bbf52e2303eb5ba5010c28d71b.zip
Checking the lockdown key for user switching.
Diffstat (limited to 'src')
-rw-r--r--src/session-service.c72
1 files changed, 67 insertions, 5 deletions
diff --git a/src/session-service.c b/src/session-service.c
index 8306d02..791611e 100644
--- a/src/session-service.c
+++ b/src/session-service.c
@@ -50,6 +50,9 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#define GUEST_SESSION_LAUNCHER "/usr/share/gdm/guest-session/guest-session-launch"
+#define LOCKDOWN_DIR "/desktop/gnome/lockdown"
+#define LOCKDOWN_KEY LOCKDOWN_DIR "/disable_user_switching"
+
typedef struct _ActivateData ActivateData;
struct _ActivateData
{
@@ -62,6 +65,7 @@ static DBusGProxy *gdm_proxy = NULL;
static UsersServiceDbus *dbus_interface = NULL;
static DbusmenuMenuitem *lock_menuitem = NULL;
+static DbusmenuMenuitem *switch_menuitem = NULL;
static gint count;
static GList *users;
@@ -80,6 +84,53 @@ static DbusmenuMenuitem * logout_mi = NULL;
static DbusmenuMenuitem * restart_mi = NULL;
static DbusmenuMenuitem * shutdown_mi = NULL;
+static GConfClient * gconf_client = NULL;
+static guint notify_lockdown_id = 0;
+
+static void
+lockdown_changed (GConfClient *client,
+ guint cnxd_id,
+ GConfEntry *entry,
+ gpointer user_data)
+{
+ GConfValue *value = gconf_entry_get_value (entry);
+ const gchar *key = gconf_entry_get_key (entry);
+
+ if (!value || !key)
+ return;
+
+ if (g_strcmp0 (key, LOCKDOWN_KEY) == 0)
+ {
+ if (switch_menuitem)
+ {
+ if (gconf_value_get_bool (value))
+ {
+ dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
+ }
+ else
+ {
+ dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
+ }
+ }
+ }
+}
+
+static void
+ensure_gconf_client (void)
+{
+ if (!gconf_client)
+ {
+ gconf_client = gconf_client_get_default ();
+
+ notify_lockdown_id = gconf_client_notify_add (gconf_client,
+ LOCKDOWN_KEY,
+ lockdown_changed,
+ NULL,
+ NULL,
+ NULL);
+ }
+}
+
/* A return from the command to sleep the system. Make sure
that we unthrottle the screensaver. */
static void
@@ -441,13 +492,24 @@ rebuild_items (DbusmenuMenuitem *root,
if (check_new_session ())
{
- mi = dbusmenu_menuitem_new ();
- dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Switch User..."));
- dbusmenu_menuitem_child_append (root, mi);
- g_signal_connect (G_OBJECT (mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_new_session), NULL);
+ ensure_gconf_client ();
+
+ switch_menuitem = dbusmenu_menuitem_new ();
+ dbusmenu_menuitem_property_set (switch_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _("Switch User..."));
+ dbusmenu_menuitem_child_append (root, switch_menuitem);
+ g_signal_connect (G_OBJECT (switch_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_new_session), NULL);
+
+ if (gconf_client_get_bool (gconf_client, LOCKDOWN_KEY, NULL))
+ {
+ dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
+ }
+ else
+ {
+ dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
+ }
}
}
-
+
DbusmenuMenuitem * separator = dbusmenu_menuitem_new();
dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR);
dbusmenu_menuitem_child_append(root, separator);