[gcompris] missingletter, fixed support for more then 6 letters.



commit 856048cb75a8ab319219aed9a05b017030ec3875
Author: Bruno Coudoin <bcoudoin gcompris net>
Date:   Sun Oct 20 16:06:17 2013 +0200

    missingletter, fixed support for more then 6 letters.
    
    If more than 6 letters choices were proposed they was not
    displayed at all.
    
    Fixed a little memory leak.
    
    Improved the layout to support more than 6 letters.

 src/missing_letter-activity/missingletter.c |   28 +++++++++++++++++---------
 1 files changed, 18 insertions(+), 10 deletions(-)
---
diff --git a/src/missing_letter-activity/missingletter.c b/src/missing_letter-activity/missingletter.c
index 0003d10..44124ca 100644
--- a/src/missing_letter-activity/missingletter.c
+++ b/src/missing_letter-activity/missingletter.c
@@ -172,7 +172,7 @@ start_board (GcomprisBoard *agcomprisBoard)
                        "missing_letter/missingletter-bg.jpg");
        _init(agcomprisBoard);
       gc_bar_set(GC_BAR_CONFIG | GC_BAR_LEVEL);
-      gc_bar_location(10, -1, 0.9);
+      gc_bar_location(10, -1, 0.7);
 
       missing_letter_next_level();
 
@@ -244,7 +244,7 @@ missing_letter_next_level()
   gc_score_end();
   gc_score_start(SCORESTYLE_NOTE,
                 BOARDWIDTH - 195,
-                BOARDHEIGHT - 30,
+                30,
                 gcomprisBoard_missing->number_of_sublevel);
 
 
@@ -281,7 +281,7 @@ missing_letter_destroy_all_items()
 static void
 missing_letter_create_item(GooCanvasItem *parent)
 {
-  int xOffset, yOffset;
+  int xOffset, yOffset, yBase;
   GdkPixbuf *button_pixmap = NULL;
   GdkPixbuf *pixmap = NULL;
   Board *board;
@@ -315,7 +315,7 @@ missing_letter_create_item(GooCanvasItem *parent)
   pixmap = gc_pixmap_load(board->pixmapfile);
 
   text = goo_canvas_text_new (boardRootItem,
-                             _(board->question),
+                             board->question,
                              (double) txt_area_x,
                              (double) txt_area_y,
                              -1,
@@ -338,13 +338,15 @@ missing_letter_create_item(GooCanvasItem *parent)
   /* Calc the number of proposals */
   i = 0;
   while(board->text[i++]);
+  i--;
 
-  vertical_separation = 10 + 20 / i;
+  vertical_separation = 10;
 
-  yOffset = ( BOARDHEIGHT
-             - i * gdk_pixbuf_get_height(button_pixmap)
-             - 2 * vertical_separation) / 2 - 20;
-  xOffset = (img_area_x - gdk_pixbuf_get_width(button_pixmap))/2;
+  yOffset = yBase = 20;
+  if (i < 7)
+    xOffset = (img_area_x - gdk_pixbuf_get_width(button_pixmap))/2;
+  else
+    xOffset = (img_area_x - gdk_pixbuf_get_width(button_pixmap))/3;
 
   i = 0;
   while(board->text[i])
@@ -354,6 +356,12 @@ missing_letter_create_item(GooCanvasItem *parent)
       GooCanvasItem *group = goo_canvas_group_new (boardRootItem,
                                                   NULL);
 
+      if (i == 6)
+       {
+         xOffset += gdk_pixbuf_get_width(button_pixmap) + 10;
+         yOffset = yBase;
+       }
+
       button = goo_canvas_image_new (group,
                                     button_pixmap,
                                     xOffset,
@@ -703,7 +711,7 @@ destroy_board(Board * board)
   g_free(board->question);
   while(board->text[i])
     {
-      g_free(board->text[i++]);
+      g_free(board->text[i]);
       g_free(board->choices[i++]);
     }
 


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