From e86e25a79fbedda83e81e07afd3d0981cf1db44b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 6 Aug 2010 10:43:18 -0500 Subject: Removing the ability to have the menu item say anything other than 'Lock Screen' --- src/lock-helper.c | 50 -------------------------------------------------- src/lock-helper.h | 2 -- src/session-service.c | 7 +------ 3 files changed, 1 insertion(+), 58 deletions(-) (limited to 'src') diff --git a/src/lock-helper.c b/src/lock-helper.c index ba6b182..cdc8d14 100644 --- a/src/lock-helper.c +++ b/src/lock-helper.c @@ -253,53 +253,3 @@ lock_screen_setup (gpointer data) return FALSE; } -/* When the GConf key changes we need to adjust the text on - what we're going to do with the menu item */ -static void -lockscreen_update (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer data) { - DbusmenuMenuitem * mi = (DbusmenuMenuitem*) data; - const gchar * key = gconf_entry_get_key (entry); - - if(g_strcmp0 (key, GCONF_KEY) == 0) { - if (will_lock_screen()) { - dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Lock Screen")); - } else { - dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Start Screensaver")); - } - } -} - -/* Notification handler for lock menuitems. */ -static guint lock_notify = 0; - -/* Sets the menu item to be updating. There can - only be one. So we clear and reset if we get - another. */ -void -lock_screen_update_item (DbusmenuMenuitem * mi) -{ - if (gconf_client == NULL) { - gconf_client = gconf_client_get_default(); - } - - if (lock_notify == 0) { - gconf_client_add_dir (gconf_client, - GCONF_DIR, - GCONF_CLIENT_PRELOAD_ONELEVEL, - NULL); - } - - if (lock_notify != 0) { - gconf_client_notify_remove(gconf_client, lock_notify); - lock_notify = 0; - } - - lock_notify = gconf_client_notify_add(gconf_client, - GCONF_KEY, - lockscreen_update, - mi, - NULL, - NULL); - - return; -} diff --git a/src/lock-helper.h b/src/lock-helper.h index 1d707d8..37f1448 100644 --- a/src/lock-helper.h +++ b/src/lock-helper.h @@ -31,6 +31,4 @@ gboolean will_lock_screen (void); void lock_screen (DbusmenuMenuitem * mi, guint timestamp, gpointer data); gboolean lock_screen_setup (gpointer data); -void lock_screen_update_item (DbusmenuMenuitem * mi); - #endif /* LOCK_HELPER_H__ */ diff --git a/src/session-service.c b/src/session-service.c index 4fc12a1..65640c7 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -516,14 +516,9 @@ rebuild_items (DbusmenuMenuitem *root, /* Lock screen item */ if (can_lockscreen) { lock_menuitem = dbusmenu_menuitem_new(); - if (will_lock_screen()) { - dbusmenu_menuitem_property_set(lock_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _("Lock Screen")); - } else { - dbusmenu_menuitem_property_set(lock_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _("Start Screensaver")); - } + dbusmenu_menuitem_property_set(lock_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _("Lock Screen")); g_signal_connect(G_OBJECT(lock_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(lock_screen), NULL); dbusmenu_menuitem_child_append(root, lock_menuitem); - lock_screen_update_item(lock_menuitem); } /* Set to NULL just incase we don't end up building one */ -- cgit v1.2.3 From 306e8f6cc860bdbadabe924dc4384c822e49bab9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 6 Aug 2010 10:57:11 -0500 Subject: Making it so that lock_screen always locks the screen --- src/lock-helper.c | 35 ++++++----------------------------- 1 file changed, 6 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/lock-helper.c b/src/lock-helper.c index cdc8d14..9b15070 100644 --- a/src/lock-helper.c +++ b/src/lock-helper.c @@ -176,9 +176,11 @@ build_gss_proxy (void) static gboolean activate_timeout (gpointer data) { + /* Clear the ID for the timeout */ guint * address = (guint *)data; *address = 0; + /* Quit the mainloop */ if (gss_mainloop != NULL) { g_main_loop_quit(gss_mainloop); } @@ -186,22 +188,6 @@ activate_timeout (gpointer data) return FALSE; } -/* Handle errors from activating the screensaver */ -static void -active_cb (DBusGProxy * proxy, DBusGProxyCall * call, gpointer user_data) -{ - GError * error = NULL; - - dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_INVALID); - - if (error != NULL) { - g_warning("Unable to activate screensaver: %s", error->message); - g_error_free(error); - } - - return; -} - /* A fun little function to actually lock the screen. If, that's what you want, let's do it! */ void @@ -212,19 +198,10 @@ lock_screen (DbusmenuMenuitem * mi, guint timestamp, gpointer data) build_gss_proxy(); g_return_if_fail(gss_proxy != NULL); - if (will_lock_screen()) { - dbus_g_proxy_call_no_reply(gss_proxy, - "Lock", - G_TYPE_INVALID, - G_TYPE_INVALID); - } else { - dbus_g_proxy_begin_call(gss_proxy, - "SetActive", - active_cb, NULL, - NULL, - G_TYPE_BOOLEAN, TRUE, - G_TYPE_INVALID); - } + dbus_g_proxy_call_no_reply(gss_proxy, + "Lock", + G_TYPE_INVALID, + G_TYPE_INVALID); if (gss_mainloop == NULL) { gss_mainloop = g_main_loop_new(NULL, FALSE); -- cgit v1.2.3 From b423aba6638c2862e0ce92093b92225dbf4b172c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 6 Aug 2010 11:58:25 -0500 Subject: Getting keybinding defines --- src/session-service.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index 65640c7..4a03974 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -61,6 +61,9 @@ with this program. If not, see . #define LOCKDOWN_KEY_USER LOCKDOWN_DIR "/disable_user_switching" #define LOCKDOWN_KEY_SCREENSAVER LOCKDOWN_DIR "/disable_lock_screen" +#define KEYBINDING_DIR "/apps/gnome_settings_daemon/keybindings" +#define KEY_LOCK_SCREEN KEYBINDING_DIR "/screensaver" + typedef struct _ActivateData ActivateData; struct _ActivateData { -- cgit v1.2.3 From fbed796878da42ee291f86bfe4ae07ba213b1258 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 6 Aug 2010 12:01:20 -0500 Subject: Set up the listener for the keybinding --- src/session-service.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index 4a03974..feef5e7 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -122,6 +122,26 @@ lockdown_changed (GConfClient *client, return; } +static void +keybinding_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 == NULL || key == NULL) { + return; + } + + if (g_strcmp0 (key, KEY_LOCK_SCREEN) == 0) { + // TODO: set value + } + + return; +} + /* Ensures that we have a GConf client and if we build one set up the signal handler. */ static void @@ -129,8 +149,12 @@ ensure_gconf_client (void) { if (!gconf_client) { gconf_client = gconf_client_get_default (); + gconf_client_add_dir(gconf_client, LOCKDOWN_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); gconf_client_notify_add(gconf_client, LOCKDOWN_DIR, lockdown_changed, NULL, NULL, NULL); + + gconf_client_add_dir(gconf_client, KEYBINDING_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + gconf_client_notify_add(gconf_client, KEYBINDING_DIR, keybinding_changed, NULL, NULL, NULL); } return; } -- cgit v1.2.3 From fcf32dbec44550b677610791f905c8dc8d1d097a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 6 Aug 2010 13:40:30 -0500 Subject: Putting the shortcut on the menuitem --- src/session-service.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index feef5e7..2872de0 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -36,6 +36,7 @@ with this program. If not, see . #include #include #include +#include #include @@ -136,7 +137,10 @@ keybinding_changed (GConfClient *client, } if (g_strcmp0 (key, KEY_LOCK_SCREEN) == 0) { - // TODO: set value + g_debug("Keybinding changed to: %s", gconf_value_get_string(value)); + if (lock_menuitem != NULL) { + dbusmenu_menuitem_property_set_shortcut_string(lock_menuitem, gconf_value_get_string(value)); + } } return; @@ -544,6 +548,16 @@ rebuild_items (DbusmenuMenuitem *root, 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(root, lock_menuitem); } -- cgit v1.2.3 From c5f528c40b82aa69beb2712f1c2dac3cab13ff00 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 6 Aug 2010 13:45:10 -0500 Subject: Add and accel group to the indicator for the shortcut --- src/indicator-session.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/indicator-session.c b/src/indicator-session.c index dc23139..a1f1667 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -122,6 +122,9 @@ indicator_session_init (IndicatorSession *self) dbusmenu_client_add_type_handler(client, USER_ITEM_TYPE, new_user_item); dbusmenu_client_add_type_handler(client, RESTART_ITEM_TYPE, build_restart_item); + GtkAccelGroup * agroup = gtk_accel_group_new(); + dbusmenu_gtkclient_set_accel_group(DBUSMENU_GTKCLIENT(client), agroup); + DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); self->service_proxy = dbus_g_proxy_new_for_name(session_bus, INDICATOR_SESSION_DBUS_NAME, -- cgit v1.2.3