aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2012-06-05 14:00:18 -0500
committerCharles Kerr <charles.kerr@canonical.com>2012-06-05 14:00:18 -0500
commit913dcda481011189ce4dfd338e11e86ee48a49e1 (patch)
tree2f684a9f68a8ff7483e4ef22d2de4d1f4613f6cf
parentf49835864541e39f42ed6b06feabbdbcd8d3eac2 (diff)
downloadayatana-indicator-session-913dcda481011189ce4dfd338e11e86ee48a49e1.tar.gz
ayatana-indicator-session-913dcda481011189ce4dfd338e11e86ee48a49e1.tar.bz2
ayatana-indicator-session-913dcda481011189ce4dfd338e11e86ee48a49e1.zip
remove duplicate code when updating the lock menuitem's keybindings
-rw-r--r--src/device-menu-mgr.c42
1 files changed, 17 insertions, 25 deletions
diff --git a/src/device-menu-mgr.c b/src/device-menu-mgr.c
index a76ecd5..1e62262 100644
--- a/src/device-menu-mgr.c
+++ b/src/device-menu-mgr.c
@@ -129,23 +129,23 @@ lockdown_changed (GSettings * settings,
}
static void
-keybinding_changed (GSettings *settings,
- const gchar *key,
- gpointer user_data)
+update_screensaver_shortcut (DbusmenuMenuitem * menuitem, GSettings * settings)
{
- if (key == NULL) {
- return;
- }
+ if (lock_menuitem != NULL)
+ {
+ gchar * val = g_settings_get_string (settings, KEY_LOCK_SCREEN);
+ g_debug ("Keybinding changed to: %s", val);
+ dbusmenu_menuitem_property_set_shortcut_string (lock_menuitem, val);
+ g_free (val);
+ }
+}
- if (g_strcmp0 (key, KEY_LOCK_SCREEN) == 0) {
- gchar * val = g_settings_get_string(settings, key);
- g_debug("Keybinding changed to: %s", val);
- if (lock_menuitem != NULL) {
- dbusmenu_menuitem_property_set_shortcut_string (lock_menuitem, val);
- }
- g_free (val);
- }
- return;
+static void
+screensaver_keybinding_changed (GSettings * settings,
+ const gchar * key G_GNUC_UNUSED,
+ gpointer user_data G_GNUC_UNUSED)
+{
+ update_screensaver_shortcut (lock_menuitem, settings);
}
static void
@@ -477,15 +477,7 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self, gboolean greeter_mode)
DBUSMENU_MENUITEM_PROP_LABEL,
_("Lock Screen"));
- gchar * shortcut = g_settings_get_string(keybinding_settings, KEY_LOCK_SCREEN);
- 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.");
- }
+ update_screensaver_shortcut (lock_menuitem, keybinding_settings);
g_signal_connect (G_OBJECT(lock_menuitem),
DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
@@ -590,7 +582,7 @@ device_menu_mgr_ensure_settings_client (DeviceMenuMgr* self)
}
if (!keybinding_settings) {
keybinding_settings = g_settings_new (KEYBINDING_SCHEMA);
- g_signal_connect(lockdown_settings, "changed::" KEY_LOCK_SCREEN, G_CALLBACK(keybinding_changed), self);
+ g_signal_connect(lockdown_settings, "changed::" KEY_LOCK_SCREEN, G_CALLBACK(screensaver_keybinding_changed), self);
}
return;
}