[recipes] Unify gr_timer_start and _continue



commit 1fe01d3ea1a4b1e1157fc20ca7fed3e76d173ff4
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Feb 22 20:25:10 2017 -0500

    Unify gr_timer_start and _continue
    
    Make these two functions do the same thing, and drop
    _continue.

 src/gr-cooking-view.c |    2 +-
 src/gr-time-widget.c  |    2 +-
 src/gr-timer.c        |   15 ++++-----------
 src/gr-timer.h        |    1 -
 4 files changed, 6 insertions(+), 14 deletions(-)
---
diff --git a/src/gr-cooking-view.c b/src/gr-cooking-view.c
index 6b6d6ce..5ce9e2c 100644
--- a/src/gr-cooking-view.c
+++ b/src/gr-cooking-view.c
@@ -301,7 +301,7 @@ step_timer_pause (GrCookingView *view)
         if (gr_timer_get_active (s->timer))
                 gr_timer_stop (s->timer);
         else
-                gr_timer_continue (s->timer);
+                gr_timer_start (s->timer);
 }
 
 static void
diff --git a/src/gr-time-widget.c b/src/gr-time-widget.c
index 05ce98d..0c9aaba 100644
--- a/src/gr-time-widget.c
+++ b/src/gr-time-widget.c
@@ -128,7 +128,7 @@ timer_pause (GrTimeWidget *self)
                 gtk_stack_set_visible_child_name (GTK_STACK (self->pause_stack), "resume");
         }
         else {
-                gr_timer_continue (self->timer);
+                gr_timer_start (self->timer);
                 gtk_stack_set_visible_child_name (GTK_STACK (self->pause_stack), "pause");
         }
 }
diff --git a/src/gr-timer.c b/src/gr-timer.c
index 5512d45..1d62608 100644
--- a/src/gr-timer.c
+++ b/src/gr-timer.c
@@ -281,7 +281,10 @@ gr_timer_init (GrTimer *self)
 void
 gr_timer_start (GrTimer *timer)
 {
-        timer->start_time = g_get_monotonic_time ();
+        guint64 elapsed;
+
+        elapsed = timer->end_time - timer->start_time;
+        timer->start_time = g_get_monotonic_time () - elapsed;
         set_active (timer, TRUE);
 }
 
@@ -301,13 +304,3 @@ gr_timer_reset (GrTimer *timer)
         set_active (timer, FALSE);
         g_object_notify (G_OBJECT (timer), "remaining");
 }
-
-void
-gr_timer_continue (GrTimer *timer)
-{
-        guint64 elapsed;
-
-        elapsed = timer->end_time - timer->start_time;
-        timer->start_time = g_get_monotonic_time () - elapsed;
-        set_active (timer, TRUE);
-}
diff --git a/src/gr-timer.h b/src/gr-timer.h
index d1b2d09..5702f2c 100644
--- a/src/gr-timer.h
+++ b/src/gr-timer.h
@@ -37,7 +37,6 @@ guint64     gr_timer_get_duration   (GrTimer    *timer);
 guint64     gr_timer_get_remaining  (GrTimer    *timer);
 void        gr_timer_start          (GrTimer    *timer);
 void        gr_timer_stop           (GrTimer    *timer);
-void        gr_timer_continue       (GrTimer    *timer);
 void        gr_timer_reset          (GrTimer    *timer);
 
 G_END_DECLS


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