Merge lp:~kamstrup/unity-lens-applications/home-lenses into lp:unity-lens-applications

Proposed by Mikkel Kamstrup Erlandsen
Status: Merged
Approved by: Michal Hruby
Approved revision: 261
Merged at revision: 259
Proposed branch: lp:~kamstrup/unity-lens-applications/home-lenses
Merge into: lp:unity-lens-applications
Diff against target: 244 lines (+80/-47)
2 files modified
src/daemon.vala (+78/-45)
src/schemas.vala (+2/-2)
To merge this branch: bzr merge lp:~kamstrup/unity-lens-applications/home-lenses
Reviewer Review Type Date Requested Status
Michal Hruby (community) Approve
Review via email: mp+89670@code.launchpad.net

Description of the change

Implement the new home screen policy. That is when we don't have a global search show the Recent Apps category. When we do have a global search then only show the Applications category. See also https://code.launchpad.net/~kamstrup/unity/home-lenses/+merge/89669

To post a comment you must log in.
Michal Hruby (mhr3) wrote :

Can we try to merge all the queue_search_changed() calls into a single method, so it's not all over the place?

review: Needs Fixing

Pushed fix. Please re-review

261. By Mikkel Kamstrup Erlandsen on 2012-01-23

Collect some of all our queue_search_changed() requests into one mark_dirty() method

Michal Hruby (mhr3) wrote :

