[gnome-clocks/bilelmoussaoui/adaptive-headerbar: 4/5] Use a HdySqueezer instead of GtkStackSwitcher



commit 0e2a80a7e4b0b46a399725beb7c91791357e5981
Author: Bilal Elmoussaoui <bil elmoussaoui gmail com>
Date:   Thu Sep 26 14:31:25 2019 +0200

    Use a HdySqueezer instead of GtkStackSwitcher

 data/ui/window.ui | 50 ++++++++++++++++++++++++++++++++++++++++++++++++--
 src/main.vala     |  2 ++
 src/window.vala   |  5 ++---
 3 files changed, 52 insertions(+), 5 deletions(-)
---
diff --git a/data/ui/window.ui b/data/ui/window.ui
index ae9c7a5..676beb0 100644
--- a/data/ui/window.ui
+++ b/data/ui/window.ui
@@ -1,6 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <!-- interface-requires gtk+ 3.8 -->
+  <!-- interface-requires gtk+ 3.20 -->
+  <requires lib="gtk+" version="3.20"/>
+  <requires lib="libhandy" version="0.0"/>
   <template class="ClocksWindow" parent="GtkApplicationWindow">
     <property name="title" translatable="yes">Clocks</property>
     <menu id="primary-menu">
@@ -28,8 +30,52 @@
           <class name="titlebar"/>
         </style>
         <child type="title">
-          <object class="GtkStackSwitcher" id="stack_switcher">
+          <object class="HdySqueezer" id="squeezer">
             <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="transition_type">crossfade</property>
+            <child>
+              <object class="HdyViewSwitcher" id="title_wide_switcher">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="halign">center</property>
+                <property name="policy">wide</property>
+                <property name="stack">stack</property>
+              </object>
+            </child>
+            <child>
+              <object class="HdyViewSwitcher" id="title_narrow_switcher">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="halign">center</property>
+                <property name="policy">narrow</property>
+                <property name="stack">stack</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkBox" id="title_text">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="halign">center</property>
+                <property name="valign">center</property>
+                <property name="orientation">vertical</property>
+                <child>
+                  <object class="GtkLabel" id="title_label">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes">Clock</property>
+                    <style>
+                      <class name="title"/>
+                    </style>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+              </object>
+            </child>
           </object>
         </child>
         <child>
diff --git a/src/main.vala b/src/main.vala
index b28f613..3a132d4 100644
--- a/src/main.vala
+++ b/src/main.vala
@@ -21,6 +21,8 @@ int main (string[] args) {
     Intl.bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "UTF-8");
     Intl.textdomain (Config.GETTEXT_PACKAGE);
 
+    Hdy.init (ref args);
+
     var app = new Clocks.Application ();
     return app.run (args);
 }
diff --git a/src/window.vala b/src/window.vala
index 437711c..56b21df 100644
--- a/src/window.vala
+++ b/src/window.vala
@@ -37,7 +37,7 @@ public class Window : Gtk.ApplicationWindow {
     [GtkChild]
     private Gtk.Stack stack;
     [GtkChild]
-    private Gtk.StackSwitcher stack_switcher;
+    private Hdy.Squeezer squeezer;
     [GtkChild]
     private Gtk.MenuButton menu_button;
     private GLib.Settings settings;
@@ -85,7 +85,6 @@ public class Window : Gtk.ApplicationWindow {
             });
         }
 
-        stack_switcher.set_stack (stack);
 
         var stack_id = stack.notify["visible-child"].connect (() => {
             var help_overlay = get_help_overlay ();
@@ -288,7 +287,7 @@ public class Window : Gtk.ApplicationWindow {
         }
 
         if (header_bar.mode == HeaderBar.Mode.NORMAL) {
-            header_bar.custom_title = stack_switcher;
+            header_bar.custom_title = squeezer;
             menu_button.show ();
         }
 


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