Merge lp:~ken-vandine/indicator-me/gsettings into lp:indicator-me

Proposed by Ken VanDine
Status: Merged
Approved by: Ted Gould
Approved revision: 150
Merged at revision: 148
Proposed branch: lp:~ken-vandine/indicator-me/gsettings
Merge into: lp:indicator-me
Diff against target: 189 lines (+40/-36)
6 files modified
configure.ac (+4/-2)
data/Makefile.am (+11/-2)
data/com.canonical.indicator.me.gschema.xml.in (+10/-0)
data/indicator-me.convert (+2/-0)
po/POTFILES.in (+1/-0)
src/me-service.c (+12/-32)
To merge this branch: bzr merge lp:~ken-vandine/indicator-me/gsettings
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Review via email: mp+58065@code.launchpad.net

This proposal supersedes a proposal from 2010-10-08.

Description of the change

Resubmit of mterry's branch, but renamed gsettings schema name to com.canonical.indicator.me, following the what we did for indicator-datetime

This fixes (LP: #656322)

To post a comment you must log in.
Revision history for this message
Ted Gould (ted) wrote : Posted in a previous version of this proposal

On Fri, 2010-10-08 at 19:01 +0000, Michael Terry wrote:
> One big concern I had with this conversion was that indicator-datetime is
> apparently using /apps/indicators/XXX for their gsettings paths. But
> indicator-me was using /system/indicator/XXX in gconf.

I like /apps because it seems like that's where people are putting
things that aren't part of GNOME Core. But, we should probably get a
definitive answer here.

Also, it seems to me this key should be an enum in gsettings (as it
supports that) instead of an int. Thoughts?

Revision history for this message
Michael Terry (mterry) wrote : Posted in a previous version of this proposal

I agree that this key would be an enum if we designed it from scratch. However, the gsettings documentation leads me to believe that enums are stored as strings. And gsettings-data-convert does not handle any sort of data transformation.

So you'd have to use some new key like 'display_enum', keep 'display' around, and then convert values yourself after both are in dconf. Doesn't seem worth it.

Revision history for this message
Ted Gould (ted) wrote : Posted in a previous version of this proposal

On Fri, 2010-10-08 at 23:52 +0000, Michael Terry wrote:
> I agree that this key would be an enum if we designed it from scratch. However, the gsettings documentation leads me to believe that enums are stored as strings. And gsettings-data-convert does not handle any sort of data transformation.
>
> So you'd have to use some new key like 'display_enum', keep 'display' around, and then convert values yourself after both are in dconf. Doesn't seem worth it.

Ah, sucks. Probably worth sticking with the int then. No cool new
feature use :)

Revision history for this message
Ted Gould (ted) wrote : Posted in a previous version of this proposal

