Commit a2e86c2d authored by Bruno Coudoin's avatar Bruno Coudoin

Added a message in GCompris itself when we fail to load the skin.

Before, when the skin file was not found, which means GCompris is not
properly installed or configured, there was an assert and nothing
was explained to the user. Now there is a message in the GCompris
windows.
parent 5f7d2b39
......@@ -174,6 +174,9 @@ void gc_board_init(void)
BoardPlugin *gc_board_get_current_board_plugin(void)
{
if (! bp_data)
return NULL;
if(bp_data->current_gcompris_board)
return bp_data->current_gcompris_board->plugin;
......@@ -182,6 +185,9 @@ BoardPlugin *gc_board_get_current_board_plugin(void)
GcomprisBoard *gc_board_get_current(void)
{
if (! bp_data)
return NULL;
return bp_data->current_gcompris_board;
}
......@@ -361,6 +367,9 @@ gc_board_pause(int pause)
void
gc_board_stop(void)
{
if (! bp_data)
return;
if (bp_data->playing && gc_board_get_current_board_plugin())
{
bp_data->playing = FALSE;
......
......@@ -1212,11 +1212,27 @@ static void map_cb (GtkWidget *widget, gpointer data)
is_mapped = TRUE;
GcomprisBoard *board_to_start;
if (! gc_skin_load(properties->skin) )
{
gc_status_init("");
gchar *filename = \
g_strdup_printf("%s/%s/skin.xml",
properties->package_skin_dir,
properties->skin);
gc_status_set_msg(_("Failed to load the skin '%s'"
" (Check the file exists and is readable)"),
filename);
g_free(filename);
return;
}
gc_set_default_background (goo_canvas_get_root_item (GOO_CANVAS(canvas)));
gc_fullscreen_set(properties->fullscreen);
gc_status_init("");
gc_board_init();
/* Load all the menu once */
gc_menu_load();
......@@ -1932,8 +1948,6 @@ main (int argc, char *argv[])
gc_net_init();
gc_cache_init();
gc_skin_load(properties->skin);
gc_sound_build_music_list();
if(properties->music || properties->fx)
......
......@@ -580,10 +580,8 @@ void gc_menu_load_dir(char *dirname, gboolean db){
}
}
if (board_read) {
gchar *msg = g_strdup_printf(_("Loading activity from file:\n%s"),
gettext(board_read->title));
gc_status_set_msg(msg);
g_free(msg);
gc_status_set_msg( _("Loading activity from file:\n%s"),
gettext(board_read->title) );
}
}
else
......
......@@ -302,8 +302,9 @@ gboolean gc_skin_str_to_color(gchar* data, guint32* color){
/*
* Parse a skin.xml file located in the skin directory
* and load the skin properties into memory
* @return TRUE if load suceeded
*/
static void
static gboolean
skin_xml_load (gchar* skin)
{
gchar* xmlfilename;
......@@ -314,7 +315,7 @@ skin_xml_load (gchar* skin)
gchar* data;
guint32 color;
g_return_if_fail(skin!=NULL);
g_return_val_if_fail(skin!=NULL, FALSE);
xmlfilename = \
gc_file_find_absolute("%s/skin.xml",
......@@ -325,14 +326,17 @@ skin_xml_load (gchar* skin)
if(!xmlfilename)
{
g_warning("Couldn't find skin file %s !", skin);
return;
return FALSE;
}
xmldoc = xmlParseFile(xmlfilename);
g_free(xmlfilename);
if(!xmldoc)
return;
{
g_warning("Parsing of skin file failed '%s' !", skin);
return FALSE;
}
if(/* if there is no root element */
!xmldoc->children ||
......@@ -340,9 +344,10 @@ skin_xml_load (gchar* skin)
!xmldoc->children->name ||
/* if it isn't a GCompris node */
g_strcasecmp((gchar *)xmldoc->children->name, "GCompris")!=0) {
g_warning("No Gcompris node");
xmlFreeDoc(xmldoc);
return;
g_warning("Skin file is not properly formatted (no GCompris node) '%s' !",
skin);
return FALSE;
}
skinNode = xmldoc->children->children;
......@@ -351,9 +356,10 @@ skin_xml_load (gchar* skin)
if((skinNode==NULL)||
g_strcasecmp((gchar *)skinNode->name, "Skin")!=0) {
g_warning("No Skin node %s", xmldoc->children->children->name);
g_warning("In skin file '%s' there are no Skin node %s", skin,
xmldoc->children->children->name);
xmlFreeDoc(xmldoc);
return;
return FALSE;
}
node = skinNode->children;
......@@ -397,18 +403,20 @@ skin_xml_load (gchar* skin)
}
xmlFreeDoc(xmldoc);
return TRUE;
}
/*
* Parse the default skin.xml file and the one located in the skin
* directory then load all skins properties into memory
* @return TRUE if load suceeded
*/
void
gboolean
gc_skin_load (gchar* skin)
{
if(skin==NULL)
return;
return FALSE;
gc_skin_free();
......@@ -421,11 +429,14 @@ gc_skin_load (gchar* skin)
gc_skin_numbers = g_hash_table_new_full(g_str_hash, g_str_equal,
gc_skin_free_string,
NULL);
skin_xml_load(DEFAULT_SKIN);
if (! skin_xml_load(DEFAULT_SKIN) )
return FALSE;
if(strcmp(skin,DEFAULT_SKIN)!=0)
skin_xml_load(skin);
if (! skin_xml_load(skin) )
return FALSE;
gc_skin_setup_vars();
return TRUE;
}
/*
......
......@@ -50,7 +50,7 @@ GdkPixbuf *gc_skin_pixmap_load(char *pixmapfile);
RsvgHandle *gc_skin_rsvg_get();
RsvgHandle *gc_skin_rsvg_load(char *pixmapfile);
void gc_skin_load (gchar* skin);
gboolean gc_skin_load (gchar* skin);
void gc_skin_free (void);
guint32 gc_skin_get_color_default(gchar* id, guint32 def);
......
......@@ -95,17 +95,27 @@ void gc_status_init(gchar *msg)
/*
* Update the message in the status box
* \param format: printf formating.
* \param ...: additional params for the format (printf like)
*/
void gc_status_set_msg(gchar *msg)
void gc_status_set_msg(const gchar *format, ...)
{
va_list args;
gchar *msg;
// No status bar means we are still at command line level.
if (!itemStatusMsg)
if (!itemStatusMsg || !format)
return;
g_assert(rootStatusItem);
va_start (args, format);
msg = g_strdup_vprintf (format, args);
va_end (args);
g_object_set (itemStatusMsg,
"text", msg,
NULL);
g_free(msg);
while (gtk_events_pending())
gtk_main_iteration();
}
......@@ -24,7 +24,7 @@
/* Status box */
void gc_status_init(gchar *str);
void gc_status_close();
void gc_status_set_msg(gchar *str);
void gc_status_set_msg(const gchar *format, ...);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment