[geary/mjog/account-command-stacks: 73/77] Move MainWindow folder management impl to MainWindow
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/account-command-stacks: 73/77] Move MainWindow folder management impl to MainWindow
- Date: Tue, 5 Nov 2019 00:39:13 +0000 (UTC)
commit 4a4d1731925848bfe5faa75b4bd290ba034747a1
Author: Michael Gratton <mike vee net>
Date: Tue Nov 5 08:25:35 2019 +1100
Move MainWindow folder management impl to MainWindow
src/client/application/application-controller.vala | 25 ++++------------------
src/client/components/main-window.vala | 18 ++++++++++++++++
2 files changed, 22 insertions(+), 21 deletions(-)
---
diff --git a/src/client/application/application-controller.vala
b/src/client/application/application-controller.vala
index f2d036e1..d1accf8f 100644
--- a/src/client/application/application-controller.vala
+++ b/src/client/application/application-controller.vala
@@ -1341,17 +1341,10 @@ public class Application.Controller : Geary.BaseObject {
if (!should_add_folder(available, folder)) {
continue;
}
-
- main_window.folder_list.add_folder(folder);
- if (folder.account == main_window.selected_account) {
- if (!main_window.main_toolbar.copy_folder_menu.has_folder(folder))
- main_window.main_toolbar.copy_folder_menu.add_folder(folder);
- if (!main_window.main_toolbar.move_folder_menu.has_folder(folder))
- main_window.main_toolbar.move_folder_menu.add_folder(folder);
- }
+ folder.special_folder_type_changed.connect(on_special_folder_type_changed);
+ this.main_window.add_folder(folder);
GLib.Cancellable cancellable = context.cancellable;
-
switch (folder.special_folder_type) {
case Geary.SpecialFolderType.INBOX:
// Special case handling of inboxes
@@ -1388,8 +1381,6 @@ public class Application.Controller : Geary.BaseObject {
}
break;
}
-
- folder.special_folder_type_changed.connect(on_special_folder_type_changed);
}
}
@@ -1399,14 +1390,8 @@ public class Application.Controller : Geary.BaseObject {
bool has_prev = unavailable_iterator.last();
while (has_prev) {
Geary.Folder folder = unavailable_iterator.get();
-
- main_window.folder_list.remove_folder(folder);
- if (folder.account == this.main_window.selected_account) {
- if (main_window.main_toolbar.copy_folder_menu.has_folder(folder))
- main_window.main_toolbar.copy_folder_menu.remove_folder(folder);
- if (main_window.main_toolbar.move_folder_menu.has_folder(folder))
- main_window.main_toolbar.move_folder_menu.remove_folder(folder);
- }
+ folder.special_folder_type_changed.disconnect(on_special_folder_type_changed);
+ this.main_window.remove_folder(folder);
switch (folder.special_folder_type) {
case Geary.SpecialFolderType.INBOX:
@@ -1423,8 +1408,6 @@ public class Application.Controller : Geary.BaseObject {
break;
}
- folder.special_folder_type_changed.disconnect(on_special_folder_type_changed);
-
has_prev = unavailable_iterator.previous();
}
diff --git a/src/client/components/main-window.vala b/src/client/components/main-window.vala
index 1a7cc5d7..6d1d3a24 100644
--- a/src/client/components/main-window.vala
+++ b/src/client/components/main-window.vala
@@ -577,6 +577,24 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
}
}
+ /** Adds a folder to the window. */
+ public void add_folder(Geary.Folder to_add) {
+ this.folder_list.add_folder(to_add);
+ if (to_add.account == this.selected_account) {
+ this.main_toolbar.copy_folder_menu.add_folder(to_add);
+ this.main_toolbar.move_folder_menu.add_folder(to_add);
+ }
+ }
+
+ /** Removes a folder from the window. */
+ public void remove_folder(Geary.Folder to_remove) {
+ if (to_remove.account == this.selected_account) {
+ this.main_toolbar.copy_folder_menu.remove_folder(to_remove);
+ this.main_toolbar.move_folder_menu.remove_folder(to_remove);
+ }
+ this.folder_list.remove_folder(to_remove);
+ }
+
private void load_config(Configuration config) {
// This code both loads AND saves the pane positions with live updating. This is more
// resilient against crashes because the value in dconf changes *immediately*, and
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]