Commit 9cd516a8 authored by Bruno Coudoin's avatar Bruno Coudoin

Added python plugin by Olivier Samyn

parent b8855f88
2003-03-05 Bruno Coudoin <bruno.coudoin@free.fr>
* boards/Makefile.am: Added python plugin by Olivier Samyn
* boards/boardicons/python.png: Added python plugin by Olivier Samyn
* configure.in:
* po/Makefile.in.in: Added python plugin by Olivier Samyn
* po/POTFILES.in: Added python plugin by Olivier Samyn
* src/boards/Makefile.am: Added python plugin by Olivier Samyn
* src/boards/py-gcompris-board.c: Added python plugin by Olivier Samyn
(gcompris_new_pyGcomprisBoardObject),
(pyGcomprisBoardType_dealloc), (pyGcomprisBoardType_getattr),
(pyGcomprisBoardType_setattr): Added python plugin by Olivier Samyn
* src/boards/py-gcompris-board.h: Added python plugin by Olivier Samyn
* src/boards/py-mod-gcompris.c: (py_gcompris_end_board),
(py_gcompris_bar_start), (py_gcompris_set_background),
(py_gcompris_bar_set_level), (py_gcompris_bar_set),
(py_gcompris_bar_hide), (py_gcompris_board_has_help),
(py_gcompris_help_start), (py_gcompris_help_stop),
(py_gcompris_get_canvas), (py_gcompris_get_window),
(py_gcompris_get_locale), (py_gcompris_set_locale),
(py_gcompris_set_cursor), (pyImageSelectorCallBack),
(py_gcompris_images_selector_start),
(py_gcompris_images_selector_stop), (py_gcompris_exit),
(python_gcompris_module_init): Added python plugin by Olivier Samyn
* src/boards/py-mod-gcompris.h: Added python plugin by Olivier Samyn
* src/boards/python.c: (get_bplugin_info), (python_simple_call),
(pythonboard_start), (pythonboard_pause), (pythonboard_end),
(pythonboard_is_our_board), (pythonboard_key_press),
(pythonboard_ok), (pythonboard_set_level), (pythonboard_config),
(pythonboard_repeat): Added python plugin by Olivier Samyn
* src/boards/python/Makefile.am: Added python plugin by Olivier Samyn
* src/boards/python/pythontest.py: Added python plugin by Olivier Samyn
* src/gcompris/Makefile.am: Added python plugin by Olivier Samyn
2003-03-04 Gregory Leblanc <gleblanc@linuxweasel.com>
* boards/algebra_guesscount/dash.png:
......
......@@ -45,7 +45,6 @@ xml_in_files = \
reversecount.xml.in \
scalesboard.xml.in \
smallnumbers.xml.in \
submarine.xml.in \
superbrain.xml.in \
target.xml.in \
traffic.xml.in \
......@@ -58,7 +57,8 @@ xml_in_files = \
algebra_guesscount.xml.in \
leftright.xml.in \
colors.xml.in \
colors_group.xml.in
colors_group.xml.in \
pythontest.xml.in
xml_DATA = $(xml_in_files:.xml.in=.xml)
......
......@@ -7,17 +7,12 @@ AM_MAINTAINER_MODE
AC_ISC_POSIX
GNOME_COMPILE_WARNINGS
GNOME_PTHREAD_CHECK
AC_SUBST(PTHREAD_LIB)
LIBGNOME_REQUIRED=1.96.0
LIBGNOMEUI_REQUIRED=1.96.0
GDK_PIXBUF_REQUIRED=2.0.6
LIBGNOMECANVAS_REQUIRED=2.0.2
PKG_CHECK_MODULES(GCOMPRIS, libgnome-2.0 >= $LIBGNOME_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED gdk-pixbuf-2.0 >= $GDK_PIXBUF_REQUIRED libgnomecanvas-2.0 >= $LIBGNOMECANVAS_REQUIRED)
PKG_CHECK_MODULES(GCOMPRIS, libgnome-2.0 >= $LIBGNOME_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED gdk-pixbuf-2.0 >= $GDK_PIXBUF_REQUIRED libgnomecanvas-2.0 >= $LIBGNOMECANVAS_REQUIRED gthread-2.0)
AC_SUBST(GCOMPRIS_CFLAGS)
AC_SUBST(GCOMPRIS_LIBS)
......@@ -41,8 +36,13 @@ AC_LIBTOOL_DLOPEN
AM_PROG_LIBTOOL
dnl GNOME2 GNOME_X_CHECKS
AM_PATH_GLIB
AM_PATH_XML2
AM_PATH_GLIB_2_0
dnl libxml-2 Checks
PKG_CHECK_MODULES(XML, libxml-2.0)
AC_SUBST(XML_CFLAGS)
AC_SUBST(XML_LIBS)
AM_ICONV
dnl Add the languages which your application supports here.
......@@ -108,11 +108,100 @@ if test x$TETEX = xno; then
AC_MSG_ERROR(Couldn't find texi2html usualy in the tetex package, please install it)
fi
dnl Tests for the python plugin
PYTHON_CFLAGS=
PYTHON_LIBS=
PYTHON_PATH=yes
build_python_plugin=yes
AC_ARG_WITH(python,
AC_HELP_STRING(
[--with-python=path],
[Give the python interpreter (ex: /opt/python/bin/python2.2)]),
[PYTHON_PATH=$withval] )
if test x$PYTHON_PATH = xno; then
build_python_plugin=no
else
dnl Find a python interpretter
python_old_path=${PATH}
if test x$PYTHON_PATH = xyes; then
AC_PATH_PROG(python_exec, python, no)
if test x$python_exec = xno; then
build_python_plugin=no
AC_MSG_WARN([Couldn't find python interpreter, python plugin disabled.])
fi
else
if test -x "${PYTHON_PATH}"; then
python_exec=${PYTHON_PATH}
else
build_python_plugin=no
AC_MSG_WARN([Couldn't find python interpreter, python plugin disabled.])
fi
fi
if test x$build_python_plugin = xyes; then
python_version=`${python_exec} -c "import sys; print sys.version[[:3]]"`
python_prefix=`${python_exec} -c "import sys; print sys.prefix"`
python_exec_prefix=`${python_exec} -c "import sys; print sys.exec_prefix"`
dnl Search for python's includes
python_old_cppflags=${CPPFLAGS}
CPPFLAGS="${CPPFLAGS} -I${python_prefix}/include/python${python_version}"
AC_CHECK_HEADER(Python.h,
PYTHON_CFLAGS="-I${python_prefix}/include/python${python_version}",
[ AC_MSG_WARN([Couldn't find python includes, python plugin disabled.])
build_python_plugin=no])
CPPFLAGS=$python_old_cppflags
fi
if test x$build_python_plugin = xyes; then
dnl Search for python's libs
dnl Take the needed libraries into the lib/python/config/Makefile... (see dia config)
python_makefile="${python_exec_prefix}/lib/python${python_version}/config/Makefile"
if test -f "${python_makefile}"; then
dnl extra required libs
python_localmodlibs=`sed -n -e 's/^LOCALMODLIBS=\(.*\)/\1/p' $python_makefile`
python_basemodlibs=`sed -n -e 's/^BASEMODLIBS=\(.*\)/\1/p' $python_makefile`
python_other_libs=`sed -n -e 's/^LIBS=\(.*\)/\1/p' $python_makefile`
python_libs_cflags=`sed -n -e 's/^LINKFORSHARED=\(.*\)/\1/p' $python_makefile`
python_libs="${python_localmodlibs} ${python_basemodlibs} ${python_other_libs}"
python_old_ldflags=${LDFLAGS}
LDFLAGS="${LDFLAGS} ${python_libs_cflags} -L${python_exec_prefix}/lib/python${python_version}/config ${python_libs}"
AC_CHECK_LIB(python${python_version},
Py_Initialize,
PYTHON_LIBS="${python_libs_cflags} -L${python_exec_prefix}/lib/python${python_version}/config -lpython${python_version} ${python_libs}",
[ AC_MSG_WARN([Couldn't find python library, python plugin disabled.])
build_python_plugin=no ])
LDFLAGS=${python_old_ldflags}
else
AC_MSG_WARN([Couldn't find python library, python plugin disabled.])
build_python_plugin=no
fi
fi
fi
dnl Finally output the required python variables and automake defines.
AM_CONDITIONAL(PYTHON_PLUGIN, test x$build_python_plugin = xyes)
AC_SUBST(PYTHON_CFLAGS)
AC_SUBST(PYTHON_LIBS)
if test x$build_python_plugin = xno; then
AC_MSG_NOTICE([Python plugin is disabled.])
else
dnl Python interpreter is available so check for pygtk and gnome-python
PKG_CHECK_MODULES(PYGTK, pygtk-2.0 gnome-python-2.0)
AC_SUBST(PYGTK_CFLAGS)
AC_SUBST(PYGTK_LIBS)
fi
dnl Autoconf output
AC_OUTPUT([ gcompris.spec
Makefile
src/Makefile
src/gcompris/Makefile
src/boards/Makefile
src/boards/python/Makefile
po/Makefile.in
docs/Makefile
docs/C/Makefile
......
......@@ -26,10 +26,11 @@ VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
datadir = $(prefix)/@DATADIRNAME@
localedir = $(datadir)/locale
gnulocaledir = $(prefix)/share/locale
gettextsrcdir = $(prefix)/share/glib-2.0/gettext/po
datadir = @datadir@
libdir = @libdir@
localedir = $(libdir)/locale
gnulocaledir = $(datadir)/locale
gettextsrcdir = $(datadir)/glib-2.0/gettext/po
subdir = po
INSTALL = @INSTALL@
......@@ -38,9 +39,9 @@ MKINSTALLDIRS = $(top_srcdir)/@MKINSTALLDIRS@
CC = @CC@
GENCAT = @GENCAT@
GMSGFMT = PATH=../src:$$PATH @GMSGFMT@
GMSGFMT = @GMSGFMT@
MSGFMT = @MSGFMT@
XGETTEXT = PATH=../src:$$PATH @XGETTEXT@
XGETTEXT = @XGETTEXT@
INTLTOOL_UPDATE = @INTLTOOL_UPDATE@
INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@
MSGMERGE = INTLTOOL_EXTRACT=$(INTLTOOL_EXTRACT) $(INTLTOOL_UPDATE) --gettext-package $(GETTEXT_PACKAGE) --dist
......@@ -197,7 +198,6 @@ dist distdir: update-po $(DISTFILES)
update-po: Makefile
$(MAKE) $(GETTEXT_PACKAGE).pot
PATH=`pwd`/../src:$$PATH; \
cd $(srcdir); \
catalogs='$(CATALOGS)'; \
for cat in $$catalogs; do \
......
......@@ -114,6 +114,7 @@ boards/smallnumbers.xml.in
boards/target.xml.in
boards/traffic.xml.in
boards/wordsgame.xml.in
boards/pythontest.xml.in
gcompris.desktop.in
gcompris-edit.desktop.in
src/boards/advanced_colors.c
......@@ -151,6 +152,7 @@ src/boards/smallnumbers.c
src/boards/target.c
src/boards/traffic.c
src/boards/wordsgame.c
src/boards/python.c
src/gcompris/about.c
src/gcompris/config.c
src/gcompris/gameutil.c
......
if PYTHON_PLUGIN
python_plugin = libpython.la
python_subdir = python
else
python_plugin =
python_subdir =
endif
SUBDIRS= $(python_subdir)
lib_LTLIBRARIES = \
libalgebra.la \
libalgebra_guesscount.la \
......@@ -29,21 +40,24 @@ lib_LTLIBRARIES = \
libshapegame.la \
libsmallnumbers.la \
libsubmarine.la \
libtarget.la \
libtarget.la \
libtraffic.la \
libwordsgame.la \
libadvanced_colors.la \
libread_colors.la
libread_colors.la \
$(python_plugin)
libdir = $(plugindir)
INCLUDES = \
-I.. \
-I$(top_srcdir)/intl \
$(GCOMPRIS_CFLAGS) \
$(XML_CFLAGS)
$(XML_CFLAGS) \
$(PYTHON_CFLAGS) \
$(PYGTK_CFLAGS)
libmenu_la_LDFLAGS = -module -avoid-version
libmenu_la_LIBADD = @PTHREAD_LIB@
libmenu_la_LIBADD = \
$(GCOMPRIS_LIBS) \
$(XML_LIBS) $(INTLLIBS)
......@@ -51,14 +65,14 @@ libmenu_la_SOURCES = menu.c
libclickgame_la_LDFLAGS = -module -avoid-version
libclickgame_la_LIBADD = @PTHREAD_LIB@
libclickgame_la_LIBADD = \
$(GCOMPRIS_LIBS) \
$(XML_LIBS) $(INTLLIBS)
libclickgame_la_SOURCES = clickgame.c
libalgebra_la_LDFLAGS = -module -avoid-version
libalgebra_la_LIBADD = @PTHREAD_LIB@
libalgebra_la_LIBADD = \
$(GCOMPRIS_LIBS) \
$(XML_LIBS) $(INTLLIBS)
......@@ -66,7 +80,7 @@ libalgebra_la_SOURCES = algebra.c
libclockgame_la_LDFLAGS = -module -avoid-version
libclockgame_la_LIBADD = @PTHREAD_LIB@
libclockgame_la_LIBADD = \
$(GCOMPRIS_LIBS) \
$(XML_LIBS) $(INTLLIBS)
......@@ -74,7 +88,7 @@ libclockgame_la_SOURCES = clockgame.c
libshapegame_la_LDFLAGS = -module -avoid-version
libshapegame_la_LIBADD = @PTHREAD_LIB@
libshapegame_la_LIBADD = \
$(GCOMPRIS_LIBS) \
$(XML_LIBS) $(INTLLIBS)
......@@ -82,7 +96,7 @@ libshapegame_la_SOURCES = shapegame.c
libwordsgame_la_LDFLAGS = -module -avoid-version
libwordsgame_la_LIBADD = @PTHREAD_LIB@
libwordsgame_la_LIBADD = \
$(GCOMPRIS_LIBS) \
$(XML_LIBS) $(INTLLIBS)
......@@ -90,7 +104,7 @@ libwordsgame_la_SOURCES = wordsgame.c
libgletters_la_LDFLAGS = -module -avoid-version
libgletters_la_LIBADD = @PTHREAD_LIB@
libgletters_la_LIBADD = \
$(GCOMPRIS_LIBS) \
$(XML_LIBS) $(INTLLIBS)
......@@ -98,7 +112,7 @@ libgletters_la_SOURCES = gletters.c
libplanegame_la_LDFLAGS = -module -avoid-version
libplanegame_la_LIBADD = @PTHREAD_LIB@
libplanegame_la_LIBADD = \
$(GCOMPRIS_LIBS) \
$(XML_LIBS) $(INTLLIBS)
......@@ -106,7 +120,7 @@ libplanegame_la_SOURCES = planegame.c
libsmallnumbers_la_LDFLAGS = -module -avoid-version
libsmallnumbers_la_LIBADD = @PTHREAD_LIB@
libsmallnumbers_la_LIBADD = \
$(GCOMPRIS_LIBS) \
$(XML_LIBS) $(INTLLIBS)
......@@ -114,7 +128,7 @@ libsmallnumbers_la_SOURCES = smallnumbers.c
libparatrooper_la_LDFLAGS = -module -avoid-version
libparatrooper_la_LIBADD = @PTHREAD_LIB@
libparatrooper_la_LIBADD = \
$(GCOMPRIS_LIBS) \
$(XML_LIBS) $(INTLLIBS)
......@@ -122,7 +136,7 @@ libparatrooper_la_SOURCES = paratrooper.c
libreading_la_LDFLAGS = -module -avoid-version
libreading_la_LIBADD = @PTHREAD_LIB@
libreading_la_LIBADD = \
$(GCOMPRIS_LIBS) \
$(XML_LIBS) $(INTLLIBS)
......@@ -130,7 +144,7 @@ libreading_la_SOURCES = reading.c
libdraw_la_LDFLAGS = -module -avoid-version
libdraw_la_LIBADD = @PTHREAD_LIB@
libdraw_la_LIBADD = \
$(GCOMPRIS_LIBS) \
$(XML_LIBS) $(INTLLIBS)
......@@ -138,7 +152,7 @@ libdraw_la_SOURCES = draw.c
libmemory_la_LDFLAGS = -module -avoid-version
libmemory_la_LIBADD = @PTHREAD_LIB@
libmemory_la_LIBADD = \
$(GCOMPRIS_LIBS) \
$(XML_LIBS) $(INTLLIBS)
......@@ -146,7 +160,7 @@ libmemory_la_SOURCES = memory.c
libimageid_la_LDFLAGS = -module -avoid-version
libimageid_la_LIBADD = @PTHREAD_LIB@
libimageid_la_LIBADD = \
$(GCOMPRIS_LIBS) \
$(XML_LIBS) $(INTLLIBS)
......@@ -154,7 +168,7 @@ libimageid_la_SOURCES = imageid.c
libmissingletter_la_LDFLAGS = -module -avoid-version
libmissingletter_la_LIBADD = @PTHREAD_LIB@
libmissingletter_la_LIBADD = \
$(GCOMPRIS_LIBS) \
$(XML_LIBS) $(INTLLIBS)
......@@ -162,145 +176,164 @@ libmissingletter_la_SOURCES = missingletter.c
libclick_on_letter_la_LDFLAGS = -module -avoid-version
libclick_on_letter_la_LIBADD = @PTHREAD_LIB@
libclick_on_letter_la_LIBADD = \
$(GCOMPRIS_LIBS) \
$(XML_LIBS) $(INTLLIBS)
libclick_on_letter_la_SOURCES = click_on_letter.c
librailroad_la_LDFLAGS = -module -avoid-version
librailroad_la_LIBADD = @PTHREAD_LIB@
librailroad_la_LIBADD = \
$(GCOMPRIS_LIBS) \
$(XML_LIBS) $(INTLLIBS)
librailroad_la_SOURCES = railroad.c
liberase_la_LDFLAGS = -module -avoid-version
liberase_la_LIBADD = @PTHREAD_LIB@
liberase_la_LIBADD = \
$(GCOMPRIS_LIBS) \
$(XML_LIBS) $(INTLLIBS)
liberase_la_SOURCES = erase.c
libalgebra_guesscount_la_LDFLAGS = -module -avoid-version
libalgebra_guesscount_la_LIBADD = @PTHREAD_LIB@
libalgebra_guesscount_la_LIBADD = \
$(GCOMPRIS_LIBS) \
$(XML_LIBS) $(INTLLIBS)
libalgebra_guesscount_la_SOURCES = algebra_guesscount.c
libleftright_la_LDFLAGS = -module -avoid-version
libleftright_la_LIBADD = @PTHREAD_LIB@
libleftright_la_LIBADD = \
$(GCOMPRIS_LIBS) \
$(GNOME_XML_LIB) $(INTLLIBS)
$(XML_LIBS) $(INTLLIBS)
libleftright_la_SOURCES = leftright.c
libcolors_la_LDFLAGS = -module -avoid-version
libcolors_la_LIBADD = @PTHREAD_LIB@
libcolors_la_LIBADD = \
$(GCOMPRIS_LIBS) \
$(GNOME_XML_LIB) $(INTLLIBS)
$(XML_LIBS) $(INTLLIBS)
libcolors_la_SOURCES = colors.c
libtarget_la_LDFLAGS = -module -avoid-version
libtarget_la_LIBADD = @PTHREAD_LIB@
libtarget_la_LIBADD = \
$(GCOMPRIS_LIBS) \
$(GNOME_XML_LIB) $(INTLLIBS)
$(XML_LIBS) $(INTLLIBS)
libtarget_la_SOURCES = target.c
libmaze_la_LDFLAGS = -module -avoid-version
libmaze_la_LIBADD = @PTHREAD_LIB@
libmaze_la_LIBADD = \
$(GCOMPRIS_LIBS) \
$(GNOME_XML_LIB) $(INTLLIBS)
$(XML_LIBS) $(INTLLIBS)
libmaze_la_SOURCES = maze.c
libreversecount_la_LDFLAGS = -module -avoid-version
libreversecount_la_LIBADD = @PTHREAD_LIB@
libreversecount_la_LIBADD = \
$(GCOMPRIS_LIBS) \
$(GNOME_XML_LIB) $(INTLLIBS)
$(XML_LIBS) $(INTLLIBS)
libreversecount_la_SOURCES = reversecount.c
libcanal_lock_la_LDFLAGS = -module -avoid-version
libcanal_lock_la_LIBADD = @PTHREAD_LIB@
libcanal_lock_la_LIBADD = \
$(GCOMPRIS_LIBS) \
$(GNOME_XML_LIB) $(INTLLIBS)
$(XML_LIBS) $(INTLLIBS)
libcanal_lock_la_SOURCES = canal_lock.c
libadvanced_colors_la_LDFLAGS = -module -avoid-version
libadvanced_colors_la_LIBADD = @PTHREAD_LIB@
libadvanced_colors_la_LIBADD = \
$(GCOMPRIS_LIBS) \
$(GNOME_XML_LIB) $(INTLLIBS)
$(XML_LIBS) $(INTLLIBS)
libadvanced_colors_la_SOURCES = advanced_colors.c
libsuperbrain_la_LDFLAGS = -module -avoid-version
libsuperbrain_la_LIBADD = @PTHREAD_LIB@
libsuperbrain_la_LIBADD = \
$(GCOMPRIS_LIBS) \
$(GNOME_XML_LIB) $(INTLLIBS)
$(XML_LIBS) $(INTLLIBS)
libsuperbrain_la_SOURCES = superbrain.c
libread_colors_la_LDFLAGS = -module -avoid-version
libread_colors_la_LIBADD = @PTHREAD_LIB@
libread_colors_la_LIBADD = \
$(GCOMPRIS_LIBS) \
$(GNOME_XML_LIB) $(INTLLIBS)
$(XML_LIBS) $(INTLLIBS)
libread_colors_la_SOURCES = read_colors.c
libchess_la_LDFLAGS = -module -avoid-version
libchess_la_LIBADD = @PTHREAD_LIB@
libchess_la_LIBADD = \
$(GCOMPRIS_LIBS) \
$(GNOME_XML_LIB) $(INTLLIBS)
$(XML_LIBS) $(INTLLIBS)
libchess_la_SOURCES = chess.c chess_position.c chess_notation.c \
chess_notation.h chess_position.h chess_makros.h
libenumerate_la_LDFLAGS = -module -avoid-version
libenumerate_la_LIBADD = @PTHREAD_LIB@
libenumerate_la_LIBADD = \
$(GCOMPRIS_LIBS) \
$(GNOME_XML_LIB) $(INTLLIBS)
$(XML_LIBS) $(INTLLIBS)
libenumerate_la_SOURCES = enumerate.c
libmoney_la_LDFLAGS = -module -avoid-version
libmoney_la_LIBADD = @PTHREAD_LIB@
libmoney_la_LIBADD = \
$(GCOMPRIS_LIBS) \
$(GNOME_XML_LIB) $(INTLLIBS)
$(XML_LIBS) $(INTLLIBS)
libmoney_la_SOURCES = money.c money_widget.c money_widget.h
libtraffic_la_LDFLAGS = -module -avoid-version
libtraffic_la_LIBADD = @PTHREAD_LIB@
libtraffic_la_LIBADD = \
$(GCOMPRIS_LIBS) \
$(GNOME_XML_LIB) $(INTLLIBS)
$(XML_LIBS) $(INTLLIBS)
libtraffic_la_SOURCES = traffic.c
libmachpuzzle_la_LDFLAGS = -module -avoid-version
libmachpuzzle_la_LIBADD = @PTHREAD_LIB@
libmachpuzzle_la_LIBADD = \
$(GCOMPRIS_LIBS) \
$(GNOME_XML_LIB) $(INTLLIBS)
$(XML_LIBS) $(INTLLIBS)
libmachpuzzle_la_SOURCES = machpuzzle.c
libsubmarine_la_LDFLAGS = -module -avoid-version
libsubmarine_la_LIBADD = @PTHREAD_LIB@
libsubmarine_la_LIBADD = \
$(GCOMPRIS_LIBS) \
$(GNOME_XML_LIB) $(INTLLIBS)
$(XML_LIBS) $(INTLLIBS)
libsubmarine_la_SOURCES = submarine.c
libhanoi_la_LDFLAGS = -module -avoid-version
libhanoi_la_LIBADD = @PTHREAD_LIB@
libhanoi_la_LIBADD = \
$(GCOMPRIS_LIBS) \
$(GNOME_XML_LIB) $(INTLLIBS)
$(XML_LIBS) $(INTLLIBS)
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 = \
$(GCOMPRIS_LIBS) \
$(XML_LIBS) $(INTLLIBS) \
$(PYGTK_LIBS)
libpython_la_SOURCES = python.c \
py-gcompris-board.c py-gcompris-board.h \
py-mod-gcompris.c py-mod-gcompris.h
EXTRA_DIST = README
#include "py-gcompris-board.h"
#include <pygobject.h>
staticforward PyTypeObject pyGcomprisBoardType;
//static char pyGcomprisBoardType_doc[]= "Python GcomprisBoars structure binding";
/* Special function created for the python plugin to be able to create
* a pyGcomprisBoardObject form the existing GcomprisBoard structure
*/
PyObject*
gcompris_new_pyGcomprisBoardObject(GcomprisBoard* aboard)
{
pyGcomprisBoardObject* theboard = NULL;
g_print("pyGcomprisBoardType new\n");
theboard = PyObject_New(pyGcomprisBoardObject, &pyGcomprisBoardType);
if (theboard!=NULL)
theboard->cdata = aboard;
return (PyObject*)theboard;
}
/* Free the python gcompris board */
static void
pyGcomprisBoardType_dealloc(pyGcomprisBoardObject *self)
{
g_print("pyGcomprisBoardType_dealloc\n");
self->cdata = NULL;
PyObject_DEL(self);
}
/* Methods defined in the pyGcomprisBoard class */
static PyMethodDef pyGcomprisBoardType_methods[] = {
{NULL, NULL} /* sentinel */
};
/* Return the value of the members contained in the GcomprisBoard structure */
static PyObject *
pyGcomprisBoardType_getattr(pyGcomprisBoardObject *self, char *name)
{
g_print("pyGcomprisBoardType getAttr\n");
if (self->cdata != NULL) {
/* Board type */
if(strcmp(name,"type")==0) return Py_BuildValue("s", self->cdata->type);
if(strcmp(name,"board_ready")==0){
if(self->cdata->board_ready){
Py_INCREF(Py_True);
return Py_True;
} else {
Py_INCREF(Py_False);
return Py_False;
}
}
/* Board specific mode */
if(strcmp(name,"mode")==0) return Py_BuildValue("s", self->cdata->mode);
/* Name of this Board */
if(strcmp(name,"name")==0) return Py_BuildValue("s", self->cdata->name);
if(strcmp(name,"title")==0) return Py_BuildValue("s", self->cdata->title);
if(strcmp(name,"description")==0) return Py_BuildValue("s", self->cdata->description);
if(strcmp(name,"icon_name")==0) return Py_BuildValue("s", self->cdata->icon_name);
if(strcmp(name,"author")==0) return Py_BuildValue("s", self->cdata->author);
if(strcmp(name,"boarddir")==0) return Py_BuildValue("s", self->cdata->boarddir);
if(strcmp(name,"filename")==0) return Py_BuildValue("s", self->cdata->filename);
if(strcmp(name,"difficulty")==0) return Py_BuildValue("s", self->cdata->difficulty);
if(strcmp(name,"mandatory_sound_file")==0) return Py_BuildValue("s", self->cdata->mandatory_sound_file);
/* Menu positionning */
if(strcmp(name,"section")==0) return Py_BuildValue("s", self->cdata->section);
if(strcmp(name,"menuposition")==0) return Py_BuildValue("s", self->cdata->menuposition);
/* Help Information */
if(strcmp(name,"prerequisite")==0) return Py_BuildValue("s", self->cdata->prerequisite);
if(strcmp(name,"goal")==0) return Py_BuildValue("s", self->cdata->goal);
if(strcmp(name,"manual")==0) return Py_BuildValue("s", self->cdata->manual);
if(strcmp(name,"credit")==0) return Py_BuildValue("s", self->cdata->credit);
/* Size of the window in which we have to run */
if(strcmp(name,"width")==0) return Py_BuildValue("i", self->cdata->width);
if(strcmp(name,"height")==0) return Py_BuildValue("i", self->cdata->height);
/* Dynamic board information (status) */
if(strcmp(name,"level")==0) return Py_BuildValue("i", self->cdata->level);
if(strcmp(name,"maxlevel")==0) return Py_BuildValue("i", self->cdata->maxlevel);
if(strcmp(name,"sublevel")==0) return Py_BuildValue("i", self->cdata->sublevel);
if(strcmp(name,"number_of_sublevel")==0) return Py_BuildValue("i", self->cdata->number_of_sublevel);
if(strcmp(name,"previous_level")==0)
return gcompris_new_pyGcomprisBoardObject(self->cdata->previous_board);
if(strcmp(name,"canvas")==0)
return (PyObject*) pygobject_new((GObject*)self->cdata->canvas);
/* Other members are special one...
* TODO: Does we need to write a BoardPlugin structure wrapper ?
*/
}
return Py_FindMethod(pyGcomprisBoardType_methods, (PyObject *)self, name);
}
/* Set the value of a GcomprisBoard structure member */
static int
pyGcomprisBoardType_setattr(pyGcomprisBoardObject *self, char *name, PyObject *v)
{
int value;
g_print("pyGcomprisBoardType setAttr\n");
if (self->cdata==NULL) return -1;
if (v==NULL) return -1;
if (strcmp(name,"level")==0){
value = (int) PyInt_AsLong(v);
if ( value < 0 ) return -1;
self->cdata->level=value;
return 0;
}
if (strcmp(name,"maxlevel")==0){
value = PyInt_AsLong(v);
if ( value < 0 ) return -1;
self->cdata->maxlevel=value;
return 0;
}
if (strcmp(name,"sublevel")==0){
value = PyInt_AsLong(v);
if ( value < 0 ) return -1;
self->cdata->sublevel=value;
return 0;
}
if (strcmp(name,"number_of_sublevel")==0){
value = PyInt_AsLong(v);
if ( value < 0 ) return -1;
self->cdata->number_of_sublevel=value;
return 0;
}
/* Other members are supposed to be read only */
return -1;
}
static PyTypeObject pyGcomprisBoardType = {
PyObject_HEAD_INIT(&PyType_Type)
0, /*ob_size*/
"pyGcomprisBoard", /*tp_name*/
sizeof(pyGcomprisBoardObject), /*tp_basicsize*/
0, /*tp_itemsize*/
/* methods */
(destructor)pyGcomprisBoardType_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc)pyGcomprisBoardType_getattr, /*tp_getattr*/
(setattrfunc)pyGcomprisBoardType_setattr, /*tp_setattr*/
0, /*tp_compare*/