gnome-edu r14 - trunk/garfunkel/src
- From: brunobol svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-edu r14 - trunk/garfunkel/src
- Date: Wed, 14 May 2008 22:36:22 +0100 (BST)
Author: brunobol
Date: Wed May 14 21:36:21 2008
New Revision: 14
URL: http://svn.gnome.org/viewvc/gnome-edu?rev=14&view=rev
Log:
Garfunkel - code update
Modified:
trunk/garfunkel/src/garfunkel.c
trunk/garfunkel/src/garfunkel.h
Modified: trunk/garfunkel/src/garfunkel.c
==============================================================================
--- trunk/garfunkel/src/garfunkel.c (original)
+++ trunk/garfunkel/src/garfunkel.c Wed May 14 21:36:21 2008
@@ -33,14 +33,17 @@
#include "garfunkel.h"
+#define GFK_BLINK_SPEED_FAST 200000
+#define GFK_BLINK_SPEED_NORMAL 1000000
+
G_DEFINE_TYPE (Garfunkel, garfunkel, GTK_TYPE_DRAWING_AREA);
typedef enum
{
- GARFUNKEL_GREEN = 1 << 0,
- GARFUNKEL_RED = 1 << 1,
- GARFUNKEL_BLUE = 1 << 2,
- GARFUNKEL_YELLOW = 1 << 3
+ GFK_GREEN = 1 << 0,
+ GFK_RED = 1 << 1,
+ GFK_BLUE = 1 << 2,
+ GFK_YELLOW = 1 << 3
} GarfunkelLights;
@@ -48,15 +51,16 @@
RsvgHandle *svg_handle;
GarfunkelLights lights;
+
+ gulong blink_time;
- gboolean block_events;
-
- gboolean animate;
+ GSList *sequence;
+ GSList *user_sequence;
};
static gboolean garfunkel_expose (GtkWidget *widget, GdkEventExpose *event);
static void garfunkel_redraw (Garfunkel *garfunkel);
-void garfunkel_blink (Garfunkel *garfunkel, GarfunkelLights light);
+void garfunkel_blink (Garfunkel *garfunkel, GarfunkelLights light, gulong time);
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);
@@ -71,8 +75,8 @@
garfunkel->priv = g_new0 (GarfunkelPrivate, 1);
garfunkel->priv->lights = 0;
- garfunkel->priv->block_events = FALSE;
- garfunkel->priv->animate = FALSE;
+ garfunkel->priv->sequence = NULL;
+ garfunkel->priv->user_sequence = NULL;
}
static void garfunkel_finalize(GObject* object) {
@@ -150,22 +154,22 @@
rsvg_handle_render_cairo_sub (gp->svg_handle, cr, "#background");
- if (gp->lights & GARFUNKEL_GREEN)
+ if (gp->lights & GFK_GREEN)
rsvg_handle_render_cairo_sub (gp->svg_handle, cr, "#green-on");
else
rsvg_handle_render_cairo_sub (gp->svg_handle, cr, "#green");
- if (gp->lights & GARFUNKEL_RED)
+ if (gp->lights & GFK_RED)
rsvg_handle_render_cairo_sub (gp->svg_handle, cr, "#red-on");
else
rsvg_handle_render_cairo_sub (gp->svg_handle, cr, "#red");
- if (gp->lights & GARFUNKEL_BLUE)
+ if (gp->lights & GFK_BLUE)
rsvg_handle_render_cairo_sub (gp->svg_handle, cr, "#blue-on");
else
rsvg_handle_render_cairo_sub (gp->svg_handle, cr, "#blue");
- if (gp->lights & GARFUNKEL_YELLOW)
+ if (gp->lights & GFK_YELLOW)
rsvg_handle_render_cairo_sub (gp->svg_handle, cr, "#yellow-on");
else
rsvg_handle_render_cairo_sub (gp->svg_handle, cr, "#yellow");
@@ -210,10 +214,12 @@
void
-garfunkel_blink (Garfunkel *garfunkel, GarfunkelLights light)
+garfunkel_blink (Garfunkel *garfunkel, GarfunkelLights light, gulong time)
{
garfunkel->priv->lights = garfunkel->priv->lights | light;
+ garfunkel->priv->blink_time = time;
+
garfunkel_redraw (garfunkel);
g_thread_join (g_thread_create (garfunkel_blink_thread, (gpointer) garfunkel, TRUE, NULL));
@@ -229,14 +235,14 @@
garfunkel_redraw (garfunkel);
- g_usleep (GARFUNKEL_BLINK_TIME);
+ g_usleep (garfunkel->priv->blink_time);
}
static gboolean
garfunkel_key_press (GtkWidget *widget, GdkEventKey *event)
{
- garfunkel_blink ((Garfunkel *) widget, GARFUNKEL_GREEN);
+ garfunkel_blink ((Garfunkel *) widget, GFK_GREEN, GFK_BLINK_SPEED_NORMAL);
return FALSE;
}
@@ -248,11 +254,15 @@
Garfunkel *garfunkel;
garfunkel = (Garfunkel *) widget;
-
- garfunkel_blink (garfunkel, GARFUNKEL_GREEN);
- garfunkel_blink (garfunkel, GARFUNKEL_RED);
- garfunkel_blink (garfunkel, GARFUNKEL_BLUE);
- garfunkel_blink (garfunkel, GARFUNKEL_YELLOW);
+
+ 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);
return FALSE;
}
Modified: trunk/garfunkel/src/garfunkel.h
==============================================================================
--- trunk/garfunkel/src/garfunkel.h (original)
+++ trunk/garfunkel/src/garfunkel.h Wed May 14 21:36:21 2008
@@ -27,9 +27,6 @@
#include <gtk/gtk.h>
-/* lights' blink time */
-#define GARFUNKEL_BLINK_TIME 300000
-
G_BEGIN_DECLS
#define GARFUNKEL_TYPE (garfunkel_get_type ())
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]