Merge lp:~angeloc/unity-lens-files/fix-for-837810 into lp:unity-lens-files

Proposed by Angelo Compagnucci
Status: Rejected
Rejected by: Michal Hruby
Proposed branch: lp:~angeloc/unity-lens-files/fix-for-837810
Merge into: lp:unity-lens-files
Diff against target: 41 lines (+12/-1)
1 file modified
src/folder.vala (+12/-1)
To merge this branch: bzr merge lp:~angeloc/unity-lens-files/fix-for-837810
Reviewer Review Type Date Requested Status
Michal Hruby (community) Needs Fixing
Review via email: mp+97924@code.launchpad.net

Description of the change

Added desktop to favourites in files and folders lens.

To post a comment you must log in.
Revision history for this message
Michal Hruby (mhr3) wrote :

Thanks for this! A couple of comments:

8 + string uri_desktop = "file://" + @"$(Environment.get_user_special_dir(UserDirectory.DESKTOP))";

Don't do this pls, use Gio's File.new_for_path and the get_uri () method in the File interface.

17 + var desktop_display_name = Uri.unescape_string (uri_desktop);
18 + desktop_display_name = Filename.display_basename (desktop_display_name);

Eeek, again, we have File.get_parse_name()

I also think that the desktop bookmark (which isn't a bookmark) should be last in the list, so it doesn't stick out.

review: Needs Fixing
Revision history for this message
Angelo Compagnucci (angeloc) wrote :

Done!

modified:
    src/folder.vala
    - Using File.new_for_path instead path string concatenation
    - Moved desktop folder to the end of favourites list

223. By Angelo Compagnucci

modified:
  src/folder.vala
  - Using File.new_for_path instead path string concatenation
  - Moved desktop folder to the end of favourites list

224. By Angelo Compagnucci

modified:
  src/folder.vala
  - Using get_parse_name() to get desktop folder name.

Revision history for this message
Angelo Compagnucci (angeloc) wrote :

Done

modified:
  src/folder.vala
  - Using get_parse_name() to get desktop folder name.

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

10 + File uri_desktop_file = File.new_for_path (@"$(Environment.get_user_special_dir(UserDirectory.DESKTOP))");

Can you please remove the string template, it's useless in this case.

36 + var desktop_display_name = Filename.display_basename (uri_desktop_file.get_parse_name());

This should be just Path.get_basename, not Filename.display_basename (Filename.display_basename doesn't expect utf-8 string).

25 + if (uri == uri_desktop)
26 + continue;

If the user has Desktop in favourites, we shouldn't mess with the order, and this should be just a flag "if (uri == uri_desktop) add_desktop_bookmark = false;".

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

Fixed the remaining issues and proposed in https://code.launchpad.net/~mhr3/unity-lens-files/fix-837810/+merge/100986 Thanks!

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/folder.vala'
--- src/folder.vala 2012-03-05 09:36:13 +0000
+++ src/folder.vala 2012-03-16 18:15:22 +0000
@@ -52,6 +52,10 @@
52 {52 {
53 bookmarks = new List<Bookmark> ();53 bookmarks = new List<Bookmark> ();
54 string contents;54 string contents;
55 string uri_desktop;
56
57 File uri_desktop_file = File.new_for_path (@"$(Environment.get_user_special_dir(UserDirectory.DESKTOP))");
58 uri_desktop = uri_desktop_file.get_uri ();
55 59
56 try {60 try {
57 FileUtils.get_contents (bookmarks_file, out contents);61 FileUtils.get_contents (bookmarks_file, out contents);
@@ -64,11 +68,13 @@
64 string[] favorites = contents.split ("\n");68 string[] favorites = contents.split ("\n");
65 string mimetype = "inode/directory";69 string mimetype = "inode/directory";
66 70
67
68 foreach (var uri in favorites)71 foreach (var uri in favorites)
69 {72 {
70 if (uri == "")73 if (uri == "")
71 continue;74 continue;
75
76 if (uri == uri_desktop)
77 continue;
72 78
73 string[] parts = uri.split (" ", 2);79 string[] parts = uri.split (" ", 2);
74 string display_name;80 string display_name;
@@ -93,6 +99,11 @@
93 var bookmark = new Bookmark (uri, mimetype, display_name);99 var bookmark = new Bookmark (uri, mimetype, display_name);
94 bookmarks.append (bookmark);100 bookmarks.append (bookmark);
95 }101 }
102
103 /* Add desktop statically */
104 var desktop_display_name = Filename.display_basename (uri_desktop_file.get_parse_name());
105 var desktop_bookmark = new Bookmark (uri_desktop, mimetype, desktop_display_name);
106 bookmarks.append (desktop_bookmark);
96 }107 }
97108
98 /* makes sure the uris exist on the filesystem (checks only native uris) */109 /* makes sure the uris exist on the filesystem (checks only native uris) */

Subscribers

People subscribed via source and target branches