[geary/wip/draft-management: 4/4] Don't reopen drafts that are already open in a composer
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/draft-management: 4/4] Don't reopen drafts that are already open in a composer
- Date: Wed, 31 Jul 2019 12:29:11 +0000 (UTC)
commit f33812ab10d2ff61e58c6b68a8fc8cf1a90d7d15
Author: Michael Gratton <mike vee net>
Date: Mon Jul 22 18:08:46 2019 +1000
Don't reopen drafts that are already open in a composer
See #402
src/client/application/application-controller.vala | 22 ++++++++++++++++++----
src/client/components/main-window.vala | 2 +-
src/client/composer/composer-widget.vala | 12 ++++++++++--
3 files changed, 29 insertions(+), 7 deletions(-)
---
diff --git a/src/client/application/application-controller.vala
b/src/client/application/application-controller.vala
index e493977d..9c72d774 100644
--- a/src/client/application/application-controller.vala
+++ b/src/client/application/application-controller.vala
@@ -1249,9 +1249,23 @@ public class Application.Controller : Geary.BaseObject {
Geary.Email draft = activated.get_latest_recv_email(
Geary.App.Conversation.Location.IN_FOLDER
);
- create_compose_widget(
- ComposerWidget.ComposeType.NEW_MESSAGE, draft, null, null, true
- );
+
+ bool already_open = false;
+ foreach (ComposerWidget composer in this.composer_widgets) {
+ if (composer.draft_id != null &&
+ composer.draft_id.equal_to(draft.id)) {
+ already_open = true;
+ composer.present();
+ composer.set_focus();
+ break;
+ }
+ }
+
+ if (!already_open) {
+ create_compose_widget(
+ ComposerWidget.ComposeType.NEW_MESSAGE, draft, null, null, true
+ );
+ }
}
private void on_special_folder_type_changed(Geary.Folder folder,
@@ -2035,7 +2049,7 @@ public class Application.Controller : Geary.BaseObject {
);
} else {
widget = new ComposerWidget(
- this.application, current_account, compose_type
+ this.application, current_account, null, compose_type
);
}
diff --git a/src/client/components/main-window.vala b/src/client/components/main-window.vala
index 695a6096..ad46db79 100644
--- a/src/client/components/main-window.vala
+++ b/src/client/components/main-window.vala
@@ -125,7 +125,7 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
public void open_composer_for_mailbox(Geary.RFC822.MailboxAddress to) {
Application.Controller controller = this.application.controller;
ComposerWidget composer = new ComposerWidget(
- this.application, this.current_folder.account, NEW_MESSAGE
+ this.application, this.current_folder.account, null, NEW_MESSAGE
);
composer.to = to.to_full_display();
controller.add_composer(composer);
diff --git a/src/client/composer/composer-widget.vala b/src/client/composer/composer-widget.vala
index 88904a7e..e3e331d7 100644
--- a/src/client/composer/composer-widget.vala
+++ b/src/client/composer/composer-widget.vala
@@ -170,6 +170,9 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface {
public Geary.Account account { get; private set; }
private Gee.Map<string, Geary.AccountInformation> accounts;
+ /** The identifier of the draft this composer holds, if any. */
+ public Geary.EmailIdentifier? draft_id { get; private set; default = null; }
+
public Geary.RFC822.MailboxAddresses from { get; private set; }
public string to {
@@ -399,11 +402,12 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface {
public ComposerWidget(GearyApplication application,
Geary.Account initial_account,
+ Geary.EmailIdentifier? draft_id,
ComposeType compose_type) {
base_ref();
this.application = application;
this.account = initial_account;
- this.account = account;
+ this.draft_id = draft_id;
try {
this.accounts = this.application.engine.get_accounts();
@@ -569,7 +573,7 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface {
public ComposerWidget.from_mailto(GearyApplication application,
Geary.Account initial_account,
string mailto) {
- this(application, initial_account, ComposeType.NEW_MESSAGE);
+ this(application, initial_account, null, ComposeType.NEW_MESSAGE);
Gee.HashMultiMap<string, string> headers = new Gee.HashMultiMap<string, string>();
if (mailto.length > Geary.ComposedEmail.MAILTO_SCHEME.length) {
@@ -819,6 +823,10 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface {
return referred_quote;
}
+ public void present() {
+ this.container.present();
+ }
+
public void set_focus() {
bool not_compact = (this.state != ComposerState.INLINE_COMPACT);
if (not_compact && Geary.String.is_empty(to))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]