[gcompris/gcomprixogoo] Added an OK button to start the melody activity.



commit de8420561e60c1120ee198b5b21ed3d8f5b374ed
Author: Bruno Coudoin <bruno coudoin free fr>
Date:   Sun Jan 24 22:59:17 2010 +0100

    Added an OK button to start the melody activity.
    
    This is important to make sure the intro voice is not skipped
    because this activity play a sounds and interrupt the running one.

 src/melody-activity/melody.py |   28 +++++++++++++++++++++++-----
 1 files changed, 23 insertions(+), 5 deletions(-)
---
diff --git a/src/melody-activity/melody.py b/src/melody-activity/melody.py
index 27307bb..6f7fb5e 100644
--- a/src/melody-activity/melody.py
+++ b/src/melody-activity/melody.py
@@ -101,10 +101,6 @@ class Gcompris_melody:
     self.pause(1);
     self.display_current_level()
 
-    # Play an intro sound
-    gcompris.sound.play_ogg_cb("melody/" + self.melodylist[self.theme][0]['theme'] +
-                               "_melody.ogg", self.intro_cb)
-
     Prop = gcompris.get_properties()
 
     if(not Prop.fx):
@@ -184,7 +180,30 @@ class Gcompris_melody:
     self.hitofset_x = self.melodylist[self.theme][0]['hitofset_x']
     self.hitofset_y = self.melodylist[self.theme][0]['hitofset_y']
 
+    self.waitOK(self.rootitem)
+
+  def waitOK(self, rootitem):
+    # The OK Button
+    self.ok_item = goocanvas.Svg(parent = rootitem,
+                                 svg_handle = gcompris.skin.svg_get(),
+                                 svg_id = "#OK"
+                                 )
+    item = self.ok_item
+    item.translate(item.get_bounds().x1 * -1
+                           + gcompris.BOARD_WIDTH - (item.get_bounds().x2 - item.get_bounds().x1) - 30,
+                           item.get_bounds().y1 * -1
+                           + 65)
+
+    item.connect("button_press_event", self.ok_event, None)
+    gcompris.utils.item_focus_init(item, None)
+
+  def ok_event(self, widget, target, event, data):
+    self.ok_item.props.visibility = goocanvas.ITEM_INVISIBLE
     self.populate(self.sound_list)
+    # Play an intro sound
+    gcompris.sound.play_ogg_cb("melody/" + self.melodylist[self.theme][0]['theme'] +
+                               "_melody.ogg", self.intro_cb)
+
 
 
   # records the try of the child
@@ -371,7 +390,6 @@ class Gcompris_melody:
   def intro_cb(self, file):
     #print "intro passed. go play"
     self.pause(0)
-    self.populate(self.sound_list)
 
 def stop_board():
   gcompris.bonus.board_finished(gcompris.bonus.FINISHED_RANDOM)



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