[gnome-sudoku] Tweaks to the clock code



commit 6a5fd88f12abc04cb3812fc70606912eba47353b
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Sat Oct 4 16:09:53 2014 -0500

    Tweaks to the clock code
    
    This doesn't change anything, it should just be a bit clearer.

 lib/sudoku-game.vala  |   13 +++++--------
 src/gnome-sudoku.vala |    4 ++--
 2 files changed, 7 insertions(+), 10 deletions(-)
---
diff --git a/lib/sudoku-game.vala b/lib/sudoku-game.vala
index cf2f57a..6dd2788 100644
--- a/lib/sudoku-game.vala
+++ b/lib/sudoku-game.vala
@@ -171,23 +171,20 @@ public class SudokuGame : Object
     }
 
     public void stop_clock ()
+        requires (timer != null)
     {
-        if (timer == null)
-            return;
         if (clock_timeout != 0)
             Source.remove (clock_timeout);
-        paused = true;
         clock_timeout = 0;
+        paused = true;
         timer.stop ();
         tick ();
     }
 
-    public void continue_clock ()
+    public void resume_clock ()
+        requires (timer != null && clock_timeout == 0)
     {
-        if (timer == null)
-            timer = new Timer ();
-        else
-            timer.continue ();
+        timer.continue ();
         paused = false;
         timeout_cb ();
     }
diff --git a/src/gnome-sudoku.vala b/src/gnome-sudoku.vala
index d8907b0..6e79522 100644
--- a/src/gnome-sudoku.vala
+++ b/src/gnome-sudoku.vala
@@ -273,7 +273,7 @@ public class Sudoku : Gtk.Application
     private void toggle_pause_cb ()
     {
        if (game.paused)
-           game.continue_clock ();
+           game.resume_clock ();
        else
            game.stop_clock ();
     }
@@ -433,7 +433,7 @@ public class Sudoku : Gtk.Application
 
         if (game != null)
         {
-            game.continue_clock ();
+            game.resume_clock ();
             clear_action.set_enabled (!game.board.is_empty ());
             headerbar.title = game.board.difficulty_category.to_string ();
         }


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