[geary/mjog/mutiple-main-windows] Remove Application.Controller::display_main_window_if_ready
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/mutiple-main-windows] Remove Application.Controller::display_main_window_if_ready
- Date: Mon, 18 Nov 2019 10:46:18 +0000 (UTC)
commit 51f0efe6eed93c66a690f69a11c3852c8d7546a4
Author: Michael Gratton <mike vee net>
Date: Mon Nov 18 21:44:48 2019 +1100
Remove Application.Controller::display_main_window_if_ready
It's not actually needed under the new application regime for anything
other than UpgradeDialog, so rework that to not require it and remove
the method and supporting code.
src/client/application/application-controller.vala | 39 ++--------------------
src/client/dialogs/upgrade-dialog.vala | 31 +++++++++--------
2 files changed, 20 insertions(+), 50 deletions(-)
---
diff --git a/src/client/application/application-controller.vala
b/src/client/application/application-controller.vala
index 6ae7869a..d3c37985 100644
--- a/src/client/application/application-controller.vala
+++ b/src/client/application/application-controller.vala
@@ -16,7 +16,6 @@
internal class Application.Controller : Geary.BaseObject {
- private const string PROP_ATTEMPT_OPEN_ACCOUNT = "attempt-open-account";
private const uint MAX_AUTH_ATTEMPTS = 3;
@@ -132,10 +131,7 @@ internal class Application.Controller : Geary.BaseObject {
IconFactory.init(application.get_resource_directory());
// Create DB upgrade dialog.
- this.upgrade_dialog = new UpgradeDialog();
- this.upgrade_dialog.notify[UpgradeDialog.PROP_VISIBLE_NAME].connect(
- display_main_window_if_ready
- );
+ this.upgrade_dialog = new UpgradeDialog(application);
// Initialise WebKit and WebViews
ClientWebView.init_web_context(
@@ -980,10 +976,9 @@ internal class Application.Controller : Geary.BaseObject {
bool retry = false;
do {
try {
- account.set_data(PROP_ATTEMPT_OPEN_ACCOUNT, true);
yield account.open_async(this.controller_open);
retry = false;
- } catch (Error open_err) {
+ } catch (GLib.Error open_err) {
debug("Unable to open account %s: %s", account.to_string(), open_err.message);
if (open_err is Geary.EngineError.CORRUPT) {
@@ -1005,7 +1000,6 @@ internal class Application.Controller : Geary.BaseObject {
} while (retry);
account_available(context);
- display_main_window_if_ready();
update_account_status();
}
@@ -1318,35 +1312,6 @@ internal class Application.Controller : Geary.BaseObject {
return retry;
}
- /**
- * Returns true if we've attempted to open all accounts at this point.
- */
- private bool did_attempt_open_all_accounts() {
- try {
- foreach (Geary.AccountInformation info in Geary.Engine.instance.get_accounts().values) {
- Geary.Account a = Geary.Engine.instance.get_account_instance(info);
- if (a.get_data<bool?>(PROP_ATTEMPT_OPEN_ACCOUNT) == null)
- return false;
- }
- } catch(Error e) {
- error("Could not open accounts: %s", e.message);
- }
-
- return true;
- }
-
- /**
- * Displays the main window if we're ready. Otherwise does nothing.
- */
- private void display_main_window_if_ready() {
- if (did_attempt_open_all_accounts() &&
- !this.upgrade_dialog.visible &&
- !this.controller_open.is_cancelled() &&
- !this.application.is_background_service) {
- this.application.get_active_main_window().present();
- }
- }
-
/**
* Returns the number of accounts that exist in Geary. Note that not all accounts may be
* open. Zero is returned on an error.
diff --git a/src/client/dialogs/upgrade-dialog.vala b/src/client/dialogs/upgrade-dialog.vala
index 7a238b17..29d88864 100644
--- a/src/client/dialogs/upgrade-dialog.vala
+++ b/src/client/dialogs/upgrade-dialog.vala
@@ -14,29 +14,31 @@ public class UpgradeDialog : Object {
// Whether or not this dialog is visible.
public bool visible { get; set; }
- private Gtk.Dialog dialog;
+ private weak Application.Client application;
+
+ private Gtk.Dialog? dialog = null;
private Gee.HashSet<Cancellable> cancellables = new Gee.HashSet<Cancellable>();
/**
* Creates and loads the upgrade progress dialog.
*/
- public UpgradeDialog() {
- // Load UI.
- Gtk.Builder builder = GioUtil.create_builder("upgrade_dialog.glade");
- dialog = (Gtk.Dialog) builder.get_object("dialog");
+ public UpgradeDialog(Application.Client application) {
+ this.application = application;
+ // Load UI.
// Hook up signals.
monitor.start.connect(on_start);
monitor.finish.connect(on_close);
- dialog.delete_event.connect(on_delete_event);
-
- // Bind visibility flag.
- dialog.bind_property(PROP_VISIBLE_NAME, this, PROP_VISIBLE_NAME, BindingFlags.BIDIRECTIONAL |
- BindingFlags.SYNC_CREATE);
}
private void on_start() {
- dialog.show();
+ Gtk.Builder builder = GioUtil.create_builder("upgrade_dialog.glade");
+ this.dialog = (Gtk.Dialog) builder.get_object("dialog");
+ this.dialog.set_transient_for(
+ this.application.get_active_main_window()
+ );
+ this.dialog.delete_event.connect(on_delete_event);
+ this.dialog.show();
}
private bool on_delete_event() {
@@ -51,8 +53,11 @@ public class UpgradeDialog : Object {
c.cancel();
}
- if (dialog.visible)
- dialog.hide();
+ if (this.dialog != null &&
+ this.dialog.visible) {
+ this.dialog.hide();
+ this.dialog = null;
+ }
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]