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
1=== modified file '.bzrignore'
2--- .bzrignore 2011-08-10 17:11:27 +0000
3+++ .bzrignore 2011-08-19 20:18:25 +0000
4@@ -1,6 +1,6 @@
5 compile
6 m4
7-po
8+po/indicator-session.pot
9 src/libmessaging.la
10 src/libmessaging_la-indicator-messages.lo
11 config.guess.cdbs-orig
12@@ -199,3 +199,6 @@
13 modified:
14 .bzrignore
15 src/libsession_la-user-widget.lo
16+consolekit-seat-client.h
17+data/com.canonical.indicator.session.gschema.valid
18+data/com.canonical.indicator.session.gschema.xml
19
20=== modified file 'configure.ac'
21--- configure.ac 2011-08-10 18:15:18 +0000
22+++ configure.ac 2011-08-19 20:18:25 +0000
23@@ -8,6 +8,8 @@
24
25 AM_MAINTAINER_MODE
26
27+GLIB_GSETTINGS
28+
29 IT_PROG_INTLTOOL([0.35.0])
30
31 AC_ISC_POSIX
32@@ -89,16 +91,6 @@
33 AC_SUBST(GTKLOGOUTHELPER_CFLAGS)
34 AC_SUBST(GTKLOGOUTHELPER_LIBS)
35
36-AC_PATH_PROG(GCONFTOOL, gconftool-2)
37-dnl Specify the gconf configuration source,
38-dnl default to xml::$(sysconfdir)/gconf/gconf.xml.defaults
39-
40-AM_GCONF_SOURCE_2
41-
42-PKG_CHECK_MODULES(GCONF, gconf-2.0 >= 2.0)
43-AC_SUBST(GCONF_CFLAGS)
44-AC_SUBST(GCONF_LIBS)
45-
46 ###########################
47 # Check to see if we're local
48 ###########################
49
50=== modified file 'data/Makefile.am'
51--- data/Makefile.am 2011-05-11 22:22:21 +0000
52+++ data/Makefile.am 2011-08-19 20:18:25 +0000
53@@ -9,37 +9,22 @@
54 %.service: %.service.in
55 sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@
56
57-##############################
58-# GConf Schema
59-##############################
60-
61-schemadir = \
62- $(GCONF_SCHEMA_FILE_DIR)
63-
64-schema_in_files = \
65- indicator-session.schemas.in
66-
67-schema_DATA = \
68- $(schema_in_files:.schemas.in=.schemas)
69-
70 @INTLTOOL_SCHEMAS_RULE@
71-
72-
73-#$(dbus_services_DATA): $(service_in_files) Makefile
74-# sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@
75+@INTLTOOL_XML_NOMERGE_RULE@
76+
77+@GSETTINGS_RULES@
78+gsettings_SCHEMAS = com.canonical.indicator.session.gschema.xml
79+
80+convertdir = $(datadir)/GConf/gsettings
81+dist_convert_DATA = indicator-session.convert
82+
83
84 EXTRA_DIST = \
85 $(service_in_files) \
86- $(schema_in_files)
87+ $(gsettings_SCHEMAS:.xml=.xml.in)
88+
89
90 CLEANFILES = \
91 $(dbus_services_DATA) \
92- $(schema_DATA)
93+ $(gsettings_SCHEMAS)
94
95-if GCONF_SCHEMAS_INSTALL
96-install-data-local:
97- GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) \
98- gconftool-2 --makefile-install-rule $(schema_DATA)
99-else
100-install-data-local:
101-endif
102
103=== added file 'data/com.canonical.indicator.session.gschema.xml.in'
104--- data/com.canonical.indicator.session.gschema.xml.in 1970-01-01 00:00:00 +0000
105+++ data/com.canonical.indicator.session.gschema.xml.in 2011-08-19 20:18:25 +0000
106@@ -0,0 +1,24 @@
107+<schemalist>
108+ <schema id="com.canonical.indicator.session" path="/apps/indicator-session/">
109+ <key name="suppress-logout-restart-shutdown" type="b">
110+ <default>false</default>
111+ <_summary>Suppress the dialog to confirm logout, restart and shutdown action</_summary>
112+ <_description>Whether or not to show confirmation dialogs for logout, restart and shutdown actions.</_description>
113+ </key>
114+ <key name="suppress-logout-menuitem" type="b">
115+ <default>false</default>
116+ <_summary>Remove the Log Out item from the session menu</_summary>
117+ <_description>Makes it so that the logout button doesn't show in the session menu.</_description>
118+ </key>
119+ <key name="suppress-restart-menuitem" type="b">
120+ <default>false</default>
121+ <_summary>Remove the Restart item from the session menu</_summary>
122+ <_description>Makes it so that the restart button doesn't show in the session menu.</_description>
123+ </key>
124+ <key name="suppress-shutdown-menuitem" type="b">
125+ <default>false</default>
126+ <_summary>Remove the shutdown item from the session menu</_summary>
127+ <_description>Makes it so that the shutdown button doesn't show in the session menu.</_description>
128+ </key>
129+ </schema>
130+</schemalist>
131
132=== added file 'data/indicator-session.convert'
133--- data/indicator-session.convert 1970-01-01 00:00:00 +0000
134+++ data/indicator-session.convert 2011-08-19 20:18:25 +0000
135@@ -0,0 +1,5 @@
136+[com.canonical.indicator.session]
137+suppress_logout_restart_shutdown = /apps/indicator-session/suppress_logout_restart_shutdown
138+suppress_logout_menuitem = /apps/indicator-session/suppress_logout_menuitem
139+suppress_restart_menuitem = /apps/indicator-session/suppress_restart_menuitem
140+suppress_shutdown_menuitem = /apps/indicator-session/suppress_shutdown_menuitem
141
142=== removed file 'data/indicator-session.schemas.in'
143--- data/indicator-session.schemas.in 2010-04-06 21:56:04 +0000
144+++ data/indicator-session.schemas.in 1970-01-01 00:00:00 +0000
145@@ -1,50 +0,0 @@
146-<?xml version="1.0"?>
147-<gconfschemafile>
148- <schemalist>
149- <schema>
150- <key>/schemas/apps/indicator-session/suppress_logout_restart_shutdown</key>
151- <applyto>/apps/indicator-session/suppress_logout_restart_shutdown</applyto>
152- <owner>indicator-session</owner>
153- <type>bool</type>
154- <default>FALSE</default>
155- <locale name="C">
156- <short>Suppress the dialog to confirm logout, restart and shutdown action</short>
157- <long>Whether or not to show confirmation dialogs for logout,
158- restart and shutdown actions.</long>
159- </locale>
160- </schema>
161- <schema>
162- <key>/schemas/apps/indicator-session/suppress_logout_menuitem</key>
163- <applyto>/apps/indicator-session/suppress_logout_menuitem</applyto>
164- <owner>indicator-session</owner>
165- <type>bool</type>
166- <default>FALSE</default>
167- <locale name="C">
168- <short>Remove the Log Out item from the session menu</short>
169- <long>Makes it so that the logout button doesn't show in the session menu.</long>
170- </locale>
171- </schema>
172- <schema>
173- <key>/schemas/apps/indicator-session/suppress_restart_menuitem</key>
174- <applyto>/apps/indicator-session/suppress_restart_menuitem</applyto>
175- <owner>indicator-session</owner>
176- <type>bool</type>
177- <default>FALSE</default>
178- <locale name="C">
179- <short>Remove the Restart item from the session menu</short>
180- <long>Makes it so that the restart button doesn't show in the session menu.</long>
181- </locale>
182- </schema>
183- <schema>
184- <key>/schemas/apps/indicator-session/suppress_shutdown_menuitem</key>
185- <applyto>/apps/indicator-session/suppress_shutdown_menuitem</applyto>
186- <owner>indicator-session</owner>
187- <type>bool</type>
188- <default>FALSE</default>
189- <locale name="C">
190- <short>Remove the shutdown item from the session menu</short>
191- <long>Makes it so that the shutdown button doesn't show in the session menu.</long>
192- </locale>
193- </schema>
194- </schemalist>
195-</gconfschemafile>
196
197=== modified file 'po/POTFILES.in'
198--- po/POTFILES.in 2011-07-22 17:12:20 +0000
199+++ po/POTFILES.in 2011-08-19 20:18:25 +0000
200@@ -1,7 +1,7 @@
201 [encoding: UTF-8]
202-data/indicator-session.schemas.in
203+data/com.canonical.indicator.session.gschema.xml.in
204 data/extra-sessions/classic-desktop.desktop.in.in
205-src/gconf-helper.c
206+src/settings-helper.c
207 src/lock-helper.c
208 src/gtk-logout-helper.c
209 src/dialog.c
210
211=== modified file 'src/Makefile.am'
212--- src/Makefile.am 2011-08-17 20:53:51 +0000
213+++ src/Makefile.am 2011-08-19 20:18:25 +0000
214@@ -96,11 +96,11 @@
215 session-dbus.h \
216 gen-session-dbus.xml.c \
217 dbusmenu-shared.h \
218- gconf-helper.c \
219+ settings-helper.c \
220 users-service-dbus.h \
221 users-service-dbus.c \
222 user-menu-mgr.h \
223- user-menu-mgr.c \
224+ user-menu-mgr.c \
225 device-menu-mgr.h \
226 device-menu-mgr.c \
227 apt-watcher.h \
228@@ -126,8 +126,8 @@
229
230 gtk_logout_helper_SOURCES = \
231 gtk-logout-helper.c \
232- gconf-helper.c \
233- gconf-helper.h \
234+ settings-helper.c \
235+ settings-helper.h \
236 dialog.c \
237 dialog.h
238
239
240=== modified file 'src/device-menu-mgr.c'
241--- src/device-menu-mgr.c 2011-08-18 15:21:02 +0000
242+++ src/device-menu-mgr.c 2011-08-19 20:18:25 +0000
243@@ -21,7 +21,7 @@
244 #include <libdbusmenu-gtk3/menuitem.h>
245
246 #include "device-menu-mgr.h"
247-#include "gconf-helper.h"
248+#include "settings-helper.h"
249 #include "dbus-shared-names.h"
250 #include "dbusmenu-shared.h"
251 #include "lock-helper.h"
252@@ -44,7 +44,8 @@
253 UdevMgr* udev_mgr;
254 };
255
256-static GConfClient *gconf_client = NULL;
257+static GSettings *lockdown_settings = NULL;
258+static GSettings *keybinding_settings = NULL;
259 static DbusmenuMenuitem *lock_menuitem = NULL;
260 static DbusmenuMenuitem *system_settings_menuitem = NULL;
261 static DbusmenuMenuitem *display_settings_menuitem = NULL;
262@@ -72,7 +73,7 @@
263 static DBusGProxy * up_main_proxy = NULL;
264 static DBusGProxy * up_prop_proxy = NULL;
265
266-static void device_menu_mgr_ensure_gconf_client (DeviceMenuMgr* self);
267+static void device_menu_mgr_ensure_settings_client (DeviceMenuMgr* self);
268 static void setup_restart_watch (DeviceMenuMgr* self);
269 static void setup_up (DeviceMenuMgr* self);
270 static void device_menu_mgr_rebuild_items (DeviceMenuMgr *self);
271@@ -128,21 +129,18 @@
272 // TODO
273 // Is this needed anymore
274 static void
275-lockdown_changed (GConfClient *client,
276- guint cnxd_id,
277- GConfEntry *entry,
278+lockdown_changed (GSettings * settings,
279+ const gchar * key,
280 gpointer user_data)
281 {
282- DeviceMenuMgr* self = DEVICE_MENU_MGR (user_data);
283- GConfValue *value = gconf_entry_get_value (entry);
284- const gchar *key = gconf_entry_get_key (entry);
285+ DeviceMenuMgr* self = DEVICE_MENU_MGR (user_data);
286
287- if (value == NULL || key == NULL) {
288+ if (key == NULL) {
289 return;
290 }
291
292 if (g_strcmp0 (key, LOCKDOWN_KEY_USER) == 0 ||
293- g_strcmp0 (key, LOCKDOWN_KEY_SCREENSAVER) == 0) {
294+ g_strcmp0 (key, LOCKDOWN_KEY_SCREENSAVER) == 0) {
295 device_menu_mgr_rebuild_items(self);
296 }
297
298@@ -150,23 +148,19 @@
299 }
300
301 static void
302-keybinding_changed (GConfClient *client,
303- guint cnxd_id,
304- GConfEntry *entry,
305+keybinding_changed (GSettings *settings,
306+ const gchar *key,
307 gpointer user_data)
308 {
309- GConfValue *value = gconf_entry_get_value (entry);
310- const gchar *key = gconf_entry_get_key (entry);
311-
312- if (value == NULL || key == NULL) {
313+ if (key == NULL) {
314 return;
315 }
316
317 if (g_strcmp0 (key, KEY_LOCK_SCREEN) == 0) {
318- g_debug("Keybinding changed to: %s", gconf_value_get_string(value));
319+ g_debug("Keybinding changed to: %s", g_settings_get_string(settings, key));
320 if (lock_menuitem != NULL) {
321 dbusmenu_menuitem_property_set_shortcut_string (lock_menuitem,
322- gconf_value_get_string(value));
323+ g_settings_get_string(settings, key));
324 }
325 }
326 return;
327@@ -176,9 +170,9 @@
328 locking the screen. If not, lock it. */
329 static void
330 lock_if_possible (DeviceMenuMgr* self) {
331- device_menu_mgr_ensure_gconf_client (self);
332+ device_menu_mgr_ensure_settings_client (self);
333
334- if (!gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_SCREENSAVER, NULL)) {
335+ if (!g_settings_get_boolean (lockdown_settings, LOCKDOWN_KEY_SCREENSAVER)) {
336 lock_screen (NULL, 0, NULL);
337 }
338 return;
339@@ -659,10 +653,9 @@
340
341 /* Make sure we have a valid GConf client, and build one
342 if needed */
343- device_menu_mgr_ensure_gconf_client (self);
344- can_lockscreen = !gconf_client_get_bool ( gconf_client,
345- LOCKDOWN_KEY_SCREENSAVER,
346- NULL);
347+ device_menu_mgr_ensure_settings_client (self);
348+ can_lockscreen = !g_settings_get_boolean (lockdown_settings,
349+ LOCKDOWN_KEY_SCREENSAVER);
350 /* Lock screen item */
351 if (can_lockscreen) {
352 lock_menuitem = dbusmenu_menuitem_new();
353@@ -670,7 +663,7 @@
354 DBUSMENU_MENUITEM_PROP_LABEL,
355 _("Lock Screen"));
356
357- gchar * shortcut = gconf_client_get_string(gconf_client, KEY_LOCK_SCREEN, NULL);
358+ gchar * shortcut = g_settings_get_string(keybinding_settings, KEY_LOCK_SCREEN);
359 if (shortcut != NULL) {
360 g_debug("Lock screen shortcut: %s", shortcut);
361 dbusmenu_menuitem_property_set_shortcut_string(lock_menuitem, shortcut);
362@@ -830,26 +823,18 @@
363 /* Ensures that we have a GConf client and if we build one
364 set up the signal handler. */
365 static void
366-device_menu_mgr_ensure_gconf_client (DeviceMenuMgr* self)
367+device_menu_mgr_ensure_settings_client (DeviceMenuMgr* self)
368 {
369- if (!gconf_client) {
370- gconf_client = gconf_client_get_default ();
371- gconf_client_add_dir(gconf_client, LOCKDOWN_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
372- gconf_client_notify_add (gconf_client,
373- LOCKDOWN_DIR,
374- lockdown_changed,
375- self,
376- NULL,
377- NULL);
378+ if (!lockdown_settings) {
379+ lockdown_settings = g_settings_new (LOCKDOWN_SCHEMA);
380+ g_signal_connect(lockdown_settings, "changed", G_CALLBACK(lockdown_changed), self);
381+ }
382+ if (!keybinding_settings) {
383+ keybinding_settings = g_settings_new (KEYBINDING_SCHEMA);
384+ g_signal_connect(lockdown_settings, "changed::" KEY_LOCK_SCREEN, G_CALLBACK(keybinding_changed), self);
385+ }
386
387- gconf_client_add_dir(gconf_client, KEYBINDING_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
388- gconf_client_notify_add (gconf_client,
389- KEYBINDING_DIR,
390- keybinding_changed,
391- self,
392- NULL,
393- NULL);
394- }
395+ return;
396 }
397
398 DbusmenuMenuitem*
399
400=== modified file 'src/gtk-logout-helper.c'
401--- src/gtk-logout-helper.c 2010-04-02 02:27:28 +0000
402+++ src/gtk-logout-helper.c 2011-08-19 20:18:25 +0000
403@@ -26,7 +26,7 @@
404 #include <gtk/gtk.h>
405 #include <dbus/dbus-glib.h>
406 #include "dialog.h"
407-#include "gconf-helper.h"
408+#include "settings-helper.h"
409
410 static void
411 consolekit_fallback (LogoutDialogType action)
412
413=== renamed file 'src/gconf-helper.c' => 'src/settings-helper.c'
414--- src/gconf-helper.c 2011-06-12 12:42:53 +0000
415+++ src/settings-helper.c 2011-08-19 20:18:25 +0000
416@@ -1,5 +1,5 @@
417 /*
418-A small wrapper utility for connecting to gconf.
419+A small wrapper utility for connecting to GSettings.
420
421 Copyright 2009 Canonical Ltd.
422
423@@ -19,9 +19,7 @@
424 with this program. If not, see <http://www.gnu.org/licenses/>.
425 */
426
427-
428-#include <gconf/gconf-client.h>
429-
430+#include <gio/gio.h>
431 #include <glib/gi18n.h>
432
433 #include <dbus/dbus-glib.h>
434@@ -31,53 +29,52 @@
435 #include <libdbusmenu-glib/menuitem.h>
436
437 #include "dbus-shared-names.h"
438-#include "gconf-helper.h"
439-
440-static GConfClient * gconf_client = NULL;
441+#include "settings-helper.h"
442+
443+static GSettings* settings = NULL;
444+
445 static guint confirmation_notify = 0;
446 static guint logout_notify = 0;
447 static guint restart_notify = 0;
448 static guint shutdown_notify = 0;
449
450+static void
451+build_settings (void) {
452+ if(!settings) {
453+ settings = g_settings_new (SESSION_SCHEMA);
454+ }
455+ return;
456+}
457+
458 gboolean
459 supress_confirmations (void) {
460- if(!gconf_client) {
461- gconf_client = gconf_client_get_default ();
462- }
463- return gconf_client_get_bool (gconf_client, SUPPRESS_KEY, NULL) ;
464+ build_settings();
465+ return g_settings_get_boolean (settings, SUPPRESS_KEY) ;
466 }
467
468 gboolean
469 show_logout (void) {
470- if(!gconf_client) {
471- gconf_client = gconf_client_get_default ();
472- }
473- return !gconf_client_get_bool (gconf_client, LOGOUT_KEY, NULL) ;
474+ build_settings();
475+ return !g_settings_get_boolean (settings, LOGOUT_KEY) ;
476 }
477
478 gboolean
479 show_restart (void) {
480- if(!gconf_client) {
481- gconf_client = gconf_client_get_default ();
482- }
483- return !gconf_client_get_bool (gconf_client, RESTART_KEY, NULL) ;
484+ build_settings();
485+ return !g_settings_get_boolean (settings, RESTART_KEY) ;
486 }
487
488 gboolean
489 show_shutdown (void) {
490- if(!gconf_client) {
491- gconf_client = gconf_client_get_default ();
492- }
493- return !gconf_client_get_bool (gconf_client, SHUTDOWN_KEY, NULL) ;
494+ build_settings();
495+ return !g_settings_get_boolean (settings, SHUTDOWN_KEY) ;
496 }
497
498-static void update_menu_entries_callback (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer data) {
499+static void update_menu_entries_callback (GSettings * settings, const gchar * key, gpointer data) {
500 RestartShutdownLogoutMenuItems * restart_shutdown_logout_mi = (RestartShutdownLogoutMenuItems*) data;
501- GConfValue * value = gconf_entry_get_value (entry);
502- const gchar * key = gconf_entry_get_key (entry);
503
504 if(g_strcmp0 (key, SUPPRESS_KEY) == 0) {
505- if (gconf_value_get_bool (value)) {
506+ if (g_settings_get_boolean (settings, key)) {
507 dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->logout_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Log Out"));
508 dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->restart_mi, RESTART_ITEM_LABEL, _("Restart"));
509 dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Shut Down"));
510@@ -90,80 +87,65 @@
511 }
512
513 static void
514-update_logout_callback (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer data) {
515+update_logout_callback (GSettings * settings, const gchar * key, gpointer data) {
516 DbusmenuMenuitem * mi = (DbusmenuMenuitem*) data;
517- GConfValue * value = gconf_entry_get_value (entry);
518- const gchar * key = gconf_entry_get_key (entry);
519
520 if(g_strcmp0 (key, LOGOUT_KEY) == 0) {
521- dbusmenu_menuitem_property_set_bool(mi, DBUSMENU_MENUITEM_PROP_VISIBLE, !gconf_value_get_bool(value));
522+ dbusmenu_menuitem_property_set_bool(mi, DBUSMENU_MENUITEM_PROP_VISIBLE, !g_settings_get_boolean(settings, key));
523 }
524 }
525
526 static void
527-update_restart_callback (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer data) {
528+update_restart_callback (GSettings * settings, const gchar * key, gpointer data) {
529 DbusmenuMenuitem * mi = (DbusmenuMenuitem*) data;
530- GConfValue * value = gconf_entry_get_value (entry);
531- const gchar * key = gconf_entry_get_key (entry);
532
533 if(g_strcmp0 (key, RESTART_KEY) == 0) {
534- dbusmenu_menuitem_property_set_bool(mi, DBUSMENU_MENUITEM_PROP_VISIBLE, !gconf_value_get_bool(value));
535+ dbusmenu_menuitem_property_set_bool(mi, DBUSMENU_MENUITEM_PROP_VISIBLE, !g_settings_get_boolean(settings, key));
536 }
537 }
538
539 static void
540-update_shutdown_callback (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer data) {
541+update_shutdown_callback (GSettings * settings, const gchar * key, gpointer data) {
542 DbusmenuMenuitem * mi = (DbusmenuMenuitem*) data;
543- GConfValue * value = gconf_entry_get_value (entry);
544- const gchar * key = gconf_entry_get_key (entry);
545
546 if(g_strcmp0 (key, SHUTDOWN_KEY) == 0) {
547- dbusmenu_menuitem_property_set_bool(mi, DBUSMENU_MENUITEM_PROP_VISIBLE, !gconf_value_get_bool(value));
548+ dbusmenu_menuitem_property_set_bool(mi, DBUSMENU_MENUITEM_PROP_VISIBLE, !g_settings_get_boolean(settings, key));
549 }
550 }
551
552 void
553 update_menu_entries(RestartShutdownLogoutMenuItems * restart_shutdown_logout_mi) {
554 /* If we don't have a client, build one. */
555- if(!gconf_client) {
556- gconf_client = gconf_client_get_default ();
557- }
558-
559- /* If we've not gotten any notifications, then we need
560- to add the directory for notifications to come from. */
561- if (confirmation_notify == 0 || logout_notify == 0) {
562- gconf_client_add_dir (gconf_client, GLOBAL_DIR,
563- GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
564- }
565+ build_settings();
566
567 if (confirmation_notify != 0) {
568- gconf_client_notify_remove (gconf_client, confirmation_notify);
569+ g_signal_handler_disconnect (settings, confirmation_notify);
570 confirmation_notify = 0;
571 }
572
573 if (logout_notify != 0) {
574- gconf_client_notify_remove (gconf_client, logout_notify);
575+ g_signal_handler_disconnect (settings, logout_notify);
576 logout_notify = 0;
577 }
578
579 if (restart_notify != 0) {
580- gconf_client_notify_remove (gconf_client, restart_notify);
581+ g_signal_handler_disconnect (settings, restart_notify);
582 restart_notify = 0;
583 }
584
585 if (shutdown_notify != 0) {
586- gconf_client_notify_remove (gconf_client, shutdown_notify);
587+ g_signal_handler_disconnect (settings, shutdown_notify);
588 shutdown_notify = 0;
589 }
590
591- confirmation_notify = gconf_client_notify_add (gconf_client, SUPPRESS_KEY,
592- update_menu_entries_callback, restart_shutdown_logout_mi, NULL, NULL);
593- logout_notify = gconf_client_notify_add (gconf_client, LOGOUT_KEY,
594- update_logout_callback, restart_shutdown_logout_mi->logout_mi, NULL, NULL);
595- restart_notify = gconf_client_notify_add (gconf_client, RESTART_KEY,
596- update_restart_callback, restart_shutdown_logout_mi->restart_mi, NULL, NULL);
597- shutdown_notify = gconf_client_notify_add (gconf_client, SHUTDOWN_KEY,
598- update_shutdown_callback, restart_shutdown_logout_mi->shutdown_mi, NULL, NULL);
599+ confirmation_notify = g_signal_connect (settings, "changed::" SUPPRESS_KEY,
600+ G_CALLBACK(update_menu_entries_callback), restart_shutdown_logout_mi);
601+ logout_notify = g_signal_connect (settings, "changed::" LOGOUT_KEY,
602+ G_CALLBACK(update_logout_callback), restart_shutdown_logout_mi->logout_mi);
603+ restart_notify = g_signal_connect (settings, "changed::" RESTART_KEY,
604+ G_CALLBACK(update_restart_callback), restart_shutdown_logout_mi->restart_mi);
605+ shutdown_notify = g_signal_connect (settings, "changed::" SHUTDOWN_KEY,
606+ G_CALLBACK(update_shutdown_callback), restart_shutdown_logout_mi->shutdown_mi);
607
608 return;
609 }
610
611=== renamed file 'src/gconf-helper.h' => 'src/settings-helper.h'
612--- src/gconf-helper.h 2011-07-15 11:06:53 +0000
613+++ src/settings-helper.h 2011-08-19 20:18:25 +0000
614@@ -1,5 +1,5 @@
615 /*
616-A small wrapper utility for connecting to gconf.
617+A small wrapper utility for connecting to GSettings.
618
619 Copyright 2009 Canonical Ltd.
620
621@@ -23,8 +23,6 @@
622 #ifndef __GCONF_HELPER_H__
623 #define __GCONF_HELPER_H__ 1
624
625-#include <gconf/gconf-client.h>
626-
627 #include <glib/gi18n.h>
628
629 #include <dbus/dbus-glib.h>
630@@ -33,17 +31,17 @@
631 #include <libdbusmenu-glib/server.h>
632 #include <libdbusmenu-glib/menuitem.h>
633
634-#define GLOBAL_DIR "/apps/indicator-session"
635-#define SUPPRESS_KEY GLOBAL_DIR "/suppress_logout_restart_shutdown"
636-#define LOGOUT_KEY GLOBAL_DIR "/suppress_logout_menuitem"
637-#define RESTART_KEY GLOBAL_DIR "/suppress_restart_menuitem"
638-#define SHUTDOWN_KEY GLOBAL_DIR "/suppress_shutdown_menuitem"
639+#define SESSION_SCHEMA "com.canonical.indicator.session"
640+#define SUPPRESS_KEY "suppress-logout-restart-shutdown"
641+#define LOGOUT_KEY "suppress-logout-menuitem"
642+#define RESTART_KEY "suppress-restart-menuitem"
643+#define SHUTDOWN_KEY "suppress-shutdown-menuitem"
644
645-#define LOCKDOWN_DIR "/desktop/gnome/lockdown"
646-#define LOCKDOWN_KEY_USER LOCKDOWN_DIR "/disable_user_switching"
647-#define LOCKDOWN_KEY_SCREENSAVER LOCKDOWN_DIR "/disable_lock_screen"
648-#define KEYBINDING_DIR "/apps/gnome_settings_daemon/keybindings"
649-#define KEY_LOCK_SCREEN KEYBINDING_DIR "/screensaver"
650+#define LOCKDOWN_SCHEMA "org.gnome.desktop.lockdown"
651+#define LOCKDOWN_KEY_USER "disable-user-switching"
652+#define LOCKDOWN_KEY_SCREENSAVER "disable-lock-screen"
653+#define KEYBINDING_SCHEMA "org.gnome.settings-daemon.plugins.media-keys"
654+#define KEY_LOCK_SCREEN "screensaver"
655
656 typedef struct _RestartShutdownLogoutMenuItems
657 {
658
659=== modified file 'src/user-menu-mgr.c'
660--- src/user-menu-mgr.c 2011-08-18 15:21:02 +0000
661+++ src/user-menu-mgr.c 2011-08-19 20:18:25 +0000
662@@ -20,13 +20,13 @@
663 #include <libdbusmenu-glib/client.h>
664
665 #include "user-menu-mgr.h"
666-#include "gconf-helper.h"
667+#include "settings-helper.h"
668 #include "dbus-shared-names.h"
669 #include "dbusmenu-shared.h"
670 #include "lock-helper.h"
671 #include "users-service-dbus.h"
672
673-static GConfClient * gconf_client = NULL;
674+static GSettings* settings = NULL;
675 static DbusmenuMenuitem *switch_menuitem = NULL;
676
677 struct _UserMenuMgr
678@@ -56,7 +56,7 @@
679 const gchar *user_id,
680 gpointer user_data);
681
682-static void ensure_gconf_client ();
683+static void ensure_settings_client ();
684 static gboolean check_guest_session (void);
685 static void activate_guest_session (DbusmenuMenuitem * mi,
686 guint timestamp,
687@@ -110,11 +110,11 @@
688
689 /* Make sure we have a valid GConf client, and build one
690 if needed */
691- ensure_gconf_client ();
692+ ensure_settings_client ();
693
694 /* Check to see which menu items we're allowed to have */
695 can_activate = users_service_dbus_can_activate_session (self->users_dbus_interface) &&
696- !gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_USER, NULL);
697+ !g_settings_get_boolean (settings, LOCKDOWN_KEY_USER);
698
699 /* Remove the old menu items if that makes sense */
700 children = dbusmenu_menuitem_take_children (self->root_item);
701@@ -288,9 +288,9 @@
702 locking the screen. If not, lock it. */
703 static void
704 lock_if_possible (void) {
705- ensure_gconf_client ();
706+ ensure_settings_client ();
707
708- if (!gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_SCREENSAVER, NULL)) {
709+ if (!g_settings_get_boolean (settings, LOCKDOWN_KEY_SCREENSAVER)) {
710 lock_screen(NULL, 0, NULL);
711 }
712
713@@ -373,13 +373,12 @@
714 /* Ensures that we have a GConf client and if we build one
715 set up the signal handler. */
716 static void
717-ensure_gconf_client ()
718+ensure_settings_client ()
719 {
720- if (!gconf_client) {
721- gconf_client = gconf_client_get_default ();
722- gconf_client_add_dir (gconf_client, LOCKDOWN_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
723- gconf_client_add_dir (gconf_client, KEYBINDING_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
724+ if(!settings) {
725+ settings = g_settings_new (LOCKDOWN_SCHEMA);
726 }
727+ return;
728 }
729
730 DbusmenuMenuitem*

Subscribers

People subscribed via source and target branches