Commit c82cdc58 authored by Bruno Coudoin's avatar Bruno Coudoin

By Yves and Bruno. Added 2 options to allow gcompris to be used with an external

	directory containing a complete independant activity. For e.g.
	gcompris -L /home/user/myboard  => add the activities in this dir to gcompris
	gcompris -l /reading            => run gcompris directly in the reading activity set
parent 3c129ea2
2005-04-11 Bruno coudoin <bruno.coudoin@free.fr>
By Yves and Bruno. Added 2 options to allow gcompris to be used with an external
directory containing a complete independant activity. For e.g.
gcompris -L /home/user/myboard => add the activities in this dir to gcompris
gcompris -l /reading => run gcompris directly in the reading activity set
* README: update to point the the boards/gletters/README
* boards/boardicons/connect4.png:
* boards/connect4.xml.in: changed to use the icon already in the game
* docs/C/python.html: updated
* docs/C/python.xml: -
* po/POTFILES.in: updated
* src/boards/py-mod-gcompris.c: (python_gcompris_module_init):
* src/boards/python.c: (pythonboard_start):
* src/boards/python/anim.py:
* src/gcompris/about.c: (gcompris_about_start):
* src/gcompris/bar.c: (gcompris_bar_set_level), (gcompris_bar_set):
* src/gcompris/board.c: (board_play), (board_stop):
* src/gcompris/bonus.c: (board_finished), (gcompris_display_bonus):
* src/gcompris/gameutil.c: (gcompris_load_pixmap),
(gcompris_get_board_from_section), (gcompris_load_menus_dir),
(gcompris_load_menus):
* src/gcompris/gcompris-board.h:
* src/gcompris/gcompris.c: (setup_window), (gcompris_init):
* src/gcompris/images_selector.c: (parseImage):
* src/gcompris/properties.c: (gcompris_properties_new):
* src/gcompris/properties.h:
2005-04-10 Bruno coudoin <bruno.coudoin@free.fr>
New sounds package for Swedish
......
......@@ -62,3 +62,6 @@ It is best to choose somebody that speaks and articulate well your language.
What is great with GCompris is that you can use it to practice a foreign
language.
For the falling letters activity, there is a special directory to look at in
boards/gletters/README.
It let you configure this activity for any 'non standard' keyboard.
<?xml version="1.0" encoding="UTF-8"?>
<GCompris>
<Board type="python:connect4" section="/boards/."
name="connect4" icon="boardicons/python.png"
name="connect4" icon="boardicons/connect4.png"
difficulty="2" boarddir="connect4"
author="Laurent Lacheny (laurent.lacheny@wanadoo.fr)">
<_title>Connect 4</_title>
......@@ -11,4 +11,4 @@
<_manual>Click anywhere in the line in which you want to drop a piece</_manual>
<_credit>Laurent Lacheny. Images and Artificial Intelligence taken from project 4stattack by Jeroen Vloothuis. The original project can be found on http://forcedattack.sourceforge.net</_credit>
</Board>
</GCompris>
\ No newline at end of file
</GCompris>
This diff is collapsed.
......@@ -33,7 +33,7 @@ xsltproc -o python.html http://docbook.sourceforge.net/release/xsl/current/html/
<date>January 2004</date>
</revision>
<revision>
<revnumber>0.3</revnumber>
<revnumber>0.4</revnumber>
<date>January 2005</date>
</revision>
</revhistory>
......
......@@ -202,6 +202,7 @@ src/boards/traffic.c
src/boards/wordsgame.c
src/gcompris/about.c
src/gcompris/board.c
src/gcompris/bonus.c
src/gcompris/config.c
src/gcompris/file_selector.c
src/gcompris/gameutil.c
......
......@@ -620,7 +620,6 @@ static PyMethodDef PythonGcomprisModule[] = {
{ NULL, NULL, 0, NULL}
};
void python_gcompris_module_init(void)
{
PyObject* gcomprisModule;
......@@ -682,7 +681,8 @@ void python_gcompris_module_init(void)
PyModule_AddIntConstant(gcomprisModule, "CURSOR_DEFAULT", GCOMPRIS_DEFAULT_CURSOR);
/* Some non gcompris.h constants. */
PyModule_AddStringConstant(gcomprisModule, "DATA_DIR", PACKAGE_DATA_DIR);
GcomprisProperties *properties = gcompris_get_properties();
PyModule_AddStringConstant(gcomprisModule, "DATA_DIR", properties->package_data_dir);
/* GetText constants. */
PyModule_AddStringConstant(gcomprisModule, "GETTEXT_PACKAGE", GETTEXT_PACKAGE);
......
......@@ -201,13 +201,17 @@ pythonboard_start (GcomprisBoard *agcomprisBoard){
/* Add the python plugins dir to the python's search path */
#ifndef DISABLE_USER_PLUGIN_DIR
userplugindir = g_strconcat(g_get_home_dir(), "/.gcompris/Plugins/", NULL);
boarddir = g_strdup_printf("import sys; sys.path.append('%s/python'); sys.path.append('%s')",
userplugindir, PYTHON_PLUGIN_DIR);
boarddir = g_strdup_printf("import sys; sys.path.append('%s/python'); sys.path.append('%s'); sys.path.append('%s')",
userplugindir,
PYTHON_PLUGIN_DIR,
gcomprisBoard->board_dir);
#else
boarddir = g_strdup_printf("import sys; sys.path.append('%s')",PYTHON_PLUGIN_DIR );
#endif
PyRun_SimpleString(boarddir);
g_free(boarddir);
#ifndef DISABLE_USER_PLUGIN_DIR
g_free(userplugindir);
#endif
......
......@@ -2360,7 +2360,7 @@ def list_restore(picklelist):
list_images = list_images + im + '\n'
gcompris.utils.dialog(_('Warning: the following images cannot be accessed on your system.\n') +
list_images +
_('The corresponding items have been skiped.'),
_('The corresponding items have been skipped.'),
None)
fles.list_z_last_shot= []
for item in fles.framelist:
......
/* gcompris - about.c
*
* Time-stamp: <2005/02/13 11:59:55 bruno>
* Time-stamp: <2005/04/10 16:48:33 bruno>
*
* Copyright (C) 2000 Bruno Coudoin
*
......@@ -249,7 +249,7 @@ void gcompris_about_start ()
// License
item = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
gnome_canvas_text_get_type (),
"text", _("This software is a GNU Package and is released under the GNU Public License"),
"text", _("This software is a GNU Package and is released under the GNU General Public License"),
"font", gcompris_skin_font_content,
"x", (double) BOARDWIDTH/2,
"y", (double) y - 80,
......
/* gcompris - bar.c
*
* Time-stamp: <2003/12/21 17:44:37 bcoudoin>
* Time-stamp: <2005/04/10 19:25:52 bruno>
*
* Copyright (C) 2000-2003 Bruno Coudoin
*
......@@ -317,7 +317,9 @@ void gcompris_bar_set_level(GcomprisBoard *gcomprisBoard)
{
str = g_strdup_printf("level%d.png", gcomprisBoard->level);
GcomprisProperties *properties = gcompris_get_properties();
pixmap = gcompris_load_skin_pixmap(str);
g_free(str);
/* Warning changing the image needs to update pixbuf_ref for the focus usage */
g_object_set_data (G_OBJECT (level_item), "pixbuf_ref", pixmap);
......@@ -355,6 +357,7 @@ gcompris_bar_set_repeat_icon (GdkPixbuf *pixmap)
void
gcompris_bar_set (const GComprisBarFlags flags)
{
GcomprisProperties *properties = gcompris_get_properties();
current_flags = flags;
......
......@@ -341,6 +341,7 @@ void board_play(GcomprisBoard *gcomprisBoard)
bp = gcomprisBoard->plugin;
set_current_gcompris_board(gcomprisBoard);
bp->start_board(gcomprisBoard);
bp_data->playing = TRUE;
return;
......@@ -362,9 +363,11 @@ void board_pause(void)
void board_stop(void)
{
/* If we are in the upper menu, no need to stop and restart it */
if (get_current_gcompris_board()->previous_board == NULL)
if (get_current_gcompris_board()->previous_board == NULL){
return;
}
if (bp_data->playing && get_current_board_plugin())
{
......@@ -378,6 +381,7 @@ void board_stop(void)
bp_data->paused = FALSE;
gcompris_end_board();
return;
}
bp_data->playing = FALSE;
......
......@@ -100,6 +100,8 @@ void end_board_finished() {
#define OFFSET 100
void board_finished(BoardFinishedList type) {
GcomprisBoard *gcomprisBoard = get_current_gcompris_board();
GcomprisProperties *properties = gcompris_get_properties();
int x,y;
GdkPixbuf *pixmap_door1 = NULL,*pixmap_door2 = NULL,*pixmap_tuxplane = NULL;
char * str = NULL;
......@@ -190,13 +192,15 @@ void board_finished(BoardFinishedList type) {
gdk_pixbuf_unref(pixmap_tuxplane);
board_finished_id = gtk_timeout_add (TUX_TIME_STEP, (GtkFunction) end_board_finished, NULL);
}
/* ==================================== */
void gcompris_display_bonus(BonusStatusList gamewon, BonusList bonus_id)
{
GcomprisBoard *gcomprisBoard = get_current_gcompris_board();
GcomprisProperties *properties = gcompris_get_properties();
gcompris_bar_hide(TRUE);
if (bonus_display_running)
......
/* gcompris - gameutil.c
*
* Time-stamp: <2005/02/16 22:11:28 bruno>
* Time-stamp: <2005/04/10 23:50:40 bruno>
*
* Copyright (C) 2000 Bruno Coudoin
*
......@@ -117,13 +117,19 @@ GdkPixbuf *gcompris_load_pixmap(char *pixmapfile)
{
gchar *filename;
GdkPixbuf *pixmap;
GcomprisProperties *properties = gcompris_get_properties();
/* Search it on the file system */
if (!g_path_is_absolute (pixmapfile))
filename = g_strdup_printf("%s/%s", PACKAGE_DATA_DIR, pixmapfile);
else
filename = pixmapfile;
if (!g_path_is_absolute (pixmapfile)) {
filename = g_strdup_printf("%s/%s", properties->package_data_dir, pixmapfile);
if (!g_file_test ((filename), G_FILE_TEST_EXISTS)) {
GcomprisBoard *gcomprisBoard = get_current_gcompris_board();
g_free(filename);
filename = g_strdup_printf("%s/%s", gcomprisBoard->board_dir, pixmapfile);
}
} else {
filename = strdup(pixmapfile);
}
if (!g_file_test ((filename), G_FILE_TEST_EXISTS)) {
char *str;
......@@ -140,6 +146,8 @@ GdkPixbuf *gcompris_load_pixmap(char *pixmapfile)
pixmap = gdk_pixbuf_new_from_file (filename, NULL);
g_free(filename);
if(!pixmap)
g_warning("Loading image returned a null pointer");
......@@ -575,11 +583,15 @@ GcomprisBoard *gcompris_get_board_from_section(gchar *section)
for(list = boards_list; list != NULL; list = list->next) {
GcomprisBoard *board = list->data;
g_warning("gcompris_get_board_from_section searching '%s' in board '%s'\n", section, board->section);
if( board->section && (strcmp (board->section, section) == 0))
{
g_warning("gcompris_get_board_from_section found '%s' in board '%s'\n", section, board->section);
return board;
}
}
g_warning("gcompris_get_board_from_section searching '%s' but NOT FOUND\n", section);
return NULL;
}
......@@ -643,25 +655,21 @@ void cleanup_menus() {
}
}
/* load all the menus xml files in the gcompris path
* into our memory structures.
/*
* gcompris_load_menus
*
* Load all the menu it can from the given dirname
*
*/
void gcompris_load_menus()
{
void gcompris_load_menus_dir(char *dirname){
struct dirent *one_dirent;
DIR *dir;
int n;
if(boards_list) {
cleanup_menus();
return;
}
/* Load the Pixpmaps directory file names */
dir = opendir(PACKAGE_DATA_DIR);
dir = opendir(dirname);
if (!dir) {
g_warning("gcompris_load_menus : no menu found in %s", PACKAGE_DATA_DIR);
g_warning("gcompris_load_menus : no menu found in %s", dirname);
} else {
while((one_dirent = readdir(dir)) != NULL) {
......@@ -670,7 +678,7 @@ void gcompris_load_menus()
gchar *filename;
filename = g_strdup_printf("%s/%s",
PACKAGE_DATA_DIR, one_dirent->d_name);
dirname, one_dirent->d_name);
if(!g_file_test(filename, G_FILE_TEST_IS_REGULAR)) {
g_free(filename);
......@@ -679,6 +687,7 @@ void gcompris_load_menus()
if(selectMenuXML(one_dirent->d_name)) {
gcomprisBoard = g_malloc0 (sizeof (GcomprisBoard));
gcomprisBoard->board_dir = dirname;
/* Need to be initialized here because gcompris_read_xml_file is used also to reread */
/* the locale data */
......@@ -694,8 +703,26 @@ void gcompris_load_menus()
}
}
closedir(dir);
}
/* load all the menus xml files in the gcompris path
* into our memory structures.
*/
void gcompris_load_menus()
{
GcomprisProperties *properties = gcompris_get_properties();
if(boards_list) {
cleanup_menus();
return;
}
gcompris_load_menus_dir(properties->package_data_dir);
if (properties->local_directory)
gcompris_load_menus_dir(properties->local_directory);
gcompris_get_menulist("/");
gcompris_get_menulist(properties->root_menu);
}
/* ======================================= */
......
/* gcompris - gcompris-board.h
*
* Time-stamp: <2004/06/18 00:26:05 bcoudoin>
* Time-stamp: <2005/04/10 22:33:24 bruno>
*
* Copyright (C) 2000 Bruno Coudoin
*
......@@ -32,6 +32,9 @@ struct _GcomprisBoard
gchar *type;
gboolean board_ready;
/* The directory from which it was started */
gchar *board_dir;
/* Board specific mode */
gchar *mode;
......
/* gcompris - gcompris.c
*
* Time-stamp: <2005/04/07 00:03:51 bruno>
* Time-stamp: <2005/04/10 20:00:49 bruno>
*
* Copyright (C) 2000-2003 Bruno Coudoin
*
......@@ -85,6 +85,10 @@ static int popt_aalias = FALSE;
static int popt_difficulty_filter = FALSE;
static int popt_debug = FALSE;
static int popt_noxrandr = FALSE;
/* <YC experimental local only options> */
static char *popt_root_menu = NULL;
static char *popt_local_activity = NULL;
/* </YC> */
static struct poptOption options[] = {
{"fullscreen", 'f', POPT_ARG_NONE, &popt_fullscreen, 0,
......@@ -107,6 +111,12 @@ static struct poptOption options[] = {
N_("Use the antialiased canvas (slower)."), NULL},
{"noxrandr", 'x', POPT_ARG_NONE, &popt_noxrandr, 0,
N_("Disable XRANDR (No screen resolution change)."), NULL},
/* <YC experimental local only options> */
{"root-menu", 'l', POPT_ARG_STRING, &popt_root_menu, 0,
N_("Run gcompris with local menu (e.g -l /reading will let you play only reading activity directory)"), NULL},
{"local-activity", 'L', POPT_ARG_STRING, &popt_local_activity, 0,
N_("Run gcompris with local activity directory added to menu"), NULL},
/* </YC> */
#ifndef WIN32
POPT_AUTOHELP
#endif
......@@ -571,8 +581,11 @@ static void setup_window ()
gcompris_load_mime_types();
/* Get and Run the root menu */
gcomprisBoardMenu = gcompris_get_board_from_section("/");
if(!board_check_file(gcomprisBoardMenu)) {
gcomprisBoardMenu = gcompris_get_board_from_section(properties->root_menu);
if(!gcomprisBoardMenu) {
g_warning("Couldn't find the board menu %s, or plugin execution error", properties->root_menu);
exit(1);
} else if(!board_check_file(gcomprisBoardMenu)) {
g_error("Couldn't find the board menu, or plugin execution error");
} else {
g_warning("Fine, we got the gcomprisBoardMenu, xml boards parsing went fine");
......@@ -896,6 +909,17 @@ gcompris_init (int argc, char *argv[])
properties->filter_style = GCOMPRIS_FILTER_EQUAL;
}
if (popt_root_menu){
g_warning("Using menu %s as root.", popt_root_menu);
properties->root_menu = g_strdup(popt_root_menu);
}
if (popt_local_activity){
g_warning("Adding local activies from %s.", popt_local_activity);
properties->local_directory = g_strdup(popt_local_activity);
}
poptFreeContext(pctx);
/*------------------------------------------------------------*/
......
/* gcompris - images_selector.c
*
* Time-stamp: <2005/03/01 00:27:18 bruno>
* Time-stamp: <2005/04/10 16:44:29 bruno>
*
* Copyright (C) 2000 Bruno Coudoin
*
......@@ -624,9 +624,9 @@ parseImage (xmlDocPtr doc, xmlNodePtr cur) {
}
if (havePathName && pathname[0] == '~'){
/* replace '~' by home dir */
pathname = g_strdup_printf("%s%s",g_get_home_dir(),pathname+1);
pathname = g_strdup_printf("%s%s",g_get_home_dir(), pathname+1);
if (!g_file_test ((pathname), G_FILE_TEST_IS_DIR)){
g_warning(_("ImageSet %s pathname home %s image not found. Skipping ImageSet...\n"), imageSetName, pathname);
g_warning(_("In ImageSet %s, home pathname %s is not found. Skipping ImageSet...\n"), imageSetName, pathname);
return;
}
havePathName = TRUE;
......@@ -661,7 +661,7 @@ parseImage (xmlDocPtr doc, xmlNodePtr cur) {
if(!g_file_test ((absolutepath), G_FILE_TEST_EXISTS) )
{
g_warning(_("ImageSet %s image not found. Skipping ImageSet...\n"), absolutepath);
g_warning(_("In ImageSet %s, an image is not found. Skipping ImageSet...\n"), absolutepath);
return;
}
......@@ -687,7 +687,7 @@ parseImage (xmlDocPtr doc, xmlNodePtr cur) {
/* or all files with a given suffix */
if (!g_file_test ((pathname), G_FILE_TEST_IS_DIR)){
g_warning(_("ImageSet %s directory %s not found. Skipping all the ImageSet...\n"), absolutepath, pathname);
g_warning(_("In ImageSet %s, directory %s is not found. Skipping all the ImageSet...\n"), absolutepath, pathname);
return;
}
imageset_directory = g_dir_open (pathname, 0, error);
......
/* gcompris - properties.c
*
* Time-stamp: <2005/03/29 00:58:14 bruno>
* Time-stamp: <2005/04/10 23:46:00 bruno>
*
* Copyright (C) 2000,2003 Bruno Coudoin
*
......@@ -120,7 +120,9 @@ GcomprisProperties *gcompris_properties_new ()
tmp->difficulty_max = 0;
tmp->filter_style = GCOMPRIS_FILTER_NONE; /* No difficulty filter by default */
tmp->difficulty_filter = 1; /* No difficulty filter by default */
tmp->root_menu = "/";
tmp->local_directory = NULL;
tmp->package_data_dir = PACKAGE_DATA_DIR;
home_dir = g_get_home_dir();
......
/* gcompris - properties.h
*
* Time-stamp: <2005/03/31 23:06:12 bruno>
* Time-stamp: <2005/04/10 23:53:34 bruno>
*
* Copyright (C) 2000 Bruno Coudoin
*
......@@ -34,6 +34,9 @@ typedef struct {
gint filter_style;
gint difficulty_filter;
gint difficulty_max;
gchar *root_menu;
gchar *local_directory;
gchar *package_data_dir;
gchar *locale;
gchar *skin;
gchar *key;
......@@ -49,20 +52,6 @@ void gcompris_properties_disable_board(gchar *boardName);
gboolean gcompris_properties_get_board_status(gchar *boardName);
void gcompris_write_boards_status();
/* private definitions */
typedef enum {
GCOMPRIS_PROP_MUSIC,
GCOMPRIS_PROP_FX,
GCOMPRIS_PROP_SCREENSIZE,
GCOMPRIS_PROP_TIMER,
GCOMPRIS_PROP_FULLSCREEN,
GCOMPRIS_PROP_LOCALE,
GCOMPRIS_PROP_SKIN,
GCOMPRIS_PROP_AUDIO,
GCOMPRIS_PROP_DIFFICULTY,
GCOMPRIS_PROP_FILTER_STYLE
} GcomprisTokenType;
#endif
/* Local Variables: */
......
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