Merge lp:~stolowski/libunity/home-lens-category-name into lp:libunity

Proposed by Paweł Stołowski
Status: Merged
Approved by: Michal Hruby
Approved revision: 173
Merged at revision: 170
Proposed branch: lp:~stolowski/libunity/home-lens-category-name
Merge into: lp:libunity
Diff against target: 192 lines (+80/-39)
4 files modified
configure.ac (+1/-1)
src/unity-lens-private.vala (+3/-0)
src/unity-lens.vala (+3/-0)
test/vala/test-lens.vala (+73/-38)
To merge this branch: bzr merge lp:~stolowski/libunity/home-lens-category-name
Reviewer Review Type Date Requested Status
Michal Hruby (community) Approve
Review via email: mp+122008@code.launchpad.net

Commit message

Implemented home-lens-default-name lens property.

Description of the change

Implemented home-lens-default-name lens property.

To post a comment you must log in.
171. By Paweł Stołowski

Don't send empty/null home_lens_default_name.

172. By Paweł Stołowski

Bumped micro version for new home_lens_default_name property.

173. By Paweł Stołowski

provides_private_content and home_lens_default_name test cases: property handle Changed() signal to avoid race on multiple Chaged() notifications.

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

Looking good now. +1

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 2012-08-28 14:39:06 +0000
3+++ configure.ac 2012-08-30 10:06:54 +0000
4@@ -1,5 +1,5 @@
5 # When releasing also remember to update the soname as instructed below
6-AC_INIT(libunity, 5.97.1)
7+AC_INIT(libunity, 5.97.2)
8
9 AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
10 AM_CONFIG_HEADER(config.h)
11
12=== modified file 'src/unity-lens-private.vala'
13--- src/unity-lens-private.vala 2012-08-29 10:32:57 +0000
14+++ src/unity-lens-private.vala 2012-08-30 10:06:54 +0000
15@@ -70,6 +70,7 @@
16 _owner.notify["visible"].connect (queue_info_changed);
17 _owner.notify["search-hint"].connect (queue_info_changed);
18 _owner.notify["sources-display-name"].connect (sources_display_name_changed);
19+ _owner.notify["home-lens-default-name"].connect (queue_info_changed);
20
21 _sources = new CheckOptionFilter (Lens.SOURCES_FILTER_ID,
22 _owner.sources_display_name,
23@@ -228,6 +229,8 @@
24 }
25 }
26 info.hints.insert ("provides-private-content", provides_private_content);
27+ if (_owner.home_lens_default_name != null && _owner.home_lens_default_name != "")
28+ info.hints.insert ("home-lens-default-name", _owner.home_lens_default_name);
29
30 changed (info);
31
32
33=== modified file 'src/unity-lens.vala'
34--- src/unity-lens.vala 2012-01-09 11:19:46 +0000
35+++ src/unity-lens.vala 2012-08-30 10:06:54 +0000
36@@ -29,6 +29,9 @@
37 public bool searching { get; private set; default = false; }
38 public bool exported { get; private set; default = false; }
39 public bool search_in_global { get; set; default = true; }
40+
41+ // default category name to be used by Home Lens when no search query is provided
42+ public string home_lens_default_name { get; set; default = ""; }
43 public string id { get; construct; }
44 public string dbus_path { get; construct; }
45 public string search_hint { get; set; }
46
47=== modified file 'test/vala/test-lens.vala'
48--- test/vala/test-lens.vala 2012-08-28 14:20:34 +0000
49+++ test/vala/test-lens.vala 2012-08-30 10:06:54 +0000
50@@ -59,6 +59,7 @@
51 Test.add_data_func ("/Unit/Lens/Preview/Signal", test_lens_preview_signal);
52 Test.add_data_func ("/Unit/Lens/Preview/ClosedSignal", test_lens_preview_closed_signal);
53 Test.add_data_func ("/Unit/Lens/PrivateContentFlag", test_lens_private_content_flag);
54+ Test.add_data_func ("/Unit/Lens/HomeLensDefaultName", test_lens_home_lens_default_name);
55
56 Test.run ();
57
58@@ -194,39 +195,6 @@
59 });
60 }
61
62- private static Unity.Protocol.LensInfo? get_lens_info ()
63- {
64- var ml = new MainLoop ();
65- Unity.Protocol.LensInfo? info = null;
66-
67- try
68- {
69- var bus = Bus.get_sync (BusType.SESSION);
70- var sig_id = bus.signal_subscribe (null,
71- "com.canonical.Unity.Lens",
72- "Changed",
73- "/com/canonical/Unity/Lens/Test",
74- null,
75- 0,
76- (conn, sender, obj_path, ifc_name, sig_name, parameters) =>
77- {
78- info = (Unity.Protocol.LensInfo) parameters.get_child_value (0);
79- ml.quit ();
80- });
81-
82- call_lens_method ("InfoRequest", null, null);
83-
84- run_with_timeout (ml, 5000);
85-
86- bus.signal_unsubscribe (sig_id);
87- }
88- catch (Error e) {
89- warning ("%s", e.message);
90- }
91-
92- return info;
93- }
94-
95 private static void call_lens_search (string search_string,
96 Func<Variant?>? cb = null)
97 {
98@@ -1102,22 +1070,89 @@
99
100 public static void test_lens_private_content_flag ()
101 {
102- SignalWrapper[] signals = null;
103 assert (local_scope != null);
104 assert (exported_lens != null);
105+ var ml = new MainLoop ();
106+
107+ Unity.Protocol.LensInfo? info = null;
108+
109+ var bus = Bus.get_sync (BusType.SESSION);
110+ var sig_id = bus.signal_subscribe (null,
111+ "com.canonical.Unity.Lens",
112+ "Changed",
113+ "/com/canonical/Unity/Lens/Test",
114+ null,
115+ 0,
116+ (conn, sender, obj_path, ifc_name, sig_name, parameters) =>
117+ {
118+ info = (Unity.Protocol.LensInfo) parameters.get_child_value (0);
119+ ml.quit ();
120+ });
121
122 // check default value of provides_private_content
123- Unity.Protocol.LensInfo? info = get_lens_info ();
124+ info = null;
125+ call_lens_method ("InfoRequest", null, null);
126+
127+ run_with_timeout (ml, 5000);
128+
129 assert (info != null);
130 assert (info.hints.contains ("provides-private-content"));
131 assert (info.hints["provides-private-content"].get_boolean () == false);
132
133+ info = null;
134 local_scope.provides_private_content = true;
135
136- info = get_lens_info ();
137+ run_with_timeout (ml, 5000);
138+
139 assert (info != null);
140 assert (info.hints.contains ("provides-private-content"));
141 assert (info.hints["provides-private-content"].get_boolean () == true);
142- }
143-
144+
145+ bus.signal_unsubscribe (sig_id);
146+ }
147+
148+ public static void test_lens_home_lens_default_name ()
149+ {
150+ assert (exported_lens != null);
151+ var ml = new MainLoop ();
152+
153+ // check default value of home_lens_default_name
154+ Unity.Protocol.LensInfo? info = null;
155+
156+ var bus = Bus.get_sync (BusType.SESSION);
157+ var sig_id = bus.signal_subscribe (null,
158+ "com.canonical.Unity.Lens",
159+ "Changed",
160+ "/com/canonical/Unity/Lens/Test",
161+ null,
162+ 0,
163+ (conn, sender, obj_path, ifc_name, sig_name, parameters) =>
164+ {
165+ info = (Unity.Protocol.LensInfo) parameters.get_child_value (0);
166+ ml.quit ();
167+ });
168+
169+ call_lens_method ("InfoRequest", null, null);
170+
171+ run_with_timeout (ml, 5000);
172+ assert (info != null);
173+ assert (info.hints.contains ("home-lens-default-name") == false);
174+
175+ info = null;
176+ exported_lens.home_lens_default_name = null;
177+ run_with_timeout (ml, 5000);
178+
179+ assert (info != null);
180+ assert (info.hints.contains ("home-lens-default-name") == false);
181+
182+ info = null;
183+ exported_lens.home_lens_default_name = "Foo Bar";
184+ run_with_timeout (ml, 5000);
185+
186+ assert (info != null);
187+ assert (info.hints.contains ("home-lens-default-name"));
188+ assert (info.hints["home-lens-default-name"].get_string () == "Foo Bar");
189+
190+ bus.signal_unsubscribe (sig_id);
191+ }
192 }

Subscribers

People subscribed via source and target branches