[gnome-clocks/bilelmoussaoui/redesign-timer] TimerRow: hide/show buttons depending on the state



commit f64944c4e9e6a8210827c968afe045d12afc1064
Author: Bilal Elmoussaoui <bil elmoussaoui gmail com>
Date:   Tue Jan 28 06:08:52 2020 +0100

    TimerRow: hide/show buttons depending on the state

 data/ui/timer_row.ui | 24 ++++++++++++------------
 src/timer.vala       | 14 ++++++++++++++
 2 files changed, 26 insertions(+), 12 deletions(-)
---
diff --git a/data/ui/timer_row.ui b/data/ui/timer_row.ui
index 678039c..5fd9eef 100644
--- a/data/ui/timer_row.ui
+++ b/data/ui/timer_row.ui
@@ -128,9 +128,13 @@
       </packing>
     </child>
     <child>
-      <object class="GtkBox" id="actions_box">
+      <object class="GtkGrid">
+        <property name="width_request">300</property>
         <property name="visible">True</property>
         <property name="can_focus">False</property>
+        <property name="halign">center</property>
+        <property name="row_homogeneous">True</property>
+        <property name="column_homogeneous">True</property>
         <child>
           <object class="GtkButton" id="reset_button">
             <property name="visible">True</property>
@@ -152,9 +156,8 @@
             </style>
           </object>
           <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="position">0</property>
+            <property name="left_attach">0</property>
+            <property name="top_attach">0</property>
           </packing>
         </child>
         <child>
@@ -217,9 +220,8 @@
             </child>
           </object>
           <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="position">1</property>
+            <property name="left_attach">1</property>
+            <property name="top_attach">0</property>
           </packing>
         </child>
         <child>
@@ -242,17 +244,15 @@
             </style>
           </object>
           <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="position">2</property>
+            <property name="left_attach">2</property>
+            <property name="top_attach">0</property>
           </packing>
         </child>
       </object>
       <packing>
         <property name="expand">False</property>
         <property name="fill">True</property>
-        <property name="pack_type">end</property>
-        <property name="position">2</property>
+        <property name="position">3</property>
       </packing>
     </child>
   </template>
diff --git a/src/timer.vala b/src/timer.vala
index 4751ab9..96e0e1c 100644
--- a/src/timer.vala
+++ b/src/timer.vala
@@ -245,6 +245,11 @@ public class Row : Gtk.Box {
     [GtkChild]
     private Gtk.Stack start_stack;
 
+    [GtkChild]
+    private Gtk.Button reset_button;
+    [GtkChild]
+    private Gtk.Button delete_button;
+
     [GtkChild]
     private Gtk.Label hours_label;
     [GtkChild]
@@ -304,6 +309,9 @@ public class Row : Gtk.Box {
         minutes_label.label = "%02i".printf(item.duration.minutes);
         seconds_label.label = "%02i".printf(item.duration.seconds);
 
+        reset_button.hide ();
+        delete_button.show ();
+
         timer.reset ();
         countdown_container.get_style_context ().add_class ("timer-paused");
         countdown_container.get_style_context ().remove_class ("timer-running");
@@ -314,6 +322,9 @@ public class Row : Gtk.Box {
         countdown_container.get_style_context ().add_class ("timer-running");
         countdown_container.get_style_context ().remove_class ("timer-paused");
 
+        reset_button.hide ();
+        delete_button.hide ();
+
         start_stack.visible_child_name = "pause";
         state = State.RUNNING;
         timer.start ();
@@ -338,6 +349,9 @@ public class Row : Gtk.Box {
         countdown_container.get_style_context ().add_class ("timer-paused");
         countdown_container.get_style_context ().remove_class ("timer-running");
 
+        reset_button.show ();
+        delete_button.show ();
+
         state = State.PAUSED;
         timer.stop ();
         span -= timer.elapsed ();


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