[geary/wip/743960-split-header-2] Use standard close button on detached composer
- From: Robert Schroll <rschroll src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/743960-split-header-2] Use standard close button on detached composer
- Date: Wed, 4 Mar 2015 06:23:23 +0000 (UTC)
commit b5011f950dbcff808e10ba43c7b36bdd744cbe7d
Author: Robert Schroll <rschroll gmail com>
Date: Tue Mar 3 22:47:31 2015 -0500
Use standard close button on detached composer
Also, rearrange the window management buttons.
src/client/composer/composer-headerbar.vala | 68 +++++++++++++++++++++++----
src/client/composer/composer-window.vala | 3 +-
2 files changed, 60 insertions(+), 11 deletions(-)
---
diff --git a/src/client/composer/composer-headerbar.vala b/src/client/composer/composer-headerbar.vala
index bea026b..e083c70 100644
--- a/src/client/composer/composer-headerbar.vala
+++ b/src/client/composer/composer-headerbar.vala
@@ -9,31 +9,50 @@ public class ComposerHeaderbar : PillHeaderbar {
public ComposerWidget.ComposerState state { get; set; }
public bool show_pending_attachments { get; set; default = false; }
public bool send_enabled { get; set; default = false; }
- public bool show_detach_button { get; set; default = true; }
private Gtk.Button recipients;
private Gtk.Label recipients_label;
+ private Gtk.Box detach_start;
+ private Gtk.Box detach_end;
public ComposerHeaderbar(Gtk.ActionGroup action_group) {
base(action_group);
show_close_button = false;
+ bool rtl = (get_direction() == Gtk.TextDirection.RTL);
+
// Toolbar setup.
Gee.List<Gtk.Button> insert = new Gee.ArrayList<Gtk.Button>();
// Window management.
+ detach_start = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
+ Gtk.Button detach_button = create_toolbar_button(null, ComposerWidget.ACTION_DETACH);
+ detach_button.set_relief(Gtk.ReliefStyle.NONE);
+ if (rtl)
+ detach_button.set_margin_left(6);
+ else
+ detach_button.set_margin_right(6);
+ detach_start.pack_start(detach_button);
+ detach_start.pack_start(new Gtk.Separator(Gtk.Orientation.VERTICAL));
+
+ detach_end = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
+ detach_button = create_toolbar_button(null, ComposerWidget.ACTION_DETACH);
+ detach_button.set_relief(Gtk.ReliefStyle.NONE);
+ if (rtl)
+ detach_button.set_margin_right(6);
+ else
+ detach_button.set_margin_left(6);
+ detach_end.pack_end(detach_button);
+ detach_end.pack_end(new Gtk.Separator(Gtk.Orientation.VERTICAL));
+
insert.add(create_toolbar_button(null, ComposerWidget.ACTION_CLOSE_DISCARD));
insert.add(create_toolbar_button(null, ComposerWidget.ACTION_CLOSE_SAVE));
- Gtk.Button detach_button = create_toolbar_button(null, ComposerWidget.ACTION_DETACH);
- bind_property("show-detach-button", detach_button, "visible", BindingFlags.SYNC_CREATE);
- insert.add(detach_button);
+ Gtk.Box close_buttons = create_pill_buttons(insert, false);
+ insert.clear();
+
Gtk.Button send_button = create_toolbar_button(null, ComposerWidget.ACTION_SEND, true);
send_button.get_style_context().add_class("suggested-action");
- insert.add(send_button);
- Gtk.Box window_buttons = create_pill_buttons(insert, false);
-
- insert.clear();
Gtk.Box attach_buttons = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
Gtk.Button attach_only = create_toolbar_button(null, ComposerWidget.ACTION_ADD_ATTACHMENT);
@@ -61,14 +80,45 @@ public class ComposerHeaderbar : PillHeaderbar {
BindingFlags.SYNC_CREATE);
bind_property("send-enabled", send_button, "sensitive", BindingFlags.SYNC_CREATE);
+ add_start(detach_start);
add_start(attach_buttons);
add_start(recipients);
- add_end(window_buttons);
+#if !GTK_3_12
+ add_end(send_button);
+ add_end(close_buttons);
+#endif
+ add_end(detach_end);
+#if GTK_3_12
+ add_end(close_buttons);
+ add_end(send_button);
+#endif
+ get_style_context().changed.connect(set_detach_button_side);
+ realize.connect(set_detach_button_side);
+ notify["state"].connect((s, p) => {
+ if (state == ComposerWidget.ComposerState.DETACHED) {
+ get_style_context().changed.disconnect(set_detach_button_side);
+ detach_start.visible = detach_end.visible = false;
+ }
+ });
}
public void set_recipients(string label, string tooltip) {
recipients_label.label = label;
recipients.tooltip_text = tooltip;
}
+
+ private void set_detach_button_side() {
+ string layout;
+ bool at_end = false;
+ get_toplevel().style_get("decoration-button-layout", out layout);
+ // Based on logic of close_button_at_end in gtkheaderbar.c: Close button appears
+ // at end iff "close" follows a colon in the layout string.
+ if (layout != null) {
+ int colon_ind = layout.index_of(":");
+ at_end = (colon_ind >= 0 && layout.index_of("close", colon_ind) >= 0);
+ }
+ detach_start.visible = !at_end;
+ detach_end.visible = at_end;
+ }
}
diff --git a/src/client/composer/composer-window.vala b/src/client/composer/composer-window.vala
index f8a892f..ea5048b 100644
--- a/src/client/composer/composer-window.vala
+++ b/src/client/composer/composer-window.vala
@@ -14,9 +14,8 @@ public class ComposerWindow : Gtk.Window, ComposerContainer {
add(composer);
- composer.header.show_detach_button = false;
-
if (!GearyApplication.instance.is_running_unity) {
+ composer.header.show_close_button = true;
if (composer.header.parent != null)
composer.header.parent.remove(composer.header);
set_titlebar(composer.header);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]