Merge lp:~jeremywootten/pantheon-files/fix-1467571-do-not-bookmark-home-directory into lp:~elementary-apps/pantheon-files/trunk

Proposed by Jeremy Wootten
Status: Merged
Approved by: Danielle Foré
Approved revision: 2113
Merged at revision: 2113
Proposed branch: lp:~jeremywootten/pantheon-files/fix-1467571-do-not-bookmark-home-directory
Merge into: lp:~elementary-apps/pantheon-files/trunk
Diff against target: 67 lines (+25/-7)
2 files modified
libcore/BookmarkList.vala (+8/-2)
src/View/AbstractDirectoryView.vala (+17/-5)
To merge this branch: bzr merge lp:~jeremywootten/pantheon-files/fix-1467571-do-not-bookmark-home-directory
Reviewer Review Type Date Requested Status
elementary Apps team Pending
Review via email: mp+291914@code.launchpad.net

Commit message

Do not allow creation of personal bookmarks for user home and filesystem root as these have builtins.

Description of the change

This branch does not allow inserting a bookmark representing the user home directory or the root of the filesystem into the personal bookmark list, because there are already builtin bookmarks for these. The context menus also do not show the "bookmark" option for these directories.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'libcore/BookmarkList.vala'
--- libcore/BookmarkList.vala 2016-01-08 19:31:54 +0000
+++ libcore/BookmarkList.vala 2016-04-14 16:22:00 +0000
@@ -206,8 +206,14 @@
206 }206 }
207207
208 private void insert_item_internal (Marlin.Bookmark bm, uint index) {208 private void insert_item_internal (Marlin.Bookmark bm, uint index) {
209 if (this.contains (bm))209 if (this.contains (bm)) {
210 return;210 return;
211 }
212 /* Do not insert bookmark for home or filesystem root (already have builtins) */
213 var path = bm.gof_file.location.get_path ();
214 if ((path == Environment.get_home_dir () || path == Path.DIR_SEPARATOR_S)) {
215 return;
216 }
211217
212 list.insert (bm, (int)index);218 list.insert (bm, (int)index);
213 start_monitoring_bookmark (bm);219 start_monitoring_bookmark (bm);
214220
=== modified file 'src/View/AbstractDirectoryView.vala'
--- src/View/AbstractDirectoryView.vala 2016-04-07 17:53:16 +0000
+++ src/View/AbstractDirectoryView.vala 2016-04-14 16:22:00 +0000
@@ -1885,9 +1885,12 @@
1885 menu.append_section (null, builder.get_object ("rename") as GLib.MenuModel);1885 menu.append_section (null, builder.get_object ("rename") as GLib.MenuModel);
1886 }1886 }
18871887
1888 if (common_actions.get_action_enabled ("bookmark"))1888 if (common_actions.get_action_enabled ("bookmark")) {
1889 menu.append_section (null, builder.get_object ("bookmark") as GLib.MenuModel);1889 /* Do not offer to bookmark if the home folder is selected */
18901890 if (!(file_location_is_builtin (selected_files.data))) {
1891 menu.append_section (null, builder.get_object ("bookmark") as GLib.MenuModel);
1892 }
1893 }
1891 menu.append_section (null, builder.get_object ("properties") as GLib.MenuModel);1894 menu.append_section (null, builder.get_object ("properties") as GLib.MenuModel);
1892 }1895 }
18931896
@@ -1935,8 +1938,12 @@
1935 menu.append_section (null, builder.get_object ("sort-by") as GLib.MenuModel);1938 menu.append_section (null, builder.get_object ("sort-by") as GLib.MenuModel);
1936 }1939 }
19371940
1938 if (common_actions.get_action_enabled ("bookmark"))1941 if (common_actions.get_action_enabled ("bookmark")) {
1939 menu.append_section (null, builder.get_object ("bookmark") as GLib.MenuModel);1942 /* Do not insert bookmark for home or filesystem root (already have builtins) */
1943 if (!(file_location_is_builtin (slot.directory.file))) {
1944 menu.append_section (null, builder.get_object ("bookmark") as GLib.MenuModel);
1945 }
1946 }
19401947
1941 menu.append_section (null, builder.get_object ("hidden") as GLib.MenuModel);1948 menu.append_section (null, builder.get_object ("hidden") as GLib.MenuModel);
19421949
@@ -3379,6 +3386,11 @@
3379 unselect_path (p);3386 unselect_path (p);
3380 }3387 }
3381 }3388 }
3389 /** Check whether gof_file represents the user home directory or the root filesystem **/
3390 protected bool file_location_is_builtin (GOF.File gof_file) {
3391 var path = gof_file.location.get_path ();
3392 return (path == Environment.get_home_dir () || path == Path.DIR_SEPARATOR_S);
3393 }
33823394
3383 public virtual void sync_selection () {}3395 public virtual void sync_selection () {}
3384 public virtual void highlight_path (Gtk.TreePath? path) {}3396 public virtual void highlight_path (Gtk.TreePath? path) {}

Subscribers

People subscribed via source and target branches

to all changes: