[geary] Add is_background_service to app as a consistent way to determine this.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary] Add is_background_service to app as a consistent way to determine this.
- Date: Sat, 17 Dec 2016 03:38:22 +0000 (UTC)
commit e24db89d104d8870b313c5689a264da29305f369
Author: Michael James Gratton <mike vee net>
Date: Sat Dec 17 14:26:51 2016 +1100
Add is_background_service to app as a consistent way to determine this.
* src/client/application/geary-application.vala
(GearyApplication::is_background_service): New property to provide
common way to determine if the app is a background service. Rework
other uses of the command line arg or setting to use this.
src/client/application/geary-application.vala | 11 +++++++++++
src/client/application/geary-controller.vala | 6 ++++--
src/client/components/main-window.vala | 3 +--
3 files changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/src/client/application/geary-application.vala b/src/client/application/geary-application.vala
index 5f5f7b5..1aef984 100644
--- a/src/client/application/geary-application.vala
+++ b/src/client/application/geary-application.vala
@@ -98,6 +98,17 @@ public class GearyApplication : Gtk.Application {
*/
public Configuration config { get; private set; }
+ /**
+ * Determines if Geary configured to run as as a background service.
+ *
+ * If this returns `true`, then the primary application instance
+ * will continue to run in the background after the last window is
+ * closed, instead of existing as usual.
+ */
+ public bool is_background_service {
+ get { return Args.hidden_startup || this.config.startup_notifications; }
+ }
+
public Gtk.ActionGroup actions {
get; private set; default = new Gtk.ActionGroup("GearyActionGroup");
}
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index c7a6fa4..588f1e0 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -1276,8 +1276,10 @@ public class GearyController : Geary.BaseObject {
* Displays the main window if we're ready. Otherwise does nothing.
*/
private void display_main_window_if_ready() {
- if (did_attempt_open_all_accounts() && !upgrade_dialog.visible &&
- !cancellable_open_account.is_cancelled() && !Args.hidden_startup)
+ if (did_attempt_open_all_accounts() &&
+ !upgrade_dialog.visible &&
+ !cancellable_open_account.is_cancelled() &&
+ !this.application.is_background_service)
main_window.show_all();
}
diff --git a/src/client/components/main-window.vala b/src/client/components/main-window.vala
index 9f9e723..9cf92b7 100644
--- a/src/client/components/main-window.vala
+++ b/src/client/components/main-window.vala
@@ -375,7 +375,7 @@ public class MainWindow : Gtk.ApplicationWindow {
[GtkCallback]
private bool on_delete_event() {
- if (Args.hidden_startup || this.application.config.startup_notifications)
+ if (this.application.is_background_service)
return hide_on_delete();
this.application.exit();
@@ -383,4 +383,3 @@ public class MainWindow : Gtk.ApplicationWindow {
return true;
}
}
-
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]