Skip to content

Commit e55d92f

Browse files
committed
Persist conversation list filter switches
1 parent 5e065fd commit e55d92f

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

data/io.elementary.mail.gschema.xml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@
3232
<summary>Whether to always load remote images without prompting</summary>
3333
<description>Whether to always load remote images without prompting</description>
3434
</key>
35+
<key name="hide-read-conversations" type="b">
36+
<default>false</default>
37+
<summary>Whether to hide read conversations in the list</summary>
38+
<description>Stores the last used state of the “Hide read conversations” filter</description>
39+
</key>
40+
<key name="hide-unstarred-conversations" type="b">
41+
<default>false</default>
42+
<summary>Whether to hide unstarred conversations in the list</summary>
43+
<description>Stores the last used state of the “Hide unstarred conversations” filter</description>
44+
</key>
3545
<key name="remote-images-whitelist" type="as">
3646
<default>[]</default>
3747
<summary>A list of sender addresses for which remote images will be automatically loaded</summary>
@@ -51,4 +61,3 @@
5161
</key>
5262
</schema>
5363
</schemalist>
54-

src/ConversationList/ConversationList.vala

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,16 @@ public class Mail.ConversationList : Gtk.Box {
4141
private Granite.SwitchModelButton hide_unstarred_switch;
4242
private Gtk.MenuButton filter_button;
4343
private Gtk.Stack refresh_stack;
44+
private GLib.Settings settings;
4445

4546
private uint mark_read_timeout_id = 0;
4647

4748
construct {
4849
orientation = VERTICAL;
4950
get_style_context ().add_class (Gtk.STYLE_CLASS_VIEW);
5051

52+
settings = new GLib.Settings ("io.elementary.mail");
53+
5154
conversations = new Gee.HashMap<string, ConversationItemModel> ();
5255
folders = new Gee.HashMap<string, Camel.Folder> ();
5356
folder_info_flags = new Gee.HashMap<string, Camel.FolderInfoFlags> ();
@@ -88,8 +91,19 @@ public class Mail.ConversationList : Gtk.Box {
8891
};
8992

9093
hide_read_switch = new Granite.SwitchModelButton (_("Hide read conversations"));
91-
9294
hide_unstarred_switch = new Granite.SwitchModelButton (_("Hide unstarred conversations"));
95+
settings.bind (
96+
"hide-read-conversations",
97+
hide_read_switch,
98+
"active",
99+
SettingsBindFlags.DEFAULT | SettingsBindFlags.SET
100+
);
101+
settings.bind (
102+
"hide-unstarred-conversations",
103+
hide_unstarred_switch,
104+
"active",
105+
SettingsBindFlags.DEFAULT | SettingsBindFlags.SET
106+
);
93107

94108
var filter_menu_popover_box = new Gtk.Box (VERTICAL, 0) {
95109
margin_bottom = 3,
@@ -163,7 +177,7 @@ public class Mail.ConversationList : Gtk.Box {
163177
add (scrolled_window);
164178
add (conversation_action_bar);
165179

166-
search_entry.search_changed.connect (() => load_folder.begin (folder_info_per_account));
180+
search_entry.search_changed.connect (() => reload_active_folder ());
167181

168182
list_box.row_activated.connect ((row) => {
169183
if (mark_read_timeout_id != 0) {
@@ -203,9 +217,15 @@ public class Mail.ConversationList : Gtk.Box {
203217
}
204218
});
205219

206-
hide_read_switch.toggled.connect (() => load_folder.begin (folder_info_per_account));
220+
hide_read_switch.notify["active"].connect (() => reload_active_folder ());
207221

208-
hide_unstarred_switch.toggled.connect (() => load_folder.begin (folder_info_per_account));
222+
hide_unstarred_switch.notify["active"].connect (() => reload_active_folder ());
223+
}
224+
225+
private void reload_active_folder () {
226+
if (folder_info_per_account != null) {
227+
load_folder.begin (folder_info_per_account);
228+
}
209229
}
210230

211231
private static void set_thread_flag (Camel.FolderThreadNode? node, Camel.MessageFlags flag) {

0 commit comments

Comments
 (0)