Great!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/daemon.vala'
2--- src/daemon.vala 2012-01-18 17:02:52 +0000
3+++ src/daemon.vala 2012-01-23 14:09:24 +0000
4@@ -88,8 +88,8 @@
5 zg_index = new Zeitgeist.Index();
6 monitor = new Zeitgeist.Monitor (new Zeitgeist.TimeRange.from_now (),
7 zg_templates);
8- monitor.events_inserted.connect (on_zeitgeist_changed);
9- monitor.events_deleted.connect (on_zeitgeist_changed);
10+ monitor.events_inserted.connect (mark_dirty);
11+ monitor.events_deleted.connect (mark_dirty);
12 log.install_monitor (monitor);
13
14 this.gp_settings = new Settings ("com.canonical.Unity.ApplicationsLens");
15@@ -164,7 +164,7 @@
16 scope.activate_uri.connect (activate);
17
18 /* Listen for changes in the installed applications */
19- AppInfoManager.get_default().changed.connect (on_appinfo_changed);
20+ AppInfoManager.get_default().changed.connect (mark_dirty);
21
22 /* Now start the RunEntry */
23 runner = new Unity.ApplicationsLens.Runner (this);
24@@ -177,12 +177,11 @@
25 }
26
27 favorite_apps = Unity.LauncherFavorites.get_default ();
28+ favorite_apps.changed.connect(mark_dirty);
29+
30 app_watcher = new AppWatcher ();
31- app_watcher.running_applications_changed.connect (() =>
32- {
33- scope.queue_search_changed (SearchType.GLOBAL);
34- scope.queue_search_changed (SearchType.DEFAULT);
35- });
36+ app_watcher.running_applications_changed.connect (mark_dirty);
37+
38
39 lens = new Unity.Lens ("/com/canonical/unity/lens/applications", "applications");
40 lens.search_hint = _("Search Applications");
41@@ -224,6 +223,10 @@
42 var cat = new Unity.Category (_("Recently Used"),
43 new FileIcon (icon_dir.get_child ("group-recent.svg")));
44 categories.append (cat);
45+
46+ cat = new Unity.Category (_("Recent Apps"),
47+ new FileIcon (icon_dir.get_child ("group-apps.svg")));
48+ categories.append (cat);
49
50 cat = new Unity.Category (_("Installed"),
51 new FileIcon (icon_dir.get_child ("group-installed.svg")));
52@@ -232,7 +235,11 @@
53 cat = new Unity.Category (_("Apps Available for Download"),
54 new FileIcon (icon_dir.get_child ("group-downloads.svg")));
55 categories.append (cat);
56-
57+
58+ cat = new Unity.Category (_("Applications"),
59+ new FileIcon (icon_dir.get_child ("group-apps.svg")));
60+ categories.append (cat);
61+
62 lens.categories = categories;
63 }
64
65@@ -327,9 +334,7 @@
66 {
67 build_app_menu_index ();
68
69- debug ("Updating result models");
70- scope.queue_search_changed (SearchType.DEFAULT);
71- scope.queue_search_changed (SearchType.GLOBAL);
72+ mark_dirty ();
73
74 return false;
75 }
76@@ -346,10 +351,10 @@
77 zg_templates.add ((ev as GLib.Object).ref());
78 }
79
80- private void on_zeitgeist_changed ()
81+ private void mark_dirty ()
82 {
83- scope.invalidate_search (SearchType.DEFAULT);
84- scope.invalidate_search (SearchType.GLOBAL);
85+ scope.queue_search_changed (SearchType.DEFAULT);
86+ scope.queue_search_changed (SearchType.GLOBAL);
87 }
88
89 private string prepare_zg_search_string (Unity.LensSearch? search,
90@@ -492,15 +497,21 @@
91 private async void update_global_search (Unity.LensSearch search,
92 Cancellable cancellable)
93 {
94+ /*
95+ * In global search, with a non-empty search string, we collate all
96+ * hits under one Applications category
97+ */
98+
99+ if (Utils.search_is_invalid (search))
100+ {
101+ yield update_global_without_search (search, cancellable);
102+ return;
103+ }
104+
105 var model = search.results_model;
106
107 model.clear ();
108
109- if (Utils.search_is_invalid (search))
110- {
111- return;
112- }
113-
114 var search_string = prepare_pkg_search_string (search, "all");
115 Set<string> installed_uris = new HashSet<string> ();
116 Set<string> available_uris = new HashSet<string> ();
117@@ -509,28 +520,11 @@
118 Unity.Package.SearchType.PREFIX,
119 Unity.Package.Sort.BY_RELEVANCY);
120 add_pkg_search_result (appresults, installed_uris, available_uris, model,
121- Category.INSTALLED);
122+ Category.APPLICATIONS);
123
124 timer.stop ();
125 debug ("Global search listed %i Installed apps in %fms for query: %s",
126 appresults.num_hits, timer.elapsed ()*1000, search_string);
127-
128- // Dowloadable Apps search disabled from global search
129- // See https://bugs.launchpad.net/unity-lens-applications/+bug/733669
130- /*
131- if (pkgsearcher != null)
132- {
133- timer.start ();
134- var pkgresults = pkgsearcher.search (search_string, 20,
135- Unity.Package.SearchType.PREFIX,
136- Unity.Package.Sort.BY_RELEVANCY);
137- add_pkg_search_result (pkgresults, installed_uris, available_uris,
138- model, Category.AVAILABLE);
139- timer.stop ();
140- debug ("Global search listed %i Available apps in %fms for query: %s",
141- pkgresults.num_hits, timer.elapsed ()*1000, search_string);
142- }
143- */
144
145 /* Allow new searches once we enter an idle again.
146 * We don't do it directly from here as that could mean we start
147@@ -539,6 +533,49 @@
148 search.finished ();
149 }
150
151+ private async void update_global_without_search (Unity.LensSearch search,
152+ Cancellable cancellable)
153+ {
154+ /*
155+ * In global search, with an empty search string, we show just Recent Apps
156+ * Excluding apps with icons in the launcher (be they running or faves)
157+ */
158+ var model = search.results_model;
159+
160+ Timer timer = new Timer ();
161+
162+ var zg_search_string = prepare_zg_search_string (search, "all");
163+
164+ if (local_apps_active () && display_recent_apps) {
165+ try {
166+ var results = yield zg_index.search (zg_search_string,
167+ new Zeitgeist.TimeRange.anytime(),
168+ zg_templates,
169+ 0,
170+ 40,
171+ Zeitgeist.ResultType.MOST_RECENT_SUBJECTS,
172+ cancellable);
173+
174+ model.clear ();
175+ append_events_with_category (results, model, Category.RECENT_APPS, false);
176+
177+ timer.stop ();
178+ debug ("Entry search found %u/%u Recently Used apps in %fms for query '%s'",
179+ results.size (), results.estimated_matches (),
180+ timer.elapsed()*1000, zg_search_string);
181+
182+ } catch (IOError.CANCELLED ioe) {
183+ // no need to bother
184+ return;
185+ } catch (GLib.Error e) {
186+ warning ("Error performing search '%s': %s",
187+ search.search_string, e.message);
188+ }
189+ }
190+
191+ search.finished ();
192+ }
193+
194 private string prepare_pkg_search_string (Unity.LensSearch? search, string type_id="all")
195 {
196 if (Utils.search_is_invalid (search))
197@@ -625,12 +662,6 @@
198
199 return icon;
200 }
201-
202- private void on_appinfo_changed (string id, AppInfo? appinfo)
203- {
204- debug ("Application changed: %s", id);
205- //update_scope_results_model.begin ();
206- }
207
208 private void add_pkg_search_result (Unity.Package.SearchResult results,
209 Set<string> installed_uris,
210@@ -677,6 +708,7 @@
211 switch (category)
212 {
213 case Category.INSTALLED:
214+ case Category.APPLICATIONS:
215 installed_uris.add (uri);
216 display_name = app.get_display_name ();
217 comment = app.get_description ();
218@@ -833,7 +865,8 @@
219 string desktop_id = Utils.get_desktop_id_for_actor (app_uri);
220
221 /* Discard Recently Used apps that are in the launcher */
222- if (category_id == Category.RECENT &&
223+ if ((category_id == Category.RECENT ||
224+ category_id == Category.RECENT_APPS) &&
225 !include_favorites &&
226 (favorite_apps.has_app_id (desktop_id)
227 || app_watcher.has_app_id (desktop_id)))
228
229=== modified file 'src/schemas.vala'
230--- src/schemas.vala 2012-01-05 12:36:04 +0000
231+++ src/schemas.vala 2012-01-23 14:09:24 +0000
232@@ -32,10 +32,10 @@
233 public enum Category
234 {
235 RECENT,
236+ RECENT_APPS,
237 INSTALLED,
238 AVAILABLE,
239- EMPTY_SEARCH,
240- EMPTY_SECTION
241+ APPLICATIONS,
242 }
243
244 public enum RunnerCategory

Subscribers

People subscribed via source and target branches