gnome-games r8290 - trunk/glines



Author: rancell
Date: Sun Nov  9 08:40:16 2008
New Revision: 8290
URL: http://svn.gnome.org/viewvc/gnome-games?rev=8290&view=rev

Log:
Only start animation timer when required (Bug #523589)

Modified:
   trunk/glines/glines.c

Modified: trunk/glines/glines.c
==============================================================================
--- trunk/glines/glines.c	(original)
+++ trunk/glines/glines.c	Sun Nov  9 08:40:16 2008
@@ -383,17 +383,25 @@
   gdk_window_invalidate_rect (widget->window, NULL, FALSE);
 }
 
-void
-set_inmove (int i)
+static void
+start_animation (void)
 {
   int ms;
 
+  ms = (inmove ? move_timeout : 100);
+  if (animate_id == 0)
+    animate_id = g_timeout_add (ms, animate, draw_area);
+}
+
+void
+set_inmove (int i)
+{
   if (inmove != i) {
     inmove = i;
-    ms = (inmove ? move_timeout : 100);
     if (animate_id)
       g_source_remove (animate_id);
-    animate_id = g_timeout_add (ms, animate, draw_area);
+    animate_id = 0;
+    start_animation ();
   }
 }
 
@@ -690,6 +698,7 @@
 
       active = fx + fy * hfieldsize;
       field[active].active = 1;
+      start_animation();
     }
   }
 
@@ -1108,8 +1117,11 @@
   x = active % hfieldsize;
   y = active / hfieldsize;
 
-  if (active == -1)
-    return TRUE;
+  if (active == -1) {
+    animate_id = 0;
+    return FALSE;
+  }
+
   if (inmove != 0) {
     if ((x > 0)
         && (field[active - 1].pathsearch == field[active].pathsearch + 1))



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