diff --git a/src/client/composer/composer-widget.vala b/src/client/composer/composer-widget.vala index 9253eab4..67b4c439 100644 --- a/src/client/composer/composer-widget.vala +++ b/src/client/composer/composer-widget.vala @@ -316,6 +316,7 @@ public class Composer.Widget : Gtk.EventBox, Geary.BaseInterface { private Gtk.ComboBoxText from_multiple; private Gee.ArrayList from_list = new Gee.ArrayList(); + [GtkChild] Gtk.Box to_row; [GtkChild] private Gtk.Box to_box; [GtkChild] @@ -323,25 +324,30 @@ public class Composer.Widget : Gtk.EventBox, Geary.BaseInterface { private EmailEntry to_entry; private Components.EntryUndo to_undo; - [GtkChild] - private Gtk.Revealer extended_fields_revealer; + [GtkChild] private Gtk.Revealer extended_fields_revealer; + [GtkChild] Gtk.Box extended_fields_box; + [GtkChild] private Gtk.ToggleButton show_extended_fields; + [GtkChild] private Gtk.Box filled_fields; + [GtkChild] Gtk.Box cc_row; [GtkChild] - private Gtk.EventBox cc_box; + private Gtk.Box cc_box; [GtkChild] private Gtk.Label cc_label; private EmailEntry cc_entry; private Components.EntryUndo cc_undo; + [GtkChild] Gtk.Box bcc_row; [GtkChild] - private Gtk.EventBox bcc_box; + private Gtk.Box bcc_box; [GtkChild] private Gtk.Label bcc_label; private EmailEntry bcc_entry; private Components.EntryUndo bcc_undo; + [GtkChild] Gtk.Box reply_to_row; [GtkChild] - private Gtk.EventBox reply_to_box; + private Gtk.Box reply_to_box; [GtkChild] private Gtk.Label reply_to_label; private EmailEntry reply_to_entry; @@ -516,18 +522,21 @@ public class Composer.Widget : Gtk.EventBox, Geary.BaseInterface { this.to_undo = new Components.EntryUndo(this.to_entry); this.cc_entry = new EmailEntry(this); + this.cc_entry.hexpand = true; this.cc_entry.changed.connect(on_envelope_changed); this.cc_box.add(cc_entry); this.cc_label.set_mnemonic_widget(this.cc_entry); this.cc_undo = new Components.EntryUndo(this.cc_entry); this.bcc_entry = new EmailEntry(this); + this.bcc_entry.hexpand = true; this.bcc_entry.changed.connect(on_envelope_changed); this.bcc_box.add(bcc_entry); this.bcc_label.set_mnemonic_widget(this.bcc_entry); this.bcc_undo = new Components.EntryUndo(this.bcc_entry); this.reply_to_entry = new EmailEntry(this); + this.reply_to_entry.hexpand = true; this.reply_to_entry.changed.connect(on_envelope_changed); this.reply_to_box.add(reply_to_entry); this.reply_to_label.set_mnemonic_widget(this.reply_to_entry); @@ -1036,7 +1045,6 @@ public class Composer.Widget : Gtk.EventBox, Geary.BaseInterface { switch (this.compose_type) { // Restoring a draft case ComposeType.NEW_MESSAGE: - bool show_extended = false; if (referred.from != null) this.from = referred.from; if (referred.to != null) @@ -1044,11 +1052,9 @@ public class Composer.Widget : Gtk.EventBox, Geary.BaseInterface { if (referred.cc != null) this.cc_entry.addresses = referred.cc; if (referred.bcc != null) { - show_extended = true; this.bcc_entry.addresses = referred.bcc; } if (referred.reply_to != null) { - show_extended = true; this.reply_to_entry.addresses = referred.reply_to; } if (referred.in_reply_to != null) @@ -1067,14 +1073,6 @@ public class Composer.Widget : Gtk.EventBox, Geary.BaseInterface { } catch (Error error) { debug("Error getting draft message body: %s", error.message); } - if (show_extended) { - this.editor_actions.change_action_state( - ACTION_SHOW_EXTENDED_HEADERS, true - ); - this.composer_actions.change_action_state( - ACTION_SHOW_EXTENDED_HEADERS, true - ); - } break; case ComposeType.REPLY: @@ -1097,6 +1095,8 @@ public class Composer.Widget : Gtk.EventBox, Geary.BaseInterface { Geary.RFC822.TextFormat.HTML); break; } + + update_extended_headers(); return referred_quote; } @@ -2135,10 +2135,44 @@ public class Composer.Widget : Gtk.EventBox, Geary.BaseInterface { this.application.config.compose_as_html = compose_as_html; } + private void reparent_widget(Gtk.Widget child, Gtk.Container new_parent) { + ((Gtk.Container) child.get_parent()).remove(child); + new_parent.add(child); + } + + private void update_extended_headers(bool reorder=true) { + bool cc = this.cc_entry.addresses != null; + bool bcc = this.bcc_entry.addresses != null; + bool reply_to = this.reply_to_entry.addresses != null; + + if (reorder) { + if (cc) { + reparent_widget(this.cc_row, this.filled_fields); + } else { + reparent_widget(this.cc_row, this.extended_fields_box); + } + if (bcc) { + reparent_widget(this.bcc_row, this.filled_fields); + } else { + reparent_widget(this.bcc_row, this.extended_fields_box); + } + if (reply_to) { + reparent_widget(this.reply_to_row, this.filled_fields); + } else { + reparent_widget(this.reply_to_row, this.extended_fields_box); + } + } + + this.show_extended_fields.visible = !(cc && bcc && reply_to); + } + private void on_show_extended_headers_toggled(GLib.SimpleAction? action, GLib.Variant? new_state) { bool show_extended = new_state.get_boolean(); action.set_state(show_extended); + + update_extended_headers(); + this.extended_fields_revealer.reveal_child = show_extended; if (show_extended && this.current_mode == INLINE_COMPACT) { @@ -2607,6 +2641,7 @@ public class Composer.Widget : Gtk.EventBox, Geary.BaseInterface { [GtkCallback] private void on_envelope_changed() { draft_changed(); + update_extended_headers(false); } private void on_from_changed() { diff --git a/ui/composer-widget.ui b/ui/composer-widget.ui index 57ee5157..f79c16c5 100644 --- a/ui/composer-widget.ui +++ b/ui/composer-widget.ui @@ -118,7 +118,7 @@ - + True False 6 @@ -152,7 +152,7 @@ - + True True True @@ -190,21 +190,27 @@ 13 + + + True + False + vertical + + True False - + True False - 6 vertical - 6 - + True False + 6 6 @@ -227,10 +233,13 @@ - + True False True + False @@ -246,10 +255,11 @@ - + True False 6 + 6 True @@ -271,10 +281,13 @@ - + True False True + False @@ -290,10 +303,11 @@ - + True False 6 + 6 True @@ -315,10 +329,13 @@ - + True False True + False