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.
This commit is contained in:
parent
fbc47a1f99
commit
51f0efe6ee
2 changed files with 20 additions and 50 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue