[gnome-clocks/wip/exalm/libhandy-1: 3/11] headerbar: Use HdyViewSwitcherTitle



commit c148b355abcbedbb28d6f2fc28b25e640009d63e
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Sat May 23 00:04:26 2020 +0500

    headerbar: Use HdyViewSwitcherTitle

 data/ui/headerbar.ui | 35 ++++-------------------------------
 src/headerbar.vala   | 10 ++++------
 2 files changed, 8 insertions(+), 37 deletions(-)
---
diff --git a/data/ui/headerbar.ui b/data/ui/headerbar.ui
index e28208f..d83aa1f 100644
--- a/data/ui/headerbar.ui
+++ b/data/ui/headerbar.ui
@@ -32,38 +32,11 @@
         <property name="homogeneous">False</property>
         <property name="transition_type">none</property>
         <child>
-          <object class="HdySqueezer" id="squeezer">
+          <object class="HdyViewSwitcherTitle" id="view_switcher_title">
             <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="transition_type">crossfade</property>
-            <signal name="notify::visible-child" handler="visible_child_changed"/>
-            <child>
-              <object class="HdyViewSwitcher">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="halign">center</property>
-                <property name="stack" bind-source="ClocksHeaderBar" bind-property="stack" 
bind-flags="sync-create">ignore-me</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" bind-source="ClocksHeaderBar" bind-property="title" 
bind-flags="sync-create" />
-                    <style>
-                      <class name="title"/>
-                    </style>
-                  </object>
-                </child>
-              </object>
-            </child>
+            <property name="stack" bind-source="ClocksHeaderBar" bind-property="stack" 
bind-flags="sync-create">ignore-me</property>
+            <property name="title" bind-source="ClocksHeaderBar" bind-property="title" 
bind-flags="sync-create" />
+            <signal name="notify::title-visible" handler="title_visible_changed"/>
           </object>
           <packing>
             <property name="name">switcher</property>
diff --git a/src/headerbar.vala b/src/headerbar.vala
index 039637d..a2fc802 100644
--- a/src/headerbar.vala
+++ b/src/headerbar.vala
@@ -56,7 +56,7 @@ public class Clocks.HeaderBar : Hdy.HeaderBar {
                     break;
             }
 
-            visible_child_changed ();
+            title_visible_changed ();
         }
     }
 
@@ -93,9 +93,7 @@ public class Clocks.HeaderBar : Hdy.HeaderBar {
     [GtkChild]
     private Gtk.Stack end_button_stack;
     [GtkChild]
-    private Hdy.Squeezer squeezer;
-    [GtkChild]
-    private Gtk.Box title_text;
+    private Hdy.ViewSwitcherTitle view_switcher_title;
     [GtkChild]
     private Gtk.Stack title_stack;
     [GtkChild]
@@ -107,7 +105,7 @@ public class Clocks.HeaderBar : Hdy.HeaderBar {
     }
 
     [GtkCallback]
-    private void visible_child_changed () {
-        switcher_bar.reveal = squeezer.visible_child == title_text && view_mode == NORMAL;
+    private void title_visible_changed () {
+        switcher_bar.reveal = view_switcher_title.title_visible && view_mode == NORMAL;
     }
 }


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