[gnome-contacts] Window: Handle window decorations with a Hdy.HeaderGroup
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts] Window: Handle window decorations with a Hdy.HeaderGroup
- Date: Tue, 30 Oct 2018 21:59:28 +0000 (UTC)
commit 38e1df7568b9be9d418d0d34b33ab37b5e5f7493
Author: Adrien Plazas <kekun plazas laposte net>
Date: Wed Oct 17 14:09:05 2018 +0200
Window: Handle window decorations with a Hdy.HeaderGroup
This avoids to handle the window decoration layout of each heaader bar
by hand and simplifies the code.
data/ui/contacts-window.ui | 6 ++++++
src/contacts-window.vala | 17 +++++------------
2 files changed, 11 insertions(+), 12 deletions(-)
---
diff --git a/data/ui/contacts-window.ui b/data/ui/contacts-window.ui
index 12498ad..4c0e736 100644
--- a/data/ui/contacts-window.ui
+++ b/data/ui/contacts-window.ui
@@ -397,4 +397,10 @@
<widget name="loading_box"/>
</widgets>
</object>
+ <object class="HdyHeaderGroup" id="header_group">
+ <headerbars>
+ <headerbar name="left_header"/>
+ <headerbar name="right_header"/>
+ </headerbars>
+ </object>
</interface>
diff --git a/src/contacts-window.vala b/src/contacts-window.vala
index 3734293..bf0f1ff 100644
--- a/src/contacts-window.vala
+++ b/src/contacts-window.vala
@@ -17,6 +17,7 @@
using Gee;
using Gtk;
+using Hdy;
using Folks;
[GtkTemplate (ui = "/org/gnome/Contacts/ui/contacts-window.ui")]
@@ -54,6 +55,9 @@ public class Contacts.Window : Gtk.ApplicationWindow {
private Button cancel_button;
[GtkChild]
private Button done_button;
+ // Somehow needed for the header group to work
+ [GtkChild]
+ private HeaderGroup header_group;
// The 2 panes the window consists of
private ListPane list_pane;
@@ -96,7 +100,6 @@ public class Contacts.Window : Gtk.ApplicationWindow {
bind_dimension_properties_to_settings ();
create_contact_pane ();
- set_headerbar_layout ();
connect_button_signals ();
restore_window_size_and_position_from_settings ();
}
@@ -193,6 +196,7 @@ public class Contacts.Window : Gtk.ApplicationWindow {
// UI when we're not editing of selecting stuff
this.add_button.visible
= this.hamburger_menu_button.visible
+ = this.left_header.show_close_button
= this.right_header.show_close_button
= (this.state == UiState.NORMAL || this.state == UiState.SHOWING);
@@ -315,17 +319,6 @@ public class Contacts.Window : Gtk.ApplicationWindow {
list_pane.filter_entry.set_text (query);
}
- private void set_headerbar_layout () {
- // Propagate the decoration layout to the separate headerbars, so
- // that we know, for example, on which side the close button should be.
- string layout_desc = Gtk.Settings.get_default ().gtk_decoration_layout;
- string[] tokens = layout_desc.split (":", 2);
- if (tokens != null) {
- this.right_header.decoration_layout = ":%s".printf (tokens[1]);
- this.left_header.decoration_layout = tokens[0];
- }
- }
-
private void connect_button_signals () {
this.select_cancel_button.clicked.connect (() => { this.state = UiState.NORMAL; });
this.done_button.clicked.connect (() => stop_editing ());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]