python.html 31.6 KB
Newer Older
1
<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.75.2"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="article" title="Python wrapper for Gcompris"><div class="titlepage"><div><div><h2 class="title"><a name="id3048170"></a>Python wrapper for Gcompris</h2></div><div><div class="author"><h3 class="author"><span class="honorific">Ir</span>. <span class="firstname">Olivier</span> <span class="surname">Samyn</span></h3><code class="email">&lt;<a class="email" href="mailto:osamyn@ulb.ac.be">osamyn@ulb.ac.be</a>&gt;</code></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.7</td><td align="left">July 2010</td></tr><tr><td align="left" colspan="2">Updated documentation of the sound API.</td></tr></table></div></div></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="#id3049080">Notes about this wrapper</a></span></dt><dt><span class="sect1"><a href="#id3049113">Python board structure</a></span></dt><dt><span class="sect1"><a href="#id3047951">GcomprisBoard structure mapping </a></span></dt><dt><span class="sect1"><a href="#id3047602">gcompris.h functions and constants Mapping</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id3047607">Functions mapping</a></span></dt><dt><span class="sect2"><a href="#id3048566">GComprisBarFlags enum mapping</a></span></dt><dt><span class="sect2"><a href="#id3048649">Misc constants mapping</a></span></dt><dt><span class="sect2"><a href="#id3099202">Colors constants mapping</a></span></dt><dt><span class="sect2"><a href="#id3099261">Fonts constants mapping</a></span></dt><dt><span class="sect2"><a href="#id3099335">Board font constants mapping</a></span></dt><dt><span class="sect2"><a href="#id3099436">Cursor constants mapping</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id3099536">gameutil.h functions and constants Mapping</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id3099542">Functions mapping</a></span></dt><dt><span class="sect2"><a href="#id3099751">Constants mapping</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id3099763">bonus.h functions and constants Mapping</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id3099769">Functions mapping</a></span></dt><dt><span class="sect2"><a href="#id3099830">Constants mapping (BonusStatusList)</a></span></dt><dt><span class="sect2"><a href="#id3099884">Constants mapping (BonusList)</a></span></dt><dt><span class="sect2"><a href="#id3099969">Constants mapping (BoardFinishedList)</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id3100035">score.h functions and constants Mapping</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id3100041">Functions mapping</a></span></dt><dt><span class="sect2"><a href="#id3100113">Constants mapping</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id3100160">soundutil.h functions and constants Mapping</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id3100166">Functions mapping</a></span></dt><dt><span class="sect2"><a href="#id3100393">Constants mapping</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id3100452">timer.h functions and constants Mapping</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id3100458">Functions mapping</a></span></dt><dt><span class="sect2"><a href="#id3100559">Constants mapping</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id3100621">anim.h structures Mapping</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id3100632">Animation</a></span></dt><dt><span class="sect2"><a href="#id3100648">CanvasItem</a></span></dt></dl></dd></dl></div><div class="sect1" title="Notes about this wrapper"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id3049080"></a>Notes about this wrapper</h2></div></div></div><p>Generaly speaking, all C gc_xxx functions are wrapped to a
2 3 4 5 6
corresponding gcompris.xxx function; parameters and return types remains the same.
Some structures have also been wrapped. See below particular notes about this.</p><p>The wrapped functions are divided into packages. Every package correponds to a
gcompris header file (gameutil.h, score.h, ...)</p><p>For each package/header not all functions have been wrapped.
Only functions that are used/usefull for plugins are wrapped.</p><p>Notice also that not all functions have been tested (with time and new python
plugins implemented they will be, but...). The wrappers have been written, they compiles,
7
but there is no warranty on their behaviour... I you find a bug report it!</p></div><div class="sect1" title="Python board structure"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id3049113"></a>Python board structure</h2></div></div></div><p>Each board written in python must contains a class which name is
8 9 10
"Gcompris_xxx" where xxx is the name of the board. Let's take an example: I made
a gcompris board written in python and called "pythontest".</p><p>For this board there is a gcompris pythontest.xml file containing
"pythontest" for the board name and "pythonboard" for the board type. There's
11
also a pythontest.py file containing the board code. And to finish, this file
12
contains a "Gcompris_pythontest" class definition which in turns contains the
13
needed gcompris board functions.</p><p>The class defined in the python board must contains the following methods:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">__init__(self, gcomprisBoard)</li><li class="listitem">start(self)</li><li class="listitem">end(self)</li><li class="listitem">ok(self)</li><li class="listitem">repeat(self)</li><li class="listitem">config(self)</li><li class="listitem">key_press(self, keyval)</li><li class="listitem">pause(self, pause)</li><li class="listitem">set_level(self, level)</li></ul></div><p>
14
</p><p>For the method role and use, please consult the sample pythontest.py board
15
and other C boards.</p></div><div class="sect1" title="GcomprisBoard structure mapping"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id3047951"></a>GcomprisBoard structure mapping </h2></div></div></div><p>An instance of this structure in Python will act like an instance of the C
16
one. Here a some Python call samples:</p><pre class="programlisting">
17 18 19 20 21 22
...
  gcomprisBoard.level = 1
  gcomprisBoard.maxlevel = 1
...
  gcompris.bar_start(gcomprisBoard.canvas)
...
23
</pre><p>Here are the Python structure member name and type, and a note indicating if the
24
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" title="gcompris.h functions and constants Mapping"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id3047602"></a>gcompris.h functions and constants Mapping</h2></div></div></div><div class="sect2" title="Functions mapping"><div class="titlepage"><div><div><h3 class="title"><a name="id3047607"></a>Functions mapping</h3></div></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 gc_board_end(void)</td><td></td></tr><tr><td>gcompris.bar_start(gnomeCanvas)</td><td>void gc_bar_start(GnomeCanvas *theCanvas)</td><td></td></tr><tr><td>gcompris.set_background(gnomeCanvasGroup, file)</td><td>GnomeCanvasItem *gc_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 gc_bar_set_level(GcomprisBoard *gcomprisBoard)</td><td></td></tr><tr><td>gcompris.bar_set_repeat_icon(pixmap)</td><td>void gc_bar_set_repeat_icon(GdkPixbuf *pixmap)</td><td></td></tr><tr><td>gcompris.bar_set(flags)</td><td>void gc_bar_set(const GComprisBarFlags flags)</td><td></td></tr><tr><td>gcompris.bar_hide(hide)</td><td>void gc_bar_hide(gboolean hide)</td><td></td></tr><tr><td>gcompris.get_canvas()</td><td>GnomeCanvas* gc_get_canvas()</td><td>return a gnome.canvas.Canvas</td></tr><tr><td>gcompris.get_window()</td><td>GtkWidget* gc_get_window(void)</td><td>return a gtk.Widget</td></tr><tr><td>gcompris.get_locale()</td><td>gchar* gc_locale_get(void)</td><td>return a string</td></tr><tr><td>gcompris.set_locale(locale)</td><td>void gc_locale_set(gchar *locale)</td><td></td></tr><tr><td>gcompris.set_cursor(cursor_type)</td><td>void gc_cursor_set(guint gdk_cursor_type)</td><td></td></tr><tr><td>gcompris.images_selector_start(gcomprisBoard, dataset, callback)</td><td>void gc_selector_images_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 gc_selector_images_stop(void)</td><td></td></tr><tr><td>gcompris.exit()</td><td>void gc_exit(void)</td><td></td></tr><tr><td>gcompris.log_set_reason (gcomprisBoard, expected, got)</td><td>gc_log_set_reason (GcomprisBoard *gcomprisBoard, gchar *expected, gchar *got)</td><td></td></tr><tr><td>gcompris.log_end (gcomprisBoard, status)</td><td>gc_log_end (GcomprisBoard *gcomprisBoard, gchar *status)</td><td></td></tr><tr><td>gcompris.file_selector_load(gcomprisBoard, rootdir, file_types, callback)</td><td>void gc_selector_file_load (GcomprisBoard *gcomprisBoard, gchar *rootdir, gchar *file_types, FileSelectorCallBack fscb)</td><td>The callback must be a callable object</td></tr><tr><td>gcompris.file_selector_save(gcomprisBoard, rootdir, file_types, callback)</td><td>void gc_selector_file_save(GcomprisBoard *gcomprisBoard, gchar *rootdir,gchar *file_types, FileSelectorCallBack fscb)</td><td>The callback must be a callable object</td></tr><tr><td>gcompris.file_selector_stop()</td><td>void gc_selector_file_stop(void)</td><td></td></tr><tr><td>gcompris.get_database()</td><td>gchar* gc_db_get_filename(void)</td><td>return the filename (string) of the database (fullpath)</td></tr><tr><td>gcompris.get_wordlist()</td><td>GcomprisWordlist* gc_wordlist_get_from_file(const gchar *fileformat, ...)</td><td>Return a WordList object loaded from the given file. It can be loaded with "wordsgame/default-$LOCALE.xml"</td></tr><tr><td>gcompris.get_random_word(wordlist, level)</td><td>gchar* gc_wordlist_random_word_get(GcomprisWordlist *wordlist, guint level)</td><td>Return a random word from the previously loaded wordlist object and the specified level.</td></tr></tbody></table></div></div><div class="sect2" title="GComprisBarFlags enum mapping"><div class="titlepage"><div><div><h3 class="title"><a name="id3048566"></a>GComprisBarFlags enum mapping</h3></div></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_REPEAT</td><td>GCOMPRIS_BAR_REPEAT</td></tr><tr><td>gcompris.BAR_REPEAT_ICON</td><td>GCOMPRIS_BAR_REPEAT_ICON</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" title="Misc constants mapping"><div class="titlepage"><div><div><h3 class="title"><a name="id3048649"></a>Misc constants mapping</h3></div></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" title="Colors constants mapping"><div class="titlepage"><div><div><h3 class="title"><a name="id3099202"></a>Colors constants mapping</h3></div></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" title="Fonts constants mapping"><div class="titlepage"><div><div><h3 class="title"><a name="id3099261"></a>Fonts constants mapping</h3></div></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" title="Board font constants mapping"><div class="titlepage"><div><div><h3 class="title"><a name="id3099335"></a>Board font constants mapping</h3></div></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" title="Cursor constants mapping"><div class="titlepage"><div><div><h3 class="title"><a name="id3099436"></a>Cursor constants mapping</h3></div></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_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 class="sect1" title="gameutil.h functions and constants Mapping"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id3099536"></a>gameutil.h functions and constants Mapping</h2></div></div></div><div class="sect2" title="Functions mapping"><div class="titlepage"><div><div><h3 class="title"><a name="id3099542"></a>Functions mapping</h3></div></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.utils.image_to_skin(imagename)</td><td>gchar *gc_skin_image_get(gchar *imagename)</td><td>return a string</td></tr><tr><td>gcompris.skin.load_pixmap(pixmapfile)</td><td>GdkPixbuf *gc_skin_pixmap_load(char *pixmapfile)</td><td>return a gtk.gdk.Pixbuf</td></tr><tr><td>gcompris.utils.load_pixmap(pixmapfile)</td><td>GdkPixbuf *gc_pixmap_load(char *pixmapfile)</td><td>return a gtk.gdk.Pixbuf</td></tr><tr><td>gcompris.utils.find_file_absolute(file)</td><td>char *gc_file_find_absolute(char *file)</td><td>return a string</td></tr><tr><td>gcompris.utils.set_image_focus(item, focus)</td><td>void gc_item_focus_set(GnomeCanvasItem *item, gboolean focus)</td><td></td></tr><tr><td>gcompris.utils.item_event_focus(item, event, dest_item)</td><td>gint gc_item_focus_event(GnomeCanvasItem *item, GdkEvent *event, GnomeCanvasItem *dest_item)</td><td>return an integer</td></tr><tr><td>gcompris.utils.item_absolute_move(item, x, y)</td><td>void gc_item_absolute_move(GnomeCanvasItem *item, int x, int y)</td><td></td></tr><tr><td>gcompris.utils.item_rotate(item, angle)</td><td>void gc_item_rotate(GnomeCanvasItem *item, double angle)</td><td></td></tr><tr><td>gcompris.utils.item_rotate_relative(item, angle)</td><td>void gc_item_rotate_relative(GnomeCanvasItem *item, double angle)</td><td></td></tr><tr><td>gcompris.utils.item_rotate_with_center(item, angle, x, y)</td><td>void gc_item_rotate_with_center(GnomeCanvasItem *item, double angle, int x, int y)</td><td></td></tr><tr><td>gcompris.utils.item_rotate_relative_with_center(item, angle, x, y)</td><td>void gc_item_rotate_relative_with_center(GnomeCanvasItem *item, double angle, int x, int y)</td><td></td></tr><tr><td>gcompris.utils.dialog(str, callback)</td><td>void gc_dialog(gchar *str, DialogBoxCallBack callback)</td><td>The callback must be a callable object</td></tr><tr><td>gcompris.utils.dialog_close()</td><td>void gc_dialog_close()</td><td></td></tr></tbody></table></div></div><div class="sect2" title="Constants mapping"><div class="titlepage"><div><div><h3 class="title"><a name="id3099751"></a>Constants mapping</h3></div></div></div><p>
25
          There is no constants in this package.
26
        </p></div></div><div class="sect1" title="bonus.h functions and constants Mapping"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id3099763"></a>bonus.h functions and constants Mapping</h2></div></div></div><div class="sect2" title="Functions mapping"><div class="titlepage"><div><div><h3 class="title"><a name="id3099769"></a>Functions mapping</h3></div></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.bonus.display(BonusStatusList, BonusList)</td><td>void gc_bonus_display(BonusStatusList, BonusList)</td><td></td></tr><tr><td>gcompris.bonus.board_finished(BoardFinishedList)</td><td>void gc_bonus_end_display(BoardFinishedList)</td><td></td></tr></tbody></table></div></div><div class="sect2" title="Constants mapping (BonusStatusList)"><div class="titlepage"><div><div><h3 class="title"><a name="id3099830"></a>Constants mapping (BonusStatusList)</h3></div></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.bonus.LOOSE</td><td>BOARD_LOOSE</td></tr><tr><td>gcompris.bonus.WIN</td><td>BOARD_WIN</td></tr><tr><td>gcompris.bonus.DRAW</td><td>BOARD_DRAW</td></tr></tbody></table></div></div><div class="sect2" title="Constants mapping (BonusList)"><div class="titlepage"><div><div><h3 class="title"><a name="id3099884"></a>Constants mapping (BonusList)</h3></div></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.bonus.TIME_CLICK_TO</td><td>TIME_CLICK_TO_BONUS</td></tr><tr><td>gcompris.bonus.RANDOM</td><td>BONUS_RANDOM</td></tr><tr><td>gcompris.bonus.SMILEY</td><td>BONUS_SMILEY</td></tr><tr><td>gcompris.bonus.FLOWER</td><td>BONUS_FLOWER</td></tr><tr><td>gcompris.bonus.TUX</td><td>BONUS_TUX</td></tr><tr><td>gcompris.bonus.GNU</td><td>BONUS_TUX</td></tr><tr><td>gcompris.bonus.LION</td><td>BONUS_LION</td></tr></tbody></table></div></div><div class="sect2" title="Constants mapping (BoardFinishedList)"><div class="titlepage"><div><div><h3 class="title"><a name="id3099969"></a>Constants mapping (BoardFinishedList)</h3></div></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.bonus.FINISHED_RANDOM</td><td>BOARD_FINISHED_RANDOM</td></tr><tr><td>gcompris.bonus.FINISHED_TUXPLANE</td><td>BOARD_FINISHED_TUXPLANE</td></tr><tr><td>gcompris.bonus.FINISHED_TUXLOCO</td><td>BOARD_FINISHED_TUXLOCO</td></tr><tr><td>gcompris.bonus.FINISHED_TOOMANYERRORS</td><td>BOARD_FINISHED_TOOMANYERRORS</td></tr></tbody></table></div></div></div><div class="sect1" title="score.h functions and constants Mapping"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id3100035"></a>score.h functions and constants Mapping</h2></div></div></div><div class="sect2" title="Functions mapping"><div class="titlepage"><div><div><h3 class="title"><a name="id3100041"></a>Functions mapping</h3></div></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.score.start(style, x, y, max)</td><td>void gc_score_start(ScoreStyleList style, guint x, guint y, guint max)</td><td></td></tr><tr><td>gcompris.score.end()</td><td>void gc_score_end()</td><td></td></tr><tr><td>gcompris.score.set(value)</td><td>void gc_score_set(guint value)</td><td></td></tr></tbody></table></div></div><div class="sect2" title="Constants mapping"><div class="titlepage"><div><div><h3 class="title"><a name="id3100113"></a>Constants mapping</h3></div></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.score.STYLE_NOTE</td><td>SCORESTYLE_NOTE</td></tr><tr><td>gcompris.score.STYLE_LIFE</td><td>SCORESTYLE_LIFE</td></tr></tbody></table></div></div></div><div class="sect1" title="soundutil.h functions and constants Mapping"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id3100160"></a>soundutil.h functions and constants Mapping</h2></div></div></div><div class="sect2" title="Functions mapping"><div class="titlepage"><div><div><h3 class="title"><a name="id3100166"></a>Functions mapping</h3></div></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.sound.play_ogg_list(list)</td><td>void gc_sound_play_ogg_list( GList* files )</td><td>The list argument is a python list
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
		       <pre class="programlisting">
