Commit cd31974f authored by Bruno Coudoin's avatar Bruno Coudoin
Browse files

- Fixes several issue in src/boards/python.c. No more craches.

	- Prepared the login screen but empty for now
	- Renamed reread_xml by reread_menu
	- Now the noxrandr param is 'almost' persistant in the config file
	  'almost' because until you enter and quit the gcompris config
	  panel, it is not saved. This is very dangerous becaus after that
	  there is no way to put back xrander in since there is no --withxrandr
	  switch.
	  WARNING: This need more works !!
parent ee122043
2005-08-03 Bruno coudoin <bruno.coudoin@free.fr>
- Fixes several issue in src/boards/python.c. No more craches.
- Prepared the login screen but empty for now
- Renamed reread_xml by reread_menu
- Now the noxrandr param is 'almost' persistant in the config file
'almost' because until you enter and quit the gcompris config
panel, it is not saved. This is very dangerous becaus after that
there is no way to put back xrander in since there is no --withxrandr
switch.
WARNING: This need more works !!
* boards/login.xml.in:
* src/boards/python/login.py: Empty and unused for now
* boards/Makefile.am:
* boards/music/background/BachJSBrandenburgConcertNo2inFMajorBWV104
7mvmt1.ogg:
* boards/music/background/Bach_JS__Brandenburg_Concert_No_2_in_F_Ma
jor_BWV_1047_mvmt1.ogg:
* configure.in:
* po/Makefile.in.in:
* po/POTFILES.in:
* src/boards/py-gcompris-properties.c:
(pyGcomprisPropertiesType_getattr):
* src/boards/py-mod-admin.c: (py_board_run_next):
* src/boards/py-mod-gcompris.c:
(py_gcompris_get_board_from_section):
* src/boards/python.c: (get_pythonboards_list), (pythonboard_init):
* src/boards/python/Makefile.am:
* src/gcompris/Makefile.am:
* src/gcompris/board.c: (board_run_next_end), (board_run_next):
* src/gcompris/gameutil.c: (gcompris_load_menus):
* src/gcompris/gcompris.c: (setup_window), (gcompris_init):
* src/gcompris/properties.c: (gcompris_properties_new),
(gcompris_properties_save):
* src/gcompris/properties.h:
2005-07-31 Bruno coudoin <bruno.coudoin@free.fr>
Hopefully completed the user/group/profile edition.
......
......@@ -55,6 +55,7 @@ xml_in_files = \
imageid.xml.in \
imagename.xml.in \
leftright.xml.in \
login.xml.in \
maze.xml.in \
maze2DRelative.xml.in \
maze3D.xml.in \
......
<?xml version="1.0" encoding="UTF-8"?>
<GCompris>
<Board
name="login"
type="python:login"
section="none"
icon=""
author="">
<_title>GCompris login screen</_title>
<_description>Select or enter your name to log in GCompris</_description>
<_prerequisite></_prerequisite>
<_goal>By identifying in GCompris, we are able to provide specific reporting for each kids.</_goal>
<_manual xml:space="preserve">In order to activate the login screen, you must
first add users in the administration part of GCompris.
You access the administration part by running 'gcompris -a'.
In the administration, you can create different profiles. In each profiles
you can have a different set of users and select which activities are available to them.
To run Gcompris in a specific profile, you can run 'gcompris -p profile' where 'profile'
is the name of a profile as you created it in the administration.</_manual>
</Board>
</GCompris>
......@@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script.
AC_INIT(src/gcompris/gcompris.c)
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE(gcompris, 6.5.3)
AM_INIT_AUTOMAKE(gcompris, 7.0.0PRE1)
AM_CONFIG_HEADER(config.h)
AM_MAINTAINER_MODE
......
......@@ -21,7 +21,6 @@ SHELL = /bin/sh
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = ..
VPATH = @srcdir@
prefix = @prefix@
......@@ -32,22 +31,17 @@ localedir = $(libdir)/locale
gnulocaledir = $(datadir)/locale
gettextsrcdir = $(datadir)/glib-2.0/gettext/po
subdir = po
install_sh = @install_sh@
mkdir_p = @mkdir_p@
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
MKINSTALLDIRS = $(top_srcdir)/@MKINSTALLDIRS@
CC = @CC@
GENCAT = @GENCAT@
GMSGFMT = @GMSGFMT@
MSGFMT = @MSGFMT@
XGETTEXT = @XGETTEXT@
INTLTOOL_UPDATE = @INTLTOOL_UPDATE@
INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@
MSGMERGE = INTLTOOL_EXTRACT=$(INTLTOOL_EXTRACT) srcdir=$(srcdir) $(INTLTOOL_UPDATE) --gettext-package $(GETTEXT_PACKAGE) --dist
GENPOT = INTLTOOL_EXTRACT=$(INTLTOOL_EXTRACT) srcdir=$(srcdir) $(INTLTOOL_UPDATE) --gettext-package $(GETTEXT_PACKAGE) --pot
MSGMERGE = msgmerge
DEFS = @DEFS@
CFLAGS = @CFLAGS@
......@@ -60,7 +54,7 @@ COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS)
SOURCES =
POFILES = @POFILES@
GMOFILES = @GMOFILES@
DISTFILES = ChangeLog Makefile.in.in POTFILES.in \
DISTFILES = ChangeLog Makefile.in.in POTFILES.in $(GETTEXT_PACKAGE).pot \
$(POFILES) $(GMOFILES) $(SOURCES)
POTFILES = \
......@@ -77,13 +71,13 @@ INSTOBJEXT = @INSTOBJEXT@
.po.pox:
$(MAKE) $(GETTEXT_PACKAGE).pot
$(MSGMERGE) $< $(top_builddir)/po/$(GETTEXT_PACKAGE).pot -o $*pox
$(MSGMERGE) $< $(srcdir)/$(GETTEXT_PACKAGE).pot -o $*.pox
.po.mo:
$(MSGFMT) -o $@ $<
.po.gmo:
file=`echo $* | sed 's,.*/,,'`.gmo \
file=$(srcdir)/`echo $* | sed 's,.*/,,'`.gmo \
&& rm -f $$file && $(GMSGFMT) -o $$file $<
.po.cat:
......@@ -96,15 +90,20 @@ all: all-@USE_NLS@
all-yes: $(CATALOGS)
all-no:
$(GETTEXT_PACKAGE).pot: $(POTFILES)
$(GENPOT)
$(srcdir)/$(GETTEXT_PACKAGE).pot: $(POTFILES)
$(XGETTEXT) --default-domain=$(GETTEXT_PACKAGE) --directory=$(top_srcdir) \
--add-comments --keyword=_ --keyword=N_ \
--files-from=$(srcdir)/POTFILES.in \
&& test ! -f $(GETTEXT_PACKAGE).po \
|| ( rm -f $(srcdir)/$(GETTEXT_PACKAGE).pot \
&& mv $(GETTEXT_PACKAGE).po $(srcdir)/$(GETTEXT_PACKAGE).pot )
install: install-exec install-data
install-exec:
install-data: install-data-@USE_NLS@
install-data-no: all
install-data-yes: all
if test -n "$(MKINSTALLDIRS)"; then \
if test -r "$(MKINSTALLDIRS)"; then \
$(MKINSTALLDIRS) $(DESTDIR)$(datadir); \
else \
$(SHELL) $(top_srcdir)/mkinstalldirs $(DESTDIR)$(datadir); \
......@@ -118,7 +117,7 @@ install-data-yes: all
esac; \
lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
dir=$(DESTDIR)$$destdir/$$lang/LC_MESSAGES; \
if test -n "$(MKINSTALLDIRS)"; then \
if test -r "$(MKINSTALLDIRS)"; then \
$(MKINSTALLDIRS) $$dir; \
else \
$(SHELL) $(top_srcdir)/mkinstalldirs $$dir; \
......@@ -146,7 +145,7 @@ install-data-yes: all
fi; \
done
if test "$(PACKAGE)" = "glib"; then \
if test -n "$(MKINSTALLDIRS)"; then \
if test -r "$(MKINSTALLDIRS)"; then \
$(MKINSTALLDIRS) $(DESTDIR)$(gettextsrcdir); \
else \
$(SHELL) $(top_srcdir)/mkinstalldirs $(DESTDIR)$(gettextsrcdir); \
......@@ -170,18 +169,15 @@ uninstall:
rm -f $(DESTDIR)$(gnulocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE)$(INSTOBJEXT); \
rm -f $(DESTDIR)$(gnulocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE)$(INSTOBJEXT).m; \
done
if test "$(PACKAGE)" = "glib"; then \
rm -f $(DESTDIR)$(gettextsrcdir)/Makefile.in.in; \
fi
rm -f $(DESTDIR)$(gettextsrcdir)/po-Makefile.in.in
check: all
dvi info tags TAGS ID:
mostlyclean:
rm -f core core.* *.pox $(GETTEXT_PACKAGE).pot *.old.po cat-id-tbl.tmp
rm -f core core.* *.pox $(GETTEXT_PACKAGE).po *.old.po cat-id-tbl.tmp
rm -fr *.o
rm -f .intltool-merge-cache
clean: mostlyclean
......@@ -194,7 +190,7 @@ maintainer-clean: distclean
rm -f $(GMOFILES)
distdir = ../$(GETTEXT_PACKAGE)-$(VERSION)/$(subdir)
dist distdir: $(DISTFILES) $(GETTEXT_PACKAGE).pot
dist distdir: update-po $(DISTFILES)
dists="$(DISTFILES)"; \
for file in $$dists; do \
ln $(srcdir)/$$file $(distdir) 2> /dev/null \
......@@ -203,28 +199,19 @@ dist distdir: $(DISTFILES) $(GETTEXT_PACKAGE).pot
update-po: Makefile
$(MAKE) $(GETTEXT_PACKAGE).pot
tmpdir=`pwd`; \
cd $(srcdir); \
catalogs='$(CATALOGS)'; \
for cat in $$catalogs; do \
cat=`basename $$cat`; \
lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
mv $$lang.po $$lang.old.po; \
echo "$$lang:"; \
result="`$(MSGMERGE) -o $$tmpdir/$$lang.new.po $$lang`"; \
if $$result; then \
if cmp $(srcdir)/$$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
rm -f $$tmpdir/$$lang.new.po; \
else \
if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
:; \
else \
echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
rm -f $$tmpdir/$$lang.new.po; \
exit 1; \
fi; \
fi; \
if $(MSGMERGE) $$lang.old.po $(GETTEXT_PACKAGE).pot -o $$lang.po; then \
rm -f $$lang.old.po; \
else \
echo "msgmerge for $$cat failed!"; \
rm -f $$tmpdir/$$lang.new.po; \
rm -f $$lang.po; \
mv $$lang.old.po $$lang.po; \
fi; \
done
......
......@@ -109,6 +109,7 @@ boards/imagename/board3_0.xml.in
boards/imagename/board4_0.xml.in
boards/imagename/board5_0.xml.in
boards/imagename/board6_0.xml.in
boards/login.xml.in
boards/leftright.xml.in
boards/maze.xml.in
boards/maze2DRelative.xml.in
......
......@@ -136,8 +136,8 @@ pyGcomprisPropertiesType_getattr(pyGcomprisPropertiesObject *self, char *name)
return Py_False;
}
}
if(strcmp(name,"reread_xml")==0){
if(self->cdata->reread_xml){
if(strcmp(name,"reread_menu")==0){
if(self->cdata->reread_menu){
Py_INCREF(Py_True);
return Py_True;
} else {
......
......@@ -29,7 +29,6 @@ py_board_run_next (PyObject* self, PyObject* args)
/* Create and return the result */
Py_INCREF(Py_None);
return Py_None;
}
static PyObject*
......
......@@ -663,6 +663,24 @@ py_gcompris_get_properties(PyObject* self, PyObject* args)
return gcompris_new_pyGcomprisPropertiesObject(result);
}
/* GcomprisBoard *gcompris_get_board_from_section(gchar *section); */
static PyObject*
py_gcompris_get_board_from_section(PyObject* self, PyObject* args)
{
GcomprisBoard* result;
gchar *section;
/* Parse arguments */
if(!PyArg_ParseTuple(args, "s:gcompris_get_board_from_section", &section))
return NULL;
/* Call the corresponding C function */
result = gcompris_get_board_from_section(section);
/* Create and return the result */
return gcompris_new_pyGcomprisBoardObject(result);
}
/* Code stolen from PyGTK */
/* This bindings are available only in pygtk 2.6, a little bit too young for us. */
......@@ -1193,6 +1211,7 @@ static PyMethodDef PythonGcomprisModule[] = {
METH_VARARGS, "gcompris_file_selector_stop" },
{ "get_database", py_gcompris_get_database, METH_VARARGS, "gcompris_get_database" },
{ "get_properties", py_gcompris_get_properties, METH_VARARGS, "gcompris_get_properties" },
{ "get_board_from_section", py_gcompris_get_board_from_section, METH_VARARGS, "gcompris_get_board_from_section" },
{ "spawn_async", py_gcompris_spawn_async, METH_VARARGS|METH_KEYWORDS, "gcompris_spawn_sync" },
{ "child_watch_add", py_gcompris_child_watch_add, METH_VARARGS|METH_KEYWORDS, "gcompris_child_watch_add" },
{ "get_board_conf", py_gcompris_get_board_conf, METH_VARARGS, "gcompris_get_board_conf" },
......
......@@ -56,28 +56,28 @@ static gboolean pythonboard_is_ready = FALSE;
/* Description of this plugin */
static BoardPlugin menu_bp =
{
NULL,
NULL,
N_("Python Board"),
N_("Special board that embeds python into gcompris."),
"Olivier Samyn <osamyn@ulb.ac.be>",
pythonboard_init,
NULL,
NULL,
NULL,
pythonboard_start,
pythonboard_pause,
pythonboard_end,
pythonboard_is_our_board,
pythonboard_key_press,
pythonboard_ok,
pythonboard_set_level,
pythonboard_config,
pythonboard_repeat,
pythonboard_config_start,
pythonboard_config_stop
};
{
NULL,
NULL,
N_("Python Board"),
N_("Special board that embeds python into gcompris."),
"Olivier Samyn <osamyn@ulb.ac.be>",
pythonboard_init,
NULL,
NULL,
NULL,
pythonboard_start,
pythonboard_pause,
pythonboard_end,
pythonboard_is_our_board,
pythonboard_key_press,
pythonboard_ok,
pythonboard_set_level,
pythonboard_config,
pythonboard_repeat,
pythonboard_config_start,
pythonboard_config_stop
};
static BoardPlugin *bp_board = NULL;
......@@ -95,7 +95,8 @@ GET_BPLUGIN_INFO(python)
static GList *config_boards= NULL;
GList *get_pythonboards_list()
GList *
get_pythonboards_list()
{
GList *pythonboards_list = NULL;
GList *boards_list = gcompris_get_boards_list();
......@@ -127,15 +128,9 @@ pythonboard_init (GcomprisBoard *agcomprisBoard){
PyObject* py_boardclass_args;
PyObject* py_config_start;
GcomprisBoard *board;
GList *list;
if (pythonboard_is_ready)
return ;
config_boards = get_pythonboards_list();
/* Initialize the python interpreter */
Py_Initialize();
......@@ -153,7 +148,7 @@ pythonboard_init (GcomprisBoard *agcomprisBoard){
#ifndef DISABLE_USER_PLUGIN_DIR
userplugindir = g_strconcat(g_get_home_dir(), "/.gcompris/Plugins/", NULL);
execstr = g_strdup_printf("import sys; sys.path.append('%s/python'); sys.path.append('%s')",
userplugindir, PYTHON_PLUGIN_DIR);
userplugindir, PYTHON_PLUGIN_DIR);
g_free(userplugindir);
#else
execstr = g_strdup_printf("import sys; sys.path.append('%s')",PYTHON_PLUGIN_DIR );
......@@ -188,42 +183,48 @@ pythonboard_init (GcomprisBoard *agcomprisBoard){
if(PyRun_SimpleString(execstr)!=0){
pythonboard_is_ready = FALSE;
g_warning("! Python disabled: Cannot import gcompris modules\n");
}
else {
/* Load the gcompris modules */
python_gcompris_module_init();
} else {
GList *python_boards;
GList *list;
list = config_boards;
while (list != NULL){
board = (GcomprisBoard *) list->data;
/* Load the gcompris modules */
python_gcompris_module_init();
/* Get the list of python boards */
python_boards = get_pythonboards_list();
/* Search in the list each one with a config entry */
for(list = python_boards; list != NULL; list = list->next) {
GcomprisBoard *board = (GcomprisBoard *) list->data;
/* Python is now initialized we create some usefull variables */
board_file_name = strchr(board->type, ':')+1;
boardclass = g_strdup_printf("Gcompris_%s", board_file_name);
/* Python is now initialized we create some usefull variables */
board_file_name = strchr(board->type, ':')+1;
boardclass = g_strdup_printf("Gcompris_%s", board_file_name);
/* Insert the board module into the python's interpreter */
python_board_module = PyImport_ImportModuleEx(board_file_name,
globals,
globals,
NULL);
if(python_board_module!=NULL){
//printf("init: python_board_module ok \n");
/* Get the module dictionnary */
module_dict = PyModule_GetDict(python_board_module);
/* Insert the board module into the python's interpreter */
python_board_module = PyImport_ImportModuleEx(board_file_name,
globals,
globals,
NULL);
if(python_board_module!=NULL){
/* Get the module dictionnary */
module_dict = PyModule_GetDict(python_board_module);
/* Get the python board class */
py_boardclass = PyDict_GetItemString(module_dict, boardclass);
list = list->next;
if (!PyObject_HasAttrString( py_boardclass, "config_start")){
config_boards = g_list_remove(config_boards, board);
g_free(boardclass);
/* Get the python board class */
py_boardclass = PyDict_GetItemString(module_dict, boardclass);
if (PyObject_HasAttrString( py_boardclass, "config_start")) {
config_boards = g_list_append(config_boards, board);
g_warning("The board '%s' has a configuration entry",
board_file_name);
}
}
g_free(boardclass);
}
}
g_list_free(python_boards);
}
}
}
......
......@@ -12,6 +12,7 @@ dist_python_DATA= \
followline.py \
gnumch.py \
hexagon.py \
login.py \
melody.py \
pythontest.py \
redraw.py \
......
# gcompris - login
#
# Time-stamp: <2001/08/20 00:54:45 bruno>
#
# Copyright (C) 2005 Bruno Coudoin
#
# 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 of the License, 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
#
import gnome
import gnome.canvas
import gcompris
import gcompris.utils
import gcompris.skin
import gtk
import gtk.gdk
from gettext import gettext as _
# Background screens
backgrounds = [
"images/scenery2_background.png",
"images/scenery3_background.png",
"images/scenery4_background.png",
"images/scenery5_background.png",
"images/scenery6_background.png"
]
class Gcompris_login:
"""Login screen for gcompris"""
def __init__(self, gcomprisBoard):
self.gcomprisBoard = gcomprisBoard
print("Gcompris_pythontest __init__.")
def start(self):
self.gcomprisBoard.level=1
self.gcomprisBoard.maxlevel=1
self.gcomprisBoard.sublevel=1
self.gcomprisBoard.number_of_sublevel=1
gcompris.bar_set(0)
gcompris.set_background(self.gcomprisBoard.canvas.root(),
gcompris.utils.load_pixmap(backgrounds[self.gcomprisBoard.level-1]))
gcompris.bar_set_level(self.gcomprisBoard)
# Create our rootitem. We put each canvas item in it so at the end we
# only have to kill it. The canvas deletes all the items it contains automaticaly.
self.rootitem = self.gcomprisBoard.canvas.root().add(
gnome.canvas.CanvasGroup,
x=0.0,
y=0.0
)
print("Gcompris_pythontest start.")
def end(self):
# Remove the root item removes all the others inside it
self.rootitem.destroy()
def ok(self):
print("Gcompris_pythontest ok.")
def repeat(self):
print("Gcompris_pythontest repeat.")
def config(self):
print("Gcompris_pythontest config.")
def key_press(self, keyval):
print("Gcompris_pythontest key press. %i" % keyval)
# Return True if you did process a key
# Return False if you did not processed a key
# (gtk need to send it to next widget)
return False
def pause(self, pause):
print("Gcompris_pythontest pause. %i" % pause)
def set_level(self, level):
print("Gcompris_pythontest set level. %i" % level)
# ---- End of Initialisation
......@@ -15,17 +15,17 @@ sqlite_ldflags =
sqlite_cflags =
endif
if USE_CAIRO
cairo_ldflags = $(CAIRO_LIBS)
cairo_cflags = $(CAIRO_CFLAGS)
cairo_h = gcompris-cairo.h
cairo_c = gcompris-cairo.c
else
cairo_ldflags =
cairo_cflags =
cairo_h =
cairo_c =
endif
#if USE_CAIRO
#cairo_ldflags = $(CAIRO_LIBS)
#cairo_cflags = $(CAIRO_CFLAGS)
#cairo_h = gcompris-cairo.h
#cairo_c = gcompris-cairo.c
#else
#cairo_ldflags =
#cairo_cflags =
#cairo_h =
#cairo_c =
#endif
if PLATFORM_WIN32
no_undefined = -no-undefined
......
......@@ -395,14 +395,29 @@ gboolean get_board_paused(void)
return bp_data->paused;
}
void board_run_next(GcomprisBoard *board)
static GcomprisBoard *next_board = NULL;
static gint next_board_callback_id = 0;
#define NEXT_TIME_DELAY 10
void board_run_next_end()
{
gtk_timeout_remove(next_board_callback_id);
next_board_callback_id = 0;
if (next_board->previous_board->plugin->end_board)
next_board->previous_board->plugin->end_board();