diff options
author | Yves Combe <ycombe@src.gnome.org> | 2006-11-09 09:53:06 (GMT) |
---|---|---|
committer | Yves Combe <ycombe@src.gnome.org> | 2006-11-09 09:53:06 (GMT) |
commit | a9b4f53ad3f94c572f02b1351ccda8dcc4b5bb46 (patch) | |
tree | 1b418bdd3fd4ea7369b2b28457d3753189bca7a5 | |
parent | df642cc058ca8a81a780b0787040d085198148a3 (diff) |
Landing of GCOMPRIS_8_2_CROSSCOMPIL branch.
Allow cross compilation for win32 with mingw/Linux.
Use GLib functions instead of unix one .
Adapt Tuxpaint launcher to make it work on Windows.
67 files changed, 1003 insertions, 633 deletions
@@ -1,3 +1,83 @@ +2006-11-09 Yves Combe <yves@ycombe.net> + + Landing of GCOMPRIS_8_2_CROSSCOMPIL branch. + Allow cross compilation for win32 with mingw/Linux. + Use GLib functions instead of unix one . + + Adapt Tuxpaint launcher to make it work on Windows. + + * Makefile.am: + * Makefile.mingw.in: + * README.mingw-cross: + * acinclude.m4: + * configure.in: + * cross-configure.sh: + * cross-make.sh: + * gcompris-installer.nsi.in: + * po/Makefile.in.in: + * src/boards/Makefile.am: + * src/boards/Makefile.mingw: + * src/boards/advanced_colors.c: (colors_next_level), + (colors_create_item): + * src/boards/algebra.c: (get_operand), (get_random_number): + * src/boards/algebra_guesscount.c: (generate_numbers): + * src/boards/awele.c: (initBoardGraphics), (updateNbBeans): + * src/boards/awele_alphaBeta.c: (firstChild): + * src/boards/awele_utils.c: (randplay): + * src/boards/click_on_letter.c: (click_on_letter_create_item): + * src/boards/clickgame.c: (clickgame_create_item), (game_won): + * src/boards/clockgame.c: (get_random_hour): + * src/boards/colors.c: (start_board): + * src/boards/crane.c: (shuffle_list): + * src/boards/enumerate.c: (enumerate_create_item): + * src/boards/erase.c: (shuffle_image_list): + * src/boards/fifteen.c: (scramble): + * src/boards/gletters.c: (gletters_create_item): + * src/boards/gtans.c: + * src/boards/gtans_support.c: (check_file_exists): + * src/boards/hanoi.c: (hanoi_create_item): + * src/boards/imageid.c: (imageid_create_item): + * src/boards/leftright.c: (leftright_create_item): + * src/boards/machpuzzle.c: (minigolf_create_item): + * src/boards/magic_hat.c: (magic_hat_create_item): + * src/boards/maze.c: (maze_next_level), (generateMaze): + * src/boards/memory.c: (get_random_token), (get_image), (tux_play): + * src/boards/missingletter.c: (missing_letter_create_item): + * src/boards/money.c: (money_next_level): + * src/boards/paratrooper.c: (paratrooper_next_level), + (paratrooper_create_cloud): + * src/boards/planegame.c: (planegame_create_item): + * src/boards/py-mod-gcompris.c: (py_gcompris_child_watch_add), + (py_gcompris_spawn_async): + * src/boards/python/tuxpaint.py: + * src/boards/railroad.c: (railroad_create_item): + * src/boards/read_colors.c: (start_board): + * src/boards/reading.c: (display_what_to_do): + * src/boards/reversecount.c: (display_random_fish): + * src/boards/shapegame.c: (parse_doc): + * src/boards/smallnumbers.c: (smallnumbers_create_item): + * src/boards/submarine.c: (submarine_create_item): + * src/boards/superbrain.c: (superbrain_next_level): + * src/boards/target.c: (display_windspeed): + * src/boards/wordsgame.c: (wordsgame_create_item): + * src/gcompris/Makefile.am: + * src/gcompris/Makefile.mingw: + * src/gcompris/binreloc.c: (_br_find_exe): + * src/gcompris/board.c: (gc_board_pause): + * src/gcompris/board.h: + * src/gcompris/bonus.c: (gc_bonus_display), (bonus_image): + * src/gcompris/file_selector.c: (parse_doc): + * src/gcompris/gameutil.c: (gc_util_create_rootdir): + * src/gcompris/gameutil.h: + * src/gcompris/gcompris.c: (activation_done), (load_properties), + (gc_init): + * src/gcompris/gcompris_db.c: (gc_db_init): + * src/gcompris/images_selector.c: (parse_doc): + * src/gcompris/menu.c: (gc_menu_load): + * src/gcompris/properties.c: (gc_prop_user_root_directory_get), + (gc_prop_config_file_get), (gc_prop_new): + * src/gcompris/sdlplayer.c: (errorv): + 2006-11-07 Bruno coudoin <bruno.coudoin@free.fr> - Removed unused `no_undefined' diff --git a/Makefile.am b/Makefile.am index 9653892..f2c6a00 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,22 +1,36 @@ ## Process this file with automake to produce Makefile.in +if !BUILD_MINGW32 if TEXINFO DOCS_SUBDIR=docs else DOCS_SUBDIR= endif +else +DOCS_SUBDIR= +endif SUBDIRS = po src boards $(DOCS_SUBDIR) autopackage icondir=$(datadir)/pixmaps icon_DATA = gcompris.png gcompris-edit.png +if BUILD_MINGW32 +Applicationsdir = $(datadir)/ +Applications_in_files = +Applications_DATA = + +Menudir=$(prefix) +Menu_DATA= + +else Applicationsdir = $(datadir)/applications/ Applications_in_files = gcompris.desktop.in gcompris-edit.desktop.in Applications_DATA = gcompris.desktop gcompris-edit.desktop Menudir=$(prefix)/lib/menu Menu_DATA=gcompris +endif @INTLTOOL_DESKTOP_RULE@ diff --git a/Makefile.mingw.in b/Makefile.mingw.in index 0864473..a2ee05d 100644 --- a/Makefile.mingw.in +++ b/Makefile.mingw.in @@ -18,7 +18,7 @@ LIBXML2_TOP := /libxml2 SDL_TOP := /sdl CANVAS_TOP := /gnomecanvas GNUCHESS_TOP := /gnuchess -PYTHON_DLL := /c/WINDOWS/system32/python24.dll +PYTHON_TOP := /c/WINDOWS/system32/python24.dll GNUCAP_TOP := /gnucap MAKENSIS := "/c/Program Files/NSIS/makensis.exe" @@ -26,7 +26,7 @@ MAKENSIS := "/c/Program Files/NSIS/makensis.exe" # These will be copied in the win32-install-dir ready to be packaged. NEEDED_DLLS = $(GNUCHESS_TOP)/bin/pthreadGC.dll \ $(GNUCHESS_TOP)/bin/libreadline.dll \ - $(PYTHON_DLL) \ + $(PYTHON_TOP)/python24.dll \ $(GNUCAP_TOP)/src/MSW/gnucap.exe \ $(GTK_TOP)/bin/gspawn-win32-helper.exe \ $(GNUCHESS_TOP)/bin/gnuchess.exe \ @@ -136,7 +136,7 @@ prep: @echo "Copy pixmap" mkdir $(GCOMPRIS_INSTALL_DIR)/share/pixmaps cp gcompris.png $(GCOMPRIS_INSTALL_DIR)/share/pixmaps - @echo remove tuxpaint activity + @remove tuxpaint activity rm -f $(GCOMPRIS_INSTALL_DIR)/share/$(pkgdatadir)/boards/tuxpaint.xml @echo "Create the file gcompris-win-prepack.tar.gz" tar -czf gcompris-win-prepack.tar.gz win32-install-dir nsis tools diff --git a/README.mingw-cross b/README.mingw-cross new file mode 100644 index 0000000..e824f87 --- /dev/null +++ b/README.mingw-cross @@ -0,0 +1,39 @@ +How to cross compile GCompris for windows with mingw on GNU/Linux + +You need: +======== +You need cross version of mingw, wich is available in all good distribution. +You have to install all mingw/windows version of your dev librairies somewhere. +You have to adapt cross-configure.sh with the places where you put this libs. + +The scripts: +============ +There is two script: cross-configure.sh and cross-make.sh. They are stolen from libsdl version: http://www.libsdl.org/extras/win32/cross/README.txt + +You can use them as configure and make, but you need to adapt them in your configuration. cross-configure.sh has a couple of lines for each library. +Check TARGET too, TARGET is used tu set name of your compilators (gcc is i586-mingw32msvc-gcc when TARGET=i586-mingw32msvc) + +You have to set the PREFIX in cross-configure.sh to indicate where to install all the stuff. + +Library warning +=============== +You need lib*.a version of libraries if you want compile with -shared modules. You can make them from dll/def/lib using pexport/dlltool (i586-mingw32msvc-dlltool) if they are missing (e.g. sqlite.org gives only dll and def). +Read http://www.go-evolution.org/Building_Evolution_on_Windows#libxml2 for an exemple with libxml2 + +Libxml2 +======= +The windows dev version is missing pc file for pkg-config. +Read that: http://www.go-evolution.org/Building_Evolution_on_Windows#libxml2 +I have wrote a pc file for it : +-------------------------- +prefix=/home/ycombe/Win32/98/libxml2-2.6.26.win32 +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include + +Name: libXML +Version: 2.6.26 +Description: libXML library version 2. +Requires: +Libs: -L${libdir} -llibxml2 -lz +-------------------------- diff --git a/acinclude.m4 b/acinclude.m4 index a351e4d..9ea0a8e 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -43,18 +43,25 @@ AC_DEFUN([AM_CHECK_PYTHON_HEADERS], [AC_REQUIRE([AM_PATH_PYTHON]) AC_MSG_CHECKING(for headers required to compile python extensions) dnl deduce PYTHON_CFLAGS -py_prefix=`$PYTHON -c "import sys; print sys.prefix"` -py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"` -PYTHON_CFLAGS="-I${py_prefix}/include/python${PYTHON_VERSION}" -python_link=`$PYTHON -c "import distutils.sysconfig ; print distutils.sysconfig.get_config_var(\"LIBRARY\")" | sed -e "s%lib\(.*\)\.[[a-zA-Z]]*$%-l\1%"` +if test "x$PYTHON_CFLAGS" = "x" ; then + py_prefix=`$PYTHON -c "import sys; print sys.prefix"` + py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"` -python_libdir=`$PYTHON -c "import distutils.sysconfig ; print distutils.sysconfig.get_config_var(\"LIBDIR\")"` + PYTHON_CFLAGS="-I${py_prefix}/include/python${PYTHON_VERSION}" -PYTHON_LIBS="-L${python_libdir} ${python_link}" -if test "$py_prefix" != "$py_exec_prefix"; then - PYTHON_CFLAGS="$PYTHON_CFLAGS -I${py_exec_prefix}/include/python${PYTHON_VERSION}" + if test "$py_prefix" != "$py_exec_prefix"; then + PYTHON_CFLAGS="$PYTHON_CFLAGS -I${py_exec_prefix}/include/python${PYTHON_VERSION}" + fi +fi + +if test "x$PYTHON_LIBS" = "x" ; then + python_link=`$PYTHON -c "import distutils.sysconfig ; print distutils.sysconfig.get_config_var(\"LIBRARY\")" | sed -e "s%lib\(.*\)\.[[a-zA-Z]]*$%-l\1%"` + + python_libdir=`$PYTHON -c "import distutils.sysconfig ; print distutils.sysconfig.get_config_var(\"LIBDIR\")"` + + PYTHON_LIBS="-L${python_libdir} ${python_link}" fi AC_SUBST(PYTHON_CFLAGS) diff --git a/configure.in b/configure.in index 970efc8..9127739 100644 --- a/configure.in +++ b/configure.in @@ -63,10 +63,24 @@ AM_PROG_LIBTOOL dnl Check for SDL SDL_VERSION=1.2.3 -AM_PATH_SDL($SDL_VERSION, + +cflags_previous=$CFLAGS +libs_previous=$LIBS + +if test "x$SDL_CFLAGS" = "x" -o "x$SDL_LIBS" = "x" ; then + AM_PATH_SDL($SDL_VERSION, :, AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!]) -) + ) +else + AC_SUBST(SDL_CFLAGS) + AC_SUBST(SDL_LIBS) + echo "*** Not checking SDL. Using existing SDL_FLAGS and SDL_LIBS ***" +fi + +dnl RESTAURE PREVIOUSLY SET VALUES +CFLAGS=$cflags_previous +LIBS=$libs_previous dnl GNOME2 GNOME_X_CHECKS AM_PATH_GLIB_2_0 @@ -218,27 +232,55 @@ dnl dnl === DIRECTORY DEFINITIONS === dnl -dnl Set PACKAGE_LOCALE_DIR in config.h. -AC_DEFINE_UNQUOTED(PACKAGE_LOCALE_DIR, "${myprefix}/${DATADIRNAME}/locale", [GCompris locale directory]) +if test "x$platform_win32" = "xno" ; then -dnl Set PACKAGE_DATA_DIR -PACKAGE_DATA_DIR="boards" -AC_SUBST(PACKAGE_DATA_DIR) -AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${myprefix}/${DATADIRNAME}", [GCompris data directory]) + dnl Set PACKAGE_LOCALE_DIR in config.h. + AC_DEFINE_UNQUOTED(PACKAGE_LOCALE_DIR, "${myprefix}/${DATADIRNAME}/locale", [GCompris locale directory]) -dnl Set PACKAGE_HELP_DIR -PACKAGE_HELP_DIR="${myprefix}/${DATADIRNAME}/${PACKAGE}/help" -AC_SUBST(PACKAGE_HELP_DIR) + dnl Set PACKAGE_DATA_DIR + PACKAGE_DATA_DIR="boards" + AC_SUBST(PACKAGE_DATA_DIR) + AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${myprefix}/${DATADIRNAME}", [GCompris data directory]) -dnl Plugin Directory -my_libdir=`eval echo "${libdir}"` -AC_DEFINE_UNQUOTED(PACKAGE_CLIB_DIR, "${my_libdir}", [Gcompris plugins directory]) -plugindir=$libdir/gcompris -AC_SUBST(plugindir) + dnl Set PACKAGE_HELP_DIR + PACKAGE_HELP_DIR="${myprefix}/${DATADIRNAME}/${PACKAGE}/help" + AC_SUBST(PACKAGE_HELP_DIR) + + dnl Plugin Directory + my_libdir=`eval echo "${libdir}"` + AC_DEFINE_UNQUOTED(PACKAGE_CLIB_DIR, "${my_libdir}", [Gcompris plugins directory]) + plugindir=$libdir/gcompris + AC_SUBST(plugindir) + + dnl Python plugin Directory + PYTHON_PLUGIN_DIR="${myprefix}/${DATADIRNAME}/${PACKAGE}/python" + AC_SUBST(PYTHON_PLUGIN_DIR) + +else + DATADIRNAME="share" -dnl Python plugin Directory -PYTHON_PLUGIN_DIR="${myprefix}/${DATADIRNAME}/${PACKAGE}/python" -AC_SUBST(PYTHON_PLUGIN_DIR) + dnl Set PACKAGE_LOCALE_DIR in config.h for WINDOWS + AC_DEFINE_UNQUOTED(PACKAGE_LOCALE_DIR, "../${DATADIRNAME}/locale", [GCompris locale directory]) + + dnl Set PACKAGE_DATA_DIR + PACKAGE_DATA_DIR="boards" + AC_SUBST(PACKAGE_DATA_DIR) + AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "../${DATADIRNAME}", [GCompris data directory]) + + dnl Set PACKAGE_HELP_DIR + PACKAGE_HELP_DIR="${myprefix}/${DATADIRNAME}/gnome/help/gcompris" + AC_SUBST(PACKAGE_HELP_DIR) + + dnl Plugin Directory + AC_DEFINE_UNQUOTED(PACKAGE_CLIB_DIR, "../${DATADIRNAME}", [Gcompris plugins directory]) + plugindir=${myprefix}/${DATADIRNAME}/gcompris + AC_SUBST(plugindir) + + dnl Python plugin Directory + PYTHON_PLUGIN_DIR="${myprefix}/${DATADIRNAME}/gcompris/python" + AC_SUBST(PYTHON_PLUGIN_DIR) + +fi dnl Test for gnuchess AC_PATH_PROG(GNUCHESS, gnuchess,no,[/usr/bin:/usr/games:/usr/local/bin:$PATH]) @@ -295,6 +337,7 @@ else if test x$python_path != xnot ; then PYTHON=$python_path fi + AM_PATH_PYTHON(2.2) AM_CHECK_PYTHON_HEADERS( [build_python_plugin="yes"], [build_python_plugin="no"] ) @@ -342,10 +385,11 @@ else AC_MSG_WARN([py-build-only: Do not forget to install pygtk, pysqlite2]) fi - if test x$with_sqlite = xyes; then +fi + +if test x$with_sqlite = xyes; then PKG_CHECK_MODULES(SQLITE3, sqlite3,, AC_MSG_ERROR([*** SQLITE3 not found!])) AC_DEFINE([USE_SQLITE], 1,[SQLITE Database, Profiles are enabled]) - fi fi AM_CONDITIONAL(USE_SQLITE, test x$with_sqlite = xyes) @@ -455,7 +499,31 @@ AC_SUBST(VERSION_VOICES_SV) VERSION_VOICES_TR=1.0 AC_SUBST(VERSION_VOICES_TR) +dnl mingw32 specific stuff. +dnl use libgw32c +dnl define __GW32__ and WIN32 + +# Check platform - see if WinMain needed: +AC_MSG_CHECKING([for native Win32]) +case "$host" in + *-*-mingw*) + native_win32=yes + ;; + *) + native_win32=no + ;; +esac +AC_MSG_RESULT([$native_win32]) + +AM_CONDITIONAL(BUILD_MINGW32, test "$native_win32" = yes) +if test "$native_win32" = yes; then + LIBS="$LIBS -luuid -lole32 -lwsock32 -mno-cygwin -mms-bitfields -mwindows -mconsole" + #CFLAGS="$CFLAGS -D__GW32__ -DWIN32 -I$CROSS_ROOT/include -I$CROSS_ROOT/include/glibc" + #CFLAGS="$CFLAGS -DWIN32" +fi + AC_SUBST(CFLAGS) +AC_SUBST(LIBS) dnl Autoconf output AC_OUTPUT([ gcompris.spec diff --git a/cross-configure.sh b/cross-configure.sh new file mode 100755 index 0000000..9636549 --- /dev/null +++ b/cross-configure.sh @@ -0,0 +1,110 @@ +#!/bin/sh + +# adapted from http://www.libsdl.org/extras/win32/cross/README.txt + +CONFIG_SHELL=/bin/sh +export CONFIG_SHELL +TARGET=i586-mingw32msvc +CROSS_DEV=/home/ycombe/Win32/98 +PATH="$PATH:$CROSS_DEV/bin" +export PATH + +#PYTHON is copied from a windows install (with pygtk, pycairo, pysqlite) into: +# $CROSS_DEV/Python24/ + +######################################### +# Libs using pkg-config +# +# rem: for me libxml2 as and hand-written pc file +# +# PKG_CONFIG in cross-configuration. +PKG_CONFIG_LIBDIR="$CROSS_DEV/lib/pkgconfig:$CROSS_DEV/Python24/Lib/pkgconfig" + +DIRS="$(ls $CROSS_DEV)" + +# all my libs are in $CROSS_DEV/__libname__/ +# the *.pc files needs there prefix adapted +for f in $DIRS; do + if test -d $CROSS_DEV/$f/lib/pkgconfig ; then + PKG_CONFIG_LIBDIR="$PKG_CONFIG_LIBDIR:$CROSS_DEV/$f/lib/pkgconfig" ; + fi +done +# /PKG_CONFIG +######################################### + + +######################################### +# PYTHON +export PKG_CONFIG_LIBDIR +export PKG_CONFIG_PATH +PYTHONHOME="$CROSS_DEV/Python24" +PYTHONPATH="$CROSS_DEV/Python24/Lib" +PYTHON_CFLAGS="-I$CROSS_DEV/Python24/include" +PYTHON_LIBS="-L$CROSS_DEV/Python24/libs -lpython24" + +# GCompris configure will skip PYTHON_TEST if this is exported: +export PYTHONHOME +export PYTHONPATH +export PYTHON_CFLAGS +export PYTHON_LIBS +# /PYTHON +########################################## + +########################################## +# SDL and SDL_mixer +SDL_MIXER_CFLAGS="-I$CROSS_DEV/SDL_mixer/SDL_mixer-1.2.7/include" +SDL_MIXER_LDFLAGS="-L$CROSS_DEV/SDL_mixer/SDL_mixer-1.2.7/lib" +SDL_CFLAGS="-I$CROSS_DEV/SDL/SDL-1.2.11/include" +SDL_LIBS="-L$CROSS_DEV/SDL/SDL-1.2.11/lib -lSDLmain -lSDL" + +# GCompris configure will skip SDL_TEST if this is exported: +export SDL_CFLAGS +export SDL_LIBS + +CFLAGS="-g -O2 -I$CROSS_DEV/include $SDL_MIXER_CFLAGS" +LDFLAGS="-L$CROSS_DEV/lib $SDL_MIXER_LDFLAGS" +# /SDL and SDL_mixer +########################################### + +########################################### +# These libs do not use pkg-config ! + +# popt +CFLAGS="$CFLAGS -I$CROSS_DEV/popt/include" +LDFLAGS="$LDFLAGS -L$CROSS_DEV/popt/lib" + +# sqlite3 +CFLAGS="$CFLAGS -I$CROSS_DEV/sqlite/include" +LDFLAGS="$LDFLAGS -L$CROSS_DEV/sqlite/lib" +# /sqlite3 + +#libiconv +CFLAGS="$CFLAGS -I$CROSS_DEV/libiconv/include" +LDFLAGS="$LDFLAGS -L$CROSS_DEV/libiconv/lib" + +#gettext +CFLAGS="$CFLAGS -I$CROSS_DEV/gettext/include" +LDFLAGS="$LDFLAGS -L$CROSS_DEV/gettext/lib" + +#zlib +CFLAGS="$CFLAGS -I$CROSS_DEV/zlib/include" +LDFLAGS="$LDFLAGS -L$CROSS_DEV/zlib/lib" + +# LIBXML2 +# !!!!!! libxml2 if it does not hace pc file +# adapt CFLAGS +# adapt LDFLAGS + +############################################ + +cache=cross-config.cache +CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" sh configure --cache-file="$cache" \ + --target=$TARGET --host=$TARGET --build=i386-linux \ + --enable-py-build-only \ + --with-sdl-prefix="$CROSS_DEV/SDL/SDL-1.2.11" \ + --disable-binreloc \ + $* + +status=$? +rm -f "$cache" +exit $status diff --git a/cross-make.sh b/cross-make.sh new file mode 100755 index 0000000..9d99e43 --- /dev/null +++ b/cross-make.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# copied from http://www.libsdl.org/extras/win32/cross/README.txt + +PREFIX=/usr/local/cross-tools +TARGET=i386-mingw32msvc +PATH="$PREFIX/bin:$PREFIX/$TARGET/bin:$PATH" +export PATH +exec make $* diff --git a/gcompris-installer.nsi.in b/gcompris-installer.nsi.in index 1c662fa..49ab163 100644 --- a/gcompris-installer.nsi.in +++ b/gcompris-installer.nsi.in @@ -215,27 +215,32 @@ Section -SecUninstallOldGcompris StrCmp $R2 "" uninstall_problem ; Check if we have uninstall string.. IfFileExists $R3 0 uninstall_problem + ; Have uninstall string.. go ahead and uninstall. - MessageBox MB_YESNO "Uninstall your previous version of GCompris?" IDYES do_uninstall IDNO done - - do_uninstall: - ; Have uninstall string.. go ahead and uninstall. - SetOverwrite on - ; Need to copy uninstaller outside of the install dir - ClearErrors - CopyFiles /SILENT $R3 "$TEMP\${GCOMPRIS_UNINST_EXE}" - SetOverwrite off - IfErrors uninstall_problem - ; Ready to uninstall.. - ClearErrors - ExecWait '"$TEMP\${GCOMPRIS_UNINST_EXE}" /S _?=$R1' - IfErrors exec_error - Delete "$TEMP\${GCOMPRIS_UNINST_EXE}" - Goto done + ; In this case just wipe out previous Gcompris install dir.. + ; We get here because versions 0.60a1 and 0.60a2 don't have versions set in the registry + ; and versions 0.60 and lower did not correctly set the uninstall reg string + ; (the string was set in quotes) + MessageBox MB_YESNO $(GCOMPRIS_PROMPT_WIPEOUT) IDYES do_wipeout IDNO cancel_install + cancel_install: + Quit - exec_error: - Delete "$TEMP\${GCOMPRIS_UNINST_EXE}" - Goto uninstall_problem + SetOverwrite on + ; Need to copy uninstaller outside of the install dir + ClearErrors + CopyFiles /SILENT $R3 "$TEMP\${GCOMPRIS_UNINST_EXE}" + SetOverwrite off + IfErrors uninstall_problem + ; Ready to uninstall.. + ClearErrors + ExecWait '"$TEMP\${GCOMPRIS_UNINST_EXE}" /S _?=$R1' + IfErrors exec_error + Delete "$TEMP\${GCOMPRIS_UNINST_EXE}" + Goto done + + exec_error: + Delete "$TEMP\${GCOMPRIS_UNINST_EXE}" + Goto uninstall_problem uninstall_problem: ; In this case just wipe out previous Gcompris install dir.. @@ -243,9 +248,7 @@ Section -SecUninstallOldGcompris ; and versions 0.60 and lower did not correctly set the uninstall reg string ; (the string was set in quotes) IfSilent do_wipeout - MessageBox MB_YESNO $(GCOMPRIS_PROMPT_WIPEOUT) IDYES do_wipeout IDNO cancel_install - cancel_install: - Quit + MessageBox MB_YESNO "Uninstall previous version?" IDYES do_wipeout IDNO done do_wipeout: StrCmp $R0 "HKLM" gcompris_del_lm_reg gcompris_del_cu_reg @@ -428,7 +431,6 @@ Section Uninstall Delete "$INSTDIR\pangocairo.pyd" Delete "$INSTDIR\popt1.dll" Delete "$INSTDIR\pthreadGC.dll" - Delete "$INSTDIR\python24.dll" Delete "$INSTDIR\python24.zip" Delete "$INSTDIR\select.pyd" Delete "$INSTDIR\setup.py" diff --git a/po/Makefile.in.in b/po/Makefile.in.in index 1a6961e..d2d4e4c 100644 --- a/po/Makefile.in.in +++ b/po/Makefile.in.in @@ -22,7 +22,6 @@ PACKAGE = @PACKAGE@ VERSION = @VERSION@ SHELL = /bin/sh -@SET_MAKE@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ @@ -34,18 +33,17 @@ exec_prefix = @exec_prefix@ datadir = @datadir@ datarootdir = @datarootdir@ libdir = @libdir@ -localedir = $(libdir)/locale -gnulocaledir = $(datadir)/locale -gettextsrcdir = $(datadir)/glib-2.0/gettext/po +DATADIRNAME = @DATADIRNAME@ +itlocaledir = $(prefix)/$(DATADIRNAME)/locale subdir = po install_sh = @install_sh@ -mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +# Automake >= 1.8 provides @mkdir_p@. +# Until it can be supposed, use the safe fallback: +mkdir_p = $(install_sh) -d INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ -CC = @CC@ -GENCAT = @GENCAT@ GMSGFMT = @GMSGFMT@ MSGFMT = @MSGFMT@ XGETTEXT = @XGETTEXT@ @@ -54,32 +52,22 @@ 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 -DEFS = @DEFS@ -CFLAGS = @CFLAGS@ -CPPFLAGS = @CPPFLAGS@ +ALL_LINGUAS = @ALL_LINGUAS@ -INCLUDES = -I.. -I$(top_srcdir)/intl +PO_LINGUAS=$(shell if test -r $(srcdir)/LINGUAS; then grep -v "^\#" $(srcdir)/LINGUAS; fi) -COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS) +POFILES=$(shell if test -n "$(PO_LINGUAS)"; then LINGUAS="$(PO_LINGUAS)"; else LINGUAS="$(ALL_LINGUAS)"; fi; for lang in $$LINGUAS; do printf "$$lang.po "; done) -SOURCES = -POFILES = @POFILES@ -GMOFILES = @GMOFILES@ -DISTFILES = ChangeLog Makefile.in.in POTFILES.in \ -$(POFILES) $(SOURCES) +DISTFILES = ChangeLog Makefile.in.in POTFILES.in $(POFILES) EXTRA_DISTFILES = POTFILES.skip Makevars LINGUAS POTFILES = \ +#This Gets Replace for some reason -CATALOGS = @CATALOGS@ -CATOBJEXT = @CATOBJEXT@ -INSTOBJEXT = @INSTOBJEXT@ +CATALOGS=$(shell if test -n "$(PO_LINGUAS)"; then LINGUAS="$(PO_LINGUAS)"; else LINGUAS="$(ALL_LINGUAS)"; fi; for lang in $$LINGUAS; do printf "$$lang.gmo "; done) .SUFFIXES: -.SUFFIXES: .c .o .po .pox .gmo .mo .msg .cat - -.c.o: - $(COMPILE) $< +.SUFFIXES: .po .pox .gmo .mo .msg .cat .po.pox: $(MAKE) $(GETTEXT_PACKAGE).pot @@ -94,7 +82,7 @@ INSTOBJEXT = @INSTOBJEXT@ .po.cat: sed -f ../intl/po2msg.sed < $< > $*.msg \ - && rm -f $@ && $(GENCAT) $@ $*.msg + && rm -f $@ && gencat $@ $*.msg all: all-@USE_NLS@ @@ -105,120 +93,98 @@ all-no: $(GETTEXT_PACKAGE).pot: $(POTFILES) $(GENPOT) -install: install-exec install-data -install-exec: +install: install-data install-data: install-data-@USE_NLS@ install-data-no: all install-data-yes: all - if test -n "$(MKINSTALLDIRS)"; then \ - $(MKINSTALLDIRS) $(DESTDIR)$(datadir); \ + $(mkdir_p) $(DESTDIR)$(itlocaledir) + if test -n "$(PO_LINGUAS)"; then \ + linguas="$(PO_LINGUAS)"; \ else \ - $(SHELL) $(top_srcdir)/mkinstalldirs $(DESTDIR)$(datadir); \ - fi - @catalogs='$(CATALOGS)'; \ - for cat in $$catalogs; do \ - cat=`basename $$cat`; \ - case "$$cat" in \ - *.gmo) destdir=$(gnulocaledir);; \ - *) destdir=$(localedir);; \ - esac; \ - lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \ - dir=$(DESTDIR)$$destdir/$$lang/LC_MESSAGES; \ - if test -n "$(MKINSTALLDIRS)"; then \ - $(MKINSTALLDIRS) $$dir; \ + linguas="$(ALL_LINGUAS)"; \ + fi; \ + for lang in $$linguas; do \ + dir=$(DESTDIR)$(itlocaledir)/$$lang/LC_MESSAGES; \ + $(mkdir_p) $$dir; \ + if test -r $$lang.gmo; then \ + $(INSTALL_DATA) $$lang.gmo $$dir/$(GETTEXT_PACKAGE).mo; \ + echo "installing $$lang.gmo as $$dir/$(GETTEXT_PACKAGE).mo"; \ else \ - $(SHELL) $(top_srcdir)/mkinstalldirs $$dir; \ + $(INSTALL_DATA) $(srcdir)/$$lang.gmo $$dir/$(GETTEXT_PACKAGE).mo; \ + echo "installing $(srcdir)/$$lang.gmo as" \ + "$$dir/$(GETTEXT_PACKAGE).mo"; \ fi; \ - if test -r $$cat; then \ - $(INSTALL_DATA) $$cat $$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT); \ - echo "installing $$cat as $$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT)"; \ + if test -r $$lang.gmo.m; then \ + $(INSTALL_DATA) $$lang.gmo.m $$dir/$(GETTEXT_PACKAGE).mo.m; \ + echo "installing $$lang.gmo.m as $$dir/$(GETTEXT_PACKAGE).mo.m"; \ else \ - $(INSTALL_DATA) $(srcdir)/$$cat $$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT); \ - echo "installing $(srcdir)/$$cat as" \ - "$$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT)"; \ - fi; \ - if test -r $$cat.m; then \ - $(INSTALL_DATA) $$cat.m $$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT).m; \ - echo "installing $$cat.m as $$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT).m"; \ - else \ - if test -r $(srcdir)/$$cat.m ; then \ - $(INSTALL_DATA) $(srcdir)/$$cat.m \ - $$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT).m; \ - echo "installing $(srcdir)/$$cat as" \ - "$$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT).m"; \ + if test -r $(srcdir)/$$lang.gmo.m ; then \ + $(INSTALL_DATA) $(srcdir)/$$lang.gmo.m \ + $$dir/$(GETTEXT_PACKAGE).mo.m; \ + echo "installing $(srcdir)/$$lang.gmo.m as" \ + "$$dir/$(GETTEXT_PACKAGE).mo.m"; \ else \ true; \ fi; \ fi; \ done - if test "$(PACKAGE)" = "glib"; then \ - if test -n "$(MKINSTALLDIRS)"; then \ - $(MKINSTALLDIRS) $(DESTDIR)$(gettextsrcdir); \ - else \ - $(SHELL) $(top_srcdir)/mkinstalldirs $(DESTDIR)$(gettextsrcdir); \ - fi; \ - $(INSTALL_DATA) $(srcdir)/Makefile.in.in \ - $(DESTDIR)$(gettextsrcdir)/Makefile.in.in; \ - else \ - : ; \ - fi + +# Empty stubs to satisfy archaic automake needs +dvi info tags TAGS ID: # Define this as empty until I found a useful application. installcheck: uninstall: - catalogs='$(CATALOGS)'; \ - for cat in $$catalogs; do \ - cat=`basename $$cat`; \ - lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \ - rm -f $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE)$(INSTOBJEXT); \ - rm -f $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE)$(INSTOBJEXT).m; \ - rm -f $(DESTDIR)$(gnulocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE)$(INSTOBJEXT); \ - rm -f $(DESTDIR)$(gnulocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE)$(INSTOBJEXT).m; \ + if test -n "$(PO_LINGUAS)"; then \ + linguas="$(PO_LINGUAS)"; \ + else \ + linguas="$(ALL_LINGUAS)"; \ + fi; \ + for lang in $$linguas; do \ + rm -f $(DESTDIR)$(itlocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE).mo; \ + rm -f $(DESTDIR)$(itlocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE).mo.m; \ done - if test "$(PACKAGE)" = "glib"; then \ - rm -f $(DESTDIR)$(gettextsrcdir)/Makefile.in.in; \ - fi check: all $(GETTEXT_PACKAGE).pot -dvi info tags TAGS ID: - mostlyclean: - rm -f core core.* *.pox $(GETTEXT_PACKAGE).pot *.old.po cat-id-tbl.tmp - rm -fr *.o + rm -f *.pox $(GETTEXT_PACKAGE).pot *.old.po cat-id-tbl.tmp rm -f .intltool-merge-cache clean: mostlyclean distclean: clean - rm -f Makefile Makefile.in POTFILES - rm -f *.mo *.msg *.cat *.cat.m $(GMOFILES) + rm -f Makefile Makefile.in POTFILES stamp-it + rm -f *.mo *.msg *.cat *.cat.m *.gmo maintainer-clean: distclean @echo "This command is intended for maintainers to use;" @echo "it deletes files that may require special tools to rebuild." rm -f Makefile.in.in -distdir = ../$(GETTEXT_PACKAGE)-$(VERSION)/$(subdir) +distdir = ../$(PACKAGE)-$(VERSION)/$(subdir) dist distdir: $(DISTFILES) dists="$(DISTFILES)"; \ extra_dists="$(EXTRA_DISTFILES)"; \ for file in $$extra_dists; do \ - test -f $$file && dists="$$dists $$file"; \ + test -f $(srcdir)/$$file && dists="$$dists $(srcdir)/$$file"; \ done; \ for file in $$dists; do \ - ln $(srcdir)/$$file $(distdir) 2> /dev/null \ - || cp -p $(srcdir)/$$file $(distdir); \ + test -f $$file || file="$(srcdir)/$$file"; \ + ln $$file $(distdir) 2> /dev/null \ + || cp -p $$file $(distdir); \ done update-po: Makefile $(MAKE) $(GETTEXT_PACKAGE).pot tmpdir=`pwd`; \ - catalogs='$(CATALOGS)'; \ - for cat in $$catalogs; do \ - cat=`basename $$cat`; \ - lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \ + if test -n "$(PO_LINGUAS)"; then \ + linguas="$(PO_LINGUAS)"; \ + else \ + linguas="$(ALL_LINGUAS)"; \ + fi; \ + for lang in $$linguas; do \ echo "$$lang:"; \ result="`$(MSGMERGE) -o $$tmpdir/$$lang.new.po $$lang`"; \ if $$result; then \ @@ -234,28 +200,20 @@ update-po: Makefile fi; \ fi; \ else \ - echo "msgmerge for $$cat failed!"; \ + echo "msgmerge for $$lang.gmo failed!"; \ rm -f $$tmpdir/$$lang.new.po; \ fi; \ done -# POTFILES is created from POTFILES.in by stripping comments, empty lines -# and Intltool tags (enclosed in square brackets), and appending a full -# relative path to them -POTFILES: POTFILES.in - ( posrcprefix='$(top_srcdir)/'; \ - rm -f $@-t $@ \ - && (sed -e '/^#/d' \ - -e 's/^[[].*] *//' \ - -e '/^[ ]*$$/d' \ - -e "s@^@ $$posrcprefix@" $(srcdir)/$@.in \ - | sed -e '$$!s/$$/ \\/') > $@-t \ - && chmod a-w $@-t \ - && mv $@-t $@ ) - -Makefile: Makefile.in.in ../config.status POTFILES +Makefile POTFILES: stamp-it + @if test ! -f $@; then \ + rm -f stamp-it; \ + $(MAKE) stamp-it; \ + fi + +stamp-it: Makefile.in.in ../config.status POTFILES.in cd .. \ - && CONFIG_FILES=$(subdir)/$@.in CONFIG_HEADERS= \ + && CONFIG_FILES=$(subdir)/Makefile.in CONFIG_HEADERS= CONFIG_LINKS= \ $(SHELL) ./config.status # Tell versions [3.59,3.63) of GNU make not to export all variables. diff --git a/src/boards/Makefile.am b/src/boards/Makefile.am index 0e8e04a..233e0d2 100644 --- a/src/boards/Makefile.am +++ b/src/boards/Makefile.am @@ -23,6 +23,17 @@ cairo_ldflags = cairo_cflags = endif +if PLATFORM_WIN32 +shared = -shared +no_undefined = -no-undefined +gc_libs = $(GCOMPRIS_LIBS) +dll_export = -DBOARD_DLL_EXPORT +else +shared = +no_undefined = +gc_libs = +dll_export = +endif SUBDIRS= $(python_subdir) @@ -80,192 +91,193 @@ INCLUDES = \ $(PYTHON_CFLAGS) \ $(PYGTK_CFLAGS) \ $(sqlite_cflags) \ - $(cairo_cflags) + $(cairo_cflags) \ + $(dll_export) -libdraw_la_LDFLAGS = -module -avoid-version +libdraw_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) libdraw_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libdraw_la_SOURCES = draw.c -libawele_la_LDFLAGS = -module -avoid-version +libawele_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) libawele_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libawele_la_SOURCES = awele.c awele_alphaBeta.c awele_utils.c awele_utils.h awele.h -libcrane_la_LDFLAGS = -module -avoid-version +libcrane_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) libcrane_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libcrane_la_SOURCES = crane.c -libmenu_la_LDFLAGS = -module -avoid-version +libmenu_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) libmenu_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libmenu_la_SOURCES = menu2.c -libclickgame_la_LDFLAGS = -module -avoid-version +libclickgame_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) libclickgame_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libclickgame_la_SOURCES = clickgame.c -libalgebra_la_LDFLAGS = -module -avoid-version +libalgebra_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) libalgebra_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libalgebra_la_SOURCES = algebra.c -libclockgame_la_LDFLAGS = -module -avoid-version +libclockgame_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) libclockgame_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libclockgame_la_SOURCES = clockgame.c -libshapegame_la_LDFLAGS = -module -avoid-version +libshapegame_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) $(XML_LIBS) libshapegame_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libshapegame_la_SOURCES = shapegame.c -libwordsgame_la_LDFLAGS = -module -avoid-version +libwordsgame_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) libwordsgame_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libwordsgame_la_SOURCES = wordsgame.c -libgletters_la_LDFLAGS = -module -avoid-version +libgletters_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) libgletters_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libgletters_la_SOURCES = gletters.c -libgtans_la_LDFLAGS = -module -avoid-version +libgtans_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) libgtans_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libgtans_la_SOURCES = gtans.c gtans_interface.c gtans_support.c gtans_callbacks.c \ gtans_callbacks.h gtans.h gtans_interface.h gtans_support.h -libplanegame_la_LDFLAGS = -module -avoid-version +libplanegame_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) libplanegame_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libplanegame_la_SOURCES = planegame.c -libsmallnumbers_la_LDFLAGS = -module -avoid-version +libsmallnumbers_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) libsmallnumbers_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libsmallnumbers_la_SOURCES = smallnumbers.c -libparatrooper_la_LDFLAGS = -module -avoid-version +libparatrooper_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) libparatrooper_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libparatrooper_la_SOURCES = paratrooper.c -libreading_la_LDFLAGS = -module -avoid-version +libreading_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) libreading_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libreading_la_SOURCES = reading.c -libmemory_la_LDFLAGS = -module -avoid-version +libmemory_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) libmemory_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libmemory_la_SOURCES = memory.c -libimageid_la_LDFLAGS = -module -avoid-version +libimageid_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) $(XML_LIBS) libimageid_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libimageid_la_SOURCES = imageid.c -libmissingletter_la_LDFLAGS = -module -avoid-version +libmissingletter_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) $(XML_LIBS) libmissingletter_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libmissingletter_la_SOURCES = missingletter.c -libclick_on_letter_la_LDFLAGS = -module -avoid-version +libclick_on_letter_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) libclick_on_letter_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libclick_on_letter_la_SOURCES = click_on_letter.c -librailroad_la_LDFLAGS = -module -avoid-version +librailroad_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) librailroad_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la librailroad_la_SOURCES = railroad.c -liberase_la_LDFLAGS = -module -avoid-version +liberase_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) liberase_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la liberase_la_SOURCES = erase.c -libalgebra_guesscount_la_LDFLAGS = -module -avoid-version +libalgebra_guesscount_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) libalgebra_guesscount_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libalgebra_guesscount_la_SOURCES = algebra_guesscount.c -libleftright_la_LDFLAGS = -module -avoid-version +libleftright_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) libleftright_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libleftright_la_SOURCES = leftright.c -libcolors_la_LDFLAGS = -module -avoid-version +libcolors_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) libcolors_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libcolors_la_SOURCES = colors.c -libtarget_la_LDFLAGS = -module -avoid-version +libtarget_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) libtarget_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libtarget_la_SOURCES = target.c -libmagic_hat_la_LDFLAGS = -module -avoid-version +libmagic_hat_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) libmagic_hat_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libmagic_hat_la_SOURCES = magic_hat.c -libmaze_la_LDFLAGS = -module -avoid-version +libmaze_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) libmaze_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libmaze_la_SOURCES = maze.c -libreversecount_la_LDFLAGS = -module -avoid-version +libreversecount_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) libreversecount_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libreversecount_la_SOURCES = reversecount.c -libcanal_lock_la_LDFLAGS = -module -avoid-version +libcanal_lock_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) libcanal_lock_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libcanal_lock_la_SOURCES = canal_lock.c -libadvanced_colors_la_LDFLAGS = -module -avoid-version +libadvanced_colors_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) $(XML_LIBS) libadvanced_colors_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libadvanced_colors_la_SOURCES = advanced_colors.c -libsuperbrain_la_LDFLAGS = -module -avoid-version +libsuperbrain_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) libsuperbrain_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libsuperbrain_la_SOURCES = superbrain.c -libread_colors_la_LDFLAGS = -module -avoid-version +libread_colors_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) $(XML_LIBS) libread_colors_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libread_colors_la_SOURCES = read_colors.c -libchess_la_LDFLAGS = -module -avoid-version +libchess_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) libchess_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la 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_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) libenumerate_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libenumerate_la_SOURCES = enumerate.c -libmoney_la_LDFLAGS = -module -avoid-version +libmoney_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) libmoney_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libmoney_la_SOURCES = money.c money_widget.c money_widget.h -libtraffic_la_LDFLAGS = -module -avoid-version +libtraffic_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) libtraffic_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libtraffic_la_SOURCES = traffic.c traffic.h -libmachpuzzle_la_LDFLAGS = -module -avoid-version +libmachpuzzle_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) libmachpuzzle_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libmachpuzzle_la_SOURCES = machpuzzle.c -libsubmarine_la_LDFLAGS = -module -avoid-version +libsubmarine_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) libsubmarine_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libsubmarine_la_SOURCES = submarine.c -libhanoi_la_LDFLAGS = -module -avoid-version +libhanoi_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) libhanoi_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libhanoi_la_SOURCES = hanoi.c -libhanoi_real_la_LDFLAGS = -module -avoid-version +libhanoi_real_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) libhanoi_real_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libhanoi_real_la_SOURCES = hanoi_real.c -libfifteen_la_LDFLAGS = -module -avoid-version +libfifteen_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) libfifteen_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libfifteen_la_SOURCES = fifteen.c -libwordprocessor_la_LDFLAGS = -module -avoid-version +libwordprocessor_la_LDFLAGS = $(shared) $(no_undefined) -module -avoid-version $(gc_libs) libwordprocessor_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la libwordprocessor_la_SOURCES = wordprocessor.c -libpython_la_LDFLAGS = -export-dynamic -module -avoid-version $(PYTHON_LIBS) +libpython_la_LDFLAGS = -export-dynamic $(shared) $(no_undefined) -module -avoid-version $(gc_libs) $(PYTHON_LIBS) libpython_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la -libpython_la_CFLAGS = -fno-strict-aliasing +libpython_la_CFLAGS = -fno-strict-aliasing $(PYGTK_CFLAGS) libpython_la_SOURCES = python.c \ canvas.c canvasmodule.c \ py-gcompris-board.c py-gcompris-board.h \ diff --git a/src/boards/Makefile.mingw b/src/boards/Makefile.mingw index a9424ea..1bf88e2 100644 --- a/src/boards/Makefile.mingw +++ b/src/boards/Makefile.mingw @@ -26,7 +26,7 @@ GCOMPRIS_INSTALL_DIR := $(GCOMPRIS_TOP)/win32-install-dir # Compiler Options -CFLAGS = +CFLAGS = -DSTATIC_MODULE DEFINES = diff --git a/src/boards/advanced_colors.c b/src/boards/advanced_colors.c index fa9a581..1362af8 100644 --- a/src/boards/advanced_colors.c +++ b/src/boards/advanced_colors.c @@ -196,7 +196,7 @@ static gboolean is_our_board (GcomprisBoard *gcomprisBoard) { * =====================================================================*/ static void colors_next_level() { gchar *str = NULL; - int i; + int i, list_length; GList * list = NULL; int * item; @@ -215,8 +215,8 @@ static void colors_next_level() { for (i=0; i<LAST_COLOR; i++) list = g_list_append(list, GINT_TO_POINTER(i)); - while ((g_list_length(list) > 0)) { - i = RAND(0,g_list_length(list)-1); + while((list_length = g_list_length(list))) { + i = list_length == 1 ? 0 : g_random_int_range(0,g_list_length(list)-1); item = g_list_nth_data(list, i); listColors = g_list_append(listColors, item); list = g_list_remove(list, item); @@ -288,7 +288,7 @@ static GnomeCanvasItem *colors_create_item(GnomeCanvasGroup *parent) { g_free(str); gnome_canvas_item_hide(highlight_image_item); - i = RAND(0,LAST_COLOR); + i = g_random_int_range(0,LAST_COLOR); gdk_pixbuf_unref(highlight_pixmap); diff --git a/src/boards/algebra.c b/src/boards/algebra.c index 4075692..691d653 100644 --- a/src/boards/algebra.c +++ b/src/boards/algebra.c @@ -709,7 +709,7 @@ item_event(GnomeCanvasItem *item, GdkEvent *event, gpointer data) static gint get_operand() { gint j = 10; - gint i = (1+rand()%10); + gint i = (1+g_random_int()%10); // Get the next free slot while(operation_done[i]==TRUE && j>=0) @@ -781,8 +781,8 @@ static void get_random_number(guint *first_operand, guint *second_operand) min = 1; max = 10; } - *second_operand = (min+rand()%(max-min+1)); - *first_operand = *second_operand*(min+rand()%max); + *second_operand = (min+g_random_int()%(max-min+1)); + *first_operand = *second_operand*(min+g_random_int()%max); break; default: g_error("Bad Operation"); diff --git a/src/boards/algebra_guesscount.c b/src/boards/algebra_guesscount.c index 726e636..722c632 100644 --- a/src/boards/algebra_guesscount.c +++ b/src/boards/algebra_guesscount.c @@ -334,7 +334,7 @@ static int generate_numbers() { gboolean minus, divide; for (i=0; i<gcomprisBoard->level+1; i++) { - j = RAND(0,NUM_VALUES-1); + j = g_random_int_range(0,NUM_VALUES-1); answer_num_index[i] = j; } @@ -350,7 +350,7 @@ static int generate_numbers() { } r = 2 + minus + divide; - switch (RAND(1,r)) { + switch (g_random_int_range(1,r)) { case 1 : answer_oper[i] = '+'; result += num_values[answer_num_index[i+1]]; @@ -377,7 +377,7 @@ static int generate_numbers() { } break; case 4 : - if ( RAND(0,1) == 0) { + if ( g_random_int_range(0,1) == 0) { answer_oper[i] = '-'; result -= num_values[answer_num_index[i+1]]; g_assert(result >= 0); diff --git a/src/boards/awele.c b/src/boards/awele.c index 574fc90..a03f757 100644 --- a/src/boards/awele.c +++ b/src/boards/awele.c @@ -16,8 +16,6 @@ #include <awele_utils.h> #include <awele.h> #include <string.h> -#include <unistd.h> - static GcomprisBoard *gcomprisBoard = NULL; static gboolean board_paused = TRUE; @@ -624,17 +622,17 @@ initBoardGraphics (GRAPHICS_ELT * graphsElt) j < staticAwale->board[i] && idxTabBeans < NBTOTALBEAN; j++, idxTabBeans++) { - k = 0 + rand () % 4; + k = 0 + g_random_int() % 4; graphsElt->ptBeansHoleLink[idxTabBeans].beanPixbuf = gnome_canvas_item_new (boardRootItem, gnome_canvas_pixbuf_get_type (), "x", (double) caseCoord[i] + - rand () % 50, "y", + g_random_int() % 50, "y", (double) (((i < 6) ? 260 : 130) + - rand () % + g_random_int() % 60), "pixbuf", graphsElt-> @@ -858,15 +856,15 @@ updateNbBeans (int alpha) j++, idxTabBeans++) { - k = 0 + rand () % 4; + k = 0 + g_random_int() % 4; gnome_canvas_item_set (ptBeansHoleLink[idxTabBeans]. beanPixbuf, "x", (double) caseCoord[i] + - rand () % 50, "y", + g_random_int() % 50, "y", (double) (((i < 6) ? 260 : 130) + - rand () % 60), NULL); + g_random_int() % 60), NULL); ptBeansHoleLink[idxTabBeans].hole = i; } diff --git a/src/boards/awele_alphaBeta.c b/src/boards/awele_alphaBeta.c index 418856b..567193d 100644 --- a/src/boards/awele_alphaBeta.c +++ b/src/boards/awele_alphaBeta.c @@ -73,7 +73,7 @@ GNode *firstChild(GNode *node) return NULL; gint i; - rand_play = RAND(1, 5); + rand_play = g_random_int_range(1, 5); for (i = 0 ; i < 6; i++) { diff --git a/src/boards/awele_utils.c b/src/boards/awele_utils.c index 368503c..f2d5982 100644 --- a/src/boards/awele_utils.c +++ b/src/boards/awele_utils.c @@ -139,7 +139,7 @@ short int randplay(AWALE * a) AWALE *tmp = NULL; do { - i = 6 + rand() % 6; + i = 6 + g_random_int() % 6; } while (a->board[i] == 0 && !(tmp = moveAwale(i, a))); g_free(tmp); diff --git a/src/boards/click_on_letter.c b/src/boards/click_on_letter.c index a5a2e0b..409d1cc 100644 --- a/src/boards/click_on_letter.c +++ b/src/boards/click_on_letter.c @@ -353,7 +353,7 @@ static GnomeCanvasItem *click_on_letter_create_item(GnomeCanvasGroup *parent) g_assert(number_of_letters<=length_of_aphabet); // because we must set unique letter on every "vagon" for (i=0;i<number_of_letters;i++){ - numbers[i]=((int)(((float)length_of_aphabet)*rand()/(RAND_MAX+1.0))); + numbers[i]= g_random_int_range(0, number_of_letters); // check that the letter has not been taken yet for(j=0;j<i;j++){ @@ -378,7 +378,7 @@ static GnomeCanvasItem *click_on_letter_create_item(GnomeCanvasGroup *parent) case 2 : letters[i]=g_strndup(copy_from,copy_to-copy_from); break; case 3 : letters[i]=g_utf8_strup(copy_from,copy_to-copy_from); break; default : - if ( rand() > (RAND_MAX/2) ) + if ( g_random_boolean() ) letters[i]=g_strndup(copy_from,copy_to-copy_from); else letters[i]=g_utf8_strup(copy_from,copy_to-copy_from); @@ -387,7 +387,7 @@ static GnomeCanvasItem *click_on_letter_create_item(GnomeCanvasGroup *parent) } /* */ - right_position = ((int)(((float)number_of_letters)*rand()/(RAND_MAX+1.0))); + right_position = g_random_int_range(0,number_of_letters); g_assert(right_position >= 0 && right_position < number_of_letters); right_letter = g_utf8_strdown(letters[right_position],-1); diff --git a/src/boards/clickgame.c b/src/boards/clickgame.c index 53e9df8..7772878 100644 --- a/src/boards/clickgame.c +++ b/src/boards/clickgame.c @@ -720,7 +720,7 @@ clickgame_create_item() fishitem = g_malloc(sizeof(FishItem)); fishitem->currentItem = 0; - fishitem->speed = (double)(rand()%(60))/10 - 3; + fishitem->speed = (double)(g_random_int()%(60))/10 - 3; fishitem->fright = 0; fishitem->stun = 0; fishitem->fwd_frames = NULL; @@ -746,7 +746,7 @@ clickgame_create_item() gnome_canvas_item_new (parent, gnome_canvas_group_get_type (), "x", x, - "y", (double)(rand()%(gcomprisBoard->height- + "y", (double)(g_random_int()%(gcomprisBoard->height- (guint)(gdk_pixbuf_get_height(pixmap)* imageZoom))), NULL); @@ -840,4 +840,3 @@ static void game_won() } clickgame_next_level(); } - diff --git a/src/boards/clockgame.c b/src/boards/clockgame.c index 6e98303..92749d6 100644 --- a/src/boards/clockgame.c +++ b/src/boards/clockgame.c @@ -746,21 +746,21 @@ item_event(GnomeCanvasItem *item, GdkEvent *event, gpointer data) static void get_random_hour(GcomprisTime *time) { - time->hour=rand()%12; - + time->hour=g_random_int()%12; + if(gcomprisBoard->level>3) - time->second=rand()%60; + time->second=g_random_int()%60; else time->second=0; - - time->minute=rand()%60; + + time->minute=g_random_int()%60; switch(gcomprisBoard->level) { case 1: - time->minute=rand()%4*15; + time->minute=g_random_int()%4*15; break; case 2: - time->minute=rand()%12*5; + time->minute=g_random_int()%12*5; break; default: break; diff --git a/src/boards/colors.c b/src/boards/colors.c index 8331b29..46cf4a8 100644 --- a/src/boards/colors.c +++ b/src/boards/colors.c @@ -211,7 +211,7 @@ static void start_board (GcomprisBoard *agcomprisBoard) { GcomprisProperties *properties = gc_prop_get(); GList * list = NULL; int * item; - int i; + int i, list_length; GHashTable *config = gc_db_get_board_conf(); @@ -239,8 +239,8 @@ static void start_board (GcomprisBoard *agcomprisBoard) { for (i=0; i<LAST_COLOR; i++) list = g_list_append(list, GINT_TO_POINTER(i)); - while ((g_list_length(list) > 0)) { - i = RAND(0,g_list_length(list)-1); + while ((list_length = g_list_length(list))) { + i = list_length == 1 ? 0 : g_random_int_range(0,g_list_length(list)-1); item = g_list_nth_data(list, i); listColors = g_list_append(listColors, item); list = g_list_remove(list, item); diff --git a/src/boards/crane.c b/src/boards/crane.c index 5db70d1..118a01b 100644 --- a/src/boards/crane.c +++ b/src/boards/crane.c @@ -696,8 +696,8 @@ void shuffle_list(int list[], int size) { for (i = 0 ; i < size ; i++) { - rand1 = RAND(0, size-1); - rand2 = RAND(0, size-1); + rand1 = g_random_int_range(0, size-1); + rand2 = g_random_int_range(0, size-1); buffer = list[rand2]; list[rand2] = list[rand1]; diff --git a/src/boards/enumerate.c b/src/boards/enumerate.c index f05e604..e4474dc 100644 --- a/src/boards/enumerate.c +++ b/src/boards/enumerate.c @@ -377,15 +377,15 @@ static GnomeCanvasItem *enumerate_create_item(GnomeCanvasGroup *parent) pixmap = gc_pixmap_load(imageList[i]); - answer_to_find[i] = RAND(1, number_of_item_max); + answer_to_find[i] = g_random_int_range(1, number_of_item_max); answer[i] = 0; for(j=0; j<answer_to_find[i]; j++) { guint x, y; - x = RAND(0, ANSWER_X-gdk_pixbuf_get_width(pixmap)-ANSWER_WIDTH); - y = RAND(0, BOARDHEIGHT-gdk_pixbuf_get_height(pixmap)); + x = g_random_int_range(0, ANSWER_X-gdk_pixbuf_get_width(pixmap)-ANSWER_WIDTH); + y = g_random_int_range(0, BOARDHEIGHT-gdk_pixbuf_get_height(pixmap)); item = gnome_canvas_item_new (boardRootItem, gnome_canvas_pixbuf_get_type (), diff --git a/src/boards/erase.c b/src/boards/erase.c index 5210719..b3c89d1 100644 --- a/src/boards/erase.c +++ b/src/boards/erase.c @@ -487,8 +487,8 @@ void shuffle_image_list(char *list[], int size) for(i=0; i<size; i++) { - int random1 = RAND(0, size-1); - int random2 = RAND(0, size-1); + int random1 = g_random_int_range(0, size-1); + int random2 = g_random_int_range(0, size-1); char *olditem; olditem = list[random2]; diff --git a/src/boards/fifteen.c b/src/boards/fifteen.c index 04646c3..4d71d8f 100644 --- a/src/boards/fifteen.c +++ b/src/boards/fifteen.c @@ -431,7 +431,8 @@ scramble (GnomeCanvasItem **board, guint number_of_scrambles) int dir; int x, y; - srand (time (NULL)); + /* g_random are initialised in gcompris launch */ + /* srand (time (NULL)); */ /* First, find the blank spot */ @@ -443,7 +444,7 @@ scramble (GnomeCanvasItem **board, guint number_of_scrambles) for (i = 0; i < number_of_scrambles; i++) { retry_scramble: - dir = rand () % 4; + dir = g_random_int () % 4; x = y = 0; diff --git a/src/boards/gletters.c b/src/boards/gletters.c index 1ceb498..660b0c1 100644 --- a/src/boards/gletters.c +++ b/src/boards/gletters.c @@ -611,7 +611,7 @@ static GnomeCanvasItem *gletters_create_item(GnomeCanvasGroup *parent) { attempt++; str_p = letters_array[gcomprisBoard->level-1]; - i = (int)((float)k*rand()/(RAND_MAX+1.0)); + i = g_random_int_range(0,k); for(j = 0; j < i; j++) { @@ -651,7 +651,7 @@ static GnomeCanvasItem *gletters_create_item(GnomeCanvasGroup *parent) "y", (double) -12, NULL); - x = 80 + (int)((float)(gcomprisBoard->width-160)*rand()/(RAND_MAX+1.0)); + x = g_random_int_range( 80, gcomprisBoard->width-160); gnome_canvas_item_new (GNOME_CANVAS_GROUP(item), gnome_canvas_text_get_type (), "text", letter, diff --git a/src/boards/gtans.c b/src/boards/gtans.c index 03bed7b..d57ba17 100644 --- a/src/boards/gtans.c +++ b/src/boards/gtans.c @@ -20,20 +20,12 @@ #include "gcompris/gcompris.h" -#include <math.h> -#include <stdio.h> #include <string.h> /* Added by Florian Ernst <florian_ernst@gmx.net> for lines 193 and 194 */ //#include <string.h> /* End of added section */ -/* uniquement pour mkdir() */ -#include <sys/stat.h> -#include <sys/types.h> -#include <fcntl.h> -#include <unistd.h> - #include "gtans.h" #include "gtans_interface.h" #include "gtans_support.h" diff --git a/src/boards/gtans_support.c b/src/boards/gtans_support.c index 2590ced..9303d98 100644 --- a/src/boards/gtans_support.c +++ b/src/boards/gtans_support.c @@ -1,17 +1,14 @@ -/* - * DO NOT EDIT THIS FILE - it is generated by Glade. - */ + + #ifdef HAVE_CONFIG_H # include <config.h> #endif -#include <sys/types.h> -#include <sys/stat.h> -#include <unistd.h> #include <string.h> #include "gcompris/gcompris.h" +#include <glib/gstdio.h> #include "gtans_support.h" @@ -150,7 +147,7 @@ check_file_exists (const gchar *directory, strcat (full_filename, G_DIR_SEPARATOR_S); strcat (full_filename, filename); - status = stat (full_filename, &s); + status = g_stat (full_filename, &s); if (status == 0 && S_ISREG (s.st_mode)) return full_filename; g_free (full_filename); diff --git a/src/boards/hanoi.c b/src/boards/hanoi.c index 60873c6..e70ed0e 100644 --- a/src/boards/hanoi.c +++ b/src/boards/hanoi.c @@ -371,7 +371,7 @@ static GnomeCanvasItem *hanoi_create_item(GnomeCanvasGroup *parent) /* Initialize a random goal and store the color index in position[number_of_item_x] */ for(i=0; i<(number_of_item_y); i++) { - guint color = (guint)RAND(0, NUMBER_OF_COLOR-1); + guint color = (guint)g_random_int_range(0, NUMBER_OF_COLOR-1); position[number_of_item_x+1][i]->color = color; used_colors[color] = TRUE; @@ -386,10 +386,10 @@ static GnomeCanvasItem *hanoi_create_item(GnomeCanvasGroup *parent) { done = FALSE; - i = (guint)RAND(0, number_of_item_x-2); + i = (guint)g_random_int_range(0, number_of_item_x-2); /* Restrict the goal to lowest items */ - j = (guint)RAND(0, 2); + j = (guint)g_random_int_range(0, 2); if(position[i][j]->color == -1) { @@ -408,7 +408,7 @@ static GnomeCanvasItem *hanoi_create_item(GnomeCanvasGroup *parent) if(position[i][j]->color == -1) { /* Take only a color that is not part of the goal */ - guint color = (guint)RAND(0, NUMBER_OF_COLOR-1); + guint color = (guint)g_random_int_range(0, NUMBER_OF_COLOR-1); //printf(" i,j=%d,%d random color = %d used_colors[color]=%d\n", i,j,color, used_colors[color]); while(used_colors[color]) { diff --git a/src/boards/imageid.c b/src/boards/imageid.c index e2d0068..a04431d 100644 --- a/src/boards/imageid.c +++ b/src/boards/imageid.c @@ -266,7 +266,7 @@ static GnomeCanvasItem *imageid_create_item(GnomeCanvasGroup *parent) board_number = g_list_length(board_list)-1; */ g_assert(board_number >= 0 && board_number < g_list_length(board_list)); - place = ((int)(3.0*rand()/(RAND_MAX+1.0))); + place = g_random_int_range( 0, 3); g_assert(place >= 0 && place < 3); right_word = place+1; diff --git a/src/boards/leftright.c b/src/boards/leftright.c index c7109d9..23bdc5d 100644 --- a/src/boards/leftright.c +++ b/src/boards/leftright.c @@ -314,7 +314,7 @@ static GnomeCanvasItem *leftright_create_item(GnomeCanvasGroup *parent) { // make sure that next hand is not the same as previous do { - i = RAND(0,gcomprisBoard->level*8-1); + i = g_random_int_range(0,gcomprisBoard->level*8-1); } while ( i == last_hand ); last_hand = i; diff --git a/src/boards/machpuzzle.c b/src/boards/machpuzzle.c index 569c861..ed30700 100644 --- a/src/boards/machpuzzle.c +++ b/src/boards/machpuzzle.c @@ -243,7 +243,7 @@ static GnomeCanvasItem *minigolf_create_item(GnomeCanvasGroup *parent) NULL)); create_machine_item(MACH_HOLE, 730.0, 260.0); - create_machine_item(MACH_BASKET_BALL, (double)RAND(60, 150), (double)RAND(60, 400)); + create_machine_item(MACH_BASKET_BALL, (double)g_random_int_range(60, 150), (double)RAND(60, 400)); return NULL; diff --git a/src/boards/magic_hat.c b/src/boards/magic_hat.c index 496fc10..089f7c0 100644 --- a/src/boards/magic_hat.c +++ b/src/boards/magic_hat.c @@ -363,9 +363,9 @@ static GnomeCanvasItem *magic_hat_create_item() // Frame 1 if (board_mode == MODE_MINUS) - frame1.nb_stars[i] = RAND(2, (1 + (step * nb_list()))); // Minimum 2 to avoid '0' value (which is not easy to understand for kids) + frame1.nb_stars[i] = g_random_int_range(2, (1 + (step * nb_list()))); // Minimum 2 to avoid '0' value (which is not easy to understand for kids) else - frame1.nb_stars[i] = RAND(1, (step * nb_list())); + frame1.nb_stars[i] = g_random_int_range(1, (step * nb_list())); for (j = 0 ; j < frame1.nb_stars[i] ; j++) frame1.array_star_type[i][j] = i; for ( ; j < MAX_ITEM ; j++) frame1.array_star_type[i][j] = -1; @@ -373,9 +373,9 @@ static GnomeCanvasItem *magic_hat_create_item() // Frame 2 if (board_mode == MODE_MINUS) - frame2.nb_stars[i] = RAND(1, (frame1.nb_stars[i]) - 1); // Minimum 1 to avoid '0' + frame2.nb_stars[i] = g_random_int_range(1, (frame1.nb_stars[i]) - 1); // Minimum 1 to avoid '0' else - frame2.nb_stars[i] = RAND(1, ((step * nb_list()) - frame1.nb_stars[i] + 1)); + frame2.nb_stars[i] = g_random_int_range(1, ((step * nb_list()) - frame1.nb_stars[i] + 1)); for (j = 0 ; j < frame2.nb_stars[i] ; j++) frame2.array_star_type[i][j] = i; for ( ; j < MAX_ITEM ; j++) frame2.array_star_type[i][j] = -1; diff --git a/src/boards/maze.c b/src/boards/maze.c index 6b5a3f2..6618cf1 100644 --- a/src/boards/maze.c +++ b/src/boards/maze.c @@ -272,7 +272,7 @@ static void maze_next_level() { gamewon = FALSE; initMaze(); - generateMaze((rand()%breedte),(rand()%hoogte)); + generateMaze((g_random_int()%breedte),(g_random_int()%hoogte)); removeSet(); /* Try the next level */ maze_create_item(gnome_canvas_root(gcomprisBoard->canvas)); @@ -283,8 +283,8 @@ static void maze_next_level() { } /* make a new group for the items */ - begin=rand()%hoogte; - end=rand()%hoogte; + begin=g_random_int()%hoogte; + end=g_random_int()%hoogte; /* Draw the tux */ pixmap = gc_pixmap_load("gcompris/misc/tux_top_east.png"); @@ -723,7 +723,7 @@ static void generateMaze(int x, int y) { int nr = *po; int ran, in; - in=(rand()%nr)+1; + in=(g_random_int()%nr)+1; //printf("random: %d en %d mogelijkheden\n", in, *po); ran=*(po + in); if (nr>=1) diff --git a/src/boards/memory.c b/src/boards/memory.c index e78ca3f..cbe9bae 100644 --- a/src/boards/memory.c +++ b/src/boards/memory.c @@ -522,7 +522,7 @@ void get_random_token(int token_type, gint *returned_type, gchar **string, gchar g_assert(max_token >0); - i = rand()%max_token; + i = g_random_int()%max_token; for (list = data; list != NULL; list = list->next) if ( i < ((DATUM *)list->data)->bound) @@ -1175,8 +1175,8 @@ static void get_image(MemoryItem *memoryItem, guint x, guint y) // Randomly set the pair - rx = (int)(numberOfColumn*((double)rand()/RAND_MAX)); - ry = (int)(numberOfLine*((double)rand()/RAND_MAX)); + rx = g_random_int_range( 0, numberOfColumn); + ry = g_random_int_range(0, numberOfLine); while(memoryArray[rx][ry]) { @@ -1744,8 +1744,8 @@ static gint tux_play(){ } // Randomly set the pair - rx = (int)(numberOfColumn*((double)rand()/RAND_MAX)); - ry = (int)(numberOfLine*((double)rand()/RAND_MAX)); + rx = g_random_int_range( 0, numberOfColumn); + ry = g_random_int_range(0, numberOfLine); gboolean stay_unknown = (remainingCards > (g_queue_get_length (tux_memory) + (firstCard ? 1 : 0))); diff --git a/src/boards/missingletter.c b/src/boards/missingletter.c index febe4c9..46d7795 100644 --- a/src/boards/missingletter.c +++ b/src/boards/missingletter.c @@ -275,7 +275,7 @@ static GnomeCanvasItem *missing_letter_create_item(GnomeCanvasGroup *parent) board_number = (gcomprisBoard->level-1) * NUMBER_OF_SUBLEVELS + gcomprisBoard->sublevel-1; g_assert(board_number >= 0 && board_number < g_list_length(board_list)); - place = ((int)(3.0*rand()/(RAND_MAX+1.0))); + place = g_random_int_range( 0, 3); g_assert(place >= 0 && place < 3); right_word = place+1; diff --git a/src/boards/money.c b/src/boards/money.c index 68ca52e..3f85f33 100644 --- a/src/boards/money.c +++ b/src/boards/money.c @@ -469,7 +469,7 @@ static void money_next_level() double object_price; gchar *text; - pixmap = gc_pixmap_load(imageList[RAND(0, NUMBER_OF_IMAGES-1)]); + pixmap = gc_pixmap_load(imageList[g_random_int_range(0, NUMBER_OF_IMAGES-1)]); gnome_canvas_item_new ( boardRootItem, gnome_canvas_pixbuf_get_type (), @@ -480,7 +480,7 @@ static void money_next_level() NULL); /* Diplay the price */ - object_price = (double) RAND(min_price/number_of_item, max_price/number_of_item); + object_price = (double) g_random_int_range(min_price/number_of_item, max_price/number_of_item); if(currentMode==WITH_CENTS) { @@ -489,11 +489,11 @@ static void money_next_level() /* Add random cents */ if(gcomprisBoard->level == 1) { - object_price += (double)((double) RAND(1, 9))/10.0; + object_price += (double)((double) g_random_int_range(1, 9))/10.0; } else { - object_price += (double)((double) RAND(1, 99))/100.0; + object_price += (double)((double) g_random_int_range(1, 99))/100.0; } } else diff --git a/src/boards/paratrooper.c b/src/boards/paratrooper.c index 4a380c8..804ef50 100644 --- a/src/boards/paratrooper.c +++ b/src/boards/paratrooper.c @@ -337,8 +337,8 @@ static void paratrooper_next_level() NULL); gdk_pixbuf_unref(pixmap); - windspeed = (3 + rand()%gcomprisBoard->level); - if(rand()%2==0) + windspeed = (3 + g_random_int()%gcomprisBoard->level); + if(g_random_int()%2==0) windspeed *= -1; /* Drop a cloud */ @@ -620,7 +620,7 @@ static GnomeCanvasItem *paratrooper_create_cloud(GnomeCanvasGroup *parent) gnome_canvas_item_new (parent, gnome_canvas_group_get_type (), "x", (double) x, - "y", (double)(rand()%(gcomprisBoard->height-200- + "y", (double)(g_random_int()%(gcomprisBoard->height-200- (guint)(gdk_pixbuf_get_height(pixmap)* imageZoom))), NULL); diff --git a/src/boards/planegame.c b/src/boards/planegame.c index f0aa74b..251dbf5 100644 --- a/src/boards/planegame.c +++ b/src/boards/planegame.c @@ -469,7 +469,7 @@ static GnomeCanvasItem *planegame_create_item(GnomeCanvasGroup *parent) CloudItem *clouditem; /* Random cloud number */ - if(rand()%2==0) + if(g_random_int()%2==0) { /* Put the target */ i = plane_target; @@ -477,7 +477,7 @@ static GnomeCanvasItem *planegame_create_item(GnomeCanvasGroup *parent) else { min = MAX(1, plane_target - 1); - i = min + rand()%(plane_target - min + 3); + i = min + g_random_int()%(plane_target - min + 3); } number = g_strdup_printf("%d", i); @@ -487,7 +487,7 @@ static GnomeCanvasItem *planegame_create_item(GnomeCanvasGroup *parent) gnome_canvas_item_new (parent, gnome_canvas_group_get_type (), "x", (double) gcomprisBoard->width, - "y", (double)(rand()%(gcomprisBoard->height- + "y", (double)(g_random_int()%(gcomprisBoard->height- (guint)(gdk_pixbuf_get_height(pixmap)* imageZoom))), NULL); diff --git a/src/boards/py-mod-gcompris.c b/src/boards/py-mod-gcompris.c index 12c1bd3..c5ae83c 100644 --- a/src/boards/py-mod-gcompris.c +++ b/src/boards/py-mod-gcompris.c @@ -671,7 +671,7 @@ py_gcompris_child_watch_add(PyObject *unused, PyObject *args, PyObject *kwargs) static char *kwlist[] = { "pid", "function", "data", "priority", NULL }; guint id; gint priority = G_PRIORITY_DEFAULT; - int pid; + GPid pid; PyObject *func, *user_data = NULL; struct _PyGChildData *child_data; @@ -738,7 +738,7 @@ py_gcompris_spawn_async(PyObject *unused, PyObject *args, PyObject *kwargs) gint *standard_input, *standard_output, *standard_error; struct _PyGChildSetupData *callback_data = NULL; GError *error = NULL; - GPid child_pid = -1; + GPid child_pid = (GPid) -1; int len, i; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|OsiOOOOO:gcompris.spawn_async", diff --git a/src/boards/python/tuxpaint.py b/src/boards/python/tuxpaint.py index ae0c7fa..dea43b6 100644 --- a/src/boards/python/tuxpaint.py +++ b/src/boards/python/tuxpaint.py @@ -1,252 +1,272 @@ -# gcompris - Tuxpaint Launcher -# -# Copyright (C) 2004 Yves Combe -# -# 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 gnomecanvas -import gcompris -import gcompris.utils -import gcompris.bonus -import gcompris.skin -import gcompris.sound -import gcompris.admin -import gtk -import os - -import pango - -#import gobject -from gettext import gettext as _ - -pid = None -#board = None - -class Gcompris_tuxpaint: - """TuxPaint Launcher""" - global pid - - def __init__(self, gcomprisBoard): - self.gcomprisBoard = gcomprisBoard - pass - - def configuration(self, value, init): - if self.config_dict.has_key(value): - return eval(self.config_dict[value]) - else: - return init - - def start(self): -# line = os.sys.stdin.readline() -# while (len(line) >1): -# exec(line) -# line = os.sys.stdin.readline() - - self.window = self.gcomprisBoard.canvas.get_toplevel() - - #global board - #board = self - - Prop = gcompris.get_properties() - - #get default values - self.config_dict = self.init_config() - - #replace configured values - self.config_dict.update(gcompris.get_board_conf()) - - self.rootitem = self.gcomprisBoard.canvas.root().add( - gnomecanvas.CanvasGroup, - x=0.0, - y=0.0 - ) - - options = ['tuxpaint'] - - if (Prop.fullscreen and eval(self.config_dict['fullscreen'])): - options.append('--fullscreen') - - # tuxpaint size are 800x600 and 640x480 in 9.14 - # in cvs (future 9.15) it will be - # [--640x480 | --800x600 | --1024x768 | - # --1280x1024 | --1400x1050 | --1600x1200] - if (Prop.screensize and eval(self.config_dict['size'])): - if (Prop.screensize >=1): - print 'Prop.screensize', Prop.screensize - options.append('--800x600') - else: - options.append('--640x480') - - if eval(self.config_dict['disable_shape_rotation']): - options.append('--simpleshapes') - - if eval(self.config_dict['uppercase_text']): - options.append('--uppercase') - - if eval(self.config_dict['disable_stamps']): - options.append('--nostamps') - - if eval(self.config_dict['disable_stamps_control']): - options.append('--nostampcontrols') - - gcompris.sound.close() - - # release pointergrab if running fullscreen, tuxpaint wants to grab the - # pointer itself - if (Prop.fullscreen and not Prop.noxf86vm): - gtk.gdk.pointer_ungrab() - - #self.window.set_property("accept-focus", 0) - #self.window.set_keep_below(False) - - try: - # gobject.SPAWN_DO_NOT_REAP_CHILD|gobject.SPAWN_SEARCH_PATH = 2 | 4 - pid,stdin, stdout, stderr = gcompris.spawn_async( - options, flags=2|4) - except: - gcompris.utils.dialog(_("Cannot find Tuxpaint.\nInstall it to use this activity !"),stop_board) - return - - gcompris.child_watch_add(pid, child_callback, self) - - gcompris.bar_set(0) - gcompris.bar_hide(1) - - gcompris.set_background(self.rootitem, - gcompris.skin.image_to_skin("gcompris-bg.jpg")) - - textItem = self.rootitem.add( - gnomecanvas.CanvasText, - text = _("Waiting for Tuxpaint to finish"), - x = gcompris.BOARD_WIDTH/2, - y = 185, - fill_color_rgba = 0x000000ffL, - font = gcompris.skin.get_font("gcompris/board/title bold"), - ) - - def end(self): - gcompris.sound.reopen() - global pid - # force kill - data loss - if pid != None: - print "Tuxpaint not killed", self.pid - #import os - #os.kill(self.pid, signal.SIGKILL) - if self.rootitem != None: - self.rootitem.destroy() - self.rootitem = None - - def set_level(self,level): - pass - - def ok(self): - pass - - def key_press(self, keyval, commit_str, preedit_str): - return False - - def repeat(self): - pass - - def pause(self, pause): - pass - - def config(self): - print "Config" - pass - - def config_stop(self): - print "config_stop", self - pass - - def config_start(self, profile): - self.configure_profile = profile - - #get default values - self.config_dict = self.init_config() - - #set already configured values - self.config_dict.update(gcompris.get_conf(profile, self.gcomprisBoard)) - - self.main_vbox = gcompris.configuration_window(_('<b>%s</b> configuration\n for profile <b>%s</b>') % ('Tuxpaint', profile.name ), - self.apply_callback) - - - gcompris.boolean_box(_('Inherit fullscreen setting from GCompris'), 'fullscreen', eval(self.config_dict['fullscreen'])) - - gcompris.separator() - - gcompris.boolean_box(_('Inherit size setting from GCompris (800x600, 640x480)'), 'size', eval(self.config_dict['size'])) - - gcompris.separator() - - gcompris.boolean_box(_('Disable shape rotation'), 'disable_shape_rotation', eval(self.config_dict['disable_shape_rotation'])) - - gcompris.separator() - - gcompris.boolean_box(_('Show Uppercase text only'), 'uppercase_text', eval(self.config_dict['uppercase_text'])) - - gcompris.separator() - - stamps = gcompris.boolean_box(_('Disable stamps'), 'disable_stamps', eval(self.config_dict['disable_stamps'])) - stamps.connect("toggled", self.stamps_changed) - - self.stamps_control = gcompris.boolean_box('Disable stamps control', 'disable_stamps_control', eval(self.config_dict['disable_stamps_control'])) - self.stamps_control.set_sensitive(not eval(self.config_dict['disable_stamps'])) - - def stamps_changed(self, button): - self.stamps_control.set_sensitive(not button.get_active()) - - def apply_callback(self,table): - print table - for key,value in table.iteritems(): - gcompris.set_board_conf(self.configure_profile, self.gcomprisBoard, key, value) - - def init_config(self): - default_config_dict = { 'fullscreen' : 'True', - 'disable_shape_rotation' : 'False', - 'uppercase_text' : 'False', - 'disable_stamps' : 'False', - 'disable_stamps_control' : 'False', - 'size' : 'True' - } - return default_config_dict - -def child_callback(fd, cond, data): - # restore pointergrab if running fullscreen - if (gcompris.get_properties().fullscreen and - not gcompris.get_properties().noxf86vm): - gtk.gdk.pointer_grab(data.window.window, True, 0, data.window.window) - #global board - #board.window.set_property("accept-focus", 1) - #board.window.set_keep_above(False) - gcompris.sound.reopen() - - #a bug in tuxpaint 9.14: it does not suppress it lockfile - lockfile = os.getenv('HOME') + '/.tuxpaint/lockfile.dat' - - try: - os.remove(lockfile) - except: - print lockfile, 'not removed.' - - global pid - pid = None - gcompris.bar_hide(0) - gcompris.bonus.board_finished(gcompris.bonus.FINISHED_RANDOM) - -def stop_board(): - gcompris.bonus.board_finished(gcompris.bonus.FINISHED_RANDOM) - +# gcompris - Tuxpaint Launcher
+#
+# Copyright (C) 2004 Yves Combe
+#
+# 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 gnomecanvas
+import gcompris
+import gcompris.utils
+import gcompris.bonus
+import gcompris.skin
+import gcompris.sound
+import gcompris.admin
+import gtk
+import os
+import gobject
+
+import pango
+import platform
+
+#import gobject
+from gettext import gettext as _
+
+pid = None
+
+class Gcompris_tuxpaint:
+ """TuxPaint Launcher"""
+ global pid
+
+ def __init__(self, gcomprisBoard):
+ self.gcomprisBoard = gcomprisBoard
+ pass
+
+ def configuration(self, value, init):
+ if self.config_dict.has_key(value):
+ return eval(self.config_dict[value])
+ else:
+ return init
+
+ def start(self):
+ progname='tuxpaint'
+ tuxpaint_dir = None
+ flags = gobject.SPAWN_DO_NOT_REAP_CHILD | gobject.SPAWN_SEARCH_PATH
+
+ print platform.platform(), platform.platform().split('-')[0]
+ if (platform.platform().split('-')[0] == 'Windows'):
+ progname = 'tuxpaint.exe'
+
+ try:
+ import _winreg
+
+ tuxpaint_key = _winreg.OpenKey( _winreg.HKEY_LOCAL_MACHINE,
+ "Software\\TuxPaint" )
+ tuxpaint_dir, type = _winreg.QueryValueEx(tuxpaint_key, "Install_Dir")
+ flags = gobject.SPAWN_DO_NOT_REAP_CHILD
+ # escape mandatory in Win pygtk2.6
+ tuxpaint_dir = '"' + tuxpaint_dir + '"'
+
+ except:
+ pass
+
+ self.window = self.gcomprisBoard.canvas.get_toplevel()
+
+ #global board
+ #board = self
+
+ Prop = gcompris.get_properties()
+
+ #get default values
+ self.config_dict = self.init_config()
+
+ #replace configured values
+ self.config_dict.update(gcompris.get_board_conf())
+
+ self.rootitem = self.gcomprisBoard.canvas.root().add(
+ gnomecanvas.CanvasGroup,
+ x=0.0,
+ y=0.0
+ )
+
+ options = [progname]
+
+ if (Prop.fullscreen and eval(self.config_dict['fullscreen'])):
+ options.append('--fullscreen')
+
+ # tuxpaint size are 800x600 and 640x480 in 9.14
+ # in cvs (future 9.15) it will be
+ # [--640x480 | --800x600 | --1024x768 |
+ # --1280x1024 | --1400x1050 | --1600x1200]
+ if (Prop.screensize and eval(self.config_dict['size'])):
+ if (Prop.screensize >=1):
+ options.append('--800x600')
+ else:
+ options.append('--640x480')
+
+ if eval(self.config_dict['disable_shape_rotation']):
+ options.append('--simpleshapes')
+
+ if eval(self.config_dict['uppercase_text']):
+ options.append('--uppercase')
+
+ if eval(self.config_dict['disable_stamps']):
+ options.append('--nostamps')
+
+ if eval(self.config_dict['disable_stamps_control']):
+ options.append('--nostampcontrols')
+
+ gcompris.sound.close()
+
+ # release pointergrab if running fullscreen, tuxpaint wants to grab the
+ # pointer itself
+ if (Prop.fullscreen and not Prop.noxf86vm):
+ gtk.gdk.pointer_ungrab()
+
+ #self.window.set_property("accept-focus", 0)
+ #self.window.set_keep_below(False)
+
+ try:
+ # bug in working_directory=None ?
+ if (tuxpaint_dir):
+ pid, stdin, stdout, stderr = gobject.spawn_async(
+ argv=options,
+ flags=flags,
+ working_directory=tuxpaint_dir)
+
+ else:
+ pid, stdin, stdout, stderr = gobject.spawn_async(
+ argv=options,
+ flags=flags)
+
+ except:
+ gcompris.utils.dialog(_("Cannot find Tuxpaint.\nInstall it to use this activity !"),stop_board)
+ return
+
+ gobject.child_watch_add(pid, child_callback, data=self, priority=gobject.PRIORITY_HIGH)
+
+ gcompris.bar_set(0)
+ gcompris.bar_hide(1)
+
+ gcompris.set_background(self.rootitem,
+ gcompris.skin.image_to_skin("gcompris-bg.jpg"))
+
+ textItem = self.rootitem.add(
+ gnomecanvas.CanvasText,
+ text = _("Waiting for Tuxpaint to finish"),
+ x = gcompris.BOARD_WIDTH/2,
+ y = 185,
+ fill_color_rgba = 0x000000ffL,
+ font = gcompris.skin.get_font("gcompris/board/title bold"),
+ )
+
+ def end(self):
+ gcompris.sound.reopen()
+ global pid
+ # force kill - data loss
+ if pid != None:
+ print "Tuxpaint not killed", self.pid
+ #import os
+ #os.kill(self.pid, signal.SIGKILL)
+ if self.rootitem != None:
+ self.rootitem.destroy()
+ self.rootitem = None
+
+ def set_level(self,level):
+ pass
+
+ def ok(self):
+ pass
+
+ def key_press(self, keyval, commit_str, preedit_str):
+ return False
+
+ def repeat(self):
+ pass
+
+ def pause(self, pause):
+ pass
+
+ def config(self):
+ print "Config"
+ pass
+
+ def config_stop(self):
+ print "config_stop", self
+ pass
+
+ def config_start(self, profile):
+ self.configure_profile = profile
+
+ #get default values
+ self.config_dict = self.init_config()
+
+ #set already configured values
+ self.config_dict.update(gcompris.get_conf(profile, self.gcomprisBoard))
+
+ self.main_vbox = gcompris.configuration_window(_('<b>%s</b> configuration\n for profile <b>%s</b>') % ('Tuxpaint', profile.name ),
+ self.apply_callback)
+
+
+ gcompris.boolean_box(_('Inherit fullscreen setting from GCompris'), 'fullscreen', eval(self.config_dict['fullscreen']))
+
+ gcompris.separator()
+
+ gcompris.boolean_box(_('Inherit size setting from GCompris (800x600, 640x480)'), 'size', eval(self.config_dict['size']))
+
+ gcompris.separator()
+
+ gcompris.boolean_box(_('Disable shape rotation'), 'disable_shape_rotation', eval(self.config_dict['disable_shape_rotation']))
+
+ gcompris.separator()
+
+ gcompris.boolean_box(_('Show Uppercase text only'), 'uppercase_text', eval(self.config_dict['uppercase_text']))
+
+ gcompris.separator()
+
+ stamps = gcompris.boolean_box(_('Disable stamps'), 'disable_stamps', eval(self.config_dict['disable_stamps']))
+ stamps.connect("toggled", self.stamps_changed)
+
+ self.stamps_control = gcompris.boolean_box('Disable stamps control', 'disable_stamps_control', eval(self.config_dict['disable_stamps_control']))
+ self.stamps_control.set_sensitive(not eval(self.config_dict['disable_stamps']))
+
+ def stamps_changed(self, button):
+ self.stamps_control.set_sensitive(not button.get_active())
+
+ def apply_callback(self,table):
+ print table
+ for key,value in table.iteritems():
+ gcompris.set_board_conf(self.configure_profile, self.gcomprisBoard, key, value)
+
+ def init_config(self):
+ default_config_dict = { 'fullscreen' : 'True',
+ 'disable_shape_rotation' : 'False',
+ 'uppercase_text' : 'False',
+ 'disable_stamps' : 'False',
+ 'disable_stamps_control' : 'False',
+ 'size' : 'True'
+ }
+ return default_config_dict
+
+def child_callback(fd, cond, data):
+ # restore pointergrab if running fullscreen
+ if (gcompris.get_properties().fullscreen and
+ not gcompris.get_properties().noxf86vm):
+ gtk.gdk.pointer_grab(data.window.window, True, 0, data.window.window)
+
+ #bug in gtk2.6/window
+ if (gtk.gtk_version <= (2,6,10)):
+ data.window.unfullscreen()
+ data.window.fullscreen()
+
+ gcompris.sound.reopen()
+
+ global pid
+ pid = None
+ gcompris.bar_hide(0)
+ gcompris.bonus.board_finished(gcompris.bonus.FINISHED_RANDOM)
+
+def stop_board():
+ gcompris.bonus.board_finished(gcompris.bonus.FINISHED_RANDOM)
+
diff --git a/src/boards/railroad.c b/src/boards/railroad.c index 7387372..76c0ccc 100644 --- a/src/boards/railroad.c +++ b/src/boards/railroad.c @@ -357,7 +357,7 @@ static GnomeCanvasItem *railroad_create_item(GnomeCanvasGroup *parent) model_size = gcomprisBoard->level +1; // engine + cars // First the cars, depending of the level for (i=0; i<model_size-1; i++) { - r = (int)(((float) WAGONS)*rand()/(RAND_MAX+1.0)); + r = g_random_int_range( 0, WAGONS); g_assert( r >=0 && r < WAGONS); // keep track of the answer int_model_list = g_list_append(int_model_list, GINT_TO_POINTER(r+ENGINES)); @@ -373,7 +373,7 @@ static GnomeCanvasItem *railroad_create_item(GnomeCanvasGroup *parent) } // Then the engine - r = (int)(((float) ENGINES)*rand()/(RAND_MAX+1.0)); + r = g_random_int_range( 0, ENGINES); g_assert( r >=0 && r < ENGINES); // keep track of the answer int_model_list = g_list_append(int_model_list, GINT_TO_POINTER(r)); diff --git a/src/boards/read_colors.c b/src/boards/read_colors.c index f5997ac..06caa2f 100644 --- a/src/boards/read_colors.c +++ b/src/boards/read_colors.c @@ -127,7 +127,7 @@ static void pause_board (gboolean pause) static void start_board (GcomprisBoard *agcomprisBoard) { GList * list = NULL; int * item; - int i; + int i,list_length; if(agcomprisBoard!=NULL) { gcomprisBoard=agcomprisBoard; @@ -148,8 +148,8 @@ static void start_board (GcomprisBoard *agcomprisBoard) { for (i=0; i<LAST_COLOR; i++) list = g_list_append(list, GINT_TO_POINTER(i)); - while ((g_list_length(list) > 0)) { - i = RAND(0,g_list_length(list)-1); + while ((list_length = g_list_length(list))) { + i = list_length == 1 ? 0 : g_random_int_range(0,g_list_length(list)-1); item = g_list_nth_data(list, i); listColors = g_list_append(listColors, item); list = g_list_remove(list, item); diff --git a/src/boards/reading.c b/src/boards/reading.c index 1926d01..a89f7b3 100644 --- a/src/boards/reading.c +++ b/src/boards/reading.c @@ -362,7 +362,6 @@ static GnomeCanvasItem *display_what_to_do(GnomeCanvasGroup *parent) gint base_Y = 110; gint base_X = 580; - gint i; /* Load the text to find */ @@ -372,9 +371,8 @@ static GnomeCanvasItem *display_what_to_do(GnomeCanvasGroup *parent) /* Decide now if this time we will display the text to find */ /* Use this formula to have a better random number see 'man 3 rand' */ - i=((int)(2.0*rand()/(RAND_MAX+1.0))); - if(i==0) - textToFindIndex = rand() % numberOfLine; + if(g_random_boolean()) + textToFindIndex = g_random_int_range(0, numberOfLine); else textToFindIndex = NOT_THERE; diff --git a/src/boards/reversecount.c b/src/boards/reversecount.c index a81bf9a..f9872bc 100644 --- a/src/boards/reversecount.c +++ b/src/boards/reversecount.c @@ -570,13 +570,13 @@ static void display_random_fish() { fish_index = tux_index + - rand()%(max_dice_number*number_of_dices) + 1; + g_random_int()%(max_dice_number*number_of_dices) + 1; // Wrapping if(fish_index >= number_of_item) fish_index = fish_index - (number_of_item); - fishItem = display_item_at(fishList[rand()%NUMBER_OF_FISHES], + fishItem = display_item_at(fishList[g_random_int()%NUMBER_OF_FISHES], fish_index, -1); } diff --git a/src/boards/shapegame.c b/src/boards/shapegame.c index abf754f..6af6207 100644 --- a/src/boards/shapegame.c +++ b/src/boards/shapegame.c @@ -1954,6 +1954,7 @@ parse_doc(xmlDocPtr doc) xmlNodePtr node; GList *list; GnomeCanvasItem *item; + int list_length, i; /* find <Shape> nodes and add them to the list, this just loops through all the children of the root of the document */ @@ -1966,11 +1967,12 @@ parse_doc(xmlDocPtr doc) shape_list = g_list_copy(shape_list_init); /* Insert each of the shapes randomly */ - while(g_list_length(shape_list_init)>0) + while((list_length = g_list_length(shape_list_init))) { Shape *shape; - shape = g_list_nth_data(shape_list_init, RAND(0, (g_list_length(shape_list_init)-1))); + i = list_length == 1 ? 0 : g_random_int_range(0, g_list_length(shape_list_init)-1); + shape = g_list_nth_data(shape_list_init, i); add_shape_to_canvas(shape); shape_list_init = g_list_remove (shape_list_init, shape); diff --git a/src/boards/smallnumbers.c b/src/boards/smallnumbers.c index 4ad1d10..08cac23 100644 --- a/src/boards/smallnumbers.c +++ b/src/boards/smallnumbers.c @@ -376,9 +376,9 @@ static void smallnumbers_create_item(GnomeCanvasGroup *parent) /* Take care not to go above 9 anyway */ if(total_number==0) { - i=rand()%6; + i=g_random_int()%6; } else { - int rando = rand()%(9-total_number); + int rando = g_random_int()%(9-total_number); i=MIN(rando, 5); } @@ -434,7 +434,7 @@ static void smallnumbers_create_item(GnomeCanvasGroup *parent) if(x==0.0) { - x = (double)(rand()%(gcomprisBoard->width- + x = (double)(g_random_int()%(gcomprisBoard->width- (guint)(gdk_pixbuf_get_width(smallnumbers_pixmap)* imageZoom)*2)); } else diff --git a/src/boards/submarine.c b/src/boards/submarine.c index c4e6331..1aaea62 100644 --- a/src/boards/submarine.c +++ b/src/boards/submarine.c @@ -779,8 +779,8 @@ static GnomeCanvasItem *submarine_create_item(GnomeCanvasGroup *parent) { // whale item str = g_strdup_printf("%s/%s", gcomprisBoard->boarddir, "whale.png"); pixmap = gc_pixmap_load(str); - whale_x = RAND((int)(gdk_pixbuf_get_width(pixmap)), (int)(gcomprisBoard->width-gdk_pixbuf_get_width(pixmap))); - whale_y = RAND((int)(SURFACE_IN_BACKGROUND + gdk_pixbuf_get_height(pixmap)),(int)MAX_DEPTH); + whale_x = g_random_int_range((int)(gdk_pixbuf_get_width(pixmap)), (int)(gcomprisBoard->width-gdk_pixbuf_get_width(pixmap))); + whale_y = g_random_int_range((int)(SURFACE_IN_BACKGROUND + gdk_pixbuf_get_height(pixmap)),(int)MAX_DEPTH); whale = gnome_canvas_item_new (boardRootItem, gnome_canvas_pixbuf_get_type (), "pixbuf", pixmap, diff --git a/src/boards/superbrain.c b/src/boards/superbrain.c index 769dc66..797bb69 100644 --- a/src/boards/superbrain.c +++ b/src/boards/superbrain.c @@ -258,9 +258,9 @@ static void superbrain_next_level() { guint j; - j = (guint)RAND(1, number_of_color); + j = (guint)g_random_int_range(1, number_of_color); while(selected_color[j]) - j = (guint)RAND(1, number_of_color); + j = (guint)g_random_int_range(1, number_of_color); solution[i] = j; selected_color[j] = TRUE; diff --git a/src/boards/target.c b/src/boards/target.c index d81de24..29466a9 100644 --- a/src/boards/target.c +++ b/src/boards/target.c @@ -362,12 +362,12 @@ static void display_windspeed() NULL)); /* Speed orientation */ - second = rand()%60; + second = g_random_int()%60; ang = second * M_PI / 30; /* Speed force */ wind_speed = targetDefinition[gcomprisBoard->level-1].target_min_wind_speed \ - + rand()%(targetDefinition[gcomprisBoard->level-1].target_max_wind_speed \ + + g_random_int()%(targetDefinition[gcomprisBoard->level-1].target_max_wind_speed \ - targetDefinition[gcomprisBoard->level-1].target_min_wind_speed); canvasPoints->coords[0]=SPEED_CENTER_X; diff --git a/src/boards/wordsgame.c b/src/boards/wordsgame.c index 05a5044..51d5e61 100644 --- a/src/boards/wordsgame.c +++ b/src/boards/wordsgame.c @@ -636,7 +636,7 @@ static GnomeCanvasItem *wordsgame_create_item(GnomeCanvasGroup *parent) &x2, &y2); - gnome_canvas_item_move (item->rootitem,(double) (rand()%(gcomprisBoard->width-(gint)(x2))),(double) 0); + gnome_canvas_item_move (item->rootitem,(double) (g_random_int()%(gcomprisBoard->width-(gint)(x2))),(double) 0); g_static_rw_lock_writer_lock (&items_lock); diff --git a/src/gcompris/Makefile.am b/src/gcompris/Makefile.am index 6a444f7..f796882 100644 --- a/src/gcompris/Makefile.am +++ b/src/gcompris/Makefile.am @@ -27,6 +27,25 @@ endif #cairo_c = #endif +if PLATFORM_WIN32 +no_undefined = -no-undefined +shared = -shared +else +no_undefined = +shared = +endif + +if OS_WIN32 +install-libtool-import-lib: + $(INSTALL) .libs/libgcompris-1.dll.a $(DESTDIR)$(libdir) + +uninstall-libtool-import-lib: + -rm $(DESTDIR)$(libdir)/libgcompris-1.dll.a +else +install-libtool-import-lib: +uninstall-libtool-import-lib: +endif + bin_PROGRAMS = gcompris INCLUDES = \ @@ -45,26 +64,25 @@ gcompris_SOURCES = \ main.c gcompris_LDFLAGS = \ - -export-dynamic $(python_ldflags) $(SDL_LIBS) $(cairo_ldflags) + -export-dynamic $(python_ldflags) $(cairo_ldflags) gcompris_LDADD = \ + $(top_builddir)/src/gcompris/libgcompris-1.la \ $(LIBICONV) \ $(INTLLIBS) \ $(python_ldadd) \ - $(top_builddir)/src/gcompris/libgcompris-1.la \ $(LIBPOPT) - # # Gcompris library # lib_LTLIBRARIES = libgcompris-1.la libgcompris_1_la_LIBADD = \ - $(GCOMPRIS_LIBS) $(sqlite_ldadd) $(XML_LIBS) $(GNET_LIBS) + $(GCOMPRIS_LIBS) $(sqlite_ldadd) $(XML_LIBS) $(GNET_LIBS) $(SDL_LIBS) -libgcompris_1_la_LDFLAGS = \ +libgcompris_1_la_LDFLAGS = $(shared) $(no_undefined) \ -version-info $(LIBGCOMPRIS_CURRENT):$(LIBGCOMPRIS_REVISION):$(LIBGCOMPRIS_AGE) libgcomprisincludedir = $(includedir)/libgcompris-1.0/libgcompris @@ -164,5 +182,9 @@ dist-hook: rm -f $(distdir)/$$file ; \ done +install-data-local: install-libtool-import-lib + +uninstall-local: uninstall-libtool-import-lib + clean-local: rm -f $(marshal_sources) diff --git a/src/gcompris/Makefile.mingw b/src/gcompris/Makefile.mingw index 437ea59..6493872 100644 --- a/src/gcompris/Makefile.mingw +++ b/src/gcompris/Makefile.mingw @@ -29,7 +29,7 @@ TARGET = gcompris # Compiler and Linker Options -CFLAGS = +CFLAGS = -DSTATIC_MODULE DEFINES = diff --git a/src/gcompris/binreloc.c b/src/gcompris/binreloc.c index 6b92634..03ffbc7 100644 --- a/src/gcompris/binreloc.c +++ b/src/gcompris/binreloc.c @@ -17,7 +17,6 @@ #ifdef ENABLE_BINRELOC #include <sys/types.h> - #include <sys/stat.h> #include <unistd.h> #endif /* ENABLE_BINRELOC */ #include <glib/gstdio.h> @@ -86,7 +85,7 @@ _br_find_exe (GbrInitError *error) /* Check whether the symlink's target is also a symlink. * We want to get the final target. */ - i = stat (path, &stat_buf); + i = g_stat (path, &stat_buf); if (i == -1) { /* Error. */ g_free (path2); diff --git a/src/gcompris/board.c b/src/gcompris/board.c index e86d776..cbde963 100644 --- a/src/gcompris/board.c +++ b/src/gcompris/board.c @@ -28,7 +28,7 @@ static struct BoardPluginData *bp_data; static gboolean get_board_playing(void); -#ifdef WIN32 +#ifdef STATIC_MODULE int gc_activation_check(char *code); extern BoardPlugin * get_advanced_colors_bplugin_info(); extern BoardPlugin * get_algebra_bplugin_info(); @@ -79,7 +79,7 @@ static BoardPlugin *static_boards[MAX_NUMBER_OF_BOARDS]; #endif -#ifdef WIN32 +#ifdef STATIC_MODULE int gc_board_number_in_demo; void gc_board_init(void) { @@ -203,7 +203,7 @@ void gc_board_set_current(GcomprisBoard * gcomprisBoard) bp_data->current_gcompris_board = gcomprisBoard; } -#ifdef WIN32 +#ifdef STATIC_MODULE gboolean gc_board_check_file(GcomprisBoard *gcomprisBoard) { @@ -380,6 +380,7 @@ gc_board_pause(int pause) if(gc_board_get_current_board_plugin()->pause_board) gc_board_get_current_board_plugin()->pause_board(pause); } + else g_warning ("No boards to pause ?"); } void diff --git a/src/gcompris/board.h b/src/gcompris/board.h index cec22ac..8a81f89 100644 --- a/src/gcompris/board.h +++ b/src/gcompris/board.h @@ -23,9 +23,9 @@ /** * Handles plugins initialization * - * WIN32 = Static module, else it's dynamic + * STATIC_MODULE = Static module, else it's dynamic */ -#if defined WIN32 +#if defined STATIC_MODULE #define GET_BPLUGIN_INFO(pluginname) \ BoardPlugin \ *get_##pluginname##_bplugin_info(void) \ @@ -34,8 +34,16 @@ } \ BoardPlugin * _##pluginname##_menu_bp = &menu_bp; #else + +#ifdef BOARD_DLL_EXPORT +// the dll exports +# define EXPORT __declspec(dllexport) +#else +# define EXPORT +#endif + #define GET_BPLUGIN_INFO(pluginname) \ - BoardPlugin \ +EXPORT BoardPlugin \ *get_bplugin_info(void) \ { \ return &menu_bp; \ diff --git a/src/gcompris/bonus.c b/src/gcompris/bonus.c index b434507..c94adf3 100644 --- a/src/gcompris/bonus.c +++ b/src/gcompris/bonus.c @@ -212,20 +212,28 @@ gc_bonus_end_display(BoardFinishedList type) { void gc_bonus_display(BonusStatusList gamewon, BonusList bonus_id) { + g_warning("bonus display %d %d", (int) gamewon, (int) bonus_id); gchar *absolute_file; g_assert(bonus_id < BONUS_LAST); + g_warning("bar_hide..."); gc_bar_hide(TRUE); + g_warning("bar_hide... ok"); - if (bonus_display_running) + if (bonus_display_running) { + g_warning("error bonus_display_running !"); return; + } else bonus_display_running = TRUE; if(gamewon == BOARD_WIN || gamewon == BOARD_DRAW) { + g_warning("bonus absolute filename... "); absolute_file = gc_file_find_absolute(greetingsList[RAND(0, NUMBER_OF_GREETINGS-1)]); + g_warning("bonus absolute filename: %s", absolute_file ); + if (absolute_file) { gc_sound_play_ogg(absolute_file, NULL); @@ -247,7 +255,9 @@ gc_bonus_display(BonusStatusList gamewon, BonusList bonus_id) } /* First pause the board */ + g_warning("Pausinng board ..."); gc_board_pause(TRUE); + g_warning("Pausinng board ...ok"); if(bonus_id==BONUS_RANDOM) bonus_id = RAND(1, BONUS_LAST-2); @@ -278,8 +288,15 @@ bonus_image(char *image, BonusStatusList gamewon) char *str= NULL; int x,y; GdkPixbuf *pixmap = NULL; + + g_warning("Bonus_image: gc_board_get_current..."); + GcomprisBoard *gcomprisBoard = gc_board_get_current(); + g_assert(gcomprisBoard); + + g_warning("Bonus_image: gc_board_get_current... ok"); + /* check that bonus_group is a singleton */ if (bonus_group != NULL) { bonus_display_running = FALSE; diff --git a/src/gcompris/file_selector.c b/src/gcompris/file_selector.c index b6aaf2b..f8c577a 100644 --- a/src/gcompris/file_selector.c +++ b/src/gcompris/file_selector.c @@ -847,7 +847,7 @@ static void parse_doc(xmlDocPtr doc) { cur = xmlDocGetRootElement(doc); if (cur == NULL) { - fprintf(stderr,"empty document\n"); + g_warning("empty document\n"); xmlFreeDoc(doc); return; } diff --git a/src/gcompris/gameutil.c b/src/gcompris/gameutil.c index 41792fb..337be1e 100644 --- a/src/gcompris/gameutil.c +++ b/src/gcompris/gameutil.c @@ -23,10 +23,8 @@ #include <string.h> #include <time.h> -/* for gc_util_create_rootdir */ -#include <unistd.h> -#include <sys/types.h> -#include <sys/stat.h> +/* g_mkdir */ +#include <glib/gstdio.h> /* libxml includes */ #include <libxml/parserInternals.h> @@ -630,16 +628,13 @@ gc_util_create_rootdir (gchar *rootdir) /* Case where ~/.gcompris already exist as a file. We remove it */ if(g_file_test(rootdir, G_FILE_TEST_IS_REGULAR)) { - unlink(rootdir); + g_unlink(rootdir); } if(g_file_test(rootdir, G_FILE_TEST_IS_DIR)) { return 0; } -#if defined WIN32 - return(mkdir(rootdir)); -#else - return(mkdir(rootdir, 0755)); -#endif + return(g_mkdir(rootdir, 0755)); + } diff --git a/src/gcompris/gameutil.h b/src/gcompris/gameutil.h index ecfc5c7..cf1a714 100644 --- a/src/gcompris/gameutil.h +++ b/src/gcompris/gameutil.h @@ -33,7 +33,7 @@ #include "soundutil.h" // returns a random integer in range [A,B] -#define RAND(A,B) (A + (int)((float)(B-A+1)*rand()/(RAND_MAX+1.0))) +#define RAND(A,B) (A == B ? A : g_random_int_range((guint32) A,(guint32) B)) #ifndef MAX #define MAX(a,b) (((a) > (b)) ? (a) : (b)) diff --git a/src/gcompris/gcompris.c b/src/gcompris/gcompris.c index 02babbd..83e223e 100644 --- a/src/gcompris/gcompris.c +++ b/src/gcompris/gcompris.c @@ -60,7 +60,7 @@ void gc_terminate(int signum); /* * For the Activation dialog */ -#ifdef WIN32 +#ifdef STATIC_MODULE int gc_activation_check(char *code); static void activation_enter_callback(GtkWidget *widget, GtkWidget *entry ); @@ -785,7 +785,7 @@ static void setup_window () } -#ifdef WIN32 +#ifdef STATIC_MODULE extern int gc_board_number_in_demo; /** Display the activation dialog for the windows version * @@ -924,7 +924,7 @@ activation_done() (strcmp((char *)gtk_entry_get_text(GTK_ENTRY(widget_activation_entry)), "GOOD") != 0) && (strcmp((char *)gtk_entry_get_text(GTK_ENTRY(widget_activation_entry)), "WRONG") != 0)) { - activation_enter_callback(widget_activation_entry, NULL); + activation_enter_callback(GTK_WIDGET(widget_activation_entry), NULL); } gc_board_play(properties->menu_board); @@ -1119,12 +1119,12 @@ static void load_properties () g_free(prefix_dir); - /* Display the directory value we have */ + /* Display the directory and database value we have */ printf("package_data_dir = %s\n", properties->package_data_dir); printf("package_locale_dir = %s\n", properties->package_locale_dir); printf("package_plugin_dir = %s\n", properties->package_plugin_dir); printf("package_python_plugin_dir= %s\n", properties->package_python_plugin_dir); - + printf("database = %s\n", properties->database); } GcomprisProperties *gc_prop_get () @@ -1393,7 +1393,7 @@ gc_init (int argc, char *argv[]) textdomain (GETTEXT_PACKAGE); /* To have some real random behaviour */ - srand (time (NULL)); + g_random_set_seed (time (NULL)); /* Default difficulty filter: non specified */ popt_difficulty_filter = -1; @@ -1662,10 +1662,10 @@ gc_init (int argc, char *argv[]) if(popt_web_only) { g_free(properties->package_data_dir); - properties->package_data_dir = g_strdup(""); + properties->package_data_dir = ""; g_free(properties->system_icon_dir); - properties->system_icon_dir = g_strdup(""); + properties->system_icon_dir = ""; } if (popt_server){ diff --git a/src/gcompris/gcompris_db.c b/src/gcompris/gcompris_db.c index c7f1207..ef9cb7e 100644 --- a/src/gcompris/gcompris_db.c +++ b/src/gcompris/gcompris_db.c @@ -20,8 +20,7 @@ #include <string.h> #include "gcompris.h" -#include <sys/stat.h> - +#include <glib/gstdio.h> #ifdef USE_SQLITE static sqlite3 *gcompris_db=NULL; @@ -127,12 +126,17 @@ int gc_db_init() if (!g_file_test(properties->database, G_FILE_TEST_EXISTS)) creation = TRUE; + +#ifndef WIN32 + /* this stat() does not work on WinXP */ + /* NEEDS CHECKING IN WINXP */ + else { /* we have to check this file is not empty, because bug in administration */ struct stat buf; - if (stat(properties->database, &buf)!=0) + if (g_stat(properties->database, &buf)!=0) g_error("Can't stat %s", properties->database); /* if size of file is null, we recreate the tables */ @@ -141,10 +145,11 @@ int gc_db_init() g_warning("Database file is empty! Trying to create table..."); } } +#endif rc = sqlite3_open(properties->database, &gcompris_db); if( rc ){ - g_error("Can't open database: %s\n", sqlite3_errmsg(gcompris_db)); + g_error("Can't open database %s : %s\n", properties->database, sqlite3_errmsg(gcompris_db)); sqlite3_close(gcompris_db); exit(1); } diff --git a/src/gcompris/images_selector.c b/src/gcompris/images_selector.c index 0bbd9ae..32e27d0 100644 --- a/src/gcompris/images_selector.c +++ b/src/gcompris/images_selector.c @@ -784,7 +784,7 @@ parse_doc(xmlDocPtr doc) { cur = xmlDocGetRootElement(doc); if (cur == NULL) { - fprintf(stderr,"empty document\n"); + g_warning("empty document\n"); xmlFreeDoc(doc); return; } diff --git a/src/gcompris/menu.c b/src/gcompris/menu.c index da1d4cf..9918c5d 100644 --- a/src/gcompris/menu.c +++ b/src/gcompris/menu.c @@ -633,9 +633,19 @@ void gc_menu_load() int db = (gc_profile_get_current() ? TRUE: FALSE); properties->reread_menu = TRUE; gc_menu_load_dir(properties->package_data_dir, db); + + + /* use GTimeVal for portability */ GDate *today = g_date_new(); - g_date_set_time (today, time (NULL)); +#if (GLIB_MAJOR_VERSION > 2) && (GLIB_MINOR_VERSION > 10) + GTimeVal now; + + g_get_current_time (&now); + g_date_set_time_val (today, &now); +#else + g_date_set_time (today, time (NULL)); +#endif gchar date[11]; g_date_strftime (date, 11, "%F", today); gc_db_set_date(date); diff --git a/src/gcompris/properties.c b/src/gcompris/properties.c index 5a8d2d6..2d20020 100644 --- a/src/gcompris/properties.c +++ b/src/gcompris/properties.c @@ -19,6 +19,7 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#define G_STDIO_NO_WRAP_ON_UNIX #include <glib/gstdio.h> #include <fcntl.h> #include <string.h> @@ -78,9 +79,11 @@ gc_prop_user_root_directory_get () { G_CONST_RETURN gchar *home_dir = g_get_home_dir(); - if (home_dir == NULL) /* Win9x */ - return g_strdup("gcompris"); +#ifdef WIN32 + if ( ! G_WIN32_IS_NT_BASED() ) /* Win9x */ + return g_strdup("../gcompris"); else +#endif return g_strconcat(home_dir, "/.gcompris", NULL); } @@ -97,11 +100,13 @@ gc_prop_config_file_get() return(config_file); dir = gc_prop_user_root_directory_get(); /* Was never called, must calculate it */ - if (g_get_home_dir()==NULL) { +#ifdef WIN32 + if (! G_WIN32_IS_NT_BASED() ) { config_file = g_strconcat(dir, "/gcompris.cfg", NULL); - } else { + } else +#endif config_file = g_strconcat(dir, "/gcompris.conf", NULL); - } + g_free(dir); return(config_file); } @@ -128,7 +133,9 @@ gc_prop_new () GScanner *scanner; int filefd; gchar *full_rootdir; +#ifndef WIN32 const gchar *locale; +#endif gchar *user_dir; tmp = (GcomprisProperties *) malloc (sizeof (GcomprisProperties)); diff --git a/src/gcompris/sdlplayer.c b/src/gcompris/sdlplayer.c index 81c750f..5591ff4 100644 --- a/src/gcompris/sdlplayer.c +++ b/src/gcompris/sdlplayer.c @@ -45,15 +45,15 @@ static gboolean sound_closed = FALSE; void errorv(char *str, va_list ap) { - vfprintf(stderr,str,ap); + //vfprintf(stderr,str,ap); if(strcmp(Mix_GetError(), "Unrecognized file type (not VOC)")==0) { - fprintf(stderr,"*** You need a version of \"SDL_mixer\" with OGG Vorbis supported ***\n"); + g_warning("*** You need a version of \"SDL_mixer\" with OGG Vorbis supported ***\n"); exit(EXIT_FAILURE); } - fprintf(stderr,": %s.\n", Mix_GetError()); - fprintf(stderr,": %s.\n", SDL_GetError()); + g_warning(": %s.\n", Mix_GetError()); + g_warning(": %s.\n", SDL_GetError()); } |