[geary/mjog/406-offline-infobar-delay: 22/22] Application.Controller: Delay showing infobar whe going offline
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/406-offline-infobar-delay: 22/22] Application.Controller: Delay showing infobar whe going offline
- Date: Sat, 21 Mar 2020 22:39:13 +0000 (UTC)
commit ffba41d106addc267fb83a444af1cea4e9ffb19a
Author: Michael Gratton <mike vee net>
Date: Wed Mar 18 13:53:26 2020 +1100
Application.Controller: Delay showing infobar whe going offline
Wait 10s before showing the offline infobar to avoid having it flash
up when network connections are temporarily lost, e.g. when resuming
from suspend.
Fixes #406
src/client/application/application-controller.vala | 31 ++++++++++++++++------
1 file changed, 23 insertions(+), 8 deletions(-)
---
diff --git a/src/client/application/application-controller.vala
b/src/client/application/application-controller.vala
index 613c9d24..7167fd58 100644
--- a/src/client/application/application-controller.vala
+++ b/src/client/application/application-controller.vala
@@ -90,6 +90,9 @@ internal class Application.Controller : Geary.BaseObject {
// Requested mailto composers not yet fullfulled
private Gee.List<string?> pending_mailtos = new Gee.ArrayList<string>();
+ // Timeout controller for displaying the offline status bar
+ private Geary.TimeoutManager offline_timeout;
+
/**
* Emitted when an account is added or is enabled.
@@ -178,6 +181,10 @@ internal class Application.Controller : Geary.BaseObject {
application.engine.account_available.connect(on_account_available);
+ this.offline_timeout = new Geary.TimeoutManager.seconds(
+ 10, () => update_account_status(false)
+ );
+
this.account_manager = new Accounts.Manager(
libsecret,
this.application.get_user_config_directory(),
@@ -999,7 +1006,7 @@ internal class Application.Controller : Geary.BaseObject {
}
}
- private void update_account_status() {
+ private void update_account_status(bool delay_offline = true) {
// Start off assuming all accounts are online and error free
// (i.e. no status issues to indicate) and proceed until
// proven incorrect.
@@ -1022,13 +1029,21 @@ internal class Application.Controller : Geary.BaseObject {
has_cert_error |= context.tls_validation_failed;
}
- foreach (MainWindow window in this.application.get_main_windows()) {
- window.update_account_status(
- effective_status,
- has_auth_error,
- has_cert_error,
- service_problem_source
- );
+ // Don't show the offline bar right away, wait a few seconds
+ // in case the host is currently resuming and the network is
+ // already coming back up
+ if (!effective_status.is_online() && delay_offline) {
+ this.offline_timeout.start();
+ } else {
+ this.offline_timeout.reset();
+ foreach (MainWindow window in this.application.get_main_windows()) {
+ window.update_account_status(
+ effective_status,
+ has_auth_error,
+ has_cert_error,
+ service_problem_source
+ );
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]