[geary: 1/2] composer: Do not hide nonempty extended fields
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary: 1/2] composer: Do not hide nonempty extended fields
- Date: Thu, 23 Jan 2020 09:23:34 +0000 (UTC)
commit f5b6bd6e7c1c04ad723c1a04f967686062dca0b7
Author: James Westman <flyingpimonster gmail com>
Date: Tue Jan 21 13:14:31 2020 -0600
composer: Do not hide nonempty extended fields
This way, you won't forget about an important field (such as CC) if the
extended fields are hidden.
Fixes #675.
src/client/composer/composer-widget.vala | 67 ++++++++++++++++++++++++--------
ui/composer-widget.ui | 39 +++++++++++++------
2 files changed, 79 insertions(+), 27 deletions(-)
---
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<FromAddressMap> from_list = new Gee.ArrayList<FromAddressMap>();
+ [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 @@
</packing>
</child>
<child>
- <object class="GtkBox">
+ <object class="GtkBox" id="to_row">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_bottom">6</property>
@@ -152,7 +152,7 @@
<placeholder/>
</child>
<child>
- <object class="GtkToggleButton">
+ <object class="GtkToggleButton" id="show_extended_fields">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
@@ -190,21 +190,27 @@
<property name="position">13</property>
</packing>
</child>
+ <child>
+ <object class="GtkBox" id="filled_fields">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ </object>
+ </child>
<child>
<object class="GtkRevealer" id="extended_fields_revealer">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <object class="GtkBox">
+ <object class="GtkBox" id="extended_fields_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="margin_bottom">6</property>
<property name="orientation">vertical</property>
- <property name="spacing">6</property>
<child>
- <object class="GtkBox">
+ <object class="GtkBox" id="cc_row">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="margin_bottom">6</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="cc_label">
@@ -227,10 +233,13 @@
</packing>
</child>
<child>
- <object class="GtkEventBox" id="cc_box">
+ <object class="GtkBox" id="cc_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
+ <style>
+ <class name="linked"/>
+ </style>
</object>
<packing>
<property name="expand">False</property>
@@ -246,10 +255,11 @@
</packing>
</child>
<child>
- <object class="GtkBox">
+ <object class="GtkBox" id="bcc_row">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
+ <property name="margin_bottom">6</property>
<child>
<object class="GtkLabel" id="bcc_label">
<property name="visible">True</property>
@@ -271,10 +281,13 @@
</packing>
</child>
<child>
- <object class="GtkEventBox" id="bcc_box">
+ <object class="GtkBox" id="bcc_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
+ <style>
+ <class name="linked"/>
+ </style>
</object>
<packing>
<property name="expand">False</property>
@@ -290,10 +303,11 @@
</packing>
</child>
<child>
- <object class="GtkBox">
+ <object class="GtkBox" id="reply_to_row">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
+ <property name="margin_bottom">6</property>
<child>
<object class="GtkLabel" id="reply_to_label">
<property name="visible">True</property>
@@ -315,10 +329,13 @@
</packing>
</child>
<child>
- <object class="GtkEventBox" id="reply_to_box">
+ <object class="GtkBox" id="reply_to_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
+ <style>
+ <class name="linked"/>
+ </style>
</object>
<packing>
<property name="expand">False</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]