[gcompris/gcomprixogoo] Minor change. Now if we don't find the cursor image, we fallback to the default X cursor.
- From: Bruno Coudoin <bcoudoin src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gcompris/gcomprixogoo] Minor change. Now if we don't find the cursor image, we fallback to the default X cursor.
- Date: Sun, 5 Dec 2010 18:09:31 +0000 (UTC)
commit aa06126a36e35de0adc0f6997f64c1fbd0da930a
Author: Bruno Coudoin <bruno coudoin free fr>
Date: Sun Dec 5 17:31:17 2010 +0100
Minor change. Now if we don't find the cursor image, we fallback to the default X cursor.
src/gcompris/bar.c | 3 ++-
src/gcompris/gcompris.c | 25 ++++++++++++++++---------
src/gcompris/skin.c | 22 +++++++++++++++++++++-
src/gcompris/skin.h | 1 +
4 files changed, 40 insertions(+), 11 deletions(-)
---
diff --git a/src/gcompris/bar.c b/src/gcompris/bar.c
index 73c1b29..be95de2 100644
--- a/src/gcompris/bar.c
+++ b/src/gcompris/bar.c
@@ -448,7 +448,8 @@ static void
bar_hide (gboolean hide)
{
/* Non yet initialized : Something Wrong */
- g_assert(rootitem);
+ if ( ! rootitem )
+ return;
_hidden = hide;
diff --git a/src/gcompris/gcompris.c b/src/gcompris/gcompris.c
index 240db79..0ff8b9d 100644
--- a/src/gcompris/gcompris.c
+++ b/src/gcompris/gcompris.c
@@ -505,31 +505,31 @@ void gc_cursor_set(guint gdk_cursor_type)
switch (gdk_cursor_type) {
case GCOMPRIS_DEFAULT_CURSOR :
- cursor_pixbuf = gc_skin_pixmap_load("cursors/default.png");
+ cursor_pixbuf = gc_skin_pixmap_load_or_null("cursors/default.png");
break;
case GCOMPRIS_LINE_CURSOR :
- cursor_pixbuf = gc_skin_pixmap_load("cursors/line.png");
+ cursor_pixbuf = gc_skin_pixmap_load_or_null("cursors/line.png");
break;
case GCOMPRIS_RECT_CURSOR :
- cursor_pixbuf = gc_skin_pixmap_load("cursors/rect.png");
+ cursor_pixbuf = gc_skin_pixmap_load_or_null("cursors/rect.png");
break;
case GCOMPRIS_FILLRECT_CURSOR :
- cursor_pixbuf = gc_skin_pixmap_load("cursors/fillrect.png");
+ cursor_pixbuf = gc_skin_pixmap_load_or_null("cursors/fillrect.png");
break;
case GCOMPRIS_CIRCLE_CURSOR :
- cursor_pixbuf = gc_skin_pixmap_load("cursors/circle.png");
+ cursor_pixbuf = gc_skin_pixmap_load_or_null("cursors/circle.png");
break;
case GCOMPRIS_FILLCIRCLE_CURSOR :
- cursor_pixbuf = gc_skin_pixmap_load("cursors/fillcircle.png");
+ cursor_pixbuf = gc_skin_pixmap_load_or_null("cursors/fillcircle.png");
break;
case GCOMPRIS_FILL_CURSOR :
- cursor_pixbuf = gc_skin_pixmap_load("cursors/fill.png");
+ cursor_pixbuf = gc_skin_pixmap_load_or_null("cursors/fill.png");
break;
case GCOMPRIS_DEL_CURSOR :
- cursor_pixbuf = gc_skin_pixmap_load("cursors/del.png");
+ cursor_pixbuf = gc_skin_pixmap_load_or_null("cursors/del.png");
break;
case GCOMPRIS_SELECT_CURSOR :
- cursor_pixbuf = gc_skin_pixmap_load("cursors/select.png");
+ cursor_pixbuf = gc_skin_pixmap_load_or_null("cursors/select.png");
break;
default :
return;
@@ -544,6 +544,13 @@ void gc_cursor_set(guint gdk_cursor_type)
gdk_cursor_unref(cursor);
gdk_pixbuf_unref(cursor_pixbuf);
}
+ else
+ {
+ /* The cursor image was not found, falback to default one */
+ properties->defaultcursor = GDK_LEFT_PTR;
+ gc_cursor_set(GCOMPRIS_DEFAULT_CURSOR);
+ return;
+ }
}
gc_cursor_current = gdk_cursor_type;
}
diff --git a/src/gcompris/skin.c b/src/gcompris/skin.c
index 276e724..d3523dc 100644
--- a/src/gcompris/skin.c
+++ b/src/gcompris/skin.c
@@ -84,7 +84,27 @@ gc_skin_image_get(gchar *pixmapfile)
/*
* Load a pixmap from the current skin directory
* If not found, try in the default skin directory
- * If not found abort gcompris
+ * If not found returns NULL
+ */
+GdkPixbuf *
+gc_skin_pixmap_load_or_null(char *pixmapfile)
+{
+ gchar *filename;
+ GdkPixbuf *result_pixbuf;
+
+ filename = gc_skin_image_get(pixmapfile);
+
+ result_pixbuf = gc_pixmap_load_or_null (filename);
+
+ g_free(filename);
+
+ return (result_pixbuf);
+}
+
+/*
+ * Load a pixmap from the current skin directory
+ * If not found, try in the default skin directory
+ * If not found returns a small 1x1 pixmap
*/
GdkPixbuf *
gc_skin_pixmap_load(char *pixmapfile)
diff --git a/src/gcompris/skin.h b/src/gcompris/skin.h
index ce17a20..8e4116e 100644
--- a/src/gcompris/skin.h
+++ b/src/gcompris/skin.h
@@ -45,6 +45,7 @@ extern gchar* gc_skin_font_board_huge_bold;
gchar *gc_skin_image_get(gchar *imagename);
+GdkPixbuf *gc_skin_pixmap_load_or_null(char *pixmapfile);
GdkPixbuf *gc_skin_pixmap_load(char *pixmapfile);
RsvgHandle *gc_skin_rsvg_get();
RsvgHandle *gc_skin_rsvg_load(char *pixmapfile);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]