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.
Revision history for this message
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
Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

Pushed fix. Please re-review

261. By Mikkel Kamstrup Erlandsen

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

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

Great!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/daemon.vala'
--- src/daemon.vala 2012-01-18 17:02:52 +0000
+++ src/daemon.vala 2012-01-23 14:09:24 +0000
@@ -88,8 +88,8 @@
88 zg_index = new Zeitgeist.Index();88 zg_index = new Zeitgeist.Index();
89 monitor = new Zeitgeist.Monitor (new Zeitgeist.TimeRange.from_now (),89 monitor = new Zeitgeist.Monitor (new Zeitgeist.TimeRange.from_now (),
90 zg_templates);90 zg_templates);
91 monitor.events_inserted.connect (on_zeitgeist_changed);91 monitor.events_inserted.connect (mark_dirty);
92 monitor.events_deleted.connect (on_zeitgeist_changed);92 monitor.events_deleted.connect (mark_dirty);
93 log.install_monitor (monitor);93 log.install_monitor (monitor);
94 94
95 this.gp_settings = new Settings ("com.canonical.Unity.ApplicationsLens");95 this.gp_settings = new Settings ("com.canonical.Unity.ApplicationsLens");
@@ -164,7 +164,7 @@
164 scope.activate_uri.connect (activate);164 scope.activate_uri.connect (activate);
165165
166 /* Listen for changes in the installed applications */166 /* Listen for changes in the installed applications */
167 AppInfoManager.get_default().changed.connect (on_appinfo_changed);167 AppInfoManager.get_default().changed.connect (mark_dirty);
168 168
169 /* Now start the RunEntry */169 /* Now start the RunEntry */
170 runner = new Unity.ApplicationsLens.Runner (this);170 runner = new Unity.ApplicationsLens.Runner (this);
@@ -177,12 +177,11 @@
177 }177 }
178 178
179 favorite_apps = Unity.LauncherFavorites.get_default ();179 favorite_apps = Unity.LauncherFavorites.get_default ();
180 favorite_apps.changed.connect(mark_dirty);
181
180 app_watcher = new AppWatcher ();182 app_watcher = new AppWatcher ();
181 app_watcher.running_applications_changed.connect (() =>183 app_watcher.running_applications_changed.connect (mark_dirty);
182 {184
183 scope.queue_search_changed (SearchType.GLOBAL);
184 scope.queue_search_changed (SearchType.DEFAULT);
185 });
186 185
187 lens = new Unity.Lens ("/com/canonical/unity/lens/applications", "applications");186 lens = new Unity.Lens ("/com/canonical/unity/lens/applications", "applications");
188 lens.search_hint = _("Search Applications");187 lens.search_hint = _("Search Applications");
@@ -224,6 +223,10 @@
224 var cat = new Unity.Category (_("Recently Used"),223 var cat = new Unity.Category (_("Recently Used"),
225 new FileIcon (icon_dir.get_child ("group-recent.svg")));224 new FileIcon (icon_dir.get_child ("group-recent.svg")));
226 categories.append (cat);225 categories.append (cat);
226
227 cat = new Unity.Category (_("Recent Apps"),
228 new FileIcon (icon_dir.get_child ("group-apps.svg")));
229 categories.append (cat);
227230
228 cat = new Unity.Category (_("Installed"),231 cat = new Unity.Category (_("Installed"),
229 new FileIcon (icon_dir.get_child ("group-installed.svg")));232 new FileIcon (icon_dir.get_child ("group-installed.svg")));
@@ -232,7 +235,11 @@
232 cat = new Unity.Category (_("Apps Available for Download"),235 cat = new Unity.Category (_("Apps Available for Download"),
233 new FileIcon (icon_dir.get_child ("group-downloads.svg")));236 new FileIcon (icon_dir.get_child ("group-downloads.svg")));
234 categories.append (cat);237 categories.append (cat);
235238
239 cat = new Unity.Category (_("Applications"),
240 new FileIcon (icon_dir.get_child ("group-apps.svg")));
241 categories.append (cat);
242
236 lens.categories = categories;243 lens.categories = categories;
237 }244 }
238245
@@ -327,9 +334,7 @@
327 {334 {
328 build_app_menu_index ();335 build_app_menu_index ();
329 336
330 debug ("Updating result models");337 mark_dirty ();
331 scope.queue_search_changed (SearchType.DEFAULT);
332 scope.queue_search_changed (SearchType.GLOBAL);
333338
334 return false;339 return false;
335 }340 }
@@ -346,10 +351,10 @@
346 zg_templates.add ((ev as GLib.Object).ref());351 zg_templates.add ((ev as GLib.Object).ref());
347 }352 }
348353
349 private void on_zeitgeist_changed ()354 private void mark_dirty ()
350 {355 {
351 scope.invalidate_search (SearchType.DEFAULT);356 scope.queue_search_changed (SearchType.DEFAULT);
352 scope.invalidate_search (SearchType.GLOBAL);357 scope.queue_search_changed (SearchType.GLOBAL);
353 }358 }
354359
355 private string prepare_zg_search_string (Unity.LensSearch? search,360 private string prepare_zg_search_string (Unity.LensSearch? search,
@@ -492,15 +497,21 @@
492 private async void update_global_search (Unity.LensSearch search,497 private async void update_global_search (Unity.LensSearch search,
493 Cancellable cancellable)498 Cancellable cancellable)
494 {499 {
500 /*
501 * In global search, with a non-empty search string, we collate all
502 * hits under one Applications category
503 */
504
505 if (Utils.search_is_invalid (search))
506 {
507 yield update_global_without_search (search, cancellable);
508 return;
509 }
510
495 var model = search.results_model;511 var model = search.results_model;
496 512
497 model.clear ();513 model.clear ();
498 514
499 if (Utils.search_is_invalid (search))
500 {
501 return;
502 }
503
504 var search_string = prepare_pkg_search_string (search, "all");515 var search_string = prepare_pkg_search_string (search, "all");
505 Set<string> installed_uris = new HashSet<string> ();516 Set<string> installed_uris = new HashSet<string> ();
506 Set<string> available_uris = new HashSet<string> ();517 Set<string> available_uris = new HashSet<string> ();
@@ -509,28 +520,11 @@
509 Unity.Package.SearchType.PREFIX,520 Unity.Package.SearchType.PREFIX,
510 Unity.Package.Sort.BY_RELEVANCY); 521 Unity.Package.Sort.BY_RELEVANCY);
511 add_pkg_search_result (appresults, installed_uris, available_uris, model,522 add_pkg_search_result (appresults, installed_uris, available_uris, model,
512 Category.INSTALLED);523 Category.APPLICATIONS);
513 524
514 timer.stop ();525 timer.stop ();
515 debug ("Global search listed %i Installed apps in %fms for query: %s",526 debug ("Global search listed %i Installed apps in %fms for query: %s",
516 appresults.num_hits, timer.elapsed ()*1000, search_string);527 appresults.num_hits, timer.elapsed ()*1000, search_string);
517
518 // Dowloadable Apps search disabled from global search
519 // See https://bugs.launchpad.net/unity-lens-applications/+bug/733669
520 /*
521 if (pkgsearcher != null)
522 {
523 timer.start ();
524 var pkgresults = pkgsearcher.search (search_string, 20,
525 Unity.Package.SearchType.PREFIX,
526 Unity.Package.Sort.BY_RELEVANCY);
527 add_pkg_search_result (pkgresults, installed_uris, available_uris,
528 model, Category.AVAILABLE);
529 timer.stop ();
530 debug ("Global search listed %i Available apps in %fms for query: %s",
531 pkgresults.num_hits, timer.elapsed ()*1000, search_string);
532 }
533 */
534 528
535 /* Allow new searches once we enter an idle again.529 /* Allow new searches once we enter an idle again.
536 * We don't do it directly from here as that could mean we start530 * We don't do it directly from here as that could mean we start
@@ -539,6 +533,49 @@
539 search.finished ();533 search.finished ();
540 }534 }
541 535
536 private async void update_global_without_search (Unity.LensSearch search,
537 Cancellable cancellable)
538 {
539 /*
540 * In global search, with an empty search string, we show just Recent Apps
541 * Excluding apps with icons in the launcher (be they running or faves)
542 */
543 var model = search.results_model;
544
545 Timer timer = new Timer ();
546
547 var zg_search_string = prepare_zg_search_string (search, "all");
548
549 if (local_apps_active () && display_recent_apps) {
550 try {
551 var results = yield zg_index.search (zg_search_string,
552 new Zeitgeist.TimeRange.anytime(),
553 zg_templates,
554 0,
555 40,
556 Zeitgeist.ResultType.MOST_RECENT_SUBJECTS,
557 cancellable);
558
559 model.clear ();
560 append_events_with_category (results, model, Category.RECENT_APPS, false);
561
562 timer.stop ();
563 debug ("Entry search found %u/%u Recently Used apps in %fms for query '%s'",
564 results.size (), results.estimated_matches (),
565 timer.elapsed()*1000, zg_search_string);
566
567 } catch (IOError.CANCELLED ioe) {
568 // no need to bother
569 return;
570 } catch (GLib.Error e) {
571 warning ("Error performing search '%s': %s",
572 search.search_string, e.message);
573 }
574 }
575
576 search.finished ();
577 }
578
542 private string prepare_pkg_search_string (Unity.LensSearch? search, string type_id="all")579 private string prepare_pkg_search_string (Unity.LensSearch? search, string type_id="all")
543 {580 {
544 if (Utils.search_is_invalid (search))581 if (Utils.search_is_invalid (search))
@@ -625,12 +662,6 @@
625 662
626 return icon;663 return icon;
627 }664 }
628
629 private void on_appinfo_changed (string id, AppInfo? appinfo)
630 {
631 debug ("Application changed: %s", id);
632 //update_scope_results_model.begin ();
633 }
634 665
635 private void add_pkg_search_result (Unity.Package.SearchResult results,666 private void add_pkg_search_result (Unity.Package.SearchResult results,
636 Set<string> installed_uris,667 Set<string> installed_uris,
@@ -677,6 +708,7 @@
677 switch (category)708 switch (category)
678 {709 {
679 case Category.INSTALLED:710 case Category.INSTALLED:
711 case Category.APPLICATIONS:
680 installed_uris.add (uri);712 installed_uris.add (uri);
681 display_name = app.get_display_name ();713 display_name = app.get_display_name ();
682 comment = app.get_description ();714 comment = app.get_description ();
@@ -833,7 +865,8 @@
833 string desktop_id = Utils.get_desktop_id_for_actor (app_uri);865 string desktop_id = Utils.get_desktop_id_for_actor (app_uri);
834 866
835 /* Discard Recently Used apps that are in the launcher */867 /* Discard Recently Used apps that are in the launcher */
836 if (category_id == Category.RECENT &&868 if ((category_id == Category.RECENT ||
869 category_id == Category.RECENT_APPS) &&
837 !include_favorites &&870 !include_favorites &&
838 (favorite_apps.has_app_id (desktop_id)871 (favorite_apps.has_app_id (desktop_id)
839 || app_watcher.has_app_id (desktop_id)))872 || app_watcher.has_app_id (desktop_id)))
840873
=== modified file 'src/schemas.vala'
--- src/schemas.vala 2012-01-05 12:36:04 +0000
+++ src/schemas.vala 2012-01-23 14:09:24 +0000
@@ -32,10 +32,10 @@
32 public enum Category32 public enum Category
33 {33 {
34 RECENT,34 RECENT,
35 RECENT_APPS,
35 INSTALLED,36 INSTALLED,
36 AVAILABLE,37 AVAILABLE,
37 EMPTY_SEARCH,38 APPLICATIONS,
38 EMPTY_SECTION
39 }39 }
40 40
41 public enum RunnerCategory41 public enum RunnerCategory

Subscribers

People subscribed via source and target branches