Merge lp:~ted/indicator-session/gsettings-port into lp:indicator-session/0.1

Proposed by Ted Gould
Status: Merged
Merged at revision: 180
Proposed branch: lp:~ted/indicator-session/gsettings-port
Merge into: lp:indicator-session/0.1
Diff against target: 730 lines (+148/-225)
13 files modified
.bzrignore (+4/-1)
configure.ac (+2/-10)
data/Makefile.am (+11/-26)
data/com.canonical.indicator.session.gschema.xml.in (+24/-0)
data/indicator-session.convert (+5/-0)
data/indicator-session.schemas.in (+0/-50)
po/POTFILES.in (+2/-2)
src/Makefile.am (+4/-4)
src/device-menu-mgr.c (+30/-45)
src/gtk-logout-helper.c (+1/-1)
src/settings-helper.c (+43/-61)
src/settings-helper.h (+11/-13)
src/user-menu-mgr.c (+11/-12)
To merge this branch: bzr merge lp:~ted/indicator-session/gsettings-port
Reviewer Review Type Date Requested Status
Conor Curran (community) Approve
Review via email: mp+72254@code.launchpad.net

Description of the change

GSettings port. I've updated the ubuntu branch with this branch so it can be tested easier.

To post a comment you must log in.
Revision history for this message
Conor Curran (cjcurran) wrote :

