diff options
author | Bruno Coudoin <bcoudoin@src.gnome.org> | 2006-08-15 10:42:27 (GMT) |
---|---|---|
committer | Bruno Coudoin <bcoudoin@src.gnome.org> | 2006-08-15 10:42:27 (GMT) |
commit | d6cf7d18c1eff223a2f0fe9cd3d01a2fc893847a (patch) | |
tree | 7579b92fae3a7819171e7f4cff4bda8619cfe5be | |
parent | d463d12dc20ea5862f2d36818889affed9b3127a (diff) |
- Fixed default path search for platform not supported by binreloc
- removed x86-64 warning (all remaining ones I hope).
- Added "weight", PANGO_WEIGHT_HEAVY, in all dialogs for the title and
ok button. It looks better.
- Fixed menu2 to lock the user board selection until the display is complete.
- Added support in gc_net_load_pixmap to also load local file. Thus I standartize
on called this one which will make local or remote load depending on the url given.
-rw-r--r-- | ChangeLog | 34 | ||||
-rw-r--r-- | src/boards/click_on_letter.c | 4 | ||||
-rw-r--r-- | src/boards/gtans_callbacks.c | 2 | ||||
-rw-r--r-- | src/boards/menu2.c | 37 | ||||
-rw-r--r-- | src/boards/money_widget.c | 5 | ||||
-rw-r--r-- | src/boards/smallnumbers.c | 5 | ||||
-rw-r--r-- | src/boards/target.c | 34 | ||||
-rw-r--r-- | src/gcompris/about.c | 6 | ||||
-rw-r--r-- | src/gcompris/bar.c | 3 | ||||
-rw-r--r-- | src/gcompris/config.c | 61 | ||||
-rw-r--r-- | src/gcompris/gameutil.c | 96 | ||||
-rw-r--r-- | src/gcompris/gc_net.c | 68 | ||||
-rw-r--r-- | src/gcompris/gc_net.h | 4 | ||||
-rw-r--r-- | src/gcompris/gcompris.c | 99 | ||||
-rw-r--r-- | src/gcompris/help.c | 20 | ||||
-rw-r--r-- | src/gcompris/skin.c | 8 | ||||
-rw-r--r-- | src/gcompris/timer.c | 34 |
17 files changed, 359 insertions, 161 deletions
@@ -1,3 +1,37 @@ +2006-08-15 Bruno coudoin <bruno.coudoin@free.fr> + + - Fixed default path search for platform not supported by binreloc + - removed x86-64 warning (all remaining ones I hope). + - Added "weight", PANGO_WEIGHT_HEAVY, in all dialogs for the title and + ok button. It looks better. + - Fixed menu2 to lock the user board selection until the display is complete. + - Added support in gc_net_load_pixmap to also load local file. Thus I standartize + on called this one which will make local or remote load depending on the url given. + + * src/boards/click_on_letter.c: (click_on_letter_create_item): + * src/boards/gtans_callbacks.c: (on_rotation_clicked): + * src/boards/menu2.c: (display_section), (item_event), + (display_welcome): + * src/boards/money_widget.c: (money_display_total): + * src/boards/smallnumbers.c: (key_press): + * src/boards/target.c: (key_press), (display_windspeed), + (target_create_item), (request_score): + * src/gcompris/about.c: (gcompris_about_start): + * src/gcompris/bar.c: (item_event_bar): + * src/gcompris/config.c: (gcompris_config_start), + (set_locale_flag), (item_event_ok): + * src/gcompris/gameutil.c: (gcompris_load_pixmap), + (gcompris_dialog), (gcompris_find_absolute_filename): + * src/gcompris/gc_net.c: (my_strcmp), (gc_net_init), + (gc_net_load_pixmap), (gc_net_get_url_from_file), (gc_net_is_url): + * src/gcompris/gc_net.h: + * src/gcompris/gcompris.c: (setup_window), (load_properties), + (gcompris_init): + * src/gcompris/help.c: (gcompris_help_start): + * src/gcompris/skin.c: (gcompris_image_to_skin): + * src/gcompris/timer.c: (gcompris_timer_display), + (timer_increment): + 2006-08-14 Bruno coudoin <bruno.coudoin@free.fr> - Fixed compilation warnings and potential bugs for x86-64. diff --git a/src/boards/click_on_letter.c b/src/boards/click_on_letter.c index a21366c..6536da7 100644 --- a/src/boards/click_on_letter.c +++ b/src/boards/click_on_letter.c @@ -412,7 +412,6 @@ static GnomeCanvasItem *click_on_letter_create_item(GnomeCanvasGroup *parent) for (i=0; i< number_of_letters; i++) { - buttons[i] = gnome_canvas_item_new (boardRootItem, gnome_canvas_pixbuf_get_type (), "pixbuf", button_pixmap, @@ -423,13 +422,14 @@ static GnomeCanvasItem *click_on_letter_create_item(GnomeCanvasGroup *parent) l_items[i] = gnome_canvas_item_new (boardRootItem, gnome_canvas_text_get_type (), - "text", g_strdup(letters[i]), + "text", letters[i], "font", gcompris_skin_font_board_huge_bold, "anchor", GTK_ANCHOR_CENTER, "fill_color_rgba", 0x0000ffff, "x", (double) xOffset + gdk_pixbuf_get_width(button_pixmap)/2, "y", (double) yOffset + gdk_pixbuf_get_height(button_pixmap)/2 - 5, NULL); + g_free(letters[i]); xOffset +=HORIZONTAL_SEPARATION +gdk_pixbuf_get_width(button_pixmap); diff --git a/src/boards/gtans_callbacks.c b/src/boards/gtans_callbacks.c index 928281f..9d1ad1a 100644 --- a/src/boards/gtans_callbacks.c +++ b/src/boards/gtans_callbacks.c @@ -353,7 +353,7 @@ on_rotation_clicked (GnomeCanvasItem *canvasitem, gint angle = 0; if (selectedgrande==TRUE){ - switch ((gint) user_data){ + switch (GPOINTER_TO_INT(user_data)){ case 0: angle = -rotstepnbr; break; diff --git a/src/boards/menu2.c b/src/boards/menu2.c index 0e6d5d7..a3887e9 100644 --- a/src/boards/menu2.c +++ b/src/boards/menu2.c @@ -1,6 +1,6 @@ /* gcompris - menu2.c * - * Time-stamp: <2006/08/12 02:59:38 bruno> + * Time-stamp: <2006/08/15 02:27:54 bruno> * * Copyright (C) 2000 Bruno Coudoin * @@ -47,6 +47,9 @@ static MenuItems *menuitems; static GcomprisBoard *gcomprisBoard = NULL; static gboolean board_paused = TRUE; +/* We don't wan't the callback on boards to be accepted until the menu is fully displayed */ +static gboolean menu_displayed = FALSE; + static void menu_start (GcomprisBoard *agcomprisBoard); static void menu_pause (gboolean pause); static void menu_end (void); @@ -341,6 +344,8 @@ static void display_section (gchar *path) { GList *boardlist; /* List of Board */ + menu_displayed = FALSE; + boardlist = gcompris_get_menulist(path); if (actualSectionItem) @@ -366,6 +371,7 @@ static void display_section (gchar *path) if (strcmp(path,"home")!=0) g_list_free(boardlist); + menu_displayed = TRUE; } static void @@ -642,22 +648,25 @@ item_event(GnomeCanvasItem *item, GdkEvent *event, MenuItems *menuitems) break; case GDK_BUTTON_PRESS: - gcompris_play_ogg ("sounds/gobble.ogg", NULL); + if(!menu_displayed) + return TRUE; - if (strcmp(board->type,"menu")==0){ - gchar *path = g_strdup_printf("%s/%s",board->section, board->name); - GcomprisProperties *properties = gcompris_get_properties(); + gcompris_play_ogg ("sounds/gobble.ogg", NULL); + + if (strcmp(board->type,"menu")==0){ + gchar *path = g_strdup_printf("%s/%s",board->section, board->name); + GcomprisProperties *properties = gcompris_get_properties(); - display_section(path); + display_section(path); - if (properties->menu_position) - g_free(properties->menu_position); + if (properties->menu_position) + g_free(properties->menu_position); - properties->menu_position = path; + properties->menu_position = path; - } - else - board_run_next (board); + } + else + board_run_next (board); break; @@ -953,7 +962,8 @@ static void create_top(GnomeCanvasGroup *parent, gchar *path) } -static void display_welcome (void) +static void +display_welcome (void) { GnomeCanvasItem *logo; GdkPixbuf *pixmap; @@ -1009,6 +1019,7 @@ static void display_welcome (void) "text", "", NULL); + menu_displayed = TRUE; } static void diff --git a/src/boards/money_widget.c b/src/boards/money_widget.c index e9b2ea9..efe2796 100644 --- a/src/boards/money_widget.c +++ b/src/boards/money_widget.c @@ -223,12 +223,15 @@ money_widget_set_position (Money_Widget *moneyWidget, static void money_display_total(Money_Widget *moneyWidget) { + gchar *tmpstr; g_return_if_fail (moneyWidget != NULL); + tmpstr = g_strdup_printf("%.2f €", moneyWidget->priv->total); if(moneyWidget->priv->display_total) gnome_canvas_item_set (moneyWidget->priv->item_total, - "text", g_strdup_printf("%.2f €", moneyWidget->priv->total), + "text", tmpstr, NULL); + g_free(tmpstr); } diff --git a/src/boards/smallnumbers.c b/src/boards/smallnumbers.c index 8d0ad66..073654f 100644 --- a/src/boards/smallnumbers.c +++ b/src/boards/smallnumbers.c @@ -1,6 +1,6 @@ /* gcompris - smallnumbers.c * - * Time-stamp: <2006/08/12 03:05:21 bruno> + * Time-stamp: <2006/08/15 11:09:04 bruno> * * Copyright (C) 2000 Bruno Coudoin * @@ -244,7 +244,8 @@ static gint key_press(guint keyval, gchar *commit_str, gchar *preedit_str) keyval = atoi(str); g_list_foreach(GNOME_CANVAS_GROUP(boardRootItem)->item_list, - (GFunc) smallnumbers_gotkey_item, (void *)keyval); + (GFunc) smallnumbers_gotkey_item, + GINT_TO_POINTER(keyval)); return TRUE; } diff --git a/src/boards/target.c b/src/boards/target.c index a636fc2..4027211 100644 --- a/src/boards/target.c +++ b/src/boards/target.c @@ -281,9 +281,13 @@ static gint key_press(guint keyval, gchar *commit_str, gchar *preedit_str) } if(answer_item) - gnome_canvas_item_set(answer_item, - "text", g_strdup_printf(_("Points = %s"), answer_string), - NULL); + { + gchar *tmpstr = g_strdup_printf(_("Points = %s"), answer_string); + gnome_canvas_item_set(answer_item, + "text", tmpstr, + NULL); + g_free(tmpstr); + } return TRUE; } @@ -347,7 +351,7 @@ static void display_windspeed() { guint second = 0; guint needle_zoom = 15; - + gchar *tmpstr; GnomeCanvasPoints *canvasPoints; canvasPoints = gnome_canvas_points_new (2); @@ -400,15 +404,17 @@ static void display_windspeed() "width_units", (double)1, NULL); + tmpstr = g_strdup_printf(_("Wind speed = %d\nkilometers/hour"), (guint)wind_speed); gnome_canvas_item_new (speedRootItem, gnome_canvas_text_get_type (), - "text", g_strdup_printf(_("Wind speed = %d\nkilometers/hour"), (guint)wind_speed), + "text", tmpstr, "font", gcompris_skin_font_board_medium, "x", (double) SPEED_CENTER_X, "y", (double) SPEED_CENTER_Y + 110, "anchor", GTK_ANCHOR_CENTER, "fill_color", "white", NULL); + g_free(tmpstr); } @@ -418,6 +424,7 @@ static void display_windspeed() static GnomeCanvasItem *target_create_item(GnomeCanvasGroup *parent) { int i; + gchar *tmpstr; GnomeCanvasItem *item = NULL; boardRootItem = GNOME_CANVAS_GROUP( @@ -445,16 +452,18 @@ static GnomeCanvasItem *target_create_item(GnomeCanvasGroup *parent) gtk_signal_connect(GTK_OBJECT(item), "event", (GtkSignalFunc) item_event, NULL); /* Display the value for this target */ + tmpstr = g_strdup_printf("%d", + targetDefinition[gcomprisBoard->level-1].target_width_value[i*2+1]); item = gnome_canvas_item_new (boardRootItem, gnome_canvas_text_get_type (), - "text", g_strdup_printf("%d", - targetDefinition[gcomprisBoard->level-1].target_width_value[i*2+1]), + "text", tmpstr, "font", gcompris_skin_font_board_medium, "x", (double) 0, "y", (double) targetDefinition[gcomprisBoard->level-1].target_width_value[i*2] - 10, "anchor", GTK_ANCHOR_CENTER, "fill_color", "white", NULL); + g_free(tmpstr); gtk_signal_connect(GTK_OBJECT(item), "event", (GtkSignalFunc) item_event, NULL); } @@ -462,16 +471,18 @@ static GnomeCanvasItem *target_create_item(GnomeCanvasGroup *parent) number_of_arrow = targetDefinition[gcomprisBoard->level-1].number_of_arrow; + tmpstr = g_strdup_printf(_("Distance to target = %d meters"), + targetDefinition[gcomprisBoard->level-1].target_distance); gnome_canvas_item_new (boardRootItem, gnome_canvas_text_get_type (), - "text", g_strdup_printf(_("Distance to target = %d meters"), - targetDefinition[gcomprisBoard->level-1].target_distance), + "text", tmpstr, "font", gcompris_skin_font_board_medium, "x", (double) 0, "y", (double) BOARDHEIGHT-TARGET_CENTER_Y -45, "anchor", GTK_ANCHOR_CENTER, "fill_color", "white", NULL); + g_free(tmpstr); display_windspeed(); @@ -525,6 +536,7 @@ static void request_score() GdkPixbuf *button_pixmap = NULL; double y_offset = 160; double x_offset = 245; + gchar *tmpstr; gcompris_bar_set(GCOMPRIS_BAR_LEVEL|GCOMPRIS_BAR_OK); button_pixmap = gcompris_load_skin_pixmap("button_large2.png"); @@ -535,15 +547,17 @@ static void request_score() "y", y_offset, NULL); + tmpstr = g_strdup_printf(_("Points = %s"), ""); answer_item = gnome_canvas_item_new (boardRootItem, gnome_canvas_text_get_type (), - "text", g_strdup_printf(_("Points = %s"), ""), + "text", tmpstr, "font", gcompris_skin_font_board_title_bold, "x", (double) x_offset + gdk_pixbuf_get_width(button_pixmap)/2, "y", (double) y_offset + gdk_pixbuf_get_height(button_pixmap)/2, "anchor", GTK_ANCHOR_CENTER, "fill_color", "white", NULL); + g_free(tmpstr); gdk_pixbuf_unref(button_pixmap); } diff --git a/src/gcompris/about.c b/src/gcompris/about.c index 2630e4e..e847065 100644 --- a/src/gcompris/about.c +++ b/src/gcompris/about.c @@ -1,6 +1,6 @@ /* gcompris - about.c * - * Time-stamp: <2006/08/11 17:21:46 bruno> + * Time-stamp: <2006/08/15 03:56:58 bruno> * * Copyright (C) 2000 Bruno Coudoin * @@ -107,6 +107,7 @@ void gcompris_about_start () "y", (double) y_start + 40 + 1.0, "anchor", GTK_ANCHOR_CENTER, "fill_color_rgba", gcompris_skin_color_shadow, + "weight", PANGO_WEIGHT_HEAVY, NULL); gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem), gnome_canvas_text_get_type (), @@ -116,6 +117,7 @@ void gcompris_about_start () "y", (double) y_start + 40, "anchor", GTK_ANCHOR_CENTER, "fill_color_rgba", gcompris_skin_color_title, + "weight", PANGO_WEIGHT_HEAVY, NULL); gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem), @@ -343,6 +345,7 @@ void gcompris_about_start () "y", (double) y - gdk_pixbuf_get_height(pixmap) + 20 + 1.0, "anchor", GTK_ANCHOR_CENTER, "fill_color_rgba", gcompris_skin_color_shadow, + "weight", PANGO_WEIGHT_HEAVY, NULL); item2 = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem), gnome_canvas_text_get_type (), @@ -352,6 +355,7 @@ void gcompris_about_start () "y", (double) y - gdk_pixbuf_get_height(pixmap) + 20, "anchor", GTK_ANCHOR_CENTER, "fill_color_rgba", gcompris_skin_color_text_button, + "weight", PANGO_WEIGHT_HEAVY, NULL); gtk_signal_connect(GTK_OBJECT(item2), "event", (GtkSignalFunc) item_event_ok, diff --git a/src/gcompris/bar.c b/src/gcompris/bar.c index e09bc28..11289c3 100644 --- a/src/gcompris/bar.c +++ b/src/gcompris/bar.c @@ -1,6 +1,6 @@ /* gcompris - bar.c * - * Time-stamp: <2006/05/05 00:48:26 bruno> + * Time-stamp: <2006/08/15 02:39:55 bruno> * * Copyright (C) 2000-2003 Bruno Coudoin * @@ -534,6 +534,7 @@ item_event_bar(GnomeCanvasItem *item, GdkEvent *event, gchar *data) else if(!strcmp((char *)data, "back")) { gcompris_play_ogg ("gobble", NULL); + gcompris_bar_hide (TRUE); board_stop(); } else if(!strcmp((char *)data, "help")) diff --git a/src/gcompris/config.c b/src/gcompris/config.c index d06f589..a65652c 100644 --- a/src/gcompris/config.c +++ b/src/gcompris/config.c @@ -1,6 +1,6 @@ /* gcompris - config.c * - * Time-stamp: <2006/08/13 17:20:28 bruno> + * Time-stamp: <2006/08/15 03:53:37 bruno> * * Copyright (C) 2000-2003 Bruno Coudoin * @@ -190,6 +190,7 @@ void gcompris_config_start () "y", (double) y_start + 40 + 1.0, "anchor", GTK_ANCHOR_CENTER, "fill_color_rgba", gcompris_skin_color_shadow, + "weight", PANGO_WEIGHT_HEAVY, NULL); gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem), gnome_canvas_text_get_type (), @@ -199,6 +200,7 @@ void gcompris_config_start () "y", (double) y_start + 40, "anchor", GTK_ANCHOR_CENTER, "fill_color_rgba", gcompris_skin_color_title, + "weight", PANGO_WEIGHT_HEAVY, NULL); pixmap_checked = gcompris_load_skin_pixmap("button_checked.png"); @@ -368,13 +370,14 @@ void gcompris_config_start () guint i; GDir *dir; gchar *skin_dir; + gchar *first_skin_name; /* Load the Pixpmaps directory file names */ skin_dir = g_strconcat(properties->package_data_dir, "/skins", NULL); dir = g_dir_open(skin_dir, 0, NULL); if (!dir) - g_error (_("Couldn't open skin dir: %s"), skin_dir); + g_warning (_("Couldn't open skin dir: %s"), skin_dir); /* Fill up the skin list */ while((one_dirent = g_dir_read_name(dir)) != NULL) { @@ -393,11 +396,6 @@ void gcompris_config_start () } g_dir_close(dir); - /* Should not happen. It the user found the config, there should be a skin */ - if(g_list_length(skinlist) == 0) { - g_warning( "No skin found in %s\n", skin_dir); - } - g_free(skin_dir); /* Find the current skin index */ @@ -408,18 +406,25 @@ void gcompris_config_start () y_start += Y_GAP; - display_previous_next(x_start, y_start, "skin_previous", "skin_next"); + /* Should not happen. It the user found the config, there should be a skin */ + if(g_list_length(skinlist) > 0) { + g_warning("No skin found in %s\n", skin_dir); + display_previous_next(x_start, y_start, "skin_previous", "skin_next"); + first_skin_name = g_strdup_printf(_("Skin : %s"), (char *)g_list_nth_data(skinlist, skin_index)); + } else { + first_skin_name = g_strdup(_("SKINS NOT FOUND")); + } item_skin_text = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem), gnome_canvas_text_get_type (), - "text", g_strdup_printf(_("Skin : %s"), - (char *)g_list_nth_data(skinlist, skin_index)), + "text", first_skin_name, "font", gcompris_skin_font_subtitle, "x", (double) x_text_start, "y", (double) y_start, "anchor", GTK_ANCHOR_WEST, "fill_color_rgba", gcompris_skin_color_content, NULL); + g_free(first_skin_name); } // Difficulty Filter @@ -465,16 +470,18 @@ void gcompris_config_start () "y", (double) y - gdk_pixbuf_get_height(pixmap) + 20 + 1.0, "anchor", GTK_ANCHOR_CENTER, "fill_color_rgba", gcompris_skin_color_shadow, + "weight", PANGO_WEIGHT_HEAVY, NULL); item2 = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem), - gnome_canvas_text_get_type (), - "text", _("OK"), - "font", gcompris_skin_font_title, - "x", (double) BOARDWIDTH*0.5, - "y", (double) y - gdk_pixbuf_get_height(pixmap) + 20, - "anchor", GTK_ANCHOR_CENTER, - "fill_color_rgba", gcompris_skin_color_text_button, - NULL); + gnome_canvas_text_get_type (), + "text", _("OK"), + "font", gcompris_skin_font_title, + "x", (double) BOARDWIDTH*0.5, + "y", (double) y - gdk_pixbuf_get_height(pixmap) + 20, + "anchor", GTK_ANCHOR_CENTER, + "fill_color_rgba", gcompris_skin_color_text_button, + "weight", PANGO_WEIGHT_HEAVY, + NULL); gtk_signal_connect(GTK_OBJECT(item2), "event", (GtkSignalFunc) item_event_ok, "ok"); @@ -586,7 +593,7 @@ static void set_locale_flag(gchar *locale) if(filename) { - pixmap = gdk_pixbuf_new_from_file (filename, NULL); + pixmap = gc_net_load_pixmap(filename); gnome_canvas_item_set (item_locale_flag, "pixbuf", pixmap, @@ -824,24 +831,30 @@ item_event_ok(GnomeCanvasItem *item, GdkEvent *event, gpointer data) } else if(!strcmp((char *)data, "skin_previous")) { + gchar *skin_str; if(skin_index-- < 1) skin_index = g_list_length(skinlist)-1; + skin_str = g_strdup_printf(_("Skin : %s"), + (char *)g_list_nth_data(skinlist, skin_index)); + gnome_canvas_item_set (item_skin_text, - "text", g_strdup_printf(_("Skin : %s"), - (char *)g_list_nth_data(skinlist, skin_index)), + "text", skin_str, NULL); - + g_free(skin_str); } else if(!strcmp((char *)data, "skin_next")) { + gchar *skin_str; if(skin_index++ >= g_list_length(skinlist)-1) skin_index = 0; + skin_str = g_strdup_printf(_("Skin : %s"), + (char *)g_list_nth_data(skinlist, skin_index)); gnome_canvas_item_set (item_skin_text, - "text", g_strdup_printf(_("Skin : %s"), - (char *)g_list_nth_data(skinlist, skin_index)), + "text", skin_str, NULL); + g_free(skin_str); } default: break; diff --git a/src/gcompris/gameutil.c b/src/gcompris/gameutil.c index f7040c7..c53b95c 100644 --- a/src/gcompris/gameutil.c +++ b/src/gcompris/gameutil.c @@ -1,6 +1,6 @@ /* gcompris - gameutil.c * - * Time-stamp: <2006/08/14 02:30:53 bruno> + * Time-stamp: <2006/08/15 04:27:21 bruno> * * Copyright (C) 2000-2006 Bruno Coudoin * @@ -63,34 +63,30 @@ GdkPixbuf *gcompris_load_pixmap(char *pixmapfile) /* Search */ filename = gcompris_find_absolute_filename(pixmapfile); - if (!filename) + if(filename) + pixmap = gc_net_load_pixmap(filename); + + if (!filename || !pixmap) { - pixmap = gc_net_load_pixmap(pixmapfile); + char *str; if(!pixmap) - { - char *str; - g_warning ("Couldn't find file %s !", pixmapfile); - - str = g_strdup_printf("%s\n%s\n%s\n%s", - _("Couldn't find file"), - pixmapfile, - _("This activity is incomplete."), - _("Exit it and report\nthe problem to the authors.")); - gcompris_dialog (str, NULL); - g_free(str); - return NULL; - } - } - else - { - pixmap = gdk_pixbuf_new_from_file (filename, NULL); + g_warning("Loading image '%s' returned a null pointer", filename); + else + g_warning ("Couldn't find file %s !", pixmapfile); + + str = g_strdup_printf("%s\n%s\n%s\n%s", + _("Couldn't find or load the file"), + pixmapfile, + _("This activity is incomplete."), + _("Exit it and report\nthe problem to the authors.")); + gcompris_dialog (str, NULL); + g_free(str); + return NULL; } g_free(filename); - if(!pixmap) - g_warning("Loading image '%s' returned a null pointer", filename); return(pixmap); } @@ -1072,14 +1068,15 @@ void gcompris_dialog(gchar *str, DialogBoxCallBack dbcb) /* OK Text */ item_text_ok = gnome_canvas_item_new (rootDialogItem, - gnome_canvas_text_get_type (), - "text", _("OK"), - "font", gcompris_skin_font_title, - "x", (double) BOARDWIDTH*0.5, - "y", (double) (BOARDHEIGHT - gdk_pixbuf_get_height(pixmap_dialog))/2 + + gnome_canvas_text_get_type (), + "text", _("OK"), + "font", gcompris_skin_font_title, + "x", (double) BOARDWIDTH*0.5, + "y", (double) (BOARDHEIGHT - gdk_pixbuf_get_height(pixmap_dialog))/2 + gdk_pixbuf_get_height(pixmap_dialog) - 35, - "anchor", GTK_ANCHOR_CENTER, - "fill_color_rgba", gcompris_skin_color_text_button, + "anchor", GTK_ANCHOR_CENTER, + "fill_color_rgba", gcompris_skin_color_text_button, + "weight", PANGO_WEIGHT_HEAVY, NULL); gdk_pixbuf_unref(pixmap_dialog); @@ -1243,8 +1240,6 @@ gcompris_find_absolute_filename(const gchar *format, ...) if (!format) return NULL; - g_warning("format '%s'", format); - va_start (args, format); filename = g_strdup_vprintf (format, args); va_end (args); @@ -1252,8 +1247,9 @@ gcompris_find_absolute_filename(const gchar *format, ...) g_warning("filename '%s'", filename); /* Check it's already an absolute file */ - if(g_path_is_absolute (filename) && - g_file_test (filename, G_FILE_TEST_EXISTS)) + if( ((g_path_is_absolute (filename) && + g_file_test (filename, G_FILE_TEST_EXISTS)) + || gc_net_is_url(filename)) ) { return filename; } @@ -1288,11 +1284,19 @@ gcompris_find_absolute_filename(const gchar *format, ...) g_strlcpy(locale, gcompris_get_locale(), sizeof(locale)); filename2 = g_strjoinv(locale, tmp); absolute_filename = g_strdup_printf("%s/%s", dir_to_search[i], filename2); - g_free(filename2); g_warning("1>>>> trying %s\n", absolute_filename); if(g_file_test (absolute_filename, G_FILE_TEST_EXISTS)) { g_strfreev(tmp); + g_free(filename2); + goto FOUND; + } + + /* Now check if this file is on the net */ + if((absolute_filename = gc_net_get_url_from_file("boards/%s", filename2, NULL))) + { + g_strfreev(tmp); + g_free(filename2); goto FOUND; } @@ -1303,20 +1307,36 @@ gcompris_find_absolute_filename(const gchar *format, ...) filename2 = g_strjoinv(locale, tmp); g_strfreev(tmp); absolute_filename = g_strdup_printf("%s/%s", dir_to_search[i], filename2); - g_free(filename2); g_warning("2>>>> trying %s\n", absolute_filename); if(g_file_test (absolute_filename, G_FILE_TEST_EXISTS)) - goto FOUND; + { + g_free(filename2); + goto FOUND; + } + + /* Now check if this file is on the net */ + if((absolute_filename = gc_net_get_url_from_file("boards/%s", filename2, NULL))) + { + g_free(filename2); + goto FOUND; + } + + } } else { absolute_filename = g_strdup_printf("%s/%s", dir_to_search[i], filename); + + if(g_file_test (absolute_filename, G_FILE_TEST_EXISTS)) + goto FOUND; + + /* Now check if this file is on the net */ + if((absolute_filename = gc_net_get_url_from_file("boards/%s", filename, NULL))) + goto FOUND; } i++; - if(g_file_test (absolute_filename, G_FILE_TEST_EXISTS)) - goto FOUND; } g_free(filename); diff --git a/src/gcompris/gc_net.c b/src/gcompris/gc_net.c index ce01743..b23fabf 100644 --- a/src/gcompris/gc_net.c +++ b/src/gcompris/gc_net.c @@ -1,4 +1,4 @@ -/* gcompris - gc_net.c +/* gcompris - gameutil_net.c * * Time-stamp: <2006/07/10 01:24:04 bruno> * @@ -25,18 +25,70 @@ #include <gnet.h> #endif -/* - * Init the network library, must be called once before using it +/* FIXME: Should not be needed, a bug in gnet header ? */ +gboolean gnet_http_get (const gchar *url, + gchar **buffer, + gsize *length, + guint *response); + +#include <string.h> + +#ifdef USE_GNET +static GSList *server_content_list = NULL; +#define SUPPORT_OR_RETURN(rv) {if(!gcompris_get_properties()->server) return rv;} +#else +#define SUPPORT_OR_RETURN(rv) { return rv; } +#endif + + +static inline int my_strcmp(gchar *a, gchar *b) { return strcmp( a, b); } + +/** Init the network library, must be called once before using it + * */ void gc_net_init() { + SUPPORT_OR_RETURN(); + +} + +/** Load a pixmap from the network + * + * \param pixmapfile : a full URL to the file to load as an image + * in case a local file is given, it will be loaded. + * \return a GdkPixbuf or NULL + */ +GdkPixbuf *gc_net_load_pixmap(const char *url) +{ + if(!gc_net_is_url(url)) + return(gdk_pixbuf_new_from_file (url, NULL)); + + SUPPORT_OR_RETURN(NULL); + +} + +/** return an absolute URL if the given file is part of the file available on our server + * + * \param file: the file to check + * \return: a newly allocated URL or NULL + */ +gchar * +gc_net_get_url_from_file(const gchar *format, ...) +{ + SUPPORT_OR_RETURN(NULL); + } -/* - * load a pixmap from the network - * pixmapfile is given relative to PACKAGE_DATA_DIR +/** return TRUE if the url starts with http:// + * + * \param url: an url to check + * \return TRUE is the url starts with 'http://' */ -GdkPixbuf *gc_net_load_pixmap(char *pixmapfile) +gboolean +gc_net_is_url(const gchar *url) { - return NULL; + if( !url || strncmp(url, "http://", 7) ) + return FALSE; + + return TRUE; } diff --git a/src/gcompris/gc_net.h b/src/gcompris/gc_net.h index 0b80f9a..756f141 100644 --- a/src/gcompris/gc_net.h +++ b/src/gcompris/gc_net.h @@ -33,6 +33,8 @@ #define GCOMPRIS_BASE_URL "http://gcompris.net/gcompris" void gc_net_init(); -GdkPixbuf *gc_net_load_pixmap(char *pixmapfile); +GdkPixbuf *gc_net_load_pixmap(const char *url); +gchar * gc_net_get_url_from_file(const gchar *format, ...); +gboolean gc_net_is_url(const char *url); #endif diff --git a/src/gcompris/gcompris.c b/src/gcompris/gcompris.c index f110582..321a990 100644 --- a/src/gcompris/gcompris.c +++ b/src/gcompris/gcompris.c @@ -81,9 +81,9 @@ static gint board_widget_key_press_callback (GtkWidget *widget, gpointer client_data); void gcompris_terminate(int signum); -GcomprisProperties *properties = NULL; -static gboolean antialiased = FALSE; -static gboolean is_mapped = FALSE; +static GcomprisProperties *properties = NULL; +static gboolean antialiased = FALSE; +static gboolean is_mapped = FALSE; /****************************************************************************/ /* Some constants. */ @@ -123,60 +123,91 @@ static int popt_no_quit = FALSE; static int popt_no_config = FALSE; static int popt_display_resource = FALSE; static char *popt_server = NULL; +static int *popt_web_only = NULL; static struct poptOption options[] = { {"fullscreen", 'f', POPT_ARG_NONE, &popt_fullscreen, 0, N_("run gcompris in fullscreen mode."), NULL}, + {"window", 'w', POPT_ARG_NONE, &popt_window, 0, N_("run gcompris in window mode."), NULL}, + {"sound", 's', POPT_ARG_NONE, &popt_sound, 0, N_("run gcompris with sound enabled."), NULL}, + {"mute", 'm', POPT_ARG_NONE, &popt_mute, 0, N_("run gcompris without sound."), NULL}, + {"cursor", 'c', POPT_ARG_NONE, &popt_cursor, 0, N_("run gcompris with the default gnome cursor."), NULL}, + {"difficulty", 'd', POPT_ARG_INT, &popt_difficulty_filter, 0, N_("display only activities with this difficulty level."), NULL}, + {"debug", 'D', POPT_ARG_NONE, &popt_debug, 0, N_("display debug informations on the console."), NULL}, + {"version", 'v', POPT_ARG_NONE, &popt_version, 0, N_("Print the version of " PACKAGE), NULL}, + {"antialiased", '\0', POPT_ARG_NONE, &popt_aalias, 0, N_("Use the antialiased canvas (slower)."), NULL}, + {"noxf86vm", 'x', POPT_ARG_NONE, &popt_noxf86vm, 0, N_("Disable XF86VidMode (No screen resolution change)."), NULL}, + {"root-menu", 'l', POPT_ARG_STRING, &popt_root_menu, 0, N_("Run gcompris with local menu (e.g -l /reading will let you play only activities in the reading directory, -l /boards/connect4 only the connect4 activity)"), NULL}, + {"local-activity", 'L', POPT_ARG_STRING, &popt_local_activity, 0, N_("Run GCompris with local activity directory added to menu"), NULL}, + {"administration", 'a', POPT_ARG_NONE, &popt_administration, 0, N_("Run GCompris in administration and user-management mode"), NULL}, + {"database", 'b', POPT_ARG_STRING, &popt_database, 0, N_("Use alternate database for profiles"), NULL}, + {"logs", 'j', POPT_ARG_STRING, &popt_logs_database, 0, N_("Use alternate database for logs"), NULL}, + {"create-db",'\0', POPT_ARG_NONE, &popt_create_db, 0, N_("Create the alternate database for profiles"), NULL}, + {"reread-menu",'\0', POPT_ARG_NONE, &popt_reread_menu, 0, N_("Re-read XML Menus and store them in the database"), NULL}, + {"profile",'p', POPT_ARG_STRING, &popt_profile, 0, N_("Set the profile to use. Use 'gcompris -a' to create profiles"), NULL}, + {"profile-list",'\0', POPT_ARG_NONE, &popt_profile_list, 0, N_("List all available profiles. Use 'gcompris -a' to create profiles"), NULL}, + {"shared-dir",'\0', POPT_ARG_STRING, &popt_shared_dir, 0, N_("Shared directory location, for profiles and board-configuration data: [$HOME/.gcompris/shared]"), NULL}, + {"users-dir",'\0', POPT_ARG_STRING, &popt_users_dir, 0, N_("The location of user directories: [$HOME/.gcompris/users]"), NULL}, + {"experimental",'\0', POPT_ARG_NONE, &popt_experimental, 0, N_("Run the experimental activities"), NULL}, + {"disable-quit",'\0', POPT_ARG_NONE, &popt_no_quit, 0, N_("Disable the quit button"), NULL}, + {"disable-config",'\0', POPT_ARG_NONE, &popt_no_config, 0, N_("Disable the config button"), NULL}, + {"display-resource",'\0', POPT_ARG_NONE, &popt_display_resource, 0, N_("Display the resources on stdout based on the selected activities"), NULL}, + {"server", '\0', POPT_ARG_STRING, &popt_server, 0, - N_("GCompris will get images, sounds and activity data from this server if not found locally. To use the default server, set this value to 'gcompris.net'"), NULL}, + N_("GCompris will get images, sounds and activity data from this server if not found locally."\ + "To use the default server, set this value to 'gcompris.net'"), NULL}, + + {"web-only", '\0', POPT_ARG_NONE, &popt_web_only, 0, + N_("Only when --server is provided, disable check for local resource first." + "Data are always taken from the web server."), NULL}, #ifndef WIN32 /* Not supported on windows */ POPT_AUTOHELP #endif @@ -628,7 +659,6 @@ static void setup_window () { GcomprisBoard *board_to_start; GdkPixbuf *gcompris_icon_pixbuf; - GError *error = NULL; gchar *icon_file; window = gtk_window_new (GTK_WINDOW_TOPLEVEL); @@ -639,14 +669,18 @@ static void setup_window () */ icon_file = g_strconcat(properties->system_icon_dir, "/gcompris.png", NULL); if (!g_file_test (icon_file, G_FILE_TEST_EXISTS)) { - g_warning ("Couldn't find file %s !", icon_file); + /* Now check if this file is on the net */ + icon_file = gc_net_get_url_from_file("gcompris.png", NULL); } - gcompris_icon_pixbuf = gdk_pixbuf_new_from_file (icon_file, &error); + + if(!icon_file) + g_warning ("Couldn't find file %s !", icon_file); + + gcompris_icon_pixbuf = gc_net_load_pixmap(icon_file); if (!gcompris_icon_pixbuf) { - g_warning ("Failed to load pixbuf file: %s: %s\n", - icon_file, error->message); - g_error_free (error); + g_warning ("Failed to load pixbuf file: %s\n", + icon_file); } g_free(icon_file); @@ -985,15 +1019,16 @@ static void load_properties () } else { - properties->package_data_dir = g_strconcat(gbr_find_data_dir(PACKAGE_DATA_DIR), - "/gcompris/boards", NULL); + gchar *pkg_data_dir = gbr_find_data_dir(PACKAGE_DATA_DIR); + gchar *pkg_plugin_dir = gbr_find_lib_dir(PACKAGE_DATA_DIR "/lib/gcompris"); + + properties->package_data_dir = g_strconcat(pkg_data_dir, "/gcompris/boards", NULL); properties->package_locale_dir = gbr_find_locale_dir(PACKAGE_LOCALE_DIR); - properties->package_plugin_dir = g_strconcat(gbr_find_lib_dir(PACKAGE_DATA_DIR), - "/gcompris", NULL); - properties->package_python_plugin_dir = g_strconcat(gbr_find_data_dir(PACKAGE_DATA_DIR), - "/gcompris/python", NULL); - properties->system_icon_dir = g_strconcat(gbr_find_data_dir(PACKAGE_DATA_DIR), - "/pixmap", NULL); + properties->package_plugin_dir = g_strconcat(pkg_plugin_dir, "/gcompris", NULL); + properties->package_python_plugin_dir = g_strconcat(pkg_data_dir, "/gcompris/python", NULL); + properties->system_icon_dir = g_strconcat(pkg_data_dir, "/pixmaps", NULL); + g_free(pkg_data_dir); + g_free(pkg_plugin_dir); } g_free(tmpstr); g_free(prefix_dir); @@ -1521,6 +1556,15 @@ gcompris_init (int argc, char *argv[]) properties->server = g_strdup(popt_server); } + if(popt_web_only) { + g_free(properties->package_data_dir); + properties->package_data_dir = ""; + + g_free(properties->system_icon_dir); + properties->system_icon_dir = ""; + } + + /* * Database init MUST BE after properties * And after a possible alternate database as been provided @@ -1556,25 +1600,6 @@ gcompris_init (int argc, char *argv[]) g_list_free(profile_list); -/* g_warning("Wordlist test"); */ - -/* GcomprisWordlist *wl = gcompris_get_wordlist_from_file("default-fr"); */ - -/* GList *lev_list, *words, *list; */ - -/* lev_list = wl->levels_words; */ - -/* for (list = lev_list; list != NULL; list = list->next){ */ -/* LevelWordlist *lw = list->data; */ - -/* g_warning("Level : %d", lw->level); */ - -/* for (words = lw->words; words != NULL; words = words->next) */ -/* g_warning("%s", (gchar *)words->data); */ -/* } */ - -/* gcompris_wordlist_free(wl); */ - exit(0); } diff --git a/src/gcompris/help.c b/src/gcompris/help.c index 13ecd52..a922acd 100644 --- a/src/gcompris/help.c +++ b/src/gcompris/help.c @@ -1,6 +1,6 @@ /* gcompris - help.c * - * Time-stamp: <2006/08/11 17:24:52 bruno> + * Time-stamp: <2006/08/15 03:55:26 bruno> * * Copyright (C) 2000 Bruno Coudoin * @@ -161,6 +161,7 @@ void gcompris_help_start (GcomprisBoard *gcomprisBoard) "y", (double) y_start + 1.0, "anchor", GTK_ANCHOR_CENTER, "fill_color_rgba", gcompris_skin_color_shadow, + "weight", PANGO_WEIGHT_HEAVY, NULL); gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem), gnome_canvas_text_get_type (), @@ -170,6 +171,7 @@ void gcompris_help_start (GcomprisBoard *gcomprisBoard) "y", (double) y_start, "anchor", GTK_ANCHOR_CENTER, "fill_color_rgba", gcompris_skin_color_title, + "weight", PANGO_WEIGHT_HEAVY, NULL); @@ -381,15 +383,17 @@ void gcompris_help_start (GcomprisBoard *gcomprisBoard) "y", (double) y - gdk_pixbuf_get_height(pixmap) + 20 + 1.0, "anchor", GTK_ANCHOR_CENTER, "fill_color_rgba", gcompris_skin_color_shadow, + "weight", PANGO_WEIGHT_HEAVY, NULL); item2 = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem), - gnome_canvas_text_get_type (), - "text", _("OK"), - "font", gcompris_skin_font_title, - "x", (double) BOARDWIDTH*0.5, - "y", (double) y - gdk_pixbuf_get_height(pixmap) + 20, - "anchor", GTK_ANCHOR_CENTER, - "fill_color_rgba", gcompris_skin_color_text_button, + gnome_canvas_text_get_type (), + "text", _("OK"), + "font", gcompris_skin_font_title, + "x", (double) BOARDWIDTH*0.5, + "y", (double) y - gdk_pixbuf_get_height(pixmap) + 20, + "anchor", GTK_ANCHOR_CENTER, + "fill_color_rgba", gcompris_skin_color_text_button, + "weight", PANGO_WEIGHT_HEAVY, NULL); gtk_signal_connect(GTK_OBJECT(item2), "event", (GtkSignalFunc) item_event_help, diff --git a/src/gcompris/skin.c b/src/gcompris/skin.c index a9526d2..07e8e86 100644 --- a/src/gcompris/skin.c +++ b/src/gcompris/skin.c @@ -58,7 +58,7 @@ gchar* gcompris_skin_font_board_huge_bold; */ gchar *gcompris_image_to_skin(gchar *pixmapfile) { - GcomprisProperties *properties = gcompris_get_properties(); + GcomprisProperties *properties = gcompris_get_properties(); gchar *filename; /* First, test if pixmapfile is in the current skin dir */ @@ -73,6 +73,12 @@ gchar *gcompris_image_to_skin(gchar *pixmapfile) return(filename); } + g_free(filename); + + /* Check it's on the server */ + filename = gc_net_get_url_from_file("boards/skins/%s/%s", properties->skin, pixmapfile); + if(filename) + return(filename); /* Return the default skin dir */ filename = g_strdup_printf("skins/%s/%s", DEFAULT_SKIN, pixmapfile); diff --git a/src/gcompris/timer.c b/src/gcompris/timer.c index 2e9ca33..a2c59e7 100644 --- a/src/gcompris/timer.c +++ b/src/gcompris/timer.c @@ -105,16 +105,20 @@ void gcompris_timer_display(int ax, int ay, TimerList atype, int second, Gcompri } break; case GCOMPRIS_TIMER_TEXT: - /* Display the value for this timer */ - item = gnome_canvas_item_new (boardRootItem, - gnome_canvas_text_get_type (), - "text", g_strdup_printf("Remaining Time = %d", timer), - "font_gdk", gdk_font, - "x", x, - "y", y, - "anchor", GTK_ANCHOR_CENTER, - "fill_color", "white", - NULL); + { + gchar *tmpstr = g_strdup_printf("Remaining Time = %d", timer); + /* Display the value for this timer */ + item = gnome_canvas_item_new (boardRootItem, + gnome_canvas_text_get_type (), + "text", tmpstr, + "font_gdk", gdk_font, + "x", x, + "y", y, + "anchor", GTK_ANCHOR_CENTER, + "fill_color", "white", + NULL); + g_free(tmpstr); + } break; case GCOMPRIS_TIMER_BALLOON: pixmap = gcompris_load_pixmap("gcompris/misc/tuxballoon.png"); @@ -318,9 +322,13 @@ static gint timer_increment(GtkWidget *widget, gpointer data) case GCOMPRIS_TIMER_TEXT: /* Display the value for this timer */ if(item) - gnome_canvas_item_set(item, - "text", g_strdup_printf(_("Remaining Time = %d"), timer), - NULL); + { + char *tmpstr = g_strdup_printf(_("Remaining Time = %d"), timer); + gnome_canvas_item_set(item, + "text", tmpstr, + NULL); + g_free(tmpstr); + } break; case GCOMPRIS_TIMER_BALLOON: break; |