Skip to content

Commit 872a71c

Browse files
authored
Merge branch 'main' into danirabbit/abstractdirectoryview-newsubglibmenu
2 parents b5ee8a8 + 6c5e657 commit 872a71c

File tree

7 files changed

+71
-73
lines changed

7 files changed

+71
-73
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 ();

libcore/Preferences.vala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ namespace Files {
2626
};
2727

2828
public bool show_hidden_files {get; set; default = false;}
29-
public bool show_remote_thumbnails {set; get; default = true;}
30-
public bool show_local_thumbnails {set; get; default = true;}
3129
public bool show_file_preview {set; get; default = true;}
3230
public bool confirm_trash {set; get; default = true;}
3331
public bool remember_history { get; set; default = true; }

src/Application.vala

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,6 @@ public class Files.Application : Gtk.Application {
265265
var prefs = Files.Preferences.get_default ();
266266
Files.app_settings.bind ("show-hiddenfiles", prefs, "show-hidden-files", GLib.SettingsBindFlags.DEFAULT);
267267

268-
Files.app_settings.bind ("show-remote-thumbnails",
269-
prefs, "show-remote-thumbnails", GLib.SettingsBindFlags.DEFAULT);
270-
Files.app_settings.bind ("show-local-thumbnails",
271-
prefs, "show-local-thumbnails", GLib.SettingsBindFlags.DEFAULT);
272-
273268
Files.app_settings.bind ("show-file-preview",
274269
prefs, "show-file-preview", GLib.SettingsBindFlags.DEFAULT);
275270

src/View/AbstractDirectoryView.vala

Lines changed: 63 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -453,12 +453,12 @@ namespace Files {
453453

454454
var prefs = (Files.Preferences.get_default ());
455455
prefs.notify["show-hidden-files"].connect (on_show_hidden_files_changed);
456-
prefs.notify["show-remote-thumbnails"].connect (on_show_thumbnails_changed);
457-
prefs.notify["show-local-thumbnails"].connect (on_show_thumbnails_changed);
458456
prefs.notify["date-format"].connect (on_dateformat_changed);
459457

460458
app_settings.bind ("singleclick-select", this, "singleclick_select", SettingsBindFlags.DEFAULT);
461459

460+
app_settings.changed["show-remote-thumbnails"].connect (on_show_thumbnails_changed);
461+
app_settings.changed["show-local-thumbnails"].connect (on_show_thumbnails_changed);
462462
app_settings.changed["sort-directories-first"].connect (on_sort_directories_first_changed);
463463

464464
model.set_should_sort_directories_first (app_settings.get_boolean ("sort-directories-first"));
@@ -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 */
@@ -1462,11 +1462,10 @@ namespace Files {
14621462
}
14631463

14641464
private void set_should_thumbnail () {
1465-
var prefs = Files.Preferences.get_default ();
14661465
if (slot.directory.is_network) {
1467-
should_thumbnail = slot.directory.can_open_files && prefs.show_remote_thumbnails;
1466+
should_thumbnail = slot.directory.can_open_files && app_settings.get_boolean ("show-remote-thumbnails");
14681467
} else {
1469-
should_thumbnail = prefs.show_local_thumbnails;
1468+
should_thumbnail = app_settings.get_boolean ("show-local-thumbnails");
14701469
}
14711470
}
14721471

@@ -2056,6 +2055,9 @@ namespace Files {
20562055
));
20572056
}
20582057

