diff options
Diffstat (limited to 'src/device-menu-mgr.c')
-rw-r--r-- | src/device-menu-mgr.c | 103 |
1 files changed, 37 insertions, 66 deletions
diff --git a/src/device-menu-mgr.c b/src/device-menu-mgr.c index cbddaa3..523ea8d 100644 --- a/src/device-menu-mgr.c +++ b/src/device-menu-mgr.c @@ -21,7 +21,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <libdbusmenu-gtk3/menuitem.h> #include "device-menu-mgr.h" -#include "gconf-helper.h" +#include "settings-helper.h" #include "dbus-shared-names.h" #include "dbusmenu-shared.h" #include "lock-helper.h" @@ -44,11 +44,11 @@ struct _DeviceMenuMgr UdevMgr* udev_mgr; }; -static GConfClient *gconf_client = NULL; +static GSettings *lockdown_settings = NULL; +static GSettings *keybinding_settings = NULL; static DbusmenuMenuitem *lock_menuitem = NULL; static DbusmenuMenuitem *system_settings_menuitem = NULL; static DbusmenuMenuitem *display_settings_menuitem = NULL; -static DbusmenuMenuitem *bluetooth_settings_menuitem = NULL; static DbusmenuMenuitem *login_settings_menuitem = NULL; static DbusmenuMenuitem *software_updates_menuitem = NULL; static DbusmenuMenuitem *printers_menuitem = NULL; @@ -72,7 +72,7 @@ static gboolean allow_suspend = TRUE; static DBusGProxy * up_main_proxy = NULL; static DBusGProxy * up_prop_proxy = NULL; -static void device_menu_mgr_ensure_gconf_client (DeviceMenuMgr* self); +static void device_menu_mgr_ensure_settings_client (DeviceMenuMgr* self); static void setup_restart_watch (DeviceMenuMgr* self); static void setup_up (DeviceMenuMgr* self); static void device_menu_mgr_rebuild_items (DeviceMenuMgr *self); @@ -128,21 +128,18 @@ device_menu_mgr_class_init (DeviceMenuMgrClass *klass) // TODO // Is this needed anymore static void -lockdown_changed (GConfClient *client, - guint cnxd_id, - GConfEntry *entry, +lockdown_changed (GSettings * settings, + const gchar * key, gpointer user_data) { - DeviceMenuMgr* self = DEVICE_MENU_MGR (user_data); - GConfValue *value = gconf_entry_get_value (entry); - const gchar *key = gconf_entry_get_key (entry); + DeviceMenuMgr* self = DEVICE_MENU_MGR (user_data); - if (value == NULL || key == NULL) { + if (key == NULL) { return; } if (g_strcmp0 (key, LOCKDOWN_KEY_USER) == 0 || - g_strcmp0 (key, LOCKDOWN_KEY_SCREENSAVER) == 0) { + g_strcmp0 (key, LOCKDOWN_KEY_SCREENSAVER) == 0) { device_menu_mgr_rebuild_items(self); } @@ -150,23 +147,19 @@ lockdown_changed (GConfClient *client, } static void -keybinding_changed (GConfClient *client, - guint cnxd_id, - GConfEntry *entry, +keybinding_changed (GSettings *settings, + const gchar *key, gpointer user_data) { - GConfValue *value = gconf_entry_get_value (entry); - const gchar *key = gconf_entry_get_key (entry); - - if (value == NULL || key == NULL) { + if (key == NULL) { return; } if (g_strcmp0 (key, KEY_LOCK_SCREEN) == 0) { - g_debug("Keybinding changed to: %s", gconf_value_get_string(value)); + g_debug("Keybinding changed to: %s", g_settings_get_string(settings, key)); if (lock_menuitem != NULL) { dbusmenu_menuitem_property_set_shortcut_string (lock_menuitem, - gconf_value_get_string(value)); + g_settings_get_string(settings, key)); } } return; @@ -176,9 +169,9 @@ keybinding_changed (GConfClient *client, locking the screen. If not, lock it. */ static void lock_if_possible (DeviceMenuMgr* self) { - device_menu_mgr_ensure_gconf_client (self); + device_menu_mgr_ensure_settings_client (self); - if (!gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_SCREENSAVER, NULL)) { + if (!g_settings_get_boolean (lockdown_settings, LOCKDOWN_KEY_SCREENSAVER)) { lock_screen (NULL, 0, NULL); } return; @@ -541,17 +534,6 @@ device_menu_mgr_build_settings_items (DeviceMenuMgr* self) dbusmenu_menuitem_child_add_position(self->root_item, display_settings_menuitem, 1); - bluetooth_settings_menuitem = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set (bluetooth_settings_menuitem, - DBUSMENU_MENUITEM_PROP_LABEL, - _("Bluetooth…")); - g_signal_connect (G_OBJECT(bluetooth_settings_menuitem), - DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK(show_system_settings_with_context), "bluetooth"); - dbusmenu_menuitem_child_add_position(self->root_item, - bluetooth_settings_menuitem, - 2); - login_settings_menuitem = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set (login_settings_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, @@ -562,20 +544,20 @@ device_menu_mgr_build_settings_items (DeviceMenuMgr* self) "login"); dbusmenu_menuitem_child_add_position(self->root_item, login_settings_menuitem, - 3); + 2); software_updates_menuitem = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set (software_updates_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _("Software Up to Date")); dbusmenu_menuitem_child_add_position(self->root_item, software_updates_menuitem, - 4); + 3); DbusmenuMenuitem * separator1 = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set (separator1, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); - dbusmenu_menuitem_child_add_position (self->root_item, separator1, 5); + dbusmenu_menuitem_child_add_position (self->root_item, separator1, 4); } static void @@ -590,7 +572,7 @@ device_menu_mgr_build_devices_items (DeviceMenuMgr* self) FALSE); dbusmenu_menuitem_child_add_position (self->root_item, device_heading, - 6); + 5); printers_menuitem = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set (printers_menuitem, @@ -602,7 +584,7 @@ device_menu_mgr_build_devices_items (DeviceMenuMgr* self) "printers"); dbusmenu_menuitem_child_add_position(self->root_item, printers_menuitem, - 7); + 6); scanners_menuitem = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set (scanners_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, @@ -613,7 +595,7 @@ device_menu_mgr_build_devices_items (DeviceMenuMgr* self) NULL); dbusmenu_menuitem_child_add_position (self->root_item, scanners_menuitem, - 8); + 7); dbusmenu_menuitem_property_set_bool (scanners_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); @@ -628,7 +610,7 @@ device_menu_mgr_build_devices_items (DeviceMenuMgr* self) NULL); dbusmenu_menuitem_child_add_position (self->root_item, webcam_menuitem, - 10); + 8); dbusmenu_menuitem_property_set_bool (webcam_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); @@ -637,7 +619,7 @@ device_menu_mgr_build_devices_items (DeviceMenuMgr* self) dbusmenu_menuitem_property_set (separator3, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); - dbusmenu_menuitem_child_add_position (self->root_item, separator3, 11); + dbusmenu_menuitem_child_add_position (self->root_item, separator3, 9); } static void @@ -659,10 +641,9 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self, gboolean greeter_mode) /* 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); + device_menu_mgr_ensure_settings_client (self); + can_lockscreen = !g_settings_get_boolean (lockdown_settings, + LOCKDOWN_KEY_SCREENSAVER); /* Lock screen item */ if (can_lockscreen) { lock_menuitem = dbusmenu_menuitem_new(); @@ -670,7 +651,7 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self, gboolean greeter_mode) DBUSMENU_MENUITEM_PROP_LABEL, _("Lock Screen")); - gchar * shortcut = gconf_client_get_string(gconf_client, KEY_LOCK_SCREEN, NULL); + 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); @@ -759,7 +740,6 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self, gboolean greeter_mode) self->udev_mgr = udev_mgr_new (scanners_menuitem, webcam_menuitem); } - static void device_menu_mgr_rebuild_items (DeviceMenuMgr* self) { @@ -830,26 +810,17 @@ setup_restart_watch (DeviceMenuMgr* self) /* Ensures that we have a GConf client and if we build one set up the signal handler. */ static void -device_menu_mgr_ensure_gconf_client (DeviceMenuMgr* self) +device_menu_mgr_ensure_settings_client (DeviceMenuMgr* self) { - 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, - self, - 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, - self, - NULL, - NULL); + if (!lockdown_settings) { + lockdown_settings = g_settings_new (LOCKDOWN_SCHEMA); + g_signal_connect(lockdown_settings, "changed", G_CALLBACK(lockdown_changed), 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); } + return; } DbusmenuMenuitem* |