[gnome-games/wip/exalm/libhandy: 57/58] wip



commit 416907eeebe21712c81a7c4f13159f2ccee1b80a
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Tue Aug 7 19:33:09 2018 +0500

    wip

 data/org.gnome.Games.gresource.xml       |  1 +
 data/ui/preferences-back-button.ui       | 23 +++++++++
 data/ui/preferences-page-controllers.ui  | 85 ++++++++++++++++++--------------
 data/ui/preferences-page-plugins-item.ui |  1 +
 data/ui/preferences-page-plugins.ui      | 27 ++++++----
 data/ui/preferences-page-video.ui        | 47 +++++++++++-------
 data/ui/preferences-window.ui            | 21 ++++++--
 src/meson.build                          |  1 +
 src/ui/preferences-back-button.vala      |  5 ++
 src/ui/preferences-window.vala           | 41 +++++++++++++--
 10 files changed, 179 insertions(+), 73 deletions(-)
---
diff --git a/data/org.gnome.Games.gresource.xml b/data/org.gnome.Games.gresource.xml
index dc309b63..15d54314 100644
--- a/data/org.gnome.Games.gresource.xml
+++ b/data/org.gnome.Games.gresource.xml
@@ -32,6 +32,7 @@
     <file preprocess="xml-stripblanks">ui/media-menu-button.ui</file>
     <file preprocess="xml-stripblanks">ui/media-selector.ui</file>
     <file preprocess="xml-stripblanks">ui/platform-list-item.ui</file>
+    <file preprocess="xml-stripblanks">ui/preferences-back-button.ui</file>
     <file preprocess="xml-stripblanks">ui/preferences-page-controllers.ui</file>
     <file preprocess="xml-stripblanks">ui/preferences-page-plugins.ui</file>
     <file preprocess="xml-stripblanks">ui/preferences-page-plugins-item.ui</file>
diff --git a/data/ui/preferences-back-button.ui b/data/ui/preferences-back-button.ui
new file mode 100644
index 00000000..94da9a7a
--- /dev/null
+++ b/data/ui/preferences-back-button.ui
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <template class="GamesPreferencesBackButton" parent="GtkButton">
+    <property name="visible">True</property>
+    <property name="valign">center</property>
+    <property name="use-underline">True</property>
+    <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>
+  </template>
+</interface>
diff --git a/data/ui/preferences-page-controllers.ui b/data/ui/preferences-page-controllers.ui
index bc39e828..b4148a28 100644
--- a/data/ui/preferences-page-controllers.ui
+++ b/data/ui/preferences-page-controllers.ui
@@ -15,57 +15,66 @@
     <child>
       <object class="GtkScrolledWindow" id="main_stack_child_holder">
         <property name="visible">True</property>
+        <property name="hscrollbar-policy">never</property>
         <child>
           <object class="GtkViewport">
             <property name="visible">True</property>
             <child>
-              <object class="GtkBox">
+              <object class="HdyColumn" type-func="hdy_column_get_type">
                 <property name="visible">True</property>
-                <property name="orientation">vertical</property>
-                <property name="margin">12</property>
-                <property name="spacing">12</property>
+                <property name="expand">True</property>
+                <property name="maximum_width">600</property>
                 <child>
-                  <object class="GtkLabel" id="gamepads_label">
+                  <object class="GtkBox">
                     <property name="visible">True</property>
-                    <property name="halign">start</property>
-                    <property name="label" translatable="yes">Gamepads</property>
-                    <attributes>
-                      <attribute name="weight" value="bold"/>
-                    </attributes>
-                  </object>
-                </child>
-                <child>
-                  <object class="GtkFrame" id="gamepads_frame">
-                    <property name="visible">True</property>
-                    <property name="shadow_type">in</property>
+                    <property name="orientation">vertical</property>
+                    <property name="margin">12</property>
+                    <property name="spacing">12</property>
+                    <property name="width-request">300</property>
                     <child>
-                      <object class="GtkListBox" id="gamepads_list_box">
+                      <object class="GtkLabel" id="gamepads_label">
                         <property name="visible">True</property>
