| Revision History | |
|---|---|
| Revision 0.1 | February 2003 |
| Revision 0.2 | April 2003 |
| Revision 0.3 | January 2004 |
Table of Contents
Generaly speaking, all C gcompris_xxx functions are wrapped to a corresponding gcompris.xxx function; parameters and return types remains the same. Some structures have also been wrapped. See below particular notes about this.
The wrapped functions are divided into packages. Every package correponds to a gcompris header file (gameutil.h, score.h, ...)
For each package/header not all functions have been wrapped. Only functions that are used/usefull for plugins are wrapped.
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, but there is no warranty on their behaviour... I you find a bug report it!
Each board written in python must contains a class which name is "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".
For this board there is a gcompris pythontest.xml file containing "pythontest" for the board name and "pythonboard" for the board type. There's also a pythontest.py file containing the board code. And to finish, this file contains a "Gcompris_pythontest" class definition which in turns contains the needed gcompris board functions.
The class defined in the python board must contains the following methods:
For the method role and use, please consult the sample pythontest.py board and other C boards.
An instance of this structure in Python will act like an instance of the C one. Here a some Python call samples:
... gcomprisBoard.level = 1 gcomprisBoard.maxlevel = 1 ... gcompris.bar_start(gcomprisBoard.canvas) ...
Here are the Python structure member name and type, and a note indicating if the attribute is readeable and/or writable.
| Structure member | Type | Readable | Writable |
|---|---|---|---|
| type | string | Y | N |
| board_ready | boolean | Y | N |
| mode | string | Y | N |
| name | string | Y | N |
| title | string | Y | N |
| description | string | Y | N |
| icon_name | string | Y | N |
| author | string | Y | N |
| boarddir | string | Y | N |
| filename | string | Y | N |
| difficulty | string | Y | N |
| mandatory_sound_file | string | Y | N |
| section | string | Y | N |
| menuposotion | string | Y | N |
| prerequisite | string | Y | N |
| goal | string | Y | N |
| manual | string | Y | N |
| credit | string | Y | N |
| width | int | Y | N |
| height | int | Y | N |
| canvas | gnome.canvas.Canvas | Y | N |
| previous_board | GcomprisBoard | Y | N |
| level | int | Y | Y |
| maxlevel | int | Y | Y |
| sublevel | int | Y | Y |
| number_of_sublevel | int | Y | Y |
| Python function | C equivalent | Notes |
|---|---|---|
| gcompris.end_board() | void gcompris_end_board(void) | |
| gcompris.bar_start(gnomeCanvas) | void gcompris_bar_start(GnomeCanvas *theCanvas) | |
| gcompris.set_background(gnomeCanvasGroup, file) | GnomeCanvasItem *gcompris_set_background(GnomeCanvasGroup *parent, gchar *file) | return a gnome.canvas.CanvasItem object |
| gcompris.bar_set_level(gcomprisBoard) | void gcompris_bar_set_level(GcomprisBoard *gcomprisBoard) | |
| gcompris.bar_set_repeat_icon(pixmap) | void gcompris_bar_set_repeat_icon(GdkPixbuf *pixmap) | |
| gcompris.bar_set(flags) | void gcompris_bar_set(const GComprisBarFlags flags) | |
| gcompris.bar_hide(hide) | void gcompris_bar_hide(gboolean hide) | |
| gcompris.board_has_help(gcomprisBoard) | gboolean gcompris_board_has_help(GcomprisBoard *gcomprisBoard) | return a boolean |
| gcompris.help_start(gcomprisBoard) | void gcompris_help_start(GcomprisBoard *gcomprisBoard) | |
| gcompris.help_stop() | void gcompris_help_stop(void) | |
| gcompris.get_canvas() | GnomeCanvas* gcompris_get_canvas() | return a gnome.canvas.Canvas |
| gcompris.get_window() | GtkWidget* gcompris_get_window(void) | return a gtk.Widget |
| gcompris.get_locale() | gchar* gcompris_get_locale(void) | return a string |
| gcompris.set_locale(locale) | void gcompris_set_locale(gchar *locale) | |
| gcompris.set_cursor(cursor_type) | void gcompris_set_cursor(guint gdk_cursor_type) | |
| gcompris.images_selector_start(gcomprisBoard, dataset, callback) | void gcompris_images_selector_start (GcomprisBoard *gcomprisBoard, gchar *dataset, ImageSelectorCallBack imscb) | The callback must be a callable object |
| gcompris.images_selector_stop() | void gcompris_images_selector_stop(void) | |
| gcompris.exit() | void gcompris_exit(void) | |
| gcompris.log_set_reason (gcomprisBoard, comment) | gcompris_log_set_reason (GcomprisBoard *gcomprisBoard, gchar *comment) | |
| gcompris.log_end (gcomprisBoard, status) | gcompris_log_end (GcomprisBoard *gcomprisBoard, gchar *status) |
| Python constant | C equivalent |
|---|---|
| gcompris.BAR_LEVEL | GCOMPRIS_BAR_LEVEL |
| gcompris.BAR_OK | GCOMPRIS_BAR_OK |
| gcompris.BAR_REPEAT | GCOMPRIS_BAR_REPEAT |
| gcompris.BAR_CONFIG | GCOMPRIS_BAR_CONFIG |
| gcompris.BAR_ABOUT | GCOMPRIS_BAR_ABOUT |
| Python constant | C equivalent |
|---|---|
| gcompris.BOARD_HEIGHT | BOARDHEIGHT |
| gcompris.BOARD_WIDTH | BOARDWIDTH |
| gcompris.BAR_HEIGHT | BAR_HEIGHT |
| gcompris.DEFAULT_SKIN | DEFAULT_SKIN |
| Python constant | C equivalent |
|---|---|
| gcompris.COLOR_TITLE | COLOR_TITLE |
| gcompris.COLOR_TEXT_BUTTON | COLOR_TEXT_BUTTON |
| gcompris.COLOR_CONTENT | COLOR_CONTENT |
| gcompris.COLOR_SUBTITLE | COLOR_SUBTITLE |
| Python constant | C equivalent |
|---|---|
| gcompris.FONT_TITLE | FONT_TITLE |
| gcompris.FONT_TITLE_FALLBACK | FONT_TITLE_FALLBACK |
| gcompris.FONT_SUBTITLE | FONT_SUBTITLE |
| gcompris.FONT_SUBTITLE_FALLBACK | FONT_SUBTITLE_FALLBACK |
| gcompris.FONT_CONTENT | FONT_CONTENT |
| gcompris.FONT_CONTENT_FALLBACK | FONT_CONTENT_FALLBACK |
| Python constant | C equivalent |
|---|---|
| gcompris.FONT_BOARD_TINY | FONT_BOARD_TINY |
| gcompris.FONT_BOARD_SMALL | FONT_BOARD_SMALL |
| gcompris.FONT_BOARD_MEDIUM | FONT_BOARD_MEDIUM |
| gcompris.FONT_BOARD_BIG | FONT_BOARD_BIG |
| gcompris.FONT_BOARD_BIG_BOLD | FONT_BOARD_BIG_BOLD |
| gcompris.FONT_BOARD_FIXED | FONT_BOARD_FIXED |
| gcompris.FONT_BOARD_TITLE | FONT_BOARD_TITLE |
| gcompris.FONT_BOARD_TITLE_BOLD | FONT_BOARD_TITLE_BOLD |
| gcompris.FONT_BOARD_HUGE | FONT_BOARD_HUGE |
| gcompris.FONT_BOARD_HUGE_BOLD | FONT_BOARD_HUGE_BOLD |
| Python constant | C equivalent |
|---|---|
| gcompris.CURSOR_FIRST_CUSTOM | GCOMPRIS_FIRST_CUSTOM_CURSOR |
| gcompris.CURSOR_BIG_RED_ARROW | GCOMPRIS_BIG_RED_ARROW_CURSOR |
| gcompris.CURSOR_BIRD | GCOMPRIS_BIRD_CURSOR |
| gcompris.CURSOR_LINE | GCOMPRIS_LINE_CURSOR |
| gcompris.CURSOR_FILLRECT | GCOMPRIS_FILLRECT_CURSOR |
| gcompris.CURSOR_RECT | GCOMPRIS_RECT_CURSOR |
| gcompris.CURSOR_FILLCIRCLE | GCOMPRIS_FILLCIRCLE_CURSOR |
| gcompris.CURSOR_CIRCLE | GCOMPRIS_CIRCLE_CURSOR |
| gcompris.CURSOR_DEL | GCOMPRIS_DEL_CURSOR |
| gcompris.CURSOR_FILL | GCOMPRIS_FILL_CURSOR |
| gcompris.CURSOR_SELECT | GCOMPRIS_SELECT_CURSOR |
| gcompris.CURSOR_DEFAULT | GCOMPRIS_DEFAULT_CURSOR |
| Python function | C equivalent | Notes |
|---|---|---|
| gcompris.utils.load_number_pixmap(number) | GdkPixbuf *gcompris_load_number_pixmap(char number) | return a gtk.gdk.Pixbuf |
| gcompris.utils.image_to_skin(imagename) | gchar *gcompris_image_to_skin(gchar *imagename) | return a string |
| gcompris.utils.load_skin_pixmap(pixmapfile) | GdkPixbuf *gcompris_load_skin_pixmap(char *pixmapfile) | return a gtk.gdk.Pixbuf |
| gcompris.utils.load_pixmap(pixmapfile) | GdkPixbuf *gcompris_load_pixmap(char *pixmapfile) | return a gtk.gdk.Pixbuf |
| gcompris.utils.set_image_focus(item, focus) | void gcompris_set_image_focus(GnomeCanvasItem *item, gboolean focus) | |
| gcompris.utils.item_event_focus(item, event, dest_item) | gint gcompris_item_event_focus(GnomeCanvasItem *item, GdkEvent *event, GnomeCanvasItem *dest_item) | return an integer |
| gcompris.utils.item_absolute_move(item, x, y) | void item_absolute_move(GnomeCanvasItem *item, int x, int y) | |
| gcompris.utils.item_rotate(item, angle) | void item_rotate(GnomeCanvasItem *item, double angle) | |
| gcompris.utils.item_rotate_relative(item, angle) | void item_rotate_relative(GnomeCanvasItem *item, double angle) | |
| gcompris.utils.item_rotate_with_center(item, angle, x, y) | void item_rotate_with_center(GnomeCanvasItem *item, double angle, int x, int y) | |
| gcompris.utils.item_rotate_relative_with_center(item, angle, x, y) | void item_rotate_relative_with_center(GnomeCanvasItem *item, double angle, int x, int y) | |
| gcompris.utils.dialog(str, callback) | void gcompris_dialog(gchar *str, DialogBoxCallBack callback) | The callback must be a callable object |
| gcompris.utils.load_pixmap_asset(dataset, categories, mimetype, name) | GdkPixbuf *gcompris_load_pixmap_asset(gchar *dataset, gchar* categories, gchar* mimetype, gchar* name) | return a gtk.gdk.Pixbuf |
| gcompris.utils.get_asset_file(dataset, categories, mimetype, name) | gchar *gcompris_get_asset_file(gchar *dataset, gchar* categories, gchar* mimetype, gchar* name) | return a string |
| Python function | C equivalent | Notes |
|---|---|---|
| gcompris.bonus.display(gamewon, bonus_id) | void gcompris_display_bonus(int gamewon, int bonus_id) | |
| gcompris.bonus.board_finished(type) | void board_finished(int type) |
| Python constant | C equivalent |
|---|---|
| gcompris.bonus.TIME_CLICK_TO | TIME_CLICK_TO_BONUS |
| gcompris.bonus.RANDOM | BONUS_RANDOM |
| gcompris.bonus.SMILEY | BONUS_SMILEY |
| gcompris.bonus.FLOWER | BONUS_FLOWER |
| gcompris.bonus.LAST | BONUS_LAST |
| gcompris.bonus.FINISHED_RANDOM | BOARD_FINISHED_RANDOM |
| gcompris.bonus.FINISHED_TUXPLANE | BOARD_FINISHED_TUXPLANE |
| gcompris.bonus.FINISHED_TUXLOCO | BOARD_FINISHED_TUXLOCO |
| gcompris.bonus.FINISHED_TOOMANYERRORS | BOARD_FINISHED_TOOMANYERRORS |
| gcompris.bonus.FINISHED_LAST | BOARD_FINISHED_LAST |
| Python function | C equivalent | Notes |
|---|---|---|
| gcompris.score.start(style, x, y, max) | void gcompris_score_start(ScoreStyleList style, guint x, guint y, guint max) | |
| gcompris.score.end() | void gcompris_score_end() | |
| gcompris.score.set(value) | void gcompris_score_set(guint value) |
| Python function | C equivalent | Notes |
|---|---|---|
| gcompris.sound.play_ogg_list(list) | void gcompris_play_ogg_list( GList* files ) | The list argument is a GList |
| gcompris.sound.play_ogg(list) | void gcompris_play_ogg(char *, ...) | The list argument is a python list containing strings |
| Python function | C equivalent | Notes |
|---|---|---|
| gcompris.timer.display(x, y, type, second, callback) | void gcompris_timer_display (int x, int y, TimerList type, int second, GcomprisTimerEnd gcomprisTimerEnd); | The callback must be a callable object |
| gcompris.timer.add(second) | void gcompris_timer_add(int second) | |
| gcompris.timer.end() | void gcompris_timer_end(void) | |
| gcompris.timer.get_remaining() | guint gcompris_timer_get_remaining() | Return an integer |
| gcompris.timer.pause(pause) | void gcompris_timer_pause(gboolean pause) |