main-toolbar: Use a header group
This simplifies the code handling the location of the window decorations by using HdyHeaderGroup, whis is designed specifically for that.
This commit is contained in:
parent
bc4f208d36
commit
7d207dbb77
4 changed files with 14 additions and 29 deletions
|
|
@ -14,8 +14,6 @@ public class MainToolbar : Gtk.Box {
|
|||
public string folder { get; set; }
|
||||
// Close button settings
|
||||
public bool show_close_button { get; set; default = true; }
|
||||
public bool show_close_button_left { get; private set; default = true; }
|
||||
public bool show_close_button_right { get; private set; default = true; }
|
||||
// Search and find bar
|
||||
public bool search_open { get; set; default = false; }
|
||||
public bool find_open { get; set; default = false; }
|
||||
|
|
@ -33,7 +31,6 @@ public class MainToolbar : Gtk.Box {
|
|||
private Gtk.ToggleButton search_conversations_button;
|
||||
[GtkChild]
|
||||
private Gtk.MenuButton main_menu_button;
|
||||
private Binding guest_header_binding;
|
||||
|
||||
// Conversation header elements
|
||||
[GtkChild]
|
||||
|
|
@ -51,6 +48,9 @@ public class MainToolbar : Gtk.Box {
|
|||
[GtkChild]
|
||||
private Gtk.ToggleButton find_button;
|
||||
|
||||
[GtkChild]
|
||||
private Hdy.HeaderGroup header_group;
|
||||
|
||||
private bool show_trash_button = true;
|
||||
|
||||
// Load these at construction time
|
||||
|
|
@ -72,10 +72,6 @@ public class MainToolbar : Gtk.Box {
|
|||
this.bind_property("account", this.folder_header, "title", BindingFlags.SYNC_CREATE);
|
||||
this.bind_property("folder", this.folder_header, "subtitle", BindingFlags.SYNC_CREATE);
|
||||
}
|
||||
this.bind_property("show-close-button-left", this.folder_header, "show-close-button",
|
||||
BindingFlags.SYNC_CREATE);
|
||||
this.bind_property("show-close-button-right", this.conversation_header, "show-close-button",
|
||||
BindingFlags.SYNC_CREATE);
|
||||
|
||||
// Assemble the main/mark menus
|
||||
Gtk.Builder builder = new Gtk.Builder.from_resource("/org/gnome/Geary/main-toolbar-menus.ui");
|
||||
|
|
@ -95,27 +91,21 @@ public class MainToolbar : Gtk.Box {
|
|||
|
||||
this.bind_property("find-open", this.find_button, "active",
|
||||
BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
|
||||
|
||||
Gtk.Settings.get_default().notify["gtk-decoration-layout"].connect(set_window_buttons);
|
||||
this.realize.connect(set_window_buttons);
|
||||
}
|
||||
|
||||
public void set_conversation_header(Gtk.HeaderBar header) {
|
||||
conversation_header.hide();
|
||||
header.get_style_context().add_class("geary-titlebar");
|
||||
header.get_style_context().add_class("geary-titlebar-right");
|
||||
guest_header_binding = bind_property("show-close-button-right", header,
|
||||
"show-close-button", BindingFlags.SYNC_CREATE);
|
||||
this.header_group.add_header_bar(header);
|
||||
pack_start(header, true, true);
|
||||
header.decoration_layout = conversation_header.decoration_layout;
|
||||
}
|
||||
|
||||
public void remove_conversation_header(Gtk.HeaderBar header) {
|
||||
remove(header);
|
||||
header.get_style_context().remove_class("geary-titlebar");
|
||||
header.get_style_context().remove_class("geary-titlebar-right");
|
||||
guest_header_binding.unbind();
|
||||
header.decoration_layout = Gtk.Settings.get_default().gtk_decoration_layout;
|
||||
this.header_group.remove_header_bar(header);
|
||||
conversation_header.show();
|
||||
}
|
||||
|
||||
|
|
@ -124,18 +114,6 @@ public class MainToolbar : Gtk.Box {
|
|||
update_conversation_buttons();
|
||||
}
|
||||
|
||||
private void set_window_buttons() {
|
||||
string[] buttons = Gtk.Settings.get_default().gtk_decoration_layout.split(":");
|
||||
this.show_close_button_left = this.show_close_button;
|
||||
this.show_close_button_right = this.show_close_button;
|
||||
this.folder_header.decoration_layout = buttons[0] + ":";
|
||||
this.conversation_header.decoration_layout = (
|
||||
(buttons.length == 2)
|
||||
? ":" + buttons[1]
|
||||
: ""
|
||||
);
|
||||
}
|
||||
|
||||
// Updates tooltip text depending on number of conversations selected.
|
||||
private void update_conversation_buttons() {
|
||||
this.mark_message_button.tooltip_text = ngettext(
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ public class Composer.Headerbar : Gtk.HeaderBar {
|
|||
Gtk.Settings.get_default().notify["gtk-decoration-layout"].connect(
|
||||
on_gtk_decoration_layout_changed
|
||||
);
|
||||
this.show_close_button = this.config.desktop_environment != UNITY;
|
||||
}
|
||||
|
||||
public override void destroy() {
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ public class Composer.Window : Gtk.ApplicationWindow, Container {
|
|||
if (application.config.desktop_environment == UNITY) {
|
||||
composer.embed_header();
|
||||
} else {
|
||||
composer.header.show_close_button = true;
|
||||
set_titlebar(this.composer.header);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
<object class="GtkHeaderBar" id="folder_header">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="show_close_button" bind-source="MainToolbar" bind-property="show_close_button" bind-flags="sync-create"/>
|
||||
<child>
|
||||
<object class="GtkButton" id="compose_new_message_button">
|
||||
<property name="visible">True</property>
|
||||
|
|
@ -100,7 +101,7 @@
|
|||
<object class="GtkHeaderBar" id="conversation_header">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="show_close_button">True</property>
|
||||
<property name="show_close_button" bind-source="MainToolbar" bind-property="show_close_button" bind-flags="sync-create"/>
|
||||
<child>
|
||||
<object class="GtkBox" id="reply_forward_buttons">
|
||||
<property name="visible">True</property>
|
||||
|
|
@ -344,4 +345,10 @@
|
|||
</packing>
|
||||
</child>
|
||||
</template>
|
||||
<object class="HdyHeaderGroup" id="header_group">
|
||||
<headerbars>
|
||||
<headerbar name="folder_header"/>
|
||||
<headerbar name="conversation_header"/>
|
||||
</headerbars>
|
||||
</object>
|
||||
</interface>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue