diff options
author | Michael Terry <michael.terry@canonical.com> | 2011-08-03 11:31:25 -0400 |
---|---|---|
committer | Michael Terry <michael.terry@canonical.com> | 2011-08-03 11:31:25 -0400 |
commit | c09a09f1ad35f5a6ac1333f99cdcbf5369b97691 (patch) | |
tree | 674e27418b24f0264f57130db79ad132585c83a3 | |
parent | b587cf67da20cce1a8467c190696cbdb35ef347b (diff) | |
download | ayatana-indicator-session-c09a09f1ad35f5a6ac1333f99cdcbf5369b97691.tar.gz ayatana-indicator-session-c09a09f1ad35f5a6ac1333f99cdcbf5369b97691.tar.bz2 ayatana-indicator-session-c09a09f1ad35f5a6ac1333f99cdcbf5369b97691.zip |
when used in a greeter, don't show settings links, the user switcher, or log out links
-rw-r--r-- | src/device-menu-mgr.c | 126 | ||||
-rw-r--r-- | src/device-menu-mgr.h | 2 | ||||
-rw-r--r-- | src/session-service.c | 24 |
3 files changed, 93 insertions, 59 deletions
diff --git a/src/device-menu-mgr.c b/src/device-menu-mgr.c index 324b3f1..e58bdab 100644 --- a/src/device-menu-mgr.c +++ b/src/device-menu-mgr.c @@ -461,9 +461,8 @@ show_system_settings_with_context (DbusmenuMenuitem * mi, } static void -device_menu_mgr_build_static_items (DeviceMenuMgr* self) +device_menu_mgr_build_settings_items (DeviceMenuMgr* self) { - // Static Setting items system_settings_menuitem = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set (system_settings_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, @@ -520,8 +519,11 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self) DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); dbusmenu_menuitem_child_add_position (self->root_item, separator1, 5); +} - // Devices control +static void +device_menu_mgr_build_devices_items (DeviceMenuMgr* self) +{ DbusmenuMenuitem * device_heading = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set (device_heading, DBUSMENU_MENUITEM_PROP_LABEL, @@ -581,58 +583,74 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self) DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); dbusmenu_menuitem_child_add_position (self->root_item, separator3, 11); - +} + +static void +device_menu_mgr_build_static_items (DeviceMenuMgr* self, gboolean greeter_mode) +{ + // Static Setting items + if (!greeter_mode) { + device_menu_mgr_build_settings_items (self); + } + + // Devices control + if (!greeter_mode) { + device_menu_mgr_build_devices_items (self); + } + // Session control - gboolean can_lockscreen; - - /* Make sure we have a valid GConf client, and build one - if needed */ - device_menu_mgr_ensure_gconf_client (self); - can_lockscreen = !gconf_client_get_bool ( gconf_client, - LOCKDOWN_KEY_SCREENSAVER, - NULL); - /* Lock screen item */ - if (can_lockscreen) { - lock_menuitem = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set (lock_menuitem, - DBUSMENU_MENUITEM_PROP_LABEL, - _("Lock Screen")); + if (!greeter_mode) { + gboolean can_lockscreen; + + /* Make sure we have a valid GConf client, and build one + if needed */ + device_menu_mgr_ensure_gconf_client (self); + can_lockscreen = !gconf_client_get_bool ( gconf_client, + LOCKDOWN_KEY_SCREENSAVER, + NULL); + /* Lock screen item */ + if (can_lockscreen) { + lock_menuitem = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (lock_menuitem, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Lock Screen")); + + gchar * shortcut = gconf_client_get_string(gconf_client, KEY_LOCK_SCREEN, NULL); + if (shortcut != NULL) { + g_debug("Lock screen shortcut: %s", shortcut); + dbusmenu_menuitem_property_set_shortcut_string(lock_menuitem, shortcut); + g_free(shortcut); + } + else { + g_debug("Unable to get lock screen shortcut."); + } + + g_signal_connect (G_OBJECT(lock_menuitem), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(lock_screen), NULL); + dbusmenu_menuitem_child_append(self->root_item, lock_menuitem); + } - gchar * shortcut = gconf_client_get_string(gconf_client, KEY_LOCK_SCREEN, NULL); - if (shortcut != NULL) { - g_debug("Lock screen shortcut: %s", shortcut); - dbusmenu_menuitem_property_set_shortcut_string(lock_menuitem, shortcut); - g_free(shortcut); + logout_mi = dbusmenu_menuitem_new(); + + if (supress_confirmations()) { + dbusmenu_menuitem_property_set (logout_mi, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Log Out")); } else { - g_debug("Unable to get lock screen shortcut."); + dbusmenu_menuitem_property_set (logout_mi, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Log Out\342\200\246")); } - - g_signal_connect (G_OBJECT(lock_menuitem), + dbusmenu_menuitem_property_set_bool (logout_mi, + DBUSMENU_MENUITEM_PROP_VISIBLE, + show_logout()); + dbusmenu_menuitem_child_append(self->root_item, logout_mi); + g_signal_connect( G_OBJECT(logout_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK(lock_screen), NULL); - dbusmenu_menuitem_child_append(self->root_item, lock_menuitem); - } - - logout_mi = dbusmenu_menuitem_new(); - - if (supress_confirmations()) { - dbusmenu_menuitem_property_set (logout_mi, - DBUSMENU_MENUITEM_PROP_LABEL, - _("Log Out")); - } - else { - dbusmenu_menuitem_property_set (logout_mi, - DBUSMENU_MENUITEM_PROP_LABEL, - _("Log Out\342\200\246")); - } - dbusmenu_menuitem_property_set_bool (logout_mi, - DBUSMENU_MENUITEM_PROP_VISIBLE, - show_logout()); - dbusmenu_menuitem_child_append(self->root_item, logout_mi); - g_signal_connect( G_OBJECT(logout_mi), - DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK(show_dialog), "logout"); + G_CALLBACK(show_dialog), "logout"); + } if (can_suspend && allow_suspend) { suspend_mi = dbusmenu_menuitem_new(); @@ -787,12 +805,14 @@ device_mgr_get_root_item (DeviceMenuMgr* self) /* * Clean Entry Point */ -DeviceMenuMgr* device_menu_mgr_new (SessionDbus* session_dbus) +DeviceMenuMgr* device_menu_mgr_new (SessionDbus* session_dbus, gboolean greeter_mode) { DeviceMenuMgr* device_mgr = g_object_new (DEVICE_TYPE_MENU_MGR, NULL); device_mgr->session_dbus_interface = session_dbus; - device_menu_mgr_build_static_items (device_mgr); - device_mgr->apt_watcher = apt_watcher_new (session_dbus, - software_updates_menuitem); + device_menu_mgr_build_static_items (device_mgr, greeter_mode); + if (software_updates_menuitem != NULL) { + device_mgr->apt_watcher = apt_watcher_new (session_dbus, + software_updates_menuitem); + } return device_mgr; } diff --git a/src/device-menu-mgr.h b/src/device-menu-mgr.h index 503b36a..d3c3a5a 100644 --- a/src/device-menu-mgr.h +++ b/src/device-menu-mgr.h @@ -44,7 +44,7 @@ struct _DeviceMenuMgrClass GType device_menu_mgr_get_type (void) G_GNUC_CONST; -DeviceMenuMgr* device_menu_mgr_new (SessionDbus* session_dbus); +DeviceMenuMgr* device_menu_mgr_new (SessionDbus* session_dbus, gboolean greeter_mode); DbusmenuMenuitem* device_mgr_get_root_item (DeviceMenuMgr* self); diff --git a/src/session-service.c b/src/session-service.c index bb473e9..fa212fd 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -78,11 +78,21 @@ service_shutdown (IndicatorService * service, gpointer user_data) return; } +static gboolean +get_greeter_mode (void) +{ + const gchar *var; + var = g_getenv("INDICATOR_GREETER_MODE"); + return (g_strcmp0(var, "1") == 0); +} + /* Main, is well, main. It brings everything up and throws us into the mainloop of no return. */ int main (int argc, char ** argv) { + gboolean greeter_mode; + g_type_init(); /* Setting up i18n and gettext. Apparently, we need @@ -99,15 +109,19 @@ main (int argc, char ** argv) session_dbus = session_dbus_new(); + greeter_mode = get_greeter_mode(); + // Devices - DeviceMenuMgr* device_mgr = device_menu_mgr_new (session_dbus); + DeviceMenuMgr* device_mgr = device_menu_mgr_new (session_dbus, greeter_mode); DbusmenuServer * server = dbusmenu_server_new(INDICATOR_SESSION_DBUS_OBJECT); dbusmenu_server_set_root(server, device_mgr_get_root_item (device_mgr)); - // Users - UserMenuMgr* user_mgr = user_menu_mgr_new (session_dbus); - DbusmenuServer* users_server = dbusmenu_server_new (INDICATOR_USERS_DBUS_OBJECT); - dbusmenu_server_set_root (users_server, user_mgr_get_root_item (user_mgr)); + if (!greeter_mode) { + // Users + UserMenuMgr* user_mgr = user_menu_mgr_new (session_dbus); + DbusmenuServer* users_server = dbusmenu_server_new (INDICATOR_USERS_DBUS_OBJECT); + dbusmenu_server_set_root (users_server, user_mgr_get_root_item (user_mgr)); + } mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); |