-                        <property name="selection_mode">none</property>
-                        <signal name="row-activated" handler="gamepads_list_box_row_activated"/>
+                        <property name="halign">start</property>
+                        <property name="label" translatable="yes">Gamepads</property>
+                        <attributes>
+                          <attribute name="weight" value="bold"/>
+                        </attributes>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkFrame" id="gamepads_frame">
+                        <property name="visible">True</property>
+                        <property name="shadow_type">in</property>
+                        <child>
+                          <object class="GtkListBox" id="gamepads_list_box">
+                            <property name="visible">True</property>
+                            <property name="selection_mode">none</property>
+                            <signal name="row-activated" handler="gamepads_list_box_row_activated"/>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkLabel">
+                        <property name="visible">True</property>
+                        <property name="halign">start</property>
+                        <property name="label" translatable="yes">Keyboard</property>
+                        <attributes>
+                          <attribute name="weight" value="bold"/>
+                        </attributes>
                       </object>
                     </child>
-                  </object>
-                </child>
-                <child>
-                  <object class="GtkLabel">
-                    <property name="visible">True</property>
-                    <property name="halign">start</property>
-                    <property name="label" translatable="yes">Keyboard</property>
-                    <attributes>
-                      <attribute name="weight" value="bold"/>
-                    </attributes>
-                  </object>
-                </child>
-                <child>
-                  <object class="GtkFrame">
-                    <property name="visible">True</property>
-                    <property name="shadow_type">in</property>
                     <child>
-                      <object class="GtkListBox" id="keyboard_list_box">
+                      <object class="GtkFrame">
                         <property name="visible">True</property>
-                        <property name="selection_mode">none</property>
-                        <signal name="row-activated" handler="keyboard_list_box_row_activated"/>
+                        <property name="shadow_type">in</property>
+                        <child>
+                          <object class="GtkListBox" id="keyboard_list_box">
+                            <property name="visible">True</property>
+                            <property name="selection_mode">none</property>
+                            <signal name="row-activated" handler="keyboard_list_box_row_activated"/>
+                          </object>
+                        </child>
                       </object>
                     </child>
                   </object>
diff --git a/data/ui/preferences-page-plugins-item.ui b/data/ui/preferences-page-plugins-item.ui
index 7bb477e3..c71c4005 100644
--- a/data/ui/preferences-page-plugins-item.ui
+++ b/data/ui/preferences-page-plugins-item.ui
@@ -15,6 +15,7 @@
       <object class="GtkLabel" id="plugin_description">
         <property name="visible">true</property>
         <property name="xalign">0</property>
+        <property name="wrap">true</property>
         <style>
           <class name="dim-label" />
         </style>
diff --git a/data/ui/preferences-page-plugins.ui b/data/ui/preferences-page-plugins.ui
index e135a45e..946faedf 100644
--- a/data/ui/preferences-page-plugins.ui
+++ b/data/ui/preferences-page-plugins.ui
@@ -6,23 +6,32 @@
     <child>
       <object class="GtkScrolledWindow" id="plugins">
         <property name="visible">true</property>
+        <property name="hscrollbar-policy">never</property>
         <child>
           <object class="GtkViewport">
             <property name="visible">true</property>
             <child>
-              <object class="GtkBox">
+              <object class="HdyColumn" type-func="hdy_column_get_type">
                 <property name="visible">True</property>
-                <property name="orientation">vertical</property>
-                <property name="margin">12</property>
-                <property name="spacing">12</property>
+                <property name="expand">True</property>
+                <property name="maximum_width">600</property>
                 <child>
-                  <object class="GtkFrame">
-                    <property name="visible">true</property>
-                    <property name="shadow-type">in</property>
+                  <object class="GtkBox">
+                    <property name="visible">True</property>
+                    <property name="orientation">vertical</property>
+                    <property name="margin">12</property>
+                    <property name="spacing">12</property>
+                    <property name="width-request">300</property>
                     <child>
-                      <object class="GtkListBox" id="list_box">
-                        <property name="selection-mode">none</property>
+                      <object class="GtkFrame">
                         <property name="visible">true</property>
