diff options
author | Bruno Coudoin <bcoudoin@src.gnome.org> | 2003-08-27 21:42:57 (GMT) |
---|---|---|
committer | Bruno Coudoin <bcoudoin@src.gnome.org> | 2003-08-27 21:42:57 (GMT) |
commit | bb83c6cc6bd77cfd56daca71547ae799d16b4a0e (patch) | |
tree | e9550de622ffdb22af24696721766952c7cca6e4 /src | |
parent | 60d4ed08f611b26ddc979db9b67138b67c891159 (diff) |
added assetml.in file creation added assetml package creation uses assetml
* configure.in: added assetml.in file creation
* gcompris.spec.in: added assetml package creation
* src/boards/click_on_letter.c: (repeat),
(click_on_letter_create_item), (phone_event): uses assetml
* src/boards/colors.c: (repeat): uses assetml
* src/boards/draw.c: (color_event): uses assetml
* src/boards/gletters.c: (gletters_create_item): uses assetml
* src/boards/smallnumbers.c: (smallnumbers_create_item): uses assetml
* src/gcompris/bar.c: (gcompris_bar_start),
(gcompris_bar_set_level), (bar_play_sound), (item_event_bar): uses assetml
* src/gcompris/config.c: (set_locale_flag), (item_event_ok): uses assetml / fixed focus effect
* src/gcompris/gameutil.c: (gcompris_get_asset_file),
(gcompris_load_pixmap_asset), (gcompris_load_pixmap): assetml enhancements
* src/gcompris/gameutil.h: assetml enhancements
* src/gcompris/gcompris.c: (gcompris_init): uses assetml
* src/gcompris/soundutil.c: (thread_play_ogg),
(gcompris_play_sound): assetml enhancements
* src/libassetml/assetml.c: (dump_asset),
(assetml_add_xml_to_data), (matching), (parse_doc),
(assetml_read_xml_file), (assetml_load_xml), (free_asset),
(assetml_get_asset): removed the name field in assetml to use file as a key instead
* src/libassetml/assetml.h: assetml enhancements
* src/libassetml/test/test.c: (load_asset), (main): assetml enhancements
* src/libassetml/test/test_assetml.assetml: assetml enhancements
* src/libassetml/tools/assetml-query.c: (dump_asset), (main): assetml enhancements
Diffstat (limited to 'src')
-rw-r--r-- | src/boards/click_on_letter.c | 32 | ||||
-rw-r--r-- | src/boards/colors.c | 16 | ||||
-rw-r--r-- | src/boards/draw.c | 18 | ||||
-rw-r--r-- | src/boards/gletters.c | 13 | ||||
-rw-r--r-- | src/boards/smallnumbers.c | 13 | ||||
-rw-r--r-- | src/gcompris/bar.c | 56 | ||||
-rw-r--r-- | src/gcompris/config.c | 43 | ||||
-rw-r--r-- | src/gcompris/gameutil.c | 60 | ||||
-rw-r--r-- | src/gcompris/gameutil.h | 33 | ||||
-rw-r--r-- | src/gcompris/gcompris.c | 11 | ||||
-rw-r--r-- | src/gcompris/soundutil.c | 72 | ||||
-rw-r--r-- | src/libassetml/assetml.c | 113 | ||||
-rw-r--r-- | src/libassetml/assetml.h | 25 | ||||
-rw-r--r-- | src/libassetml/test/test.c | 38 | ||||
-rw-r--r-- | src/libassetml/test/test_assetml.assetml | 61 | ||||
-rwxr-xr-x | src/libassetml/tools/assetml-query.c | 14 |
16 files changed, 378 insertions, 240 deletions
diff --git a/src/boards/click_on_letter.c b/src/boards/click_on_letter.c index 7120d44..bf9b850 100644 --- a/src/boards/click_on_letter.c +++ b/src/boards/click_on_letter.c @@ -187,7 +187,17 @@ static void repeat () { if(gcomprisBoard!=NULL) { - gcompris_play_ogg(right_letter, NULL); + char *str1 = NULL; + char *str2 = NULL; + + str1 = g_strdup_printf("%s%s", right_letter, ".ogg"); + str2 = gcompris_get_asset_file("gcompris alphabet", NULL, "audio/x-ogg", str1); + + gcompris_play_ogg(str2, NULL); + + g_free(str1); + g_free(str2); + } } @@ -225,6 +235,9 @@ static GnomeCanvasItem *click_on_letter_create_item(GnomeCanvasGroup *parent) char *str[4]; char l[4]; int numberOfLetters = 4; + char *str1 = NULL; + char *str2 = NULL; + char *str3 = NULL; gdk_font = gdk_font_load (gcompris_skin_font_board_big); @@ -259,7 +272,18 @@ static GnomeCanvasItem *click_on_letter_create_item(GnomeCanvasGroup *parent) right_letter[0] = l[right_position-1]; right_letter[1] = 0; g_strdown(right_letter); - gcompris_play_ogg("click_on_letter",right_letter, NULL); + + /* Get the sounds to play from assetml */ + str1 = gcompris_get_asset_file("gcompris misc", NULL, "audio/x-ogg", "click_on_letter.ogg"); + + str2 = g_strdup_printf("%s%s", right_letter, ".ogg"); + str3 = gcompris_get_asset_file("gcompris alphabet", NULL, "audio/x-ogg", str2); + + gcompris_play_ogg(str1, str3, NULL); + + g_free(str1); + g_free(str2); + g_free(str3); boardRootItem = GNOME_CANVAS_GROUP( gnome_canvas_item_new (gnome_canvas_root(gcomprisBoard->canvas), @@ -405,8 +429,8 @@ static gint phone_event(GnomeCanvasItem *item, GdkEvent *event, gpointer data) { switch (event->type) { case GDK_BUTTON_PRESS: - gcompris_play_ogg(right_letter, NULL); - break; + repeat(); + break; default: break; } diff --git a/src/boards/colors.c b/src/boards/colors.c index 0fa433f..b4fb8d5 100644 --- a/src/boards/colors.c +++ b/src/boards/colors.c @@ -189,8 +189,22 @@ static void colors_next_level() { } /* ======================================= */ static void repeat (){ + if(gcomprisBoard!=NULL) - gcompris_play_ogg(colors[GPOINTER_TO_INT(g_list_nth_data(listColors, 0))*2], NULL); + { + char *str1 = NULL; + char *str2 = NULL; + + str1 = g_strdup_printf("%s%s", colors[GPOINTER_TO_INT(g_list_nth_data(listColors, 0))*2], + ".ogg"); + str2 = gcompris_get_asset_file("gcompris colors", NULL, "audio/x-ogg", str1); + + gcompris_play_ogg(str2, NULL); + + g_free(str1); + g_free(str2); + + } } /* ===================================================================== * Destroy all the items diff --git a/src/boards/draw.c b/src/boards/draw.c index 7d20682..c02a574 100644 --- a/src/boards/draw.c +++ b/src/boards/draw.c @@ -901,9 +901,21 @@ color_event(GnomeCanvasItem *item, GdkEvent *event, gchar *color) switch(event->button.button) { case 1: - currentColor = color; - highlight_color_item(item); - gcompris_play_ogg(color, NULL); + { + char *str1 = NULL; + char *str2 = NULL; + + currentColor = color; + highlight_color_item(item); + + str1 = g_strdup_printf("%s%s", color, ".ogg"); + str2 = gcompris_get_asset_file("gcompris colors", NULL, "audio/x-ogg", str1); + + gcompris_play_ogg(str2, NULL); + + g_free(str1); + g_free(str2); + } break; default: break; diff --git a/src/boards/gletters.c b/src/boards/gletters.c index 5e639bb..cfa0290 100644 --- a/src/boards/gletters.c +++ b/src/boards/gletters.c @@ -1,6 +1,6 @@ /* gcompris - gletters.c * - * Time-stamp: <2003/01/05 00:14:42 bruno> + * Time-stamp: <2003/08/22 09:53:58 bcoudoin> * * Copyright (C) 2000 Bruno Coudoin * @@ -399,7 +399,8 @@ static GnomeCanvasItem *gletters_create_item(GnomeCanvasGroup *parent) { GdkPixbuf *gletters_pixmap = NULL; GnomeCanvasItem *item; - char *str = NULL; + char *str = NULL; + char *str2 = NULL; int i; guint c; char *lettersItem; @@ -428,7 +429,13 @@ static GnomeCanvasItem *gletters_create_item(GnomeCanvasGroup *parent) } while(item_find_by_title(lettersItem)!=NULL); lettersItem[1] = '\0'; - gcompris_play_ogg(lettersItem, NULL); + + str = g_strdup_printf("%s%s", lettersItem, ".ogg"); + str2 = gcompris_get_asset_file("gcompris alphabet", NULL, "audio/x-ogg", str); + gcompris_play_ogg(str2, NULL); + + g_free(str); + g_free(str2); str = g_strdup_printf("gcompris/letters/%c.png", letters_array[gcomprisBoard->level%LETTERS_ARRAY_LENGTH][i]); diff --git a/src/boards/smallnumbers.c b/src/boards/smallnumbers.c index 695b697..73f2167 100644 --- a/src/boards/smallnumbers.c +++ b/src/boards/smallnumbers.c @@ -1,6 +1,6 @@ /* gcompris - smallnumbers.c * - * Time-stamp: <2003/01/06 22:03:41 bruno> + * Time-stamp: <2003/08/22 10:10:29 bcoudoin> * * Copyright (C) 2000 Bruno Coudoin * @@ -394,6 +394,8 @@ static GnomeCanvasItem *smallnumbers_create_item(GnomeCanvasGroup *parent) char *str; int i; char *lettersItem; + char *str1 = NULL; + char *str2 = NULL; if (!letters_table) { @@ -413,7 +415,14 @@ static GnomeCanvasItem *smallnumbers_create_item(GnomeCanvasGroup *parent) } lettersItem[1] = '\0'; - gcompris_play_ogg(lettersItem, NULL); + + str1 = g_strdup_printf("%s%s", lettersItem, ".ogg"); + str2 = gcompris_get_asset_file("gcompris alphabet", NULL, "audio/x-ogg", str1); + + gcompris_play_ogg(str2, NULL); + + g_free(str1); + g_free(str2); str = g_strdup_printf("gcompris/dice/gnome-dice%c.png", numbers[i]); diff --git a/src/gcompris/bar.c b/src/gcompris/bar.c index de22a30..3d01bcc 100644 --- a/src/gcompris/bar.c +++ b/src/gcompris/bar.c @@ -1,8 +1,8 @@ /* gcompris - bar.c * - * Time-stamp: <2003/08/11 17:34:41 bcoudoin> + * Time-stamp: <2003/08/27 16:01:31 bcoudoin> * - * Copyright (C) 2000,2001,2002,2003 Bruno Coudoin + * Copyright (C) 2000-2003 Bruno Coudoin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -112,7 +112,7 @@ void gcompris_bar_start (GnomeCanvas *theCanvas) gtk_signal_connect(GTK_OBJECT(exit_item), "event", (GtkSignalFunc) item_event_bar, - "exit"); + "quit"); gtk_signal_connect(GTK_OBJECT(exit_item), "event", (GtkSignalFunc) gcompris_item_event_focus, @@ -260,7 +260,7 @@ void gcompris_bar_start (GnomeCanvas *theCanvas) gtk_signal_connect(GTK_OBJECT(config_item), "event", (GtkSignalFunc) item_event_bar, - "config"); + "configuration"); gtk_signal_connect(GTK_OBJECT(config_item), "event", (GtkSignalFunc) gcompris_item_event_focus, @@ -325,12 +325,6 @@ void gcompris_bar_set_level(GcomprisBoard *gcomprisBoard) "pixbuf", pixmap, NULL); gdk_pixbuf_unref(pixmap); - - /* Warning, I have to reconnect to highlight the new image */ - gtk_signal_disconnect (GTK_OBJECT(level_item), level_handler_id); - level_handler_id = gtk_signal_connect(GTK_OBJECT(level_item), "event", - (GtkSignalFunc) gcompris_item_event_focus, - NULL); } current_level=gcomprisBoard->level; @@ -437,13 +431,23 @@ static void update_exit_button() * This is called to play sound * */ -static gint bar_play_sound (gchar *data) +static gint bar_play_sound (gchar *sound) { - int policy = getSoundPolicy(); - setSoundPolicy(PLAY_ONLY_IF_IDLE); - gcompris_play_ogg(data, NULL); - setSoundPolicy(policy); - sound_play_id = 0; + int policy = getSoundPolicy(); + gchar *str1; + gchar *str2; + setSoundPolicy(PLAY_ONLY_IF_IDLE); + + str1 = g_strdup_printf("%s%s", sound, ".ogg"); + str2 = gcompris_get_asset_file("gcompris misc", NULL, "audio/x-ogg", str1); + + gcompris_play_ogg( str2, NULL); + + g_free(str1); + g_free(str2); + + setSoundPolicy(policy); + sound_play_id = 0; return (FALSE); } @@ -492,6 +496,8 @@ item_event_bar(GnomeCanvasItem *item, GdkEvent *event, gchar *data) { gint tmp = current_level; gchar *current_level_str; + gchar *str_level; + gchar *str_number; current_level++; if(current_level>gcomprisBoard->maxlevel) @@ -499,8 +505,15 @@ item_event_bar(GnomeCanvasItem *item, GdkEvent *event, gchar *data) if(tmp!=current_level) { - current_level_str = g_strdup_printf("%d", current_level); - gcompris_play_ogg("level", current_level_str, NULL); + current_level_str = g_strdup_printf("%d.ogg", current_level); + + str_level = gcompris_get_asset_file("gcompris misc", NULL, "audio/x-ogg", "level.ogg"); + str_number = gcompris_get_asset_file("gcompris alphabet", NULL, "audio/x-ogg", current_level_str); + + gcompris_play_ogg(str_level, str_number, NULL); + + g_free(str_level); + g_free(str_number); g_free(current_level_str); } @@ -517,7 +530,6 @@ item_event_bar(GnomeCanvasItem *item, GdkEvent *event, gchar *data) else if(!strcmp((char *)data, "help")) { gcompris_play_ogg ("gobble", NULL); - // gcompris_set_image_focus(item, FALSE); gcompris_help_start(gcomprisBoard); } else if(!strcmp((char *)data, "repeat")) @@ -527,20 +539,18 @@ item_event_bar(GnomeCanvasItem *item, GdkEvent *event, gchar *data) gcomprisBoard->plugin->repeat(); } } - else if(!strcmp((char *)data, "config")) + else if(!strcmp((char *)data, "configuration")) { if(gcomprisBoard->plugin->config != NULL) { - // gcompris_set_image_focus(item, FALSE); gcomprisBoard->plugin->config(); } } else if(!strcmp((char *)data, "about")) { - // gcompris_set_image_focus(item, FALSE); gcompris_about_start(); } - else if(!strcmp((char *)data, "exit")) + else if(!strcmp((char *)data, "quit")) { gcompris_exit(); } diff --git a/src/gcompris/config.c b/src/gcompris/config.c index d01215f..4902536 100644 --- a/src/gcompris/config.c +++ b/src/gcompris/config.c @@ -1,8 +1,8 @@ /* gcompris - config.c * - * Time-stamp: <2003/08/17 18:45:49 bcoudoin> + * Time-stamp: <2003/08/27 16:01:38 bcoudoin> * - * Copyright (C) 2000,2001,2002,2003 Bruno Coudoin + * Copyright (C) 2000-2003 Bruno Coudoin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -52,6 +52,8 @@ static gchar *linguas[] = { "am_ET.UTF-8", N_("Amharic"), "ar_AE.UTF-8", N_("Arabic"), "az_AZ.UTF-8", N_("Azerbaijani Turkic"), + "ca_ES.UTF-8", N_("Catalan"), + "cs_CZ.UTF-8", N_("Czech"), "de_DE.UTF-8", N_("German"), "el_GR.UTF-8", N_("Greek"), "en_GB.UTF-8", N_("English"), @@ -62,18 +64,19 @@ static gchar *linguas[] = { "hi_IN.UTF-8", N_("Indian"), "hu_HU.UTF-8", N_("Hungarian"), "it_IT.UTF-8", N_("Italian"), + "lt_LT.UTF-8", N_("Lithuanian"), "mk_MK.UTF-8", N_("Macedonian"), "ml_IN.UTF-8", N_("Malayalam"), "ms_MY.UTF-8", N_("Malay"), "nl_NL.UTF-8", N_("Dutch"), + "no_NO.UTF-8", N_("Norwegian"), "pt_PT.UTF-8", N_("Portuguese"), "pt_BR.UTF-8", N_("Brazil Portuguese"), "ro_RO.UTF-8", N_("Romanian"), "ru_RU.UTF-8", N_("Russian"), - "sv_FI.UTF-8", N_("Swedish"), "sk_SK.UTF-8", N_("Slovak"), + "sv_FI.UTF-8", N_("Swedish"), "tr_TR.UTF-8", N_("Turkish"), - "lt_LT.UTF-8", N_("Lithuanian"), NULL, NULL }; @@ -482,28 +485,11 @@ display_previous_next(guint x_start, guint y_start, static void set_locale_flag(gchar *locale) { char *str = NULL; - char *filename = NULL; GdkPixbuf *pixmap = NULL; /* First try to find a flag for the long locale name */ - str = g_strdup_printf("flags/%.5s.png", locale); - filename = g_strdup_printf("%s/%s", PACKAGE_DATA_DIR, str); - - if (!g_file_test ((filename), G_FILE_TEST_EXISTS)) - { - g_free(str); - g_free(filename); - - str = g_strdup_printf("flags/%.2s.png", locale); - filename = g_strdup_printf("%s/%s", PACKAGE_DATA_DIR, str); - } - - g_warning("Trying to load flag %s", filename); - - if (g_file_test ((filename), G_FILE_TEST_EXISTS)) - { - pixmap = gcompris_load_pixmap(str); - } + str = g_strdup_printf("%.2s.png", locale); + pixmap = gcompris_load_pixmap_asset("gcompris flags", "flags", "image/png", str); gnome_canvas_item_set (item_locale_flag, "pixbuf", pixmap, @@ -516,7 +502,6 @@ static void set_locale_flag(gchar *locale) gnome_canvas_item_hide (item_bad_flag); g_free(str); - g_free(filename); if(pixmap) gdk_pixbuf_unref(pixmap); @@ -615,6 +600,9 @@ item_event_ok(GnomeCanvasItem *item, GdkEvent *event, gpointer data) else if(!strcmp((char *)data, "fullscreen")) { properties->fullscreen = (properties->fullscreen ? 0 : 1); + /* Warning changing the image needs to update pixbuf_ref for the focus usage */ + g_object_set_data (G_OBJECT (item), "pixbuf_ref", + (properties->fullscreen ? pixmap_checked : pixmap_unchecked)); gnome_canvas_item_set (item, "pixbuf", (properties->fullscreen ? pixmap_checked : pixmap_unchecked), NULL); @@ -623,6 +611,9 @@ item_event_ok(GnomeCanvasItem *item, GdkEvent *event, gpointer data) else if(!strcmp((char *)data, "music")) { properties->music = (properties->music ? 0 : 1); + /* Warning changing the image needs to update pixbuf_ref for the focus usage */ + g_object_set_data (G_OBJECT (item), "pixbuf_ref", + (properties->music ? pixmap_checked : pixmap_unchecked)); gnome_canvas_item_set (item, "pixbuf", (properties->music ? pixmap_checked : pixmap_unchecked), NULL); @@ -631,10 +622,14 @@ item_event_ok(GnomeCanvasItem *item, GdkEvent *event, gpointer data) else if(!strcmp((char *)data, "effect")) { properties->fx = (properties->fx ? 0 : 1); + /* Warning changing the image needs to update pixbuf_ref for the focus usage */ + g_object_set_data (G_OBJECT (item), "pixbuf_ref", + (properties->fx ? pixmap_checked : pixmap_unchecked)); gnome_canvas_item_set (item, "pixbuf", (properties->fx ? pixmap_checked : pixmap_unchecked), NULL); + } else if(!strcmp((char *)data, "locale_previous")) { diff --git a/src/gcompris/gameutil.c b/src/gcompris/gameutil.c index 468151d..e09dbbe 100644 --- a/src/gcompris/gameutil.c +++ b/src/gcompris/gameutil.c @@ -1,6 +1,6 @@ /* gcompris - gameutil.c * - * Time-stamp: <2003/08/12 13:01:39 bcoudoin> + * Time-stamp: <2003/08/23 00:21:29 bcoudoin> * * Copyright (C) 2000 Bruno Coudoin * @@ -101,15 +101,17 @@ GdkPixbuf *gcompris_load_number_pixmap(char number) } /* - * Load a pixmap from the assetml database + * Returns a filename path found from the assetml base. */ -GdkPixbuf *gcompris_load_pixmap_asset(gchar *dataset, gchar* categories, gchar* name) +gchar *gcompris_get_asset_file(gchar *dataset, gchar* categories, + gchar* mimetype, gchar* file) { GList *gl_result; AssetML *assetml; GdkPixbuf *pixmap; + gchar* resultfile = NULL; - gl_result = assetml_get_asset(dataset, categories, "image/png", name); + gl_result = assetml_get_asset(dataset, categories, mimetype, gcompris_get_locale(), file); if(g_list_length(gl_result)>0) { @@ -119,35 +121,55 @@ GdkPixbuf *gcompris_load_pixmap_asset(gchar *dataset, gchar* categories, gchar* if(assetml->file) { - pixmap = gdk_pixbuf_new_from_file (assetml->file, NULL); + resultfile = g_strdup(assetml->file); + } - assetml_free_assetlist(gl_result); + } + else + { + g_warning("Asset not found (dataset=%s categorie=%s mimetype=%s locale=%s file=%s)\n", + dataset, categories, mimetype, gcompris_get_locale(), file); + } + assetml_free_assetlist(gl_result); - if(!pixmap) - g_warning("Loading image returned a null pointer"); + return (resultfile); +} - return pixmap; - } +/* + * Load a pixmap from the assetml database + */ +GdkPixbuf *gcompris_load_pixmap_asset(gchar *dataset, gchar* categories, + gchar* mimetype, gchar* name) +{ + GdkPixbuf *pixmap; + gchar* file = NULL; + + file = gcompris_get_asset_file(dataset, categories, mimetype, name); + + if(file) + { + + pixmap = gdk_pixbuf_new_from_file (file, NULL); + + if(!pixmap) + g_warning("Loading image returned a null pointer"); + + return pixmap; } - assetml_free_assetlist(gl_result); - return NULL; - } +/* + * load a pixmap from the filesystem + * pixmapfile is given relative to PACKAGE_DATA_DIR + */ GdkPixbuf *gcompris_load_pixmap(char *pixmapfile) { gchar *filename; GdkPixbuf *pixmap; - /* Let's try to find it in the assetml base */ - pixmap = gcompris_load_pixmap_asset(NULL, NULL, pixmapfile); - - if(pixmap) - return pixmap; - /* Search it on the file system */ filename = g_strdup_printf("%s/%s", PACKAGE_DATA_DIR, pixmapfile); diff --git a/src/gcompris/gameutil.h b/src/gcompris/gameutil.h index f19a728..e344324 100644 --- a/src/gcompris/gameutil.h +++ b/src/gcompris/gameutil.h @@ -18,6 +18,11 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/*! \file gameutil.h + \brief Function usefull to board developpers +*/ + #ifndef GAMEUTIL_H #define GAMEUTIL_H @@ -46,10 +51,34 @@ void gcompris_load_menus(); gchar *convertUTF8Toisolat1(gchar * text); void item_absolute_move(GnomeCanvasItem *item, int x, int y); -void item_rotate(GnomeCanvasItem *item, double angle); -void item_rotate_with_center(GnomeCanvasItem *item, double angle, int x, int y); +void item_rotate(GnomeCanvasItem *item, double angle); +void item_rotate_with_center(GnomeCanvasItem *item, double angle, int x, int y); typedef void (*DialogBoxCallBack) (); void gcompris_dialog(gchar *str, DialogBoxCallBack dbcb); +/*! \fn GdkPixbuf *gcompris_load_pixmap_asset(gchar *dataset, gchar* categories, gchar* name) + \brief Returns a pixmap from the assetml base. + \warning If there is more than one answer, the first pixmap is returned + + \param dataset The assetml dataset + \param categories The category filter + \param mimetype The mimetype for the asset to search + \param name The name filter +*/ +GdkPixbuf *gcompris_load_pixmap_asset(gchar *dataset, gchar* categories, + gchar* mimetype, gchar* name); + +/*! \fn gchar *gcompris_get_asset_file(gchar *dataset, gchar* categories, gchar* name) + \brief Returns a filename path found from the assetml base. + \warning If there is more than one answer, the first asset found is returned + + \param dataset The assetml dataset + \param categories The category filter + \param mimetype The mimetype for the asset to search + \param file The file filter +*/ +gchar *gcompris_get_asset_file(gchar *dataset, gchar* categories, + gchar* mimetype, gchar* file); + #endif diff --git a/src/gcompris/gcompris.c b/src/gcompris/gcompris.c index 757020b..9142f21 100644 --- a/src/gcompris/gcompris.c +++ b/src/gcompris/gcompris.c @@ -1,6 +1,6 @@ /* gcompris - gcompris.c * - * Time-stamp: <2003/08/04 16:59:26 bcoudoin> + * Time-stamp: <2003/08/22 01:52:40 bcoudoin> * * Copyright (C) 2000,2001 Bruno Coudoin * @@ -506,6 +506,7 @@ gcompris_init (int argc, char *argv[]) GValue value = {0,}; poptContext pctx; char** args; + gchar *str; bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); @@ -600,12 +601,16 @@ gcompris_init (int argc, char *argv[]) gtk_widget_show_all (window); + str = gcompris_get_asset_file("gcompris misc", NULL, "audio/x-ogg", "welcome.ogg"); + if (properties->music) { - gcompris_play_ogg("intro", "welcome", NULL); + gcompris_play_ogg("intro", str, NULL); } else - gcompris_play_ogg("welcome", NULL); + gcompris_play_ogg(str, NULL); + + g_free(str); gtk_main (); return 0; diff --git a/src/gcompris/soundutil.c b/src/gcompris/soundutil.c index f3065d7..a69f0ff 100644 --- a/src/gcompris/soundutil.c +++ b/src/gcompris/soundutil.c @@ -191,42 +191,50 @@ static void* thread_play_ogg (void *s) strncpy( locale, gcompris_get_locale(), 2 ); locale[2] = 0; // because strncpy does not put a '\0' at the end of the string - file = g_strdup_printf("%s/%s/%s.ogg", PACKAGE_DATA_DIR "/sounds", locale, s); - - if (g_file_test ((file), G_FILE_TEST_EXISTS)) - { - printf("trying to play %s\n", file); - } else - { - g_free(file); - file = g_strdup_printf("%s/%s.ogg", PACKAGE_DATA_DIR "/music", s); - if (g_file_test ((file), G_FILE_TEST_EXISTS)) - { - printf("trying to play %s\n", file); - } else - /* Try to find a sound file that does not need to be localized - (ie directly in root /sounds directory) */ + if(((char *)s)[0]=='/') + { + /* If the given file starts with a / then we don't need to search it */ + file = g_strdup(s); + } + else { - g_free(file); + file = g_strdup_printf("%s/%s/%s.ogg", PACKAGE_DATA_DIR "/sounds", locale, s); + + if (g_file_test ((file), G_FILE_TEST_EXISTS)) + { + printf("trying to play %s\n", file); + } else + { + g_free(file); + file = g_strdup_printf("%s/%s.ogg", PACKAGE_DATA_DIR "/music", s); + if (g_file_test ((file), G_FILE_TEST_EXISTS)) + { + printf("trying to play %s\n", file); + } else + /* Try to find a sound file that does not need to be localized + (ie directly in root /sounds directory) */ + { + g_free(file); file = g_strdup_printf("%s/%s.ogg", PACKAGE_DATA_DIR "/sounds", s); - if (g_file_test ((file), G_FILE_TEST_EXISTS)) - { - printf("trying to play %s\n", file); - } else - { - g_free(file); - g_warning("Can't find sound %s", s); - return NULL; - } + if (g_file_test ((file), G_FILE_TEST_EXISTS)) + { + printf("trying to play %s\n", file); + } else + { + g_free(file); + g_warning("Can't find sound %s", s); + return NULL; + } + } + } } - } if ( file ) - { - printf("Calling decode_ogg_file(%s)\n"); - decode_ogg_file(file); - g_free( file ); - } + { + printf("Calling decode_ogg_file(%s)\n"); + decode_ogg_file(file); + g_free( file ); + } return NULL; } @@ -349,7 +357,7 @@ void gcompris_play_sound (const char *soundlistfile, const char *which) return; filename = g_strdup_printf("%s/%s.wav", PACKAGE_SOUNDS_DIR, which); - // DEBUG + // DEBUG printf("gcompris_play_sound %s\n", filename); if (!g_file_test ((filename), G_FILE_TEST_EXISTS)) g_error (_("Couldn't find file %s !"), filename); diff --git a/src/libassetml/assetml.c b/src/libassetml/assetml.c index 2a775d4..7366681 100644 --- a/src/libassetml/assetml.c +++ b/src/libassetml/assetml.c @@ -35,9 +35,9 @@ gchar *reactivate_newline(gchar *str); void dump_asset(AssetML *assetml); int selectAssetML(const struct dirent *d); void assetml_read_xml_file(GList **gl_result, char *fname, - gchar *dataset, gchar* categories, gchar* mimetype, gchar* name); + gchar *dataset, gchar* categories, gchar* mimetype, gchar *locale, gchar* file); void assetml_load_xml(GList **gl_result, gchar *dataset, gchar* categories, gchar* mimetype, - gchar* name); + gchar* locale, gchar* file); void free_asset(AssetML *assetml); /* @@ -87,12 +87,11 @@ void dump_asset(AssetML *assetml) if(assetml==NULL) return; - printf(" name = %s\n",assetml->name_noi18n); - printf(" name(i18n) = %s\n",assetml->name); printf(" dataset = %s\n",assetml->dataset); + printf(" file = %s\n",assetml->file); + printf(" locale = %s\n",assetml->locale); printf(" description = %s\n",assetml->description); printf(" categories = %s\n",assetml->categories); - printf(" file = %s\n",assetml->file); printf(" mimetype = %s\n",assetml->mimetype); printf(" credits = %s\n",assetml->credits); @@ -123,7 +122,11 @@ static AssetML *assetml_add_xml_to_data(xmlDocPtr doc, /* get the specific values */ tmpstr = xmlGetProp(xmlnode,"file"); if(tmpstr && strlen(tmpstr)>0) - assetml->file = g_strdup_printf("%s/%s", rootdir, tmpstr); + if(rootdir[0]!='/') + /* This is a relative path, add ASSETMLPIXMAPDIR and rootdir prefix */ + assetml->file = g_build_filename(ASSETMLPIXMAPDIR, rootdir, tmpstr, NULL); + else + assetml->file = g_build_filename(rootdir, tmpstr, NULL); else assetml->file = NULL; xmlFree(tmpstr); @@ -138,24 +141,7 @@ static AssetML *assetml_add_xml_to_data(xmlDocPtr doc, xmlnode = xmlnode->xmlChildrenNode; while (xmlnode != NULL) { gchar *lang = xmlGetProp(xmlnode,"lang"); - /* get the name of the asset */ - if (!strcmp(xmlnode->name, "Name") - && (lang==NULL || - !strcmp(lang, assetml_get_locale()) - || !strncmp(lang, assetml_get_locale(), 2))) - { - if(lang) - assetml->name_noi18n = xmlNodeListGetString(doc, - xmlnode->xmlChildrenNode, 1); - else - { - assetml->name = reactivate_newline(xmlNodeListGetString(doc, - xmlnode->xmlChildrenNode, 1)); - if(assetml->name_noi18n==NULL) - assetml->name_noi18n = assetml->name; - } - } /* get the description of the asset */ if (!strcmp(xmlnode->name, "Description") && (lang==NULL || @@ -194,11 +180,12 @@ static AssetML *assetml_add_xml_to_data(xmlDocPtr doc, } /* - * Given the assetml and the dataset, categories, name + * Given the assetml and the dataset, categories, name * return true if the assetml matches the requirements */ static gboolean matching(AssetML *assetml, gchar *mydataset, - gchar *dataset, gchar* categories, gchar* mimetype, gchar* name) + gchar *dataset, gchar* categories, gchar* mimetype, + gchar* mylocale, gchar* locale, gchar* file) { g_assert(assetml); @@ -207,14 +194,39 @@ static gboolean matching(AssetML *assetml, gchar *mydataset, if(g_ascii_strcasecmp(assetml->dataset, dataset)) return FALSE; + /* Check the leading locale definition matches the leading user request so that + * File Requested Status + * fr fr_FR.UTF8 OK + * pt pt_BR OK + * pt_BR pt NO + */ + assetml->locale = g_strdup(mylocale); + if(assetml->locale && locale) + if(g_ascii_strncasecmp(assetml->locale, locale, strlen(assetml->locale))) + return FALSE; + if(assetml->mimetype && mimetype) if(g_ascii_strcasecmp(assetml->mimetype, mimetype)) return FALSE; - if(assetml->name_noi18n && name) - if(g_ascii_strcasecmp(assetml->name_noi18n, name)) - return FALSE; - + if(assetml->file && file) + { + gchar *str1; + gchar *str2; + gboolean nomatch; + /* We test only the basename of the file so that caller do not need to specify a full path */ + str1 = g_path_get_basename(assetml->file); + str2 = g_path_get_basename(file); + + nomatch = g_ascii_strcasecmp(str1, str2); + + g_free(str1); + g_free(str2); + + if(nomatch) + return FALSE; + } + if(assetml->categories && categories) { guint i; @@ -234,8 +246,8 @@ static gboolean matching(AssetML *assetml, gchar *mydataset, /* parse the doc, add it to our internal structures and to the clist */ static void parse_doc(GList **gl_result, xmlDocPtr doc, - gchar *mydataset, gchar *rootdir, - gchar *dataset, gchar* categories, gchar* mimetype, gchar* name) + gchar *mydataset, gchar *rootdir, gchar* mylocale, + gchar *dataset, gchar* categories, gchar* mimetype, gchar* locale, gchar* file) { xmlNodePtr node; @@ -246,7 +258,7 @@ parse_doc(GList **gl_result, xmlDocPtr doc, we pass NULL as the node of the child */ AssetML *assetml = assetml_add_xml_to_data(doc, node, rootdir, NULL); - if(assetml && matching(assetml, mydataset, dataset, categories, mimetype, name)) + if(assetml && matching(assetml, mydataset, dataset, categories, mimetype, mylocale, locale, file)) *gl_result = g_list_append (*gl_result, assetml); } @@ -258,22 +270,23 @@ parse_doc(GList **gl_result, xmlDocPtr doc, dump any old data we have in memory if we can load a new set Fill the gl_result list with all matching asseml items */ -void assetml_read_xml_file(GList **gl_result, char *filename, - gchar *dataset, gchar* categories, gchar* mimetype, gchar* name) +void assetml_read_xml_file(GList **gl_result, char *assetmlfile, + gchar *dataset, gchar* categories, gchar* mimetype, gchar *locale, gchar* file) { /* pointer to the new doc */ xmlDocPtr doc; gchar *rootdir; + gchar *mylocale; gchar *mydataset; - g_return_if_fail(filename!=NULL); + g_return_if_fail(assetmlfile!=NULL); /* parse the new file and put the result into newdoc */ - doc = xmlParseFile(filename); + doc = xmlParseFile(assetmlfile); /* in case something went wrong */ if(!doc) { - g_warning("Oups, the parsing of %s failed", filename); + g_warning("Oups, the parsing of %s failed", assetmlfile); return; } @@ -285,15 +298,16 @@ void assetml_read_xml_file(GList **gl_result, char *filename, g_strcasecmp(doc->children->name,"AssetML")!=0) { xmlFreeDoc(doc); - g_warning("Oups, the file %s is not of the assetml type", filename); + g_warning("Oups, the file %s is not of the assetml type", assetmlfile); return; } rootdir = xmlGetProp(doc->children,"rootdir"); mydataset = xmlGetProp(doc->children,"dataset"); + mylocale = xmlGetProp(doc->children,"locale"); /* parse our document and replace old data */ - parse_doc(gl_result, doc, mydataset, rootdir, dataset, categories, mimetype, name); + parse_doc(gl_result, doc, mydataset, rootdir, mylocale, dataset, categories, mimetype, locale, file); xmlFree(rootdir); xmlFree(mydataset); @@ -319,7 +333,8 @@ int selectAssetML(const struct dirent *d) /* load all the xml files in the assetml path * into our memory structures. */ -void assetml_load_xml(GList **gl_result, gchar *dataset, gchar* categories, gchar* mimetype, gchar* name) +void assetml_load_xml(GList **gl_result, gchar *dataset, gchar* categories, gchar* mimetype, gchar *locale, + gchar* name) { struct dirent **namelist; int n; @@ -330,12 +345,12 @@ void assetml_load_xml(GList **gl_result, gchar *dataset, gchar* categories, gcha g_warning("scandir returns no files with extension %s in directory %s", FILE_EXT, ASSETMLPIXMAPDIR); else { while(n--) { - gchar *file = g_strdup_printf("%s/%s", ASSETMLPIXMAPDIR, namelist[n]->d_name); + gchar *assetmlfile = g_strdup_printf("%s/%s", ASSETMLPIXMAPDIR, namelist[n]->d_name); - assetml_read_xml_file(gl_result, file, - dataset, categories, mimetype, name); + assetml_read_xml_file(gl_result, assetmlfile, + dataset, categories, mimetype, locale, name); - g_free(file); + g_free(assetmlfile); free (namelist [n]); } free (namelist); @@ -347,11 +362,7 @@ void assetml_load_xml(GList **gl_result, gchar *dataset, gchar* categories, gcha void free_asset(AssetML *assetml) { - xmlFree(assetml->name_noi18n); - - if(assetml->name!=assetml->name_noi18n) - xmlFree(assetml->name); - + xmlFree(assetml->locale); xmlFree(assetml->dataset); xmlFree(assetml->description); xmlFree(assetml->categories); @@ -370,11 +381,11 @@ void assetml_free_assetlist(GList *assetlist) } -GList* assetml_get_asset(gchar *dataset, gchar* categories, gchar* mimetype, gchar* name) +GList* assetml_get_asset(gchar *dataset, gchar* categories, gchar* mimetype, gchar *locale, gchar* file) { GList *gl_result = NULL; - assetml_load_xml(&gl_result, dataset, categories, mimetype, name); + assetml_load_xml(&gl_result, dataset, categories, mimetype, locale, file); if(g_list_length(gl_result)==0) { diff --git a/src/libassetml/assetml.h b/src/libassetml/assetml.h index deb538a..118ba0d 100644 --- a/src/libassetml/assetml.h +++ b/src/libassetml/assetml.h @@ -17,19 +17,27 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +/*! \file assetml.h + \brief The libassetml API +*/ + #ifndef ASSETML_H #define ASSETML_H #include <glib.h> -/* Returns a list of AssetML struct - dataset: the name of the dataset, NULL for ANY dataset - categories: a list of categorie columns ';' separated (NULL for all) - mimetype: an official mimetype describing the content (NULL for all) - name: the asset name to get or NULL for any name +/** + \fn GList* assetml_get_asset(gchar *dataset, gchar* categories, gchar* mimetype, gchar* name) + \brief Returns a list of AssetML struct + \param dataset the name of the dataset, NULL for ANY dataset + \param categories a list of categorie columns ';' separated (NULL for all) + \param mimetype an official mimetype describing the content (NULL for all) + \param locale is the locale to search for or NULL for the current locale + \param file the asset file name to get or NULL for any file name */ - -GList* assetml_get_asset(gchar *dataset, gchar* categories, gchar* mimetype, gchar* name); +GList* assetml_get_asset(gchar *dataset, gchar* categories, gchar* mimetype, gchar* locale, gchar* name); + + void assetml_free_assetlist(GList *assetlist); typedef struct _AssetML AssetML; @@ -38,8 +46,7 @@ struct _AssetML { gchar *dataset; gchar *categories; - gchar *name; - gchar *name_noi18n; + gchar *locale; gchar *description; gchar *file; gchar *mimetype; diff --git a/src/libassetml/test/test.c b/src/libassetml/test/test.c index baf431e..fa644eb 100644 --- a/src/libassetml/test/test.c +++ b/src/libassetml/test/test.c @@ -27,25 +27,25 @@ * => Dangerous */ -void *load_asset(gchar *dataset, gchar* categories, gchar* name, - gchar* mimetype, guint expected_number); +void *load_asset(gchar *dataset, gchar* categories, gchar* file, + gchar* mimetype, gchar* locale, guint expected_number); /* * Test the Load of an asset from the assetml database */ -void *load_asset(gchar *dataset, gchar* categories, gchar* name, gchar* mimetype, +void *load_asset(gchar *dataset, gchar* categories, gchar* file, gchar* mimetype, gchar* locale, guint expected_number) { GList *gl_result; - gl_result = assetml_get_asset(dataset, categories, mimetype, name); + gl_result = assetml_get_asset(dataset, categories, mimetype, locale, file); if(g_list_length(gl_result)==expected_number) - printf("%15s %15s %15s %15s %2d/%2d PASSED\n", dataset, categories, mimetype, name, + printf("%15s %15s %15s %15s %6s %2d/%2d PASSED\n", dataset, categories, mimetype, file, locale, expected_number, g_list_length(gl_result)); else - printf("%15s %15s %15s %15s %2d/%2d FAILED\n", dataset, categories, mimetype, name, + printf("%15s %15s %15s %15s %6s %2d/%2d FAILED\n", dataset, categories, mimetype, file, locale, expected_number, g_list_length(gl_result)); assetml_free_assetlist(gl_result); @@ -55,18 +55,20 @@ int main (int argc, char *argv[]) { - printf("%15s %15s %15s %15s %2s/%2s\n", "Dataset", "Category", "Mimetype", "Name", "Ex", "Op"); + printf("%15s %15s %15s %15s %6s %2s/%2s\n", "Dataset", "Category", "Mimetype", "File", "Locale", "Ex", "Ob"); - load_asset("assetml test", NULL, "number one", "image/png", 1); - load_asset("assetml test", NULL, "number one", NULL, 2); - load_asset("assetml test", NULL, "Number One", "audio/x-ogg", 1); - load_asset("assetml test", NULL, "number Two", NULL, 2); - load_asset("assetml test", NULL, "number", NULL, 0); - load_asset("assetml test", NULL, NULL, NULL, 20); - load_asset("assetml test", "math", "number one", NULL, 2); - load_asset("assetml test", "nonexistant", NULL, NULL, 0); - load_asset("assetml test", "algebra", NULL, "image/png", 10); - load_asset("assetml test", "math", NULL, "audio/x-ogg", 10); - load_asset("assetml test", "gcompris", NULL, NULL, 20); + load_asset("assetml test", NULL, "1.png", "image/png", NULL, 1); + load_asset("assetml test", NULL, "1.png", "image/png", "fr", 1); + load_asset("assetml test", NULL, "1.png", NULL, NULL, 1); + load_asset("assetml test", NULL, "1.ogg", "audio/x-ogg", NULL, 1); + load_asset("assetml test", NULL, "2.png", NULL, NULL, 1); + load_asset("assetml test", NULL, "number", NULL, NULL, 0); + load_asset("assetml test", NULL, NULL, NULL, NULL, 20); + load_asset("assetml test", "math", "1.png", NULL, NULL, 1); + load_asset("assetml test", "nonexistant", NULL, NULL, NULL, 0); + load_asset("assetml test", "algebra", NULL, "image/png", NULL, 10); + load_asset("assetml test", "math", NULL, "audio/x-ogg", NULL, 10); + load_asset("assetml test", "gcompris", NULL, NULL, NULL, 20); + load_asset("assetml test", "gcompris", NULL, NULL, "fr", 20); } diff --git a/src/libassetml/test/test_assetml.assetml b/src/libassetml/test/test_assetml.assetml index 406f70d..41cdcb2 100644 --- a/src/libassetml/test/test_assetml.assetml +++ b/src/libassetml/test/test_assetml.assetml @@ -1,120 +1,101 @@ <?xml version="1.0" encoding="UTF-8"?> -<AssetML dataset="assetml test" rootdir="../gcompris/boards/"> - <Asset file="sounds/fr/0.ogg" mimetype="audio/x-ogg"> - <Name>Number Zero</Name> +<AssetML dataset="assetml test" rootdir="../gcompris/boards/" locale="fr"> + <Asset file="0.ogg" mimetype="audio/x-ogg"> <Description>The number Zero</Description> <Credits>Who did the sound / Licence info</Credits> <Categories>gcompris;math;algebra</Categories> </Asset> - <Asset file="sounds/fr/1.ogg" mimetype="audio/x-ogg"> - <Name>Number One</Name> + <Asset file="1.ogg" mimetype="audio/x-ogg"> <Description>The number One</Description> <Credits>Who did the sound / Licence info</Credits> <Categories>gcompris;math;algebra</Categories> </Asset> - <Asset file="sounds/fr/2.ogg" mimetype="audio/x-ogg"> - <Name>Number Two</Name> + <Asset file="2.ogg" mimetype="audio/x-ogg"> <Description>The number Two</Description> <Credits>Who did the sound / Licence info</Credits> <Categories>gcompris;math;algebra</Categories> </Asset> - <Asset file="sounds/fr/3.ogg" mimetype="audio/x-ogg"> - <Name>Number Three</Name> + <Asset file="3.ogg" mimetype="audio/x-ogg"> <Description>The number Three</Description> <Credits>Who did the sound / Licence info</Credits> <Categories>gcompris;math;algebra</Categories> </Asset> - <Asset file="sounds/fr/4.ogg" mimetype="audio/x-ogg"> - <Name>Number Four</Name> + <Asset file="4.ogg" mimetype="audio/x-ogg"> <Description>The number Four</Description> <Credits>Who did the sound / Licence info</Credits> <Categories>gcompris;math;algebra</Categories> </Asset> - <Asset file="sounds/fr/5.ogg" mimetype="audio/x-ogg"> - <Name>Number Five</Name> + <Asset file="5.ogg" mimetype="audio/x-ogg"> <Description>The number Five</Description> <Credits>Who did the sound / Licence info</Credits> <Categories>gcompris;math;algebra</Categories> </Asset> - <Asset file="sounds/fr/6.ogg" mimetype="audio/x-ogg"> - <Name>Number Six</Name> + <Asset file="6.ogg" mimetype="audio/x-ogg"> <Description>The number Six</Description> <Credits>Who did the sound / Licence info</Credits> <Categories>gcompris;math;algebra</Categories> </Asset> - <Asset file="sounds/fr/7.ogg" mimetype="audio/x-ogg"> - <Name>Number Seven</Name> + <Asset file="7.ogg" mimetype="audio/x-ogg"> <Description>The number Seven</Description> <Credits>Who did the sound / Licence info</Credits> <Categories>gcompris;math;algebra</Categories> </Asset> - <Asset file="sounds/fr/8.ogg" mimetype="audio/x-ogg"> - <Name>Number Eight</Name> + <Asset file="8.ogg" mimetype="audio/x-ogg"> <Description>The number Eight</Description> <Credits>Who did the sound / Licence info</Credits> <Categories>gcompris;math;algebra</Categories> </Asset> - <Asset file="sounds/fr/9.ogg" mimetype="audio/x-ogg"> - <Name>Number Nine</Name> + <Asset file="9.ogg" mimetype="audio/x-ogg"> <Description>The number Nine</Description> <Credits>Who did the sound / Licence info</Credits> <Categories>gcompris;math;algebra</Categories> </Asset> - <Asset file="gcompris/letters/0.png" mimetype="image/png"> - <Name>Number Zero</Name> + <Asset file="0.png" mimetype="image/png"> <Description>The number Zero</Description> <Credits>Who did the sound / Licence info</Credits> <Categories>gcompris;math;algebra</Categories> </Asset> - <Asset file="gcompris/letters/1.png" mimetype="image/png"> - <Name>Number One</Name> + <Asset file="1.png" mimetype="image/png"> <Description>The number One</Description> <Credits>Who did the sound / Licence info</Credits> <Categories>gcompris;math;algebra</Categories> </Asset> - <Asset file="gcompris/letters/2.png" mimetype="image/png"> - <Name>Number Two</Name> + <Asset file="2.png" mimetype="image/png"> <Description>The number Two</Description> <Credits>Who did the sound / Licence info</Credits> <Categories>gcompris;math;algebra</Categories> </Asset> - <Asset file="gcompris/letters/3.png" mimetype="image/png"> - <Name>Number Three</Name> + <Asset file="3.png" mimetype="image/png"> <Description>The number Three</Description> <Credits>Who did the sound / Licence info</Credits> <Categories>gcompris;math;algebra</Categories> </Asset> - <Asset file="gcompris/letters/4.png" mimetype="image/png"> - <Name>Number Four</Name> + <Asset file="4.png" mimetype="image/png"> <Description>The number Four</Description> <Credits>Who did the sound / Licence info</Credits> <Categories>gcompris;math;algebra</Categories> </Asset> - <Asset file="gcompris/letters/5.png" mimetype="image/png"> - <Name>Number Five</Name> + <Asset file="5.png" mimetype="image/png"> <Description>The number Five</Description> <Credits>Who did the sound / Licence info</Credits> <Categories>gcompris;math;algebra</Categories> </Asset> - <Asset file="gcompris/letters/6.png" mimetype="image/png"> - <Name>Number Six</Name> + <Asset file="6.png" mimetype="image/png"> <Description>The number Six</Description> <Credits>Who did the sound / Licence info</Credits> <Categories>gcompris;math;algebra</Categories> </Asset> - <Asset file="gcompris/letters/7.png" mimetype="image/png"> - <Name>Number Seven</Name> + <Asset file="7.png" mimetype="image/png"> <Description>The number Seven</Description> <Credits>Who did the sound / Licence info</Credits> <Categories>gcompris;math;algebra</Categories> </Asset> - <Asset file="gcompris/letters/8.png" mimetype="image/png"> - <Name>Number Eight</Name> + <Asset file="8.png" mimetype="image/png"> <Description>The number Eight</Description> <Credits>Who did the sound / Licence info</Credits> <Categories>gcompris;math;algebra</Categories> </Asset> - <Asset file="gcompris/letters/9.png" mimetype="image/png"> + <Asset file="9.png" mimetype="image/png"> <Name>Number Nine</Name> <Description>The number Nine</Description> <Credits>Who did the sound / Licence info</Credits> diff --git a/src/libassetml/tools/assetml-query.c b/src/libassetml/tools/assetml-query.c index 0355a04..9f126e1 100755 --- a/src/libassetml/tools/assetml-query.c +++ b/src/libassetml/tools/assetml-query.c @@ -42,20 +42,23 @@ void dump_asset(AssetML *assetml); /*** assetml-query-popttable */ static gchar *dataset = NULL; -static gchar *name = NULL; +static gchar *file = NULL; static gchar *categories = NULL; +static gchar *locale = NULL; static gchar *mimetype = NULL; static int showVersion = FALSE; static struct poptOption options[] = { {"dataset", 'd', POPT_ARG_STRING, &dataset, 0, N_("Specify the dataset to search in"), NULL}, - {"name", 'n', POPT_ARG_STRING, &name, 0, - N_("Specify a name to search"), NULL}, + {"file", 'f', POPT_ARG_STRING, &file, 0, + N_("Specify a file to search"), NULL}, {"categories", 'c', POPT_ARG_STRING, &categories, 0, N_("Specify a category to search in"), NULL}, {"mimetype", 'm', POPT_ARG_STRING, &mimetype, 0, N_("Specify a mimetype to search in (eg: image/png)"), NULL}, + {"locale", 'l', POPT_ARG_STRING, &locale, 0, + N_("Specify a locale to search in (eg: fr)"), NULL}, {"version", '\0', POPT_ARG_NONE, &showVersion, 0, N_("Prints the version of assetml-query"), NULL}, POPT_AUTOHELP @@ -83,8 +86,7 @@ void dump_asset(AssetML *assetml) printf("dataset = %s\n",assetml->dataset); printf(" categories = %s\n",assetml->categories); - printf(" name = %s\n",assetml->name_noi18n); - printf(" name(i18n) = %s\n",assetml->name); + printf(" locale = %s\n",assetml->locale); printf(" mimetype = %s\n",assetml->mimetype); printf(" description = %s\n",assetml->description); printf(" file = %s\n",assetml->file); @@ -122,7 +124,7 @@ main (int argc, const char **argv) } /*------------------------------------------------------------*/ - result = assetml_get_asset(dataset, categories, mimetype, name); + result = assetml_get_asset(dataset, categories, mimetype, locale, file); g_list_foreach (result, (GFunc) dump_asset, NULL); |