Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruno Coudoin <bcoudoin@src.gnome.org>2006-10-15 02:56:45 (GMT)
committer Bruno Coudoin <bcoudoin@src.gnome.org>2006-10-15 02:56:45 (GMT)
commit6470b304ec68f6d2c6b705f1c938211dab99dfda (patch)
treeb1151053857df2adbd1c801ff5be9fbe5817ad22
parentb232d93bddff0d6fec3e3c90933b316fe5e2b490 (diff)
*** RELEASE 8.1 ***
- Fixed a major crash case on images with a focus and a changing image like the level icon.
-rw-r--r--ChangeLog29
-rw-r--r--Makefile.mingw14
-rw-r--r--configure.in2
-rw-r--r--src/boards/click_on_letter.c48
-rw-r--r--src/boards/reversecount.c56
-rw-r--r--src/gcompris/bar.c7
-rw-r--r--src/gcompris/board.c13
-rw-r--r--src/gcompris/config.c9
-rw-r--r--src/gcompris/gameutil.c20
-rw-r--r--src/gcompris/gameutil.h5
-rw-r--r--src/gcompris/gcompris.c32
-rw-r--r--src/gcompris/help.c62
12 files changed, 161 insertions, 136 deletions
diff --git a/ChangeLog b/ChangeLog
index a2265e3..9f438f7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2006-10-15 Bruno coudoin <bruno.coudoin@free.fr>
+
+ - Fixed a major crash case on images with a focus and a changing image
+ like the level icon.
+
+ * Makefile.mingw:
+ * src/boards/click_on_letter.c: (sounds_are_fine),
+ (click_on_letter_create_item), (item_event), (highlight_selected),
+ (save_table), (conf_ok), (config_start):
+ * src/boards/reversecount.c: (key_press), (process_ok),
+ (reversecount_create_item), (display_random_fish),
+ (display_item_at), (item_event), (create_clock), (update_clock),
+ (animate_tux):
+ * src/gcompris/bar.c: (gc_bar_set_level), (gc_bar_set_repeat_icon):
+ * src/gcompris/board.c: (gc_board_check_file):
+ * src/gcompris/config.c: (item_event_ok):
+ * src/gcompris/gameutil.c: (gc_item_focus_free),
+ (gc_item_focus_set), (gc_item_focus_event):
+ * src/gcompris/gameutil.h:
+ * src/gcompris/gcompris.c: (activation_enter_callback):
+ * src/gcompris/help.c: (gc_help_start), (gc_help_stop),
+ (select_item), (item_event_help):
+
*** RELEASE 8.0 ***
2006-10-15 Bruno coudoin <bruno.coudoin@free.fr>
@@ -182,12 +205,6 @@
2006-10-10 Bruno coudoin <bruno.coudoin@free.fr>
- reviewed by: <delete if not using a buddy>
-
- * src/gcompris/gameutil.c: (gc_item_focus_set):
-
-2006-10-10 Bruno coudoin <bruno.coudoin@free.fr>
-
- José JORGE created a new set of icons that were missing for the memory
* board/boardicons/mem_solo_calc.png
diff --git a/Makefile.mingw b/Makefile.mingw
index 48f8077..b61d66c 100644
--- a/Makefile.mingw
+++ b/Makefile.mingw
@@ -18,14 +18,12 @@ LIBXML2_TOP := /libxml2
SDL_TOP := /sdl
CANVAS_TOP := /gnomecanvas
GNUCHESS_TOP := /gnuchess
-GNUCAP_TOP := /gnucap
MAKENSIS := "/c/Program Files/NSIS/makensis.exe"
# These will be copied in the win32-install-dir ready to be packaged.
NEEDED_DLLS = $(GNUCHESS_TOP)/bin/pthreadGC.dll \
$(GNUCHESS_TOP)/bin/libreadline.dll \
- $(GNUCAP_TOP)/src/MSW/gnucap.exe \
$(GTK_TOP)/bin/gspawn-win32-helper.exe \
$(GNUCHESS_TOP)/bin/gnuchess.exe \
$(GNUWIN32_TOP)/bin/popt1.dll \
@@ -57,10 +55,8 @@ NEEDED_DLLS = $(GNUCHESS_TOP)/bin/pthreadGC.dll \
$(GTK_TOP)/expat/bin/xmltok.dll \
$(GTK_TOP)/bin/iconv.dll \
$(GTK_TOP)/bin/intl.dll \
- $(GTK_TOP)/bin/libpng13.dll \
- $(GTK_TOP)/bin/jpeg62.dll \
- $(GTK_TOP)/bin/libcairo-2.dll \
- $(GTK_TOP)/bin/libpangocairo-1.0-0.dll
+ $(GTK_TOP)/bin/libpng12.dll \
+ $(GTK_TOP)/bin/jpeg62.dll
NEEDED_FILES = README \
COPYING \
@@ -80,11 +76,6 @@ install: all
mkdir -p $(GCOMPRIS_INSTALL_DIR)/share
$(MAKE) -C $(GCOMPRIS_BOARDS) -f Makefile.mingw install
$(MAKE) -C $(GCOMPRIS_SRC) -f Makefile.mingw install
- mkdir -p $(GCOMPRIS_INSTALL_DIR)/share/gcompris
- cp -r $(GCOMPRIS_BOARDS)/python $(GCOMPRIS_INSTALL_DIR)/share/gcompris
- rm -f $(GCOMPRIS_INSTALL_DIR)/share/gcompris/python/Makefile*
- rm -f $(GCOMPRIS_INSTALL_DIR)/share/gcompris/python/gcompris/Makefile*
- rm -f $(GCOMPRIS_INSTALL_DIR)/share/gcompris/python/admin/Makefile*
# Copy mandratory files for the package in the package directory
prepack:
@@ -113,6 +104,7 @@ clean:
# Run this on Linux to prepare datadir for windows
#
prep:
+ mkdir $(GCOMPRIS_INSTALL_DIR)
mkdir -p $(GCOMPRIS_INSTALL_DIR)/share/$(pkgdatadir)/boards
cd boards ; tar cf - --exclude "Makefile.in" --exclude "*.in" --exclude "*~" --exclude "Makefile" --exclude "Makefile.am" --exclude CVS --exclude .xvpics * | ( cd ../$(GCOMPRIS_INSTALL_DIR)/share/$(pkgdatadir)/boards ; tar xf -) ; cd .. ;
@echo "-------------------------------------------------------------------------------"
diff --git a/configure.in b/configure.in
index 0fc63f5..5a32baa 100644
--- a/configure.in
+++ b/configure.in
@@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script.
AC_INIT(src/gcompris/gcompris.c)
AC_CANONICAL_TARGET
-AM_INIT_AUTOMAKE(gcompris, 8.0)
+AM_INIT_AUTOMAKE(gcompris, 8.1)
AM_CONFIG_HEADER(config.h)
AM_MAINTAINER_MODE
diff --git a/src/boards/click_on_letter.c b/src/boards/click_on_letter.c
index 00318b7..2c004d5 100644
--- a/src/boards/click_on_letter.c
+++ b/src/boards/click_on_letter.c
@@ -266,14 +266,14 @@ static gboolean sounds_are_fine()
/* TRANSLATORS: Put here the alphabet in your language */
alphabet=_("abcdefghijklmnopqrstuvwxyz");
assert(g_utf8_validate(alphabet, -1, NULL)); // require by all utf8-functions
-
+
gchar *letter = g_new0(gchar, 8);
g_unichar_to_utf8(g_utf8_get_char(alphabet), letter);
letter_str = gc_sound_alphabet(letter);
g_free(letter);
str2 = gc_file_find_absolute("sounds/$LOCALE/alphabet/%s", letter_str);
-
+
if (!str2)
{
gchar *locale = NULL;
@@ -358,7 +358,7 @@ static GnomeCanvasItem *click_on_letter_create_item(GnomeCanvasGroup *parent)
for (i=0;i<number_of_letters;i++){
numbers[i]=((int)(((float)length_of_aphabet)*rand()/(RAND_MAX+1.0)));
- // check that the letter has not been taken yet
+ // check that the letter has not been taken yet
for(j=0;j<i;j++){
if (numbers[i]==numbers[j]) {
i--;
@@ -380,10 +380,10 @@ static GnomeCanvasItem *click_on_letter_create_item(GnomeCanvasGroup *parent)
case 1 :
case 2 : letters[i]=g_strndup(copy_from,copy_to-copy_from); break;
case 3 : letters[i]=g_utf8_strup(copy_from,copy_to-copy_from); break;
- default :
- if ( rand() > (RAND_MAX/2) )
+ default :
+ if ( rand() > (RAND_MAX/2) )
letters[i]=g_strndup(copy_from,copy_to-copy_from);
- else
+ else
letters[i]=g_utf8_strup(copy_from,copy_to-copy_from);
}
}
@@ -395,7 +395,7 @@ static GnomeCanvasItem *click_on_letter_create_item(GnomeCanvasGroup *parent)
right_letter = g_utf8_strdown(letters[right_position],-1);
repeat();
-
+
boardRootItem = GNOME_CANVAS_GROUP(
gnome_canvas_item_new (gnome_canvas_root(gcomprisBoard->canvas),
@@ -488,7 +488,7 @@ item_event(GnomeCanvasItem *item, GdkEvent *event, gpointer data)
case GDK_BUTTON_PRESS:
/* We really don't want the user to change his/her mind */
board_paused = TRUE;
-
+
if ( pos == right_position ) {
gamewon = TRUE;
} else {
@@ -521,7 +521,7 @@ static void highlight_selected(GnomeCanvasItem * item) {
if (selected_button != NULL && selected_button != button) {
button_pixmap = gc_pixmap_load("images/wagon-yellow.png");
/* Warning changing the image needs to update pixbuf_ref for the focus usage */
- g_object_set_data (G_OBJECT (selected_button), "pixbuf_ref", button_pixmap);
+ gc_item_focus_free(selected_button, NULL);
gnome_canvas_item_set(selected_button, "pixbuf", button_pixmap, NULL);
gdk_pixbuf_unref(button_pixmap);
}
@@ -529,7 +529,7 @@ static void highlight_selected(GnomeCanvasItem * item) {
if (selected_button != button) {
button_pixmap_selected = gc_pixmap_load("images/wagon-green.png");
/* Warning changing the image needs to update pixbuf_ref for the focus usage */
- g_object_set_data (G_OBJECT (button), "pixbuf_ref", button_pixmap_selected);
+ gc_item_focus_free(button, NULL);
gnome_canvas_item_set(button, "pixbuf", button_pixmap_selected, NULL);
selected_button = button;
gdk_pixbuf_unref(button_pixmap_selected);
@@ -556,13 +556,13 @@ static GHFunc save_table (gpointer key,
{
gc_db_set_board_conf ( profile_conf,
board_conf,
- (gchar *) key,
+ (gchar *) key,
(gchar *) value);
return NULL;
}
-static void
+static void
conf_ok(GHashTable *table)
{
if (!table){
@@ -571,10 +571,10 @@ conf_ok(GHashTable *table)
return;
}
-
+
g_hash_table_foreach(table, (GHFunc) save_table, NULL);
-
+
board_conf = NULL;
profile_conf = NULL;
@@ -587,7 +587,7 @@ conf_ok(GHashTable *table)
gc_locale_reset();
gc_locale_set(g_hash_table_lookup(config, "locale_sound"));
-
+
gchar *up_init_str = g_hash_table_lookup( config, "uppercase_only");
if (up_init_str)
{
@@ -599,14 +599,14 @@ conf_ok(GHashTable *table)
if (profile_conf)
g_hash_table_destroy(config);
-
+
sounds_are_fine();
-
+
click_on_letter_next_level();
-
+
gamewon = FALSE;
pause_board(FALSE);
-
+
}
board_conf = NULL;
@@ -624,11 +624,11 @@ config_start(GcomprisBoard *agcomprisBoard,
pause_board(TRUE);
gchar *label = g_strdup_printf("<b>%s</b> configuration\n for profile <b>%s</b>",
- agcomprisBoard->name,
+ agcomprisBoard->name,
aProfile ? aProfile->name : "");
gc_board_config_window_display(label, conf_ok);
-
+
g_free(label);
/* init the combo to previously saved value */
@@ -638,7 +638,7 @@ config_start(GcomprisBoard *agcomprisBoard,
gc_board_config_combo_locales_asset( "Select sound locale", saved_locale_sound,
"sounds/$LOCALE/colors/purple.ogg");
-
+
gboolean up_init = FALSE;
gchar *up_init_str = g_hash_table_lookup( config, "uppercase_only");
@@ -653,11 +653,11 @@ config_start(GcomprisBoard *agcomprisBoard,
g_hash_table_destroy(config);
}
-
+
/* ======================= */
/* = config_stop = */
/* ======================= */
-static void
+static void
config_stop()
{
}
diff --git a/src/boards/reversecount.c b/src/boards/reversecount.c
index 81a7e77..5fb9a41 100644
--- a/src/boards/reversecount.c
+++ b/src/boards/reversecount.c
@@ -273,7 +273,7 @@ gint key_press(guint keyval, gchar *commit_str, gchar *preedit_str)
case GDK_Hyper_L:
case GDK_Hyper_R:
case GDK_Num_Lock:
- return FALSE;
+ return FALSE;
case GDK_KP_Enter:
case GDK_Return:
process_ok();
@@ -326,7 +326,7 @@ static void process_ok()
if(!animate_id) {
animate_id = gtk_timeout_add (animate_speed, (GtkFunction) animate_tux, NULL);
}
-
+
}
/*-------------------------------------------------------------------------------*/
@@ -465,24 +465,24 @@ static GnomeCanvasItem *reversecount_create_item(GnomeCanvasGroup *parent)
j=0;
item = gnome_canvas_item_new (boardRootItem,
gnome_canvas_pixbuf_get_type (),
- "pixbuf", pixmap,
+ "pixbuf", pixmap,
"x", (double) i,
"y", (double) j,
"width", (double) block_width,
"height", (double) block_height,
- "width_set", TRUE,
+ "width_set", TRUE,
"height_set", TRUE,
NULL);
j=BOARDHEIGHT-block_height;
item = gnome_canvas_item_new (boardRootItem,
gnome_canvas_pixbuf_get_type (),
- "pixbuf", pixmap,
+ "pixbuf", pixmap,
"x", (double) i,
"y", (double) j,
"width", (double) block_width,
"height", (double) block_height,
- "width_set", TRUE,
+ "width_set", TRUE,
"height_set", TRUE,
NULL);
}
@@ -492,24 +492,24 @@ static GnomeCanvasItem *reversecount_create_item(GnomeCanvasGroup *parent)
i = 0;
item = gnome_canvas_item_new (boardRootItem,
gnome_canvas_pixbuf_get_type (),
- "pixbuf", pixmap,
+ "pixbuf", pixmap,
"x", (double) i,
"y", (double) j,
"width", (double) block_width,
"height", (double) block_height,
- "width_set", TRUE,
+ "width_set", TRUE,
"height_set", TRUE,
NULL);
i = BOARDWIDTH - block_width;
item = gnome_canvas_item_new (boardRootItem,
gnome_canvas_pixbuf_get_type (),
- "pixbuf", pixmap,
+ "pixbuf", pixmap,
"x", (double) i,
"y", (double) j,
"width", (double) block_width,
"height", (double) block_height,
- "width_set", TRUE,
+ "width_set", TRUE,
"height_set", TRUE,
NULL);
}
@@ -525,7 +525,7 @@ static GnomeCanvasItem *reversecount_create_item(GnomeCanvasGroup *parent)
gnome_canvas_item_new (boardRootItem,
gnome_canvas_pixbuf_get_type (),
- "pixbuf", pixmap,
+ "pixbuf", pixmap,
"x", (double) dice_area_x,
"y", (double) block_height + 20,
NULL);
@@ -545,14 +545,14 @@ static GnomeCanvasItem *reversecount_create_item(GnomeCanvasGroup *parent)
item = gnome_canvas_item_new (boardRootItem,
gnome_canvas_pixbuf_get_type (),
- "pixbuf", pixmap,
+ "pixbuf", pixmap,
"x", (double) i,
"y", (double) j,
NULL);
dicevalue_array[d] = 1;
val = g_new(gint, 1);
*val = d;
- gtk_signal_connect(GTK_OBJECT(item), "event", (GtkSignalFunc) item_event,
+ gtk_signal_connect(GTK_OBJECT(item), "event", (GtkSignalFunc) item_event,
val);
gtk_signal_connect(GTK_OBJECT(item), "event",
(GtkSignalFunc) gc_item_focus_event,
@@ -573,7 +573,7 @@ static GnomeCanvasItem *reversecount_create_item(GnomeCanvasGroup *parent)
static void display_random_fish()
{
- fish_index = tux_index +
+ fish_index = tux_index +
rand()%(max_dice_number*number_of_dices) + 1;
// Wrapping
@@ -607,7 +607,7 @@ static GnomeCanvasItem *display_item_at(gchar *imagename, int block, double rati
g_warning(" // Upper line\n");
i = block_width * block;
j = 0;
- }
+ }
else if(block < number_of_item_x + number_of_item_y - 2)
{
// Right line
@@ -628,7 +628,7 @@ static GnomeCanvasItem *display_item_at(gchar *imagename, int block, double rati
// Left line
g_warning(" // Left line\n");
i = 0;
- j = block_height * (number_of_item_y - (block - (number_of_item_x*2 +
+ j = block_height * (number_of_item_y - (block - (number_of_item_x*2 +
number_of_item_y-4)));
}
@@ -648,14 +648,14 @@ static GnomeCanvasItem *display_item_at(gchar *imagename, int block, double rati
item = gnome_canvas_item_new (boardRootItem,
gnome_canvas_pixbuf_get_type (),
- "pixbuf", pixmap,
+ "pixbuf", pixmap,
"x", (double) i + (block_width -
(gdk_pixbuf_get_width (pixmap) * xratio)) / 2,
"y", (double) j + (block_height -
(gdk_pixbuf_get_height (pixmap) * yratio)) / 2,
"width", (double) gdk_pixbuf_get_width (pixmap) * xratio,
"height", (double) gdk_pixbuf_get_height (pixmap) * yratio,
- "width_set", TRUE,
+ "width_set", TRUE,
"height_set", TRUE,
NULL);
@@ -697,10 +697,10 @@ item_event(GnomeCanvasItem *item, GdkEvent *event, gint *dice_index)
if(board_paused)
return FALSE;
- switch (event->type)
+ switch (event->type)
{
case GDK_BUTTON_PRESS:
- switch(event->button.button)
+ switch(event->button.button)
{
case 1:
if(dicevalue_array[i]++ >= max_dice_number)
@@ -716,11 +716,11 @@ item_event(GnomeCanvasItem *item, GdkEvent *event, gint *dice_index)
}
str = g_strdup_printf("gcompris/dice/gnome-dice%d.png", dicevalue_array[i]);
-
+
pixmap = gc_pixmap_load(str);
/* Warning changing the image needs to update pixbuf_ref for the focus usage */
- g_object_set_data (G_OBJECT (item), "pixbuf_ref", pixmap);
+ gc_item_focus_free(item, NULL);
gnome_canvas_item_set (item,
"pixbuf", pixmap,
NULL);
@@ -739,7 +739,7 @@ item_event(GnomeCanvasItem *item, GdkEvent *event, gint *dice_index)
/*
* Clock management
*/
-static void create_clock(double x, double y, int value)
+static void create_clock(double x, double y, int value)
{
GdkPixbuf *pixmap = NULL;
char *str = NULL;
@@ -757,12 +757,12 @@ static void create_clock(double x, double y, int value)
"x", (double) x,
"y", (double) y,
NULL);
-
+
gdk_pixbuf_unref(pixmap);
g_free(str);
}
-static void update_clock(int value)
+static void update_clock(int value)
{
GdkPixbuf *pixmap = NULL;
char *str = NULL;
@@ -777,7 +777,7 @@ static void update_clock(int value)
gnome_canvas_item_set (clock_image_item,
"pixbuf", pixmap,
NULL);
-
+
gdk_pixbuf_unref(pixmap);
g_free(str);
}
@@ -825,9 +825,9 @@ static gint animate_tux()
// Remove the fish
if(fishItem!=NULL)
gtk_object_destroy(GTK_OBJECT(fishItem));
-
+
gc_sound_play_ogg ("sounds/gobble.ogg", NULL);
-
+
if(--number_of_fish == 0)
{
gamewon = TRUE;
diff --git a/src/gcompris/bar.c b/src/gcompris/bar.c
index 91a2797..b4ddc9a 100644
--- a/src/gcompris/bar.c
+++ b/src/gcompris/bar.c
@@ -296,8 +296,9 @@ void gc_bar_set_level(GcomprisBoard *gcomprisBoard)
pixmap = gc_skin_pixmap_load(str);
g_free(str);
- /* Warning changing the image needs to update pixbuf_ref for the focus usage */
- g_object_set_data (G_OBJECT (level_item), "pixbuf_ref", pixmap);
+ /* Warning changing the image needs to free the focus first */
+ gc_item_focus_free(level_item, NULL);
+
gnome_canvas_item_set (level_item,
"pixbuf", pixmap,
NULL);
@@ -322,7 +323,7 @@ void
gc_bar_set_repeat_icon (GdkPixbuf *pixmap)
{
/* Warning changing the image needs to update pixbuf_ref for the focus usage */
- g_object_set_data (G_OBJECT (repeat_item), "pixbuf_ref", pixmap);
+ gc_item_focus_free(repeat_item, NULL);
gnome_canvas_item_set (repeat_item,
"pixbuf", pixmap,
NULL);
diff --git a/src/gcompris/board.c b/src/gcompris/board.c
index af722d9..1feffd7 100644
--- a/src/gcompris/board.c
+++ b/src/gcompris/board.c
@@ -33,8 +33,8 @@ static gboolean get_board_playing(void);
# define WIN32
#endif
-
#ifdef WIN32
+extern gchar *keycode[];
extern BoardPlugin * get_advanced_colors_bplugin_info();
extern BoardPlugin * get_algebra_bplugin_info();
extern BoardPlugin * get_algebra_guesscount_bplugin_info();
@@ -211,6 +211,7 @@ gc_board_check_file(GcomprisBoard *gcomprisBoard)
GcomprisProperties *properties = gc_prop_get();
BoardPlugin *bp;
guint i=0;
+ guint key_is_valid = 0;
g_assert(gcomprisBoard!=NULL);
g_assert(properties->key!=NULL);
@@ -220,7 +221,15 @@ gc_board_check_file(GcomprisBoard *gcomprisBoard)
return TRUE;
}
- if(strncmp(properties->key, "your_welcome", 12)==0) {
+ while(keycode[i++])
+ {
+ if(strncmp(entry_text, keycode[i-1], 5) == 0)
+ {
+ key_is_valid = 1;
+ }
+ }
+
+ if(key_is_valid)
while(static_boards[i++] != NULL) {
/* Get the BoardPlugin Info */
diff --git a/src/gcompris/config.c b/src/gcompris/config.c
index f43b229..1f44bfe 100644
--- a/src/gcompris/config.c
+++ b/src/gcompris/config.c
@@ -757,8 +757,7 @@ item_event_ok(GnomeCanvasItem *item, GdkEvent *event, gpointer data)
gc_fullscreen_set(properties->fullscreen);
#endif
/* Warning changing the image needs to update pixbuf_ref for the focus usage */
- g_object_set_data (G_OBJECT (item), "pixbuf_ref",
- (properties->fullscreen ? pixmap_checked : pixmap_unchecked));
+ gc_item_focus_free(item, NULL);
gnome_canvas_item_set (item,
"pixbuf", (properties->fullscreen ? pixmap_checked : pixmap_unchecked),
NULL);
@@ -768,8 +767,7 @@ item_event_ok(GnomeCanvasItem *item, GdkEvent *event, gpointer data)
{
properties->music = (properties->music ? 0 : 1);
/* Warning changing the image needs to update pixbuf_ref for the focus usage */
- g_object_set_data (G_OBJECT (item), "pixbuf_ref",
- (properties->music ? pixmap_checked : pixmap_unchecked));
+ gc_item_focus_free(item, NULL);
gnome_canvas_item_set (item,
"pixbuf", (properties->music ? pixmap_checked : pixmap_unchecked),
NULL);
@@ -779,8 +777,7 @@ item_event_ok(GnomeCanvasItem *item, GdkEvent *event, gpointer data)
{
properties->fx = (properties->fx ? 0 : 1);
/* Warning changing the image needs to update pixbuf_ref for the focus usage */
- g_object_set_data (G_OBJECT (item), "pixbuf_ref",
- (properties->fx ? pixmap_checked : pixmap_unchecked));
+ gc_item_focus_free(item, NULL);
gnome_canvas_item_set (item,
"pixbuf", (properties->fx ? pixmap_checked : pixmap_unchecked),
NULL);
diff --git a/src/gcompris/gameutil.c b/src/gcompris/gameutil.c
index 3254d10..7e45488 100644
--- a/src/gcompris/gameutil.c
+++ b/src/gcompris/gameutil.c
@@ -158,14 +158,21 @@ make_hc_pixbuf(GdkPixbuf *pb, gint val)
/**
* Free the highlight image from our image_focus system
+ *
+ * It must be called before assigning a new image to an item that
+ * already has a focus enabled with gc_item_focus_event().
*/
-static void
-free_image_focus (GnomeCanvasItem *item, void *none)
+void
+gc_item_focus_free(GnomeCanvasItem *item, void *none)
{
GdkPixbuf *pixbuf;
pixbuf = (GdkPixbuf *)g_object_get_data (G_OBJECT (item), "pixbuf_ref");
- gdk_pixbuf_unref(pixbuf);
+ if(pixbuf)
+ {
+ g_object_set_data (G_OBJECT (item), "pixbuf_ref", NULL);
+ gdk_pixbuf_unref(pixbuf);
+ }
}
/**
@@ -190,7 +197,7 @@ void gc_item_focus_set(GnomeCanvasItem *item, gboolean focus)
pixbuf_ref = pixbuf;
gdk_pixbuf_ref(pixbuf);
g_signal_connect (item, "destroy",
- G_CALLBACK (free_image_focus),
+ G_CALLBACK (gc_item_focus_free),
NULL);
}
@@ -224,8 +231,9 @@ void gc_item_focus_set(GnomeCanvasItem *item, gboolean focus)
* or the given one
*
*/
-gint gc_item_focus_event(GnomeCanvasItem *item, GdkEvent *event,
- GnomeCanvasItem *dest_item)
+gint
+gc_item_focus_event(GnomeCanvasItem *item, GdkEvent *event,
+ GnomeCanvasItem *dest_item)
{
if(dest_item!=NULL)
diff --git a/src/gcompris/gameutil.h b/src/gcompris/gameutil.h
index 98ce3bc..ecfc5c7 100644
--- a/src/gcompris/gameutil.h
+++ b/src/gcompris/gameutil.h
@@ -48,7 +48,8 @@ gchar *reactivate_newline(char *str);
GdkPixbuf *gc_pixmap_load(const gchar *filename, ...);
void gc_item_focus_set(GnomeCanvasItem *item, gboolean focus);
-gint gc_item_focus_event(GnomeCanvasItem *item, GdkEvent *event,
+void gc_item_focus_free(GnomeCanvasItem *item, void *none);
+gint gc_item_focus_event(GnomeCanvasItem *item, GdkEvent *event,
GnomeCanvasItem *dest_item);
gchar *convertUTF8Toisolat1(gchar * text);
@@ -58,7 +59,7 @@ void gc_item_rotate_relative(GnomeCanvasItem *item, double angle);
void gc_item_rotate_with_center(GnomeCanvasItem *item, double angle, int x, int y);
void gc_item_rotate_relative_with_center(GnomeCanvasItem *item, double angle, int x, int y);
-GnomeCanvasGroup *gc_difficulty_display(GnomeCanvasGroup *parent, double x, double y,
+GnomeCanvasGroup *gc_difficulty_display(GnomeCanvasGroup *parent, double x, double y,
double ratio,
int difficulty);
diff --git a/src/gcompris/gcompris.c b/src/gcompris/gcompris.c
index fefa387..c480002 100644
--- a/src/gcompris/gcompris.c
+++ b/src/gcompris/gcompris.c
@@ -63,9 +63,23 @@ static gint board_widget_key_press_callback (GtkWidget *widget,
void gc_terminate(int signum);
/*
- * For the Activation dialiog
+ * For the Activation dialog
*/
#ifdef WIN32
+ /* List of keycodes */
+ gchar *keycode[] =
+ {
+ "83640",
+ "33251",
+ "99301",
+ "71848",
+ "79657",
+ "47561",
+ "84175",
+ "15987",
+ NULL
+ };
+
static void activation_enter_callback(GtkWidget *widget,
GtkWidget *entry );
static void activation_done();
@@ -845,20 +859,6 @@ activation_enter_callback( GtkWidget *widget,
entry_text = (char *)gtk_entry_get_text(GTK_ENTRY(entry));
- /* List of keycodes */
- gchar *keycode[] =
- {
- "83640",
- "33251",
- "99301",
- "71848",
- "79657",
- "47561",
- "84175",
- "15987",
- NULL
- };
-
if(strlen(entry_text) == 5)
{
int i = 0;
@@ -867,7 +867,7 @@ activation_enter_callback( GtkWidget *widget,
if(strncmp(entry_text, keycode[i-1], 5) == 0)
{
g_free(properties->key);
- properties->key=strdup("your_welcome");
+ properties->key=strdup( keycode[i-1]);
gc_prop_save(properties);
gc_menu_load();
diff --git a/src/gcompris/help.c b/src/gcompris/help.c
index 7ee9cf2..8b63f9c 100644
--- a/src/gcompris/help.c
+++ b/src/gcompris/help.c
@@ -65,7 +65,7 @@ static GnomeCanvasItem *item_selected_text = NULL;
static GtkTextBuffer *buffer_content;
/*
- * Main entry point
+ * Main entry point
* ----------------
*
*/
@@ -122,7 +122,7 @@ void gc_help_start (GcomprisBoard *gcomprisBoard)
x_start = (BOARDWIDTH - gdk_pixbuf_get_width(pixmap))/2;
item = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
gnome_canvas_pixbuf_get_type (),
- "pixbuf", pixmap,
+ "pixbuf", pixmap,
"x", (double) x_start,
"y", (double) y_start,
NULL);
@@ -156,7 +156,7 @@ void gc_help_start (GcomprisBoard *gcomprisBoard)
y_start += 35;
gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
gnome_canvas_text_get_type (),
- "text", name,
+ "text", name,
"font", gc_skin_font_title,
"x", (double) BOARDWIDTH/2 + 1.0,
"y", (double) y_start + 1.0,
@@ -166,7 +166,7 @@ void gc_help_start (GcomprisBoard *gcomprisBoard)
NULL);
gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
gnome_canvas_text_get_type (),
- "text", name,
+ "text", name,
"font", gc_skin_font_title,
"x", (double) BOARDWIDTH/2,
"y", (double) y_start,
@@ -185,15 +185,15 @@ void gc_help_start (GcomprisBoard *gcomprisBoard)
{
item_prerequisite = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
gnome_canvas_pixbuf_get_type (),
- "pixbuf", pixmap,
+ "pixbuf", pixmap,
"x", (double) (BOARDWIDTH*0.2) - gdk_pixbuf_get_width(pixmap)/2,
"y", (double) y_start - gdk_pixbuf_get_height(pixmap) - 10,
NULL);
-
+
gtk_signal_connect(GTK_OBJECT(item_prerequisite), "event",
(GtkSignalFunc) item_event_help,
"prerequisite");
-
+
item_prerequisite_text = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
gnome_canvas_text_get_type (),
"text", _("Prerequisite"),
@@ -213,15 +213,15 @@ void gc_help_start (GcomprisBoard *gcomprisBoard)
{
item_goal = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
gnome_canvas_pixbuf_get_type (),
- "pixbuf", pixmap,
+ "pixbuf", pixmap,
"x", (double) (BOARDWIDTH*0.4) - gdk_pixbuf_get_width(pixmap)/2,
"y", (double) y_start - gdk_pixbuf_get_height(pixmap) - 10,
NULL);
-
+
gtk_signal_connect(GTK_OBJECT(item_goal), "event",
(GtkSignalFunc) item_event_help,
"goal");
-
+
item_goal_text = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
gnome_canvas_text_get_type (),
"text", _("Goal"),
@@ -241,15 +241,15 @@ void gc_help_start (GcomprisBoard *gcomprisBoard)
{
item_manual = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
gnome_canvas_pixbuf_get_type (),
- "pixbuf", pixmap,
+ "pixbuf", pixmap,
"x", (double) (BOARDWIDTH*0.6) - gdk_pixbuf_get_width(pixmap)/2,
"y", (double) y_start - gdk_pixbuf_get_height(pixmap) - 10,
NULL);
-
+
gtk_signal_connect(GTK_OBJECT(item_manual), "event",
(GtkSignalFunc) item_event_help,
"manual");
-
+
item_manual_text = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
gnome_canvas_text_get_type (),
"text", _("Manual"),
@@ -269,15 +269,15 @@ void gc_help_start (GcomprisBoard *gcomprisBoard)
{
item_credit = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
gnome_canvas_pixbuf_get_type (),
- "pixbuf", pixmap,
+ "pixbuf", pixmap,
"x", (double) (BOARDWIDTH*0.8) - gdk_pixbuf_get_width(pixmap)/2,
"y", (double) y_start - gdk_pixbuf_get_height(pixmap) - 10,
NULL);
-
+
gtk_signal_connect(GTK_OBJECT(item_credit), "event",
(GtkSignalFunc) item_event_help,
"credit");
-
+
item_credit_text = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
gnome_canvas_text_get_type (),
"text", _("Credit"),
@@ -364,7 +364,7 @@ void gc_help_start (GcomprisBoard *gcomprisBoard)
item = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
gnome_canvas_pixbuf_get_type (),
- "pixbuf", pixmap,
+ "pixbuf", pixmap,
"x", (double) (BOARDWIDTH*0.5) - gdk_pixbuf_get_width(pixmap)/2,
"y", (double) y - gdk_pixbuf_get_height(pixmap) - 5,
NULL);
@@ -421,7 +421,7 @@ void gc_help_stop ()
if(rootitem!=NULL)
{
gtk_object_destroy(GTK_OBJECT(rootitem));
- rootitem = NULL;
+ rootitem = NULL;
}
gc_board_pause(FALSE);
}
@@ -440,16 +440,16 @@ void gc_help_stop ()
static void select_item(GnomeCanvasItem *item, GnomeCanvasItem *item_text)
{
GdkPixbuf *pixmap = NULL;
-
+
if(item_selected)
{
pixmap = gc_skin_pixmap_load("button_up.png");
/* Warning changing the image needs to update pixbuf_ref for the focus usage */
- g_object_set_data (G_OBJECT (item_selected), "pixbuf_ref", pixmap);
- gnome_canvas_item_set(item_selected,
+ gc_item_focus_free(item_selected, NULL);
+ gnome_canvas_item_set(item_selected,
"pixbuf", pixmap,
NULL);
- gnome_canvas_item_set(item_selected_text,
+ gnome_canvas_item_set(item_selected_text,
"fill_color_rgba", gc_skin_get_color("gcompris/helpunselect"),
NULL);
@@ -458,12 +458,12 @@ static void select_item(GnomeCanvasItem *item, GnomeCanvasItem *item_text)
pixmap = gc_skin_pixmap_load("button_up_selected.png");
/* Warning changing the image needs to update pixbuf_ref for the focus usage */
- g_object_set_data (G_OBJECT (item), "pixbuf_ref", pixmap);
- gnome_canvas_item_set(item,
+ gc_item_focus_free(item, NULL);
+ gnome_canvas_item_set(item,
"pixbuf", pixmap,
NULL);
gdk_pixbuf_unref(pixmap);
- gnome_canvas_item_set(item_text,
+ gnome_canvas_item_set(item_text,
"fill_color_rgba", gc_skin_get_color("gcompris/helpselect"),
NULL);
item_selected = item;
@@ -482,7 +482,7 @@ static gint
item_event_help(GnomeCanvasItem *item, GdkEvent *event, gpointer data)
{
- switch (event->type)
+ switch (event->type)
{
case GDK_ENTER_NOTIFY:
break;
@@ -492,27 +492,27 @@ item_event_help(GnomeCanvasItem *item, GdkEvent *event, gpointer data)
if(!strcmp((char *)data, "ok"))
{
gc_help_stop();
- }
+ }
else if(!strcmp((char *)data, "prerequisite"))
{
select_item(item_prerequisite, item_prerequisite_text);
set_content(prerequisite);
- }
+ }
else if(!strcmp((char *)data, "goal"))
{
select_item(item_goal, item_goal_text);
set_content(goal);
- }
+ }
else if(!strcmp((char *)data, "manual"))
{
select_item(item_manual, item_manual_text);
set_content(manual);
- }
+ }
else if(!strcmp((char *)data, "credit"))
{
select_item(item_credit, item_credit_text);
set_content(credit);
- }
+ }
default:
break;
}