+                        <property name="shadow-type">in</property>
+                        <child>
+                          <object class="GtkListBox" id="list_box">
+                            <property name="selection-mode">none</property>
+                            <property name="visible">true</property>
+                          </object>
+                        </child>
                       </object>
                     </child>
                   </object>
diff --git a/data/ui/preferences-page-video.ui b/data/ui/preferences-page-video.ui
index 3f0c038e..ebd8d4be 100644
--- a/data/ui/preferences-page-video.ui
+++ b/data/ui/preferences-page-video.ui
@@ -5,34 +5,43 @@
     <child>
       <object class="GtkScrolledWindow">
         <property name="visible">True</property>
+        <property name="hscrollbar-policy">never</property>
         <child>
           <object class="GtkViewport">
             <property name="visible">True</property>
             <child>
-              <object class="GtkBox">
+              <object class="HdyColumn" type-func="hdy_column_get_type">
                 <property name="visible">True</property>
-                <property name="orientation">vertical</property>
-                <property name="margin">12</property>
-                <property name="spacing">12</property>
+                <property name="expand">True</property>
+                <property name="maximum_width">600</property>
                 <child>
-                  <object class="GtkLabel">
+                  <object class="GtkBox">
                     <property name="visible">True</property>
-                    <property name="halign">start</property>
-                    <property name="label" translatable="yes">Filter</property>
-                    <attributes>
-                      <attribute name="weight" value="bold"/>
-                    </attributes>
-                  </object>
-                </child>
-                <child>
-                  <object class="GtkFrame">
-                    <property name="visible">True</property>
-                    <property name="shadow_type">in</property>
+                    <property name="orientation">vertical</property>
+                    <property name="margin">12</property>
+                    <property name="spacing">12</property>
+                    <property name="width-request">300</property>
+                    <child>
+                      <object class="GtkLabel">
+                        <property name="visible">True</property>
+                        <property name="halign">start</property>
+                        <property name="label" translatable="yes">Filter</property>
+                        <attributes>
+                          <attribute name="weight" value="bold"/>
+                        </attributes>
+                      </object>
+                    </child>
                     <child>
-                      <object class="GtkListBox" id="filter_list_box">
+                      <object class="GtkFrame">
                         <property name="visible">True</property>
-                        <property name="selection_mode">none</property>
-                        <signal name="row-activated" handler="filter_list_box_row_activated"/>
+                        <property name="shadow_type">in</property>
+                        <child>
+                          <object class="GtkListBox" id="filter_list_box">
+                            <property name="visible">True</property>
+                            <property name="selection_mode">none</property>
+                            <signal name="row-activated" handler="filter_list_box_row_activated"/>
+                          </object>
+                        </child>
                       </object>
                     </child>
                   </object>
diff --git a/data/ui/preferences-window.ui b/data/ui/preferences-window.ui
index a0a6e93a..6cdec08c 100644
--- a/data/ui/preferences-window.ui
+++ b/data/ui/preferences-window.ui
@@ -8,15 +8,17 @@
     <property name="default-height">500</property>
     <property name="window-position">GTK_WIN_POS_CENTER_ON_PARENT</property>
     <child type="titlebar">
-      <object class="GtkBox" id="titlebar_box">
+      <object class="HdyLeaflet" type-func="hdy_leaflet_get_type" 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>
@@ -28,8 +30,12 @@
       </object>
     </child>
     <child>
-      <object class="GtkBox" id="hbox1">
+      <object class="HdyLeaflet" type-func="hdy_leaflet_get_type" id="main_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="main_box_notify_fold" after="yes" swapped="no"/>
         <child>
           <object class="GtkBox" id="sidebar_vbox">
             <property name="orientation">vertical</property>
@@ -60,6 +66,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">200</property>
             <child>
               <object class="GamesPreferencesPageVideo" id="video_page">
                 <property name="visible">True</property>
@@ -99,4 +106,10 @@
       <widget name="sidebar"/>
     </widgets>
   </object>
