Skip to content

Commit 349f395

Browse files
authored
Merge branch 'main' into danirabbit/preferences-rmthumbnails
2 parents ce5ff30 + d3064c4 commit 349f395

File tree

5 files changed

+22
-27
lines changed

5 files changed

+22
-27
lines changed

libcore/Interfaces/SidebarInterface.vala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ public interface Files.SidebarInterface : Gtk.Widget {
4040
public signal bool request_focus ();
4141
public signal void sync_needed ();
4242
public signal void path_change_request (string uri, Files.OpenFlag flag);
43-
public abstract void add_favorite_uri (string uri, string custom_name = "");
44-
public abstract bool has_favorite_uri (string uri);
4543
public abstract void sync_uri (string uri);
4644
public abstract void reload ();
4745
public abstract void on_free_space_change ();

src/View/AbstractDirectoryView.vala

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,7 @@ namespace Files {
12041204
location = slot.directory.file.get_target_location ();
12051205
}
12061206

1207-
window.bookmark_uri (location.get_uri ());
1207+
BookmarkList.get_instance ().insert_uri_at_end (location.get_uri (), "");
12081208
}
12091209

12101210
/** Background actions */
@@ -2055,6 +2055,9 @@ namespace Files {
20552055
));
20562056
}
20572057

2058+
var bookmark_action = (SimpleAction) common_actions.lookup_action ("bookmark");
2059+
var bookmark_list = BookmarkList.get_instance ();
2060+
20582061
if (get_selected_files () != null) { // Add selection actions
20592062
var cut_menuitem = new Gtk.MenuItem ();
20602063
cut_menuitem.add (new Granite.AccelLabel (
@@ -2210,10 +2213,12 @@ namespace Files {
22102213
menu.add (rename_menuitem);
22112214
}
22122215

2213-
/* Do not offer to bookmark if location is already bookmarked */
2214-
if (common_actions.get_action_enabled ("bookmark") &&
2215-
window.can_bookmark_uri (selected_files.data.uri)) {
2216+
var already_bookmarked = bookmark_list.contains (
2217+
new Bookmark.from_uri (selected_files.data.uri, "")
2218+
);
22162219

2220+
/* Do not offer to bookmark if location is already bookmarked */
2221+
if (common_actions.get_action_enabled ("bookmark") && !already_bookmarked) {
22172222
menu.add (bookmark_menuitem);
22182223
}
22192224

@@ -2270,9 +2275,12 @@ namespace Files {
22702275
menu.add (new SortSubMenuItem ());
22712276
}
22722277

2278+
var already_bookmarked = bookmark_list.contains (
2279+
new Bookmark.from_uri (slot.directory.file.uri, "")
2280+
);
2281+
22732282
/* Do not offer to bookmark if location is already bookmarked */
2274-
if (common_actions.get_action_enabled ("bookmark") &&
2275-
window.can_bookmark_uri (slot.directory.file.uri)) {
2283+
if (common_actions.get_action_enabled ("bookmark") && !already_bookmarked) {
22762284

22772285
menu.add (bookmark_menuitem);
22782286
}

src/View/Sidebar/BookmarkListBox.vala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ public class Sidebar.BookmarkListBox : Gtk.Box, Sidebar.SidebarListInterface {
4545
refresh ();
4646
});
4747

48+
bookmark_list.contents_changed.connect (() => {
49+
refresh ();
50+
});
51+
4852
list_box.row_activated.connect ((row) => {
4953
if (row is BookmarkRow) {
5054
((BookmarkRow) row).activated ();
@@ -58,7 +62,7 @@ public class Sidebar.BookmarkListBox : Gtk.Box, Sidebar.SidebarListInterface {
5862
});
5963
}
6064

61-
public BookmarkRow? add_bookmark (string label,
65+
private BookmarkRow? add_bookmark (string label,
6266
string uri,
6367
Icon gicon,
6468
bool pinned = false,

src/View/Sidebar/SidebarWindow.vala

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -230,14 +230,6 @@ public class Sidebar.SidebarWindow : Gtk.Box, Files.SidebarInterface {
230230
});
231231
}
232232

233-
public void add_favorite_uri (string uri, string custom_name = "") {
234-
bookmark_listbox.add_favorite (uri, custom_name);
235-
}
236-
237-
public bool has_favorite_uri (string uri) {
238-
return bookmark_listbox.has_uri (uri);
239-
}
240-
241233
public void on_free_space_change () {
242234
/* We cannot be sure which devices will experience a freespace change so refresh all */
243235
device_listbox.refresh_info ();

src/View/Window.vala

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -739,14 +739,6 @@ public class Files.View.Window : Hdy.ApplicationWindow {
739739
}
740740
}
741741

742-
public void bookmark_uri (string uri, string custom_name = "") {
743-
sidebar.add_favorite_uri (uri, custom_name);
744-
}
745-
746-
public bool can_bookmark_uri (string uri) {
747-
return !sidebar.has_favorite_uri (uri);
748-
}
749-
750742
private void move_content_to_new_window (ViewContainer view_container) {
751743
add_window (view_container.location, view_container.view_mode);
752744
remove_content (view_container);
@@ -799,12 +791,13 @@ public class Files.View.Window : Hdy.ApplicationWindow {
799791
}
800792

801793
private void action_bookmark (GLib.SimpleAction action, GLib.Variant? param) {
794+
var bookmark_list = BookmarkList.get_instance ();
802795
/* Note: Duplicate bookmarks will not be created by BookmarkList */
803796
unowned var selected_files = current_container.view.get_selected_files ();
804797
if (selected_files == null) {
805-
sidebar.add_favorite_uri (current_container.location.get_uri ());
798+
bookmark_list.insert_uri_at_end (current_container.location.get_uri (), "");
806799
} else if (selected_files.first ().next == null) {
807-
sidebar.add_favorite_uri (selected_files.first ().data.uri);
800+
bookmark_list.insert_uri_at_end (selected_files.first ().data.uri, "");
808801
} // Ignore if more than one item selected
809802
}
810803

0 commit comments

Comments
 (0)