[gnome-games/wip/exalm/libhandy2: 19/21] ui: Use HdyLeaflet in preferences window
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/libhandy2: 19/21] ui: Use HdyLeaflet in preferences window
- Date: Mon, 17 Sep 2018 12:06:34 +0000 (UTC)
commit d54deb1a2e79169e4dc90cf36391165423da1925
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date: Wed Sep 12 14:08:34 2018 +0500
ui: Use HdyLeaflet in preferences window
data/ui/preferences-window.ui | 46 ++++++++++++++++++++++++++++++++++++++----
src/main.vala | 1 +
src/ui/preferences-window.vala | 42 +++++++++++++++++++++++++++++++++++---
3 files changed, 82 insertions(+), 7 deletions(-)
---
diff --git a/data/ui/preferences-window.ui b/data/ui/preferences-window.ui
index 3e10d978..b87914b4 100644
--- a/data/ui/preferences-window.ui
+++ b/data/ui/preferences-window.ui
@@ -16,15 +16,17 @@
<property name="transition-type">slide-left-right</property>
<property name="transition-duration">250</property>
<child>
- <object class="GtkBox" id="titlebar_box">
+ <object class="HdyLeaflet" id="titlebar_box">
<property name="visible">True</property>
+ <property name="mode_transition_type">slide</property>
+ <property name="child_transition_type">slide</property>
+ <property name="fold">unfolded</property>
<child>
<object class="GtkHeaderBar" id="left_header_bar">
<property name="name">left_header_bar</property>
<property name="visible">True</property>
<property name="title" translatable="yes">Preferences</property>
- <property name="show-close-button">True</property>
- <property name="decoration_layout">menu</property>
+ <property name="show-close-button">False</property>
</object>
</child>
<child>
@@ -42,6 +44,30 @@
<property name="visible">True</property>
<property name="hexpand">True</property>
<property name="show-close-button">True</property>
+ <child>
+ <object class="GtkButton" id="back_button">
+ <property name="visible">False</property>
+ <signal name="clicked" handler="on_back_clicked"/>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="a11y-back">
+ <property name="accessible-name" translatable="yes">Back</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImage" id="back_image">
+ <property name="visible">True</property>
+ <property name="icon-name">go-previous-symbolic</property>
+ <property name="icon-size">1</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack-type">start</property>
+ </packing>
+ </child>
</object>
</child>
</object>
@@ -57,8 +83,12 @@
<property name="transition-duration">250</property>
<signal name="notify::transition-running" handler="subpage_transition_finished"/>
<child>
- <object class="GtkBox" id="content_box">
+ <object class="HdyLeaflet" id="content_box">
<property name="visible">True</property>
+ <property name="mode_transition_type">slide</property>
+ <property name="child_transition_type">slide</property>
+ <property name="fold">unfolded</property>
+ <signal name="notify::fold" handler="on_fold_changed" after="yes"/>
<child>
<object class="GtkStackSidebar" id="sidebar">
<property name="margin-top">4</property>
@@ -86,6 +116,7 @@
<property name="expand">True</property>
<property name="visible-child">video_page</property>
<property name="transition-type">GTK_STACK_TRANSITION_TYPE_CROSSFADE</property>
+ <property name="width-request">300</property>
<child>
<object class="GamesPreferencesPageVideo" id="video_page">
<property name="visible">True</property>
@@ -127,4 +158,11 @@
<widget name="sidebar"/>
</widgets>
</object>
+ <object class="GtkSizeGroup">
+ <property name="mode">GTK_SIZE_GROUP_HORIZONTAL</property>
+ <widgets>
+ <widget name="right_header_bar"/>
+ <widget name="stack"/>
+ </widgets>
+ </object>
</interface>
diff --git a/src/main.vala b/src/main.vala
index 7aa30afe..413171b0 100644
--- a/src/main.vala
+++ b/src/main.vala
@@ -8,6 +8,7 @@ int main (string[] args) {
Grl.init (ref args);
typeof (Hdy.Column).ensure ();
+ typeof (Hdy.Leaflet).ensure ();
typeof (Hdy.TitleBar).ensure ();
var app = new Games.Application ();
diff --git a/src/ui/preferences-window.vala b/src/ui/preferences-window.vala
index 54d86c48..6b780283 100644
--- a/src/ui/preferences-window.vala
+++ b/src/ui/preferences-window.vala
@@ -7,16 +7,23 @@ private class Games.PreferencesWindow : Gtk.Window {
[GtkChild]
private Gtk.Stack titlebar_stack;
[GtkChild]
- private Gtk.Box titlebar_box;
+ private Hdy.Leaflet titlebar_box;
+ [GtkChild]
+ private Gtk.HeaderBar left_header_bar;
[GtkChild]
private Gtk.HeaderBar right_header_bar;
[GtkChild]
private Gtk.Stack main_stack;
[GtkChild]
- private Gtk.Box content_box;
+ private Hdy.Leaflet content_box;
+ [GtkChild]
+ private Gtk.StackSidebar sidebar;
[GtkChild]
private Gtk.Stack stack;
+ [GtkChild]
+ private Gtk.Button back_button;
+
private PreferencesSubpage _subpage;
public PreferencesSubpage subpage {
get { return _subpage; }
@@ -43,6 +50,9 @@ private class Games.PreferencesWindow : Gtk.Window {
titlebar_stack.add (header_bar);
titlebar_stack.visible_child = header_bar;
+
+ content_box.visible_child = stack;
+ titlebar_box.visible_child = right_header_bar;
}
_subpage = value;
@@ -57,10 +67,17 @@ private class Games.PreferencesWindow : Gtk.Window {
public PreferencesWindow () {
stack.notify["visible-child-name"].connect (visible_child_changed);
- visible_child_changed ();
+ update_ui ();
}
private void visible_child_changed () {
+ content_box.visible_child = stack;
+ titlebar_box.visible_child = right_header_bar;
+
+ update_ui ();
+ }
+
+ private void update_ui () {
var page = stack.visible_child as PreferencesPage;
if (page == null) {
right_header_bar.title = "";
@@ -86,4 +103,23 @@ private class Games.PreferencesWindow : Gtk.Window {
titlebar_stack.remove (previous_subpage.header_bar);
previous_subpage = null;
}
+
+ [GtkCallback]
+ private void on_back_clicked () {
+ content_box.visible_child = sidebar;
+ titlebar_box.visible_child = left_header_bar;
+ }
+
+ [GtkCallback]
+ private void on_fold_changed (Object object, ParamSpec paramSpec) {
+ var folded = (content_box.fold == Hdy.Fold.FOLDED);
+
+ left_header_bar.show_close_button = folded;
+ back_button.visible = folded;
+
+ if (folded)
+ stack.transition_type = Gtk.StackTransitionType.NONE;
+ else
+ stack.transition_type = Gtk.StackTransitionType.CROSSFADE;
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]