[geary/geary-0.11] Fix composers not dismissed when started hidden and main window closed.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/geary-0.11] Fix composers not dismissed when started hidden and main window closed.
- Date: Sun, 18 Dec 2016 15:36:46 +0000 (UTC)
commit 059d5f356d9325656520059f27e833edc54a6615
Author: Michael James Gratton <mike vee net>
Date: Sat Dec 17 14:35:36 2016 +1100
Fix composers not dismissed when started hidden and main window closed.
Fixes Bug 770037.
* src/client/application/geary-controller.vala
(GearyController::close_composition_windows): Set from private to
internal so MainWindow can call it, add an arg to determine if all
composers should be closed, or only the one in the main window.
* src/client/components/main-window.vala (MainWindow::on_delete_event):
Close any main window composers before letting the window close.
* src/client/composer/composer-widget.vala (ComposerWidget::state): Don't
allow ny old code to set the composer's state.
src/client/application/geary-controller.vala | 45 +++++++++++++++-----------
src/client/components/main-window.vala | 15 +++++---
src/client/composer/composer-widget.vala | 6 ++--
3 files changed, 38 insertions(+), 28 deletions(-)
---
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index 4b084a3..de2ba42 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -2151,30 +2151,37 @@ public class GearyController : Geary.BaseObject {
return ret;
}
-
- private bool close_composition_windows() {
+
+ internal bool close_composition_windows(bool main_window_only = false) {
Gee.List<ComposerWidget> composers_to_destroy = new Gee.ArrayList<ComposerWidget>();
bool quit_cancelled = false;
-
- // If there's composer windows open, give the user a chance to save or cancel.
+
+ // If there's composer windows open, give the user a chance to
+ // save or cancel.
foreach(ComposerWidget cw in composer_widgets) {
- // Check if we should close the window immediately, or if we need to wait.
- ComposerWidget.CloseStatus status = cw.should_close();
- if (status == ComposerWidget.CloseStatus.PENDING_CLOSE) {
- // Window is currently busy saving.
- waiting_to_close.add(cw);
- } else if (status == ComposerWidget.CloseStatus.CANCEL_CLOSE) {
- // User cancelled operation.
- quit_cancelled = true;
- break;
- } else if (status == ComposerWidget.CloseStatus.DO_CLOSE) {
- // Hide any existing composer windows for the moment; actually deleting the windows
- // will result in their removal from composer_windows, which could crash this loop.
- composers_to_destroy.add(cw);
- ((ComposerContainer) cw.parent).vanish();
+ if (!main_window_only ||
+ cw.state != ComposerWidget.ComposerState.DETACHED) {
+ // Check if we should close the window immediately, or
+ // if we need to wait.
+ ComposerWidget.CloseStatus status = cw.should_close();
+ if (status == ComposerWidget.CloseStatus.PENDING_CLOSE) {
+ // Window is currently busy saving.
+ waiting_to_close.add(cw);
+ } else if (status == ComposerWidget.CloseStatus.CANCEL_CLOSE) {
+ // User cancelled operation.
+ quit_cancelled = true;
+ break;
+ } else if (status == ComposerWidget.CloseStatus.DO_CLOSE) {
+ // Hide any existing composer windows for the
+ // moment; actually deleting the windows will
+ // result in their removal from composer_windows,
+ // which could crash this loop.
+ composers_to_destroy.add(cw);
+ ((ComposerContainer) cw.parent).vanish();
+ }
}
}
-
+
// Safely destroy windows.
foreach(ComposerWidget cw in composers_to_destroy)
((ComposerContainer) cw.parent).close_container();
diff --git a/src/client/components/main-window.vala b/src/client/components/main-window.vala
index 324cbb7..4acc987 100644
--- a/src/client/components/main-window.vala
+++ b/src/client/components/main-window.vala
@@ -115,12 +115,14 @@ public class MainWindow : Gtk.ApplicationWindow {
}
private bool on_delete_event() {
- if (Args.hidden_startup || GearyApplication.instance.config.startup_notifications)
- return hide_on_delete();
-
- GearyApplication.instance.exit();
-
- return true;
+ if (Args.hidden_startup || GearyApplication.instance.config.startup_notifications) {
+ if (GearyApplication.instance.controller.close_composition_windows(true)) {
+ hide();
+ }
+ } else {
+ GearyApplication.instance.exit();
+ }
+ return Gdk.EVENT_STOP;
}
// Fired on [un]maximize and possibly others. Save maximized state
@@ -437,5 +439,6 @@ public class MainWindow : Gtk.ApplicationWindow {
else
main_toolbar.folder = current_folder.get_display_name();
}
+
}
diff --git a/src/client/composer/composer-widget.vala b/src/client/composer/composer-widget.vala
index 4e990a7..fd0a619 100644
--- a/src/client/composer/composer-widget.vala
+++ b/src/client/composer/composer-widget.vala
@@ -190,9 +190,9 @@ public class ComposerWidget : Gtk.EventBox {
get { return ((Gtk.ToggleAction) actions.get_action(ACTION_SHOW_EXTENDED)).active; }
set { ((Gtk.ToggleAction) actions.get_action(ACTION_SHOW_EXTENDED)).active = value; }
}
-
- public ComposerState state { get; set; }
-
+
+ public ComposerState state { get; internal set; }
+
public ComposeType compose_type { get; private set; default = ComposeType.NEW_MESSAGE; }
public Gee.Set<Geary.EmailIdentifier> referred_ids = new Gee.HashSet<Geary.EmailIdentifier>();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]