diff options
author | Bruno Coudoin <bcoudoin@src.gnome.org> | 2009-01-30 21:15:28 (GMT) |
---|---|---|
committer | Bruno Coudoin <bcoudoin@src.gnome.org> | 2009-01-30 21:15:28 (GMT) |
commit | 82f8cd260494e0c2e119db6911965d1c7def881b (patch) | |
tree | a78a373b11ccb5805735030e94cac3d32d746b9b /src/boards | |
parent | 1ba35d1721e21ff06364adb8ed20419add37aeea (diff) |
Miguel DE IZARRA implemented the wordlist selector.
We need some improvement to save data in the ~/My GCompris
instead of the system datadir directory.
svn path=/trunk/; revision=3700
Diffstat (limited to 'src/boards')
-rw-r--r-- | src/boards/advanced_colors.c | 8 | ||||
-rw-r--r-- | src/boards/click_on_letter.c | 8 | ||||
-rw-r--r-- | src/boards/colors.c | 4 | ||||
-rw-r--r-- | src/boards/gletters.c | 12 | ||||
-rw-r--r-- | src/boards/imageid.c | 30 | ||||
-rw-r--r-- | src/boards/missingletter.c | 6 | ||||
-rw-r--r-- | src/boards/py-mod-gcompris.c | 16 | ||||
-rw-r--r-- | src/boards/reading.c | 7 | ||||
-rw-r--r-- | src/boards/scale.c | 6 | ||||
-rw-r--r-- | src/boards/shapegame.c | 7 | ||||
-rw-r--r-- | src/boards/smallnumbers.c | 7 | ||||
-rw-r--r-- | src/boards/wordsgame.c | 37 |
12 files changed, 95 insertions, 53 deletions
diff --git a/src/boards/advanced_colors.c b/src/boards/advanced_colors.c index bc91a35..e5a223f 100644 --- a/src/boards/advanced_colors.c +++ b/src/boards/advanced_colors.c @@ -476,7 +476,13 @@ static void add_xml_data(xmlDocPtr doc, xmlNodePtr xmlnode, GNode * child) sColor = g_strdup_printf("color%d", i+1); if (!strcmp((char *)xmlnode->name, sColor)) { - colors[i] = gettext((char *)xmlNodeListGetString(doc, xmlnode->xmlChildrenNode, 1)); + text = (char*)xmlNodeListGetString(doc, xmlnode->xmlChildrenNode, 1); + if(text) + { + colors[i] = gettext((char *)text); + g_free(text); + } + text = NULL; g_free(sColor); break; } diff --git a/src/boards/click_on_letter.c b/src/boards/click_on_letter.c index 879bacb..9a73cb2 100644 --- a/src/boards/click_on_letter.c +++ b/src/boards/click_on_letter.c @@ -622,8 +622,8 @@ config_start(GcomprisBoard *agcomprisBoard, gchar *label = g_strdup_printf(_("<b>%s</b> configuration\n for profile <b>%s</b>"), agcomprisBoard->name, aProfile ? aProfile->name : ""); - - gc_board_config_window_display(label, conf_ok); + GcomprisBoardConf *bconf; + bconf = gc_board_config_window_display(label, conf_ok); g_free(label); @@ -632,7 +632,7 @@ config_start(GcomprisBoard *agcomprisBoard, gchar *saved_locale_sound = g_hash_table_lookup( config, "locale_sound"); - gc_board_config_combo_locales_asset( "Select sound locale", saved_locale_sound, + gc_board_config_combo_locales_asset(bconf, "Select sound locale", saved_locale_sound, "voices/$LOCALE/colors/purple.ogg"); gboolean up_init = FALSE; @@ -642,7 +642,7 @@ config_start(GcomprisBoard *agcomprisBoard, if (up_init_str && (strcmp(up_init_str, "True")==0)) up_init = TRUE; - gc_board_config_boolean_box(_("Uppercase only text"), + gc_board_config_boolean_box(bconf, _("Uppercase only text"), "uppercase_only", up_init); diff --git a/src/boards/colors.c b/src/boards/colors.c index a5ace77..244b1d9 100644 --- a/src/boards/colors.c +++ b/src/boards/colors.c @@ -164,7 +164,7 @@ colors_config_start(GcomprisBoard *agcomprisBoard, label = g_strdup_printf(_("<b>%s</b> configuration\n for profile <b>%s</b>"), agcomprisBoard->name, aProfile ? aProfile->name : ""); - gc_board_config_window_display(label, conf_ok); + GcomprisBoardConf *bconf = gc_board_config_window_display(label, conf_ok); g_free(label); @@ -173,7 +173,7 @@ colors_config_start(GcomprisBoard *agcomprisBoard, gchar *saved_locale_sound = g_hash_table_lookup( config, "locale_sound"); - gc_board_config_combo_locales_asset( _("Select sound locale"), saved_locale_sound, + gc_board_config_combo_locales_asset(bconf, _("Select sound locale"), saved_locale_sound, "voices/$LOCALE/colors/purple.ogg"); g_hash_table_destroy(config); diff --git a/src/boards/gletters.c b/src/boards/gletters.c index 9b52e7c..04a3954 100644 --- a/src/boards/gletters.c +++ b/src/boards/gletters.c @@ -858,7 +858,7 @@ gletter_config_start(GcomprisBoard *agcomprisBoard, label = g_strdup_printf(_("<b>%s</b> configuration\n for profile <b>%s</b>"), agcomprisBoard->name, aProfile ? aProfile->name : ""); - gc_board_config_window_display(label, (GcomprisConfCallback )conf_ok); + GcomprisBoardConf *bconf = gc_board_config_window_display(label, (GcomprisConfCallback )conf_ok); g_free(label); @@ -867,7 +867,7 @@ gletter_config_start(GcomprisBoard *agcomprisBoard, gchar *locale = g_hash_table_lookup( config, "locale"); - gc_board_config_combo_locales( locale); + gc_board_config_combo_locales( bconf, locale); gboolean up_init = FALSE; @@ -876,7 +876,7 @@ gletter_config_start(GcomprisBoard *agcomprisBoard, if (up_init_str && (strcmp(up_init_str, "True")==0)) up_init = TRUE; - gc_board_conf_separator(); + gc_board_conf_separator(bconf); gchar *control_sound = g_hash_table_lookup( config, "with_sound"); if (control_sound && strcmp(g_hash_table_lookup( config, "with_sound"),"True")==0) @@ -884,11 +884,11 @@ gletter_config_start(GcomprisBoard *agcomprisBoard, else with_sound = FALSE; - gc_board_config_boolean_box(_("Enable sounds"), "with_sound", with_sound); + gc_board_config_boolean_box(bconf, _("Enable sounds"), "with_sound", with_sound); - gc_board_conf_separator(); + gc_board_conf_separator(bconf); - gc_board_config_boolean_box(_("Uppercase only text"), + gc_board_config_boolean_box(bconf, _("Uppercase only text"), "uppercase_only", up_init); diff --git a/src/boards/imageid.c b/src/boards/imageid.c index c1d38e0..459d78b 100644 --- a/src/boards/imageid.c +++ b/src/boards/imageid.c @@ -52,7 +52,6 @@ typedef struct { } Board; /* XML */ -static gboolean read_xml_file(char *fname); static void init_xml(void); static void add_xml_data(xmlDocPtr doc,xmlNodePtr xmlnode, GNode * child); static void parse_doc(xmlDocPtr doc); @@ -554,8 +553,8 @@ static void add_xml_data(xmlDocPtr doc, xmlNodePtr xmlnode, GNode * child) { gchar *pixmapfile = NULL; gchar *text1 = NULL, *text2 = NULL, *text3 = NULL; + xmlChar* tmp; Board * board = g_new(Board,1); - gboolean found_text1 = FALSE, found_text2 = FALSE, found_text3 = FALSE; xmlnode = xmlnode->xmlChildrenNode; @@ -566,30 +565,33 @@ static void add_xml_data(xmlDocPtr doc, xmlNodePtr xmlnode, GNode * child) if (!strcmp((char *)xmlnode->name, "pixmapfile")) pixmapfile = (gchar *)xmlNodeListGetString(doc, xmlnode->xmlChildrenNode, 1); - if (!found_text1 && !strcmp((char *)xmlnode->name, "text1")) + if (!strcmp((char *)xmlnode->name, "text1")) { if(text1==NULL) { - text1 = \ - g_strdup(gettext((gchar *)xmlNodeListGetString(doc, xmlnode->xmlChildrenNode, 1))); + tmp = xmlNodeListGetString(doc, xmlnode->xmlChildrenNode, 1); + text1 = g_strdup(gettext((gchar*)tmp)); + g_free(tmp); } } - if (!found_text2 && !strcmp((char *)xmlnode->name, "text2")) + if (!strcmp((char *)xmlnode->name, "text2")) { if(text2==NULL) { - text2 = \ - g_strdup(gettext((gchar *)xmlNodeListGetString(doc, xmlnode->xmlChildrenNode, 1))); + tmp = xmlNodeListGetString(doc, xmlnode->xmlChildrenNode, 1); + text2 = g_strdup(gettext((gchar*)tmp)); + g_free(tmp); } } - if (!found_text3 && !strcmp((char *)xmlnode->name, "text3")) + if (!strcmp((char *)xmlnode->name, "text3")) { if(text3==NULL) { - text3 = \ - g_strdup(gettext((gchar *)xmlNodeListGetString(doc, xmlnode->xmlChildrenNode, 1))); + tmp = xmlNodeListGetString(doc, xmlnode->xmlChildrenNode, 1); + text3 = g_strdup(gettext((gchar *)tmp)); + g_free(tmp); } } @@ -748,8 +750,8 @@ config_start(GcomprisBoard *agcomprisBoard, gchar *label = g_strdup_printf(_("<b>%s</b> configuration\n for profile <b>%s</b>"), agcomprisBoard->name, aProfile ? aProfile->name : ""); - - gc_board_config_window_display( label, + GcomprisBoardConf *bconf; + bconf = gc_board_config_window_display( label, (GcomprisConfCallback )conf_ok); g_free(label); @@ -759,7 +761,7 @@ config_start(GcomprisBoard *agcomprisBoard, gchar *locale = g_hash_table_lookup( config, "locale"); - gc_board_config_combo_locales( locale); + gc_board_config_combo_locales(bconf, locale); } diff --git a/src/boards/missingletter.c b/src/boards/missingletter.c index ed146b2..31cc562 100644 --- a/src/boards/missingletter.c +++ b/src/boards/missingletter.c @@ -770,8 +770,8 @@ config_start(GcomprisBoard *agcomprisBoard, gchar *label = g_strdup_printf(_("<b>%s</b> configuration\n for profile <b>%s</b>"), agcomprisBoard->name, aProfile ? aProfile->name : ""); - - gc_board_config_window_display( label, + GcomprisBoardConf *bconf; + bconf = gc_board_config_window_display( label, (GcomprisConfCallback )conf_ok); g_free(label); @@ -781,7 +781,7 @@ config_start(GcomprisBoard *agcomprisBoard, gchar *locale = g_hash_table_lookup( config, "locale"); - gc_board_config_combo_locales( locale); + gc_board_config_combo_locales(bconf, locale); } diff --git a/src/boards/py-mod-gcompris.c b/src/boards/py-mod-gcompris.c index 1061621..0380f09 100644 --- a/src/boards/py-mod-gcompris.c +++ b/src/boards/py-mod-gcompris.c @@ -1076,7 +1076,7 @@ py_gc_board_config_boolean_box(PyObject* self, PyObject* args) /* Call the corresponding C function */ return (PyObject *)pygobject_new((GObject*) \ - gc_board_config_boolean_box((const gchar *)label, key, PyObject_IsTrue(py_bool))); + gc_board_config_boolean_box(NULL,(const gchar *)label, key, PyObject_IsTrue(py_bool))); } @@ -1111,7 +1111,7 @@ py_gc_board_config_combo_box(PyObject* self, PyObject* args) /* Call the corresponding C function */ return (PyObject *)pygobject_new((GObject*) \ - gc_board_config_combo_box((const gchar *)label, + gc_board_config_combo_box(NULL, (const gchar *)label, list, key, init)); @@ -1196,7 +1196,7 @@ py_gc_board_config_radio_buttons(PyObject* self, PyObject* args) g_strdup(PyString_AsString(pyvalue))); } - result = gc_board_config_radio_buttons(label, + result = gc_board_config_radio_buttons(NULL,label, key, buttons_label, init); @@ -1218,7 +1218,7 @@ py_gc_board_config_spin_int(PyObject* self, PyObject* args) return NULL; return (PyObject *)pygobject_new((GObject*) \ - gc_board_config_spin_int((const gchar *)label, + gc_board_config_spin_int(NULL, (const gchar *)label, key, min, max, @@ -1237,7 +1237,7 @@ py_gc_board_conf_separator(PyObject* self, PyObject* args) return NULL; /* Create and return the result */ - return (PyObject *)pygobject_new((GObject*) gc_board_conf_separator()); + return (PyObject *)pygobject_new((GObject*) gc_board_conf_separator(NULL)); } @@ -1252,7 +1252,7 @@ py_gc_board_config_combo_locales(PyObject* self, PyObject* args) return NULL; return (PyObject *)pygobject_new((GObject*) \ - gc_board_config_combo_locales( init)); + gc_board_config_combo_locales(NULL, init)); } @@ -1295,7 +1295,7 @@ py_gc_board_config_combo_locales_asset(PyObject* self, PyObject* args) return NULL; return (PyObject *)pygobject_new((GObject*) \ - gc_board_config_combo_locales_asset( label, init, file )); + gc_board_config_combo_locales_asset(NULL, label, init, file )); } @@ -1446,7 +1446,7 @@ py_gc_board_config_textview(PyObject* self, PyObject* args){ return (PyObject *) \ pygobject_new((GObject*) \ - gc_board_config_textview( label, + gc_board_config_textview(NULL, label, key, desc, init_text, diff --git a/src/boards/reading.c b/src/boards/reading.c index 0e06fe6..9989cc3 100644 --- a/src/boards/reading.c +++ b/src/boards/reading.c @@ -821,6 +821,7 @@ static void reading_config_start(GcomprisBoard *agcomprisBoard, GcomprisProfile *aProfile) { + GcomprisBoardConf *conf; board_conf = agcomprisBoard; profile_conf = aProfile; @@ -831,7 +832,7 @@ reading_config_start(GcomprisBoard *agcomprisBoard, agcomprisBoard->name, aProfile? aProfile->name: ""); - gc_board_config_window_display( label, + conf = gc_board_config_window_display( label, (GcomprisConfCallback )conf_ok); g_free(label); @@ -841,8 +842,8 @@ reading_config_start(GcomprisBoard *agcomprisBoard, gchar *locale = g_hash_table_lookup( config, "locale"); - gc_board_config_combo_locales( locale); - + gc_board_config_combo_locales(conf, locale); + gc_board_config_wordlist(conf, "wordsgame/default-$LOCALE.xml"); } diff --git a/src/boards/scale.c b/src/boards/scale.c index 428139c..7534bfb 100644 --- a/src/boards/scale.c +++ b/src/boards/scale.c @@ -861,8 +861,8 @@ config_start(GcomprisBoard *agcomprisBoard, gchar * label = g_strdup_printf(_("<b>%s</b> configuration\n for profile <b>%s</b>"), agcomprisBoard->name, aProfile? aProfile->name : ""); - - gc_board_config_window_display( label, + GcomprisBoardConf *bconf; + bconf = gc_board_config_window_display( label, (GcomprisConfCallback )conf_ok); g_free(label); @@ -878,7 +878,7 @@ config_start(GcomprisBoard *agcomprisBoard, else drag_previous = 0; - gc_board_config_combo_drag( drag_mode); + gc_board_config_combo_drag(bconf, drag_mode); } diff --git a/src/boards/shapegame.c b/src/boards/shapegame.c index e21492d..8e41a99 100644 --- a/src/boards/shapegame.c +++ b/src/boards/shapegame.c @@ -1871,7 +1871,8 @@ config_start(GcomprisBoard *agcomprisBoard, agcomprisBoard->name, aProfile? aProfile->name : ""); - gc_board_config_window_display( label, + GcomprisBoardConf *bconf; + bconf = gc_board_config_window_display( label, (GcomprisConfCallback )conf_ok); g_free(label); @@ -1882,7 +1883,7 @@ config_start(GcomprisBoard *agcomprisBoard, if (strcmp(agcomprisBoard->name, "imagename")==0){ gchar *locale = g_hash_table_lookup( config, "locale"); - gc_board_config_combo_locales( locale); + gc_board_config_combo_locales( bconf, locale); } gchar *drag_mode_str = g_hash_table_lookup( config, "drag_mode"); @@ -1893,7 +1894,7 @@ config_start(GcomprisBoard *agcomprisBoard, else drag_previous = 0; - gc_board_config_combo_drag( drag_mode); + gc_board_config_combo_drag(bconf, drag_mode); } diff --git a/src/boards/smallnumbers.c b/src/boards/smallnumbers.c index bafb73b..5da0f9f 100644 --- a/src/boards/smallnumbers.c +++ b/src/boards/smallnumbers.c @@ -592,7 +592,8 @@ smallnumber_config_start(GcomprisBoard *agcomprisBoard, label = g_strdup_printf(_("<b>%s</b> configuration\n for profile <b>%s</b>"), agcomprisBoard->name, aProfile ? aProfile->name : ""); - gc_board_config_window_display(label, (GcomprisConfCallback )conf_ok); + GcomprisBoardConf *bconf; + bconf = gc_board_config_window_display(label, (GcomprisConfCallback )conf_ok); g_free(label); @@ -607,9 +608,9 @@ smallnumber_config_start(GcomprisBoard *agcomprisBoard, else with_sound = FALSE; - GtkCheckButton *sound_control = gc_board_config_boolean_box(_("Enable sounds"), "with_sound", with_sound); + GtkCheckButton *sound_control = gc_board_config_boolean_box(bconf, _("Enable sounds"), "with_sound", with_sound); - GtkComboBox *sound_box = gc_board_config_combo_locales_asset( _("Select sound locale"), + GtkComboBox *sound_box = gc_board_config_combo_locales_asset(bconf, _("Select sound locale"), saved_locale_sound, "voices/$LOCALE/colors/purple.ogg"); diff --git a/src/boards/wordsgame.c b/src/boards/wordsgame.c index c984a40..30d113c 100644 --- a/src/boards/wordsgame.c +++ b/src/boards/wordsgame.c @@ -79,6 +79,10 @@ static gboolean wordsgame_destroy_items(GPtrArray *items); static void wordsgame_destroy_all_items(void); static void wordsgame_next_level(void); static void wordsgame_add_new_item(void); +static void wordsgame_config_start(GcomprisBoard *agcomprisBoard, + GcomprisProfile *aProfile); +static void wordsgame_config_stop(void); + static void player_win(LettersItem *item); static void player_loose(void); @@ -121,8 +125,8 @@ static BoardPlugin menu_bp = set_level, NULL, NULL, - NULL, - NULL + wordsgame_config_start, + wordsgame_config_stop }; /* @@ -186,7 +190,7 @@ static void start_board (GcomprisBoard *agcomprisBoard) gcomprisBoard->level = 1; gcomprisBoard->maxlevel = 6; gcomprisBoard->sublevel = 0; - gc_bar_set(GC_BAR_LEVEL); + gc_bar_set(GC_BAR_LEVEL|GC_BAR_CONFIG); /* Default speed */ speed=DEFAULT_SPEED; @@ -754,3 +758,30 @@ static void player_loose() { gc_sound_play_ogg ("sounds/crash.wav", NULL); } + +static void conf_ok(gpointer data) +{ + pause_board(FALSE); +} + +static void wordsgame_config_start(GcomprisBoard *agcomprisBoard, GcomprisProfile *aProfile) +{ + if (gcomprisBoard) + pause_board(TRUE); + + gchar *label = g_strdup_printf(_("<b>%s</b> configuration\n for profile <b>%s</b>"), + agcomprisBoard->name, + aProfile? aProfile->name: ""); + GcomprisBoardConf *bconf; + bconf = gc_board_config_window_display( label, + (GcomprisConfCallback )conf_ok); + + g_free(label); + + gc_board_config_wordlist(bconf, "wordsgame/default-$LOCALE.xml"); +} + +static void wordsgame_config_stop(void) +{ +} + |