[gnome-clocks/wip/analogtimer] Add a count-up label



commit b81d573c32c50650ddb0abc78fa0394f74e7d4b5
Author: Paolo Borelli <pborelli gnome org>
Date:   Fri Aug 2 14:54:04 2013 +0200

    Add a count-up label

 data/css/gnome-clocks.css |    4 +++
 data/ui/timer.ui          |   57 ++++++++++++++++++++++++++++++++++----------
 src/timer.vala            |   19 ++++++++++++---
 3 files changed, 63 insertions(+), 17 deletions(-)
---
diff --git a/data/css/gnome-clocks.css b/data/css/gnome-clocks.css
index b53ea12..c2ebfa6 100644
--- a/data/css/gnome-clocks.css
+++ b/data/css/gnome-clocks.css
@@ -106,6 +106,10 @@
     font-size: 18px;
 }
 
+.clocks-countup-label {
+    font-size: 32px;
+}
+
 .clocks-button {
     font-size: 18px;
 }
diff --git a/data/ui/timer.ui b/data/ui/timer.ui
index 59476bd..9f3f406 100644
--- a/data/ui/timer.ui
+++ b/data/ui/timer.ui
@@ -170,21 +170,51 @@
     <property name="row_spacing">48</property>
     <property name="column_spacing">24</property>
     <child>
-      <object class="GtkLabel" id="time_label">
+      <object class="GtkGrid" id="countdown_label_panel">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <property name="halign">center</property>
         <property name="valign">center</property>
-        <style>
-          <class name="clocks-time-label"/>
-        </style>
+        <property name="hexpand">True</property>
+        <property name="vexpand">True</property>
+        <property name="row_spacing">16</property>
+        <property name="column_spacing">0</property>
+        <child>
+          <object class="GtkLabel" id="countdown_label">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="halign">center</property>
+            <property name="valign">center</property>
+            <style>
+              <class name="clocks-time-label"/>
+            </style>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">0</property>
+            <property name="width">1</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="countup_label">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="halign">center</property>
+            <property name="valign">center</property>
+            <style>
+              <class name="dim-label"/>
+              <class name="clocks-countup-label"/>
+            </style>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">1</property>
+            <property name="width">1</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
       </object>
-      <packing>
-        <property name="left_attach">0</property>
-        <property name="top_attach">0</property>
-        <property name="width">1</property>
-        <property name="height">1</property>
-      </packing>
     </child>
     <child>
       <object class="GtkGrid" id="button_grid">
@@ -230,7 +260,7 @@
       </object>
       <packing>
         <property name="left_attach">0</property>
-        <property name="top_attach">1</property>
+        <property name="top_attach">2</property>
         <property name="width">1</property>
         <property name="height">1</property>
       </packing>
@@ -240,7 +270,8 @@
     <widgets>
       <widget name="grid_spinbuttons"/>
       <widget name="start_button"/>
-      <widget name="time_label"/>
+      <widget name="countdown_label"/>
+      <widget name="countup_label"/>
       <widget name="button_grid"/>
     </widgets>
   </object>
@@ -248,7 +279,7 @@
     <property name="mode">vertical</property>
     <widgets>
       <widget name="grid_spinbuttons"/>
-      <widget name="time_label"/>
+      <widget name="countdown_label_panel"/>
     </widgets>
   </object>
   <object class="GtkSizeGroup" id="sizegroup3">
diff --git a/src/timer.vala b/src/timer.vala
index 508664e..0b18ccf 100644
--- a/src/timer.vala
+++ b/src/timer.vala
@@ -160,7 +160,8 @@ public class MainPanel : Gtk.Stack, Clocks.Clock {
     private Gtk.SpinButton s_spinbutton;
     private Gtk.Button start_button;
     private CountdownFrame countdown_frame;
-    private Gtk.Label time_label;
+    private Gtk.Label countdown_label;
+    private Gtk.Label countup_label;
     private Gtk.Button left_button;
     private Gtk.Button right_button;
     private double span;
@@ -203,7 +204,8 @@ public class MainPanel : Gtk.Stack, Clocks.Clock {
         var countdown_widgets = builder.get_object ("countdown_panel") as Gtk.Widget;
         countdown_frame.add (countdown_widgets);
 
-        time_label = builder.get_object ("time_label") as Gtk.Label;
+        countdown_label = builder.get_object ("countdown_label") as Gtk.Label;
+        countup_label = builder.get_object ("countup_label") as Gtk.Label;
         left_button = builder.get_object ("left_button") as Gtk.Button;
         right_button = builder.get_object ("right_button") as Gtk.Button;
 
@@ -290,6 +292,7 @@ public class MainPanel : Gtk.Stack, Clocks.Clock {
             visible_child = countdown_frame;
 
             update_countdown_label (h, m, s);
+            update_countup_label (0, 0, 0);
             add_timeout ();
         }
     }
@@ -328,6 +331,7 @@ public class MainPanel : Gtk.Stack, Clocks.Clock {
             state = State.STOPPED;
             remove_timeout ();
             update_countdown_label (0, 0, 0);
+            update_countup_label (0, 0, 0);
             visible_child = setup_panel;
             return false;
         }
@@ -337,7 +341,7 @@ public class MainPanel : Gtk.Stack, Clocks.Clock {
     }
 
     private void update_countdown (double elapsed) {
-        if (time_label.get_mapped ()) {
+        if (countdown_label.get_mapped ()) {
             // Math.ceil() because we count backwards:
             // with 0.3 seconds we want to show 1 second remaining,
             // with 59.2 seconds we want to show 1 minute, etc
@@ -348,13 +352,20 @@ public class MainPanel : Gtk.Stack, Clocks.Clock {
             double r;
             Utils.time_to_hms (t, out h, out m, out s, out r);
             update_countdown_label (h, m, s);
+            Utils.time_to_hms (elapsed, out h, out m, out s, out r);
+            update_countup_label (h, m, s);
             countdown_frame.update (elapsed);
         }
     }
 
     private void update_countdown_label (int h, int m, int s) {
         // Note that the format uses unicode RATIO character
-        time_label.set_text ("%02i∶%02i∶%02i".printf (h, m, s));
+        countdown_label.set_text ("%02i∶%02i∶%02i".printf (h, m, s));
+    }
+
+    private void update_countup_label (int h, int m, int s) {
+        // Note that the format uses unicode RATIO character
+        countup_label.set_text ("%02i∶%02i∶%02i".printf (h, m, s));
     }
 
     public override void grab_focus () {


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