[gcompris/gcomprixogoo] Fixed missing_letter again. Now the editor no more save the choices in a random order.



commit 23156938bddd73d447d9d407e491454ea0982d8c
Author: Bruno Coudoin <bruno coudoin free fr>
Date:   Sat Nov 6 22:52:05 2010 +0100

    Fixed missing_letter again. Now the editor no more save the choices in a random order.

 src/missing_letter-activity/missingletter.c        |    9 +++++++--
 src/missing_letter-activity/missingletter.h        |    5 +++--
 src/missing_letter-activity/missingletter_config.c |    8 ++++----
 3 files changed, 14 insertions(+), 8 deletions(-)
---
diff --git a/src/missing_letter-activity/missingletter.c b/src/missing_letter-activity/missingletter.c
index a6e164a..2e8b569 100644
--- a/src/missing_letter-activity/missingletter.c
+++ b/src/missing_letter-activity/missingletter.c
@@ -549,9 +549,11 @@ add_xml_data(xmlDocPtr doc, xmlNodePtr xmlnode, GList **list)
 	board->question = g_strdup(all_answer[i++]);
 	board->solution = 0;
 
-	while(all_answer[i] && text_index < MAX_PROPOSAL)
+	printf("%s %s\n", board->answer, board->question);
+	while(all_answer[i] && text_index < MAX_PROPOSAL + 2)
 	  {
 	    board->text[text_index++] = g_strdup(all_answer[i++]);
+	    board->choices[text_index++] = g_strdup(all_answer[i++]);
 	  }
 
 	g_strfreev(all_answer);
@@ -662,7 +664,10 @@ destroy_board(Board * board)
   g_free(board->answer);
   g_free(board->question);
   while(board->text[i])
-    g_free(board->text[i++]);
+    {
+      g_free(board->text[i++]);
+      g_free(board->choices[i++]);
+    }
 
   g_free(board);
 }
diff --git a/src/missing_letter-activity/missingletter.h b/src/missing_letter-activity/missingletter.h
index e00260c..f7a74f3 100644
--- a/src/missing_letter-activity/missingletter.h
+++ b/src/missing_letter-activity/missingletter.h
@@ -24,12 +24,13 @@ extern GcomprisBoard *gcomprisBoard_missing;
 gboolean              missing_read_xml_file(char *fname, GList**);
 void                  missing_destroy_board_list(GList *);
 
-#define MAX_PROPOSAL 6 * 2 /* Counting UTF-8 char */
+#define MAX_PROPOSAL (6 * 2) /* Counting UTF-8 char */
 typedef struct _Board {
   gchar *pixmapfile;
   gchar *question;
   gchar *answer;
-  gchar *text[MAX_PROPOSAL + 1];
+  gchar *choices[MAX_PROPOSAL + 1];
+  gchar *text[MAX_PROPOSAL + 1]; /* Same as choices but randomized */
   guint solution;
 } Board;
 
diff --git a/src/missing_letter-activity/missingletter_config.c b/src/missing_letter-activity/missingletter_config.c
index c01f1d3..034fd23 100644
--- a/src/missing_letter-activity/missingletter_config.c
+++ b/src/missing_letter-activity/missingletter_config.c
@@ -141,10 +141,10 @@ static gboolean _save(GtkTreeModel *model, GtkTreePath *path,
 	gchar outbuf[6];
 	outbuf[g_unichar_to_utf8 ( unichar_letter, outbuf)] = '\0';
 	str = g_utf8_next_char(str);
-	g_strlcat(choices, outbuf, MAX_PROPOSAL * 2);
 	g_strlcat(choices, "/", MAX_PROPOSAL * 2);
+	g_strlcat(choices, outbuf, MAX_PROPOSAL * 2);
       }
-      tmp = g_strdup_printf("%s/%s/%s",
+      tmp = g_strdup_printf("%s/%s%s",
 			    answer, question, choices);
       root =(xmlNodePtr)data;
       node = xmlNewChild(root, NULL, BAD_CAST "Board", NULL);
@@ -243,9 +243,9 @@ static void level_changed(GtkComboBox *combo, gpointer data)
 					 NULL);
 
       tmp[0] = '\0';
-      while(b->text[i])
+      while(b->choices[i])
 	{
-	  g_strlcat(tmp, b->text[i], MAX_PROPOSAL);
+	  g_strlcat(tmp, b->choices[i], MAX_PROPOSAL);
 	  i++;
 	}
       gtk_list_store_append(ls, &iter);



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