From 7fba12a9da45f893cf2fabb85a71c88989d2ff66 Mon Sep 17 00:00:00 2001 From: Bruno Coudoin Date: Fri, 30 Jan 2009 23:31:55 +0000 Subject: Added RTL support. svn path=/trunk/; revision=3709 --- diff --git a/ChangeLog b/ChangeLog index 4c5bd34..c27b8af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,14 @@ 2009-01-31 Bruno coudoin Vitali Perchonok is com gmail from vitali.pe + Added RTL support. + + * src/boards/reading.c: (start_board), (reading_next_level), + (reading_create_item): + +2009-01-31 Bruno coudoin + + Vitali Perchonok is com gmail from vitali.pe Prevent an evil crash bug when the kids press 2 buttons at the same time * src/boards/menu2.c: (item_event): diff --git a/src/boards/reading.c b/src/boards/reading.c index 9989cc3..d43d1e0 100644 --- a/src/boards/reading.c +++ b/src/boards/reading.c @@ -46,7 +46,8 @@ static GnomeCanvasGroup *boardRootItem = NULL; typedef enum { MODE_HORIZONTAL = 0, - MODE_VERTICAL = 1 + MODE_VERTICAL = 1, + MODE_HORIZONTAL_RTL = 2 } Mode; static Mode currentMode = MODE_VERTICAL; @@ -210,10 +211,9 @@ static void start_board (GcomprisBoard *agcomprisBoard) g_warning ("Font to display words have size %d ascent : %d, descent : %d.\n Set inerline to %d", font_size, ascent, descent, interline); - /* Default mode */ - currentMode=MODE_VERTICAL; - if(gcomprisBoard->mode && g_strcasecmp(gcomprisBoard->mode, "horizontal")==0) - currentMode=MODE_HORIZONTAL; + + + gc_wordlist = gc_wordlist_get_from_file("wordsgame/default-$LOCALE.xml"); @@ -230,7 +230,17 @@ static void start_board (GcomprisBoard *agcomprisBoard) } } - reading_next_level(); + + currentMode=MODE_VERTICAL; // Default mode + if(gcomprisBoard->mode && g_strcasecmp(gcomprisBoard->mode, "horizontal")==0) + { + if (pango_unichar_direction(g_utf8_get_char(gc_wordlist_random_word_get(gc_wordlist, gcomprisBoard->level))) == PANGO_DIRECTION_RTL) + currentMode=MODE_HORIZONTAL_RTL; + else + currentMode=MODE_HORIZONTAL; + } + + reading_next_level(); } } @@ -314,7 +324,7 @@ static gint reading_next_level() } else { - current_x = BASE_X1; + current_x = BASE_X2; numberOfLine=2+gcomprisBoard->level; } @@ -461,6 +471,8 @@ static gboolean reading_create_item(GnomeCanvasGroup *parent) if(currentMode==MODE_HORIZONTAL) anchor=GTK_ANCHOR_WEST; + else if (currentMode==MODE_HORIZONTAL_RTL) + anchor=GTK_ANCHOR_EAST; previousFocus.item = \ gnome_canvas_item_new (GNOME_CANVAS_GROUP(previousFocus.rootItem), @@ -497,6 +509,24 @@ static gboolean reading_create_item(GnomeCanvasGroup *parent) current_y += interline; numberOfLine--; } + else if (currentMode==MODE_HORIZONTAL_RTL) + { + double x1, y1, x2, y2; + + gnome_canvas_item_get_bounds(GNOME_CANVAS_ITEM(previousFocus.rootItem), &x1, &y1, &x2, &y2); + + // Are we out of bound + if(x1