Merge lp:~mhr3/unity-lens-music/new-libunity-api into lp:unity-lens-music/0.3

Proposed by Michal Hruby
Status: Merged
Approved by: Mikkel Kamstrup Erlandsen
Approved revision: 63
Merged at revision: 63
Proposed branch: lp:~mhr3/unity-lens-music/new-libunity-api
Merge into: lp:unity-lens-music/0.3
Diff against target: 216 lines (+31/-117)
2 files modified
configure.ac (+1/-1)
src/simple-scope.vala (+30/-116)
To merge this branch: bzr merge lp:~mhr3/unity-lens-music/new-libunity-api
Reviewer Review Type Date Requested Status
Mikkel Kamstrup Erlandsen (community) Approve
Mirco Müller (community) Approve
Review via email: mp+84738@code.launchpad.net

Description of the change

Use libunity-5.0 API.

To post a comment you must log in.
Revision history for this message
Mirco Müller (macslow) wrote :

Looking good to me. +1 from me, but I would suggest someone else, with more experience in dee/lenses takes a look at this too, before marking it as "Approved".

review: Approve
Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) :
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-09-29 15:16:02 +0000
3+++ configure.ac 2011-12-07 11:23:23 +0000
4@@ -64,7 +64,7 @@
5 sqlite3 >= 3.7.7
6 gee-1.0
7 json-glib-1.0
8- unity >= 4.0.2)
9+ unity >= 4.99.0)
10
11 AC_SUBST(LENS_DAEMON_CFLAGS)
12 AC_SUBST(LENS_DAEMON_LIBS)
13
14=== modified file 'src/simple-scope.vala'
15--- src/simple-scope.vala 2011-09-15 14:34:15 +0000
16+++ src/simple-scope.vala 2011-12-07 11:23:23 +0000
17@@ -31,63 +31,37 @@
18
19 protected abstract void perform_search (LensSearch? search, Dee.Model results_model, List<FilterParser> filters, int max_results = -1);
20
21- protected bool is_dirty;
22- protected LensSearch? previous_search;
23-
24 public SimpleScope ()
25 {
26- is_dirty = true;
27- previous_search = null;
28 }
29
30 protected void initialize ()
31 {
32 /* Listen for filter changes */
33- scope.filters_changed.connect(
34- () => {
35- if (scope.active_search != null)
36- {
37- is_dirty = true;
38- scope.notify_property ("active-search");
39- }
40- }
41- );
42-
43+ scope.filters_changed.connect (() => {
44+ scope.queue_search_changed (SearchType.DEFAULT);
45+ });
46+
47+ /* No need to search if only the whitespace changes */
48+ scope.generate_search_key.connect ((lens_search) => {
49+ return lens_search.search_string.strip ();
50+ });
51+
52 /* Listen for changes to the lens search entry */
53- scope.notify["active-search"].connect (
54- (obj, pspec) => {
55- var search = scope.active_search;
56- if (!(is_dirty || search_has_really_changed (previous_search, search)))
57- return;
58- is_dirty = false;
59- update_search_async.begin (search);
60- previous_search = search;
61- }
62- );
63-
64- /* Listen for changes to the global search */
65- scope.notify["active-global-search"].connect (
66- (obj, pspec) => {
67- var search = scope.active_global_search;
68-
69- if (search_is_invalid (search))
70- return;
71-
72- if (!search_has_really_changed (previous_search, search))
73- return;
74-
75- update_global_search_async.begin (search);
76- previous_search = search;
77- }
78- );
79+ scope.search_changed.connect ((search, search_type, cancellable) => {
80+ if (search_type == SearchType.DEFAULT)
81+ update_search_async.begin (search);
82+ else
83+ update_global_search_async.begin (search);
84+ });
85 }
86
87 /* based on the filters(?) get the default results to show when the music lens is
88 * just opened without filters, like when someone hits Super+M
89 */
90- private async void update_without_search_async (LensSearch search, Dee.Model results_model)
91+ private async void update_without_search_async (LensSearch search)
92 {
93- perform_search_async.begin (search, results_model, num_results_without_search);
94+ yield perform_search_async (search, num_results_without_search);
95 }
96
97 /**
98@@ -96,15 +70,14 @@
99 */
100 private async void update_global_search_async (LensSearch search)
101 {
102- var results_model = scope.global_results_model;
103-
104 if (search_is_invalid (search))
105- {
106- results_model.clear ();
107- return;
108- }
109-
110- perform_search_async.begin (search, scope.global_results_model, num_results_global_search);
111+ {
112+ search.results_model.clear ();
113+ search.finished ();
114+ return;
115+ }
116+
117+ yield perform_search_async (search, num_results_global_search);
118 }
119
120 private async void update_search_async (LensSearch search)
121@@ -112,20 +85,17 @@
122 // just pretend like there's no search
123 if (search_is_invalid (search))
124 {
125- update_without_search_async.begin (search, scope.results_model);
126+ yield update_without_search_async (search);
127 return;
128 }
129
130- perform_search_async.begin (search, scope.results_model, num_results_lens_search);
131+ yield perform_search_async (search, num_results_lens_search);
132 }
133
134- private async void perform_search_async (LensSearch search, Dee.Model results_model, int max_results)
135- {
136- /* Prevent concurrent searches and concurrent updates of our models,
137- * by preventing any notify signals from propagating to us.
138- * Important: Remeber to thaw the notifys again! */
139- scope.freeze_notify ();
140-
141+ private async void perform_search_async (LensSearch search, int max_results)
142+ {
143+ var results_model = search.results_model;
144+
145 List<FilterParser> filters = new List<FilterParser> ();
146 Filter filter = scope.get_filter ("genre");
147 if (filter.filtering)
148@@ -138,15 +108,6 @@
149 results_model.clear ();
150 perform_search (search, results_model, filters, max_results);
151
152- /* Allow new searches once we enter an idle again.
153- * We don't do it directly from here as that could mean we start
154- * changing the model even before we had flushed out current changes
155- */
156- Idle.add (() => {
157- scope.thaw_notify ();
158- return false;
159- });
160-
161 search.finished ();
162 }
163
164@@ -161,52 +122,5 @@
165
166 return search.search_string.strip() == "";
167 }
168-
169- private bool search_has_really_changed (LensSearch? old_search,
170- LensSearch? new_search)
171- {
172- if (old_search == null && new_search == null)
173- return false;
174-
175- string s1, s2;
176-
177- if (old_search == null)
178- {
179- s1 = new_search.search_string;
180- if (s1 == null || s1.strip() == "")
181- return false;
182- else
183- return true;
184- }
185- else if (new_search == null)
186- {
187- s2 = old_search.search_string;
188- if (s2 == null || s2.strip() == "")
189- return false;
190- else
191- return true;
192- }
193- else
194- {
195- s1 = new_search.search_string;
196- s2 = old_search.search_string;
197- if (s1 == null)
198- {
199- if (s2 == null || s2.strip() == "")
200- return false;
201- else
202- return true;
203- }
204- else if (s2 == null)
205- {
206- if (s1 == null || s1.strip() == "")
207- return false;
208- else
209- return true;
210- }
211- else
212- return s1.strip () != s2.strip ();
213- }
214- }
215 }
216 }

Subscribers

People subscribed via source and target branches

to all changes: