Commit fa94cb75 authored by Jim Nelson's avatar Jim Nelson
Browse files

Merge branch 'master' into bug/7512-expunge

parents c0078199 1b270b8c
......@@ -609,7 +609,8 @@ public class ComposerWindow : Gtk.Window {
return true;
}
public Geary.ComposedEmail get_composed_email(DateTime? date_override = null) {
public Geary.ComposedEmail get_composed_email(DateTime? date_override = null,
bool only_html = false) {
Geary.ComposedEmail email = new Geary.ComposedEmail(
date_override ?? new DateTime.now_local(),
new Geary.RFC822.MailboxAddresses.from_rfc822_string(from)
......@@ -635,9 +636,10 @@ public class ComposerWindow : Gtk.Window {
email.attachment_files.add_all(attachment_files);
if (compose_as_html)
if (compose_as_html || only_html)
email.body_html = get_html();
email.body_text = get_text();
if (!only_html)
email.body_text = get_text();
// User-Agent
email.mailer = GearyApplication.PRGNAME + "/" + GearyApplication.VERSION;
......@@ -825,8 +827,10 @@ public class ComposerWindow : Gtk.Window {
flags.add(Geary.EmailFlags.DRAFT);
try {
// only save HTML drafts to avoid resetting the DOM (which happens when converting the
// HTML to flowed text)
draft_id = yield drafts_folder.create_email_async(new Geary.RFC822.Message.from_composed_email(
get_composed_email()), flags, null, draft_id, null);
get_composed_email(null, true)), flags, null, draft_id, null);
draft_save_label.label = DRAFT_SAVED_TEXT;
} catch (Error e) {
......
......@@ -11,13 +11,13 @@ public class ContactListStore : Gtk.ListStore {
public enum Column {
CONTACT_OBJECT,
CONTACT_MARKUP_NAME,
LAST_KEY;
PRIOR_KEYS;
public static Type[] get_types() {
return {
typeof (Geary.Contact), // CONTACT_OBJECT
typeof (string), // CONTACT_MARKUP_NAME
typeof (string) // LAST_KEY
typeof (Gee.HashSet) // PRIOR_KEYS
};
}
}
......@@ -59,19 +59,18 @@ public class ContactListStore : Gtk.ListStore {
// Highlighted result should be Markup.escaped for presentation to the user
public void set_highlighted_result(Gtk.TreeIter iter, string highlighted_result,
string current_address_key) {
// get the last key for this row for comparison
GLib.Value last_key_value;
get_value(iter, Column.LAST_KEY, out last_key_value);
string? last_key = last_key_value.get_string();
// get the previous keys for this row for comparison
GLib.Value prior_keys_value;
get_value(iter, Column.PRIOR_KEYS, out prior_keys_value);
Gee.HashSet<string> prior_keys = (Gee.HashSet<string>) prior_keys_value.get_object();
// Changing a row in the list store causes Gtk.EntryCompletion to re-evaluate
// completion_match_func for that row. Thus we need to make sure the key has
// actually changed before settings the highlighting--otherwise we will cause
// an infinite loop.
if (current_address_key != last_key) {
set(iter,
Column.CONTACT_MARKUP_NAME, highlighted_result,
Column.LAST_KEY, current_address_key, -1);
if (!(current_address_key in prior_keys)) {
prior_keys.add(current_address_key);
set(iter, Column.CONTACT_MARKUP_NAME, highlighted_result, -1);
}
}
......@@ -85,7 +84,7 @@ public class ContactListStore : Gtk.ListStore {
set(iter,
Column.CONTACT_OBJECT, contact,
Column.CONTACT_MARKUP_NAME, Markup.escape_text(full_address),
Column.LAST_KEY, "");
Column.PRIOR_KEYS, new Gee.HashSet<string>());
}
private void update_contact(Geary.Contact updated_contact) {
......
......@@ -288,14 +288,11 @@ public string decorate_quotes(string text) throws Error {
return outtext;
}
// This will modify/reset the DOM
public string html_to_flowed_text(WebKit.DOM.Document doc) {
// Work on a copy of the document's body.
WebKit.DOM.HTMLElement? body = Util.DOM.clone_node(doc.get_body());
assert(body != null);
WebKit.DOM.NodeList blockquotes;
try {
blockquotes = body.query_selector_all("blockquote");
blockquotes = doc.query_selector_all("blockquote");
} catch (Error error) {
debug("Error selecting blockquotes: %s", error.message);
return "";
......@@ -321,7 +318,7 @@ public string html_to_flowed_text(WebKit.DOM.Document doc) {
}
// Reassemble plain text out of parts, replace non-breaking space with regular space
string doctext = resolve_nesting(body.get_inner_text(), bqtexts).replace("\xc2\xa0", " ");
string doctext = resolve_nesting(doc.get_body().get_inner_text(), bqtexts).replace("\xc2\xa0", " ");
// Reassemble DOM
for (int i = 0; i < nbq; i++) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment