Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruno Coudoin <bcoudoin@src.gnome.org>2003-03-25 22:06:23 (GMT)
committer Bruno Coudoin <bcoudoin@src.gnome.org>2003-03-25 22:06:23 (GMT)
commit6852e421e84dec0311674410cce8d50ea5b99e0e (patch)
tree4cd76938db4a47a683687aa8468cc95908f909f4
parent0ccfced9dc047bbdd456dc71c8bbe2a8c1d235cd (diff)
Olivier Samyn <osamyn@ulb.ac.be>
Completed the python port
-rwxr-xr-xautogen.sh9
-rw-r--r--boards/pythontest.xml.in18
-rw-r--r--boards/submarine.xml.in20
-rw-r--r--configure.in18
-rw-r--r--docs/C/python.html14
-rw-r--r--docs/C/python.xml381
-rwxr-xr-xpo-checktrans.py2
-rw-r--r--src/boards/Makefile.am19
-rw-r--r--src/boards/py-mod-bonus.c97
-rw-r--r--src/boards/py-mod-bonus.h6
-rw-r--r--src/boards/py-mod-gcompris.c94
-rw-r--r--src/boards/py-mod-score.c108
-rw-r--r--src/boards/py-mod-score.h6
-rw-r--r--src/boards/py-mod-sound.c115
-rw-r--r--src/boards/py-mod-sound.h6
-rw-r--r--src/boards/py-mod-timer.c167
-rw-r--r--src/boards/py-mod-timer.h6
-rw-r--r--src/boards/py-mod-utils.c287
-rw-r--r--src/boards/py-mod-utils.h6
-rw-r--r--src/gcompris/Makefile.am9
-rw-r--r--src/gcompris/soundutil.c45
-rw-r--r--src/gcompris/soundutil.h1
22 files changed, 1351 insertions, 83 deletions
diff --git a/autogen.sh b/autogen.sh
index 1b1dfa6..e538f9d 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -12,8 +12,7 @@ PKG_NAME="gcompris"
exit 1
}
-which gnome-autogen.sh || {
- echo "You need to install gnome-common from the GNOME CVS"
- exit 1
-}
-USE_GNOME2_MACROS=1 . gnome-autogen.sh
+REQUIRED_AUTOMAKE_VERSION=1.6 \
+USE_GNOME2_MACROS=1 \
+BUILD_PATH="$srcdir"\
+ . ./gnome2-macros/gnome-autogen.sh
diff --git a/boards/pythontest.xml.in b/boards/pythontest.xml.in
new file mode 100644
index 0000000..47c0dbc
--- /dev/null
+++ b/boards/pythontest.xml.in
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<GCompris>
+ <Board
+ name="pythontest"
+ type="pythonboard"
+ section="/."
+ icon="boardicons/python.png"
+ difficulty="1"
+ author="Olivier Samyn (osamyn@ulb.ac.be)"
+ boarddir="">
+ <_title>Python Test</_title>
+ <_description>Test board for the python plugin</_description>
+ <_prerequisite>Advanced Python Programmer :)</_prerequisite>
+ <_goal>Add a language binding to gcompris.</_goal>
+ <_credit>Thanks to Guido van Rossum and the python team for this powerfull language !</_credit>
+ </Board>
+ <Data directory=""/>
+</GCompris>
diff --git a/boards/submarine.xml.in b/boards/submarine.xml.in
new file mode 100644
index 0000000..69c6665
--- /dev/null
+++ b/boards/submarine.xml.in
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<GCompris>
+ <Board
+ name="submarine"
+ type="submarine"
+ section="/boards/."
+ icon="boardicons/erase.png"
+ difficulty="2"
+ author="Bruno Coudoin (bruno.coudoin@free.fr)"
+ boarddir="submarine">
+ <_title>Simplified Tower of Hanoi</_title>
+ <_description>Reproduce the given tower</_description>
+ <_prerequisite>Mouse manipulation</_prerequisite>
+ <_goal>Reproduce in the empty area the same tower than the one on the right</_goal>
+ <_manual>Drag and Drop the top piece only on an empty location
+ </_manual>
+ <_credit>Taken the concept from the EPI games.
+ </_credit>
+ </Board>
+</GCompris>
diff --git a/configure.in b/configure.in
index f1f5e0b..db4d8d2 100644
--- a/configure.in
+++ b/configure.in
@@ -5,6 +5,8 @@ AM_INIT_AUTOMAKE(gcompris, 2.3)
AM_CONFIG_HEADER(config.h)
AM_MAINTAINER_MODE
+GNOME_COMMON_INIT
+
AC_ISC_POSIX
LIBGNOME_REQUIRED=1.96.0
@@ -50,12 +52,12 @@ ALL_LINGUAS="am ar az ca de el es fi fr hu it lt ms nl no pt pt_BR ro ru sk sv t
dnl GCompris needs to know which locale are supported
AC_SUBST(ALL_LINGUAS)
-AC_DEFINE_UNQUOTED(ALL_LINGUAS, "${ALL_LINGUAS}")
+AC_DEFINE_UNQUOTED(ALL_LINGUAS, "${ALL_LINGUAS}", [Supported languages])
GETTEXT_PACKAGE=gcompris
AC_SUBST(GETTEXT_PACKAGE)
AM_GLIB_GNU_GETTEXT
-AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE")
+AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package name])
dnl Define myprefix depending on wether our user gives us one or not
if test "x${prefix}" = "xNONE"; then
@@ -65,27 +67,27 @@ else
fi
dnl Set PACKAGE_LOCALE_DIR in config.h.
-AC_DEFINE_UNQUOTED(PACKAGE_LOCALE_DIR, "${myprefix}/${DATADIRNAME}/locale")
+AC_DEFINE_UNQUOTED(PACKAGE_LOCALE_DIR, "${myprefix}/${DATADIRNAME}/locale", [Gcompris locale directory])
dnl Set PACKAGE_SOUNDS_DIR
PACKAGE_SOUNDS_DIR="sounds"
AC_SUBST(PACKAGE_SOUNDS_DIR)
-AC_DEFINE_UNQUOTED(PACKAGE_SOUNDS_DIR, "${myprefix}/${DATADIRNAME}/${PACKAGE}/sounds")
+AC_DEFINE_UNQUOTED(PACKAGE_SOUNDS_DIR, "${myprefix}/${DATADIRNAME}/${PACKAGE}/sounds", [Gcompris sounds directory])
dnl Set PACKAGE_DATA_DIR
PACKAGE_DATA_DIR="boards"
AC_SUBST(PACKAGE_DATA_DIR)
-AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${myprefix}/${DATADIRNAME}/${PACKAGE}/boards")
+AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${myprefix}/${DATADIRNAME}/${PACKAGE}/boards", [Gcompris data directory])
dnl Set PACKAGE_HELP_DIR
-AC_DEFINE_UNQUOTED(PACKAGE_HELP_DIR, "${myprefix}/${DATADIRNAME}/gnome/help/${PACKAGE}")
+AC_DEFINE_UNQUOTED(PACKAGE_HELP_DIR, "${myprefix}/${DATADIRNAME}/gnome/help/${PACKAGE}", [Gcompris help directory])
PACKAGE_HELP_DIR="${myprefix}/${DATADIRNAME}/gnome/help/${PACKAGE}"
AC_SUBST(PACKAGE_HELP_DIR)
dnl Plugin Directory
-AC_DEFINE_UNQUOTED(PLUGIN_DIR, "${myprefix}/lib/gcompris")
+AC_DEFINE_UNQUOTED(PLUGIN_DIR, "${myprefix}/lib/gcompris", [Gcompris plugins directory])
-AC_DEFINE_UNQUOTED(GNOME_ICONDIR, "${myprefix}/share/pixmaps")
+AC_DEFINE_UNQUOTED(GNOME_ICONDIR, "${myprefix}/share/pixmaps", [Gnome icons directory])
plugindir=$libdir/gcompris
AC_SUBST(plugindir)
diff --git a/docs/C/python.html b/docs/C/python.html
new file mode 100644
index 0000000..97d440d
--- /dev/null
+++ b/docs/C/python.html
@@ -0,0 +1,14 @@
+<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Python wrapper for Gcompris</title><meta name="generator" content="DocBook XSL Stylesheets V1.57.0"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="article" lang="en"><div class="titlepage"><div><h2 class="title"><a name="id2783186"></a>Python wrapper for Gcompris</h2></div><div><div class="author"><h3 class="author">Ir. Olivier Samyn</h3></div></div><div><div class="revhistory"><table border="1" width="100%" summary="Revision history"><tr><th align="left" valign="top" colspan="2"><b>Revision History</b></th></tr><tr><td align="left">Revision 0.1</td><td align="left">February 2003</td></tr></table></div></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="#id2841266">GcomprisBoard structure mapping </a></dt><dt><a href="#id2788464">gcompris.h functions and constants Mapping</a></dt><dd><dl><dt><a href="#id2788472">Functions mapping</a></dt><dt><a href="#id2787807">GComprisBarFlags enum mapping</a></dt><dt><a href="#id2787914">Misc constants mapping</a></dt><dt><a href="#id2787997">Colors constants mapping</a></dt><dt><a href="#id2788074">Fonts constants mapping</a></dt><dt><a href="#id2790868">Board font constants mapping</a></dt><dt><a href="#id2791000">Cursor constants mapping</a></dt></dl></dd></dl></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2841266"></a>GcomprisBoard structure mapping </h2></div></div><p>
+An instance of this structure in Python will act like an instance of the C
+one. Here a some Python call samples:
+ </p><pre class="programlisting">
+...
+ gcomprisBoard.level = 1
+ gcomprisBoard.maxlevel = 1
+...
+ gcompris.bar_start(gcomprisBoard.canvas)
+...
+</pre><p>
+Here are the Python structure member name and type, and a note indicating if the
+attribute is readeable and/or writable.
+ </p><div class="informaltable"><table border="1"><colgroup><col><col><col><col></colgroup><thead><tr><th>Structure member</th><th>Type</th><th>Readable</th><th>Writable</th></tr></thead><tbody><tr><td>type</td><td>string</td><td>Y</td><td>N</td></tr><tr><td>board_ready</td><td>boolean</td><td>Y</td><td>N</td></tr><tr><td>mode</td><td>string</td><td>Y</td><td>N</td></tr><tr><td>name</td><td>string</td><td>Y</td><td>N</td></tr><tr><td>title</td><td>string</td><td>Y</td><td>N</td></tr><tr><td>description</td><td>string</td><td>Y</td><td>N</td></tr><tr><td>icon_name</td><td>string</td><td>Y</td><td>N</td></tr><tr><td>author</td><td>string</td><td>Y</td><td>N</td></tr><tr><td>boarddir</td><td>string</td><td>Y</td><td>N</td></tr><tr><td>filename</td><td>string</td><td>Y</td><td>N</td></tr><tr><td>difficulty</td><td>string</td><td>Y</td><td>N</td></tr><tr><td>mandatory_sound_file</td><td>string</td><td>Y</td><td>N</td></tr><tr><td>section</td><td>string</td><td>Y</td><td>N</td></tr><tr><td>menuposotion</td><td>string</td><td>Y</td><td>N</td></tr><tr><td>prerequisite</td><td>string</td><td>Y</td><td>N</td></tr><tr><td>goal</td><td>string</td><td>Y</td><td>N</td></tr><tr><td>manual</td><td>string</td><td>Y</td><td>N</td></tr><tr><td>credit</td><td>string</td><td>Y</td><td>N</td></tr><tr><td>width</td><td>int</td><td>Y</td><td>N</td></tr><tr><td>height</td><td>int</td><td>Y</td><td>N</td></tr><tr><td>canvas</td><td>gnome.canvas.Canvas</td><td>Y</td><td>N</td></tr><tr><td>previous_board</td><td>GcomprisBoard</td><td>Y</td><td>N</td></tr><tr><td>level</td><td>int</td><td>Y</td><td>Y</td></tr><tr><td>maxlevel</td><td>int</td><td>Y</td><td>Y</td></tr><tr><td>sublevel</td><td>int</td><td>Y</td><td>Y</td></tr><tr><td>number_of_sublevel</td><td>int</td><td>Y</td><td>Y</td></tr></tbody></table></div></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2788464"></a>gcompris.h functions and constants Mapping</h2></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2788472"></a>Functions mapping</h3></div></div><div class="informaltable"><table border="1"><colgroup><col><col><col></colgroup><thead><tr><th>Python function</th><th>C equivalent</th><th>Notes</th></tr></thead><tbody><tr><td>gcompris.end_board()</td><td>void gcompris_end_board(void)</td><td> </td></tr><tr><td>gcompris.bar_start(gnomeCanvas)</td><td>void gcompris_bar_start(GnomeCanvas *theCanvas)</td><td> </td></tr><tr><td>gcompris.set_background(gnomeCanvasGroup, file)</td><td>GnomeCanvasItem *gcompris_set_background(GnomeCanvasGroup *parent, gchar *file)</td><td>return a gnome.canvas.CanvasItem object</td></tr><tr><td>gcompris.bar_set_level(gcomprisBoard)</td><td>void gcompris_bar_set_level(GcomprisBoard *gcomprisBoard)</td><td> </td></tr><tr><td>gcompris.bar_set(flags)</td><td>void gcompris_bar_set(const GComprisBarFlags flags)</td><td> </td></tr><tr><td>gcompris.bar_hide(hide)</td><td>void gcompris_bar_hide(gboolean hide)</td><td> </td></tr><tr><td>gcompris.board_has_help(gcomprisBoard)</td><td>gboolean gcompris_board_has_help(GcomprisBoard *gcomprisBoard)</td><td>return a boolean</td></tr><tr><td>gcompris.help_start(gcomprisBoard)</td><td>void gcompris_help_start(GcomprisBoard *gcomprisBoard)</td><td> </td></tr><tr><td>gcompris.help_stop()</td><td>void gcompris_help_stop(void)</td><td> </td></tr><tr><td>gcompris.get_canvas()</td><td>GnomeCanvas* gcompris_get_canvas()</td><td>return a gnome.canvas.Canvas</td></tr><tr><td>gcompris.get_window()</td><td>GtkWidget* gcompris_get_window(void)</td><td>return a gtk.Widget</td></tr><tr><td>gcompris.get_locale()</td><td>gchar* gcompris_get_locale(void)</td><td>return a string</td></tr><tr><td>gcompris.set_locale(locale)</td><td>void gcompris_set_locale(gchar *locale)</td><td> </td></tr><tr><td>gcompris.set_cursor(cursor_type)</td><td>void gcompris_set_cursor(guint gdk_cursor_type)</td><td> </td></tr><tr><td>gcompris.images_selector_start(gcomprisBoard, dataset, callback)</td><td>void gcompris_images_selector_start (GcomprisBoard *gcomprisBoard, gchar *dataset, ImageSelectorCallBack imscb)</td><td>The callback must be a callable object</td></tr><tr><td>gcompris.images_selector_stop()</td><td>void gcompris_images_selector_stop(void)</td><td> </td></tr><tr><td>gcompris.exit()</td><td>void gcompris_exit(void)</td><td> </td></tr></tbody></table></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2787807"></a>GComprisBarFlags enum mapping</h3></div></div><div class="informaltable"><table border="1"><colgroup><col><col></colgroup><thead><tr><th>Python constant</th><th>C equivalent</th></tr></thead><tbody><tr><td>gcompris.BAR_LEVEL</td><td>GCOMPRIS_BAR_LEVEL</td></tr><tr><td>gcompris.BAR_OK</td><td>GCOMPRIS_BAR_OK</td></tr><tr><td>gcompris.BAR_REPEAT</td><td>GCOMPRIS_BAR_REPEAT</td></tr><tr><td>gcompris.BAR_CONFIG</td><td>GCOMPRIS_BAR_CONFIG</td></tr><tr><td>gcompris.BAR_ABOUT</td><td>GCOMPRIS_BAR_ABOUT</td></tr></tbody></table></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2787914"></a>Misc constants mapping</h3></div></div><div class="informaltable"><table border="1"><colgroup><col><col></colgroup><thead><tr><th>Python constant</th><th>C equivalent</th></tr></thead><tbody><tr><td>gcompris.BOARD_HEIGHT</td><td>BOARDHEIGHT</td></tr><tr><td>gcompris.BOARD_WIDTH</td><td>BOARDWIDTH</td></tr><tr><td>gcompris.BAR_HEIGHT</td><td>BAR_HEIGHT</td></tr><tr><td>gcompris.DEFAULT_SKIN</td><td>DEFAULT_SKIN</td></tr></tbody></table></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2787997"></a>Colors constants mapping</h3></div></div><div class="informaltable"><table border="1"><colgroup><col><col></colgroup><thead><tr><th>Python constant</th><th>C equivalent</th></tr></thead><tbody><tr><td>gcompris.COLOR_TITLE</td><td>COLOR_TITLE</td></tr><tr><td>gcompris.COLOR_TEXT_BUTTON</td><td>COLOR_TEXT_BUTTON</td></tr><tr><td>gcompris.COLOR_CONTENT</td><td>COLOR_CONTENT</td></tr><tr><td>gcompris.COLOR_SUBTITLE</td><td>COLOR_SUBTITLE</td></tr></tbody></table></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2788074"></a>Fonts constants mapping</h3></div></div><div class="informaltable"><table border="1"><colgroup><col><col></colgroup><thead><tr><th>Python constant</th><th>C equivalent</th></tr></thead><tbody><tr><td>gcompris.FONT_TITLE</td><td>FONT_TITLE</td></tr><tr><td>gcompris.FONT_TITLE_FALLBACK</td><td>FONT_TITLE_FALLBACK</td></tr><tr><td>gcompris.FONT_SUBTITLE</td><td>FONT_SUBTITLE</td></tr><tr><td>gcompris.FONT_SUBTITLE_FALLBACK</td><td>FONT_SUBTITLE_FALLBACK</td></tr><tr><td>gcompris.FONT_CONTENT</td><td>FONT_CONTENT</td></tr><tr><td>gcompris.FONT_CONTENT_FALLBACK</td><td>FONT_CONTENT_FALLBACK</td></tr></tbody></table></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2790868"></a>Board font constants mapping</h3></div></div><div class="informaltable"><table border="1"><colgroup><col><col></colgroup><thead><tr><th>Python constant</th><th>C equivalent</th></tr></thead><tbody><tr><td>gcompris.FONT_BOARD_TINY</td><td>FONT_BOARD_TINY</td></tr><tr><td>gcompris.FONT_BOARD_SMALL</td><td>FONT_BOARD_SMALL</td></tr><tr><td>gcompris.FONT_BOARD_MEDIUM</td><td>FONT_BOARD_MEDIUM</td></tr><tr><td>gcompris.FONT_BOARD_BIG</td><td>FONT_BOARD_BIG</td></tr><tr><td>gcompris.FONT_BOARD_BIG_BOLD</td><td>FONT_BOARD_BIG_BOLD</td></tr><tr><td>gcompris.FONT_BOARD_FIXED</td><td>FONT_BOARD_FIXED</td></tr><tr><td>gcompris.FONT_BOARD_TITLE</td><td>FONT_BOARD_TITLE</td></tr><tr><td>gcompris.FONT_BOARD_TITLE_BOLD</td><td>FONT_BOARD_TITLE_BOLD</td></tr><tr><td>gcompris.FONT_BOARD_HUGE</td><td>FONT_BOARD_HUGE</td></tr><tr><td>gcompris.FONT_BOARD_HUGE_BOLD</td><td>FONT_BOARD_HUGE_BOLD</td></tr></tbody></table></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2791000"></a>Cursor constants mapping</h3></div></div><div class="informaltable"><table border="1"><colgroup><col><col></colgroup><thead><tr><th>Python constant</th><th>C equivalent</th></tr></thead><tbody><tr><td>gcompris.CURSOR_FIRST_CUSTOM</td><td>GCOMPRIS_FIRST_CUSTOM_CURSOR</td></tr><tr><td>gcompris.CURSOR_BIG_RED_ARROW</td><td>GCOMPRIS_BIG_RED_ARROW_CURSOR</td></tr><tr><td>gcompris.CURSOR_BIRD</td><td>GCOMPRIS_BIRD_CURSOR</td></tr><tr><td>gcompris.CURSOR_LINE</td><td>GCOMPRIS_LINE_CURSOR</td></tr><tr><td>gcompris.CURSOR_FILLRECT</td><td>GCOMPRIS_FILLRECT_CURSOR</td></tr><tr><td>gcompris.CURSOR_RECT</td><td>GCOMPRIS_RECT_CURSOR</td></tr><tr><td>gcompris.CURSOR_FILLCIRCLE</td><td>GCOMPRIS_FILLCIRCLE_CURSOR</td></tr><tr><td>gcompris.CURSOR_CIRCLE</td><td>GCOMPRIS_CIRCLE_CURSOR</td></tr><tr><td>gcompris.CURSOR_DEL</td><td>GCOMPRIS_DEL_CURSOR</td></tr><tr><td>gcompris.CURSOR_FILL</td><td>GCOMPRIS_FILL_CURSOR</td></tr><tr><td>gcompris.CURSOR_SELECT</td><td>GCOMPRIS_SELECT_CURSOR</td></tr><tr><td>gcompris.CURSOR_DEFAULT</td><td>GCOMPRIS_DEFAULT_CURSOR</td></tr></tbody></table></div></div></div></div></body></html>
diff --git a/docs/C/python.xml b/docs/C/python.xml
new file mode 100644
index 0000000..82782c5
--- /dev/null
+++ b/docs/C/python.xml
@@ -0,0 +1,381 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
+ "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
+<article>
+ <articleinfo>
+ <author>
+ <honorific>Ir</honorific>
+ <firstname>Olivier</firstname>
+ <surname>Samyn</surname>
+ <email>osamyn@ulb.ac.be</email>
+ </author>
+ <date>February 2003</date>
+ <revhistory>
+ <revision>
+ <revnumber>0.1</revnumber>
+ <date>February 2003</date>
+ </revision>
+ </revhistory>
+ </articleinfo>
+ <title>Python wrapper for Gcompris</title>
+ <sect1>
+ <title>GcomprisBoard structure mapping </title>
+
+ <para>
+An instance of this structure in Python will act like an instance of the C
+one. Here a some Python call samples:
+ </para>
+<programlisting>
+...
+ gcomprisBoard.level = 1
+ gcomprisBoard.maxlevel = 1
+...
+ gcompris.bar_start(gcomprisBoard.canvas)
+...
+</programlisting>
+ <para>
+Here are the Python structure member name and type, and a note indicating if the
+attribute is readeable and/or writable.
+ </para>
+
+ <informaltable>
+ <tgroup cols="4">
+ <thead>
+ <row>
+ <entry>Structure member</entry>
+ <entry>Type</entry>
+ <entry>Readable</entry>
+ <entry>Writable</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>type</entry><entry>string</entry><entry>Y</entry><entry>N</entry>
+ </row><row>
+ <entry>board_ready</entry><entry>boolean</entry><entry>Y</entry><entry>N</entry>
+ </row><row>
+ <entry>mode</entry><entry>string</entry><entry>Y</entry><entry>N</entry>
+ </row><row>
+ <entry>name</entry><entry>string</entry><entry>Y</entry><entry>N</entry>
+ </row><row>
+ <entry>title</entry><entry>string</entry><entry>Y</entry><entry>N</entry>
+ </row><row>
+ <entry>description</entry><entry>string</entry><entry>Y</entry><entry>N</entry>
+ </row><row>
+ <entry>icon_name</entry><entry>string</entry><entry>Y</entry><entry>N</entry>
+ </row><row>
+ <entry>author</entry><entry>string</entry><entry>Y</entry><entry>N</entry>
+ </row><row>
+ <entry>boarddir</entry><entry>string</entry><entry>Y</entry><entry>N</entry>
+ </row><row>
+ <entry>filename</entry><entry>string</entry><entry>Y</entry><entry>N</entry>
+ </row><row>
+ <entry>difficulty</entry><entry>string</entry><entry>Y</entry><entry>N</entry>
+ </row><row>
+ <entry>mandatory_sound_file</entry><entry>string</entry><entry>Y</entry><entry>N</entry>
+ </row><row>
+ <entry>section</entry><entry>string</entry><entry>Y</entry><entry>N</entry>
+ </row><row>
+ <entry>menuposotion</entry><entry>string</entry><entry>Y</entry><entry>N</entry>
+ </row><row>
+ <entry>prerequisite</entry><entry>string</entry><entry>Y</entry><entry>N</entry>
+ </row><row>
+ <entry>goal</entry><entry>string</entry><entry>Y</entry><entry>N</entry>
+ </row><row>
+ <entry>manual</entry><entry>string</entry><entry>Y</entry><entry>N</entry>
+ </row><row>
+ <entry>credit</entry><entry>string</entry><entry>Y</entry><entry>N</entry>
+ </row><row>
+ <entry>width</entry><entry>int</entry><entry>Y</entry><entry>N</entry>
+ </row><row>
+ <entry>height</entry><entry>int</entry><entry>Y</entry><entry>N</entry>
+ </row><row>
+ <entry>canvas</entry><entry>gnome.canvas.Canvas</entry><entry>Y</entry><entry>N</entry>
+ </row><row>
+ <entry>previous_board</entry><entry>GcomprisBoard</entry><entry>Y</entry><entry>N</entry>
+ </row><row>
+ <entry>level</entry><entry>int</entry><entry>Y</entry><entry>Y</entry>
+ </row><row>
+ <entry>maxlevel</entry><entry>int</entry><entry>Y</entry><entry>Y</entry>
+ </row><row>
+ <entry>sublevel</entry><entry>int</entry><entry>Y</entry><entry>Y</entry>
+ </row><row>
+ <entry>number_of_sublevel</entry><entry>int</entry><entry>Y</entry><entry>Y</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </sect1>
+
+
+
+ <sect1>
+ <title>gcompris.h functions and constants Mapping</title>
+ <sect2>
+ <title>Functions mapping</title>
+ <informaltable>
+ <tgroup cols="3">
+ <thead>
+ <row>
+ <entry>Python function</entry>
+ <entry>C equivalent</entry>
+ <entry>Notes</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>gcompris.end_board()</entry>
+ <entry>void gcompris_end_board(void)</entry>
+ <entry></entry>
+ </row>
+ <row>
+ <entry>gcompris.bar_start(gnomeCanvas)</entry>
+ <entry>void gcompris_bar_start(GnomeCanvas *theCanvas)</entry>
+ <entry></entry>
+ </row>
+ <row>
+ <entry>gcompris.set_background(gnomeCanvasGroup, file)</entry>
+ <entry>GnomeCanvasItem *gcompris_set_background(GnomeCanvasGroup *parent, gchar *file)</entry>
+ <entry>return a gnome.canvas.CanvasItem object</entry>
+ </row>
+ <row>
+ <entry>gcompris.bar_set_level(gcomprisBoard)</entry>
+ <entry>void gcompris_bar_set_level(GcomprisBoard *gcomprisBoard)</entry>
+ <entry></entry>
+ </row>
+ <row>
+ <entry>gcompris.bar_set(flags)</entry>
+ <entry>void gcompris_bar_set(const GComprisBarFlags flags)</entry>
+ <entry></entry>
+ </row>
+ <row>
+ <entry>gcompris.bar_hide(hide)</entry>
+ <entry>void gcompris_bar_hide(gboolean hide)</entry>
+ <entry></entry>
+ </row>
+ <row>
+ <entry>gcompris.board_has_help(gcomprisBoard)</entry>
+ <entry>gboolean gcompris_board_has_help(GcomprisBoard *gcomprisBoard)</entry>
+ <entry>return a boolean</entry>
+ </row>
+ <row>
+ <entry>gcompris.help_start(gcomprisBoard)</entry>
+ <entry>void gcompris_help_start(GcomprisBoard *gcomprisBoard)</entry>
+ <entry></entry>
+ </row>
+ <row>
+ <entry>gcompris.help_stop()</entry>
+ <entry>void gcompris_help_stop(void)</entry>
+ <entry></entry>
+ </row>
+ <row>
+ <entry>gcompris.get_canvas()</entry>
+ <entry>GnomeCanvas* gcompris_get_canvas()</entry>
+ <entry>return a gnome.canvas.Canvas</entry>
+ </row>
+ <row>
+ <entry>gcompris.get_window()</entry>
+ <entry>GtkWidget* gcompris_get_window(void)</entry>
+ <entry>return a gtk.Widget</entry>
+ </row>
+ <row>
+ <entry>gcompris.get_locale()</entry>
+ <entry>gchar* gcompris_get_locale(void)</entry>
+ <entry>return a string</entry>
+ </row>
+ <row>
+ <entry>gcompris.set_locale(locale)</entry>
+ <entry>void gcompris_set_locale(gchar *locale)</entry>
+ <entry></entry>
+ </row>
+ <row>
+ <entry>gcompris.set_cursor(cursor_type)</entry>
+ <entry>void gcompris_set_cursor(guint gdk_cursor_type)</entry>
+ <entry></entry>
+ </row>
+ <row>
+ <entry>gcompris.images_selector_start(gcomprisBoard, dataset, callback)</entry>
+ <entry>void gcompris_images_selector_start (GcomprisBoard *gcomprisBoard, gchar *dataset, ImageSelectorCallBack imscb)</entry>
+ <entry>The callback must be a callable object</entry>
+ </row>
+ <row>
+ <entry>gcompris.images_selector_stop()</entry>
+ <entry>void gcompris_images_selector_stop(void)</entry>
+ <entry></entry>
+ </row>
+ <row>
+ <entry>gcompris.exit()</entry>
+ <entry>void gcompris_exit(void)</entry>
+ <entry></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </sect2>
+ <sect2>
+ <title>GComprisBarFlags enum mapping</title>
+ <informaltable>
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>Python constant</entry>
+ <entry>C equivalent</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>gcompris.BAR_LEVEL</entry>
+ <entry>GCOMPRIS_BAR_LEVEL</entry>
+ </row>
+ <row>
+ <entry>gcompris.BAR_OK</entry>
+ <entry>GCOMPRIS_BAR_OK</entry>
+ </row>
+ <row>
+ <entry>gcompris.BAR_REPEAT</entry>
+ <entry>GCOMPRIS_BAR_REPEAT</entry>
+ </row>
+ <row>
+ <entry>gcompris.BAR_CONFIG</entry>
+ <entry>GCOMPRIS_BAR_CONFIG</entry>
+ </row>
+ <row>
+ <entry>gcompris.BAR_ABOUT</entry>
+ <entry>GCOMPRIS_BAR_ABOUT</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </sect2>
+
+ <sect2>
+ <title>Misc constants mapping</title>
+ <informaltable>
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>Python constant</entry>
+ <entry>C equivalent</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row><entry>gcompris.BOARD_HEIGHT</entry>
+ <entry>BOARDHEIGHT</entry></row>
+ <row><entry>gcompris.BOARD_WIDTH</entry>
+ <entry>BOARDWIDTH</entry></row>
+ <row><entry>gcompris.BAR_HEIGHT</entry>
+ <entry>BAR_HEIGHT</entry></row>
+ <row><entry>gcompris.DEFAULT_SKIN</entry>
+ <entry>DEFAULT_SKIN</entry></row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </sect2>
+
+ <sect2>
+ <title>Colors constants mapping</title>
+ <informaltable>
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>Python constant</entry>
+ <entry>C equivalent</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row><entry>gcompris.COLOR_TITLE</entry><entry>COLOR_TITLE</entry></row>
+ <row><entry>gcompris.COLOR_TEXT_BUTTON</entry><entry>COLOR_TEXT_BUTTON</entry></row>
+ <row><entry>gcompris.COLOR_CONTENT</entry><entry>COLOR_CONTENT</entry></row>
+ <row><entry>gcompris.COLOR_SUBTITLE</entry><entry>COLOR_SUBTITLE</entry></row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </sect2>
+
+ <sect2>
+ <title>Fonts constants mapping</title>
+ <informaltable>
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>Python constant</entry>
+ <entry>C equivalent</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row><entry>gcompris.FONT_TITLE</entry><entry>FONT_TITLE</entry></row>
+ <row><entry>gcompris.FONT_TITLE_FALLBACK</entry><entry>FONT_TITLE_FALLBACK</entry></row>
+ <row><entry>gcompris.FONT_SUBTITLE</entry><entry>FONT_SUBTITLE</entry></row>
+ <row><entry>gcompris.FONT_SUBTITLE_FALLBACK</entry><entry>FONT_SUBTITLE_FALLBACK</entry></row>
+ <row><entry>gcompris.FONT_CONTENT</entry><entry>FONT_CONTENT</entry></row>
+ <row><entry>gcompris.FONT_CONTENT_FALLBACK</entry><entry>FONT_CONTENT_FALLBACK</entry></row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </sect2>
+
+ <sect2>
+ <title>Board font constants mapping</title>
+ <informaltable>
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>Python constant</entry>
+ <entry>C equivalent</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row><entry>gcompris.FONT_BOARD_TINY</entry><entry>FONT_BOARD_TINY</entry></row>
+ <row><entry>gcompris.FONT_BOARD_SMALL</entry><entry>FONT_BOARD_SMALL</entry></row>
+ <row><entry>gcompris.FONT_BOARD_MEDIUM</entry><entry>FONT_BOARD_MEDIUM</entry></row>
+ <row><entry>gcompris.FONT_BOARD_BIG</entry><entry>FONT_BOARD_BIG</entry></row>
+ <row><entry>gcompris.FONT_BOARD_BIG_BOLD</entry><entry>FONT_BOARD_BIG_BOLD</entry></row>
+ <row><entry>gcompris.FONT_BOARD_FIXED</entry><entry>FONT_BOARD_FIXED</entry></row>
+ <row><entry>gcompris.FONT_BOARD_TITLE</entry><entry>FONT_BOARD_TITLE</entry></row>
+ <row><entry>gcompris.FONT_BOARD_TITLE_BOLD</entry><entry>FONT_BOARD_TITLE_BOLD</entry></row>
+ <row><entry>gcompris.FONT_BOARD_HUGE</entry><entry>FONT_BOARD_HUGE</entry></row>
+ <row><entry>gcompris.FONT_BOARD_HUGE_BOLD</entry><entry>FONT_BOARD_HUGE_BOLD</entry></row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </sect2>
+
+ <sect2>
+ <title>Cursor constants mapping</title>
+ <informaltable>
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>Python constant</entry>
+ <entry>C equivalent</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row><entry>gcompris.CURSOR_FIRST_CUSTOM</entry>
+ <entry>GCOMPRIS_FIRST_CUSTOM_CURSOR</entry></row>
+ <row><entry>gcompris.CURSOR_BIG_RED_ARROW</entry>
+ <entry>GCOMPRIS_BIG_RED_ARROW_CURSOR</entry></row>
+ <row><entry>gcompris.CURSOR_BIRD</entry><entry>GCOMPRIS_BIRD_CURSOR</entry></row>
+ <row><entry>gcompris.CURSOR_LINE</entry><entry>GCOMPRIS_LINE_CURSOR</entry></row>
+ <row><entry>gcompris.CURSOR_FILLRECT</entry><entry>GCOMPRIS_FILLRECT_CURSOR</entry></row>
+ <row><entry>gcompris.CURSOR_RECT</entry><entry>GCOMPRIS_RECT_CURSOR</entry></row>
+ <row><entry>gcompris.CURSOR_FILLCIRCLE</entry><entry>GCOMPRIS_FILLCIRCLE_CURSOR</entry></row>
+ <row><entry>gcompris.CURSOR_CIRCLE</entry><entry>GCOMPRIS_CIRCLE_CURSOR</entry></row>
+ <row><entry>gcompris.CURSOR_DEL</entry><entry>GCOMPRIS_DEL_CURSOR</entry></row>
+ <row><entry>gcompris.CURSOR_FILL</entry><entry>GCOMPRIS_FILL_CURSOR</entry></row>
+ <row><entry>gcompris.CURSOR_SELECT</entry><entry>GCOMPRIS_SELECT_CURSOR</entry></row>
+ <row><entry>gcompris.CURSOR_DEFAULT</entry><entry>GCOMPRIS_DEFAULT_CURSOR</entry></row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </sect2>
+
+ </sect1>
+</article>
+
+<!-- Keep this comment at the end of the file
+Local variables:
+mode: xml
+sgml-default-dtd-file:"/usr/share/xml/docbook/xemacs/docbook-4.2"
+End:
+-->
diff --git a/po-checktrans.py b/po-checktrans.py
index f6ade0d..4426da9 100755
--- a/po-checktrans.py
+++ b/po-checktrans.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
#
# This quick hack gives translation statistics (from the core translation
# files).
diff --git a/src/boards/Makefile.am b/src/boards/Makefile.am
index f4bd4f9..de063d0 100644
--- a/src/boards/Makefile.am
+++ b/src/boards/Makefile.am
@@ -8,7 +8,6 @@ endif
SUBDIRS= $(python_subdir)
-
lib_LTLIBRARIES = \
libalgebra.la \
libalgebra_guesscount.la \
@@ -49,7 +48,7 @@ lib_LTLIBRARIES = \
libdir = $(plugindir)
INCLUDES = \
- -I.. \
+ -I$(top_srcdir)/src \
-I$(top_srcdir)/intl \
$(GCOMPRIS_CFLAGS) \
$(XML_CFLAGS) \
@@ -316,13 +315,6 @@ libhanoi_la_LIBADD = \
libhanoi_la_SOURCES = hanoi.c
-libpython_la_CPPFLAGS = \
- -I.. \
- -I$(top_srcdir)/intl \
- $(GCOMPRIS_CFLAGS) \
- $(XML_CFLAGS) \
- $(PYTHON_CFLAGS) \
- $(PYGTK_CFLAGS)
libpython_la_LDFLAGS = -export-dynamic -module -avoid-version
libpython_la_LIBADD = \
@@ -331,8 +323,13 @@ libpython_la_LIBADD = \
$(PYGTK_LIBS)
libpython_la_SOURCES = python.c \
- py-gcompris-board.c py-gcompris-board.h \
- py-mod-gcompris.c py-mod-gcompris.h
+ py-gcompris-board.c py-gcompris-board.h \
+ py-mod-gcompris.c py-mod-gcompris.h \
+ py-mod-utils.c py-mod-utils.h \
+ py-mod-bonus.c py-mod-bonus.h \
+ py-mod-score.c py-mod-score.h \
+ py-mod-timer.c py-mod-timer.h \
+ py-mod-sound.c py-mod-sound.h
EXTRA_DIST = README
diff --git a/src/boards/py-mod-bonus.c b/src/boards/py-mod-bonus.c
new file mode 100644
index 0000000..7e3c1cd
--- /dev/null
+++ b/src/boards/py-mod-bonus.c
@@ -0,0 +1,97 @@
+#include <Python.h>
+#include <pygobject.h>
+#include "gcompris/gcompris.h"
+#include "py-mod-bonus.h"
+#include "py-gcompris-board.h"
+
+/* All functions provided by this python module
+ * wraps a gcompris function. Each "py_*" function wraps the
+ * "*" C function.
+ */
+
+/* void gcompris_display_bonus(int gamewon, int bonus_id); */
+static PyObject*
+py_gcompris_display_bonus(PyObject* self, PyObject* args)
+{
+ int gamewon;
+ int bonus_id;
+ /* Parse arguments */
+ if(!PyArg_ParseTuple(args, "ii:gcompris_display_bonus", &gamewon, &bonus_id))
+ return NULL;
+
+ /* Call the corresponding C function */
+ gcompris_display_bonus(gamewon, bonus_id);
+
+ /* Create and return the result */
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+/* void board_finished(int type); */
+static PyObject*
+py_gcompris_board_finished(PyObject* self, PyObject* args)
+{
+ int type;
+ /* Parse arguments */
+ if(!PyArg_ParseTuple(args, "i:board_finished", &type))
+ return NULL;
+
+ /* Call the corresponding C function */
+ board_finished(type);
+
+ /* Create and return the result */
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+static PyMethodDef PythonGcomprisBonusModule[] = {
+ { "display", py_gcompris_display_bonus, METH_VARARGS, "gcompris_display_bonus" },
+ { "board_finished", py_gcompris_board_finished, METH_VARARGS, "board_finished" },
+ { NULL, NULL, 0, NULL}
+};
+
+void python_gcompris_bonus_module_init(void)
+{
+ PyObject* module;
+ module = Py_InitModule("gcompris.bonus", PythonGcomprisBonusModule);
+
+ /* Misc constants */
+ PyModule_AddIntConstant(module, "TIME_CLICK_TO", TIME_CLICK_TO_BONUS );
+
+ /* BonusList constants */
+ PyModule_AddIntConstant(module, "RANDOM", BONUS_RANDOM );
+ PyModule_AddIntConstant(module, "SMILEY", BONUS_SMILEY );
+ PyModule_AddIntConstant(module, "FLOWER", BONUS_FLOWER );
+ PyModule_AddIntConstant(module, "LAST", BONUS_LAST );
+
+ /* BonusFinishedList constants */
+ PyModule_AddIntConstant(module, "FINISHED_RANDOM", BOARD_FINISHED_RANDOM );
+ PyModule_AddIntConstant(module, "FINISHED_TUXPLANE", BOARD_FINISHED_TUXPLANE );
+ PyModule_AddIntConstant(module, "FINISHED_TUXLOCO", BOARD_FINISHED_TUXLOCO );
+ PyModule_AddIntConstant(module, "FINISHED_TOOMANYERRORS", BOARD_FINISHED_TOOMANYERRORS );
+ PyModule_AddIntConstant(module, "FINISHED_LAST", BOARD_FINISHED_LAST );
+}
+
+/* Some usefull code parts ... */
+/*
+static PyObject*
+py_gcompris_(PyObject* self, PyObject* args)
+{
+*/ /* Parse arguments */
+/* if(!PyArg_ParseTuple(args, ":gcompris_"))
+ return NULL;
+*/
+ /* Call the corresponding C function */
+/* gcompris_();
+*/
+ /* Create and return the result */
+/* Py_INCREF(Py_None);
+ return Py_None;
+}
+*/
+/*
+ { "", py_gcompris_, METH_VARARGS, "gcompris_" },
+*/
+
diff --git a/src/boards/py-mod-bonus.h b/src/boards/py-mod-bonus.h
new file mode 100644
index 0000000..229ff87
--- /dev/null
+++ b/src/boards/py-mod-bonus.h
@@ -0,0 +1,6 @@
+#ifndef _PY_MOD_BONUS_H_
+#define _PY_MOD_BONUS_H_
+
+void python_gcompris_bonus_module_init(void);
+
+#endif
diff --git a/src/boards/py-mod-gcompris.c b/src/boards/py-mod-gcompris.c
index e9ca0f2..97c9148 100644
--- a/src/boards/py-mod-gcompris.c
+++ b/src/boards/py-mod-gcompris.c
@@ -4,8 +4,11 @@
#include "py-mod-gcompris.h"
#include "py-gcompris-board.h"
-/* All functions provided by this python module
- * wraps a gcompris function. Each "py_*" function wraps the
+/* submodules includes */
+#include "py-mod-utils.h"
+
+/* All functions provided by this python module
+ * wraps a gcompris function. Each "py_*" function wraps the
* "*" C function.
*/
@@ -21,7 +24,7 @@ py_gcompris_end_board(PyObject* self, PyObject* args)
/* Call the corresponding C function */
gcompris_end_board();
- /* Create and return the result */
+ /* Create and return the result */
Py_INCREF(Py_None);
return Py_None;
}
@@ -42,7 +45,7 @@ py_gcompris_bar_start(PyObject* self, PyObject* args)
/* Call the corresponding C function */
gcompris_bar_start(canvas);
- /* Create and return the result */
+ /* Create and return the result */
Py_INCREF(Py_None);
return Py_None;
}
@@ -57,7 +60,7 @@ py_gcompris_set_background(PyObject* self, PyObject* args)
gchar* file;
PyObject* pyResult;
GnomeCanvasItem* result;
-
+
/* Parse arguments */
if(!PyArg_ParseTuple(args, "Os:gcompris_set_background", &pyCanvasGroup, &file))
return NULL;
@@ -66,7 +69,7 @@ py_gcompris_set_background(PyObject* self, PyObject* args)
/* Call the corresponding C function */
result = gcompris_set_background(canvasGroup, file);
- /* Create and return the result */
+ /* Create and return the result */
pyResult = pygobject_new((GObject*)result);
return pyResult;
}
@@ -89,7 +92,7 @@ py_gcompris_bar_set_level(PyObject* self, PyObject* args)
/* Call the corresponding C function */
gcompris_bar_set_level(cGcomprisBoard);
- /* Create and return the result */
+ /* Create and return the result */
Py_INCREF(Py_None);
return Py_None;
}
@@ -99,7 +102,7 @@ py_gcompris_bar_set_level(PyObject* self, PyObject* args)
static PyObject*
py_gcompris_bar_set(PyObject* self, PyObject* args)
{
- gint values;
+ gint values;
/* Parse arguments */
if(!PyArg_ParseTuple(args, "i:gcompris_bar_set", &values))
@@ -108,7 +111,7 @@ py_gcompris_bar_set(PyObject* self, PyObject* args)
/* Call the corresponding C function */
gcompris_bar_set(values);
- /* Create and return the result */
+ /* Create and return the result */
Py_INCREF(Py_None);
return Py_None;
}
@@ -127,7 +130,7 @@ py_gcompris_bar_hide(PyObject* self, PyObject* args)
/* Call the corresponding C function */
gcompris_bar_hide(values);
- /* Create and return the result */
+ /* Create and return the result */
Py_INCREF(Py_None);
return Py_None;
}
@@ -150,7 +153,7 @@ py_gcompris_board_has_help(PyObject* self, PyObject* args)
/* Call the corresponding C function */
result = gcompris_board_has_help(cGcomprisBoard);
- /* Create and return the result */
+ /* Create and return the result */
if(result){
Py_INCREF(Py_True);
return Py_True;
@@ -177,7 +180,7 @@ py_gcompris_help_start(PyObject* self, PyObject* args)
/* Call the corresponding C function */
gcompris_help_start(cGcomprisBoard);
- /* Create and return the result */
+ /* Create and return the result */
Py_INCREF(Py_None);
return Py_None;
}
@@ -194,7 +197,7 @@ py_gcompris_help_stop(PyObject* self, PyObject* args)
/* Call the corresponding C function */
gcompris_help_stop();
- /* Create and return the result */
+ /* Create and return the result */
Py_INCREF(Py_None);
return Py_None;
}
@@ -202,7 +205,7 @@ py_gcompris_help_stop(PyObject* self, PyObject* args)
/* GnomeCanvas *gcompris_get_canvas(void); */
static PyObject*
py_gcompris_get_canvas(PyObject* self, PyObject* args)
-{
+{
GnomeCanvas* result;
/* Parse arguments */
if(!PyArg_ParseTuple(args, ":gcompris_get_canvas"))
@@ -211,7 +214,7 @@ py_gcompris_get_canvas(PyObject* self, PyObject* args)
/* Call the corresponding C function */
result = gcompris_get_canvas();
- /* Create and return the result */
+ /* Create and return the result */
return (PyObject*) pygobject_new((GObject*) result);
}
@@ -219,7 +222,7 @@ py_gcompris_get_canvas(PyObject* self, PyObject* args)
/* GtkWidget *gcompris_get_window(void); */
static PyObject*
py_gcompris_get_window(PyObject* self, PyObject* args)
-{
+{
GtkWidget* result;
/* Parse arguments */
if(!PyArg_ParseTuple(args, ":gcompris_get_window"))
@@ -228,7 +231,7 @@ py_gcompris_get_window(PyObject* self, PyObject* args)
/* Call the corresponding C function */
result = gcompris_get_window();
- /* Create and return the result */
+ /* Create and return the result */
return (PyObject*)pygobject_new((GObject*)result);
}
@@ -236,7 +239,7 @@ py_gcompris_get_window(PyObject* self, PyObject* args)
/* gchar *gcompris_get_locale(void); */
static PyObject*
py_gcompris_get_locale(PyObject* self, PyObject* args)
-{
+{
gchar* result;
/* Parse arguments */
if(!PyArg_ParseTuple(args, ":gcompris_get_locale"))
@@ -245,7 +248,7 @@ py_gcompris_get_locale(PyObject* self, PyObject* args)
/* Call the corresponding C function */
result = gcompris_get_locale();
- /* Create and return the result */
+ /* Create and return the result */
return Py_BuildValue("s", result);
}
@@ -253,7 +256,7 @@ py_gcompris_get_locale(PyObject* self, PyObject* args)
/* void gcompris_set_locale(gchar *locale); */
static PyObject*
py_gcompris_set_locale(PyObject* self, PyObject* args)
-{
+{
gchar* locale;
/* Parse arguments */
if(!PyArg_ParseTuple(args, "s:gcompris_set_locale", &locale))
@@ -262,7 +265,7 @@ py_gcompris_set_locale(PyObject* self, PyObject* args)
/* Call the corresponding C function */
gcompris_set_locale(locale);
- /* Create and return the result */
+ /* Create and return the result */
Py_INCREF(Py_None);
return Py_None;
}
@@ -280,7 +283,7 @@ py_gcompris_set_cursor(PyObject* self, PyObject* args)
/* Call the corresponding C function */
gcompris_set_cursor(cursor);
- /* Create and return the result */
+ /* Create and return the result */
Py_INCREF(Py_None);
return Py_None;
}
@@ -293,7 +296,7 @@ void pyImageSelectorCallBack(gchar* image){
PyObject* args;
PyObject* result;
if(pyImageSelectorCallBackFunc==NULL) return;
-
+
/* Build arguments */
args = PyTuple_New(1);
PyTuple_SetItem(args, 0, Py_BuildValue("s", image));
@@ -311,29 +314,29 @@ void pyImageSelectorCallBack(gchar* image){
/* ImageSelectorCallBack imscb); */
static PyObject*
py_gcompris_images_selector_start(PyObject* self, PyObject* args)
-{
+{
PyObject* pyGcomprisBoard;
GcomprisBoard* cGcomprisBoard;
PyObject* pyCallback;
gchar* dataset;
/* Parse arguments */
- if(!PyArg_ParseTuple(args,
- "OsO:gcompris_images_selector_start",
+ if(!PyArg_ParseTuple(args,
+ "OsO:gcompris_images_selector_start",
&pyGcomprisBoard,
&dataset,
&pyCallback))
return NULL;
if(!PyCallable_Check(pyCallback)) return NULL;
cGcomprisBoard = ((pyGcomprisBoardObject*) pyGcomprisBoard)->cdata;
-
+
/* Call the corresponding C function */
pyImageSelectorCallBackFunc = pyCallback;
gcompris_images_selector_start(cGcomprisBoard,
dataset,
pyImageSelectorCallBack);
- /* Create and return the result */
+ /* Create and return the result */
Py_INCREF(Py_None);
return Py_None;
}
@@ -342,7 +345,7 @@ py_gcompris_images_selector_start(PyObject* self, PyObject* args)
/* void gcompris_images_selector_stop (void); */
static PyObject*
py_gcompris_images_selector_stop(PyObject* self, PyObject* args)
-{
+{
/* Parse arguments */
if(!PyArg_ParseTuple(args, ":gcompris_images_selector_stop"))
return NULL;
@@ -350,7 +353,7 @@ py_gcompris_images_selector_stop(PyObject* self, PyObject* args)
/* Call the corresponding C function */
gcompris_images_selector_stop();
- /* Create and return the result */
+ /* Create and return the result */
Py_INCREF(Py_None);
return Py_None;
}
@@ -359,7 +362,7 @@ py_gcompris_images_selector_stop(PyObject* self, PyObject* args)
/* void gcompris_exit(); */
static PyObject*
py_gcompris_exit(PyObject* self, PyObject* args)
-{
+{
/* Parse arguments */
if(!PyArg_ParseTuple(args, ":gcompris_exit"))
return NULL;
@@ -367,7 +370,7 @@ py_gcompris_exit(PyObject* self, PyObject* args)
/* Call the corresponding C function */
gcompris_exit();
- /* Create and return the result */
+ /* Create and return the result */
Py_INCREF(Py_None);
return Py_None;
}
@@ -388,25 +391,26 @@ static PyMethodDef PythonGcomprisModule[] = {
{ "get_locale", py_gcompris_get_locale, METH_VARARGS, "gcompris_get_locale" },
{ "set_locale", py_gcompris_set_locale, METH_VARARGS, "gcompris_set_locale" },
{ "set_cursor", py_gcompris_set_cursor, METH_VARARGS, "gcompris_set_cursor" },
- { "images_selector_start", py_gcompris_images_selector_start,
+ { "images_selector_start", py_gcompris_images_selector_start,
METH_VARARGS, "gcompris_images_selector_start" },
- { "images_selector_stop", py_gcompris_images_selector_stop,
+ { "images_selector_stop", py_gcompris_images_selector_stop,
METH_VARARGS, "gcompris_images_selector_stop" },
{ "exit", py_gcompris_exit, METH_VARARGS, "gcompris_exit" },
{ NULL, NULL, 0, NULL}
};
+
void python_gcompris_module_init(void)
{
PyObject* gcomprisModule;
- gcomprisModule = Py_InitModule("gcompris", PythonGcomprisModule);
+ gcomprisModule = Py_InitModule("gcompris", PythonGcomprisModule);
/* Misc constants */
PyModule_AddIntConstant(gcomprisModule, "BOARD_HEIGHT", BOARDHEIGHT );
PyModule_AddIntConstant(gcomprisModule, "BOARD_WIDTH", BOARDWIDTH);
- PyModule_AddIntConstant(gcomprisModule, "BARHEIGHT", BARHEIGHT);
- PyModule_AddIntConstant(gcomprisModule, "DEFAULT_SKIN", DEFAULT_SKIN);
-
+ PyModule_AddIntConstant(gcomprisModule, "BAR_HEIGHT", BARHEIGHT);
+ PyModule_AddStringConstant(gcomprisModule, "DEFAULT_SKIN", DEFAULT_SKIN);
+
/* The GComprisBarFlags enum constants */
PyModule_AddIntConstant(gcomprisModule, "BAR_LEVEL", GCOMPRIS_BAR_LEVEL);
PyModule_AddIntConstant(gcomprisModule, "BAR_OK", GCOMPRIS_BAR_OK);
@@ -453,15 +457,23 @@ void python_gcompris_module_init(void)
PyModule_AddIntConstant(gcomprisModule, "CURSOR_FILL", GCOMPRIS_FILL_CURSOR);
PyModule_AddIntConstant(gcomprisModule, "CURSOR_SELECT", GCOMPRIS_SELECT_CURSOR);
PyModule_AddIntConstant(gcomprisModule, "CURSOR_DEFAULT", GCOMPRIS_DEFAULT_CURSOR);
-
+
/* Some non gcompris.h constants. */
PyModule_AddStringConstant(gcomprisModule, "DATA_DIR", PACKAGE_DATA_DIR);
+
+ /* Initialize the sub modules */
+ python_gcompris_utils_module_init();
+ python_gcompris_sound_module_init();
+ python_gcompris_bonus_module_init();
+ python_gcompris_score_module_init();
+ python_gcompris_timer_module_init();
}
+/* Some usefull code parts ... */
/*
static PyObject*
py_gcompris_(PyObject* self, PyObject* args)
-{
+{
*/ /* Parse arguments */
/* if(!PyArg_ParseTuple(args, ":gcompris_"))
return NULL;
@@ -469,7 +481,7 @@ py_gcompris_(PyObject* self, PyObject* args)
/* Call the corresponding C function */
/* gcompris_();
*/
- /* Create and return the result */
+ /* Create and return the result */
/* Py_INCREF(Py_None);
return Py_None;
}
diff --git a/src/boards/py-mod-score.c b/src/boards/py-mod-score.c
new file mode 100644
index 0000000..01a3740
--- /dev/null
+++ b/src/boards/py-mod-score.c
@@ -0,0 +1,108 @@
+#include <Python.h>
+#include <pygobject.h>
+#include "gcompris/gcompris.h"
+#include "py-mod-utils.h"
+#include "py-gcompris-board.h"
+
+/* All functions provided by this python module
+ * wraps a gcompris function. Each "py_*" function wraps the
+ * "*" C function.
+ */
+
+/* void gcompris_score_start (ScoreStyleList style, guint x, guint y, guint max); */
+static PyObject*
+py_gcompris_score_start(PyObject* self, PyObject* args)
+{
+ int style;
+ int x,y;
+ guint max;
+
+ /* Parse arguments */
+ if(!PyArg_ParseTuple(args, "iiii:gcompris_score_start", &style, &x, &y, &max))
+ return NULL;
+ if(max<0) return NULL;
+
+ /* Call the corresponding C function */
+ gcompris_score_start(style, x, y, max);
+
+ /* Create and return the result */
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+/* void gcompris_score_end(); */
+static PyObject*
+py_gcompris_score_end(PyObject* self, PyObject* args)
+{
+ /* Parse arguments */
+ if(!PyArg_ParseTuple(args, ":gcompris_score_end"))
+ return NULL;
+
+ /* Call the corresponding C function */
+ gcompris_score_end();
+
+ /* Create and return the result */
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+/* void gcompris_score_set(guint value); */
+static PyObject*
+py_gcompris_score_set(PyObject* self, PyObject* args)
+{
+ guint value;
+
+ /* Parse arguments */
+ if(!PyArg_ParseTuple(args, "i:gcompris_score_set", &value))
+ return NULL;
+ if(value<0) return NULL;
+
+ /* Call the corresponding C function */
+ gcompris_score_set(value);
+
+ /* Create and return the result */
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+static PyMethodDef PythonGcomprisScoreModule[] = {
+ { "start", py_gcompris_score_start, METH_VARARGS, "gcompris_score_start" },
+ { "end", py_gcompris_score_end, METH_VARARGS, "gcompris_score_end" },
+ { "set", py_gcompris_score_set, METH_VARARGS, "gcompris_score_set" },
+ { NULL, NULL, 0, NULL}
+};
+
+void python_gcompris_score_module_init(void)
+{
+ PyObject* module;
+ module = Py_InitModule("gcompris.score", PythonGcomprisScoreModule);
+
+ /* Misc constants */
+ PyModule_AddIntConstant(module, "STYLE_NOTE", SCORESTYLE_NOTE );
+ PyModule_AddIntConstant(module, "STYLE_LIFE", SCORESTYLE_LIFE );
+ PyModule_AddIntConstant(module, "LAST", SCORE_LAST );
+}
+
+/* Some usefull code parts ... */
+/*
+static PyObject*
+py_gcompris_(PyObject* self, PyObject* args)
+{
+*/ /* Parse arguments */
+/* if(!PyArg_ParseTuple(args, ":gcompris_"))
+ return NULL;
+*/
+ /* Call the corresponding C function */
+/* gcompris_();
+*/
+ /* Create and return the result */
+/* Py_INCREF(Py_None);
+ return Py_None;
+}
+*/
+/*
+ { "", py_gcompris_, METH_VARARGS, "gcompris_" },
+*/
diff --git a/src/boards/py-mod-score.h b/src/boards/py-mod-score.h
new file mode 100644
index 0000000..95a6295
--- /dev/null
+++ b/src/boards/py-mod-score.h
@@ -0,0 +1,6 @@
+#ifndef _PY_MOD_score_H_
+#define _PY_MOD_score_H_
+
+void python_gcompris_score_module_init(void);
+
+#endif
diff --git a/src/boards/py-mod-sound.c b/src/boards/py-mod-sound.c
new file mode 100644
index 0000000..dfff6a0
--- /dev/null
+++ b/src/boards/py-mod-sound.c
@@ -0,0 +1,115 @@
+#include <Python.h>
+#include <pygobject.h>
+#include <stdarg.h>
+#include "gcompris/gcompris.h"
+#include "py-mod-sound.h"
+#include "py-gcompris-board.h"
+
+/* All functions provided by this python module
+ * wraps a gcompris function. Each "py_*" function wraps the
+ * "*" C function.
+ */
+
+/* void gcompris_play_sound (const char *soundlistfile, const char *which); */
+static PyObject*
+py_gcompris_play_sound(PyObject* self, PyObject* args)
+{
+ gchar* soundlistfile;
+ gchar* which;
+ /* Parse arguments */
+ if(!PyArg_ParseTuple(args, "ss:gcompris_play_sound", &soundlistfile, &which))
+ return NULL;
+
+ /* Call the corresponding C function */
+ gcompris_play_sound(soundlistfile, which);
+
+ /* Create and return the result */
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+/*void gcompris_play_ogg_list( GList* files ); */
+static PyObject*
+py_gcompris_play_ogg_list(PyObject* self, PyObject* args)
+{
+ GList* list;
+ PyObject* pylist;
+ /* Parse arguments */
+ if(!PyArg_ParseTuple(args, "O:gcompris_play_ogg_list", &pylist))
+ return NULL;
+ list = (GList*) pygobject_get(pylist);
+
+ /* Call the corresponding C function */
+ gcompris_play_ogg_list(list);
+
+ /* Create and return the result */
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+
+/* void gcompris_play_ogg(char *, ...);
+ The method: gcompris_play_ogg_list( GList* ) is used
+ to perform the core call. (Because there's no way to construct
+ a variable argument function call.
+*/
+
+static PyObject*
+py_gcompris_play_ogg(PyObject* self, PyObject* args)
+{
+ PyObject* item;
+ GList* list = NULL;
+ int i, length;
+
+ /* Parse arguments */
+ length = PyTuple_Size(args);
+ if(length<1) return NULL;
+ for(i=0; i<length; i++){
+ item = PyTuple_GetItem(args, i);
+ list = g_list_append(list, PyString_AsString(item));
+ }
+
+ /* Call the corresponding C function */
+ gcompris_play_ogg_list(list);
+ g_list_free(list);
+
+ /* Create and return the result */
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyMethodDef PythonGcomprisSoundModule[] = {
+ { "play_sound", py_gcompris_play_sound, METH_VARARGS, "gcompris_play_sound" },
+ { "play_ogg_list", py_gcompris_play_ogg_list, METH_VARARGS, "gcompris_play_ogg_list" },
+ { "play_ogg", py_gcompris_play_ogg, METH_VARARGS, "gcompris_play_ogg" },
+ { NULL, NULL, 0, NULL}
+};
+
+void python_gcompris_sound_module_init(void)
+{
+ PyObject* module;
+ module = Py_InitModule("gcompris.sound", PythonGcomprisSoundModule);
+}
+
+/* Some usefull code parts ... */
+/*
+static PyObject*
+py_gcompris_(PyObject* self, PyObject* args)
+{
+*/ /* Parse arguments */
+/* if(!PyArg_ParseTuple(args, ":gcompris_"))
+ return NULL;
+*/
+ /* Call the corresponding C function */
+/* gcompris_();
+*/
+ /* Create and return the result */
+/* Py_INCREF(Py_None);
+ return Py_None;
+}
+*/
+/*
+ { "", py_gcompris_, METH_VARARGS, "gcompris_" },
+*/
diff --git a/src/boards/py-mod-sound.h b/src/boards/py-mod-sound.h
new file mode 100644
index 0000000..dd5f6f1
--- /dev/null
+++ b/src/boards/py-mod-sound.h
@@ -0,0 +1,6 @@
+#ifndef _PY_MOD_SOUND_H_
+#define _PY_MOD_SOUND_H_
+
+void python_gcompris_sound_module_init(void);
+
+#endif
diff --git a/src/boards/py-mod-timer.c b/src/boards/py-mod-timer.c
new file mode 100644
index 0000000..c51be4a
--- /dev/null
+++ b/src/boards/py-mod-timer.c
@@ -0,0 +1,167 @@
+#include <Python.h>
+#include <pygobject.h>
+#include "gcompris/gcompris.h"
+#include "py-mod-utils.h"
+#include "py-gcompris-board.h"
+
+/* All functions provided by this python module
+ * wraps a gcompris function. Each "py_*" function wraps the
+ * "*" C function.
+ */
+
+/* typedef void (*GcomprisTimerEnd) (); */
+static PyObject* pyTimerCallBackFunc = NULL;
+
+void pyTimerCallBack(){
+ PyObject* result;
+ if(pyTimerCallBackFunc==NULL) return;
+
+ /* Build arguments */
+ result = PyObject_CallObject(pyTimerCallBackFunc, NULL);
+ if(result==NULL){
+ PyErr_Print();
+ } else {
+ Py_DECREF(result);
+ }
+}
+
+
+/* void gcompris_timer_display
+ (int x, int y, TimerList type, int second, GcomprisTimerEnd gcomprisTimerEnd); */
+static PyObject*
+py_gcompris_timer_display(PyObject* self, PyObject* args)
+{
+ int x,y;
+ int type;
+ int second;
+ PyObject* pyCallback;
+
+ /* Parse arguments */
+ if(!PyArg_ParseTuple(args, "iiiiO:gcompris_timer_display", &x, &y, &type, &second, &pyCallback))
+ return NULL;
+ if(!PyCallable_Check(pyCallback)) return NULL;
+ pyTimerCallBackFunc = pyCallback;
+
+ /* Call the corresponding C function */
+ gcompris_timer_display(x, y, type, second, pyTimerCallBack );
+
+ /* Create and return the result */
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+/* void gcompris_timer_add(int second); */
+static PyObject*
+py_gcompris_timer_add(PyObject* self, PyObject* args)
+{
+ int second;
+
+ /* Parse arguments */
+ if(!PyArg_ParseTuple(args, "i:gcompris_timer_add", &second))
+ return NULL;
+
+ /* Call the corresponding C function */
+ gcompris_timer_add(second);
+
+ /* Create and return the result */
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+/*void gcompris_timer_end(void); */
+static PyObject*
+py_gcompris_timer_end(PyObject* self, PyObject* args)
+{
+ /* Parse arguments */
+ if(!PyArg_ParseTuple(args, ":gcompris_timer_end"))
+ return NULL;
+
+ /* Call the corresponding C function */
+ gcompris_timer_end();
+
+ /* Create and return the result */
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+/* guint gcompris_timer_get_remaining(); */
+static PyObject*
+py_gcompris_timer_get_remaining(PyObject* self, PyObject* args)
+{
+ guint result;
+
+ /* Parse arguments */
+ if(!PyArg_ParseTuple(args, ":gcompris_timer_get_remaining"))
+ return NULL;
+
+ /* Call the corresponding C function */
+ result = gcompris_timer_get_remaining();
+
+ /* Create and return the result */
+ return Py_BuildValue("i", result);
+}
+
+
+/* void gcompris_timer_pause(gboolean pause); */
+static PyObject*
+py_gcompris_timer_pause(PyObject* self, PyObject* args)
+{
+ gboolean pause;
+
+ /* Parse arguments */
+ if(!PyArg_ParseTuple(args, "i:gcompris_timer_pause", &pause))
+ return NULL;
+
+ /* Call the corresponding C function */
+ gcompris_timer_pause(pause);
+
+ /* Create and return the result */
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+static PyMethodDef PythonGcomprisTimerModule[] = {
+ { "display", py_gcompris_timer_display, METH_VARARGS, "gcompris_timer_display" },
+ { "add", py_gcompris_timer_add, METH_VARARGS, "gcompris_timer_add" },
+ { "end", py_gcompris_timer_end, METH_VARARGS, "gcompris_timer_end" },
+ { "get_remaining", py_gcompris_timer_get_remaining, METH_VARARGS, "gcompris_timer_get_remaining" },
+ { "pause", py_gcompris_timer_pause, METH_VARARGS, "gcompris_timer_pause" },
+ { NULL, NULL, 0, NULL}
+};
+
+void python_gcompris_timer_module_init(void)
+{
+ PyObject* module;
+ module = Py_InitModule("gcompris.timer", PythonGcomprisTimerModule);
+
+ /* TimerList constants */
+ PyModule_AddIntConstant(module, "TEXT", GCOMPRIS_TIMER_TEXT );
+ PyModule_AddIntConstant(module, "SAND", GCOMPRIS_TIMER_SAND );
+ PyModule_AddIntConstant(module, "BALLOON", GCOMPRIS_TIMER_BALLOON );
+ PyModule_AddIntConstant(module, "CLOCK", GCOMPRIS_TIMER_CLOCK );
+}
+
+/* Some usefull code parts ... */
+/*
+static PyObject*
+py_gcompris_(PyObject* self, PyObject* args)
+{
+*/ /* Parse arguments */
+/* if(!PyArg_ParseTuple(args, ":gcompris_"))
+ return NULL;
+*/
+ /* Call the corresponding C function */
+/* gcompris_();
+*/
+ /* Create and return the result */
+/* Py_INCREF(Py_None);
+ return Py_None;
+}
+*/
+/*
+ { "", py_gcompris_, METH_VARARGS, "gcompris_" },
+*/
diff --git a/src/boards/py-mod-timer.h b/src/boards/py-mod-timer.h
new file mode 100644
index 0000000..0fb5354
--- /dev/null
+++ b/src/boards/py-mod-timer.h
@@ -0,0 +1,6 @@
+#ifndef _PY_MOD_TIMER_H_
+#define _PY_MOD_TIMER_H_
+
+void python_gcompris_timer_module_init(void);
+
+#endif
diff --git a/src/boards/py-mod-utils.c b/src/boards/py-mod-utils.c
new file mode 100644
index 0000000..a3f24f7
--- /dev/null
+++ b/src/boards/py-mod-utils.c
@@ -0,0 +1,287 @@
+#include <Python.h>
+#include <pygobject.h>
+#include "gcompris/gcompris.h"
+#include "py-mod-utils.h"
+#include "py-gcompris-board.h"
+
+/* All functions provided by this python module
+ * wraps a gcompris function. Each "py_*" function wraps the
+ * "*" C function.
+ */
+
+
+/* GdkPixbuf *gcompris_load_number_pixmap(char number); */
+static PyObject*
+py_gcompris_load_number_pixmap(PyObject* self, PyObject* args)
+{
+ char value;
+ GdkPixbuf* result;
+ /* Parse arguments */
+ if(!PyArg_ParseTuple(args, "b:gcompris_load_number_pixmap", &value))
+ return NULL;
+
+ /* Call the corresponding C function */
+ result = gcompris_load_number_pixmap(value);
+
+ /* Create and return the result */
+ return(PyObject*)pygobject_new((GObject*) result);
+}
+
+
+/* gchar *gcompris_image_to_skin(gchar *imagename); */
+static PyObject*
+py_gcompris_image_to_skin(PyObject* self, PyObject* args)
+{
+ gchar* imagename;
+ gchar* result;
+ /* Parse arguments */
+ if(!PyArg_ParseTuple(args, "s:gcompris_image_to_skin", &imagename))
+ return NULL;
+
+ /* Call the corresponding C function */
+ result = gcompris_image_to_skin(imagename);
+
+ /* Create and return the result */
+ return Py_BuildValue("s", result);
+}
+
+
+/* GdkPixbuf *gcompris_load_skin_pixmap(char *pixmapfile); */
+static PyObject*
+py_gcompris_load_skin_pixmap(PyObject* self, PyObject* args)
+{
+ char* pixmapfile;
+ GdkPixbuf* result;
+ /* Parse arguments */
+ if(!PyArg_ParseTuple(args, "s:gcompris_load_skin_pixmap", pixmapfile))
+ return NULL;
+
+ /* Call the corresponding C function */
+ result = gcompris_load_skin_pixmap(pixmapfile);
+
+ /* Create and return the result */
+ return (PyObject*) pygobject_new((GObject*) result);
+}
+
+
+/* GdkPixbuf *gcompris_load_pixmap(char *pixmapfile); */
+static PyObject*
+py_gcompris_load_pixmap(PyObject* self, PyObject* args)
+{
+ char* pixmapfile;
+ GdkPixbuf* result;
+ /* Parse arguments */
+ if(!PyArg_ParseTuple(args, ":gcompris_load_pixmap"))
+ return NULL;
+
+ /* Call the corresponding C function */
+ result = gcompris_load_pixmap(pixmapfile);
+
+ /* Create and return the result */
+ return (PyObject*) pygobject_new((GObject*) result);
+}
+
+
+/* void gcompris_set_image_focus(GnomeCanvasItem *item, gboolean focus); */
+static PyObject*
+py_gcompris_set_image_focus(PyObject* self, PyObject* args)
+{
+ PyObject* pyitem;
+ GnomeCanvasItem* item;
+ gint pyfocus;
+ gboolean focus;
+
+ /* Parse arguments */
+ if(!PyArg_ParseTuple(args, "Oi:gcompris_set_image_focus"), &pyitem, &pyfocus)
+ return NULL;
+ item = (GnomeCanvasItem*) pygobject_get(pyitem);
+ if(pyfocus>0) focus = TRUE;
+ else focus = FALSE;
+
+ /* Call the corresponding C function */
+ gcompris_set_image_focus(item, focus);
+
+ /* Create and return the result */
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+/* gint gcompris_item_event_focus(GnomeCanvasItem *item,
+ GdkEvent *event,
+ GnomeCanvasItem *dest_item);
+*/
+static PyObject*
+py_gcompris_item_event_focus(PyObject* self, PyObject* args)
+{
+ PyObject* pyitem;
+ GnomeCanvasItem* item;
+ PyObject* pyevent;
+ GdkEvent* event;
+ PyObject* pydest_item;
+ GnomeCanvasItem* dest_item;
+ gint result;
+
+ /* Parse arguments */
+ if(!PyArg_ParseTuple(args, "OOO:gcompris_item_event_focus", &pyitem, &pyevent, &pydest_item))
+ return NULL;
+ item = (GnomeCanvasItem*) pygobject_get(pyitem);
+ event = (GdkEvent*) pygobject_get(pyevent);
+ dest_item = (GnomeCanvasItem*) pygobject_get(pydest_item);
+
+ /* Call the corresponding C function */
+ result = gcompris_item_event_focus(item, event, dest_item);
+
+ /* Create and return the result */
+ return Py_BuildValue("i", result);
+}
+
+
+/* void item_absolute_move(GnomeCanvasItem *item, int x, int y); */
+static PyObject*
+py_gcompris_item_absolute_move(PyObject* self, PyObject* args)
+{
+ PyObject* pyitem;
+ GnomeCanvasItem* item;
+ int x, y;
+
+ /* Parse arguments */
+ if(!PyArg_ParseTuple(args, "Oii:gcompris_item_absolute_move", &pyitem, &x, &y))
+ return NULL;
+ item = (GnomeCanvasItem*) pygobject_get(pyitem);
+
+ /* Call the corresponding C function */
+ item_absolute_move(item, x, y);
+
+ /* Create and return the result */
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+/* void item_rotate(GnomeCanvasItem *item, double angle); */
+static PyObject*
+py_gcompris_item_rotate(PyObject* self, PyObject* args)
+{
+ PyObject* pyitem;
+ GnomeCanvasItem* item;
+ double angle;
+
+ /* Parse arguments */
+ if(!PyArg_ParseTuple(args, "Od:gcompris_item_rotate", &pyitem, &angle))
+ return NULL;
+ item = (GnomeCanvasItem*) pygobject_get(pyitem);
+
+ /* Call the corresponding C function */
+ item_rotate(item, angle);
+
+ /* Create and return the result */
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+/* void item_rotate_with_center(GnomeCanvasItem *item, double angle, int x, int y); */
+static PyObject*
+py_gcompris_item_rotate_with_center(PyObject* self, PyObject* args)
+{
+ PyObject* pyitem;
+ GnomeCanvasItem* item;
+ double angle;
+ int x,y;
+
+ /* Parse arguments */
+ if(!PyArg_ParseTuple(args, "Odii:gcompris_item_rotate_with_center", &pyitem, &angle, &x, &y))
+ return NULL;
+ item = (GnomeCanvasItem*) pygobject_get(pyitem);
+
+ /* Call the corresponding C function */
+ item_rotate_with_center(item, angle, x, y);
+
+ /* Create and return the result */
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+/* Dialog callback wrapper */
+static PyObject* pyDialogBoxCallBackFunc = NULL;
+
+/* typedef void (*DialogBoxCallBack) (); */
+void pyDialogBoxCallBack(){
+ PyObject* result;
+ if(pyDialogBoxCallBackFunc==NULL) return;
+
+ /* Build arguments */
+ result = PyObject_CallObject(pyDialogBoxCallBackFunc, NULL);
+ if(result==NULL){
+ PyErr_Print();
+ } else {
+ Py_DECREF(result);
+ }
+}
+
+
+/* void gcompris_dialog(gchar *str, DialogBoxCallBack dbcb); */
+static PyObject*
+py_gcompris_dialog(PyObject* self, PyObject* args)
+{
+ PyObject* pyCallback;
+ gchar* str;
+
+ /* Parse arguments */
+ if(!PyArg_ParseTuple(args, "sO:gcompris_dialog", &str, &pyCallback))
+ return NULL;
+ if(!PyCallable_Check(pyCallback)) return NULL;
+
+ /* Call the corresponding C function */
+ gcompris_dialog(str, pyDialogBoxCallBack);
+
+ /* Create and return the result */
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+static PyMethodDef PythonGcomprisUtilsModule[] = {
+ { "load_number_pixmap", py_gcompris_load_number_pixmap, METH_VARARGS, "gcompris_load_number_pixmap" },
+ { "image_to_skin", py_gcompris_image_to_skin, METH_VARARGS, "gcompris_image_to_skin" },
+ { "load_skin_pixmap", py_gcompris_load_skin_pixmap, METH_VARARGS, "gcompris_load_skin_pixmap" },
+ { "load_pixmap", py_gcompris_load_pixmap, METH_VARARGS, "gcompris_load_pixmap" },
+ { "set_image_focus", py_gcompris_set_image_focus, METH_VARARGS, "gcompris_set_image_focus" },
+ { "item_event_focus", py_gcompris_item_event_focus, METH_VARARGS, "gcompris_item_event_focus" },
+ { "item_absolute_move", py_gcompris_item_absolute_move, METH_VARARGS, "item_absolute_move" },
+ { "item_rotate", py_gcompris_item_rotate, METH_VARARGS, "item_rotate" },
+ { "item_rotate_with_center", py_gcompris_item_rotate_with_center, METH_VARARGS,
+ "item_rotate_with_center" },
+ { "dialog", py_gcompris_dialog, METH_VARARGS, "gcompris_dialog" },
+ { NULL, NULL, 0, NULL}
+};
+
+
+void python_gcompris_utils_module_init(void)
+{
+ PyObject* module;
+ module = Py_InitModule("gcompris.utils", PythonGcomprisUtilsModule);
+}
+
+/* Some usefull code parts ... */
+/*
+static PyObject*
+py_gcompris_(PyObject* self, PyObject* args)
+{
+*/ /* Parse arguments */
+/* if(!PyArg_ParseTuple(args, ":gcompris_"))
+ return NULL;
+*/
+ /* Call the corresponding C function */
+/* gcompris_();
+*/
+ /* Create and return the result */
+/* Py_INCREF(Py_None);
+ return Py_None;
+}
+*/
+/*
+ { "", py_gcompris_, METH_VARARGS, "gcompris_" },
+*/
diff --git a/src/boards/py-mod-utils.h b/src/boards/py-mod-utils.h
new file mode 100644
index 0000000..a0d875a
--- /dev/null
+++ b/src/boards/py-mod-utils.h
@@ -0,0 +1,6 @@
+#ifndef _PY_MOD_UTILS_H_
+#define _PY_MOD_UTILS_H_
+
+void python_gcompris_utils_module_init(void);
+
+#endif
diff --git a/src/gcompris/Makefile.am b/src/gcompris/Makefile.am
index ae72018..e26bb15 100644
--- a/src/gcompris/Makefile.am
+++ b/src/gcompris/Makefile.am
@@ -1,14 +1,13 @@
## Process this file with automake to produce Makefile.in
if PYTHON_PLUGIN
- python_ldadd = $(PYTHON_LIBS)
- python_ldflags = -u Py_Initialize
+python_ldadd = $(PYTHON_LIBS)
+python_ldflags = -u Py_Initialize
else
- python_ldadd =
- python_ldflags =
+python_ldadd =
+python_ldflags =
endif
-
INCLUDES = \
-I$(top_srcdir)/intl \
-DDATADIR=\""$(datadir)"\" \
diff --git a/src/gcompris/soundutil.c b/src/gcompris/soundutil.c
index e3d7a6d..e47feb5 100644
--- a/src/gcompris/soundutil.c
+++ b/src/gcompris/soundutil.c
@@ -184,15 +184,40 @@ char* get_next_sound_to_play( )
}
/* =====================================================================
* Play a list of OGG sound files. The list must be NULL terminated
+ * This function wraps the var args into a GList and call the
+ * gcompris_play_ogg_list function to process the sounds.
+ ======================================================================*/
+void gcompris_play_ogg(char *sound, ...)
+{
+ va_list ap;
+ char* tmp = NULL;
+ GList* list = NULL;
+
+ list = g_list_append(list, sound);
+
+ va_start( ap, sound);
+ while( (tmp = va_arg (ap, char *)))
+ {
+ list = g_list_append(list, tmp);
+ }
+ va_end(ap);
+
+ gcompris_play_ogg_list( list );
+
+ g_list_free(list);
+}
+
+/* =====================================================================
+ * Play a list of OGG sound files.
* The given ogg files will be first tested as a locale dependant sound file:
* sounds/<current gcompris locale>/<sound>
* If it doesn't exists, then the test is done with a music file:
* music/<sound>
- ======================================================================*/
-void gcompris_play_ogg(char *sound, ...)
+ =====================================================================*/
+void gcompris_play_ogg_list( GList* files )
{
+ GList* list;
int err;
- va_list ap;
char* tmp = NULL;
char* tmpSound = NULL;
@@ -223,20 +248,16 @@ void gcompris_play_ogg(char *sound, ...)
pthread_mutex_lock( &lock );
- if (g_list_length(pending_queue) < MAX_QUEUE_LENGTH)
- pending_queue = g_list_append(pending_queue, g_strdup( sound ) );
-
- va_start( ap, sound);
- while( (tmp = va_arg (ap, char *)))
+ list = g_list_first( files );
+ while( list!=NULL )
{
if (g_list_length(pending_queue) < MAX_QUEUE_LENGTH)
{
- pending_queue = g_list_append(pending_queue, g_strdup( tmp ));
+ pending_queue = g_list_append(pending_queue, g_strdup( (gchar*)(list->data) ));
}
+ list = g_list_next(list);
}
-
- va_end(ap);
-
+
err = pthread_mutex_unlock ( &lock);
if (err)
printf ("mutex_unlock: %s\n", strerror (err));
diff --git a/src/gcompris/soundutil.h b/src/gcompris/soundutil.h
index 85b7bac..26c1b38 100644
--- a/src/gcompris/soundutil.h
+++ b/src/gcompris/soundutil.h
@@ -41,6 +41,7 @@ typedef struct {
void gcompris_play_sound (const char *soundlistfile, const char *which);
void gcompris_play_ogg(char *, ...);
+void gcompris_play_ogg_list( GList* files );
void setSoundPolicy(int);
int getSoundPolicy(void);
void initSound(void);