gnome-edu r15 - trunk/garfunkel/src



Author: brunobol
Date: Sun Jun 15 15:10:22 2008
New Revision: 15
URL: http://svn.gnome.org/viewvc/gnome-edu?rev=15&view=rev

Log:
Garfunkel - some thing randomized

Modified:
   trunk/garfunkel/src/garfunkel.c

Modified: trunk/garfunkel/src/garfunkel.c
==============================================================================
--- trunk/garfunkel/src/garfunkel.c	(original)
+++ trunk/garfunkel/src/garfunkel.c	Sun Jun 15 15:10:22 2008
@@ -34,7 +34,7 @@
 #include "garfunkel.h"
 
 #define GFK_BLINK_SPEED_FAST    200000
-#define GFK_BLINK_SPEED_NORMAL 1000000
+#define GFK_BLINK_SPEED_NORMAL  500000
 
 G_DEFINE_TYPE (Garfunkel, garfunkel, GTK_TYPE_DRAWING_AREA);
 
@@ -64,7 +64,8 @@
 static gpointer garfunkel_blink_thread (gpointer data);
 static gboolean garfunkel_key_press (GtkWidget *widget, GdkEventKey *event);
 static gboolean garfunkel_button_press (GtkWidget *widget, GdkEventButton *event);
-
+static void     garfunkel_sequence_increment (Garfunkel *garfunkel);
+static void     garfunkel_sequence_blink (Garfunkel *garfunkel);
 
 static void
 garfunkel_init (Garfunkel* garfunkel)
@@ -231,6 +232,8 @@
 {
   Garfunkel *garfunkel = (Garfunkel *) data;
 
+  g_usleep (200000);
+
   garfunkel->priv->lights = 0;
 
   garfunkel_redraw (garfunkel);
@@ -242,8 +245,6 @@
 static gboolean
 garfunkel_key_press (GtkWidget *widget, GdkEventKey *event)
 {
-  garfunkel_blink ((Garfunkel *) widget, GFK_GREEN, GFK_BLINK_SPEED_NORMAL);
-
   return FALSE;   
 }
 
@@ -255,15 +256,45 @@
 
   garfunkel = (Garfunkel *) widget;
   
-  garfunkel_blink (garfunkel, GFK_GREEN | GFK_BLUE, GFK_BLINK_SPEED_NORMAL);
-  garfunkel_blink (garfunkel, GFK_RED | GFK_YELLOW, GFK_BLINK_SPEED_NORMAL);
-  garfunkel_blink (garfunkel, GFK_GREEN | GFK_BLUE, GFK_BLINK_SPEED_NORMAL);
-  garfunkel_blink (garfunkel, GFK_RED | GFK_YELLOW, GFK_BLINK_SPEED_NORMAL);
-  garfunkel_blink (garfunkel, GFK_GREEN | GFK_BLUE, GFK_BLINK_SPEED_NORMAL);
-  garfunkel_blink (garfunkel, GFK_RED | GFK_YELLOW, GFK_BLINK_SPEED_NORMAL);
-  garfunkel_blink (garfunkel, GFK_GREEN | GFK_BLUE, GFK_BLINK_SPEED_NORMAL);
-  garfunkel_blink (garfunkel, GFK_RED | GFK_YELLOW, GFK_BLINK_SPEED_NORMAL);
+  garfunkel_sequence_increment (garfunkel);
+  
+  garfunkel_sequence_blink (garfunkel);
 
   return FALSE;
 }
 
+
+static void
+garfunkel_sequence_increment (Garfunkel *garfunkel)
+{
+  GarfunkelPrivate * gp= NULL;
+
+  gp = garfunkel->priv;
+
+  gint32 color;
+  
+  color = g_random_int_range (0, 3);
+  
+  gp->sequence = g_slist_append (gp->sequence, GINT_TO_POINTER (1 << color));
+}
+
+
+static void
+garfunkel_sequence_blink (Garfunkel *garfunkel)
+{
+  GarfunkelPrivate * gp= NULL;
+
+  gp = garfunkel->priv;
+
+  GSList *tmplist;
+
+  tmplist = gp->sequence;
+
+  while(tmplist){
+  
+    garfunkel_blink (garfunkel, GPOINTER_TO_INT (tmplist->data), GFK_BLINK_SPEED_NORMAL);
+  	
+  	tmplist = g_slist_next(tmplist);
+  }
+} 
+



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