From 54d0bd428fb93559f34c298ff4926102bcd98467 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 19 Aug 2011 12:20:08 +0100 Subject: converted the old gconf schema to gsettings --- data/com.canonical.indicator.session.gschema.xml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 data/com.canonical.indicator.session.gschema.xml diff --git a/data/com.canonical.indicator.session.gschema.xml b/data/com.canonical.indicator.session.gschema.xml new file mode 100644 index 0000000..ba09583 --- /dev/null +++ b/data/com.canonical.indicator.session.gschema.xml @@ -0,0 +1,24 @@ + + + + false + Suppress the dialog to confirm logout, restart and shutdown action + Whether or not to show confirmation dialogs for logout, restart and shutdown actions. + + + false + Remove the Log Out item from the session menu + Makes it so that the logout button doesn't show in the session menu. + + + false + Remove the Restart item from the session menu + Makes it so that the restart button doesn't show in the session menu. + + + false + Remove the shutdown item from the session menu + Makes it so that the shutdown button doesn't show in the session menu. + + + -- cgit v1.2.3 From 0fe1ffdfdf9c06af2b6dad36e7472e6dd5c18a7f Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 19 Aug 2011 12:50:36 +0100 Subject: the beginnings of using gsettings in the gconf helper --- src/gconf-helper.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gconf-helper.c b/src/gconf-helper.c index 93ae96f..3bd254a 100644 --- a/src/gconf-helper.c +++ b/src/gconf-helper.c @@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ - +#include #include #include @@ -34,6 +34,8 @@ with this program. If not, see . #include "gconf-helper.h" static GConfClient * gconf_client = NULL; +static GSettings* settings = NULL; + static guint confirmation_notify = 0; static guint logout_notify = 0; static guint restart_notify = 0; @@ -41,10 +43,10 @@ static guint shutdown_notify = 0; gboolean supress_confirmations (void) { - if(!gconf_client) { - gconf_client = gconf_client_get_default (); + if(!settings) { + settings = g_settings_new ("com.canonical.indicators.sound"); } - return gconf_client_get_bool (gconf_client, SUPPRESS_KEY, NULL) ; + return g_settings_get_boolean (settings, SUPPRESS_KEY, NULL) ; } gboolean -- cgit v1.2.3 From 1290c1032eea7ce2f8bdd28e3bebf618b47216ca Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 19 Aug 2011 11:06:40 -0500 Subject: Fix getting of all the keys to be settings functions --- src/gconf-helper.c | 32 ++++++++++++++++---------------- src/gconf-helper.h | 10 +++++----- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/gconf-helper.c b/src/gconf-helper.c index 3bd254a..f9e73ad 100644 --- a/src/gconf-helper.c +++ b/src/gconf-helper.c @@ -41,36 +41,36 @@ static guint logout_notify = 0; static guint restart_notify = 0; static guint shutdown_notify = 0; -gboolean -supress_confirmations (void) { +static void +build_settings (void) { if(!settings) { - settings = g_settings_new ("com.canonical.indicators.sound"); + settings = g_settings_new (SESSION_SCHEMA); } - return g_settings_get_boolean (settings, SUPPRESS_KEY, NULL) ; + return; +} + +gboolean +supress_confirmations (void) { + build_settings(); + return g_settings_get_boolean (settings, SUPPRESS_KEY) ; } gboolean show_logout (void) { - if(!gconf_client) { - gconf_client = gconf_client_get_default (); - } - return !gconf_client_get_bool (gconf_client, LOGOUT_KEY, NULL) ; + build_settings(); + return !g_settings_get_boolean (settings, LOGOUT_KEY) ; } gboolean show_restart (void) { - if(!gconf_client) { - gconf_client = gconf_client_get_default (); - } - return !gconf_client_get_bool (gconf_client, RESTART_KEY, NULL) ; + build_settings(); + return !g_settings_get_boolean (settings, RESTART_KEY) ; } gboolean show_shutdown (void) { - if(!gconf_client) { - gconf_client = gconf_client_get_default (); - } - return !gconf_client_get_bool (gconf_client, SHUTDOWN_KEY, NULL) ; + build_settings(); + return !g_settings_get_boolean (settings, SHUTDOWN_KEY) ; } static void update_menu_entries_callback (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer data) { diff --git a/src/gconf-helper.h b/src/gconf-helper.h index 039b309..0d84dc6 100644 --- a/src/gconf-helper.h +++ b/src/gconf-helper.h @@ -33,11 +33,11 @@ with this program. If not, see . #include #include -#define GLOBAL_DIR "/apps/indicator-session" -#define SUPPRESS_KEY GLOBAL_DIR "/suppress_logout_restart_shutdown" -#define LOGOUT_KEY GLOBAL_DIR "/suppress_logout_menuitem" -#define RESTART_KEY GLOBAL_DIR "/suppress_restart_menuitem" -#define SHUTDOWN_KEY GLOBAL_DIR "/suppress_shutdown_menuitem" +#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_DIR "/desktop/gnome/lockdown" #define LOCKDOWN_KEY_USER LOCKDOWN_DIR "/disable_user_switching" -- cgit v1.2.3 From 2fe4c360b2eb616cb43472b8e8e7b69bdefd349d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 19 Aug 2011 11:08:30 -0500 Subject: Dropping gconf from build --- configure.ac | 10 ---------- data/Makefile.am | 24 ------------------------ src/Makefile.am | 2 +- 3 files changed, 1 insertion(+), 35 deletions(-) diff --git a/configure.ac b/configure.ac index 19cc4bc..7fa9db6 100644 --- a/configure.ac +++ b/configure.ac @@ -89,16 +89,6 @@ AS_IF([test "x$with_gtk" = x3], AC_SUBST(GTKLOGOUTHELPER_CFLAGS) AC_SUBST(GTKLOGOUTHELPER_LIBS) -AC_PATH_PROG(GCONFTOOL, gconftool-2) -dnl Specify the gconf configuration source, -dnl default to xml::$(sysconfdir)/gconf/gconf.xml.defaults - -AM_GCONF_SOURCE_2 - -PKG_CHECK_MODULES(GCONF, gconf-2.0 >= 2.0) -AC_SUBST(GCONF_CFLAGS) -AC_SUBST(GCONF_LIBS) - ########################### # Check to see if we're local ########################### diff --git a/data/Makefile.am b/data/Makefile.am index 1f522d7..2a9ea62 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -9,25 +9,8 @@ dbus_services_DATA = $(service_in_files:.service.in=.service) %.service: %.service.in sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@ -############################## -# GConf Schema -############################## - -schemadir = \ - $(GCONF_SCHEMA_FILE_DIR) - -schema_in_files = \ - indicator-session.schemas.in - -schema_DATA = \ - $(schema_in_files:.schemas.in=.schemas) - @INTLTOOL_SCHEMAS_RULE@ - -#$(dbus_services_DATA): $(service_in_files) Makefile -# sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@ - EXTRA_DIST = \ $(service_in_files) \ $(schema_in_files) @@ -36,10 +19,3 @@ CLEANFILES = \ $(dbus_services_DATA) \ $(schema_DATA) -if GCONF_SCHEMAS_INSTALL -install-data-local: - GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) \ - gconftool-2 --makefile-install-rule $(schema_DATA) -else -install-data-local: -endif diff --git a/src/Makefile.am b/src/Makefile.am index 3bfd790..9565545 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -100,7 +100,7 @@ indicator_session_service_SOURCES = \ users-service-dbus.h \ users-service-dbus.c \ user-menu-mgr.h \ - user-menu-mgr.c \ + user-menu-mgr.c \ device-menu-mgr.h \ device-menu-mgr.c \ apt-watcher.h \ -- cgit v1.2.3 From cb15da3ae85cbd185e4878aa0156e928db5d790e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 19 Aug 2011 11:21:26 -0500 Subject: Comment out notifications so that we can get this compiling again. --- src/gconf-helper.c | 10 ++++++---- src/gconf-helper.h | 2 -- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gconf-helper.c b/src/gconf-helper.c index f9e73ad..fad1275 100644 --- a/src/gconf-helper.c +++ b/src/gconf-helper.c @@ -20,8 +20,6 @@ with this program. If not, see . */ #include -#include - #include #include @@ -33,13 +31,14 @@ with this program. If not, see . #include "dbus-shared-names.h" #include "gconf-helper.h" -static GConfClient * gconf_client = NULL; 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) { @@ -73,6 +72,7 @@ show_shutdown (void) { 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); @@ -123,9 +123,11 @@ update_shutdown_callback (GConfClient *client, guint cnxn_id, GConfEntry *entry 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 (); @@ -166,7 +168,7 @@ update_menu_entries(RestartShutdownLogoutMenuItems * restart_shutdown_logout_mi) 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 index 0d84dc6..b3b5151 100644 --- a/src/gconf-helper.h +++ b/src/gconf-helper.h @@ -23,8 +23,6 @@ with this program. If not, see . #ifndef __GCONF_HELPER_H__ #define __GCONF_HELPER_H__ 1 -#include - #include #include -- cgit v1.2.3 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 ++++++++++++++++-------- src/gconf-helper.h | 10 +++++----- src/user-menu-mgr.c | 13 ++++++------- 3 files changed, 27 insertions(+), 20 deletions(-) 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* diff --git a/src/gconf-helper.h b/src/gconf-helper.h index b3b5151..1adb269 100644 --- a/src/gconf-helper.h +++ b/src/gconf-helper.h @@ -37,11 +37,11 @@ with this program. If not, see . #define RESTART_KEY "suppress_restart_menuitem" #define SHUTDOWN_KEY "suppress_shutdown_menuitem" -#define LOCKDOWN_DIR "/desktop/gnome/lockdown" -#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" +#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 { diff --git a/src/user-menu-mgr.c b/src/user-menu-mgr.c index 44c1960..3062f04 100644 --- a/src/user-menu-mgr.c +++ b/src/user-menu-mgr.c @@ -26,7 +26,7 @@ with this program. If not, see . #include "lock-helper.h" #include "users-service-dbus.h" -static GConfClient * gconf_client = NULL; +static GSettings* settings = NULL; static DbusmenuMenuitem *switch_menuitem = NULL; struct _UserMenuMgr @@ -114,7 +114,7 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self, gboolean greeter_mode) /* Check to see which menu items we're allowed to have */ can_activate = users_service_dbus_can_activate_session (self->users_dbus_interface) && - !gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_USER, NULL); + !g_settings_get_boolean (settings, LOCKDOWN_KEY_USER); /* Remove the old menu items if that makes sense */ children = dbusmenu_menuitem_take_children (self->root_item); @@ -290,7 +290,7 @@ static void lock_if_possible (void) { ensure_gconf_client (); - if (!gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_SCREENSAVER, NULL)) { + if (!g_settings_get_boolean (settings, LOCKDOWN_KEY_SCREENSAVER)) { lock_screen(NULL, 0, NULL); } @@ -375,11 +375,10 @@ user_change (UsersServiceDbus *service, static void ensure_gconf_client () { - if (!gconf_client) { - gconf_client = gconf_client_get_default (); - gconf_client_add_dir (gconf_client, LOCKDOWN_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); - gconf_client_add_dir (gconf_client, KEYBINDING_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + if(!settings) { + settings = g_settings_new (SESSION_SCHEMA); } + return; } DbusmenuMenuitem* -- cgit v1.2.3 From 44b13c9408a1bfd2d47c6bb8a6df0b6b5127e001 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 19 Aug 2011 12:03:47 -0500 Subject: ignore generated file --- .bzrignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.bzrignore b/.bzrignore index 2985cbf..1adaca4 100644 --- a/.bzrignore +++ b/.bzrignore @@ -199,3 +199,4 @@ src/Makefile modified: .bzrignore src/libsession_la-user-widget.lo +consolekit-seat-client.h -- 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 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 2611fa7ba14756cf1e084b1bed84539641568723 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 19 Aug 2011 13:33:46 -0500 Subject: Setting the notifications to use the g_settings changed signals --- src/settings-helper.c | 66 +++++++++++++++++---------------------------------- 1 file changed, 22 insertions(+), 44 deletions(-) diff --git a/src/settings-helper.c b/src/settings-helper.c index bfe7a15..e259b09 100644 --- a/src/settings-helper.c +++ b/src/settings-helper.c @@ -33,12 +33,10 @@ with this program. If not, see . 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) { @@ -72,14 +70,11 @@ show_shutdown (void) { 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) { +static void update_menu_entries_callback (GSettings * settings, const gchar * key, 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)) { + if (g_settings_get_boolean (settings, key)) { 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")); @@ -92,83 +87,66 @@ static void update_menu_entries_callback (GConfClient *client, guint cnxn_id, GC } static void -update_logout_callback (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer data) { +update_logout_callback (GSettings * settings, const gchar * key, 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)); + dbusmenu_menuitem_property_set_bool(mi, DBUSMENU_MENUITEM_PROP_VISIBLE, !g_settings_get_boolean(settings, key)); } } static void -update_restart_callback (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer data) { +update_restart_callback (GSettings * settings, const gchar * key, 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)); + dbusmenu_menuitem_property_set_bool(mi, DBUSMENU_MENUITEM_PROP_VISIBLE, !g_settings_get_boolean(settings, key)); } } static void -update_shutdown_callback (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer data) { +update_shutdown_callback (GSettings * settings, const gchar * key, 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)); + dbusmenu_menuitem_property_set_bool(mi, DBUSMENU_MENUITEM_PROP_VISIBLE, !g_settings_get_boolean(settings, key)); } } -#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); - } + build_settings(); if (confirmation_notify != 0) { - gconf_client_notify_remove (gconf_client, confirmation_notify); + g_signal_handler_disconnect (settings, confirmation_notify); confirmation_notify = 0; } if (logout_notify != 0) { - gconf_client_notify_remove (gconf_client, logout_notify); + g_signal_handler_disconnect (settings, logout_notify); logout_notify = 0; } if (restart_notify != 0) { - gconf_client_notify_remove (gconf_client, restart_notify); + g_signal_handler_disconnect (settings, restart_notify); restart_notify = 0; } if (shutdown_notify != 0) { - gconf_client_notify_remove (gconf_client, shutdown_notify); + g_signal_handler_disconnect (settings, 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 + confirmation_notify = g_signal_connect (settings, "changed::" SUPPRESS_KEY, + G_CALLBACK(update_menu_entries_callback), restart_shutdown_logout_mi); + logout_notify = g_signal_connect (settings, "changed::" LOGOUT_KEY, + G_CALLBACK(update_logout_callback), restart_shutdown_logout_mi->logout_mi); + restart_notify = g_signal_connect (settings, "changed::" RESTART_KEY, + G_CALLBACK(update_restart_callback), restart_shutdown_logout_mi->restart_mi); + shutdown_notify = g_signal_connect (settings, "changed::" SHUTDOWN_KEY, + G_CALLBACK(update_shutdown_callback), restart_shutdown_logout_mi->shutdown_mi); + return; } -- cgit v1.2.3 From a802b4546c1f3fd4361a868a26bafb7393a34817 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 19 Aug 2011 13:34:13 -0500 Subject: Fixing the comment --- src/settings-helper.c | 2 +- src/settings-helper.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/settings-helper.c b/src/settings-helper.c index e259b09..5a69d17 100644 --- a/src/settings-helper.c +++ b/src/settings-helper.c @@ -1,5 +1,5 @@ /* -A small wrapper utility for connecting to gconf. +A small wrapper utility for connecting to GSettings. Copyright 2009 Canonical Ltd. diff --git a/src/settings-helper.h b/src/settings-helper.h index 1adb269..72d2111 100644 --- a/src/settings-helper.h +++ b/src/settings-helper.h @@ -1,5 +1,5 @@ /* -A small wrapper utility for connecting to gconf. +A small wrapper utility for connecting to GSettings. Copyright 2009 Canonical Ltd. -- cgit v1.2.3 From 549bf385e28969f3026f6eab2d38c25697e02e7b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 19 Aug 2011 13:34:48 -0500 Subject: Removing the 'gconf' string --- src/user-menu-mgr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/user-menu-mgr.c b/src/user-menu-mgr.c index 45e95dd..718380c 100644 --- a/src/user-menu-mgr.c +++ b/src/user-menu-mgr.c @@ -56,7 +56,7 @@ static void user_change (UsersServiceDbus *service, const gchar *user_id, gpointer user_data); -static void ensure_gconf_client (); +static void ensure_settings_client (); static gboolean check_guest_session (void); static void activate_guest_session (DbusmenuMenuitem * mi, guint timestamp, @@ -110,7 +110,7 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self, gboolean greeter_mode) /* Make sure we have a valid GConf client, and build one if needed */ - ensure_gconf_client (); + ensure_settings_client (); /* Check to see which menu items we're allowed to have */ can_activate = users_service_dbus_can_activate_session (self->users_dbus_interface) && @@ -288,7 +288,7 @@ check_new_session () locking the screen. If not, lock it. */ static void lock_if_possible (void) { - ensure_gconf_client (); + ensure_settings_client (); if (!g_settings_get_boolean (settings, LOCKDOWN_KEY_SCREENSAVER)) { lock_screen(NULL, 0, NULL); @@ -373,7 +373,7 @@ user_change (UsersServiceDbus *service, /* Ensures that we have a GConf client and if we build one set up the signal handler. */ static void -ensure_gconf_client () +ensure_settings_client () { if(!settings) { settings = g_settings_new (SESSION_SCHEMA); -- 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(-) 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(-) 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 From 28389054bde478136f1337577f7bce3d65b03433 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 19 Aug 2011 14:31:09 -0500 Subject: Adding GSettings schema and updating C files --- po/POTFILES.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/po/POTFILES.in b/po/POTFILES.in index 08eff5f..df89ec9 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,7 +1,7 @@ [encoding: UTF-8] -data/indicator-session.schemas.in +data/com.canonical.indicator.session.gschema.xml.in data/extra-sessions/classic-desktop.desktop.in.in -src/gconf-helper.c +src/settings-helper.c src/lock-helper.c src/gtk-logout-helper.c src/dialog.c -- cgit v1.2.3 From 20b7a5e043b0c751791e775cb96094b53e38cb6f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 19 Aug 2011 14:32:20 -0500 Subject: Setting up convert script and completing the GSettings transition including translations --- data/Makefile.am | 13 +++++- data/com.canonical.indicator.session.gschema.xml | 24 ----------- .../com.canonical.indicator.session.gschema.xml.in | 24 +++++++++++ data/indicator-session.convert | 6 +++ data/indicator-session.schemas.in | 50 ---------------------- 5 files changed, 41 insertions(+), 76 deletions(-) delete mode 100644 data/com.canonical.indicator.session.gschema.xml create mode 100644 data/com.canonical.indicator.session.gschema.xml.in create mode 100644 data/indicator-session.convert delete mode 100644 data/indicator-session.schemas.in diff --git a/data/Makefile.am b/data/Makefile.am index 2a9ea62..27328fb 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -10,12 +10,21 @@ dbus_services_DATA = $(service_in_files:.service.in=.service) sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@ @INTLTOOL_SCHEMAS_RULE@ +@INTLTOOL_XML_NOMERGE_RULE@ + +@GSETTINGS_RULES@ +gsettings_SCHEMAS = com.canonical.indicator.session.gschema.xml + +convertdir = $(datadir)/GConf/gsettings +dist_convert_DATA = indicator-session.convert + EXTRA_DIST = \ $(service_in_files) \ - $(schema_in_files) + $(gsettings_SCHEMAS:.xml=.xml.in) + CLEANFILES = \ $(dbus_services_DATA) \ - $(schema_DATA) + $(gsettings_SCHEMAS) diff --git a/data/com.canonical.indicator.session.gschema.xml b/data/com.canonical.indicator.session.gschema.xml deleted file mode 100644 index ba09583..0000000 --- a/data/com.canonical.indicator.session.gschema.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - false - Suppress the dialog to confirm logout, restart and shutdown action - Whether or not to show confirmation dialogs for logout, restart and shutdown actions. - - - false - Remove the Log Out item from the session menu - Makes it so that the logout button doesn't show in the session menu. - - - false - Remove the Restart item from the session menu - Makes it so that the restart button doesn't show in the session menu. - - - false - Remove the shutdown item from the session menu - Makes it so that the shutdown button doesn't show in the session menu. - - - diff --git a/data/com.canonical.indicator.session.gschema.xml.in b/data/com.canonical.indicator.session.gschema.xml.in new file mode 100644 index 0000000..0cb6815 --- /dev/null +++ b/data/com.canonical.indicator.session.gschema.xml.in @@ -0,0 +1,24 @@ + + + + false + <_summary>Suppress the dialog to confirm logout, restart and shutdown action + <_description>Whether or not to show confirmation dialogs for logout, restart and shutdown actions. + + + false + <_summary>Remove the Log Out item from the session menu + <_description>Makes it so that the logout button doesn't show in the session menu. + + + false + <_summary>Remove the Restart item from the session menu + <_description>Makes it so that the restart button doesn't show in the session menu. + + + false + <_summary>Remove the shutdown item from the session menu + <_description>Makes it so that the shutdown button doesn't show in the session menu. + + + diff --git a/data/indicator-session.convert b/data/indicator-session.convert new file mode 100644 index 0000000..92775d8 --- /dev/null +++ b/data/indicator-session.convert @@ -0,0 +1,6 @@ +[com.canonical.indicator.session] +panel_user_name = /system/indicator/me/display +suppress_logout_restart_shutdown = /apps/indicator-session/suppress_logout_restart_shutdown +suppress_logout_menuitem = /apps/indicator-session/suppress_logout_menuitem +suppress_restart_menuitem = /apps/indicator-session/suppress_restart_menuitem +suppress_shutdown_menuitem = /apps/indicator-session/suppress_shutdown_menuitem diff --git a/data/indicator-session.schemas.in b/data/indicator-session.schemas.in deleted file mode 100644 index f4e70da..0000000 --- a/data/indicator-session.schemas.in +++ /dev/null @@ -1,50 +0,0 @@ - - - - - /schemas/apps/indicator-session/suppress_logout_restart_shutdown - /apps/indicator-session/suppress_logout_restart_shutdown - indicator-session - bool - FALSE - - Suppress the dialog to confirm logout, restart and shutdown action - Whether or not to show confirmation dialogs for logout, - restart and shutdown actions. - - - - /schemas/apps/indicator-session/suppress_logout_menuitem - /apps/indicator-session/suppress_logout_menuitem - indicator-session - bool - FALSE - - Remove the Log Out item from the session menu - Makes it so that the logout button doesn't show in the session menu. - - - - /schemas/apps/indicator-session/suppress_restart_menuitem - /apps/indicator-session/suppress_restart_menuitem - indicator-session - bool - FALSE - - Remove the Restart item from the session menu - Makes it so that the restart button doesn't show in the session menu. - - - - /schemas/apps/indicator-session/suppress_shutdown_menuitem - /apps/indicator-session/suppress_shutdown_menuitem - indicator-session - bool - FALSE - - Remove the shutdown item from the session menu - Makes it so that the shutdown button doesn't show in the session menu. - - - - -- cgit v1.2.3 From 3bd6d50cc610ba51b329d35465aa8c9129e3303b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 19 Aug 2011 14:32:38 -0500 Subject: Adding GSettings Rule --- configure.ac | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure.ac b/configure.ac index 7fa9db6..4bfb851 100644 --- a/configure.ac +++ b/configure.ac @@ -8,6 +8,8 @@ AM_INIT_AUTOMAKE(indicator-session, 0.3.1) AM_MAINTAINER_MODE +GLIB_GSETTINGS + IT_PROG_INTLTOOL([0.35.0]) AC_ISC_POSIX -- cgit v1.2.3 From 129061ff9d4b6d9e4a8ea5c7aeba6f1274567c5d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 19 Aug 2011 14:33:00 -0500 Subject: Ignoring GSettings generated files and the pot file --- .bzrignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.bzrignore b/.bzrignore index 1adaca4..ec88d32 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1,6 +1,6 @@ compile m4 -po +po/indicator-session.pot src/libmessaging.la src/libmessaging_la-indicator-messages.lo config.guess.cdbs-orig @@ -200,3 +200,5 @@ modified: .bzrignore src/libsession_la-user-widget.lo consolekit-seat-client.h +data/com.canonical.indicator.session.gschema.valid +data/com.canonical.indicator.session.gschema.xml -- cgit v1.2.3 From 36098537001011bffd6b74ccbf318b59c81d75e8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 19 Aug 2011 14:35:39 -0500 Subject: Don't have that yet --- data/indicator-session.convert | 1 - 1 file changed, 1 deletion(-) diff --git a/data/indicator-session.convert b/data/indicator-session.convert index 92775d8..3a087a6 100644 --- a/data/indicator-session.convert +++ b/data/indicator-session.convert @@ -1,5 +1,4 @@ [com.canonical.indicator.session] -panel_user_name = /system/indicator/me/display suppress_logout_restart_shutdown = /apps/indicator-session/suppress_logout_restart_shutdown suppress_logout_menuitem = /apps/indicator-session/suppress_logout_menuitem suppress_restart_menuitem = /apps/indicator-session/suppress_restart_menuitem -- cgit v1.2.3 From 4ee9a5748d7d69f3194325a9f020d1fc50bfb22b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 19 Aug 2011 15:09:03 -0500 Subject: Fixing key names --- src/settings-helper.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/settings-helper.h b/src/settings-helper.h index 72d2111..7b377ca 100644 --- a/src/settings-helper.h +++ b/src/settings-helper.h @@ -31,15 +31,15 @@ with this program. If not, see . #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 SESSION_SCHEMA "com.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 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" -- cgit v1.2.3 From 09514f45d0ab63579ce97faf07cbc0a79e981465 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 19 Aug 2011 15:09:11 -0500 Subject: Using the right schema --- src/user-menu-mgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/user-menu-mgr.c b/src/user-menu-mgr.c index 718380c..30ea0ff 100644 --- a/src/user-menu-mgr.c +++ b/src/user-menu-mgr.c @@ -376,7 +376,7 @@ static void ensure_settings_client () { if(!settings) { - settings = g_settings_new (SESSION_SCHEMA); + settings = g_settings_new (LOCKDOWN_SCHEMA); } return; } -- cgit v1.2.3