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
1=== modified file 'libcore/BookmarkList.vala'
2--- libcore/BookmarkList.vala 2016-01-08 19:31:54 +0000
3+++ libcore/BookmarkList.vala 2016-04-14 16:22:00 +0000
4@@ -206,8 +206,14 @@
5 }
6
7 private void insert_item_internal (Marlin.Bookmark bm, uint index) {
8- if (this.contains (bm))
9- return;
10+ if (this.contains (bm)) {
11+ return;
12+ }
13+ /* Do not insert bookmark for home or filesystem root (already have builtins) */
14+ var path = bm.gof_file.location.get_path ();
15+ if ((path == Environment.get_home_dir () || path == Path.DIR_SEPARATOR_S)) {
16+ return;
17+ }
18
19 list.insert (bm, (int)index);
20 start_monitoring_bookmark (bm);
21
22=== modified file 'src/View/AbstractDirectoryView.vala'
23--- src/View/AbstractDirectoryView.vala 2016-04-07 17:53:16 +0000
24+++ src/View/AbstractDirectoryView.vala 2016-04-14 16:22:00 +0000
25@@ -1885,9 +1885,12 @@
26 menu.append_section (null, builder.get_object ("rename") as GLib.MenuModel);
27 }
28
29- if (common_actions.get_action_enabled ("bookmark"))
30- menu.append_section (null, builder.get_object ("bookmark") as GLib.MenuModel);
31-
32+ if (common_actions.get_action_enabled ("bookmark")) {
33+ /* Do not offer to bookmark if the home folder is selected */
34+ if (!(file_location_is_builtin (selected_files.data))) {
35+ menu.append_section (null, builder.get_object ("bookmark") as GLib.MenuModel);
36+ }
37+ }
38 menu.append_section (null, builder.get_object ("properties") as GLib.MenuModel);
39 }
40
41@@ -1935,8 +1938,12 @@
42 menu.append_section (null, builder.get_object ("sort-by") as GLib.MenuModel);
43 }
44
45- if (common_actions.get_action_enabled ("bookmark"))
46- menu.append_section (null, builder.get_object ("bookmark") as GLib.MenuModel);
47+ if (common_actions.get_action_enabled ("bookmark")) {
48+ /* Do not insert bookmark for home or filesystem root (already have builtins) */
49+ if (!(file_location_is_builtin (slot.directory.file))) {
50+ menu.append_section (null, builder.get_object ("bookmark") as GLib.MenuModel);
51+ }
52+ }
53
54 menu.append_section (null, builder.get_object ("hidden") as GLib.MenuModel);
55
56@@ -3379,6 +3386,11 @@
57 unselect_path (p);
58 }
59 }
60+ /** Check whether gof_file represents the user home directory or the root filesystem **/
61+ protected bool file_location_is_builtin (GOF.File gof_file) {
62+ var path = gof_file.location.get_path ();
63+ return (path == Environment.get_home_dir () || path == Path.DIR_SEPARATOR_S);
64+ }
65
66 public virtual void sync_selection () {}
67 public virtual void highlight_path (Gtk.TreePath? path) {}

Subscribers

People subscribed via source and target branches

to all changes: