gnome-games r8422 - trunk/libgames-support



Author: chpe
Date: Tue Jan  6 18:18:11 2009
New Revision: 8422
URL: http://svn.gnome.org/viewvc/gnome-games?rev=8422&view=rev

Log:
Add class vfunc to get the default theme path.

Modified:
   trunk/libgames-support/games-card-theme-fixed.c
   trunk/libgames-support/games-card-theme-preimage.c
   trunk/libgames-support/games-card-theme-private.h
   trunk/libgames-support/games-card-theme.c
   trunk/libgames-support/games-card-theme.h

Modified: trunk/libgames-support/games-card-theme-fixed.c
==============================================================================
--- trunk/libgames-support/games-card-theme-fixed.c	(original)
+++ trunk/libgames-support/games-card-theme-fixed.c	Tue Jan  6 18:18:11 2009
@@ -120,7 +120,7 @@
   games_card_theme_fixed_clear_theme_data (theme);
 
   if (!theme_dir)
-    theme_dir = games_runtime_get_directory (GAMES_RUNTIME_PRERENDERED_CARDS_DIRECTORY);
+    return FALSE;
 
   filename = g_strdup_printf ("%s.card-theme", theme_name);
   path = g_build_filename (theme_dir, filename, NULL);
@@ -376,6 +376,13 @@
   return pixbuf;
 }
 
+
+static const char *
+games_card_theme_fixed_get_default_theme_path (GamesCardThemeClass *klass)
+{
+  return games_runtime_get_directory (GAMES_RUNTIME_PRERENDERED_CARDS_DIRECTORY);
+}
+
 static void
 games_card_theme_fixed_class_init (GamesCardThemeFixedClass * klass)
 {
@@ -384,6 +391,7 @@
 
   gobject_class->finalize = games_card_theme_fixed_finalize;
 
+  theme_class->get_default_theme_path = games_card_theme_fixed_get_default_theme_path;
   theme_class->load_theme = games_card_theme_fixed_load_theme;
   theme_class->get_theme_name = games_card_theme_fixed_get_theme_name;
   theme_class->set_card_size = games_card_theme_fixed_set_card_size;

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:18:11 2009
@@ -78,6 +78,9 @@
     theme->slot_preimage = NULL;
   }
 
+  g_free (theme->theme_name);
+  theme->theme_name = NULL;
+
   theme->subsize.width = -1;
   theme->subsize.height = -1;
 
@@ -110,16 +113,13 @@
 
   games_card_theme_preimage_clear_theme_data (theme);
 
-  g_free (theme->theme_name);
-  theme->theme_name = NULL;
+  if (!theme_dir)
+    return FALSE;
 
   // FIXMEchpe wtf?
   if (theme->cards_preimage != NULL)
     return TRUE;
 
-  if (!theme_dir)
-    theme_dir = games_runtime_get_directory (GAMES_RUNTIME_SCALABLE_CARDS_DIRECTORY);
-
   /* First try and load the given file. */
   filename = g_strdup_printf ("%s.svg", theme_name);
   path = g_build_filename (theme_dir, filename, NULL);
@@ -313,6 +313,12 @@
   return aspect;
 }
 
+static const char *
+games_card_theme_preimage_get_default_theme_path (GamesCardThemeClass *klass)
+{
+  return games_runtime_get_directory (GAMES_RUNTIME_SCALABLE_CARDS_DIRECTORY);
+}
+
 static void
 games_card_theme_preimage_class_init (GamesCardThemePreimageClass * klass)
 {
@@ -321,6 +327,7 @@
 
   gobject_class->finalize = games_card_theme_preimage_finalize;
 
+  theme_class->get_default_theme_path = games_card_theme_preimage_get_default_theme_path;
   theme_class->load_theme = games_card_theme_preimage_load_theme;
   theme_class->get_theme_name = games_card_theme_preimage_get_theme_name;
   theme_class->set_card_size = games_card_theme_preimage_set_card_size;

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:18:11 2009
@@ -25,6 +25,9 @@
 struct _GamesCardThemeClass {
   GObjectClass parent_class;
 
+  /* class vfuncs */
+  const char * (* get_default_theme_path) (GamesCardThemeClass *klass);
+
   /* vfuncs */
   gboolean    (* load_theme)        (GamesCardTheme *theme,
                                      const char *theme_dir,

Modified: trunk/libgames-support/games-card-theme.c
==============================================================================
--- trunk/libgames-support/games-card-theme.c	(original)
+++ trunk/libgames-support/games-card-theme.c	Tue Jan  6 18:18:11 2009
@@ -60,6 +60,9 @@
                                            const char *theme_dir,
                                            const char *theme_name)
 {
+  if (!theme_dir)
+    theme_dir = games_card_theme_get_default_theme_path (theme->klass);
+
   if (games_card_theme_load_theme (theme, theme_dir, theme_name))
     return TRUE;
 
@@ -151,6 +154,15 @@
 
 /* public API */
 
+const char *
+games_card_theme_get_default_theme_path (GamesCardThemeClass *klass)
+{
+  if (klass->get_default_theme_path)
+    return klass->get_default_theme_path (klass);
+
+  return NULL;
+}
+
 #if GTK_CHECK_VERSION (2, 10, 0)
 
 /**

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:18:11 2009
@@ -53,6 +53,8 @@
 
 GType games_card_theme_get_type (void);
 
+const char * games_card_theme_get_default_theme_path (GamesCardThemeClass *klass);
+
 #if GTK_CHECK_VERSION (2, 10, 0)
 void games_card_theme_set_font_options (GamesCardTheme *theme,
                                         const cairo_font_options_t *font_options);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]