[geary/wip/765516-gtk-widget-conversation-viewer] Don't append in-progress drafts to a conversation.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/765516-gtk-widget-conversation-viewer] Don't append in-progress drafts to a conversation.
- Date: Mon, 26 Sep 2016 07:57:20 +0000 (UTC)
commit b3e332a7f371185be3e5b566e61c411c7cd1fea3
Author: Michael James Gratton <mike vee net>
Date: Mon Sep 26 17:44:32 2016 +1000
Don't append in-progress drafts to a conversation.
* src/client/conversation-viewer/conversation-listbox.vala
(ConversationListBox): Keep track of the draft id currently being
edited, don't add it to the conversation when appended.
* src/client/composer/composer-container.vala (ComposerContainer): Make
the container's composer internal so we can hook into its
draft_id_changed signal. Update implementing classes.
src/client/composer/composer-box.vala | 2 +-
src/client/composer/composer-container.vala | 2 +-
src/client/composer/composer-embed.vala | 2 +-
src/client/composer/composer-window.vala | 11 ++++++-----
.../conversation-viewer/conversation-listbox.vala | 11 ++++++++++-
5 files changed, 19 insertions(+), 9 deletions(-)
---
diff --git a/src/client/composer/composer-box.vala b/src/client/composer/composer-box.vala
index 70dbb61..e3116d8 100644
--- a/src/client/composer/composer-box.vala
+++ b/src/client/composer/composer-box.vala
@@ -14,7 +14,7 @@ public class ComposerBox : Gtk.Frame, ComposerContainer {
get { return (Gtk.ApplicationWindow) get_toplevel(); }
}
- protected ComposerWidget composer { get; set; }
+ internal ComposerWidget composer { get; set; }
protected Gee.MultiMap<string, string>? old_accelerators { get; set; }
diff --git a/src/client/composer/composer-container.vala b/src/client/composer/composer-container.vala
index 9089430..da82724 100644
--- a/src/client/composer/composer-container.vala
+++ b/src/client/composer/composer-container.vala
@@ -10,7 +10,7 @@
public interface ComposerContainer {
// The ComposerWidget-child.
- protected abstract ComposerWidget composer { get; set; }
+ internal abstract ComposerWidget composer { get; set; }
// Workaround to retrieve all Gtk.Actions with conflicting accelerators
protected const string[] conflicting_actions = {
diff --git a/src/client/composer/composer-embed.vala b/src/client/composer/composer-embed.vala
index 278864f..f11325e 100644
--- a/src/client/composer/composer-embed.vala
+++ b/src/client/composer/composer-embed.vala
@@ -18,7 +18,7 @@ public class ComposerEmbed : Gtk.EventBox, ComposerContainer {
get { return (Gtk.ApplicationWindow) get_toplevel(); }
}
- protected ComposerWidget composer { get; set; }
+ internal ComposerWidget composer { get; set; }
protected Gee.MultiMap<string, string>? old_accelerators { get; set; }
diff --git a/src/client/composer/composer-window.vala b/src/client/composer/composer-window.vala
index 5123308..1b0dc22 100644
--- a/src/client/composer/composer-window.vala
+++ b/src/client/composer/composer-window.vala
@@ -10,15 +10,16 @@
*/
public class ComposerWindow : Gtk.ApplicationWindow, ComposerContainer {
- private bool closing = false;
+ public Gtk.ApplicationWindow top_window {
+ get { return this; }
+ }
- protected ComposerWidget composer { get; set; }
+ internal ComposerWidget composer { get; set; }
protected Gee.MultiMap<string, string>? old_accelerators { get; set; }
- public Gtk.ApplicationWindow top_window {
- get { return this; }
- }
+ private bool closing = false;
+
public ComposerWindow(ComposerWidget composer) {
Object(type: Gtk.WindowType.TOPLEVEL);
diff --git a/src/client/conversation-viewer/conversation-listbox.vala
b/src/client/conversation-viewer/conversation-listbox.vala
index 5f6f538..b14e789 100644
--- a/src/client/conversation-viewer/conversation-listbox.vala
+++ b/src/client/conversation-viewer/conversation-listbox.vala
@@ -230,6 +230,9 @@ public class ConversationListBox : Gtk.ListBox {
private Gee.HashMap<Geary.EmailIdentifier, EmailRow> id_to_row = new
Gee.HashMap<Geary.EmailIdentifier, EmailRow>();
+ // The id of the draft referred to by the current composer.
+ private Geary.EmailIdentifier? draft_id = null;
+
// Last visible row in the list, if any
private ConversationRow? last_row = null;
@@ -427,6 +430,7 @@ public class ConversationListBox : Gtk.ListBox {
public void add_embedded_composer(ComposerEmbed embed, bool is_draft) {
if (is_draft) {
EmailRow? draft = this.id_to_row.get(embed.referred.id);
+ this.draft_id = embed.referred.id;
if (draft != null) {
remove_email(draft.email);
}
@@ -437,8 +441,10 @@ public class ConversationListBox : Gtk.ListBox {
add(row);
update_last_row();
+ embed.composer.draft_id_changed.connect((id) => { this.draft_id = id; });
embed.loaded.connect(() => { row.grab_focus(); });
embed.vanished.connect(() => {
+ this.draft_id = null;
remove(row);
if (is_draft &&
row.email != null &&
@@ -844,7 +850,10 @@ public class ConversationListBox : Gtk.ListBox {
private async void on_conversation_appended_async(
Geary.App.Conversation conversation, Geary.Email part_email) {
- if (!this.id_to_row.contains(part_email.id)) {
+ // Don't add rows that are already present, or that are
+ // currently being edited.
+ if (!(part_email.id in this.id_to_row) &&
+ part_email.id != this.draft_id) {
load_full_email.begin(part_email.id, (obj, ret) => {
try {
load_full_email.end(ret);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]