Skip to content

Commit eb25f63

Browse files
authored
Merge branch 'main' into danirabbit/file-settings-from-gsettings
2 parents dc4197f + 62b1a52 commit eb25f63

File tree

5 files changed

+21
-68
lines changed

5 files changed

+21
-68
lines changed

libcore/Preferences.vala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ namespace Files {
2929
public bool show_remote_thumbnails {set; get; default = true;}
3030
public bool show_local_thumbnails {set; get; default = true;}
3131
public bool show_file_preview {set; get; default = true;}
32-
public bool singleclick_select {set; get; default = false;}
3332
public bool confirm_trash {set; get; default = true;}
34-
public bool force_icon_size {set; get; default = true;}
3533
public bool sort_directories_first { get; set; default = true; }
3634
public bool remember_history { get; set; default = true; }
3735

src/Application.vala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,6 @@ public class Files.Application : Gtk.Application {
263263
private void init_schemas () {
264264
/* Bind settings with GOFPreferences */
265265
var prefs = Files.Preferences.get_default ();
266-
if (app_settings.settings_schema.has_key ("singleclick-select")) {
267-
app_settings.bind ("singleclick-select", prefs, "singleclick-select", GLib.SettingsBindFlags.DEFAULT);
268-
}
269-
270266
Files.app_settings.bind ("show-hiddenfiles", prefs, "show-hidden-files", GLib.SettingsBindFlags.DEFAULT);
271267

272268
Files.app_settings.bind ("show-remote-thumbnails",

src/View/AbstractDirectoryView.vala

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ namespace Files {
7777
{"create-from", on_background_action_create_from, "s"},
7878
{"sort-by", on_background_action_sort_by_changed, "s", "'name'"},
7979
{"reverse", on_background_action_reverse_changed, null, "false"},
80-
{"folders-first", on_background_action_folders_first_changed, null, "true"},
81-
{"show-hidden", null, null, "false", change_state_show_hidden}
80+
{"folders-first", on_background_action_folders_first_changed, null, "true"}
8281
};
8382

8483
const GLib.ActionEntry [] COMMON_ENTRIES = {
@@ -287,6 +286,8 @@ namespace Files {
287286
public signal void path_change_request (GLib.File location, Files.OpenFlag flag, bool new_root);
288287
public signal void selection_changed (GLib.List<Files.File> gof_file);
289288

289+
private static Settings app_settings;
290+
290291
//TODO Rewrite in Object (), construct {} style
291292
protected AbstractDirectoryView (View.Slot _slot) {
292293
slot = _slot;
@@ -412,6 +413,10 @@ namespace Files {
412413
connect_directory_handlers (slot.directory);
413414
}
414415

416+
static construct {
417+
app_settings = new Settings ("io.elementary.files.preferences");
418+
}
419+
415420
~AbstractDirectoryView () {
416421
debug ("ADV destruct"); // Cannot reference slot here as it is already invalid
417422
}
@@ -453,9 +458,8 @@ namespace Files {
453458
prefs.notify["show-local-thumbnails"].connect (on_show_thumbnails_changed);
454459
prefs.notify["sort-directories-first"].connect (on_sort_directories_first_changed);
455460
prefs.notify["date-format"].connect (on_dateformat_changed);
456-
prefs.bind_property (
457-
"singleclick-select", this, "singleclick_select", BindingFlags.DEFAULT | BindingFlags.SYNC_CREATE
458-
);
461+
462+
app_settings.bind ("singleclick-select", this, "singleclick_select", SettingsBindFlags.DEFAULT);
459463

460464
model.set_should_sort_directories_first (Files.Preferences.get_default ().sort_directories_first);
461465
model.row_deleted.connect (on_row_deleted);
@@ -1204,11 +1208,6 @@ namespace Files {
12041208
}
12051209

12061210
/** Background actions */
1207-
1208-
private void change_state_show_hidden (GLib.SimpleAction action) requires (window != null) {
1209-
window.change_state_show_hidden (action);
1210-
}
1211-
12121211
private void on_background_action_new (GLib.SimpleAction action, GLib.Variant? param) {
12131212
switch (param.get_string ()) {
12141213
case "FOLDER":
@@ -1464,7 +1463,7 @@ namespace Files {
14641463
}
14651464
}
14661465

1467-
action_set_state (background_actions, "show-hidden", show);
1466+
app_settings.set_boolean ("show-hiddenfiles", show);
14681467
}
14691468

14701469
private void set_should_thumbnail () {

src/View/Widgets/AppMenu.vala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,13 @@ public class Files.AppMenu : Gtk.Popover {
9898
};
9999

100100
var restore_tabs = new Granite.SwitchModelButton (_("Restore Tabs from Last Time")) {
101-
action_name = "win.restore-tabs-on-startup"
101+
action_name = "win.restore-tabs"
102102
};
103103

104104
var show_header = new Granite.HeaderLabel (_("Show in View"));
105105

106106
var show_hidden_button = new Gtk.CheckButton () {
107-
action_name = "win.show-hidden"
107+
action_name = "win.show-hiddenfiles"
108108
};
109109
show_hidden_button.get_style_context ().add_class (Gtk.STYLE_CLASS_MENUITEM);
110110
show_hidden_button.add (new Granite.AccelLabel (

src/View/Window.vala

Lines changed: 9 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,8 @@ public class Files.View.Window : Hdy.ApplicationWindow {
7171
{"go-to", action_go_to, "s"},
7272
{"zoom", action_zoom, "s"},
7373
{"view-mode", action_view_mode, "u", "0" },
74-
{"show-hidden", null, null, "false", change_state_show_hidden},
75-
{"singleclick-select", null, null, "false", change_state_single_click_select},
76-
{"show-remote-thumbnails", null, null, "true", change_state_show_remote_thumbnails},
77-
{"show-local-thumbnails", null, null, "false", change_state_show_local_thumbnails},
78-
{"show-file-preview", null, null, "false", change_state_show_file_preview},
7974
{"tabhistory-restore", action_tabhistory_restore, "s" },
8075
{"folders-before-files", null, null, "true", change_state_folders_before_files},
81-
{"restore-tabs-on-startup", null, null, "true", change_state_restore_tabs_on_startup},
8276
{"forward", action_forward, "i"},
8377
{"back", action_back, "i"},
8478
{"focus-sidebar", action_focus_sidebar}
@@ -122,6 +116,14 @@ public class Files.View.Window : Hdy.ApplicationWindow {
122116
icon_name = "system-file-manager";
123117
title = _(APP_TITLE);
124118

119+
var app_settings = new Settings ("io.elementary.files.preferences");
120+
add_action (app_settings.create_action ("restore-tabs"));
121+
add_action (app_settings.create_action ("show-file-preview"));
122+
add_action (app_settings.create_action ("show-local-thumbnails"));
123+
add_action (app_settings.create_action ("show-remote-thumbnails"));
124+
add_action (app_settings.create_action ("show-hiddenfiles"));
125+
add_action (app_settings.create_action ("singleclick-select"));
126+
125127
add_action_entries (WIN_ENTRIES, this);
126128
undo_actions_set_insensitive ();
127129

@@ -152,7 +154,7 @@ public class Files.View.Window : Hdy.ApplicationWindow {
152154
marlin_app.set_accels_for_action ("win.zoom::ZOOM_IN", {"<Ctrl>plus", "<Ctrl>equal"});
153155
marlin_app.set_accels_for_action ("win.zoom::ZOOM_OUT", {"<Ctrl>minus"});
154156
marlin_app.set_accels_for_action ("win.zoom::ZOOM_NORMAL", {"<Ctrl>0"});
155-
marlin_app.set_accels_for_action ("win.show-hidden", {"<Ctrl>H"});
157+
marlin_app.set_accels_for_action ("win.show-hiddenfiles", {"<Ctrl>H"});
156158
marlin_app.set_accels_for_action ("win.refresh", {"<Ctrl>R", "F5"});
157159
marlin_app.set_accels_for_action ("win.go-to::HOME", {"<Alt>Home"});
158160
marlin_app.set_accels_for_action ("win.go-to::RECENT", {"<Alt>R"});
@@ -278,13 +280,7 @@ public class Files.View.Window : Hdy.ApplicationWindow {
278280

279281
/** Apply preferences */
280282
var prefs = Files.Preferences.get_default (); // Bound to settings schema by Application
281-
get_action ("show-hidden").set_state (prefs.show_hidden_files);
282-
get_action ("show-local-thumbnails").set_state (prefs.show_local_thumbnails);
283-
get_action ("show-remote-thumbnails").set_state (prefs.show_remote_thumbnails);
284-
get_action ("show-file-preview").set_state (prefs.show_file_preview);
285-
get_action ("singleclick-select").set_state (prefs.singleclick_select);
286283
get_action ("folders-before-files").set_state (prefs.sort_directories_first);
287-
get_action ("restore-tabs-on-startup").set_state (app_settings.get_boolean ("restore-tabs"));
288284

289285
button_forward.slow_press.connect (() => {
290286
get_action_group ("win").activate_action ("forward", new Variant.int32 (1));
@@ -1041,48 +1037,12 @@ public class Files.View.Window : Hdy.ApplicationWindow {
10411037
doing_undo_redo = false;
10421038
}
10431039

1044-
public void change_state_show_hidden (GLib.SimpleAction action) {
1045-
bool state = !action.state.get_boolean ();
1046-
action.set_state (new GLib.Variant.boolean (state));
1047-
Files.app_settings.set_boolean ("show-hiddenfiles", state);
1048-
}
1049-
1050-
public void change_state_single_click_select (GLib.SimpleAction action) {
1051-
bool state = !action.state.get_boolean ();
1052-
action.set_state (new GLib.Variant.boolean (state));
1053-
Files.Preferences.get_default ().singleclick_select = state;
1054-
}
1055-
1056-
public void change_state_show_remote_thumbnails (GLib.SimpleAction action) {
1057-
bool state = !action.state.get_boolean ();
1058-
action.set_state (new GLib.Variant.boolean (state));
1059-
Files.app_settings.set_boolean ("show-remote-thumbnails", state);
1060-
}
1061-
1062-
public void change_state_show_local_thumbnails (GLib.SimpleAction action) {
1063-
bool state = !action.state.get_boolean ();
1064-
action.set_state (new GLib.Variant.boolean (state));
1065-
Files.app_settings.set_boolean ("show-local-thumbnails", state);
1066-
}
1067-
1068-
public void change_state_show_file_preview (GLib.SimpleAction action) {
1069-
var state = !action.state.get_boolean ();
1070-
action.set_state (new GLib.Variant.boolean (state));
1071-
Files.app_settings.set_boolean ("show-file-preview", state);
1072-
}
1073-
10741040
public void change_state_folders_before_files (GLib.SimpleAction action) {
10751041
bool state = !action.state.get_boolean ();
10761042
action.set_state (new GLib.Variant.boolean (state));
10771043
Files.Preferences.get_default ().sort_directories_first = state;
10781044
}
10791045

1080-
public void change_state_restore_tabs_on_startup (GLib.SimpleAction action) {
1081-
bool state = !action.state.get_boolean ();
1082-
action.set_state (new GLib.Variant.boolean (state));
1083-
Files.app_settings.set_boolean ("restore-tabs", state);
1084-
}
1085-
10861046
private void connect_to_server () {
10871047
var dialog = new PF.ConnectServerDialog ((Gtk.Window) this);
10881048
string server_uri = "";

0 commit comments

Comments
 (0)