[gcompris] lang activity: now play the voice.



commit 6ce7249711d2a02cd7645a5026394035af6abfce
Author: Bruno Coudoin <bruno coudoin free fr>
Date:   Sun Nov 6 14:56:36 2011 +0100

    lang activity: now play the voice.

 src/lang-activity/lang.py                    |    8 +++++
 src/lang-activity/resources/lang/Makefile.am |   22 +++++++++++++
 src/lang-activity/resources/lang/lang.xml.in |   42 +++++++++++++-------------
 3 files changed, 51 insertions(+), 21 deletions(-)
---
diff --git a/src/lang-activity/lang.py b/src/lang-activity/lang.py
index f9df7ed..a33cdd6 100644
--- a/src/lang-activity/lang.py
+++ b/src/lang-activity/lang.py
@@ -21,6 +21,7 @@ import gtk.gdk
 import gcompris
 import gcompris.utils
 import gcompris.skin
+import gcompris.sound
 import goocanvas
 import pango
 
@@ -239,6 +240,11 @@ class Gcompris_lang:
       alignment = pango.ALIGN_CENTER
       )
     self.displayImage( lesson.getTriplets()[self.currentTripletId] )
+    self.playVoice( lesson.getTriplets()[self.currentTripletId] )
+
+  def playVoice(self, triplet):
+    if triplet.voice:
+      gcompris.sound.play_ogg("voices/$LOCALE/" + triplet.voice)
 
   def displayImage(self, triplet):
     self.descriptionitem.set_properties (
@@ -250,6 +256,7 @@ class Gcompris_lang:
       )
     if triplet.image:
       self.missingImage.hide()
+      self.imageitem.props.visibility = goocanvas.ITEM_VISIBLE
       pixbuf = gcompris.utils.load_pixmap(gcompris.DATA_DIR + "/lang/" +
                                           triplet.image)
       center_x =  pixbuf.get_width()/2
@@ -258,6 +265,7 @@ class Gcompris_lang:
                                     x = gcompris.BOARD_WIDTH  / 2 - center_x,
                                     y = gcompris.BOARD_HEIGHT / 2 - center_y )
     else:
+      self.imageitem.props.visibility = goocanvas.ITEM_INVISIBLE
       self.missingImage.show(triplet)
 
   def previous_event(self, event, target,item, dummy):
diff --git a/src/lang-activity/resources/lang/Makefile.am b/src/lang-activity/resources/lang/Makefile.am
new file mode 100644
index 0000000..eae9df0
--- /dev/null
+++ b/src/lang-activity/resources/lang/Makefile.am
@@ -0,0 +1,22 @@
+xmldir = $(pkgdatadir)/@PACKAGE_DATA_DIR@/lang
+
+xml_in_files = \
+	lang.xml.in
+
+xml_DATA = $(xml_in_files:.xml.in=.xml)
+
+#
+# Do not use the INTLTOOL_XML_RULE, we don't need to embed the translations
+# in the file themselves. GCompris pick the translations from the po file at
+# runtime.
+#
+$(xml_DATA): %.xml: %.xml.in
+	sed -e "s/\(<\{1\}\/*\)_/\1/g" $< > $@
+
+
+imgdir = $(pkgdatadir)/@PACKAGE_DATA_DIR@/lang
+img_DATA =
+
+
+EXTRA_DIST = $(img_DATA) ${xml_in_files}
+CLEANFILES = $(xml_DATA)
diff --git a/src/lang-activity/resources/lang/lang.xml.in b/src/lang-activity/resources/lang/lang.xml.in
index 5272622..77034ce 100644
--- a/src/lang-activity/resources/lang/lang.xml.in
+++ b/src/lang-activity/resources/lang/lang.xml.in
@@ -580,62 +580,62 @@
       <description></description>
       <Triplet>
 	<description>one apple</description>
-	<image></image>
-	<voice></voice>
+	<image>numbers/one.svg</image>
+	<voice>alphabet/1.ogg</voice>
 	<c:type></c:type>
       </Triplet>
       <Triplet>
 	<description>two oranges</description>
-	<image></image>
-	<voice></voice>
+	<image>numbers/orange.svg</image>
+	<voice>alphabet/2.ogg</voice>
 	<c:type></c:type>
       </Triplet>
       <Triplet>
 	<description>three strawberries</description>
-	<image></image>
-	<voice></voice>
+	<image>numbers/strawberries.svg</image>
+	<voice>alphabet/3.ogg</voice>
 	<c:type></c:type>
       </Triplet>
       <Triplet>
 	<description>four lemons</description>
-	<image></image>
-	<voice></voice>
+	<image>numbers/lemon.svg</image>
+	<voice>alphabet/4.ogg</voice>
 	<c:type></c:type>
       </Triplet>
       <Triplet>
 	<description>five pears</description>
-	<image></image>
-	<voice></voice>
+	<image>numbers/pear.svg</image>
+	<voice>alphabet/5.ogg</voice>
 	<c:type></c:type>
       </Triplet>
       <Triplet>
 	<description>six bananas</description>
-	<image></image>
-	<voice></voice>
+	<image>numbers/banana.svg</image>
+	<voice>alphabet/6.ogg</voice>
 	<c:type></c:type>
       </Triplet>
       <Triplet>
 	<description>seven raspberries</description>
-	<image></image>
-	<voice></voice>
+	<image>numbers/raspberries.svg</image>
+	<voice>alphabet/7.ogg</voice>
 	<c:type></c:type>
       </Triplet>
       <Triplet>
 	<description>eight pineapples</description>
-	<image></image>
-	<voice></voice>
+	<image>numbers/pineapples.svg</image>
+	<voice>alphabet/8.ogg</voice>
 	<c:type></c:type>
       </Triplet>
       <Triplet>
 	<description>nine mangos</description>
-	<image></image>
-	<voice></voice>
+	<image>numbers/mango.svg</image>
+	<voice>alphabet/9.ogg</voice>
 	<c:type></c:type>
       </Triplet>
       <Triplet>
-	<description>ten apricots</description>
-	<image></image>
-	<voice></voice>
+	<description>ten peaches</description>
+	<image>numbers/peach.svg</image>
+	<voice>alphabet/10.ogg</voice>
 	<c:type></c:type>
       </Triplet>
     </Lesson>



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