2058+
var bookmark_action = (SimpleAction) common_actions.lookup_action ("bookmark");
2059+
var bookmark_list = BookmarkList.get_instance ();
2060+
20592061
if (get_selected_files () != null) { // Add selection actions
20602062
var cut_menuitem = new Gtk.MenuItem ();
20612063
cut_menuitem.add (new Granite.AccelLabel (
@@ -2211,10 +2213,12 @@ namespace Files {
22112213
menu.add (rename_menuitem);
22122214
}
22132215

2214-
/* Do not offer to bookmark if location is already bookmarked */
2215-
if (common_actions.get_action_enabled ("bookmark") &&
2216-
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+
);
22172219

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

@@ -2271,9 +2275,12 @@ namespace Files {
22712275
menu.add (new SortSubMenuItem ());
22722276
}
22732277

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

22782285
menu.add (bookmark_menuitem);
22792286
}
@@ -2313,40 +2320,51 @@ namespace Files {
23132320

23142321
private class SortSubMenuItem : Gtk.MenuItem {
23152322
construct {
2316-
var name_radioitem = new Gtk.CheckMenuItem.with_label (_("Name"));
2317-
name_radioitem.action_name = "background.sort-by";
2318-
name_radioitem.action_target = "name";
2319-
name_radioitem.draw_as_radio = true;
2320-
2321-
var size_radioitem = new Gtk.CheckMenuItem.with_label (_("Size"));
2322-
size_radioitem.action_name = "background.sort-by";
2323-
size_radioitem.action_target = "size";
2324-
size_radioitem.draw_as_radio = true;
2325-
2326-
var type_radioitem = new Gtk.CheckMenuItem.with_label (_("Type"));
2327-
type_radioitem.action_name = "background.sort-by";
2328-
type_radioitem.action_target = "type";
2329-
type_radioitem.draw_as_radio = true;
2330-
2331-
var date_radioitem = new Gtk.CheckMenuItem.with_label (_("Date"));
2332-
date_radioitem.action_name = "background.sort-by";
2333-
date_radioitem.action_target = "modified";
2334-
date_radioitem.draw_as_radio = true;
2335-
2336-
var reversed_checkitem = new Gtk.CheckMenuItem.with_label (_("Reversed Order"));
2337-
reversed_checkitem.action_name = "background.reverse";
2338-
2339-
var folders_first_checkitem = new Gtk.CheckMenuItem.with_label (_("Folders Before Files"));
2340-
folders_first_checkitem.action_name = "win.sort-directories-first";
2341-
2342-
submenu = new Gtk.Menu ();
2343-
submenu.add (name_radioitem);
2344-
submenu.add (size_radioitem);
2345-
submenu.add (type_radioitem);
2346-
submenu.add (date_radioitem);
2347-
submenu.add (new Gtk.SeparatorMenuItem ());
2348-
submenu.add (reversed_checkitem);
2349-
submenu.add (folders_first_checkitem);
2323+
var name_item = new MenuItem (
2324+
_("Name"),
2325+
Action.print_detailed_name ("background.sort-by", new Variant.string ("name"))
2326+
);
2327+
2328+
var size_item = new MenuItem (
2329+
_("Size"),
2330+
Action.print_detailed_name ("background.sort-by", new Variant.string ("size"))
2331+
);
2332+
2333+
var type_item = new MenuItem (
2334+
_("Type"),
2335+
Action.print_detailed_name ("background.sort-by", new Variant.string ("type"))
2336+
);
2337+
2338+
var date_item = new MenuItem (
2339+
_("Date"),
2340+
Action.print_detailed_name ("background.sort-by", new Variant.string ("modified"))
2341+
);
2342+
2343+
var reversed_item = new MenuItem (
2344+
_("Reversed Order"),
2345+
"background.reverse"
2346+
);
2347+
2348+
var folders_first_item = new MenuItem (
2349+
_("Folders Before Files"),
2350+
"win.sort-directories-first"
2351+
);
2352+
2353+
var radio_section = new Menu ();
2354+
radio_section.append_item (name_item);
2355+
radio_section.append_item (size_item);
2356+
radio_section.append_item (type_item);
2357+
radio_section.append_item (date_item);
2358+
2359+
var check_section = new Menu ();
2360+
check_section.append_item (reversed_item);
2361+
check_section.append_item (folders_first_item);
2362+
2363+
var menu_model = new Menu ();
2364+
menu_model.append_section (null, radio_section);
2365+
menu_model.append_section (null, check_section);
2366+
2367+
submenu = new Gtk.Menu.from_model (menu_model);
23502368

23512369
label = _("Sort by");
23522370
}

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)