Commit d58e0fe9 authored by Bruno Coudoin's avatar Bruno Coudoin

goocanvas port is going on. some activities work like before.

svn path=/branches/gcomprixogoo/; revision=3098
parent 30950181
......@@ -46,7 +46,6 @@ static gboolean read_xml_file(char *fname);
static GooCanvasItem *boardRootItem = NULL;
static GooCanvasItem *highlight_image_item = NULL;
static GooCanvasItem *clock_image_item = NULL;
static GdkPixbuf *clock_pixmap = NULL;
static GooCanvasItem *color_item = NULL;
static GooCanvasItem *colors_create_item(GooCanvasItem *parent);
......@@ -146,7 +145,8 @@ static void start_board (GcomprisBoard *agcomprisBoard) {
errors = MAX_ERRORS;
init_xml();
g_signal_connect(gcomprisBoard->canvas, "button_press_event",
g_signal_connect(goo_canvas_get_root_item(gcomprisBoard->canvas),
"button_press_event",
(GtkSignalFunc) item_event, NULL);
colors_next_level();
......@@ -250,7 +250,8 @@ static void colors_next_level() {
/* =====================================================================
* Destroy all the items
* =====================================================================*/
static void colors_destroy_all_items() {
static void colors_destroy_all_items()
{
if(boardRootItem!=NULL)
goo_canvas_item_remove(boardRootItem);
......@@ -260,9 +261,9 @@ static void colors_destroy_all_items() {
/* =====================================================================
*
* =====================================================================*/
static GooCanvasItem *colors_create_item(GooCanvasItem *parent) {
GdkPixbuf *highlight_pixmap = NULL;
static GooCanvasItem *colors_create_item(GooCanvasItem *parent)
{
GdkPixbuf *pixmap;
char *str = NULL;
int i;
......@@ -270,34 +271,38 @@ static GooCanvasItem *colors_create_item(GooCanvasItem *parent) {
NULL);
str = g_strdup_printf("%s/%s", gcomprisBoard->boarddir, "advanced_colors_highlight.png");
highlight_pixmap = gc_pixmap_load(str);
str = g_strdup_printf("%s/%s", gcomprisBoard->boarddir,
"advanced_colors_highlight.png");
pixmap = gc_pixmap_load(str);
highlight_image_item = goo_canvas_image_new (boardRootItem,
highlight_pixmap,
pixmap,
0,
0,
NULL);
highlight_width = gdk_pixbuf_get_width(highlight_pixmap);
highlight_height = gdk_pixbuf_get_height(highlight_pixmap);
highlight_width = gdk_pixbuf_get_width(pixmap);
highlight_height = gdk_pixbuf_get_height(pixmap);
g_free(str);
g_object_set (highlight_image_item, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL);
g_object_set (highlight_image_item,
"visibility", GOO_CANVAS_ITEM_INVISIBLE,
NULL);
i = g_random_int_range(0,LAST_COLOR);
gdk_pixbuf_unref(highlight_pixmap);
gdk_pixbuf_unref(pixmap);
/* setup the clock */
str = g_strdup_printf("%s%d.png", "timers/clock",errors);
clock_pixmap = gc_skin_pixmap_load(str);
pixmap = gc_skin_pixmap_load(str);
clock_image_item = goo_canvas_image_new (boardRootItem,
clock_pixmap,
pixmap,
CLOCK_X,
CLOCK_Y,
NULL);
gdk_pixbuf_unref(pixmap);
g_free(str);
return NULL;
......@@ -327,7 +332,8 @@ static void game_won() {
/* =====================================================================
*
* =====================================================================*/
static gboolean ok_timeout() {
static gboolean ok_timeout()
{
g_warning("+++ ok_timeout errors = %d\n", errors);
gc_bonus_display(gamewon, GC_BONUS_SMILEY);
if (!gamewon)
......@@ -366,7 +372,6 @@ static gboolean item_event (GooCanvasItem *item,
if (!gcomprisBoard || board_paused)
return FALSE;
return TRUE;
//goo_canvas_c2w (gcomprisBoard->canvas, x, y, &x, &y);
clicked = -1;
for (i=0; i<4; i++) {
......@@ -390,26 +395,25 @@ static gboolean item_event (GooCanvasItem *item,
/* =====================================================================
*
* =====================================================================*/
static void update_clock() {
char *str = g_strdup_printf("%s%d.png", "gcompris/timers/clock",errors);
gtk_object_destroy (GTK_OBJECT(clock_image_item));
static void update_clock()
{
GdkPixbuf *pixmap;
char *str = g_strdup_printf("%s%d.png", "timers/clock", errors);
clock_pixmap = gc_pixmap_load(str);
pixmap = gc_skin_pixmap_load(str);
clock_image_item = goo_canvas_image_new (boardRootItem,
clock_pixmap,
CLOCK_X,
CLOCK_Y,
NULL);
g_object_set(clock_image_item,
"pixbuf", pixmap,
NULL);
gdk_pixbuf_unref(clock_pixmap);
gdk_pixbuf_unref(pixmap);
g_free(str);
}
/* =====================================================================
*
* =====================================================================*/
static void highlight_selected(int c) {
static void highlight_selected(int c)
{
int x, y;
g_assert(c>=0 && c<8);
......@@ -419,7 +423,9 @@ static void highlight_selected(int c) {
x -= highlight_width/2;
y -= highlight_height;
g_object_set (highlight_image_item, "visibility", GOO_CANVAS_ITEM_VISIBLE, NULL);
g_object_set (highlight_image_item,
"visibility", GOO_CANVAS_ITEM_VISIBLE,
NULL);
gc_item_absolute_move(highlight_image_item, x, y);
}
......
This diff is collapsed.
......@@ -139,7 +139,8 @@ static Shape *create_shape(ShapeType type, char *name, char *tooltip,
char *targetfile, double x, double y, double l, double h, double zoomx,
double zoomy, guint position, char *soundfile);
static gboolean increment_sublevel(void);
static void create_title(char *name, double x, double y, GtkJustification justification,
static void create_title(char *name, double x, double y,
GtkAnchorType anchor,
guint32 color_rgba);
static gint item_event_ok(GooCanvasItem *item, GdkEvent *event, gpointer data);
static gint item_event_drag(GooCanvasItem *item, GdkEvent *event, gpointer data);
......@@ -519,11 +520,13 @@ static void shapegame_destroy_all_items()
if (shapelist_table)
{
/* Deleting the root item automatically deletes children items */
gtk_object_destroy (GTK_OBJECT(shape_list_root_item));
goo_canvas_item_remove(shape_list_root_item);
shape_list_root_item = NULL;
gtk_object_destroy (GTK_OBJECT(shape_root_item));
goo_canvas_item_remove(shape_root_item);
shape_root_item = NULL;
gtk_object_destroy (GTK_OBJECT(tooltip_root_item));
goo_canvas_item_remove(tooltip_root_item);
tooltip_root_item = NULL;
g_hash_table_destroy (shapelist_table);
......@@ -569,7 +572,6 @@ static void shapegame_init_canvas(GooCanvasItem *parent)
-1,
GTK_ANCHOR_CENTER,
"font", gc_skin_font_board_small,
"justification", GTK_JUSTIFY_CENTER,
"fill_color_rgba", gc_skin_color_shadow,
NULL);
tooltip_text_item = \
......@@ -580,7 +582,6 @@ static void shapegame_init_canvas(GooCanvasItem *parent)
-1,
GTK_ANCHOR_CENTER,
"font", gc_skin_font_board_small,
"justification", GTK_JUSTIFY_CENTER,
"fill_color_rgba", gc_skin_color_text_button,
NULL);
......@@ -621,12 +622,14 @@ add_shape_to_list_of_shapes(Shape *shape)
shapeBox.y + shapeBox.h,
NULL);
g_signal_connect(GTK_OBJECT(previous_shapelist_item), "enter_notify_event",
(GtkSignalFunc) item_event_ok,
"previous_shapelist");
g_signal_connect(GTK_OBJECT(previous_shapelist_item), "enter_notify_event",
(GtkSignalFunc) gc_item_focus_event,
NULL);
g_signal_connect(previous_shapelist_item,
"enter_notify_event",
(GtkSignalFunc) item_event_ok,
"previous_shapelist");
g_signal_connect(previous_shapelist_item,
"enter_notify_event",
(GtkSignalFunc) gc_item_focus_event,
NULL);
gdk_pixbuf_unref(pixmap);
pixmap = gc_skin_pixmap_load("button_forward.png");
......@@ -636,10 +639,10 @@ add_shape_to_list_of_shapes(Shape *shape)
shapeBox.y + shapeBox.h,
NULL);
g_signal_connect(GTK_OBJECT(next_shapelist_item), "enter_notify_event",
g_signal_connect(next_shapelist_item, "enter_notify_event",
(GtkSignalFunc) item_event_ok,
"next_shapelist");
g_signal_connect(GTK_OBJECT(next_shapelist_item), "enter_notify_event",
g_signal_connect(next_shapelist_item, "enter_notify_event",
(GtkSignalFunc) gc_item_focus_event,
NULL);
gdk_pixbuf_unref(pixmap);
......@@ -777,9 +780,9 @@ add_shape_to_list_of_shapes(Shape *shape)
shape->shapelistgroup_index, current_shapelistgroup_index);
icon_shape->shape_list_group_root = shape_list_group_root;
setup_item(item, icon_shape);
g_signal_connect(GTK_OBJECT(item), "enter_notify_event",
(GtkSignalFunc) gc_item_focus_event,
NULL);
g_signal_connect(item, "enter_notify_event",
(GtkSignalFunc) gc_item_focus_event,
NULL);
}
}
}
......@@ -956,10 +959,12 @@ static gint item_event_drag(GooCanvasItem *item, GdkEvent *event, gpointer data)
if(shadow_enable)
{
if(shadow_item)
gtk_object_destroy(GTK_OBJECT(shadow_item));
goo_canvas_item_remove(shadow_item);
// initialise shadow shape
GdkPixbuf *pixmap, *dest;
g_object_get(shape->target_shape->item, "pixbuf", &pixmap, NULL);
g_object_get(shape->target_shape->item,
"pixbuf", &pixmap, NULL);
dest = gdk_pixbuf_copy(pixmap);
pixbuf_add_transparent(dest, 100);
......@@ -1015,7 +1020,7 @@ static gint item_event_drag(GooCanvasItem *item, GdkEvent *event, gpointer data)
if(shadow_enable && shadow_item)
{
gtk_object_destroy(GTK_OBJECT(shadow_item));
goo_canvas_item_remove(shadow_item);
shadow_item = NULL;
}
......@@ -1233,11 +1238,11 @@ item_event_ok(GooCanvasItem *item, GdkEvent *event, gpointer data)
static void
setup_item(GooCanvasItem *item, Shape *shape)
{
g_signal_connect(GTK_OBJECT(item), "enter_notify_event",
g_signal_connect(item, "enter_notify_event",
(GtkSignalFunc) item_event,
shape);
g_signal_connect(GTK_OBJECT(item), "enter_notify_event",
(GtkSignalFunc) gc_drag_event, NULL);
g_signal_connect(item, "enter_notify_event",
(GtkSignalFunc) gc_drag_event, NULL);
}
/*
......@@ -1280,13 +1285,13 @@ add_shape_to_canvas(Shape *shape)
int point_size = 6;
/* Display a point to highlight the target location of this shape */
item = goo_canvas_ellipse_new (shape_root_item,
shape->x,
shape->y,
shape->x,
shape->y,
point_size,
point_size,
point_size,
"fill_color_rgba", POINT_COLOR_OFF,
"stroke-color", "black",
"width_pixels", 2,
"line-width", 2.0,
NULL);
shape->target_point = item;
}
......@@ -1333,7 +1338,8 @@ add_shape_to_canvas(Shape *shape)
}
static void create_title(char *name, double x, double y, GtkJustification justification,
static void create_title(char *name, double x, double y,
GtkAnchorType anchor,
guint32 color_rgba)
{
GooCanvasItem *item;
......@@ -1345,9 +1351,8 @@ static void create_title(char *name, double x, double y, GtkJustification justif
x + 1.0,
y + 1.0,
-1,
GTK_ANCHOR_CENTER,
anchor,
"font", gc_skin_font_board_medium,
"justification", justification,
"fill_color_rgba", gc_skin_color_shadow,
NULL);
......@@ -1359,9 +1364,8 @@ static void create_title(char *name, double x, double y, GtkJustification justif
x,
y,
-1,
GTK_ANCHOR_CENTER,
anchor,
"font", gc_skin_font_board_medium,
"justification", justification,
"fill_color_rgba", color_rgba,
NULL);
......@@ -1435,7 +1439,7 @@ add_xml_shape_to_data(xmlDocPtr doc, xmlNodePtr xmlnode, GNode * child, GList **
{
char *name,*ctype, *justification;
char *tooltip;
GtkJustification justification_gtk;
GtkAnchorType anchor_gtk;
char *pixmapfile = NULL;
char *targetfile = NULL;
char *soundfile = NULL;
......@@ -1514,17 +1518,17 @@ add_xml_shape_to_data(xmlDocPtr doc, xmlNodePtr xmlnode, GNode * child, GList **
type = SHAPE_TARGET;
/* get the JUSTIFICATION of the Title */
justification_gtk = GTK_JUSTIFY_CENTER; /* GTK_JUSTIFICATION_CENTER is default */
anchor_gtk = GTK_ANCHOR_CENTER; /* GTK_ANCHOR_CENTER is default */
justification = (char *)xmlGetProp(xmlnode, BAD_CAST "justification");
if(justification) {
if (strcmp(justification, "GTK_JUSTIFY_LEFT") == 0) {
justification_gtk = GTK_JUSTIFY_LEFT;
anchor_gtk = GTK_ANCHOR_WEST;
} else if (strcmp(justification, "GTK_JUSTIFY_RIGHT") == 0) {
justification_gtk = GTK_JUSTIFY_RIGHT;
anchor_gtk = GTK_ANCHOR_EAST;
} else if (strcmp(justification, "GTK_JUSTIFY_CENTER") == 0) {
justification_gtk = GTK_JUSTIFY_CENTER;
} else if (strcmp(justification, "GTK_JUSTIFY_FILL") == 0) {
justification_gtk = GTK_JUSTIFY_FILL;
anchor_gtk = GTK_ANCHOR_CENTER;
} else {
g_warning("Unknown justification '%s'", justification);
}
xmlFree(justification);
}
......@@ -1595,7 +1599,7 @@ add_xml_shape_to_data(xmlDocPtr doc, xmlNodePtr xmlnode, GNode * child, GList **
if(name != NULL) {
newname = g_strcompress(name);
create_title(newname, x, y, justification_gtk, color_rgba);
create_title(newname, x, y, anchor_gtk, color_rgba);
g_free(newname);
}
}
......
......@@ -365,7 +365,7 @@ static void clickgame_start (GcomprisBoard *agcomprisBoard)
/* set initial values for this level */
gcomprisBoard->level = 1;
gcomprisBoard->maxlevel=6;
gcomprisBoard->number_of_sublevel=10; /* Go to next level after this number of 'play' */
gcomprisBoard->number_of_sublevel=10;
gc_score_start(SCORESTYLE_NOTE,
gcomprisBoard->width - 220,
gcomprisBoard->height - 50,
......@@ -374,7 +374,7 @@ static void clickgame_start (GcomprisBoard *agcomprisBoard)
event_handle_id =
g_signal_connect(gcomprisBoard->canvas, "enter_notify_event",
(GtkSignalFunc) canvas_event, NULL);
(GtkSignalFunc) canvas_event, NULL);
clickgame_next_level();
clickgame_pause(FALSE);
......
......@@ -49,7 +49,7 @@ static void erase_next_level(void);
static void shuffle_image_list(char *list[], int size);
static gboolean item_event (GooCanvasItem *item,
GooCanvasItem *target,
GdkEventButton *event,
GdkEventCrossing *event,
gpointer data);
static gboolean canvas_event (GooCanvasItem *item,
GooCanvasItem *target,
......@@ -182,7 +182,7 @@ static void start_board (GcomprisBoard *agcomprisBoard)
gcomprisBoard->level=1;
gcomprisBoard->maxlevel=6;
gcomprisBoard->sublevel=1;
gcomprisBoard->number_of_sublevel=10; /* Go to next level after this number of 'play' */
gcomprisBoard->number_of_sublevel=10;
gc_bar_set(GC_BAR_LEVEL);
/* CAUTION: CoverPixmap has MAX_LAYERS elements */
......@@ -191,8 +191,9 @@ static void start_board (GcomprisBoard *agcomprisBoard)
CoverPixmap[2] = gc_pixmap_load("erase/transparent_square_yellow.png");
event_handle_id =
g_signal_connect(GTK_OBJECT(gcomprisBoard->canvas), "button_press_event",
(GtkSignalFunc) canvas_event, 0);
g_signal_connect(goo_canvas_get_root_item(gcomprisBoard->canvas),
"button_press_event",
(GtkSignalFunc) canvas_event, NULL);
if (strcmp(gcomprisBoard->mode,"clic")==0)
board_mode = CLIC;
......@@ -430,7 +431,8 @@ static void finished() {
}
/* ==================================== */
static void game_won()
static void
game_won()
{
gcomprisBoard->sublevel++;
......@@ -438,7 +440,8 @@ static void game_won()
/* Try the next level */
gcomprisBoard->sublevel=1;
gcomprisBoard->level++;
if(gcomprisBoard->level>gcomprisBoard->maxlevel) { // the current board is finished : bail out
/* the current board is finished : bail out */
if(gcomprisBoard->level>gcomprisBoard->maxlevel) {
timer_id = gtk_timeout_add (2000, (GtkFunction) finished, NULL);
return;
}
......@@ -450,11 +453,13 @@ static void game_won()
static gboolean
erase_one_item (GooCanvasItem *item)
{
double screen_x, screen_y;
gdouble screen_x, screen_y;
int x,y;
g_object_get(item, "x", &screen_x, "y", &screen_y, NULL);
goo_canvas_convert_from_item_space(goo_canvas_item_get_canvas(item),
item, &screen_x, &screen_y);
x = screen_x / (BOARDWIDTH/number_of_item_x);
y = screen_y / (BOARDHEIGHT/number_of_item_y);
if (items_per_cell)
items_per_cell[(int) (x * number_of_item_x + y)]--;
......@@ -479,7 +484,7 @@ erase_one_item (GooCanvasItem *item)
static gboolean
item_event (GooCanvasItem *item,
GooCanvasItem *target,
GdkEventButton *event,
GdkEventCrossing *event,
gpointer data)
{
counter *c = (counter *) data;
......@@ -513,10 +518,11 @@ item_event (GooCanvasItem *item,
return FALSE;
}
static gboolean canvas_event (GooCanvasItem *item,
GooCanvasItem *target,
GdkEventButton *event,
gpointer data)
static gboolean
canvas_event (GooCanvasItem *item,
GooCanvasItem *target,
GdkEventButton *event,
gpointer data)
{
if (!gcomprisBoard || board_paused)
return FALSE;
......@@ -527,8 +533,10 @@ static gboolean canvas_event (GooCanvasItem *item,
int y = event->y;
int item_x = x / (BOARDWIDTH/number_of_item_x);
int item_y = y / (BOARDHEIGHT/number_of_item_y);
if (items_per_cell[item_x * number_of_item_x + item_y] == 0)
add_one_item(x, y, 1);
}
return FALSE;
......
......@@ -57,7 +57,8 @@ gc_anim_load(char *filename)
/* read filenames, one per line, from the animation spec-file */
while(fscanf(f, "%99s", tmp) == 1)
files = g_slist_append(files,
g_strdup_printf("%s/%s", gc_prop_get()->package_data_dir, tmp));
g_strdup_printf("%s/%s",
gc_prop_get()->package_data_dir, tmp));
fclose(f);
anim = g_malloc(sizeof(GcomprisAnimation));
anim->numstates = g_slist_length(files);
......@@ -88,15 +89,20 @@ GcomprisAnimCanvasItem *
gc_anim_activate(GooCanvasItem *parent,
GcomprisAnimation *anim)
{
GcomprisAnimCanvasItem *item = g_malloc(sizeof(GcomprisAnimCanvasItem));
GcomprisAnimCanvasItem *item;
g_assert(parent != NULL);
// g_assert(anim != NULL);
item = g_malloc(sizeof(GcomprisAnimCanvasItem));
item->state = 0;
item->anim = anim;
item->iter = gdk_pixbuf_animation_get_iter(anim->anim[0], NULL);
item->canvas = (GooCanvasImage*) goo_canvas_image_new(
parent,
gdk_pixbuf_animation_iter_get_pixbuf(item->iter),
0, 0);
item->canvas = goo_canvas_image_new(parent,
gdk_pixbuf_animation_iter_get_pixbuf(item->iter),
0, 0,
NULL);
if(active == NULL)
g_timeout_add(TICK_TIME, (GSourceFunc)anim_tick, NULL);
......@@ -123,7 +129,7 @@ gc_anim_deactivate(GcomprisAnimCanvasItem *item)
}
if (GOO_IS_CANVAS_ITEM(item->canvas)){
gtk_object_destroy(GTK_OBJECT(item->canvas));
goo_canvas_item_remove(item->canvas);
item->canvas = NULL;
}
......@@ -158,9 +164,10 @@ gc_anim_set_state(GcomprisAnimCanvasItem *item, int state)
g_object_unref( item->iter );
item->iter = gdk_pixbuf_animation_get_iter( item->anim->anim[item->state],
NULL );
g_object_set( (GooCanvasItem*)item->canvas, "pixbuf",
gdk_pixbuf_animation_iter_get_pixbuf(item->iter),
NULL);
g_object_set( (GooCanvasItem*)item->canvas,
"pixbuf",
gdk_pixbuf_animation_iter_get_pixbuf(item->iter),
NULL);
}
/* private callback functions */
......@@ -180,9 +187,9 @@ anim_tick(void *ignore)
GcomprisAnimCanvasItem *a = (GcomprisAnimCanvasItem*)cur->data;
if( gdk_pixbuf_animation_iter_advance( a->iter, NULL) )
{
g_object_set((GooCanvasItem*)a->canvas, "pixbuf",
gdk_pixbuf_animation_iter_get_pixbuf(a->iter),
NULL);
g_object_set(a->canvas, "pixbuf",
gdk_pixbuf_animation_iter_get_pixbuf(a->iter),
NULL);
}
}
return TRUE;
......
......@@ -33,7 +33,7 @@ typedef struct {
} GcomprisAnimation;
typedef struct {
GooCanvasImage *canvas;
GooCanvasItem *canvas;
GcomprisAnimation *anim;
GdkPixbufAnimationIter *iter;
int state;
......
......@@ -147,7 +147,7 @@ void gc_selector_file_stop ()
// Destroy the file_selector box
/* FIXME: Crashes randomly */
if(rootitem!=NULL)
gtk_object_destroy(GTK_OBJECT(rootitem));
goo_canvas_item_remove(rootitem);
rootitem = NULL;
......
......@@ -212,7 +212,7 @@ void gc_item_focus_set(GooCanvasItem *item, gboolean focus)
GdkPixbuf *pixbuf;
GdkPixbuf *pixbuf_ref;
gtk_object_get (GTK_OBJECT (item), "pixbuf", &pixbuf, NULL);
g_object_get (item, "pixbuf", &pixbuf, NULL);
g_return_if_fail (pixbuf != NULL);
gdk_pixbuf_unref(pixbuf);
......
......@@ -503,8 +503,9 @@ GooCanvasItem *gc_set_background(GooCanvasItem *parent, gchar *file)
background_pixmap = gc_pixmap_load (file);
if(backgroundimg)
g_object_set_data (G_OBJECT(backgroundimg),
"pixbuf", background_pixmap);
g_object_set(backgroundimg,
"pixbuf", background_pixmap,
NULL);
else
backgroundimg = goo_canvas_image_new (parent,
background_pixmap,
......@@ -523,7 +524,8 @@ GooCanvasItem *gc_set_background(GooCanvasItem *parent, gchar *file)
/* Redraw the black background
*/
static gboolean
_expose_background_callback (GtkWidget *widget, GdkEventExpose *event, gpointer data)
_expose_background_callback (GtkWidget *widget,
GdkEventExpose *event, gpointer data)
{
gint screen_height, screen_width;
......
......@@ -98,7 +98,8 @@ gc_score_set(guint value)
goo_canvas_image_new (boardRootItem,
button_pixmap,
x,
y-gdk_pixbuf_get_height(button_pixmap)/2);
y-gdk_pixbuf_get_height(button_pixmap)/2,
NULL);
tmp = g_strdup_printf("%d/%d", value, max);
display_number(boardRootItem,
......
......@@ -31,8 +31,8 @@ static double ystep;
static int timer;
static double subratio;
static TimerList type;
static gint timer_increment (GtkWidget *widget, gpointer data);
static gint subtimer_increment (GtkWidget *widget, gpointer data);
static gint timer_increment (GooCanvasItem *item);
static gint subtimer_increment (GooCanvasItem *item);
static void start_animation();
static GooCanvasItem *boardRootItem = NULL;
static gint animate_id = 0;
......@@ -118,7 +118,9 @@ gc_timer_display(int ax, int ay, TimerList atype, int second, GcomprisTimerEnd a
y,
NULL);
/* Calc the number of step needed to reach the sea based on user y and second */
/* Calc the number of step needed to reach
* the sea based on user y and second
*/
ystep = (BOARDHEIGHT-y-gdk_pixbuf_get_height(pixmap))/second;
gdk_pixbuf_unref(pixmap);
......@@ -216,11 +218,15 @@ start_animation()
case GCOMPRIS_TIMER_BALLOON:
/* Perform under second animation */
subratio = 5;
subanimate_id = gtk_timeout_add (1000/subratio, (GtkFunction) subtimer_increment, NULL);
subanimate_id = gtk_timeout_add (1000/subratio,
(GtkFunction) subtimer_increment,
gc_timer_item);
break;
}
animate_id = gtk_timeout_add (1000, (GtkFunction) timer_increment, NULL);
animate_id = gtk_timeout_add (1000,
(GtkFunction) timer_increment,
gc_timer_item);
}
......@@ -244,7 +250,7 @@ display_time_ellapsed()
static gint
subtimer_increment(GtkWidget *widget, gpointer data)
subtimer_increment(GooCanvasItem *item)
{
if(paused)
return(FALSE);
......@@ -255,10 +261,9 @@ subtimer_increment(GtkWidget *widget, gpointer data)
/* Display the value for this timer */
y+=ystep/subratio;
if(gc_timer_item)
g_object_set(gc_timer_item,
g_object_set(item,
"y", y,
NULL);
// goo_canvas_update_now(gc_get_canvas());
break;
default:
break;
......@@ -267,7 +272,7 @@ subtimer_increment(GtkWidget *widget, gpointer data)
}
static gint
timer_increment(GtkWidget *widget, gpointer data)
timer_increment(GooCanvasItem *item)
{
if(paused)
return(FALSE);
......@@ -290,33 +295,34 @@ timer_increment(GtkWidget *widget, gpointer data)
{
case GCOMPRIS_TIMER_SAND:
case GCOMPRIS_TIMER_CLOCK:
if(gc_timer_item)
if(item)
{
GdkPixbuf *pixmap = NULL;
gchar *filename = NULL;
gint fileid;
gint fileid;
fileid = (gint)timer;
if(type==GCOMPRIS_TIMER_SAND)
if(type == GCOMPRIS_TIMER_SAND)
filename = g_strdup_printf("timers/sablier%d.png", fileid);
else
filename = g_strdup_printf("timers/clock%d.png", fileid);
pixmap = gc_skin_pixmap_load(filename);
g_object_set(gc_timer_item,
"pixbuf", pixmap,
NULL);
g_object_set(item,
"pixbuf", pixmap,
NULL);
gdk_pixbuf_unref(pixmap);
g_free(filename);
}
break;
case GCOMPRIS_TIMER_TEXT:
/* Display the value for this timer */
if(gc_timer_item)
if(item)
{
char *tmpstr = g_strdup_printf(_("Remaining Time = %d"), timer);
g_object_set_data (G_OBJECT(gc_timer_item),
"text", tmpstr);
g_object_set (item,
"text", tmpstr,
NULL);
g_free(tmpstr);
}