Merge lp:~didrocks/libunity/add-remote-disabling-support into lp:libunity

Proposed by Didier Roche-Tolomelli
Status: Merged
Approved by: Didier Roche-Tolomelli
Approved revision: 189
Merged at revision: 181
Proposed branch: lp:~didrocks/libunity/add-remote-disabling-support
Merge into: lp:libunity
Diff against target: 305 lines (+184/-1)
11 files modified
Makefile.am (+2/-1)
configure.ac (+13/-0)
data/Makefile.am (+16/-0)
data/com.canonical.Unity.Lenses.gschema.xml.in.in (+10/-0)
po/POTFILES.in (+4/-0)
po/POTFILES.skip (+1/-0)
src/Makefile.am (+1/-0)
src/unity-lens-preferences-manager.vala (+68/-0)
test/vala/Makefile.am (+2/-0)
test/vala/test-preferences.vala (+54/-0)
test/vala/test-vala.vala (+13/-0)
To merge this branch: bzr merge lp:~didrocks/libunity/add-remote-disabling-support
Reviewer Review Type Date Requested Status
Michal Hruby (community) Approve
Review via email: mp+126284@code.launchpad.net

Commit message

Add remote search disabling option support to libunity for lenses to consume it.

Description of the change

Add remote search disabling option support to libunity for lenses to consume
it.

Tests included

To post a comment you must log in.
Revision history for this message
Michal Hruby (mhr3) wrote :

146 + public class LensPreferencesManager : GLib.Object

Drop the Lens from the name pls.

159 + private LensPreferencesManager ()
160 + {
161 + gp_settings = new Settings ("com.canonical.Unity.Lenses");
162 + gp_settings.bind (REMOTE_CONTENT_KEY, this, "remote_content_search", SettingsBindFlags.GET);
163 + }

The binding should be in construct {} block. Constructor should be just:
private PreferencesManager ()
{
  Object ();
}

269 + Process.spawn_command_line_sync ("glib-compile-schemas " + gsettings_schema_dir);

Is this really necessary? Don't remember seeing it in other projects?

Otherwise looking good, thanks ;)

review: Needs Fixing
Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

1 & 2 -> done

for 3, you can want override the schema place as I'm doing. However, you still need the schema to be compiled for it being visible. Hence this call.

Revision history for this message
Michal Hruby (mhr3) wrote :

Looking great now! +1

review: Approve
Revision history for this message
Unity Merger (unity-merger) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-libunity/161/console reported an error when processing this lp:~didrocks/libunity/add-remote-disabling-support branch.
Not merging it.

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

@Michael: I didn't push the packaging change before you acked me on IRC. doing now :)

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

s/Michael/Michal :)

Revision history for this message
Unity Merger (unity-merger) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-libunity/162/console reported an error when processing this lp:~didrocks/libunity/add-remote-disabling-support branch.
Not merging it.

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

