[gnome-clocks/wip/exalm/libhandy-1: 9/10] headerbar: Simplify layout



commit 882ba0c80b15183dca6829101e4eddea7a627379
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Sat May 23 01:02:58 2020 +0500

    headerbar: Simplify layout
    
    Since the original subscreens are gone, a lot of code can be removed now.

 data/ui/headerbar.ui | 94 +++++++---------------------------------------------
 src/alarm.vala       |  3 --
 src/clock.vala       |  6 ----
 src/headerbar.vala   | 51 +---------------------------
 src/stopwatch.vala   |  3 --
 src/timer.vala       |  3 --
 src/window.vala      | 27 ---------------
 src/world.vala       |  3 --
 8 files changed, 13 insertions(+), 177 deletions(-)
---
diff --git a/data/ui/headerbar.ui b/data/ui/headerbar.ui
index d83aa1f..5858446 100644
--- a/data/ui/headerbar.ui
+++ b/data/ui/headerbar.ui
@@ -21,63 +21,14 @@
   <template class="ClocksHeaderBar" parent="HdyHeaderBar">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
-    <property name="title" translatable="yes">Clocks</property>
     <property name="centering_policy">strict</property>
     <property name="show_close_button">True</property>
-    <signal name="notify::subtitle" handler="subtitle_changed" swapped="no"/>
     <child type="title">
-      <object class="GtkStack" id="title_stack">
+      <object class="HdyViewSwitcherTitle" id="view_switcher_title">
         <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="homogeneous">False</property>
-        <property name="transition_type">none</property>
-        <child>
-          <object class="HdyViewSwitcherTitle" id="view_switcher_title">
-            <property name="visible">True</property>
-            <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>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkBox">
-            <property name="visible">True</property>
-            <property name="orientation">vertical</property>
-            <property name="valign">center</property>
-            <child>
-              <object class="GtkLabel">
-                <property name="visible">True</property>
-                <property name="label" bind-source="ClocksHeaderBar" bind-property="title" 
bind-flags="sync-create" />
-                <property name="ellipsize">end</property>
-                <style>
-                  <class name="title"/>
-                </style>
-              </object>
-            </child>
-            <child>
-              <object class="GtkRevealer" id="reveal_subtitle">
-                <property name="visible">True</property>
-                <property name="reveal-child">False</property>
-                <child>
-                  <object class="GtkLabel">
-                    <property name="visible">True</property>
-                    <property name="label" bind-source="ClocksHeaderBar" bind-property="subtitle" 
bind-flags="sync-create" />
-                    <property name="ellipsize">end</property>
-                    <style>
-                      <class name="subtitle"/>
-                    </style>
-                  </object>
-                </child>
-              </object>
-            </child>
-          </object>
-          <packing>
-            <property name="name">title</property>
-          </packing>
-        </child>
+        <property name="title" translatable="yes">Clocks</property>
+        <property name="stack" bind-source="ClocksHeaderBar" bind-property="stack" 
bind-flags="sync-create">ignore-me</property>
+        <signal name="notify::title-visible" handler="title_visible_changed"/>
       </object>
     </child>
     <child>
@@ -136,40 +87,19 @@
       </object>
     </child>
     <child>
-      <object class="GtkStack" id="end_button_stack">
+      <object class="GtkMenuButton">
         <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="hhomogeneous">False</property>
-        <property name="transition_type">crossfade</property>
-        <child>
-          <object class="GtkMenuButton">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">True</property>
-            <property name="action_name">win.show-primary-menu</property>
-            <property name="tooltip-text" translatable="yes">Menu</property>
-            <property name="menu_model">primary-menu</property>
-            <child>
-              <object class="GtkImage">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="icon_name">open-menu-symbolic</property>
-              </object>
-            </child>
-          </object>
-          <packing>
-            <property name="name">menu</property>
-          </packing>
-        </child>
+        <property name="can_focus">True</property>
+        <property name="receives_default">True</property>
+        <property name="action_name">win.show-primary-menu</property>
+        <property name="tooltip-text" translatable="yes">Menu</property>
+        <property name="menu_model">primary-menu</property>
         <child>