import gcompris.sound

sounds=["sounds/Harbor1.wav", "sounds/Harbor3.ogg"]
gcompris.sound.play_ogg(sounds)
		       </pre>
		</td></tr><tr><td>gcompris.sound.play_ogg(file1, ...)</td><td>void gc_sound_play_ogg(char *, ...)</td><td>Play all the given files.
		       <pre class="programlisting">
import gcompris.sound

gcompris.sound.play_ogg("sounds/Harbor1.wav", "sounds/Harbor3.ogg")
		       </pre>
		</td></tr><tr><td>gcompris.sound.play_ogg_cb(list, callback)</td><td>void gc_sound_play_ogg_cb((const gchar *file, GcomprisSoundCallback cb)</td><td>The list argument is a python string and a function callback. It will be called once the sound has been played.
		       <pre class="programlisting">
import gcompris.sound

gcompris.sound.play_ogg_cb("melody/into.ogg", self.intro_cb)

def intro_cb(self, file):
  print "intro passed. go play"
  self.pause(False)
		       </pre>
		</td></tr><tr><td>gcompris.sound.policy_get()</td><td>int gc_sound_policy_get()</td><td>Returns the current sound policy.
		       <pre class="programlisting">
import gcompris.sound

self.saved_policy = gcompris.sound.policy_get()
		       </pre>
		</td></tr><tr><td>gcompris.sound.policy_set(policy)</td><td>void gc_sound_policy_set(int)</td><td>Set the sound policy.
		       <pre class="programlisting">
import gcompris.sound

gcompris.sound.policy_set(gcompris.sound.PLAY_AND_INTERRUPT)
		       </pre>
		</td></tr><tr><td>gcompris.sound.pause()</td><td>void gc_sound_bg_pause()</td><td>Pause the background music.
		       <pre class="programlisting">
import gcompris.sound

gcompris.sound.pause()
		       </pre>
		</td></tr><tr><td>gcompris.sound.resume()</td><td>void gc_sound_bg_resume()</td><td>Resume the background music.
		       <pre class="programlisting">
import gcompris.sound

gcompris.sound.resume()
		       </pre>
		</td></tr><tr><td>gcompris.sound.close()</td><td>void gc_sound_close()</td><td>Close the audio channel. This is usefull to start an external programm which may then access the audio device on the system.
		       <pre class="programlisting">
import gcompris.sound

gcompris.sound.close()
		       </pre>
		</td></tr><tr><td>gcompris.sound.reopen()</td><td>void gc_sound_reopen()</td><td>Reopen the audio channel to be used by GCompris.
		       <pre class="programlisting">
import gcompris.sound

gcompris.sound.reopen()
		       </pre>
85
		</td></tr></tbody></table></div></div><div class="sect2" title="Constants mapping"><div class="titlepage"><div><div><h3 class="title"><a name="id3100393"></a>Constants mapping</h3></div></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.sound.PLAY_ONLY_IF_IDLE</td><td>PLAY_ONLY_IF_IDLE (Discard play request if busy)</td></tr><tr><td>gcompris.sound.PLAY_AFTER_CURRENT</td><td>PLAY_AFTER_CURRENT Default value, queue mode()</td></tr><tr><td>gcompris.sound.PLAY_AND_INTERRUPT</td><td>PLAY_AND_INTERRUPT (Interrupt current play with the new one)</td></tr></tbody></table></div></div></div><div class="sect1" title="timer.h functions and constants Mapping"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id3100452"></a>timer.h functions and constants Mapping</h2></div></div></div><div class="sect2" title="Functions mapping"><div class="titlepage"><div><div><h3 class="title"><a name="id3100458"></a>Functions mapping</h3></div></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.timer.display(x, y, type, second, callback)</td><td>void gcompris_timer_display (int x, int y, TimerList type, int second, GcomprisTimerEnd gcomprisTimerEnd);</td><td>The callback must be a callable object</td></tr><tr><td>gcompris.timer.add(second)</td><td>void gc_timer_add(int second)</td><td></td></tr><tr><td>gcompris.timer.end()</td><td>void gc_timer_end(void)</td><td></td></tr><tr><td>gcompris.timer.get_remaining()</td><td>guint gc_timer_get_remaining()</td><td>Return an integer</td></tr><tr><td>gcompris.timer.pause(pause)</td><td>void gc_timer_pause(gboolean pause)</td><td></td></tr></tbody></table></div></div><div class="sect2" title="Constants mapping"><div class="titlepage"><div><div><h3 class="title"><a name="id3100559"></a>Constants mapping</h3></div></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.timer.TEXT</td><td>GCOMPRIS_TIMER_TEXT</td></tr><tr><td>gcompris.timer.SAND</td><td>GCOMPRIS_TIMER_SAND</td></tr><tr><td>gcompris.timer.BALLOON</td><td>GCOMPRIS_TIMER_BALLOON</td></tr><tr><td>gcompris.timer.CLOCK</td><td>GCOMPRIS_TIMER_CLOCK</td></tr></tbody></table></div></div></div><div class="sect1" title="anim.h structures Mapping"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id3100621"></a>anim.h structures Mapping</h2></div></div></div><p>The gcompris.anim module supplies two objects, Animation and CanvasItems, corresponding to GcomprisAnimation and GcomprisAnimCanvasItem respectively.</p><div class="sect2" title="Animation"><div class="titlepage"><div><div><h3 class="title"><a name="id3100632"></a>Animation</h3></div></div></div><p>The Animation object represents a set of animation files loaded into memory; it has no methods or members, only a constructor and a destructor. The constructor takes a single argument, the name of a text file containing a space-separated list of animation files. Each animation file in the text file corresponds to an animation state; the animations states are numbered from 0 to n-1.</p></div><div class="sect2" title="CanvasItem"><div class="titlepage"><div><div><h3 class="title"><a name="id3100648"></a>CanvasItem</h3></div></div></div><p>The CanvasItem object is a bit more interesting than the Animation object. It represents an active instance of an animation file. Its constructor takes two arguments, an Animation and a GnomeCanvasGroup (the parent of the desired active animation).</p><div class="sect3" title="Members"><div class="titlepage"><div><div><h4 class="title"><a name="id3100661"></a>Members</h4></div></div></div><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>gnome_canvas</td><td>gnome.canvas.CanvasPixbuf</td><td>Y</td><td>N</td></tr><tr><td>num_states</td><td>int</td><td>Y</td><td>N</td></tr></tbody></table></div></div><div class="sect3" title="Functions"><div class="titlepage"><div><div><h4 class="title"><a name="id3100730"></a>Functions</h4></div></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.anim.CanvasItem.setState(int)</td><td>gc_anim_set_state(GcomprisAnimCanvasItem*, int)</td><td></td></tr></tbody></table></div></div></div></div></div></body></html>