looking good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.bzrignore'
--- .bzrignore 2011-08-10 17:11:27 +0000
+++ .bzrignore 2011-08-19 20:18:25 +0000
@@ -1,6 +1,6 @@
1compile1compile
2m42m4
3po3po/indicator-session.pot
4src/libmessaging.la4src/libmessaging.la
5src/libmessaging_la-indicator-messages.lo5src/libmessaging_la-indicator-messages.lo
6config.guess.cdbs-orig6config.guess.cdbs-orig
@@ -199,3 +199,6 @@
199modified:199modified:
200.bzrignore200.bzrignore
201src/libsession_la-user-widget.lo201src/libsession_la-user-widget.lo
202consolekit-seat-client.h
203data/com.canonical.indicator.session.gschema.valid
204data/com.canonical.indicator.session.gschema.xml
202205
=== modified file 'configure.ac'
--- configure.ac 2011-08-10 18:15:18 +0000
+++ configure.ac 2011-08-19 20:18:25 +0000
@@ -8,6 +8,8 @@
88
9AM_MAINTAINER_MODE9AM_MAINTAINER_MODE
1010
11GLIB_GSETTINGS
12
11IT_PROG_INTLTOOL([0.35.0])13IT_PROG_INTLTOOL([0.35.0])
1214
13AC_ISC_POSIX15AC_ISC_POSIX
@@ -89,16 +91,6 @@
89AC_SUBST(GTKLOGOUTHELPER_CFLAGS)91AC_SUBST(GTKLOGOUTHELPER_CFLAGS)
90AC_SUBST(GTKLOGOUTHELPER_LIBS)92AC_SUBST(GTKLOGOUTHELPER_LIBS)
9193
92AC_PATH_PROG(GCONFTOOL, gconftool-2)
93dnl Specify the gconf configuration source,
94dnl default to xml::$(sysconfdir)/gconf/gconf.xml.defaults
95
96AM_GCONF_SOURCE_2
97
98PKG_CHECK_MODULES(GCONF, gconf-2.0 >= 2.0)
99AC_SUBST(GCONF_CFLAGS)
100AC_SUBST(GCONF_LIBS)
101
102###########################94###########################
103# Check to see if we're local95# Check to see if we're local
104###########################96###########################
10597
=== modified file 'data/Makefile.am'
--- data/Makefile.am 2011-05-11 22:22:21 +0000
+++ data/Makefile.am 2011-08-19 20:18:25 +0000
@@ -9,37 +9,22 @@
9%.service: %.service.in9%.service: %.service.in
10 sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@10 sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@
1111
12##############################
13# GConf Schema
14##############################
15
16schemadir = \
17 $(GCONF_SCHEMA_FILE_DIR)
18
19schema_in_files = \
20 indicator-session.schemas.in
21
22schema_DATA = \
23 $(schema_in_files:.schemas.in=.schemas)
24
25@INTLTOOL_SCHEMAS_RULE@12@INTLTOOL_SCHEMAS_RULE@
2613@INTLTOOL_XML_NOMERGE_RULE@
2714
28#$(dbus_services_DATA): $(service_in_files) Makefile15@GSETTINGS_RULES@
29# sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@16gsettings_SCHEMAS = com.canonical.indicator.session.gschema.xml
17
18convertdir = $(datadir)/GConf/gsettings
19dist_convert_DATA = indicator-session.convert
20
3021
31EXTRA_DIST = \22EXTRA_DIST = \
32 $(service_in_files) \23 $(service_in_files) \
33 $(schema_in_files)24 $(gsettings_SCHEMAS:.xml=.xml.in)
25
3426
35CLEANFILES = \27CLEANFILES = \
36 $(dbus_services_DATA) \28 $(dbus_services_DATA) \
37 $(schema_DATA)29 $(gsettings_SCHEMAS)
3830
39if GCONF_SCHEMAS_INSTALL
40install-data-local:
41 GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) \
42 gconftool-2 --makefile-install-rule $(schema_DATA)
43else
44install-data-local:
45endif
4631
=== added file 'data/com.canonical.indicator.session.gschema.xml.in'
--- data/com.canonical.indicator.session.gschema.xml.in 1970-01-01 00:00:00 +0000
+++ data/com.canonical.indicator.session.gschema.xml.in 2011-08-19 20:18:25 +0000
@@ -0,0 +1,24 @@
1<schemalist>
2 <schema id="com.canonical.indicator.session" path="/apps/indicator-session/">
3 <key name="suppress-logout-restart-shutdown" type="b">
4 <default>false</default>
5 <_summary>Suppress the dialog to confirm logout, restart and shutdown action</_summary>
6 <_description>Whether or not to show confirmation dialogs for logout, restart and shutdown actions.</_description>
7 </key>
8 <key name="suppress-logout-menuitem" type="b">
9 <default>false</default>
10 <_summary>Remove the Log Out item from the session menu</_summary>
11 <_description>Makes it so that the logout button doesn't show in the session menu.</_description>
12 </key>
13 <key name="suppress-restart-menuitem" type="b">
14 <default>false</default>
15 <_summary>Remove the Restart item from the session menu</_summary>
16 <_description>Makes it so that the restart button doesn't show in the session menu.</_description>
17 </key>
18 <key name="suppress-shutdown-menuitem" type="b">
19 <default>false</default>
20 <_summary>Remove the shutdown item from the session menu</_summary>
21 <_description>Makes it so that the shutdown button doesn't show in the session menu.</_description>
22 </key>
23 </schema>
24</schemalist>
025
=== added file 'data/indicator-session.convert'
--- data/indicator-session.convert 1970-01-01 00:00:00 +0000
+++ data/indicator-session.convert 2011-08-19 20:18:25 +0000
@@ -0,0 +1,5 @@
1[com.canonical.indicator.session]
2suppress_logout_restart_shutdown = /apps/indicator-session/suppress_logout_restart_shutdown
3suppress_logout_menuitem = /apps/indicator-session/suppress_logout_menuitem
4suppress_restart_menuitem = /apps/indicator-session/suppress_restart_menuitem
5suppress_shutdown_menuitem = /apps/indicator-session/suppress_shutdown_menuitem
06
=== removed file 'data/indicator-session.schemas.in'
--- data/indicator-session.schemas.in 2010-04-06 21:56:04 +0000
+++ data/indicator-session.schemas.in 1970-01-01 00:00:00 +0000
@@ -1,50 +0,0 @@
1<?xml version="1.0"?>
2<gconfschemafile>
3 <schemalist>
4 <schema>
5 <key>/schemas/apps/indicator-session/suppress_logout_restart_shutdown</key>
6 <applyto>/apps/indicator-session/suppress_logout_restart_shutdown</applyto>
7 <owner>indicator-session</owner>
8 <type>bool</type>
9 <default>FALSE</default>
10 <locale name="C">
11 <short>Suppress the dialog to confirm logout, restart and shutdown action</short>
12 <long>Whether or not to show confirmation dialogs for logout,
13 restart and shutdown actions.</long>
14 </locale>
15 </schema>
16 <schema>
17 <key>/schemas/apps/indicator-session/suppress_logout_menuitem</key>
18 <applyto>/apps/indicator-session/suppress_logout_menuitem</applyto>
19 <owner>indicator-session</owner>
20 <type>bool</type>
21 <default>FALSE</default>
22 <locale name="C">
23 <short>Remove the Log Out item from the session menu</short>
24 <long>Makes it so that the logout button doesn't show in the session menu.</long>
25 </locale>
26 </schema>
27 <schema>
28 <key>/schemas/apps/indicator-session/suppress_restart_menuitem</key>
29 <applyto>/apps/indicator-session/suppress_restart_menuitem</applyto>
30 <owner>indicator-session</owner>
31 <type>bool</type>
32 <default>FALSE</default>
33 <locale name="C">
34 <short>Remove the Restart item from the session menu</short>
35 <long>Makes it so that the restart button doesn't show in the session menu.</long>
36 </locale>
37 </schema>
38 <schema>
39 <key>/schemas/apps/indicator-session/suppress_shutdown_menuitem</key>
40 <applyto>/apps/indicator-session/suppress_shutdown_menuitem</applyto>
41 <owner>indicator-session</owner>
42 <type>bool</type>
43 <default>FALSE</default>
44 <locale name="C">
45 <short>Remove the shutdown item from the session menu</short>
46 <long>Makes it so that the shutdown button doesn't show in the session menu.</long>
47 </locale>
48 </schema>
49 </schemalist>
50</gconfschemafile>
510
=== modified file 'po/POTFILES.in'
--- po/POTFILES.in 2011-07-22 17:12:20 +0000
+++ po/POTFILES.in 2011-08-19 20:18:25 +0000
@@ -1,7 +1,7 @@
1[encoding: UTF-8]1[encoding: UTF-8]
2data/indicator-session.schemas.in2data/com.canonical.indicator.session.gschema.xml.in
3data/extra-sessions/classic-desktop.desktop.in.in3data/extra-sessions/classic-desktop.desktop.in.in
4src/gconf-helper.c4src/settings-helper.c
5src/lock-helper.c5src/lock-helper.c
6src/gtk-logout-helper.c6src/gtk-logout-helper.c
7src/dialog.c7src/dialog.c
88
=== modified file 'src/Makefile.am'
--- src/Makefile.am 2011-08-17 20:53:51 +0000
+++ src/Makefile.am 2011-08-19 20:18:25 +0000
@@ -96,11 +96,11 @@
96 session-dbus.h \96 session-dbus.h \
97 gen-session-dbus.xml.c \97 gen-session-dbus.xml.c \
98 dbusmenu-shared.h \98 dbusmenu-shared.h \
99 gconf-helper.c \99 settings-helper.c \
100 users-service-dbus.h \100 users-service-dbus.h \
101 users-service-dbus.c \101 users-service-dbus.c \
102 user-menu-mgr.h \102 user-menu-mgr.h \
103 user-menu-mgr.c \ 103 user-menu-mgr.c \
104 device-menu-mgr.h \104 device-menu-mgr.h \
105 device-menu-mgr.c \105 device-menu-mgr.c \
106 apt-watcher.h \106 apt-watcher.h \
@@ -126,8 +126,8 @@
126126
127gtk_logout_helper_SOURCES = \127gtk_logout_helper_SOURCES = \
128 gtk-logout-helper.c \128 gtk-logout-helper.c \
129 gconf-helper.c \129 settings-helper.c \
130 gconf-helper.h \130 settings-helper.h \
131 dialog.c \131 dialog.c \
132 dialog.h132 dialog.h
133133
134134
=== modified file 'src/device-menu-mgr.c'
--- src/device-menu-mgr.c 2011-08-18 15:21:02 +0000
+++ src/device-menu-mgr.c 2011-08-19 20:18:25 +0000
@@ -21,7 +21,7 @@
21#include <libdbusmenu-gtk3/menuitem.h>21#include <libdbusmenu-gtk3/menuitem.h>
2222
23#include "device-menu-mgr.h"23#include "device-menu-mgr.h"
24#include "gconf-helper.h"24#include "settings-helper.h"
25#include "dbus-shared-names.h"25#include "dbus-shared-names.h"
26#include "dbusmenu-shared.h"26#include "dbusmenu-shared.h"
27#include "lock-helper.h"27#include "lock-helper.h"
@@ -44,7 +44,8 @@
44 UdevMgr* udev_mgr;44 UdevMgr* udev_mgr;
45};45};
4646
47static GConfClient *gconf_client = NULL;47static GSettings *lockdown_settings = NULL;
48static GSettings *keybinding_settings = NULL;
48static DbusmenuMenuitem *lock_menuitem = NULL;49static DbusmenuMenuitem *lock_menuitem = NULL;
49static DbusmenuMenuitem *system_settings_menuitem = NULL;50static DbusmenuMenuitem *system_settings_menuitem = NULL;
50static DbusmenuMenuitem *display_settings_menuitem = NULL;51static DbusmenuMenuitem *display_settings_menuitem = NULL;
@@ -72,7 +73,7 @@
72static DBusGProxy * up_main_proxy = NULL;73static DBusGProxy * up_main_proxy = NULL;
73static DBusGProxy * up_prop_proxy = NULL;74static DBusGProxy * up_prop_proxy = NULL;
7475
75static void device_menu_mgr_ensure_gconf_client (DeviceMenuMgr* self);76static void device_menu_mgr_ensure_settings_client (DeviceMenuMgr* self);
76static void setup_restart_watch (DeviceMenuMgr* self);77static void setup_restart_watch (DeviceMenuMgr* self);
77static void setup_up (DeviceMenuMgr* self);78static void setup_up (DeviceMenuMgr* self);
78static void device_menu_mgr_rebuild_items (DeviceMenuMgr *self);79static void device_menu_mgr_rebuild_items (DeviceMenuMgr *self);
@@ -128,21 +129,18 @@
128// TODO129// TODO
129// Is this needed anymore130// Is this needed anymore
130static void131static void
131lockdown_changed (GConfClient *client,132lockdown_changed (GSettings * settings,
132 guint cnxd_id,133 const gchar * key,
133 GConfEntry *entry,
134 gpointer user_data)134 gpointer user_data)
135{135{
136 DeviceMenuMgr* self = DEVICE_MENU_MGR (user_data);136 DeviceMenuMgr* self = DEVICE_MENU_MGR (user_data);
137 GConfValue *value = gconf_entry_get_value (entry);
138 const gchar *key = gconf_entry_get_key (entry);
139137
140 if (value == NULL || key == NULL) {138 if (key == NULL) {
141 return;139 return;
142 }140 }
143141
144 if (g_strcmp0 (key, LOCKDOWN_KEY_USER) == 0 ||142 if (g_strcmp0 (key, LOCKDOWN_KEY_USER) == 0 ||
145 g_strcmp0 (key, LOCKDOWN_KEY_SCREENSAVER) == 0) {143 g_strcmp0 (key, LOCKDOWN_KEY_SCREENSAVER) == 0) {
146 device_menu_mgr_rebuild_items(self);144 device_menu_mgr_rebuild_items(self);
147 }145 }
148146
@@ -150,23 +148,19 @@
150}148}
151149
152static void150static void
153keybinding_changed (GConfClient *client,151keybinding_changed (GSettings *settings,
154 guint cnxd_id,152 const gchar *key,
155 GConfEntry *entry,
156 gpointer user_data)153 gpointer user_data)
157{154{
158 GConfValue *value = gconf_entry_get_value (entry);155 if (key == NULL) {
159 const gchar *key = gconf_entry_get_key (entry);
160
161 if (value == NULL || key == NULL) {
162 return;156 return;
163 }157 }
164158
165 if (g_strcmp0 (key, KEY_LOCK_SCREEN) == 0) {159 if (g_strcmp0 (key, KEY_LOCK_SCREEN) == 0) {
166 g_debug("Keybinding changed to: %s", gconf_value_get_string(value));160 g_debug("Keybinding changed to: %s", g_settings_get_string(settings, key));
167 if (lock_menuitem != NULL) {161 if (lock_menuitem != NULL) {
168 dbusmenu_menuitem_property_set_shortcut_string (lock_menuitem,162 dbusmenu_menuitem_property_set_shortcut_string (lock_menuitem,
169 gconf_value_get_string(value));163 g_settings_get_string(settings, key));
170 }164 }
171 }165 }
172 return;166 return;
@@ -176,9 +170,9 @@
176 locking the screen. If not, lock it. */170 locking the screen. If not, lock it. */
177static void171static void
178lock_if_possible (DeviceMenuMgr* self) {172lock_if_possible (DeviceMenuMgr* self) {
179 device_menu_mgr_ensure_gconf_client (self);173 device_menu_mgr_ensure_settings_client (self);
180174
181 if (!gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_SCREENSAVER, NULL)) {175 if (!g_settings_get_boolean (lockdown_settings, LOCKDOWN_KEY_SCREENSAVER)) {
182 lock_screen (NULL, 0, NULL);176 lock_screen (NULL, 0, NULL);
183 }177 }
184 return;178 return;
@@ -659,10 +653,9 @@
659653
660 /* Make sure we have a valid GConf client, and build one654 /* Make sure we have a valid GConf client, and build one
661 if needed */655 if needed */
662 device_menu_mgr_ensure_gconf_client (self);656 device_menu_mgr_ensure_settings_client (self);
663 can_lockscreen = !gconf_client_get_bool ( gconf_client,657 can_lockscreen = !g_settings_get_boolean (lockdown_settings,
664 LOCKDOWN_KEY_SCREENSAVER,658 LOCKDOWN_KEY_SCREENSAVER);
665 NULL);
666 /* Lock screen item */659 /* Lock screen item */
667 if (can_lockscreen) {660 if (can_lockscreen) {
668 lock_menuitem = dbusmenu_menuitem_new();661 lock_menuitem = dbusmenu_menuitem_new();
@@ -670,7 +663,7 @@
670 DBUSMENU_MENUITEM_PROP_LABEL,663 DBUSMENU_MENUITEM_PROP_LABEL,
671 _("Lock Screen"));664 _("Lock Screen"));
672665
673 gchar * shortcut = gconf_client_get_string(gconf_client, KEY_LOCK_SCREEN, NULL);666 gchar * shortcut = g_settings_get_string(keybinding_settings, KEY_LOCK_SCREEN);
674 if (shortcut != NULL) {667 if (shortcut != NULL) {
675 g_debug("Lock screen shortcut: %s", shortcut);668 g_debug("Lock screen shortcut: %s", shortcut);
676 dbusmenu_menuitem_property_set_shortcut_string(lock_menuitem, shortcut);669 dbusmenu_menuitem_property_set_shortcut_string(lock_menuitem, shortcut);
@@ -830,26 +823,18 @@
830/* Ensures that we have a GConf client and if we build one823/* Ensures that we have a GConf client and if we build one
831 set up the signal handler. */824 set up the signal handler. */
832static void825static void
833device_menu_mgr_ensure_gconf_client (DeviceMenuMgr* self)826device_menu_mgr_ensure_settings_client (DeviceMenuMgr* self)
834{827{
835 if (!gconf_client) {828 if (!lockdown_settings) {
836 gconf_client = gconf_client_get_default ();829 lockdown_settings = g_settings_new (LOCKDOWN_SCHEMA);
837 gconf_client_add_dir(gconf_client, LOCKDOWN_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);830 g_signal_connect(lockdown_settings, "changed", G_CALLBACK(lockdown_changed), self);
838 gconf_client_notify_add (gconf_client,831 }
839 LOCKDOWN_DIR,832 if (!keybinding_settings) {
840 lockdown_changed,833 keybinding_settings = g_settings_new (KEYBINDING_SCHEMA);
841 self,834 g_signal_connect(lockdown_settings, "changed::" KEY_LOCK_SCREEN, G_CALLBACK(keybinding_changed), self);
842 NULL,835 }
843 NULL);
844836
845 gconf_client_add_dir(gconf_client, KEYBINDING_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);837 return;
846 gconf_client_notify_add (gconf_client,
847 KEYBINDING_DIR,
848 keybinding_changed,
849 self,
850 NULL,
851 NULL);
852 }
853}838}
854839
855DbusmenuMenuitem*840DbusmenuMenuitem*
856841
=== modified file 'src/gtk-logout-helper.c'
--- src/gtk-logout-helper.c 2010-04-02 02:27:28 +0000
+++ src/gtk-logout-helper.c 2011-08-19 20:18:25 +0000
@@ -26,7 +26,7 @@
26#include <gtk/gtk.h>26#include <gtk/gtk.h>
27#include <dbus/dbus-glib.h>27#include <dbus/dbus-glib.h>
28#include "dialog.h"28#include "dialog.h"
29#include "gconf-helper.h"29#include "settings-helper.h"
3030
31static void31static void
32consolekit_fallback (LogoutDialogType action)32consolekit_fallback (LogoutDialogType action)
3333
=== renamed file 'src/gconf-helper.c' => 'src/settings-helper.c'
--- src/gconf-helper.c 2011-06-12 12:42:53 +0000
+++ src/settings-helper.c 2011-08-19 20:18:25 +0000
@@ -1,5 +1,5 @@
1/*1/*
2A small wrapper utility for connecting to gconf.2A small wrapper utility for connecting to GSettings.
33
4Copyright 2009 Canonical Ltd.4Copyright 2009 Canonical Ltd.
55
@@ -19,9 +19,7 @@
19with this program. If not, see <http://www.gnu.org/licenses/>.19with this program. If not, see <http://www.gnu.org/licenses/>.
20*/20*/
2121
2222#include <gio/gio.h>
23#include <gconf/gconf-client.h>
24
25#include <glib/gi18n.h>23#include <glib/gi18n.h>
2624
27#include <dbus/dbus-glib.h>25#include <dbus/dbus-glib.h>
@@ -31,53 +29,52 @@
31#include <libdbusmenu-glib/menuitem.h>29#include <libdbusmenu-glib/menuitem.h>
3230
33#include "dbus-shared-names.h"31#include "dbus-shared-names.h"
34#include "gconf-helper.h"32#include "settings-helper.h"
3533
36static GConfClient * gconf_client = NULL;34static GSettings* settings = NULL;
35
37static guint confirmation_notify = 0;36static guint confirmation_notify = 0;
38static guint logout_notify = 0;37static guint logout_notify = 0;
39static guint restart_notify = 0;38static guint restart_notify = 0;
40static guint shutdown_notify = 0;39static guint shutdown_notify = 0;
4140
41static void
42build_settings (void) {
43 if(!settings) {
44 settings = g_settings_new (SESSION_SCHEMA);
45 }
46 return;
47}
48
42gboolean49gboolean
43supress_confirmations (void) {50supress_confirmations (void) {
44 if(!gconf_client) {51 build_settings();
45 gconf_client = gconf_client_get_default ();52 return g_settings_get_boolean (settings, SUPPRESS_KEY) ;
46 }
47 return gconf_client_get_bool (gconf_client, SUPPRESS_KEY, NULL) ;
48}53}
4954
50gboolean55gboolean
51show_logout (void) {56show_logout (void) {
52 if(!gconf_client) {57 build_settings();
53 gconf_client = gconf_client_get_default ();58 return !g_settings_get_boolean (settings, LOGOUT_KEY) ;
54 }
55 return !gconf_client_get_bool (gconf_client, LOGOUT_KEY, NULL) ;
56}59}
5760
58gboolean61gboolean
59show_restart (void) {62show_restart (void) {
60 if(!gconf_client) {63 build_settings();
61 gconf_client = gconf_client_get_default ();64 return !g_settings_get_boolean (settings, RESTART_KEY) ;
62 }
63 return !gconf_client_get_bool (gconf_client, RESTART_KEY, NULL) ;
64}65}
6566
66gboolean67gboolean
67show_shutdown (void) {68show_shutdown (void) {
68 if(!gconf_client) {69 build_settings();
69 gconf_client = gconf_client_get_default ();70 return !g_settings_get_boolean (settings, SHUTDOWN_KEY) ;
70 }
71 return !gconf_client_get_bool (gconf_client, SHUTDOWN_KEY, NULL) ;
72}71}
7372
74static void update_menu_entries_callback (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer data) {73static void update_menu_entries_callback (GSettings * settings, const gchar * key, gpointer data) {
75 RestartShutdownLogoutMenuItems * restart_shutdown_logout_mi = (RestartShutdownLogoutMenuItems*) data;74 RestartShutdownLogoutMenuItems * restart_shutdown_logout_mi = (RestartShutdownLogoutMenuItems*) data;
76 GConfValue * value = gconf_entry_get_value (entry);
77 const gchar * key = gconf_entry_get_key (entry);
7875
79 if(g_strcmp0 (key, SUPPRESS_KEY) == 0) {76 if(g_strcmp0 (key, SUPPRESS_KEY) == 0) {
80 if (gconf_value_get_bool (value)) {77 if (g_settings_get_boolean (settings, key)) {
81 dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->logout_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Log Out"));78 dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->logout_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Log Out"));
82 dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->restart_mi, RESTART_ITEM_LABEL, _("Restart"));79 dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->restart_mi, RESTART_ITEM_LABEL, _("Restart"));
83 dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Shut Down"));80 dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Shut Down"));
@@ -90,80 +87,65 @@
90}87}
9188
92static void89static void
93update_logout_callback (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer data) {90update_logout_callback (GSettings * settings, const gchar * key, gpointer data) {
94 DbusmenuMenuitem * mi = (DbusmenuMenuitem*) data;91 DbusmenuMenuitem * mi = (DbusmenuMenuitem*) data;
95 GConfValue * value = gconf_entry_get_value (entry);
96 const gchar * key = gconf_entry_get_key (entry);
9792
98 if(g_strcmp0 (key, LOGOUT_KEY) == 0) {93 if(g_strcmp0 (key, LOGOUT_KEY) == 0) {
99 dbusmenu_menuitem_property_set_bool(mi, DBUSMENU_MENUITEM_PROP_VISIBLE, !gconf_value_get_bool(value));94 dbusmenu_menuitem_property_set_bool(mi, DBUSMENU_MENUITEM_PROP_VISIBLE, !g_settings_get_boolean(settings, key));
100 }95 }
101}96}
10297
103static void98static void
104update_restart_callback (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer data) {99update_restart_callback (GSettings * settings, const gchar * key, gpointer data) {
105 DbusmenuMenuitem * mi = (DbusmenuMenuitem*) data;100 DbusmenuMenuitem * mi = (DbusmenuMenuitem*) data;
106 GConfValue * value = gconf_entry_get_value (entry);
107 const gchar * key = gconf_entry_get_key (entry);
108101
109 if(g_strcmp0 (key, RESTART_KEY) == 0) {102 if(g_strcmp0 (key, RESTART_KEY) == 0) {
110 dbusmenu_menuitem_property_set_bool(mi, DBUSMENU_MENUITEM_PROP_VISIBLE, !gconf_value_get_bool(value));103 dbusmenu_menuitem_property_set_bool(mi, DBUSMENU_MENUITEM_PROP_VISIBLE, !g_settings_get_boolean(settings, key));
111 }104 }
112}105}
113106
114static void107static void
115update_shutdown_callback (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer data) {108update_shutdown_callback (GSettings * settings, const gchar * key, gpointer data) {
116 DbusmenuMenuitem * mi = (DbusmenuMenuitem*) data;109 DbusmenuMenuitem * mi = (DbusmenuMenuitem*) data;
117 GConfValue * value = gconf_entry_get_value (entry);
118 const gchar * key = gconf_entry_get_key (entry);
119110
120 if(g_strcmp0 (key, SHUTDOWN_KEY) == 0) {111 if(g_strcmp0 (key, SHUTDOWN_KEY) == 0) {
121 dbusmenu_menuitem_property_set_bool(mi, DBUSMENU_MENUITEM_PROP_VISIBLE, !gconf_value_get_bool(value));112 dbusmenu_menuitem_property_set_bool(mi, DBUSMENU_MENUITEM_PROP_VISIBLE, !g_settings_get_boolean(settings, key));
122 }113 }
123}114}
124115
125void116void
126update_menu_entries(RestartShutdownLogoutMenuItems * restart_shutdown_logout_mi) {117update_menu_entries(RestartShutdownLogoutMenuItems * restart_shutdown_logout_mi) {
127 /* If we don't have a client, build one. */118 /* If we don't have a client, build one. */
128 if(!gconf_client) {119 build_settings();
129 gconf_client = gconf_client_get_default ();
130 }
131
132 /* If we've not gotten any notifications, then we need
133 to add the directory for notifications to come from. */
134 if (confirmation_notify == 0 || logout_notify == 0) {
135 gconf_client_add_dir (gconf_client, GLOBAL_DIR,
136 GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
137 }
138120
139 if (confirmation_notify != 0) {121 if (confirmation_notify != 0) {
140 gconf_client_notify_remove (gconf_client, confirmation_notify);122 g_signal_handler_disconnect (settings, confirmation_notify);
141 confirmation_notify = 0;123 confirmation_notify = 0;
142 }124 }
143125
144 if (logout_notify != 0) {126 if (logout_notify != 0) {
145 gconf_client_notify_remove (gconf_client, logout_notify);127 g_signal_handler_disconnect (settings, logout_notify);
146 logout_notify = 0;128 logout_notify = 0;
147 }129 }
148130
149 if (restart_notify != 0) {131 if (restart_notify != 0) {
150 gconf_client_notify_remove (gconf_client, restart_notify);132 g_signal_handler_disconnect (settings, restart_notify);
151 restart_notify = 0;133 restart_notify = 0;
152 }134 }
153135
154 if (shutdown_notify != 0) {136 if (shutdown_notify != 0) {
155 gconf_client_notify_remove (gconf_client, shutdown_notify);137 g_signal_handler_disconnect (settings, shutdown_notify);
156 shutdown_notify = 0;138 shutdown_notify = 0;
157 }139 }
158140
159 confirmation_notify = gconf_client_notify_add (gconf_client, SUPPRESS_KEY,141 confirmation_notify = g_signal_connect (settings, "changed::" SUPPRESS_KEY,
160 update_menu_entries_callback, restart_shutdown_logout_mi, NULL, NULL);142 G_CALLBACK(update_menu_entries_callback), restart_shutdown_logout_mi);
161 logout_notify = gconf_client_notify_add (gconf_client, LOGOUT_KEY,143 logout_notify = g_signal_connect (settings, "changed::" LOGOUT_KEY,
162 update_logout_callback, restart_shutdown_logout_mi->logout_mi, NULL, NULL);144 G_CALLBACK(update_logout_callback), restart_shutdown_logout_mi->logout_mi);
163 restart_notify = gconf_client_notify_add (gconf_client, RESTART_KEY,145 restart_notify = g_signal_connect (settings, "changed::" RESTART_KEY,
164 update_restart_callback, restart_shutdown_logout_mi->restart_mi, NULL, NULL);146 G_CALLBACK(update_restart_callback), restart_shutdown_logout_mi->restart_mi);
165 shutdown_notify = gconf_client_notify_add (gconf_client, SHUTDOWN_KEY,147 shutdown_notify = g_signal_connect (settings, "changed::" SHUTDOWN_KEY,
166 update_shutdown_callback, restart_shutdown_logout_mi->shutdown_mi, NULL, NULL);148 G_CALLBACK(update_shutdown_callback), restart_shutdown_logout_mi->shutdown_mi);
167149
168 return;150 return;
169}151}
170152
=== renamed file 'src/gconf-helper.h' => 'src/settings-helper.h'
--- src/gconf-helper.h 2011-07-15 11:06:53 +0000
+++ src/settings-helper.h 2011-08-19 20:18:25 +0000
@@ -1,5 +1,5 @@
1/*1/*
2A small wrapper utility for connecting to gconf.2A small wrapper utility for connecting to GSettings.
33
4Copyright 2009 Canonical Ltd.4Copyright 2009 Canonical Ltd.
55
@@ -23,8 +23,6 @@
23#ifndef __GCONF_HELPER_H__23#ifndef __GCONF_HELPER_H__
24#define __GCONF_HELPER_H__ 124#define __GCONF_HELPER_H__ 1
2525
26#include <gconf/gconf-client.h>
27
28#include <glib/gi18n.h>26#include <glib/gi18n.h>
2927
30#include <dbus/dbus-glib.h>28#include <dbus/dbus-glib.h>
@@ -33,17 +31,17 @@
33#include <libdbusmenu-glib/server.h>31#include <libdbusmenu-glib/server.h>
34#include <libdbusmenu-glib/menuitem.h>32#include <libdbusmenu-glib/menuitem.h>
3533
36#define GLOBAL_DIR "/apps/indicator-session"34#define SESSION_SCHEMA "com.canonical.indicator.session"
37#define SUPPRESS_KEY GLOBAL_DIR "/suppress_logout_restart_shutdown"35#define SUPPRESS_KEY "suppress-logout-restart-shutdown"
38#define LOGOUT_KEY GLOBAL_DIR "/suppress_logout_menuitem"36#define LOGOUT_KEY "suppress-logout-menuitem"
39#define RESTART_KEY GLOBAL_DIR "/suppress_restart_menuitem"37#define RESTART_KEY "suppress-restart-menuitem"
40#define SHUTDOWN_KEY GLOBAL_DIR "/suppress_shutdown_menuitem"38#define SHUTDOWN_KEY "suppress-shutdown-menuitem"
4139
42#define LOCKDOWN_DIR "/desktop/gnome/lockdown"40#define LOCKDOWN_SCHEMA "org.gnome.desktop.lockdown"
43#define LOCKDOWN_KEY_USER LOCKDOWN_DIR "/disable_user_switching"41#define LOCKDOWN_KEY_USER "disable-user-switching"
44#define LOCKDOWN_KEY_SCREENSAVER LOCKDOWN_DIR "/disable_lock_screen"42#define LOCKDOWN_KEY_SCREENSAVER "disable-lock-screen"
45#define KEYBINDING_DIR "/apps/gnome_settings_daemon/keybindings"43#define KEYBINDING_SCHEMA "org.gnome.settings-daemon.plugins.media-keys"
46#define KEY_LOCK_SCREEN KEYBINDING_DIR "/screensaver"44#define KEY_LOCK_SCREEN "screensaver"
4745
48typedef struct _RestartShutdownLogoutMenuItems46typedef struct _RestartShutdownLogoutMenuItems
49{47{
5048
=== modified file 'src/user-menu-mgr.c'
--- src/user-menu-mgr.c 2011-08-18 15:21:02 +0000
+++ src/user-menu-mgr.c 2011-08-19 20:18:25 +0000
@@ -20,13 +20,13 @@
20#include <libdbusmenu-glib/client.h>20#include <libdbusmenu-glib/client.h>
2121
22#include "user-menu-mgr.h"22#include "user-menu-mgr.h"
23#include "gconf-helper.h"23#include "settings-helper.h"
24#include "dbus-shared-names.h"24#include "dbus-shared-names.h"
25#include "dbusmenu-shared.h"25#include "dbusmenu-shared.h"
26#include "lock-helper.h"26#include "lock-helper.h"
27#include "users-service-dbus.h"27#include "users-service-dbus.h"
2828
29static GConfClient * gconf_client = NULL;29static GSettings* settings = NULL;
30static DbusmenuMenuitem *switch_menuitem = NULL;30static DbusmenuMenuitem *switch_menuitem = NULL;
3131
32struct _UserMenuMgr32struct _UserMenuMgr
@@ -56,7 +56,7 @@
56 const gchar *user_id,56 const gchar *user_id,
57 gpointer user_data);57 gpointer user_data);
5858
59static void ensure_gconf_client ();59static void ensure_settings_client ();
60static gboolean check_guest_session (void);60static gboolean check_guest_session (void);
61static void activate_guest_session (DbusmenuMenuitem * mi,61static void activate_guest_session (DbusmenuMenuitem * mi,
62 guint timestamp,62 guint timestamp,
@@ -110,11 +110,11 @@
110110
111 /* Make sure we have a valid GConf client, and build one111 /* Make sure we have a valid GConf client, and build one
112 if needed */112 if needed */
113 ensure_gconf_client ();113 ensure_settings_client ();
114114
115 /* Check to see which menu items we're allowed to have */115 /* Check to see which menu items we're allowed to have */
116 can_activate = users_service_dbus_can_activate_session (self->users_dbus_interface) &&116 can_activate = users_service_dbus_can_activate_session (self->users_dbus_interface) &&
117 !gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_USER, NULL);117 !g_settings_get_boolean (settings, LOCKDOWN_KEY_USER);
118118
119 /* Remove the old menu items if that makes sense */119 /* Remove the old menu items if that makes sense */
120 children = dbusmenu_menuitem_take_children (self->root_item);120 children = dbusmenu_menuitem_take_children (self->root_item);
@@ -288,9 +288,9 @@
288 locking the screen. If not, lock it. */288 locking the screen. If not, lock it. */
289static void289static void
290lock_if_possible (void) {290lock_if_possible (void) {
291 ensure_gconf_client ();291 ensure_settings_client ();
292292
293 if (!gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_SCREENSAVER, NULL)) {293 if (!g_settings_get_boolean (settings, LOCKDOWN_KEY_SCREENSAVER)) {
294 lock_screen(NULL, 0, NULL);294 lock_screen(NULL, 0, NULL);
295 }295 }
296296
@@ -373,13 +373,12 @@
373/* Ensures that we have a GConf client and if we build one373/* Ensures that we have a GConf client and if we build one
374 set up the signal handler. */374 set up the signal handler. */
375static void375static void
376ensure_gconf_client ()376ensure_settings_client ()
377{377{
378 if (!gconf_client) {378 if(!settings) {
379 gconf_client = gconf_client_get_default ();379 settings = g_settings_new (LOCKDOWN_SCHEMA);
380 gconf_client_add_dir (gconf_client, LOCKDOWN_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
381 gconf_client_add_dir (gconf_client, KEYBINDING_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
382 }380 }
381 return;
383}382}
384383
385DbusmenuMenuitem*384DbusmenuMenuitem*

Subscribers

People subscribed via source and target branches