gnome-games r8457 - trunk/libgames-support
- From: chpe svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-games r8457 - trunk/libgames-support
- Date: Tue, 6 Jan 2009 18:19:15 +0000 (UTC)
Author: chpe
Date: Tue Jan 6 18:19:15 2009
New Revision: 8457
URL: http://svn.gnome.org/viewvc/gnome-games?rev=8457&view=rev
Log:
Set errors on failure.
Simplify preimage theme by making the base class check whether scalable
cards are required.
Modified:
trunk/libgames-support/games-card-theme-kde.c
trunk/libgames-support/games-card-theme-preimage.c
trunk/libgames-support/games-card-theme-private.h
trunk/libgames-support/games-card-theme-sliced.c
trunk/libgames-support/games-card-theme-svg.c
trunk/libgames-support/games-card-theme.h
Modified: trunk/libgames-support/games-card-theme-kde.c
==============================================================================
--- trunk/libgames-support/games-card-theme-kde.c (original)
+++ trunk/libgames-support/games-card-theme-kde.c Tue Jan 6 18:19:15 2009
@@ -72,6 +72,8 @@
#define KDE_BACKDECK_PYSOL_KEY "PySol"
#define KDE_BACKDECK_SVG_KEY "SVG"
+#ifdef HAVE_RSVG_BBOX
+
static CardBbox *
games_card_theme_kde_get_card_bbox (GamesCardThemeKDE *theme,
int card_id,
@@ -127,6 +129,8 @@
return bbox;
}
+#endif /* HAVE_RSVG_BBOX */
+
/* Class implementation */
G_DEFINE_TYPE (GamesCardThemeKDE, games_card_theme_kde, GAMES_TYPE_CARD_THEME_PREIMAGE);
@@ -135,31 +139,25 @@
games_card_theme_kde_load (GamesCardTheme *card_theme,
GError **error)
{
- GamesCardThemePreimage *preimage_card_theme = (GamesCardThemePreimage *) card_theme;
+#ifdef HAVE_RSVG_BBOX
GamesCardThemeKDE *theme = (GamesCardThemeKDE *) card_theme;
- gboolean retval = FALSE;
char node[32];
-#ifndef HAVE_RSVG_BBOX
- return FALSE;
-#endif
-
if (!GAMES_CARD_THEME_CLASS (games_card_theme_kde_parent_class)->load (card_theme, error))
- goto out;
-
- if (!games_preimage_is_scalable (preimage_card_theme->cards_preimage))
- goto out;
+ return FALSE;
/* Get the bbox of the card back, which we use to compute the theme's aspect ratio */
games_card_get_node_by_id_snprintf (node, sizeof (node), GAMES_CARD_BACK);
- if (!games_card_theme_kde_get_card_bbox (theme, GAMES_CARD_BACK, node))
- goto out;
-
- retval = TRUE;
-
-out:
+ if (!games_card_theme_kde_get_card_bbox (theme, GAMES_CARD_BACK, node)) {
+ g_set_error (error, GAMES_CARD_THEME_ERROR, GAMES_CARD_THEME_ERROR_GENERIC,
+ "Failed to get the theme's aspect ratio");
+ return FALSE;
+ }
- return retval;
+ return TRUE;
+#else
+ return FALSE;
+#endif /* HAVE_RSVG_BBOX */
}
static double
@@ -232,7 +230,7 @@
return subpixbuf;
#else
return NULL;
-#endif
+#endif /* HAVE_RSVG_BBOX */
}
static void
@@ -256,6 +254,7 @@
const char *path,
const char *filename)
{
+#ifdef HAVE_RSVG_BBOX
GamesCardThemeInfo *info = NULL;
char *base_path = NULL, *key_file_path = NULL;
GKeyFile *key_file = NULL;
@@ -297,6 +296,9 @@
}
return info;
+#else
+ return NULL;
+#endif /* HAVE_RSVG_BBOX */
}
static void
@@ -316,6 +318,7 @@
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GamesCardThemeClass *theme_class = GAMES_CARD_THEME_CLASS (klass);
+ GamesCardThemePreimageClass *preimage_theme_class = GAMES_CARD_THEME_PREIMAGE_CLASS (klass);
gobject_class->finalize = games_card_theme_kde_finalize;
@@ -325,6 +328,8 @@
theme_class->load = games_card_theme_kde_load;
theme_class->get_card_aspect = games_card_theme_kde_get_card_aspect;
theme_class->get_card_pixbuf = games_card_theme_kde_get_card_pixbuf;
+
+ preimage_theme_class->needs_scalable_cards = TRUE;
}
/* private API */
Modified: trunk/libgames-support/games-card-theme-preimage.c
==============================================================================
--- trunk/libgames-support/games-card-theme-preimage.c (original)
+++ trunk/libgames-support/games-card-theme-preimage.c Tue Jan 6 18:19:15 2009
@@ -79,6 +79,13 @@
if (!theme->cards_preimage)
return FALSE;
+ if (GAMES_CARD_THEME_PREIMAGE_GET_CLASS (theme)->needs_scalable_cards &&
+ !games_preimage_is_scalable (theme->cards_preimage)) {
+ g_set_error (error, GAMES_CARD_THEME_ERROR, GAMES_CARD_THEME_ERROR_NOT_SCALABLE,
+ "Theme is not scalable");
+ return FALSE;
+ }
+
if (theme->font_options) {
games_preimage_set_font_options (theme->slot_preimage, theme->font_options);
games_preimage_set_font_options (theme->cards_preimage, theme->font_options);
Modified: trunk/libgames-support/games-card-theme-private.h
==============================================================================
--- trunk/libgames-support/games-card-theme-private.h (original)
+++ trunk/libgames-support/games-card-theme-private.h Tue Jan 6 18:19:15 2009
@@ -116,6 +116,8 @@
struct _GamesCardThemePreimageClass {
GamesCardThemeClass parent_class;
+ gboolean needs_scalable_cards;
+
void (* clear_sized_theme_data) (GamesCardThemePreimage *card_theme);
};
Modified: trunk/libgames-support/games-card-theme-sliced.c
==============================================================================
--- trunk/libgames-support/games-card-theme-sliced.c (original)
+++ trunk/libgames-support/games-card-theme-sliced.c Tue Jan 6 18:19:15 2009
@@ -73,10 +73,9 @@
{
GamesCardThemePreimage *preimage_card_theme = (GamesCardThemePreimage *) card_theme;
GamesCardThemeSliced *theme = (GamesCardThemeSliced *) card_theme;
- gboolean retval = FALSE;
if (!GAMES_CARD_THEME_CLASS (games_card_theme_sliced_parent_class)->load (card_theme, error))
- goto out;
+ return FALSE;
/* If we don't have a scalable format, build a scaled pixbuf that we'll cut up later */
theme->prescaled = games_preimage_is_scalable (preimage_card_theme->cards_preimage);
@@ -84,11 +83,7 @@
theme->source = games_preimage_render_unscaled_pixbuf (preimage_card_theme->cards_preimage);
}
- retval = TRUE;
-
-out:
-
- return retval;
+ return TRUE;
}
static gboolean
@@ -229,6 +224,7 @@
theme_class->load = games_card_theme_sliced_load;
theme_class->get_card_pixbuf = games_card_theme_sliced_get_card_pixbuf;
+ preimage_theme_class->needs_scalable_cards = FALSE;
preimage_theme_class->clear_sized_theme_data = games_card_theme_sliced_clear_sized_theme_data;
}
Modified: trunk/libgames-support/games-card-theme-svg.c
==============================================================================
--- trunk/libgames-support/games-card-theme-svg.c (original)
+++ trunk/libgames-support/games-card-theme-svg.c Tue Jan 6 18:19:15 2009
@@ -52,26 +52,6 @@
G_DEFINE_TYPE (GamesCardThemeSVG, games_card_theme_svg, GAMES_TYPE_CARD_THEME_PREIMAGE);
-static gboolean
-games_card_theme_svg_load (GamesCardTheme *card_theme,
- GError **error)
-{
- GamesCardThemePreimage *preimage_card_theme = (GamesCardThemePreimage *) card_theme;
- gboolean retval = FALSE;
-
- if (!GAMES_CARD_THEME_CLASS (games_card_theme_svg_parent_class)->load (card_theme, error))
- goto out;
-
- if (!games_preimage_is_scalable (preimage_card_theme->cards_preimage))
- goto out;
-
- retval = TRUE;
-
-out:
-
- return retval;
-}
-
static GdkPixbuf *
games_card_theme_svg_get_card_pixbuf (GamesCardTheme *card_theme,
int card_id)
@@ -141,11 +121,13 @@
games_card_theme_svg_class_init (GamesCardThemeSVGClass * klass)
{
GamesCardThemeClass *theme_class = GAMES_CARD_THEME_CLASS (klass);
+ GamesCardThemePreimageClass *preimage_theme_class = GAMES_CARD_THEME_PREIMAGE_CLASS (klass);
theme_class->get_theme_infos = games_card_theme_svg_class_get_theme_infos;
- theme_class->load = games_card_theme_svg_load;
theme_class->get_card_pixbuf = games_card_theme_svg_get_card_pixbuf;
+
+ preimage_theme_class->needs_scalable_cards = TRUE;
}
/* private API */
Modified: trunk/libgames-support/games-card-theme.h
==============================================================================
--- trunk/libgames-support/games-card-theme.h (original)
+++ trunk/libgames-support/games-card-theme.h Tue Jan 6 18:19:15 2009
@@ -31,7 +31,8 @@
#define GAMES_CARD_THEME_ERROR (g_quark_from_static_string ("games-card-theme"))
typedef enum {
- GAMES_CARD_THEME_ERROR_GENERIC = 0
+ GAMES_CARD_THEME_ERROR_GENERIC = 0,
+ GAMES_CARD_THEME_ERROR_NOT_SCALABLE = 1
} GamesCardThemeError;
/* GamesCardThemeInfo (boxed) */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]