-          <object class="GtkBox">
+          <object class="GtkImage">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="orientation">vertical</property>
+            <property name="icon_name">open-menu-symbolic</property>
           </object>
-          <packing>
-            <property name="name">empty</property>
-          </packing>
         </child>
       </object>
       <packing>
diff --git a/src/alarm.vala b/src/alarm.vala
index 6897a50..b650179 100644
--- a/src/alarm.vala
+++ b/src/alarm.vala
@@ -789,11 +789,8 @@ private class RingingPanel : Gtk.Bin {
 
 [GtkTemplate (ui = "/org/gnome/clocks/ui/alarm.ui")]
 public class Face : Gtk.Stack, Clocks.Clock {
-    public ViewMode view_mode { get; set; default = NORMAL; }
     public PanelId panel_id { get; construct set; }
     public ButtonMode button_mode { get; set; default = NEW; }
-    public string title { get; set; default = _("Clocks"); }
-    public string subtitle { get; set; }
     // Translators: Tooltip for the + button
     public string? new_label { get; default = _("New Alarm"); }
 
diff --git a/src/clock.vala b/src/clock.vala
index 7449085..58f4988 100644
--- a/src/clock.vala
+++ b/src/clock.vala
@@ -27,17 +27,11 @@ public enum Clocks.PanelId {
 public interface Clocks.Clock : GLib.Object {
     public abstract PanelId panel_id { get; protected construct set; }
     public abstract ButtonMode button_mode { get; set; }
-    public abstract ViewMode view_mode { get; set; }
-    public abstract string title { get; protected set; }
-    public abstract string subtitle { get; protected set; }
     public abstract string? new_label { get; }
 
     public virtual void activate_new () {
     }
 
-    public virtual void activate_back () {
-    }
-
     public virtual bool escape_pressed () {
         return false;
     }
diff --git a/src/headerbar.vala b/src/headerbar.vala
index a2fc802..53f334d 100644
--- a/src/headerbar.vala
+++ b/src/headerbar.vala
@@ -21,45 +21,11 @@
 
 public enum Clocks.ButtonMode {
     NEW,
-    BACK,
     NONE
 }
 
-
-public enum Clocks.ViewMode {
-    NORMAL,
-    STANDALONE
-}
-
-
 [GtkTemplate (ui = "/org/gnome/clocks/ui/headerbar.ui")]
 public class Clocks.HeaderBar : Hdy.HeaderBar {
-    public ViewMode view_mode {
-        get {
-            return _mode;
-        }
-
-        set {
-            _mode = value;
-
-            switch (_mode) {
-                case NORMAL:
-                    title_stack.visible_child_name = "switcher";
-                    start_button_stack.show ();
-                    end_button_stack.show ();
-                    end_button_stack.visible_child_name = "menu";
-                    break;
-                case STANDALONE:
-                    title_stack.visible_child_name = "title";
-                    start_button_stack.show ();
-                    end_button_stack.hide ();
-                    break;
-            }
-
-            title_visible_changed ();
-        }
-    }
-
     public ButtonMode button_mode {
         get {
             return _button_mode;
@@ -70,9 +36,6 @@ public class Clocks.HeaderBar : Hdy.HeaderBar {
                 case NEW:
                     start_button_stack.visible_child_name = "new";
                     break;
-                case BACK:
-                    start_button_stack.visible_child_name = "back";
-                    break;
                 case NONE:
                     start_button_stack.visible_child_name = "empty";
                     break;
@@ -85,27 +48,15 @@ public class Clocks.HeaderBar : Hdy.HeaderBar {
     public Hdy.ViewSwitcherBar switcher_bar { get; set; }
     public string? new_label { get; set; }
 
-    private ViewMode _mode;
     private ButtonMode _button_mode;
 
     [GtkChild]
     private Gtk.Stack start_button_stack;
     [GtkChild]
-    private Gtk.Stack end_button_stack;
-    [GtkChild]
     private Hdy.ViewSwitcherTitle view_switcher_title;
-    [GtkChild]
-    private Gtk.Stack title_stack;
-    [GtkChild]
-    private Gtk.Revealer reveal_subtitle;
-
-    [GtkCallback]
-    private void subtitle_changed () {
-        reveal_subtitle.reveal_child = ((string?) subtitle) != null && subtitle.length > 0;
-    }
 
     [GtkCallback]
     private void title_visible_changed () {
-        switcher_bar.reveal = view_switcher_title.title_visible && view_mode == NORMAL;
+        switcher_bar.reveal = view_switcher_title.title_visible;
     }
 }
diff --git a/src/stopwatch.vala b/src/stopwatch.vala
index 462affc..d8196b2 100644
--- a/src/stopwatch.vala
+++ b/src/stopwatch.vala
@@ -120,9 +120,6 @@ public class Face : Gtk.Box, Clocks.Clock {
     public HeaderBar header_bar { get; construct set; }
     public PanelId panel_id { get; construct set; }
     public ButtonMode button_mode { get; set; default = NONE; }
-    public ViewMode view_mode { get; set; default = NORMAL; }
-    public string title { get; set; default = _("Clocks"); }
-    public string subtitle { get; set; }
     public string? new_label { get; default = null; }
 
     public State state { get; private set; default = State.RESET; }
diff --git a/src/timer.vala b/src/timer.vala
index fc18b75..ac0062f 100644
--- a/src/timer.vala
+++ b/src/timer.vala
@@ -383,10 +383,7 @@ public class Face : Gtk.Stack, Clocks.Clock {
 
     public PanelId panel_id { get; construct set; }
     public ButtonMode button_mode { get; set; default = NONE; }
-    public ViewMode view_mode { get; set; default = NORMAL; }
     public bool is_running { get; set; default = false; }
-    public string title { get; set; default = _("Clocks"); }
-    public string subtitle { get; set; }
     // Translators: Tooltip for the + button
     public string? new_label { get; default = _("New Timer"); }
 
diff --git a/src/window.vala b/src/window.vala
index bd472c6..b294246 100644
--- a/src/window.vala
+++ b/src/window.vala
@@ -56,9 +56,6 @@ public class Window : Hdy.ApplicationWindow {
 
     // DIY DzlBindingGroup
     private Binding? bind_button_mode = null;
-    private Binding? bind_view_mode = null;
-    private Binding? bind_title = null;
-    private Binding? bind_subtitle = null;
     private Binding? bind_new_label = null;
 
     private bool inited = false;
@@ -327,30 +324,6 @@ public class Window : Hdy.ApplicationWindow {
                                                 "button-mode",
                                                 SYNC_CREATE);
 
-        if (bind_view_mode != null) {
-            ((Binding) bind_view_mode).unbind ();
-        }
-        bind_view_mode = panel.bind_property ("view-mode",
-                                              header_bar,
-                                              "view-mode",
-                                              SYNC_CREATE);
-
-        if (bind_title != null) {
-            ((Binding) bind_title).unbind ();
-        }
-        bind_title = panel.bind_property ("title",
-                                          header_bar,
-                                          "title",
-                                          SYNC_CREATE);
-
-        if (bind_subtitle != null) {
-            ((Binding) bind_subtitle).unbind ();
-        }
-        bind_subtitle = panel.bind_property ("subtitle",
-                                             header_bar,
-                                             "subtitle",
-                                             SYNC_CREATE);
-
         if (bind_new_label != null) {
             ((Binding) bind_new_label).unbind ();
         }
diff --git a/src/world.vala b/src/world.vala
index ec3b239..74a736b 100644
--- a/src/world.vala
+++ b/src/world.vala
@@ -595,9 +595,6 @@ public class Face : Gtk.Stack, Clocks.Clock {
 
     public PanelId panel_id { get; construct set; }
     public ButtonMode button_mode { get; set; default = NEW; }
-    public ViewMode view_mode { get; set; default = NORMAL; }
-    public string title { get; set; default = _("Clocks"); }
-    public string subtitle { get; set; }
     // Translators: Tooltip for the + button
     public string? new_label { get; default = _("Add Location"); }
 


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