Commit 25abe526 authored by Olivier Samyn's avatar Olivier Samyn

Reworked the python submodules to get them working.

Tests some features using pythontest.py
Removed some unusefull files because they are added by the autogen process.
parent 20f65022
#undef ENABLE_NLS
#undef HAVE_CATGETS
#undef HAVE_GETTEXT
#undef HAVE_LC_MESSAGES
#undef HAVE_STPCPY
#undef HAVE_LIBSM
#undef PACKAGE_LOCALE_DIR
#undef PACKAGE_DATA_DIR
#undef PACKAGE_SOUNDS_DIR
#undef PACKAGE_HELP_DIR
#undef PLUGIN_DIR
#undef ALL_LINGUAS
#undef GNOME_ICONDIR
#undef GETTEXT_PACKAGE
......@@ -204,6 +204,12 @@ src/Makefile
src/gcompris/Makefile
src/boards/Makefile
src/boards/python/Makefile
src/boards/python/gcompris/Makefile
src/boards/python/gcompris/bonus/Makefile
src/boards/python/gcompris/score/Makefile
src/boards/python/gcompris/sound/Makefile
src/boards/python/gcompris/timer/Makefile
src/boards/python/gcompris/utils/Makefile
po/Makefile.in
docs/Makefile
docs/C/Makefile
......
#! /bin/sh
# Common stub for a few missing GNU programs while installing.
# Copyright (C) 1996, 1997 Free Software Foundation, Inc.
# Franc,ois Pinard <pinard@iro.umontreal.ca>, 1996.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
if test $# -eq 0; then
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
fi
case "$1" in
-h|--h|--he|--hel|--help)
echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]...
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
error status if there is no known handling for PROGRAM.
Options:
-h, --help display this help and exit
-v, --version output version information and exit
Supported PROGRAM values:
aclocal touch file \`aclocal.m4'
autoconf touch file \`configure'
autoheader touch file \`config.h.in'
automake touch all \`Makefile.in' files
bison create \`y.tab.[ch]', if possible, from existing .[ch]
flex create \`lex.yy.c', if possible, from existing .c
lex create \`lex.yy.c', if possible, from existing .c
makeinfo touch the output file
yacc create \`y.tab.[ch]', if possible, from existing .[ch]"
;;
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
echo "missing - GNU libit 0.0"
;;
-*)
echo 1>&2 "$0: Unknown \`$1' option"
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
;;
aclocal)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`acinclude.m4' or \`configure.in'. You might want
to install the \`Automake' and \`Perl' packages. Grab them from
any GNU archive site."
touch aclocal.m4
;;
autoconf)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`configure.in'. You might want to install the
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
archive site."
touch configure
;;
autoheader)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`acconfig.h' or \`configure.in'. You might want
to install the \`Autoconf' and \`GNU m4' packages. Grab them
from any GNU archive site."
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' configure.in`
test -z "$files" && files="config.h"
touch_files=
for f in $files; do
case "$f" in
*:*) touch_files="$touch_files "`echo "$f" |
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
*) touch_files="$touch_files $f.in";;
esac
done
touch $touch_files
;;
automake)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`Makefile.am', \`acinclude.m4' or \`configure.in'.
You might want to install the \`Automake' and \`Perl' packages.
Grab them from any GNU archive site."
find . -type f -name Makefile.am -print |
sed 's/\.am$/.in/' |
while read f; do touch "$f"; done
;;
bison|yacc)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified a \`.y' file. You may need the \`Bison' package
in order for those modifications to take effect. You can get
\`Bison' from any GNU archive site."
rm -f y.tab.c y.tab.h
if [ $# -ne 1 ]; then
eval LASTARG="\${$#}"
case "$LASTARG" in
*.y)
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" y.tab.c
fi
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" y.tab.h
fi
;;
esac
fi
if [ ! -f y.tab.h ]; then
echo >y.tab.h
fi
if [ ! -f y.tab.c ]; then
echo 'main() { return 0; }' >y.tab.c
fi
;;
lex|flex)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified a \`.l' file. You may need the \`Flex' package
in order for those modifications to take effect. You can get
\`Flex' from any GNU archive site."
rm -f lex.yy.c
if [ $# -ne 1 ]; then
eval LASTARG="\${$#}"
case "$LASTARG" in
*.l)
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" lex.yy.c
fi
;;
esac
fi
if [ ! -f lex.yy.c ]; then
echo 'main() { return 0; }' >lex.yy.c
fi
;;
makeinfo)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified a \`.texi' or \`.texinfo' file, or any other file
indirectly affecting the aspect of the manual. The spurious
call might also be the consequence of using a buggy \`make' (AIX,
DU, IRIX). You might want to install the \`Texinfo' package or
the \`GNU make' package. Grab either from any GNU archive site."
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
if test -z "$file"; then
file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
fi
touch $file
;;
*)
echo 1>&2 "\
WARNING: \`$1' is needed, and you do not seem to have it handy on your
system. You might have modified some files without having the
proper tools for further handling them. Check the \`README' file,
it often tells you about the needed prerequirements for installing
this package. You may also peek at any GNU archive site, in case
some other package would contain this missing \`$1' program."
exit 1
;;
esac
exit 0
#! /bin/sh
# mkinstalldirs --- make directory hierarchy
# Author: Noah Friedman <friedman@prep.ai.mit.edu>
# Created: 1993-05-16
# Public domain
# $Id$
errstatus=0
for file
do
set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
shift
pathcomp=
for d
do
pathcomp="$pathcomp$d"
case "$pathcomp" in
-* ) pathcomp=./$pathcomp ;;
esac
if test ! -d "$pathcomp"; then
echo "mkdir $pathcomp"
mkdir "$pathcomp" || lasterr=$?
if test ! -d "$pathcomp"; then
errstatus=$lasterr
fi
fi
pathcomp="$pathcomp/"
done
done
exit $errstatus
# mkinstalldirs ends here
......@@ -55,7 +55,7 @@ static PyMethodDef PythonGcomprisBonusModule[] = {
void python_gcompris_bonus_module_init(void)
{
PyObject* module;
module = Py_InitModule("gcompris.bonus", PythonGcomprisBonusModule);
module = Py_InitModule("_gcompris_bonus", PythonGcomprisBonusModule);
/* Misc constants */
PyModule_AddIntConstant(module, "TIME_CLICK_TO", TIME_CLICK_TO_BONUS );
......
......@@ -403,7 +403,8 @@ static PyMethodDef PythonGcomprisModule[] = {
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 );
......
......@@ -78,7 +78,7 @@ static PyMethodDef PythonGcomprisScoreModule[] = {
void python_gcompris_score_module_init(void)
{
PyObject* module;
module = Py_InitModule("gcompris.score", PythonGcomprisScoreModule);
module = Py_InitModule("_gcompris_score", PythonGcomprisScoreModule);
/* Misc constants */
PyModule_AddIntConstant(module, "STYLE_NOTE", SCORESTYLE_NOTE );
......
......@@ -90,7 +90,7 @@ static PyMethodDef PythonGcomprisSoundModule[] = {
void python_gcompris_sound_module_init(void)
{
PyObject* module;
module = Py_InitModule("gcompris.sound", PythonGcomprisSoundModule);
module = Py_InitModule("_gcompris_sound", PythonGcomprisSoundModule);
}
/* Some usefull code parts ... */
......
......@@ -136,7 +136,7 @@ static PyMethodDef PythonGcomprisTimerModule[] = {
void python_gcompris_timer_module_init(void)
{
PyObject* module;
module = Py_InitModule("gcompris.timer", PythonGcomprisTimerModule);
module = Py_InitModule("_gcompris_timer", PythonGcomprisTimerModule);
/* TimerList constants */
PyModule_AddIntConstant(module, "TEXT", GCOMPRIS_TIMER_TEXT );
......
......@@ -262,7 +262,7 @@ static PyMethodDef PythonGcomprisUtilsModule[] = {
void python_gcompris_utils_module_init(void)
{
PyObject* module;
module = Py_InitModule("gcompris.utils", PythonGcomprisUtilsModule);
module = Py_InitModule("_gcompris_utils", PythonGcomprisUtilsModule);
}
/* Some usefull code parts ... */
......
......@@ -21,6 +21,7 @@
#include <pygobject.h>
#include "gcompris/gcompris.h"
#include "py-gcompris-board.h"
#include "py-mod-gcompris.h"
static GcomprisBoard *gcomprisBoard = NULL;
static PyObject* python_gcomprisBoard = NULL;
......@@ -133,7 +134,6 @@ void pythonboard_start (GcomprisBoard *agcomprisBoard){
PySys_SetArgv(1, python_args);
init_pygobject();
python_gcompris_module_init();
main_module = PyImport_AddModule("__main__");
globals = PyModule_GetDict(main_module);
......@@ -149,9 +149,15 @@ void pythonboard_start (GcomprisBoard *agcomprisBoard){
boarddir = g_strdup_printf("import sys; sys.path.append('%s/python')",PLUGIN_DIR);
PyRun_SimpleString(boarddir);
g_free(boarddir);
/* Load the gcompris modules */
python_gcompris_module_init();
/* Python is now initialized we create some usefull variables */
boardfunction = g_strdup_printf("%s_start", agcomprisBoard->name);
/* Run an interactive python command line for debugging purposes */
// PyRun_InteractiveLoop(stdin, NULL);
/* Insert the board module into the python's interpreter */
python_board_module = PyImport_ImportModuleEx(agcomprisBoard->name,
......@@ -233,8 +239,7 @@ gboolean pythonboard_is_our_board (GcomprisBoard *agcomprisBoard){
return TRUE;
}
}
return FALSE;
return FALSE;
}
/*
......
SUBDIRS=gcompris
pythondir = $(plugindir)/python
dist_python_DATA= \
......
SUBDIRS=utils score bonus timer sound
pythondir = $(plugindir)/python/gcompris
dist_python_DATA= \
__init__.py
pythondir = $(plugindir)/python/gcompris/bonus
dist_python_DATA= \
__init__.py
pythondir = $(plugindir)/python/gcompris/score
dist_python_DATA= \
__init__.py
pythondir = $(plugindir)/python/gcompris/sound
dist_python_DATA= \
__init__.py
pythondir = $(plugindir)/python/gcompris/timer
dist_python_DATA= \
__init__.py
pythondir = $(plugindir)/python/gcompris/utils
dist_python_DATA= \
__init__.py
......@@ -2,6 +2,12 @@
import gnome
import gnome.canvas
import gcompris
import gcompris.utils
cercle = 0
print dir(gcompris)
print dir(gcompris.utils)
def img_selected(image):
print("img selected")
......@@ -22,16 +28,30 @@ def pythontest_start():
gcomprisBoard.number_of_sublevel=1
gcompris.bar_set(0)
gcompris.set_background(gcomprisBoard.canvas.root(),
"gcompris/nur00523.jpg")
gcompris.utils.image_to_skin("gcompris-bg.jpg"))
gcompris.bar_set_level(gcomprisBoard)
gcompris.images_selector_start(gcomprisBoard,
"%s%s" % (gcompris.DATA_DIR, "/dataset/mrpatate.xml"),
img_selected)
global cercle
cercle = gcomprisBoard.canvas.root().add(
gnome.canvas.CanvasEllipse,
x1=0.0,
y1=0.0,
x2=100.0,
y2=100.0,
fill_color='red',
outline_color='white',
width_units=1.0
)
print("pythontest start.")
def pythontest_end():
"""Gcompris board end function.
The python equivalent of the C function:
void end_board();
"""
cercle.destroy()
print("pythontest end.")
def pythontest_ok():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment