[gcompris] lang, added an i am ready button to let the intro voice play.



commit 49d7716d46a8db75c5fa00af1ab5304e3e853032
Author: Bruno Coudoin <bcoudoin gcompris net>
Date:   Sun Sep 29 23:46:14 2013 +0200

    lang, added an i am ready button to let the intro voice play.

 src/lang-activity/lang.py |   76 +++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 74 insertions(+), 2 deletions(-)
---
diff --git a/src/lang-activity/lang.py b/src/lang-activity/lang.py
index 93b69df..4d26216 100644
--- a/src/lang-activity/lang.py
+++ b/src/lang-activity/lang.py
@@ -101,13 +101,29 @@ class Gcompris_lang:
                             None)
       return
 
+    if not (gcompris.get_properties().fx):
+      gcompris.utils.dialog(_("Error: This activity cannot be \
+played with the\nsound effects disabled.\nGo to the configuration \
+dialogue to\nenable the sound."), None)
+
     gcompris.bar_set_level(self.gcomprisBoard)
 
     self.currentExerciseModes = []
     self.currentExercise = None
     self.currentLesson = self.langLib.getLesson(self.currentChapterName,
                                                 self.gcomprisBoard.level - 1)
+
+    readyButton = TextButton(400, 255, ' ' * 20 + _('I am Ready') + ' ' * 20,
+                             self.rootitem, 0x11AA11FFL)
+    readyButton.getBackground().connect("button_press_event",
+                                        self.ready_event, readyButton)
+
+
+
+  def ready_event(self, widget, target, event, button):
+    button.destroy()
     self.displayLesson( self.currentLesson )
+    self.displayImage( self.currentLesson.getTriplets()[self.currentTripletId] )
     self.pause(0);
 
   def end(self):
@@ -169,7 +185,7 @@ class Gcompris_lang:
     for key,value in table.iteritems():
       gcompris.set_board_conf(self.configuring_profile,
                               self.gcomprisBoard, key, value)
-    
+
     return True;
 
 
@@ -222,6 +238,7 @@ class Gcompris_lang:
     self.currentLesson = self.langLib.getLesson(self.currentChapterName,
                                                 self.gcomprisBoard.level - 1)
     self.displayLesson( self.currentLesson )
+    self.displayImage( self.currentLesson.getTriplets()[self.currentTripletId] )
 
 # -------
 
@@ -325,7 +342,6 @@ class Gcompris_lang:
       alignment = pango.ALIGN_CENTER,
       width = 500
       )
-    self.displayImage( lesson.getTriplets()[self.currentTripletId] )
 
   def playVoice(self, triplet):
     if triplet.voice:
@@ -403,3 +419,59 @@ class Gcompris_lang:
 
 
 
+class TextButton:
+
+    def __init__(self, x, y, text, rootitem, color_rgba=0x666666AAL):
+        '''
+        Add a text button to the screen with the following parameters:
+        1. x: the x position of the button
+        2. y: the y position of the button
+        3. text: the text of the button
+        4. rootitem: the item to draw the button in
+        5. color: the color of button background
+
+        TextButton(200, 300, 'Hello World!', self, color_rgba=0x6600FFFFL)
+        '''
+        width = -1
+        self.rootitem = goocanvas.Group(parent=rootitem, x=0, y=0)
+        textbox = goocanvas.Text(
+            parent = self.rootitem,
+            x=x, y=y,
+            width=width,
+            text=text,
+            font = gcompris.skin.get_font("gcompris/board/small"),
+            fill_color="white", anchor=gtk.ANCHOR_CENTER,
+            alignment=pango.ALIGN_CENTER,
+            pointer_events="GOO_CANVAS_EVENTS_NONE"
+            )
+        TG = 15
+        bounds = textbox.get_bounds()
+
+        self.back = goocanvas.Rect(parent = self.rootitem,
+                       x = bounds.x1 - TG,
+                       y = bounds.y1 - TG,
+                       height = bounds.y2 - bounds.y1 + TG * 2,
+                       width = bounds.x2 - bounds.x1 + TG * 2,
+                       stroke_color = "black",
+                       fill_color_rgba = color_rgba,
+                       radius_x = 3, radius_y = 3,
+                       line_width = 2.0)
+
+        self.img = goocanvas.Image(
+                parent = self.rootitem,
+                x = bounds.x1 - TG,
+                y = bounds.y1 - TG,
+                height = bounds.y2 - bounds.y1 + TG * 2,
+                width = bounds.x2 - bounds.x1 + TG * 2,
+                pixbuf = gcompris.utils.load_pixmap('piano_composition/button_front.svg')
+                )
+
+        gcompris.utils.item_focus_init(self.img, None)
+        textbox.raise_(self.img)
+
+    def getBackground(self):
+        return self.img
+
+    def destroy(self):
+        return self.rootitem.remove()
+


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