diff options
-rw-r--r-- | ChangeLog | 22 | ||||
-rw-r--r-- | INSTALL | 3 | ||||
-rw-r--r-- | src/boards/clickgame.c | 33 | ||||
-rw-r--r-- | src/boards/money_widget.c | 1 | ||||
-rw-r--r-- | src/boards/read_colors.c | 3 | ||||
-rw-r--r-- | src/boards/reading.c | 3 | ||||
-rw-r--r-- | src/gcompris/assetml.c | 26 | ||||
-rw-r--r-- | src/gcompris/bar.c | 3 | ||||
-rw-r--r-- | src/gcompris/bonus.c | 2 | ||||
-rw-r--r-- | src/gcompris/config.c | 29 | ||||
-rw-r--r-- | src/gcompris/file_selector.c | 42 | ||||
-rw-r--r-- | src/gcompris/gameutil.c | 35 | ||||
-rw-r--r-- | src/gcompris/soundutil.c | 16 |
13 files changed, 109 insertions, 109 deletions
@@ -1,3 +1,25 @@ +2005-05-02 Bruno coudoin <bruno.coudoin@free.fr> + + Many little changes to ease the windows port. Now uses the glib + to load files with g_dir_open and no more readdir. + Many compilation warning removed. + + * INSTALL: updated for SDL_mixer + * src/boards/clickgame.c: (clickgame_start): + * src/boards/money_widget.c: (finalize): + * src/boards/read_colors.c: (item_event), (add_xml_data): + * src/boards/reading.c: (reading_create_item): + * src/gcompris/assetml.c: (selectAssetML), (assetml_load_xml): + * src/gcompris/bar.c: (gcompris_bar_start): + * src/gcompris/bonus.c: (board_finished), (gcompris_display_bonus): + * src/gcompris/config.c: (gcompris_config_start): + * src/gcompris/file_selector.c: (display_files), + (gcompris_load_mime_types): + * src/gcompris/gameutil.c: (gcompris_get_asset_file), + (selectMenuXML), (gcompris_load_menus_dir), + (gcompris_display_difficulty_stars): + * src/gcompris/soundutil.c: (scheduler_bgnd): + 2005-04-29 Bruno coudoin <bruno.coudoin@free.fr> * src/gcompris/interface.c: (create_gcompris_edit): removed the menu which uses an obsolete @@ -30,7 +30,7 @@ python-base Now that the sound is managed internally, you also need: libSDL libSDL-mixer -On a Mandrake, you will need to install their -devel counterpart package in +On a Mandriva, you will need to install their -devel counterpart package in order to be abble to compile it plus intltool, tetex. In order to compile gcompris on a mandrake 10.1 you must install : @@ -52,6 +52,7 @@ urpmi texinfo urpmi texi2html urpmi tetex urpmi gnuchess +urpmi libSDL_mixer1.2-devel diff --git a/src/boards/clickgame.c b/src/boards/clickgame.c index 777e401..9135773 100644 --- a/src/boards/clickgame.c +++ b/src/boards/clickgame.c @@ -1,6 +1,6 @@ /* gcompris - clickgame.c * - * Time-stamp: <2004/08/08 22:39:17 bcoudoin> + * Time-stamp: <2005/05/02 01:42:09 bruno> * * Copyright (C) 2000 Bruno Coudoin * @@ -22,7 +22,6 @@ #ifdef __APPLE__ # include <sys/types.h> #endif -#include <dirent.h> #include <string.h> #include "gcompris/gcompris.h" @@ -164,11 +163,11 @@ static void clickgame_pause (gboolean pause) */ static void clickgame_start (GcomprisBoard *agcomprisBoard) { - gint i; - gchar *str; - gchar *filename; - DIR *dir; - struct dirent *one_dirent; + gint i; + gchar *str; + gchar *filename; + GDir *dir; + const gchar *one_dirent; if(agcomprisBoard!=NULL) { @@ -176,27 +175,23 @@ static void clickgame_start (GcomprisBoard *agcomprisBoard) /* Load the Pixpmaps directory file names */ filename = g_strdup_printf("%s/%s", PACKAGE_DATA_DIR, gcomprisBoard->boarddir); - dir = opendir(filename); + dir = g_dir_open(filename, 0, NULL); if (!dir) g_error (_("Couldn't open dir: %s"),filename); g_free(filename); - while((one_dirent = readdir(dir)) != NULL) { + while((one_dirent = g_dir_read_name(dir)) != NULL) { - if (one_dirent->d_name[0] != '.') { - - str = g_strdup_printf("%s/%s", gcomprisBoard->boarddir, one_dirent->d_name); - str[strlen(str)-5]='x'; - - if(g_list_find_custom(pixmaplist, str, (GCompareFunc) strcmp) == NULL) - { - pixmaplist = g_list_append (pixmaplist, str); - } + str = g_strdup_printf("%s/%s", gcomprisBoard->boarddir, one_dirent); + str[strlen(str)-5]='x'; + + if(g_list_find_custom(pixmaplist, str, (GCompareFunc) strcmp) == NULL) { + pixmaplist = g_list_append (pixmaplist, str); } } - closedir(dir); + g_dir_close(dir); /* set initial values for this level */ diff --git a/src/boards/money_widget.c b/src/boards/money_widget.c index cae856b..ff6f3cc 100644 --- a/src/boards/money_widget.c +++ b/src/boards/money_widget.c @@ -110,7 +110,6 @@ money_widget_get_type () static void finalize (GtkObject *object) { - guint i, length; MoneyItem *moneyitem; Money_Widget *moneyWidget = (Money_Widget *) object; diff --git a/src/boards/read_colors.c b/src/boards/read_colors.c index b216a60..3eddecf 100644 --- a/src/boards/read_colors.c +++ b/src/boards/read_colors.c @@ -351,7 +351,7 @@ static void process_ok() { * =====================================================================*/ static gint item_event(GnomeCanvasItem *item, GdkEvent *event, gpointer data) { double x, y; - int i, j, clicked; + int i, clicked; x = event->button.x; y = event->button.y; @@ -419,7 +419,6 @@ static void init_xml() static void add_xml_data(xmlDocPtr doc, xmlNodePtr xmlnode, GNode * child) { char *text = NULL; - char * tmp = NULL; char *sColor = NULL; int color = 0; int i; diff --git a/src/boards/reading.c b/src/boards/reading.c index 16cb4e5..2da7f14 100644 --- a/src/boards/reading.c +++ b/src/boards/reading.c @@ -1,6 +1,6 @@ /* gcompris - reading.c * - * Time-stamp: <2004/11/06 23:14:34 bruno> + * Time-stamp: <2005/04/30 23:14:18 bruno> * * Copyright (C) 2000 Bruno Coudoin * @@ -370,7 +370,6 @@ static GnomeCanvasItem *display_what_to_do(GnomeCanvasGroup *parent) static gboolean reading_create_item(GnomeCanvasGroup *parent) { - gint i; gint anchor = GTK_ANCHOR_CENTER; gchar *word; gchar *overword; diff --git a/src/gcompris/assetml.c b/src/gcompris/assetml.c index 9d21825..2c64684 100644 --- a/src/gcompris/assetml.c +++ b/src/gcompris/assetml.c @@ -17,6 +17,7 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "glib.h" #include "assetml.h" #include <config.h> @@ -25,7 +26,6 @@ #include <libxml/parser.h> #include <locale.h> -#include <dirent.h> #include <string.h> #define FILE_EXT ".assetml" @@ -33,7 +33,7 @@ const gchar *assetml_get_locale(void); static gchar *reactivate_newline(gchar *str); static void dump_asset(AssetML *assetml); -int selectAssetML(const struct dirent *d); +int selectAssetML(const gchar *dirent); void assetml_read_xml_file(GList **gl_result, char *fname, gchar *dataset, gchar* categories, gchar* mimetype, const gchar *locale, gchar* file); @@ -340,15 +340,14 @@ void assetml_read_xml_file(GList **gl_result, char *assetmlfile, /* * Select only files with FILE_EXT */ -int selectAssetML(const struct dirent *d) +int selectAssetML(const gchar *dirent) { - gchar *file = ((struct dirent *)d)->d_name; guint ext_length = strlen(FILE_EXT); - if(strlen(file)<ext_length) + if(strlen(dirent)<ext_length) return 0; - return (strncmp (&file[strlen(file)-ext_length], FILE_EXT, ext_length) == 0); + return (strncmp (&dirent[strlen(dirent)-ext_length], FILE_EXT, ext_length) == 0); } /* load all the xml files in the assetml path @@ -357,20 +356,19 @@ int selectAssetML(const struct dirent *d) void assetml_load_xml(GList **gl_result, gchar *dataset, gchar* categories, gchar* mimetype, const gchar *locale, gchar* name) { - struct dirent *one_dirent; - int n; - DIR *dir; + const gchar *one_dirent; + GDir *dir; - dir = opendir(ASSETML_DIR); + dir = g_dir_open(ASSETML_DIR, 0, NULL); if(!dir) { g_warning("opendir returns no files with extension %s in directory %s", FILE_EXT, ASSETML_DIR); return; } - while((one_dirent = readdir(dir)) != NULL) { + while((one_dirent = g_dir_read_name(dir)) != NULL) { - if(strstr(one_dirent->d_name, FILE_EXT)) { - gchar *assetmlfile = g_strdup_printf("%s/%s", ASSETML_DIR, one_dirent->d_name); + if(strstr(one_dirent, FILE_EXT)) { + gchar *assetmlfile = g_strdup_printf("%s/%s", ASSETML_DIR, one_dirent); assetml_read_xml_file(gl_result, assetmlfile, dataset, categories, mimetype, locale, name); @@ -378,7 +376,7 @@ void assetml_load_xml(GList **gl_result, gchar *dataset, gchar* categories, gcha g_free(assetmlfile); } } - closedir(dir); + g_dir_close(dir); } diff --git a/src/gcompris/bar.c b/src/gcompris/bar.c index a6c6635..16fadda 100644 --- a/src/gcompris/bar.c +++ b/src/gcompris/bar.c @@ -1,6 +1,6 @@ /* gcompris - bar.c * - * Time-stamp: <2005/04/10 19:25:52 bruno> + * Time-stamp: <2005/04/30 23:45:37 bruno> * * Copyright (C) 2000-2003 Bruno Coudoin * @@ -66,7 +66,6 @@ void gcompris_bar_start (GnomeCanvas *theCanvas) { GdkPixbuf *pixmap = NULL; - GnomeCanvasItem *item; GnomeCanvasItem *rootitem; gint16 width, height; double zoom; diff --git a/src/gcompris/bonus.c b/src/gcompris/bonus.c index 51bb379..04577c7 100644 --- a/src/gcompris/bonus.c +++ b/src/gcompris/bonus.c @@ -100,7 +100,6 @@ void end_board_finished() { #define OFFSET 100 void board_finished(BoardFinishedList type) { GcomprisBoard *gcomprisBoard = get_current_gcompris_board(); - GcomprisProperties *properties = gcompris_get_properties(); int x,y; GdkPixbuf *pixmap_door1 = NULL,*pixmap_door2 = NULL,*pixmap_tuxplane = NULL; @@ -199,7 +198,6 @@ void board_finished(BoardFinishedList type) { void gcompris_display_bonus(BonusStatusList gamewon, BonusList bonus_id) { GcomprisBoard *gcomprisBoard = get_current_gcompris_board(); - GcomprisProperties *properties = gcompris_get_properties(); gcompris_bar_hide(TRUE); diff --git a/src/gcompris/config.c b/src/gcompris/config.c index cb94dfd..c55323f 100644 --- a/src/gcompris/config.c +++ b/src/gcompris/config.c @@ -1,6 +1,6 @@ /* gcompris - config.c * - * Time-stamp: <2005/04/07 00:19:08 bruno> + * Time-stamp: <2005/05/02 01:17:53 bruno> * * Copyright (C) 2000-2003 Bruno Coudoin * @@ -27,8 +27,6 @@ #include "gcompris_config.h" #include "locale.h" -#include <dirent.h> - #if defined _WIN32 || defined __WIN32__ # undef WIN32 /* avoid warning on mingw32 */ # define WIN32 @@ -134,7 +132,9 @@ static gchar *get_locale_name(gchar *locale); static gchar *get_next_locale(gchar *locale); static gchar *get_previous_locale(gchar *locale); static void display_difficulty_level(); -static gint item_event_ok(GnomeCanvasItem *item, GdkEvent *event, gpointer data); +static gint item_event_ok(GnomeCanvasItem *item, GdkEvent *event, gpointer data); +static void display_previous_next(guint x_start, guint y_start, + gchar *eventname_previous, gchar *eventname_next); /* @@ -387,33 +387,32 @@ void gcompris_config_start () // Skin { - struct dirent *one_dirent; - guint i; - char *str; - DIR *dir; + gchar *one_dirent; + guint i; + GDir *dir; /* Load the Pixpmaps directory file names */ - dir = opendir(PACKAGE_DATA_DIR"/skins"); + dir = g_dir_open(PACKAGE_DATA_DIR"/skins", 0, NULL); if (!dir) g_error (_("Couldn't open skin dir: %s"), PACKAGE_DATA_DIR"/skins"); /* Fill up the skin list */ - while((one_dirent = readdir(dir)) != NULL) { + while((one_dirent = g_dir_read_name(dir)) != NULL) { - if (one_dirent->d_name[0] != '.') { + if (one_dirent[0] != '.') { gchar *filename; /* Only directory here are skins */ - filename = g_strdup_printf("%s/skins/%s", PACKAGE_DATA_DIR, one_dirent->d_name); + filename = g_strdup_printf("%s/skins/%s", PACKAGE_DATA_DIR, one_dirent); if (g_file_test ((filename), G_FILE_TEST_IS_DIR)) { - gchar *skin_name = g_strdup_printf("%s", one_dirent->d_name); + gchar *skin_name = g_strdup_printf("%s", one_dirent); skinlist = g_list_append (skinlist, skin_name); } g_free(filename); } } - closedir(dir); + g_dir_close(dir); /* Should not happen. It the user found the config, there should be a skin */ if(g_list_length(skinlist) == 0) { @@ -505,7 +504,7 @@ void gcompris_config_stop () /*-------------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------------*/ - +static void display_previous_next(guint x_start, guint y_start, gchar *eventname_previous, gchar *eventname_next) { diff --git a/src/gcompris/file_selector.c b/src/gcompris/file_selector.c index bffbc85..95f4533 100644 --- a/src/gcompris/file_selector.c +++ b/src/gcompris/file_selector.c @@ -1,6 +1,6 @@ /* gcompris - file_selector.c * - * Time-stamp: <2005/04/17 16:01:23 bruno> + * Time-stamp: <2005/05/02 01:27:39 bruno> * * Copyright (C) 2000 Bruno Coudoin * @@ -26,7 +26,7 @@ #include <sys/types.h> #include <sys/stat.h> -#include <dirent.h> +#include <string.h> /* libxml includes */ #include <libxml/tree.h> @@ -441,8 +441,8 @@ static void display_files(GnomeCanvasItem *root_item, gchar *rootdir) { GnomeCanvasItem *item; double iw, ih; - struct dirent *one_dirent; - DIR *dir; + const gchar *one_dirent; + GDir *dir; /* Initial image position */ guint ix = 0.0; @@ -460,7 +460,7 @@ static void display_files(GnomeCanvasItem *root_item, gchar *rootdir) return; /* Display the directory content */ - dir = opendir(rootdir); + dir = g_dir_open(rootdir, 0, NULL); if (!dir) { g_warning("gcompris_file_selector : no root directory found in %s", rootdir); @@ -553,18 +553,11 @@ static void display_files(GnomeCanvasItem *root_item, gchar *rootdir) /* Insert all files in a sorted list */ - while((one_dirent = readdir(dir)) != NULL) { + while((one_dirent = g_dir_read_name(dir)) != NULL) { gchar *filename; - if((strcmp(one_dirent->d_name, "..")==0) && - strcmp(current_rootdir, rootdir)==0) - continue; - - if(strcmp(one_dirent->d_name, ".")==0) - continue; - filename = g_strdup_printf("%s/%s", - rootdir, (gchar*)(one_dirent->d_name)); + rootdir, (gchar*)(one_dirent)); if(g_file_test(filename, G_FILE_TEST_IS_DIR)) { dir_list = g_list_insert_sorted(dir_list, filename, @@ -684,7 +677,7 @@ static void display_files(GnomeCanvasItem *root_item, gchar *rootdir) listrunner = g_list_next(listrunner); } - closedir(dir); + g_dir_close(dir); } @@ -968,9 +961,9 @@ gboolean load_mime_type_from_file(gchar *fname) */ void gcompris_load_mime_types() { - struct dirent *one_dirent; - DIR *dir; - int n; + const gchar *one_dirent; + GDir *dir; + int n; if(mimetypes_hash) { return; @@ -981,31 +974,32 @@ void gcompris_load_mime_types() mimetypes_desc_hash = g_hash_table_new (g_str_hash, g_str_equal); /* Load the Pixpmaps directory file names */ - dir = opendir(PACKAGE_DATA_DIR"/gcompris/mimetypes/"); + dir = g_dir_open(PACKAGE_DATA_DIR"/gcompris/mimetypes/", 0, NULL); if (!dir) { - g_warning("gcompris_load_mime_types : no mime types found in %s", PACKAGE_DATA_DIR"/gcompris/mimetypes/"); + g_warning("gcompris_load_mime_types : no mime types found in %s", + PACKAGE_DATA_DIR"/gcompris/mimetypes/"); } else { - while((one_dirent = readdir(dir)) != NULL) { + while((one_dirent = g_dir_read_name(dir)) != NULL) { /* add the board to the list */ gchar *filename; filename = g_strdup_printf("%s/%s", - PACKAGE_DATA_DIR"/gcompris/mimetypes/", one_dirent->d_name); + PACKAGE_DATA_DIR"/gcompris/mimetypes/", one_dirent); if(!g_file_test(filename, G_FILE_TEST_IS_REGULAR)) { g_free(filename); continue; } - if(selectMenuXML(one_dirent->d_name)) { + if(selectMenuXML(one_dirent)) { load_mime_type_from_file(filename); } g_free(filename); } } - closedir(dir); + g_dir_close(dir); } diff --git a/src/gcompris/gameutil.c b/src/gcompris/gameutil.c index 700e77d..8c8f88c 100644 --- a/src/gcompris/gameutil.c +++ b/src/gcompris/gameutil.c @@ -1,6 +1,6 @@ /* gcompris - gameutil.c * - * Time-stamp: <2005/04/10 23:50:40 bruno> + * Time-stamp: <2005/05/02 01:43:21 bruno> * * Copyright (C) 2000 Bruno Coudoin * @@ -19,7 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <dirent.h> #include <math.h> /* libxml includes */ @@ -34,9 +33,6 @@ #define MAX_DESCRIPTION_LENGTH 1000 -/* default gnome pixmap directory in which this game tales the icon */ -static char *lettersdir = "letters/"; - /* List of all available boards */ static GList *boards_list = NULL; @@ -56,7 +52,6 @@ gchar *gcompris_get_asset_file(gchar *dataset, gchar* categories, { GList *gl_result; AssetML *assetml; - GdkPixbuf *pixmap; gchar* resultfile = NULL; gl_result = assetml_get_asset(dataset, categories, mimetype, gcompris_get_locale(), file); @@ -650,7 +645,7 @@ GList *gcompris_get_menulist(gchar *section) * Select only files with .xml extention * Return 1 if the given file end in .xml 0 else */ -int selectMenuXML(gchar *file) +int selectMenuXML(const gchar *file) { if(strlen(file)<4) @@ -676,30 +671,35 @@ void cleanup_menus() { * */ void gcompris_load_menus_dir(char *dirname){ - struct dirent *one_dirent; - DIR *dir; - int n; + const gchar *one_dirent; + GDir *dir; + + if (!g_file_test(dirname, G_FILE_TEST_IS_DIR)) { + g_warning("Failed to parse board in '%s' because it's not a directory\n", dirname); + return; + } - dir = opendir(dirname); + dir = g_dir_open(dirname, 0, NULL); if (!dir) { g_warning("gcompris_load_menus : no menu found in %s", dirname); + return; } else { - while((one_dirent = readdir(dir)) != NULL) { + while((one_dirent = g_dir_read_name(dir)) != NULL) { /* add the board to the list */ GcomprisBoard *gcomprisBoard = NULL; gchar *filename; filename = g_strdup_printf("%s/%s", - dirname, one_dirent->d_name); + dirname, one_dirent); if(!g_file_test(filename, G_FILE_TEST_IS_REGULAR)) { g_free(filename); continue; } - if(selectMenuXML(one_dirent->d_name)) { + if(selectMenuXML(one_dirent)) { gcomprisBoard = g_malloc0 (sizeof (GcomprisBoard)); gcomprisBoard->board_dir = dirname; @@ -716,7 +716,7 @@ void gcompris_load_menus_dir(char *dirname){ g_free(filename); } } - closedir(dir); + g_dir_close(dir); } /* load all the menus xml files in the gcompris path @@ -1033,20 +1033,19 @@ GnomeCanvasGroup *gcompris_display_difficulty_stars(GnomeCanvasGroup *parent, gint difficulty) { GdkPixbuf *pixmap = NULL; - int i; GnomeCanvasGroup *stars_group = NULL; GnomeCanvasGroup *item = NULL; gchar *filename = NULL; if(difficulty==0 || difficulty>6) - return; + return NULL; filename = g_strdup_printf("difficulty_star%d.png", difficulty); pixmap = gcompris_load_skin_pixmap(filename); g_free(filename); if(!pixmap) - return; + return NULL; stars_group = GNOME_CANVAS_GROUP( gnome_canvas_item_new (parent, diff --git a/src/gcompris/soundutil.c b/src/gcompris/soundutil.c index 1407e0f..55bfd5c 100644 --- a/src/gcompris/soundutil.c +++ b/src/gcompris/soundutil.c @@ -20,7 +20,6 @@ #ifdef __APPLE__ # include <sys/types.h> #endif -#include <dirent.h> #include "gcompris.h" #include <signal.h> #include <glib.h> @@ -121,8 +120,8 @@ static gpointer scheduler_bgnd (gpointer user_data) gchar *str; gchar *filename; GList *musiclist = NULL; - DIR *dir; - struct dirent *one_dirent; + GDir *dir; + const gchar *one_dirent; /* Sleep to let gcompris intialisation and intro music to complete */ #if defined WIN32 @@ -134,7 +133,7 @@ static gpointer scheduler_bgnd (gpointer user_data) /* Load the Music directory file names */ filename = g_strdup_printf("%s", PACKAGE_DATA_DIR "/music/background"); - dir = opendir(filename); + dir = g_dir_open(filename, 0, NULL); if (!dir) { g_warning (_("Couldn't open music dir: %s"), filename); @@ -145,16 +144,15 @@ static gpointer scheduler_bgnd (gpointer user_data) g_free(filename); /* Fill up the music list */ - while((one_dirent = readdir(dir)) != NULL) { + while((one_dirent = g_dir_read_name(dir)) != NULL) { - if (one_dirent->d_name[0] != '.' && - strcmp(one_dirent->d_name, "COPYRIGHT")) { - str = g_strdup_printf("%s/%s", PACKAGE_DATA_DIR "/music/background", one_dirent->d_name); + if (strcmp(one_dirent, "COPYRIGHT")) { + str = g_strdup_printf("%s/%s", PACKAGE_DATA_DIR "/music/background", one_dirent); musiclist = g_list_append (musiclist, str); } } - closedir(dir); + g_dir_close(dir); /* No music no play */ if(g_list_length(musiclist)==0) |