+  <object class="GtkSizeGroup" id="content_size_group">
+    <property name="mode">GTK_SIZE_GROUP_HORIZONTAL</property>
+    <widgets>
+      <widget name="stack"/>
+    </widgets>
+  </object>
 </interface>
diff --git a/src/meson.build b/src/meson.build
index 477759c6..26b2ec3e 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -154,6 +154,7 @@ vala_sources = [
   'ui/message-dialog.vala',
   'ui/platform-list-item.vala',
   'ui/platforms-view.vala',
+  'ui/preferences-back-button.vala',
   'ui/preferences-page.vala',
   'ui/preferences-page-controllers.vala',
   'ui/preferences-page-plugins.vala',
diff --git a/src/ui/preferences-back-button.vala b/src/ui/preferences-back-button.vala
new file mode 100644
index 00000000..0e3881a4
--- /dev/null
+++ b/src/ui/preferences-back-button.vala
@@ -0,0 +1,5 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+[GtkTemplate (ui = "/org/gnome/Games/ui/preferences-back-button.ui")]
+private class Games.PreferencesBackButton : Gtk.Button {
+}
diff --git a/src/ui/preferences-window.vala b/src/ui/preferences-window.vala
index 28d4e16e..cac46cb2 100644
--- a/src/ui/preferences-window.vala
+++ b/src/ui/preferences-window.vala
@@ -3,27 +3,47 @@
 [GtkTemplate (ui = "/org/gnome/Games/ui/preferences-window.ui")]
 private class Games.PreferencesWindow : Gtk.Window {
        [GtkChild]
-       private Gtk.Box titlebar_box;
+       private Hdy.Leaflet titlebar_box;
        [GtkChild]
        private Gtk.HeaderBar left_header_bar;
        [GtkChild]
        private Gtk.Separator header_separator;
        [GtkChild]
+       private Hdy.Leaflet main_box;
+       [GtkChild]
        private Gtk.Box sidebar_vbox;
        [GtkChild]
        private Gtk.Separator separator;
        [GtkChild]
        private Gtk.Stack stack;
+       [GtkChild]
+       private Gtk.SizeGroup content_size_group;
+
+       private PreferencesBackButton back_button;
 
        private Gtk.HeaderBar _right_header_bar;
        public Gtk.HeaderBar right_header_bar {
                get { return _right_header_bar; }
                set {
-                       if (_right_header_bar != null)
+                       if (_right_header_bar != null) {
+                               _right_header_bar.remove (back_button);
                                titlebar_box.remove (_right_header_bar);
+                               content_size_group.remove_widget (_right_header_bar);
+                       }
                        if (value != null) {
-                               titlebar_box.pack_end (value);
+                               titlebar_box.add (value);
+                               content_size_group.add_widget (value);
+                               value.expand = true;
                                value.show_close_button = !immersive_mode;
+
+                               back_button = new PreferencesBackButton ();
+                               back_button.clicked.connect (() => {
+                                       main_box.visible_child = sidebar_vbox;
+                                       titlebar_box.visible_child = left_header_bar;
+                               });
+                               var folded = main_box.get_fold () == Hdy.Fold.FOLDED;
+                               back_button.visible = folded;
+                               value.pack_start (back_button);
                        }
                        _right_header_bar = value;
                }
@@ -67,5 +87,20 @@ private class Games.PreferencesWindow : Gtk.Window {
                                                               BindingFlags.SYNC_CREATE);
                immersive_mode_binding = page.bind_property ("immersive-mode", this, "immersive-mode",
                                                             BindingFlags.SYNC_CREATE);
+
+               var folded = main_box.get_fold () == Hdy.Fold.FOLDED;
+               if (folded) {
+                       main_box.visible_child = stack;
+                       titlebar_box.visible_child = right_header_bar;
+               }
+       }
+
+       [GtkCallback]
+       private void main_box_notify_fold (GLib.Object    object,
+                                          GLib.ParamSpec paramSpec) {
+               var folded = main_box.get_fold () == Hdy.Fold.FOLDED;
+
+               left_header_bar.show_close_button = folded;
+               back_button.visible = folded;
        }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]