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