[geary/mjog/email-templates: 54/72] Application.FolderStoreFactory, EmailStorefactory: Remove controller use
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/email-templates: 54/72] Application.FolderStoreFactory, EmailStorefactory: Remove controller use
- Date: Mon, 20 Apr 2020 13:54:42 +0000 (UTC)
commit 2f666213ca2977c762ced1539a4bffd29c4a97eb
Author: Michael Gratton <mike vee net>
Date: Tue Apr 7 17:18:01 2020 +1000
Application.FolderStoreFactory, EmailStorefactory: Remove controller use
Remove use of Application.Controller in these classes so they can be
more easily unit tested.
.../application-email-store-factory.vala | 8 +-----
.../application-folder-store-factory.vala | 30 +++++-----------------
.../application/application-plugin-manager.vala | 18 +++++++++++--
3 files changed, 24 insertions(+), 32 deletions(-)
---
diff --git a/src/client/application/application-email-store-factory.vala
b/src/client/application/application-email-store-factory.vala
index 031f08fa..7b8322e4 100644
--- a/src/client/application/application-email-store-factory.vala
+++ b/src/client/application/application-email-store-factory.vala
@@ -23,15 +23,12 @@ internal class Application.EmailStoreFactory : Geary.BaseObject {
private class EmailStoreImpl : Geary.BaseObject, Plugin.EmailStore {
- private Controller controller;
private Gee.Map<AccountContext,PluginManager.AccountImpl> accounts;
public EmailStoreImpl(
- Controller controller,
Gee.Map<AccountContext,PluginManager.AccountImpl> accounts
) {
- this.controller = controller;
this.accounts = accounts;
}
@@ -173,7 +170,6 @@ internal class Application.EmailStoreFactory : Geary.BaseObject {
}
- private Controller controller;
private Gee.Map<AccountContext,PluginManager.AccountImpl> accounts;
private Gee.Set<EmailStoreImpl> stores =
new Gee.HashSet<EmailStoreImpl>();
@@ -183,10 +179,8 @@ internal class Application.EmailStoreFactory : Geary.BaseObject {
* Constructs a new factory instance.
*/
public EmailStoreFactory(
- Controller controller,
Gee.Map<AccountContext,PluginManager.AccountImpl> accounts
) {
- this.controller = controller;
this.accounts = accounts;
}
@@ -200,7 +194,7 @@ internal class Application.EmailStoreFactory : Geary.BaseObject {
/** Constructs a new email store for use by plugin contexts. */
public Plugin.EmailStore new_email_store() {
- var store = new EmailStoreImpl(this.controller, this.accounts);
+ var store = new EmailStoreImpl(this.accounts);
this.stores.add(store);
return store;
}
diff --git a/src/client/application/application-folder-store-factory.vala
b/src/client/application/application-folder-store-factory.vala
index 2b7de9ee..c8aa2290 100644
--- a/src/client/application/application-folder-store-factory.vala
+++ b/src/client/application/application-folder-store-factory.vala
@@ -24,13 +24,10 @@ internal class Application.FolderStoreFactory : Geary.BaseObject {
"(sv)"
);
- private Controller controller;
private Gee.Map<Geary.Folder,FolderImpl> folders;
- public FolderStoreImpl(Controller controller,
- Gee.Map<Geary.Folder,FolderImpl> folders) {
- this.controller = controller;
+ public FolderStoreImpl(Gee.Map<Geary.Folder,FolderImpl> folders) {
this.folders = folders;
}
@@ -138,8 +135,6 @@ internal class Application.FolderStoreFactory : Geary.BaseObject {
}
- private Controller controller;
-
private Gee.Map<AccountContext,PluginManager.AccountImpl> accounts;
private Gee.Map<Geary.Folder,FolderImpl> folders =
new Gee.HashMap<Geary.Folder,FolderImpl>();
@@ -150,19 +145,12 @@ internal class Application.FolderStoreFactory : Geary.BaseObject {
/**
* Constructs a new factory instance.
*/
- public FolderStoreFactory(Controller controller,
- Gee.Map<AccountContext,PluginManager.AccountImpl> accounts) {
- this.controller = controller;
- this.controller.application.window_added.connect(on_window_added);
- foreach (var main in this.controller.application.get_main_windows()) {
- main.notify["selected-folder"].connect(on_folder_selected);
- }
+ public FolderStoreFactory(Gee.Map<AccountContext,PluginManager.AccountImpl> accounts) {
this.accounts = accounts;
}
/** Clearing all state of the store. */
public void destroy() throws GLib.Error {
- this.controller.application.window_added.disconnect(on_window_added);
foreach (FolderStoreImpl store in this.stores) {
store.destroy();
}
@@ -172,7 +160,7 @@ internal class Application.FolderStoreFactory : Geary.BaseObject {
/** Constructs a new folder store for use by plugin contexts. */
public Plugin.FolderStore new_folder_store() {
- var store = new FolderStoreImpl(this.controller, this.folders);
+ var store = new FolderStoreImpl(this.folders);
this.stores.add(store);
return store;
}
@@ -217,6 +205,10 @@ internal class Application.FolderStoreFactory : Geary.BaseObject {
remove_folders(removed, removed.get_folders());
}
+ internal void main_window_added(MainWindow added) {
+ added.notify["selected-folder"].connect(on_folder_selected);
+ }
+
private void add_folders(AccountContext account,
Gee.Collection<FolderContext> to_add) {
foreach (var context in to_add) {
@@ -281,14 +273,6 @@ internal class Application.FolderStoreFactory : Geary.BaseObject {
}
}
-
- private void on_window_added(Gtk.Window window) {
- var main = window as MainWindow;
- if (main != null) {
- main.notify["selected-folder"].connect(on_folder_selected);
- }
- }
-
private void on_folder_selected(GLib.Object object, GLib.ParamSpec param) {
var main = object as MainWindow;
if (main != null) {
diff --git a/src/client/application/application-plugin-manager.vala
b/src/client/application/application-plugin-manager.vala
index d4545e70..cf91cc50 100644
--- a/src/client/application/application-plugin-manager.vala
+++ b/src/client/application/application-plugin-manager.vala
@@ -237,10 +237,10 @@ public class Application.PluginManager : GLib.Object {
this.config = config;
this.plugins = Peas.Engine.get_default();
this.folders_factory = new FolderStoreFactory(
- controller, this.plugin_accounts.read_only_view
+ this.plugin_accounts.read_only_view
);
this.email_factory = new EmailStoreFactory(
- controller, this.plugin_accounts.read_only_view
+ this.plugin_accounts.read_only_view
);
this.trusted_path = trusted_plugin_path.get_path();
@@ -267,6 +267,11 @@ public class Application.PluginManager : GLib.Object {
}
}
+ this.application.window_added.connect(on_window_added);
+ foreach (MainWindow main in this.application.get_main_windows()) {
+ this.folders_factory.main_window_added(main);
+ }
+
this.controller.account_available.connect(
on_account_available
);
@@ -341,6 +346,8 @@ public class Application.PluginManager : GLib.Object {
internal void close() throws GLib.Error {
this.is_shutdown = true;
+ this.application.window_added.disconnect(on_window_added);
+
this.controller.account_unavailable.disconnect(on_account_unavailable);
this.controller.account_available.disconnect(on_account_available);
foreach (var context in this.controller.get_account_contexts()) {
@@ -515,6 +522,13 @@ public class Application.PluginManager : GLib.Object {
this.plugin_set.unset(context.info);
}
+ private void on_window_added(Gtk.Window window) {
+ var main = window as MainWindow;
+ if (main != null) {
+ this.folders_factory.main_window_added(main);
+ }
+ }
+
private void on_account_available(AccountContext available) {
add_account(available);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]