From df3f3b8129650e2e843f9295bb092166f89e4057 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 19 Aug 2011 12:03:29 -0500 Subject: Porting the keys for the device and user manager over to use gsettings --- src/device-menu-mgr.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'src/device-menu-mgr.c') diff --git a/src/device-menu-mgr.c b/src/device-menu-mgr.c index cbddaa3..ef9567b 100644 --- a/src/device-menu-mgr.c +++ b/src/device-menu-mgr.c @@ -44,7 +44,8 @@ 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; @@ -125,6 +126,7 @@ device_menu_mgr_class_init (DeviceMenuMgrClass *klass) object_class->finalize = device_menu_mgr_finalize; } +#if 0 // TODO // Is this needed anymore static void @@ -171,6 +173,7 @@ keybinding_changed (GConfClient *client, } return; } +#endif /* Check to see if the lockdown key is protecting from locking the screen. If not, lock it. */ @@ -178,7 +181,7 @@ static void lock_if_possible (DeviceMenuMgr* self) { device_menu_mgr_ensure_gconf_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; @@ -660,9 +663,8 @@ 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); + can_lockscreen = !g_settings_get_boolean (lockdown_settings, + LOCKDOWN_KEY_SCREENSAVER); /* Lock screen item */ if (can_lockscreen) { lock_menuitem = dbusmenu_menuitem_new(); @@ -670,7 +672,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); @@ -832,8 +834,13 @@ setup_restart_watch (DeviceMenuMgr* self) static void device_menu_mgr_ensure_gconf_client (DeviceMenuMgr* self) { - if (!gconf_client) { - gconf_client = gconf_client_get_default (); + if (!lockdown_settings) { + lockdown_settings = g_settings_new (LOCKDOWN_SCHEMA); + } + if (!keybinding_settings) { + keybinding_settings = g_settings_new (KEYBINDING_SCHEMA); + } +#if 0 gconf_client_add_dir(gconf_client, LOCKDOWN_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); gconf_client_notify_add (gconf_client, LOCKDOWN_DIR, @@ -850,6 +857,7 @@ device_menu_mgr_ensure_gconf_client (DeviceMenuMgr* self) NULL, NULL); } +#endif } DbusmenuMenuitem* -- cgit v1.2.3 From 7f2161b7e2ab9902076a0e47fecac7796546fb4b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 19 Aug 2011 13:13:57 -0500 Subject: Change name to settings helper --- src/Makefile.am | 6 +- src/device-menu-mgr.c | 2 +- src/gconf-helper.c | 174 ------------------------------------------------ src/gconf-helper.h | 60 ----------------- src/gtk-logout-helper.c | 2 +- src/settings-helper.c | 174 ++++++++++++++++++++++++++++++++++++++++++++++++ src/settings-helper.h | 60 +++++++++++++++++ src/user-menu-mgr.c | 2 +- 8 files changed, 240 insertions(+), 240 deletions(-) delete mode 100644 src/gconf-helper.c delete mode 100644 src/gconf-helper.h create mode 100644 src/settings-helper.c create mode 100644 src/settings-helper.h (limited to 'src/device-menu-mgr.c') diff --git a/src/Makefile.am b/src/Makefile.am index 9565545..dba0a9e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -96,7 +96,7 @@ indicator_session_service_SOURCES = \ session-dbus.h \ gen-session-dbus.xml.c \ dbusmenu-shared.h \ - gconf-helper.c \ + settings-helper.c \ users-service-dbus.h \ users-service-dbus.c \ user-menu-mgr.h \ @@ -126,8 +126,8 @@ indicator_session_service_LDADD = \ gtk_logout_helper_SOURCES = \ gtk-logout-helper.c \ - gconf-helper.c \ - gconf-helper.h \ + settings-helper.c \ + settings-helper.h \ dialog.c \ dialog.h diff --git a/src/device-menu-mgr.c b/src/device-menu-mgr.c index ef9567b..d07ae6a 100644 --- a/src/device-menu-mgr.c +++ b/src/device-menu-mgr.c @@ -21,7 +21,7 @@ with this program. If not, see . #include #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" diff --git a/src/gconf-helper.c b/src/gconf-helper.c deleted file mode 100644 index fad1275..0000000 --- a/src/gconf-helper.c +++ /dev/null @@ -1,174 +0,0 @@ -/* -A small wrapper utility for connecting to gconf. - -Copyright 2009 Canonical Ltd. - -Authors: - Christoph Korn - -This program is free software: you can redistribute it and/or modify it -under the terms of the GNU General Public License version 3, as published -by the Free Software Foundation. - -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranties of -MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program. If not, see . -*/ - -#include -#include - -#include -#include - -#include -#include - -#include "dbus-shared-names.h" -#include "gconf-helper.h" - -static GSettings* settings = NULL; - -#if 0 -static guint confirmation_notify = 0; -static guint logout_notify = 0; -static guint restart_notify = 0; -static guint shutdown_notify = 0; -#endif - -static void -build_settings (void) { - if(!settings) { - settings = g_settings_new (SESSION_SCHEMA); - } - return; -} - -gboolean -supress_confirmations (void) { - build_settings(); - return g_settings_get_boolean (settings, SUPPRESS_KEY) ; -} - -gboolean -show_logout (void) { - build_settings(); - return !g_settings_get_boolean (settings, LOGOUT_KEY) ; -} - -gboolean -show_restart (void) { - build_settings(); - return !g_settings_get_boolean (settings, RESTART_KEY) ; -} - -gboolean -show_shutdown (void) { - build_settings(); - return !g_settings_get_boolean (settings, SHUTDOWN_KEY) ; -} - -#if 0 -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); - const gchar * key = gconf_entry_get_key (entry); - - if(g_strcmp0 (key, SUPPRESS_KEY) == 0) { - if (gconf_value_get_bool (value)) { - dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->logout_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Log Out")); - dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->restart_mi, RESTART_ITEM_LABEL, _("Restart")); - dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Shut Down")); - } else { - dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->logout_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Log Out…")); - dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->restart_mi, RESTART_ITEM_LABEL, _("Restart…")); - dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Shut Down…")); - } - } -} - -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)); - } -} - -static void -update_restart_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, RESTART_KEY) == 0) { - dbusmenu_menuitem_property_set_bool(mi, DBUSMENU_MENUITEM_PROP_VISIBLE, !gconf_value_get_bool(value)); - } -} - -static void -update_shutdown_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, SHUTDOWN_KEY) == 0) { - dbusmenu_menuitem_property_set_bool(mi, DBUSMENU_MENUITEM_PROP_VISIBLE, !gconf_value_get_bool(value)); - } -} -#endif - -void -update_menu_entries(RestartShutdownLogoutMenuItems * restart_shutdown_logout_mi) { -#if 0 - /* If we don't have a client, build one. */ - if(!gconf_client) { - gconf_client = gconf_client_get_default (); - } - - /* If we've not gotten any notifications, then we need - to add the directory for notifications to come from. */ - if (confirmation_notify == 0 || logout_notify == 0) { - gconf_client_add_dir (gconf_client, GLOBAL_DIR, - GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); - } - - if (confirmation_notify != 0) { - gconf_client_notify_remove (gconf_client, confirmation_notify); - confirmation_notify = 0; - } - - if (logout_notify != 0) { - gconf_client_notify_remove (gconf_client, logout_notify); - logout_notify = 0; - } - - if (restart_notify != 0) { - gconf_client_notify_remove (gconf_client, restart_notify); - restart_notify = 0; - } - - if (shutdown_notify != 0) { - gconf_client_notify_remove (gconf_client, shutdown_notify); - shutdown_notify = 0; - } - - confirmation_notify = gconf_client_notify_add (gconf_client, SUPPRESS_KEY, - update_menu_entries_callback, restart_shutdown_logout_mi, NULL, NULL); - logout_notify = gconf_client_notify_add (gconf_client, LOGOUT_KEY, - update_logout_callback, restart_shutdown_logout_mi->logout_mi, NULL, NULL); - restart_notify = gconf_client_notify_add (gconf_client, RESTART_KEY, - update_restart_callback, restart_shutdown_logout_mi->restart_mi, NULL, NULL); - shutdown_notify = gconf_client_notify_add (gconf_client, SHUTDOWN_KEY, - update_shutdown_callback, restart_shutdown_logout_mi->shutdown_mi, NULL, NULL); -#endif - return; -} - diff --git a/src/gconf-helper.h b/src/gconf-helper.h deleted file mode 100644 index 1adb269..0000000 --- a/src/gconf-helper.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -A small wrapper utility for connecting to gconf. - -Copyright 2009 Canonical Ltd. - -Authors: - Christoph Korn - -This program is free software: you can redistribute it and/or modify it -under the terms of the GNU General Public License version 3, as published -by the Free Software Foundation. - -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranties of -MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program. If not, see . -*/ - - -#ifndef __GCONF_HELPER_H__ -#define __GCONF_HELPER_H__ 1 - -#include - -#include -#include - -#include -#include - -#define SESSION_SCHEMA "org.canonical.indicator.session" -#define SUPPRESS_KEY "suppress_logout_restart_shutdown" -#define LOGOUT_KEY "suppress_logout_menuitem" -#define RESTART_KEY "suppress_restart_menuitem" -#define SHUTDOWN_KEY "suppress_shutdown_menuitem" - -#define LOCKDOWN_SCHEMA "org.gnome.desktop.lockdown" -#define LOCKDOWN_KEY_USER "disable_user_switching" -#define LOCKDOWN_KEY_SCREENSAVER "disable_lock_screen" -#define KEYBINDING_SCHEMA "org.gnome.settings-daemon.plugins.media-keys" -#define KEY_LOCK_SCREEN "screensaver" - -typedef struct _RestartShutdownLogoutMenuItems -{ - DbusmenuMenuitem * logout_mi; - DbusmenuMenuitem * restart_mi; - DbusmenuMenuitem * shutdown_mi; -} -RestartShutdownLogoutMenuItems; - -void update_menu_entries(RestartShutdownLogoutMenuItems*); -gboolean supress_confirmations (void); -gboolean show_logout (void); -gboolean show_restart (void); -gboolean show_shutdown (void); - -#endif /* __GCONF_HELPER__ */ diff --git a/src/gtk-logout-helper.c b/src/gtk-logout-helper.c index b8923c6..33dce3a 100644 --- a/src/gtk-logout-helper.c +++ b/src/gtk-logout-helper.c @@ -26,7 +26,7 @@ with this program. If not, see . #include #include #include "dialog.h" -#include "gconf-helper.h" +#include "settings-helper.h" static void consolekit_fallback (LogoutDialogType action) diff --git a/src/settings-helper.c b/src/settings-helper.c new file mode 100644 index 0000000..bfe7a15 --- /dev/null +++ b/src/settings-helper.c @@ -0,0 +1,174 @@ +/* +A small wrapper utility for connecting to gconf. + +Copyright 2009 Canonical Ltd. + +Authors: + Christoph Korn + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +#include +#include + +#include +#include + +#include +#include + +#include "dbus-shared-names.h" +#include "settings-helper.h" + +static GSettings* settings = NULL; + +#if 0 +static guint confirmation_notify = 0; +static guint logout_notify = 0; +static guint restart_notify = 0; +static guint shutdown_notify = 0; +#endif + +static void +build_settings (void) { + if(!settings) { + settings = g_settings_new (SESSION_SCHEMA); + } + return; +} + +gboolean +supress_confirmations (void) { + build_settings(); + return g_settings_get_boolean (settings, SUPPRESS_KEY) ; +} + +gboolean +show_logout (void) { + build_settings(); + return !g_settings_get_boolean (settings, LOGOUT_KEY) ; +} + +gboolean +show_restart (void) { + build_settings(); + return !g_settings_get_boolean (settings, RESTART_KEY) ; +} + +gboolean +show_shutdown (void) { + build_settings(); + return !g_settings_get_boolean (settings, SHUTDOWN_KEY) ; +} + +#if 0 +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); + const gchar * key = gconf_entry_get_key (entry); + + if(g_strcmp0 (key, SUPPRESS_KEY) == 0) { + if (gconf_value_get_bool (value)) { + dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->logout_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Log Out")); + dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->restart_mi, RESTART_ITEM_LABEL, _("Restart")); + dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Shut Down")); + } else { + dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->logout_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Log Out…")); + dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->restart_mi, RESTART_ITEM_LABEL, _("Restart…")); + dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Shut Down…")); + } + } +} + +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)); + } +} + +static void +update_restart_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, RESTART_KEY) == 0) { + dbusmenu_menuitem_property_set_bool(mi, DBUSMENU_MENUITEM_PROP_VISIBLE, !gconf_value_get_bool(value)); + } +} + +static void +update_shutdown_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, SHUTDOWN_KEY) == 0) { + dbusmenu_menuitem_property_set_bool(mi, DBUSMENU_MENUITEM_PROP_VISIBLE, !gconf_value_get_bool(value)); + } +} +#endif + +void +update_menu_entries(RestartShutdownLogoutMenuItems * restart_shutdown_logout_mi) { +#if 0 + /* If we don't have a client, build one. */ + if(!gconf_client) { + gconf_client = gconf_client_get_default (); + } + + /* If we've not gotten any notifications, then we need + to add the directory for notifications to come from. */ + if (confirmation_notify == 0 || logout_notify == 0) { + gconf_client_add_dir (gconf_client, GLOBAL_DIR, + GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + } + + if (confirmation_notify != 0) { + gconf_client_notify_remove (gconf_client, confirmation_notify); + confirmation_notify = 0; + } + + if (logout_notify != 0) { + gconf_client_notify_remove (gconf_client, logout_notify); + logout_notify = 0; + } + + if (restart_notify != 0) { + gconf_client_notify_remove (gconf_client, restart_notify); + restart_notify = 0; + } + + if (shutdown_notify != 0) { + gconf_client_notify_remove (gconf_client, shutdown_notify); + shutdown_notify = 0; + } + + confirmation_notify = gconf_client_notify_add (gconf_client, SUPPRESS_KEY, + update_menu_entries_callback, restart_shutdown_logout_mi, NULL, NULL); + logout_notify = gconf_client_notify_add (gconf_client, LOGOUT_KEY, + update_logout_callback, restart_shutdown_logout_mi->logout_mi, NULL, NULL); + restart_notify = gconf_client_notify_add (gconf_client, RESTART_KEY, + update_restart_callback, restart_shutdown_logout_mi->restart_mi, NULL, NULL); + shutdown_notify = gconf_client_notify_add (gconf_client, SHUTDOWN_KEY, + update_shutdown_callback, restart_shutdown_logout_mi->shutdown_mi, NULL, NULL); +#endif + return; +} + diff --git a/src/settings-helper.h b/src/settings-helper.h new file mode 100644 index 0000000..1adb269 --- /dev/null +++ b/src/settings-helper.h @@ -0,0 +1,60 @@ +/* +A small wrapper utility for connecting to gconf. + +Copyright 2009 Canonical Ltd. + +Authors: + Christoph Korn + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + + +#ifndef __GCONF_HELPER_H__ +#define __GCONF_HELPER_H__ 1 + +#include + +#include +#include + +#include +#include + +#define SESSION_SCHEMA "org.canonical.indicator.session" +#define SUPPRESS_KEY "suppress_logout_restart_shutdown" +#define LOGOUT_KEY "suppress_logout_menuitem" +#define RESTART_KEY "suppress_restart_menuitem" +#define SHUTDOWN_KEY "suppress_shutdown_menuitem" + +#define LOCKDOWN_SCHEMA "org.gnome.desktop.lockdown" +#define LOCKDOWN_KEY_USER "disable_user_switching" +#define LOCKDOWN_KEY_SCREENSAVER "disable_lock_screen" +#define KEYBINDING_SCHEMA "org.gnome.settings-daemon.plugins.media-keys" +#define KEY_LOCK_SCREEN "screensaver" + +typedef struct _RestartShutdownLogoutMenuItems +{ + DbusmenuMenuitem * logout_mi; + DbusmenuMenuitem * restart_mi; + DbusmenuMenuitem * shutdown_mi; +} +RestartShutdownLogoutMenuItems; + +void update_menu_entries(RestartShutdownLogoutMenuItems*); +gboolean supress_confirmations (void); +gboolean show_logout (void); +gboolean show_restart (void); +gboolean show_shutdown (void); + +#endif /* __GCONF_HELPER__ */ diff --git a/src/user-menu-mgr.c b/src/user-menu-mgr.c index 3062f04..45e95dd 100644 --- a/src/user-menu-mgr.c +++ b/src/user-menu-mgr.c @@ -20,7 +20,7 @@ with this program. If not, see . #include #include "user-menu-mgr.h" -#include "gconf-helper.h" +#include "settings-helper.h" #include "dbus-shared-names.h" #include "dbusmenu-shared.h" #include "lock-helper.h" -- cgit v1.2.3 From 375ef3ab8b43925e28a2453b0b6374aedc4b357b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 19 Aug 2011 13:51:37 -0500 Subject: Changing name of ensure function --- src/device-menu-mgr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/device-menu-mgr.c') diff --git a/src/device-menu-mgr.c b/src/device-menu-mgr.c index d07ae6a..04b0adf 100644 --- a/src/device-menu-mgr.c +++ b/src/device-menu-mgr.c @@ -73,7 +73,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); @@ -179,7 +179,7 @@ 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 (!g_settings_get_boolean (lockdown_settings, LOCKDOWN_KEY_SCREENSAVER)) { lock_screen (NULL, 0, NULL); @@ -662,7 +662,7 @@ 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); + device_menu_mgr_ensure_settings_client (self); can_lockscreen = !g_settings_get_boolean (lockdown_settings, LOCKDOWN_KEY_SCREENSAVER); /* Lock screen item */ @@ -832,7 +832,7 @@ 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 (!lockdown_settings) { lockdown_settings = g_settings_new (LOCKDOWN_SCHEMA); -- cgit v1.2.3 From d44d40c06cc4dab568027eb97852a8f789449116 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 19 Aug 2011 13:58:37 -0500 Subject: Changing to using the GSettings signals for change --- src/device-menu-mgr.c | 51 ++++++++++++++------------------------------------- 1 file changed, 14 insertions(+), 37 deletions(-) (limited to 'src/device-menu-mgr.c') diff --git a/src/device-menu-mgr.c b/src/device-menu-mgr.c index 04b0adf..c298682 100644 --- a/src/device-menu-mgr.c +++ b/src/device-menu-mgr.c @@ -126,25 +126,21 @@ device_menu_mgr_class_init (DeviceMenuMgrClass *klass) object_class->finalize = device_menu_mgr_finalize; } -#if 0 // 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); } @@ -152,28 +148,23 @@ 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; } -#endif /* Check to see if the lockdown key is protecting from locking the screen. If not, lock it. */ @@ -836,28 +827,14 @@ device_menu_mgr_ensure_settings_client (DeviceMenuMgr* self) { 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); } -#if 0 - 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); - } -#endif + + return; } DbusmenuMenuitem* -- cgit v1.2.3