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

Proposed by Mikkel Kamstrup Erlandsen
Status: Merged
Approved by: Michal Hruby
Approved revision: 209
Merged at revision: 206
Proposed branch: lp:~kamstrup/unity-lens-files/home-lenses
Merge into: lp:unity-lens-files
Diff against target: 200 lines (+90/-14)
2 files modified
src/daemon.vala (+86/-13)
src/schemas.vala (+4/-1)
To merge this branch: bzr merge lp:~kamstrup/unity-lens-files/home-lenses
Reviewer Review Type Date Requested Status
Michal Hruby (community) Approve
Review via email: mp+89671@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 Files and Downloads categories (in that order), and when we do have a global search show only a Files and Folders 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 :

Looks fine.

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

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-unity-lens-files/7/console reported an error when processing this lp:~kamstrup/unity-lens-files/home-lenses branch.
Not merging it.

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

Don't be lazy bot!

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-16 18:09:28 +0000
+++ src/daemon.vala 2012-01-23 12:01:17 +0000
@@ -185,6 +185,10 @@
185 var cat = new Unity.Category (_("Recent"),185 var cat = new Unity.Category (_("Recent"),
186 new FileIcon (icon_dir.get_child ("group-recent.svg")));186 new FileIcon (icon_dir.get_child ("group-recent.svg")));
187 categories.append (cat);187 categories.append (cat);
188
189 cat = new Unity.Category (_("Recent Files"),
190 new FileIcon (icon_dir.get_child ("group-recent.svg")));
191 categories.append (cat);
188192
189 cat = new Unity.Category (_("Downloads"),193 cat = new Unity.Category (_("Downloads"),
190 new FileIcon (icon_dir.get_child ("group-downloads.svg")));194 new FileIcon (icon_dir.get_child ("group-downloads.svg")));
@@ -194,6 +198,10 @@
194 new FileIcon (icon_dir.get_child ("group-folders.svg")));198 new FileIcon (icon_dir.get_child ("group-folders.svg")));
195 categories.append (cat);199 categories.append (cat);
196200
201 cat = new Unity.Category (_("Files & Folders"),
202 new FileIcon (icon_dir.get_child ("group-folders.svg")));
203 categories.append (cat);
204
197 lens.categories = categories;205 lens.categories = categories;
198 }206 }
199207
@@ -314,13 +322,18 @@
314 private async void update_global_search_async (LensSearch search,322 private async void update_global_search_async (LensSearch search,
315 Cancellable cancellable)323 Cancellable cancellable)
316 {324 {
317 var results_model = search.results_model;
318
319 if (search_is_invalid (search))325 if (search_is_invalid (search))
320 {326 {
321 results_model.clear ();327 yield update_global_without_search_async (search, cancellable);
322 return;328 return;
323 }329 }
330
331 /*
332 * For global searches we collate all results under one category heading
333 * called Files & Folders
334 */
335
336 var results_model = search.results_model;
324 337
325 var search_string = prepare_search_string (search);338 var search_string = prepare_search_string (search);
326339
@@ -349,18 +362,26 @@
349 var checked_url = urls.check_url (search.search_string);362 var checked_url = urls.check_url (search.search_string);
350 if (checked_url != null)363 if (checked_url != null)
351 {364 {
352 results_model.append (checked_url, urls.icon, Categories.RECENT,365 results_model.append (checked_url, urls.icon,
366 Categories.FILES_AND_FOLDERS,
353 "text/html", search.search_string,367 "text/html", search.search_string,
354 checked_url, checked_url);368 checked_url, checked_url);
355 }369 }
356 var bookmark_matches = bookmarks.prefix_search (search.search_string);
357 append_bookmarks (bookmark_matches, results_model, Categories.FOLDERS);
358 370
359 int64 min_size, max_size;371 int64 min_size, max_size;
360 get_current_size_limits (out min_size, out max_size);372 get_current_size_limits (out min_size, out max_size);
361373
362 Unity.FilesLens.append_events_sorted (results, results_model,374 Unity.FilesLens.append_events_sorted (results, results_model,
363 min_size, max_size, false);375 min_size, max_size, false,
376 Categories.FILES_AND_FOLDERS);
377
378 /* Add downloads catagory if we don't have a search */
379 if (search_is_invalid (search))
380 {
381 yield update_downloads_async (results_model, cancellable,
382 search.search_string,
383 Categories.FILES_AND_FOLDERS);
384 }
364385
365 } catch (IOError.CANCELLED ioe) {386 } catch (IOError.CANCELLED ioe) {
366 return;387 return;
@@ -589,6 +610,46 @@
589 e.message);610 e.message);
590 }611 }
591 }612 }
613
614 private async void update_global_without_search_async (LensSearch search,
615 Cancellable cancellable)
616 {
617 var results_model = search.results_model;
618
619 /* Grab the pre-compiled template we're going to use */
620 var templates = new PtrArray.sized(1);
621 templates.add (type_templates.lookup ("all"));
622
623 try {
624 /* Get results ranked by recency */
625 var timer = new Timer ();
626 var results = yield log.find_events (new Zeitgeist.TimeRange.anytime(),
627 templates,
628 Zeitgeist.StorageState.ANY,
629 20,
630 ResultType.MOST_RECENT_SUBJECTS,
631 cancellable);
632
633 timer.stop ();
634 debug ("Found %u/%u global results in %fms",
635 results.size (), results.estimated_matches (),
636 timer.elapsed()*1000);
637
638 results_model.clear ();
639
640 Unity.FilesLens.append_events_sorted (results, results_model,
641 int64.MIN, int64.MAX,
642 false, Categories.RECENT_FILES);
643
644 yield update_downloads_async (results_model, cancellable);
645
646 } catch (IOError.CANCELLED ioe) {
647 return;
648 } catch (GLib.Error e) {
649 warning ("Error performing empty search: %s",
650 e.message);
651 }
652 }
592653
593 private void append_bookmarks (GLib.List<Bookmark> bookmarks,654 private void append_bookmarks (GLib.List<Bookmark> bookmarks,
594 Dee.Model results_model,655 Dee.Model results_model,
@@ -603,7 +664,9 @@
603 }664 }
604665
605 private async void update_downloads_async (Dee.Model results_model,666 private async void update_downloads_async (Dee.Model results_model,
606 Cancellable cancellable, string? name_filter = null) throws IOError667 Cancellable cancellable,
668 string? name_filter = null,
669 int category_override = -1) throws IOError
607 {670 {
608 // FIXME: Store the Downloads folder and update on changes671 // FIXME: Store the Downloads folder and update on changes
609 unowned string download_path =672 unowned string download_path =
@@ -612,7 +675,7 @@
612 SList<FileInfo> downloads;675 SList<FileInfo> downloads;
613676
614 try {677 try {
615 if (name_filter != null)678 if (name_filter != null && name_filter != "")
616 downloads = yield Utils.list_dir_filtered (download_dir, name_filter);679 downloads = yield Utils.list_dir_filtered (download_dir, name_filter);
617 else680 else
618 downloads = yield Utils.list_dir (download_dir);681 downloads = yield Utils.list_dir (download_dir);
@@ -654,7 +717,12 @@
654 int64 size = info.get_size ();717 int64 size = info.get_size ();
655 if (size < min_size || size > max_size)718 if (size < min_size || size > max_size)
656 continue;719 continue;
657720
721 uint category_id = Categories.DOWNLOADS;
722
723 if (category_override >= 0)
724 category_id = category_override;
725
658 results_model.append (uri, icon_hint, Categories.DOWNLOADS,726 results_model.append (uri, icon_hint, Categories.DOWNLOADS,
659 mimetype, info.get_display_name (), uri);727 mimetype, info.get_display_name (), uri);
660 }728 }
@@ -691,7 +759,8 @@
691 public void append_events_sorted (Zeitgeist.ResultSet events,759 public void append_events_sorted (Zeitgeist.ResultSet events,
692 Dee.Model results,760 Dee.Model results,
693 int64 min_size, int64 max_size,761 int64 min_size, int64 max_size,
694 bool use_origin)762 bool use_origin,
763 int category_override = -1)
695 {764 {
696 foreach (var ev in events)765 foreach (var ev in events)
697 {766 {
@@ -751,8 +820,12 @@
751 uint category_id;820 uint category_id;
752 string comment = file.get_parse_name ();821 string comment = file.get_parse_name ();
753 822
754 category_id = file.query_file_type (0, null) == FileType.DIRECTORY ?823 if (category_override >= 0)
755 Categories.FOLDERS : Categories.RECENT;824 category_id = category_override;
825 else
826 category_id = file.query_file_type (0, null) == FileType.DIRECTORY ?
827 Categories.FOLDERS : Categories.RECENT;
828
756 results.append (uri, icon, category_id, mimetype,829 results.append (uri, icon, category_id, mimetype,
757 display_name, comment);830 display_name, comment);
758831
759832
=== modified file 'src/schemas.vala'
--- src/schemas.vala 2011-08-04 15:26:32 +0000
+++ src/schemas.vala 2012-01-23 12:01:17 +0000
@@ -39,7 +39,10 @@
39 public enum Categories39 public enum Categories
40 {40 {
41 RECENT,41 RECENT,
42 RECENT_FILES,
42 DOWNLOADS,43 DOWNLOADS,
43 FOLDERS44 FOLDERS,
45 FILES_AND_FOLDERS,
46
44 }47 }
45}48}

Subscribers

People subscribed via source and target branches

to all changes: