Merge lp:~jeremywootten/pantheon-files/fix-1467568-do-not-offer-to-bookmark-certain-locations into lp:~elementary-apps/pantheon-files/trunk

Proposed by Jeremy Wootten
Status: Merged
Approved by: Cody Garver
Approved revision: 2153
Merged at revision: 2157
Proposed branch: lp:~jeremywootten/pantheon-files/fix-1467568-do-not-offer-to-bookmark-certain-locations
Merge into: lp:~elementary-apps/pantheon-files/trunk
Diff against target: 104 lines (+33/-11)
3 files modified
src/View/AbstractDirectoryView.vala (+5/-10)
src/View/Sidebar.vala (+20/-1)
src/View/Window.vala (+8/-0)
To merge this branch: bzr merge lp:~jeremywootten/pantheon-files/fix-1467568-do-not-offer-to-bookmark-certain-locations
Reviewer Review Type Date Requested Status
elementary Apps team Pending
Review via email: mp+294724@code.launchpad.net

Commit message

Do not offer to bookmark if already a place in sidebar

Description of the change

The view context menu no longer shows the "Bookmark" option when there is already a bookmark or shortcut to the same uri in the sidebar (including builtins, mounted devices and network locations).

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 'src/View/AbstractDirectoryView.vala'
--- src/View/AbstractDirectoryView.vala 2016-05-13 21:06:02 +0000
+++ src/View/AbstractDirectoryView.vala 2016-05-15 10:13:37 +0000
@@ -1094,7 +1094,7 @@
1094 else1094 else
1095 location = slot.directory.file.get_target_location ();1095 location = slot.directory.file.get_target_location ();
10961096
1097 window.sidebar.add_uri (location.get_uri (), null);1097 window.bookmark_uri (location.get_uri (), null);
1098 }1098 }
10991099
1100 /** Background actions */1100 /** Background actions */
@@ -1906,8 +1906,8 @@
1906 }1906 }
19071907
1908 if (common_actions.get_action_enabled ("bookmark")) {1908 if (common_actions.get_action_enabled ("bookmark")) {
1909 /* Do not offer to bookmark if the home folder is selected */1909 /* Do not offer to bookmark if location is already bookmarked */
1910 if (!(file_location_is_builtin (selected_files.data))) {1910 if (window.can_bookmark_uri (selected_files.data.uri)) {
1911 menu.append_section (null, builder.get_object ("bookmark") as GLib.MenuModel);1911 menu.append_section (null, builder.get_object ("bookmark") as GLib.MenuModel);
1912 }1912 }
1913 }1913 }
@@ -1962,8 +1962,8 @@
1962 }1962 }
19631963
1964 if (common_actions.get_action_enabled ("bookmark")) {1964 if (common_actions.get_action_enabled ("bookmark")) {
1965 /* Do not insert bookmark for home or filesystem root (already have builtins) */1965 /* Do not offer to bookmark if location is already bookmarked */
1966 if (!(file_location_is_builtin (slot.directory.file))) {1966 if (window.can_bookmark_uri (slot.directory.file.uri)) {
1967 menu.append_section (null, builder.get_object ("bookmark") as GLib.MenuModel);1967 menu.append_section (null, builder.get_object ("bookmark") as GLib.MenuModel);
1968 }1968 }
1969 }1969 }
@@ -3444,11 +3444,6 @@
3444 unselect_path (p);3444 unselect_path (p);
3445 }3445 }
3446 }3446 }
3447 /** Check whether gof_file represents the user home directory or the root filesystem **/
3448 protected bool file_location_is_builtin (GOF.File gof_file) {
3449 var path = gof_file.location.get_path ();
3450 return (path == Environment.get_home_dir () || path == Path.DIR_SEPARATOR_S);
3451 }
34523447
3453 public virtual void sync_selection () {}3448 public virtual void sync_selection () {}
3454 public virtual void highlight_path (Gtk.TreePath? path) {}3449 public virtual void highlight_path (Gtk.TreePath? path) {}
34553450
=== modified file 'src/View/Sidebar.vala'
--- src/View/Sidebar.vala 2016-05-13 19:51:34 +0000
+++ src/View/Sidebar.vala 2016-05-15 10:13:37 +0000
@@ -421,6 +421,25 @@
421 return iter;421 return iter;
422 }422 }
423423
424 public bool has_place (string uri) {
425 bool found = false;
426
427 store.@foreach ((model, path, iter) => {
428 string u;
429 model.@get (iter, Column.URI, out u);
430 if (u == null) { /* Category entries etc have null uri, for example */
431 return false;
432 } else if (u == uri) {
433 found = true;
434 return true;
435 } else {
436 return false;
437 }
438 });
439
440 return found;
441 }
442
424 private bool recent_is_supported () {443 private bool recent_is_supported () {
425 string [] supported;444 string [] supported;
426445
@@ -1057,7 +1076,7 @@
1057 }1076 }
10581077
1059 private bool can_accept_file_as_bookmark (GLib.File file) {1078 private bool can_accept_file_as_bookmark (GLib.File file) {
1060 return file.query_exists (null);1079 return file.query_exists (null) && window.can_bookmark_uri (file.get_uri ());
1061 }1080 }
10621081
1063 private bool can_accept_files_as_bookmarks (List<GLib.File> items) {1082 private bool can_accept_files_as_bookmarks (List<GLib.File> items) {
10641083
=== modified file 'src/View/Window.vala'
--- src/View/Window.vala 2016-05-06 17:39:08 +0000
+++ src/View/Window.vala 2016-05-15 10:13:37 +0000
@@ -471,6 +471,14 @@
471 tabs.current = tab;471 tabs.current = tab;
472 }472 }
473473
474 public void bookmark_uri (string uri, string? name = null) {
475 sidebar.add_uri (uri, name);
476 }
477
478 public bool can_bookmark_uri (string uri) {
479 return !sidebar.has_place (uri);
480 }
481
474 public void remove_tab (ViewContainer view_container) {482 public void remove_tab (ViewContainer view_container) {
475 actual_remove_tab (tabs.get_tab_by_widget (view_container as Gtk.Widget));483 actual_remove_tab (tabs.get_tab_by_widget (view_container as Gtk.Widget));
476 }484 }

Subscribers

People subscribed via source and target branches

to all changes: