diff options
-rw-r--r-- | data/indicator-session.schemas.in | 11 | ||||
-rw-r--r-- | src/gconf-helper.c | 23 | ||||
-rw-r--r-- | src/gconf-helper.h | 8 | ||||
-rw-r--r-- | src/session-service.c | 3 |
4 files changed, 40 insertions, 5 deletions
diff --git a/data/indicator-session.schemas.in b/data/indicator-session.schemas.in index 1db9226..bb8a147 100644 --- a/data/indicator-session.schemas.in +++ b/data/indicator-session.schemas.in @@ -13,5 +13,16 @@ restart and shutdown actions.</long> </locale> </schema> + <schema> + <key>/schemas/apps/indicator-session/suppress_logout_menuitem</key> + <applyto>/apps/indicator-session/suppress_logout_menuitem</applyto> + <owner>indicator-session</owner> + <type>bool</type> + <default>FALSE</default> + <locale name="C"> + <short>Remove the Log Out item from the session menu</short> + <long>Makes it so that the logout button doesn't show in the session menu.</long> + </locale> + </schema> </schemalist> </gconfschemafile> diff --git a/src/gconf-helper.c b/src/gconf-helper.c index 5efc439..588b11c 100644 --- a/src/gconf-helper.c +++ b/src/gconf-helper.c @@ -43,6 +43,14 @@ supress_confirmations (void) { return gconf_client_get_bool (gconf_client, SUPPRESS_KEY, NULL) ; } +gboolean +show_logout (void) { + if(!gconf_client) { + gconf_client = gconf_client_get_default (); + } + return !gconf_client_get_bool (gconf_client, LOGOUT_KEY, NULL) ; +} + static void update_menu_entries_callback (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer data) { RestartShutdownLogoutMenuItems * restart_shutdown_logout_mi = (RestartShutdownLogoutMenuItems*) data; GConfValue * value = gconf_entry_get_value (entry); @@ -61,8 +69,19 @@ static void update_menu_entries_callback (GConfClient *client, guint cnxn_id, GC } } +static void +update_logout_callback (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer data) { + DbusmenuMenuitem * mi = (DbusmenuMenuitem*) data; + GConfValue * value = gconf_entry_get_value (entry); + const gchar * key = gconf_entry_get_key (entry); + + if(g_strcmp0 (key, LOGOUT_KEY) == 0) { + dbusmenu_menuitem_property_set_bool(mi, DBUSMENU_MENUITEM_PROP_VISIBLE, !gconf_value_get_bool(value)); + } +} + void -update_menu_entries(RestartShutdownLogoutMenuItems * restart_shutdown_logout_mi) { +update_menu_entries(RestartShutdownLogoutMenuItems * restart_shutdown_logout_mi, DbusmenuMenuitem * logoutitem) { if(!gconf_client) { gconf_client = gconf_client_get_default (); } @@ -70,5 +89,7 @@ update_menu_entries(RestartShutdownLogoutMenuItems * restart_shutdown_logout_mi) GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); gconf_client_notify_add (gconf_client, SUPPRESS_KEY, update_menu_entries_callback, restart_shutdown_logout_mi, NULL, NULL); + gconf_client_notify_add (gconf_client, LOGOUT_KEY, + update_logout_callback, logoutitem, NULL, NULL); } diff --git a/src/gconf-helper.h b/src/gconf-helper.h index 951bb0f..6f9bcb7 100644 --- a/src/gconf-helper.h +++ b/src/gconf-helper.h @@ -33,8 +33,9 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <libdbusmenu-glib/server.h> #include <libdbusmenu-glib/menuitem.h> -#define SUPPRESS_KEY "/apps/indicator-session/suppress_logout_restart_shutdown" -#define GLOBAL_DIR "/apps/indicator-session" +#define GLOBAL_DIR "/apps/indicator-session" +#define SUPPRESS_KEY GLOBAL_DIR "/suppress_logout_restart_shutdown" +#define LOGOUT_KEY GLOBAL_DIR "/suppress_logout_menuitem" typedef struct _RestartShutdownLogoutMenuItems { @@ -44,7 +45,8 @@ typedef struct _RestartShutdownLogoutMenuItems } RestartShutdownLogoutMenuItems; -void update_menu_entries(RestartShutdownLogoutMenuItems*); +void update_menu_entries(RestartShutdownLogoutMenuItems*, DbusmenuMenuitem * logoutitem); gboolean supress_confirmations (void); +gboolean show_logout (void); #endif /* __GCONF_HELPER__ */ diff --git a/src/session-service.c b/src/session-service.c index 4820f59..7ce4c0d 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -563,6 +563,7 @@ rebuild_items (DbusmenuMenuitem *root, } else { dbusmenu_menuitem_property_set(logout_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Log Out...")); } + dbusmenu_menuitem_property_set_bool(logout_mi, DBUSMENU_MENUITEM_PROP_VISIBLE, show_logout()); dbusmenu_menuitem_child_append(root, logout_mi); g_signal_connect(G_OBJECT(logout_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_dialog), "logout"); @@ -604,7 +605,7 @@ rebuild_items (DbusmenuMenuitem *root, restart_shutdown_logout_mi->restart_mi = restart_mi; restart_shutdown_logout_mi->shutdown_mi = shutdown_mi; - update_menu_entries(restart_shutdown_logout_mi); + update_menu_entries(restart_shutdown_logout_mi, logout_mi); if (g_file_test(DESKTOP_FILE, G_FILE_TEST_EXISTS)) { GAppInfo * appinfo = G_APP_INFO(g_desktop_app_info_new_from_filename(DESKTOP_FILE)); |