Skip to content

Commit ae7e1df

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

File tree

2 files changed

+40
-7
lines changed

2 files changed

+40
-7
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: 30 additions & 6 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> ();
@@ -87,9 +90,12 @@ public class Mail.ConversationList : Gtk.Box {
8790
valign = Gtk.Align.CENTER
8891
};
8992

90-
hide_read_switch = new Granite.SwitchModelButton (_("Hide read conversations"));
91-
92-
hide_unstarred_switch = new Granite.SwitchModelButton (_("Hide unstarred conversations"));
93+
hide_read_switch = new Granite.SwitchModelButton (_("Hide read conversations")) {
94+
active = settings.get_boolean ("hide-read-conversations")
95+
};
96+
hide_unstarred_switch = new Granite.SwitchModelButton (_("Hide unstarred conversations")) {
97+
active = settings.get_boolean ("hide-unstarred-conversations")
98+
};
9399

94100
var filter_menu_popover_box = new Gtk.Box (VERTICAL, 0) {
95101
margin_bottom = 3,
@@ -163,7 +169,7 @@ public class Mail.ConversationList : Gtk.Box {
163169
add (scrolled_window);
164170
add (conversation_action_bar);
165171

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

168174
list_box.row_activated.connect ((row) => {
169175
if (mark_read_timeout_id != 0) {
@@ -203,9 +209,27 @@ public class Mail.ConversationList : Gtk.Box {
203209
}
204210
});
205211

206-
hide_read_switch.toggled.connect (() => load_folder.begin (folder_info_per_account));
212+
hide_read_switch.notify["active"].connect (() => {
213+
if (settings.get_boolean ("hide-read-conversations") != hide_read_switch.active) {
214+
settings.set_boolean ("hide-read-conversations", hide_read_switch.active);
215+
}
216+
217+
reload_active_folder ();
218+
});
207219

208-
hide_unstarred_switch.toggled.connect (() => load_folder.begin (folder_info_per_account));
220+
hide_unstarred_switch.notify["active"].connect (() => {
221+
if (settings.get_boolean ("hide-unstarred-conversations") != hide_unstarred_switch.active) {
222+
settings.set_boolean ("hide-unstarred-conversations", hide_unstarred_switch.active);
223+
}
224+
225+
reload_active_folder ();
226+
});
227+
}
228+
229+
private void reload_active_folder () {
230+
if (folder_info_per_account != null) {
231+
load_folder.begin (folder_info_per_account);
232+
}
209233
}
210234

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

0 commit comments

Comments
 (0)