We always need some intltool…

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile.am'
2--- Makefile.am 2012-08-20 17:44:32 +0000
3+++ Makefile.am 2012-09-26 08:48:22 +0000
4@@ -7,7 +7,8 @@
5 doc \
6 examples \
7 test \
8- vapi
9+ vapi \
10+ po
11
12 pkgconfigdir = $(libdir)/pkgconfig
13 pkgconfig_DATA = unity.pc unity-protocol-private.pc
14
15=== modified file 'configure.ac'
16--- configure.ac 2012-09-24 13:30:51 +0000
17+++ configure.ac 2012-09-26 08:48:22 +0000
18@@ -121,6 +121,11 @@
19
20 GOBJECT_INTROSPECTION_CHECK([0.10.0])
21
22+#############################################
23+# Gettext
24+#############################################
25+IT_PROG_INTLTOOL([0.40.0])
26+
27 #################################################
28 # Docs
29 #################################################
30@@ -209,6 +214,12 @@
31 AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
32 AC_SUBST(GLIB_GENMARSHAL)
33
34+#############################################
35+# GSettings macros
36+#############################################
37+
38+GLIB_GSETTINGS
39+
40 ######################################################################
41 # Send directory information
42 ######################################################################
43@@ -220,10 +231,12 @@
44 Makefile
45 bindings/Makefile
46 bindings/python/Makefile
47+data/com.canonical.Unity.Lenses.gschema.xml.in
48 data/Makefile
49 doc/Makefile
50 doc/reference/Makefile
51 examples/Makefile
52+po/Makefile.in
53 protocol/Makefile
54 src/Makefile
55 tools/Makefile
56
57=== modified file 'data/Makefile.am'
58--- data/Makefile.am 2011-01-11 17:37:13 +0000
59+++ data/Makefile.am 2012-09-26 08:48:22 +0000
60@@ -0,0 +1,16 @@
61+#############################################################
62+# GSettings schemas
63+#############################################################
64+gsettings_SCHEMAS = com.canonical.Unity.Lenses.gschema.xml
65+
66+@GSETTINGS_RULES@
67+
68+@INTLTOOL_XML_NOMERGE_RULE@
69+
70+EXTRA_DIST = \
71+ com.canonical.Unity.Lenses.gschema.xml.in.in
72+
73+CLEANFILES = \
74+ gschemas.compiled \
75+ $(gsettings_SCHEMAS)
76+
77
78=== added file 'data/com.canonical.Unity.Lenses.gschema.xml.in.in'
79--- data/com.canonical.Unity.Lenses.gschema.xml.in.in 1970-01-01 00:00:00 +0000
80+++ data/com.canonical.Unity.Lenses.gschema.xml.in.in 2012-09-26 08:48:22 +0000
81@@ -0,0 +1,10 @@
82+<schemalist>
83+ <schema path="/com/canonical/unity/lenses/" id="com.canonical.Unity.Lenses" gettext-domain="libunity">
84+ <key type="s" name="remote-content-search">
85+ <default>'all'</default>
86+ <choices><choice value='all'/><choice value='none'/></choices>
87+ <summary>Content fetching from remote source preference.</summary>
88+ <description>"all" is to enable the supported default lens to search from remote and commercial sources. "none" will indicate the lenses to not perform that remote search at all.</description>
89+ </key>
90+ </schema>
91+</schemalist>
92
93=== added directory 'po'
94=== added file 'po/POTFILES.in'
95--- po/POTFILES.in 1970-01-01 00:00:00 +0000
96+++ po/POTFILES.in 2012-09-26 08:48:22 +0000
97@@ -0,0 +1,4 @@
98+[encoding: UTF-8]
99+tools/dbus-lens-connect.ui
100+tools/unity-tool.vala
101+tools/unity-tool.ui
102
103=== added file 'po/POTFILES.skip'
104--- po/POTFILES.skip 1970-01-01 00:00:00 +0000
105+++ po/POTFILES.skip 2012-09-26 08:48:22 +0000
106@@ -0,0 +1,1 @@
107+tools/unity-tool.c
108
109=== modified file 'src/Makefile.am'
110--- src/Makefile.am 2012-08-20 17:44:32 +0000
111+++ src/Makefile.am 2012-09-26 08:48:22 +0000
112@@ -98,6 +98,7 @@
113 unity-lens-category.vala \
114 unity-lens-filters.vala \
115 unity-lens-merge-strategy.vala \
116+ unity-lens-preferences-manager.vala \
117 unity-lens-private.vala \
118 unity-lens-search.vala \
119 unity-lens-tools.vala \
120
121=== added file 'src/unity-lens-preferences-manager.vala'
122--- src/unity-lens-preferences-manager.vala 1970-01-01 00:00:00 +0000
123+++ src/unity-lens-preferences-manager.vala 2012-09-26 08:48:22 +0000
124@@ -0,0 +1,68 @@
125+/*
126+ * Copyright (C) 2012 Canonical, Ltd.
127+ *
128+ * This library is free software; you can redistribute it and/or modify
129+ * it under the terms of the GNU Lesser General Public License
130+ * version 3.0 as published by the Free Software Foundation.
131+ *
132+ * This library is distributed in the hope that it will be useful,
133+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
134+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
135+ * GNU Lesser General Public License version 3.0 for more details.
136+ *
137+ * You should have received a copy of the GNU Lesser General Public
138+ * License along with this library. If not, see
139+ * <http://www.gnu.org/licenses/>.
140+ *
141+ * Authored by Didier Roche <didrocks@ubuntu.com>
142+ *
143+ */
144+
145+using Gee;
146+
147+namespace Unity {
148+
149+ /**
150+ * A singleton class that caches different gsettings settings.
151+ *
152+ */
153+ public class PreferencesManager : GLib.Object
154+ {
155+ private static PreferencesManager singleton = null;
156+
157+ private Settings gp_settings;
158+ private const string REMOTE_CONTENT_KEY = "remote-content-search";
159+
160+ public enum RemoteContent
161+ {
162+ ALL,
163+ NONE,
164+ }
165+
166+ private PreferencesManager ()
167+ {
168+ Object();
169+ }
170+
171+ construct
172+ {
173+ gp_settings = new Settings ("com.canonical.Unity.Lenses");
174+ gp_settings.bind (REMOTE_CONTENT_KEY, this, "remote_content_search", SettingsBindFlags.GET);
175+ }
176+
177+ public RemoteContent remote_content_search { get; set; default = RemoteContent.ALL; }
178+
179+ /**
180+ * Get a ref to the singleton PreferencesManager
181+ */
182+ public static PreferencesManager get_default ()
183+ {
184+ if (PreferencesManager.singleton == null)
185+ PreferencesManager.singleton = new PreferencesManager();
186+
187+ return PreferencesManager.singleton;
188+ }
189+
190+ } /* class PreferencesManager */
191+
192+} /* namespace */
193
194=== modified file 'test/vala/Makefile.am'
195--- test/vala/Makefile.am 2012-08-07 12:31:44 +0000
196+++ test/vala/Makefile.am 2012-09-26 08:48:22 +0000
197@@ -8,6 +8,7 @@
198 -I$(top_srcdir) \
199 -I$(top_builddir)/protocol \
200 -I$(top_builddir)/src \
201+ -DBUILDDIR=\"$(top_builddir)\" \
202 -DTESTDIR=\"$(top_srcdir)/test\" \
203 -DTESTVALADIR=\"$(top_srcdir)/test/vala\" \
204 -DG_SETTINGS_ENABLE_BACKEND \
205@@ -47,6 +48,7 @@
206 test-filters.vala \
207 test-io.vala \
208 test-launcher.vala \
209+ test-preferences.vala \
210 test-previews.vala \
211 test-scope-signals.vala \
212 test-vala.vala \
213
214=== added file 'test/vala/test-preferences.vala'
215--- test/vala/test-preferences.vala 1970-01-01 00:00:00 +0000
216+++ test/vala/test-preferences.vala 2012-09-26 08:48:22 +0000
217@@ -0,0 +1,54 @@
218+/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
219+/*
220+ * Copyright (C) 2012 Canonical Ltd
221+ *
222+ * This program is free software: you can redistribute it and/or modify
223+ * it under the terms of the GNU General Public License version 3 as
224+ * published by the Free Software Foundation.
225+ *
226+ * This program is distributed in the hope that it will be useful,
227+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
228+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
229+ * GNU General Public License for more details.
230+ *
231+ * You should have received a copy of the GNU General Public License
232+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
233+ *
234+ * Authored by Didier Roche <didrocks@ubuntu.com>
235+ *
236+ */
237+using Unity;
238+
239+namespace Unity.Test
240+{
241+ public class PreferencesSuite
242+ {
243+ public PreferencesSuite ()
244+ {
245+ GLib.Test.add_data_func ("/Unit/Preferences/GsettingsLoad",
246+ test_loading_remote_search_preference);
247+ GLib.Test.add_data_func ("/Unit/Preferences/Singleton",
248+ test_singleton);
249+ }
250+
251+ internal static void test_loading_remote_search_preference ()
252+ {
253+ var p = Unity.PreferencesManager.get_default ();
254+ assert (p.remote_content_search == Unity.PreferencesManager.RemoteContent.ALL);
255+
256+ var gp_settings = new Settings ("com.canonical.Unity.Lenses");
257+ gp_settings.set_string ("remote-content-search", "none");
258+ assert (p.remote_content_search == Unity.PreferencesManager.RemoteContent.NONE);
259+
260+ }
261+
262+ internal static void test_singleton ()
263+ {
264+ var p1 = Unity.PreferencesManager.get_default ();
265+ var p2 = Unity.PreferencesManager.get_default ();
266+
267+ assert (p1 == p2);
268+ }
269+
270+ }
271+}
272
273=== modified file 'test/vala/test-vala.vala'
274--- test/vala/test-vala.vala 2012-05-31 18:57:53 +0000
275+++ test/vala/test-vala.vala 2012-09-26 08:48:22 +0000
276@@ -27,10 +27,20 @@
277 AppInfoManagerSuite appinfo_manager;
278 LauncherSuite launcher;
279 FilterSuite filter_suite;
280+ PreferencesSuite preferences_suite;
281 PreviewSuite preview_suite;
282 ScopeSuite scope_suite;
283+ string gsettings_schema_dir = Config.BUILDDIR+"/data";
284
285 Environment.set_variable ("XDG_DATA_HOME", Config.TESTDIR+"/data", true);
286+ Environment.set_variable ("GSETTINGS_SCHEMA_DIR", gsettings_schema_dir, true);
287+ Environment.set_variable ("GSETTINGS_BACKEND", "memory", true);
288+ try {
289+ Process.spawn_command_line_sync ("glib-compile-schemas " + gsettings_schema_dir);
290+ } catch (SpawnError e) {
291+ stderr.printf ("%s\n", e.message);
292+ return 1;
293+ }
294 Test.init (ref args);
295
296 /* IO utility tests */
297@@ -42,6 +52,9 @@
298 /* Lens Filters */
299 filter_suite = new FilterSuite ();
300
301+ /* Lens Preferences */
302+ preferences_suite = new PreferencesSuite ();
303+
304 /* Preview test suite */
305 preview_suite = new PreviewSuite ();
306

Subscribers

People subscribed via source and target branches