GNOME has decided the paths should be Java style. So it should really be /com/canonical/indicator/me/*

review: Needs Fixing
Revision history for this message
Ted Gould (ted) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'configure.ac'
2--- configure.ac 2011-04-18 03:50:21 +0000
3+++ configure.ac 2011-04-18 04:14:23 +0000
4@@ -10,6 +10,8 @@
5
6 AM_MAINTAINER_MODE
7
8+GLIB_GSETTINGS
9+
10 IT_PROG_INTLTOOL([0.35.0])
11
12 AC_ISC_POSIX
13@@ -33,7 +35,7 @@
14 DBUSMENUGLIB_REQUIRED_VERSION=0.3.95
15 DBUSMENUGTK_REQUIRED_VERSION=0.3.95
16 TELEPATHYGLIB_REQUIRED_VERSION=0.9.0
17-GCONF_REQUIRED_VERSION=2.0.0
18+GLIB_REQUIRED_VERSION=2.26
19 INDICATOR_DISPLAY_OBJECTS=0.1
20 GIO_UNIX_REQUIRED_VERSION=2.22
21
22@@ -44,7 +46,7 @@
23 dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION
24 dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION)
25 PKG_CHECK_MODULES(MESERVICE, dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION
26- gconf-2.0 >= $GCONF_REQUIRED_VERSION
27+ glib-2.0 >= $GLIB_REQUIRED_VERSION
28 indicator >= $INDICATOR_REQUIRED_VERSION
29 gwibber-0.1 >= $GWIBBER_REQUIRED_VERSION
30 gio-unix-2.0 >= $GIO_UNIX_REQUIRED_VERSION
31
32=== modified file 'data/Makefile.am'
33--- data/Makefile.am 2009-11-20 23:26:22 +0000
34+++ data/Makefile.am 2011-04-18 04:14:23 +0000
35@@ -7,10 +7,19 @@
36 %.service: %.service.in
37 sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@
38
39+@INTLTOOL_XML_NOMERGE_RULE@
40+
41+@GSETTINGS_RULES@
42+gsettings_SCHEMAS = com.canonical.indicator.me.gschema.xml
43+
44+convertdir = $(datadir)/GConf/gsettings
45+dist_convert_DATA = indicator-me.convert
46
47 EXTRA_DIST = \
48- $(service_in_files)
49+ $(service_in_files) \
50+ $(gsettings_SCHEMAS:.xml=.xml.in)
51
52 CLEANFILES = \
53- $(dbus_services_DATA)
54+ $(dbus_services_DATA) \
55+ $(gsettings_SCHEMAS)
56
57
58=== added file 'data/com.canonical.indicator.me.gschema.xml.in'
59--- data/com.canonical.indicator.me.gschema.xml.in 1970-01-01 00:00:00 +0000
60+++ data/com.canonical.indicator.me.gschema.xml.in 2011-04-18 04:14:23 +0000
61@@ -0,0 +1,10 @@
62+<?xml version="1.0" encoding="UTF-8"?>
63+<schemalist gettext-domain="indicator-me">
64+ <schema id="com.canonical.indicator.me" path="/com/canonical/indicator/me/">
65+ <key name="display" type="i">
66+ <default>1</default>
67+ <_summary>How to display your name</_summary>
68+ <_description>Set this key to 0 to not show any name, set it to 1 to display your user name, or set it to 2 to display your full name.</_description>
69+ </key>
70+ </schema>
71+</schemalist>
72
73=== added file 'data/indicator-me.convert'
74--- data/indicator-me.convert 1970-01-01 00:00:00 +0000
75+++ data/indicator-me.convert 2011-04-18 04:14:23 +0000
76@@ -0,0 +1,2 @@
77+[com.canonical.indicator.me]
78+display = /system/indicator/me/display
79
80=== modified file 'po/POTFILES.in'
81--- po/POTFILES.in 2010-09-21 16:54:53 +0000
82+++ po/POTFILES.in 2011-04-18 04:14:23 +0000
83@@ -1,4 +1,5 @@
84 [encoding: UTF-8]
85+data/com.canonical.indicator.me.gschema.xml.in
86 src/indicator-me.c
87 src/status-provider.c
88 src/status-provider-pidgin.c
89
90=== modified file 'src/me-service.c'
91--- src/me-service.c 2011-03-23 23:21:07 +0000
92+++ src/me-service.c 2011-04-18 04:14:23 +0000
93@@ -34,8 +34,6 @@
94
95 #include <gio/gio.h>
96
97-#include <gconf/gconf-client.h>
98-
99 #include <libdbusmenu-glib/client.h>
100 #include <libdbusmenu-glib/server.h>
101 #include <libdbusmenu-glib/menuitem.h>
102@@ -93,6 +91,7 @@
103 static GFileMonitor *avatar_monitor = NULL;
104 static DbusmenuMenuitem *broadcast_field = NULL;
105 static DbusmenuMenuitem * useritem = NULL;
106+static GSettings *gsettings = NULL;
107
108 static void
109 status_update (void) {
110@@ -317,24 +316,13 @@
111 return FALSE;
112 }
113
114-#define GCONF_NAMESPACE "/system/indicator/me"
115-#define GCONF_DISPLAY "/system/indicator/me/display"
116-
117 static void
118-display_mode_changed ()
119+display_mode_changed (GSettings *settings, gchar *key)
120 {
121- GConfClient *context = gconf_client_get_default ();
122- g_return_if_fail (context != NULL);
123-
124- GConfValue *option = gconf_client_get (context, GCONF_DISPLAY, NULL);
125- gint value = 1; /* username, by default */
126+ gint value = g_settings_get_int (settings, key);
127
128 g_debug ("display_mode_changed");
129
130- if (option != NULL &&
131- option->type == GCONF_VALUE_INT)
132- value = gconf_value_get_int (option);
133-
134 switch (value) {
135 case 0: /* anonymous */
136 status_service_dbus_set_username (dbus_interface, "");
137@@ -351,10 +339,6 @@
138 dbusmenu_menuitem_property_set_bool (useritem,
139 DBUSMENU_MENUITEM_PROP_VISIBLE,
140 (value == 0) ? FALSE : TRUE);
141-
142- g_object_unref (context);
143-
144- return;
145 }
146
147
148@@ -399,22 +383,15 @@
149 }
150 #endif
151
152+#define GSETTINGS_SCHEMA "com.canonical.indicator.me"
153+#define GSETTINGS_DISPLAY "display"
154+
155 static gboolean
156 build_menu (gpointer data)
157 {
158 DbusmenuMenuitem * root = DBUSMENU_MENUITEM(data);
159 g_return_val_if_fail(DBUSMENU_IS_MENUITEM(root), FALSE);
160
161- /* and receive display mode notifications to update it later */
162- GConfClient *context = gconf_client_get_default ();
163- if (context != NULL) {
164- gconf_client_add_dir (context, GCONF_NAMESPACE,
165- GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
166- gconf_client_notify_add (context, GCONF_DISPLAY,
167- display_mode_changed, NULL, NULL, NULL);
168- g_object_unref (context);
169- }
170-
171 /* disabled for this release */
172 #if 0
173 build_avatar_item(root);
174@@ -478,9 +455,12 @@
175 }
176
177 /* finally set the menu name and update items visibility according
178- to a gconf key
179- */
180- display_mode_changed ();
181+ to a gsettings key and receive display mode notifications to update it
182+ later */
183+ gsettings = g_settings_new (GSETTINGS_SCHEMA);
184+ g_signal_connect (gsettings, "changed::" GSETTINGS_DISPLAY,
185+ G_CALLBACK (display_mode_changed), NULL);
186+ display_mode_changed (gsettings, GSETTINGS_DISPLAY);
187
188 return FALSE;
189 }

Subscribers

People subscribed via source and target branches