gnome-games r8353 - in trunk: aisleriot libgames-support



Author: chpe
Date: Fri Dec  5 21:43:24 2008
New Revision: 8353
URL: http://svn.gnome.org/viewvc/gnome-games?rev=8353&view=rev

Log:
Move the card textures cache to libgames-support.

Added:
   trunk/libgames-support/games-card-textures-cache.c
      - copied, changed from r8350, /trunk/aisleriot/card-cache.c
   trunk/libgames-support/games-card-textures-cache.h
Removed:
   trunk/aisleriot/card-cache.c
   trunk/aisleriot/card-cache.h
Modified:
   trunk/aisleriot/Makefile.am
   trunk/aisleriot/board.c
   trunk/aisleriot/card.c
   trunk/aisleriot/card.h
   trunk/aisleriot/slot-renderer.c
   trunk/aisleriot/slot-renderer.h
   trunk/libgames-support/Makefile.am

Modified: trunk/aisleriot/Makefile.am
==============================================================================
--- trunk/aisleriot/Makefile.am	(original)
+++ trunk/aisleriot/Makefile.am	Fri Dec  5 21:43:24 2008
@@ -38,8 +38,6 @@
 	baize.h		\
 	card.c          \
 	card.h          \
-	card-cache.c    \
-	card-cache.h    \
 	clutter-embed.c	\
 	clutter-embed.h	\
 	slot-renderer.c \

Modified: trunk/aisleriot/board.c
==============================================================================
--- trunk/aisleriot/board.c	(original)
+++ trunk/aisleriot/board.c	Fri Dec  5 21:43:24 2008
@@ -31,6 +31,7 @@
 // #include <clutter-gtk/gtk-clutter-util.h>
 
 #include <libgames-support/games-card-images.h>
+#include <libgames-support/games-card-textures-cache.h>
 #include <libgames-support/games-files.h>
 #include <libgames-support/games-marshal.h>
 #include <libgames-support/games-pixbuf-utils.h>
@@ -42,7 +43,6 @@
 #include "game.h"
 #include "board.h"
 #include "baize.h"
-#include "card-cache.h"
 #include "card.h"
 #include "slot-renderer.h"
 #include "clutter-embed.h"
@@ -135,7 +135,7 @@
 
   /* Cards cache */
   GamesCardImages *images;
-  AisleriotCardCache *textures;
+  GamesCardTexturesCache *textures;
 
   /* Button press */
   int last_click_x;
@@ -1050,7 +1050,7 @@
                                              priv->yslotstep,
                                              CARD_SLOT_PROP);
   if (size_changed)
-    aisleriot_card_cache_clear (priv->textures);
+    games_card_textures_cache_clear (priv->textures);
 
   card_size = priv->card_size = games_card_images_get_size (priv->images);
 
@@ -3170,7 +3170,7 @@
   /* Create this down here since we need to have the scalable_cards value */
   priv->theme = games_card_theme_new (NULL, priv->scalable_cards);
   priv->images = games_card_images_new (priv->theme);
-  priv->textures = aisleriot_card_cache_new (priv->images);
+  priv->textures = games_card_textures_cache_new (priv->images);
 
   return object;
 }

Modified: trunk/aisleriot/card.c
==============================================================================
--- trunk/aisleriot/card.c	(original)
+++ trunk/aisleriot/card.c	Fri Dec  5 21:43:24 2008
@@ -21,7 +21,6 @@
 #include <cogl/cogl.h>
 
 #include "card.h"
-#include "card-cache.h"
 
 static void aisleriot_card_paint (ClutterActor *actor);
 
@@ -39,7 +38,7 @@
 static void aisleriot_card_unref_cache (AisleriotCard *card);
 
 static void aisleriot_card_set_cache (AisleriotCard *card,
-                                      AisleriotCardCache *cache);
+                                      GamesCardTexturesCache *cache);
 
 #define ANGLE_IS_UPSIDE_DOWN(angle)             \
   ((ABS (angle) + CLUTTER_INT_TO_FIXED (90))    \
@@ -57,7 +56,7 @@
   Card card;
   gboolean highlighted;
 
-  AisleriotCardCache *cache;
+  GamesCardTexturesCache *cache;
 };
 
 enum
@@ -92,7 +91,7 @@
   g_object_class_install_property (gobject_class, PROP_CARD, pspec);
 
   pspec = g_param_spec_object ("cache", NULL, NULL,
-                               AISLERIOT_TYPE_CARD_CACHE,
+                               GAMES_TYPE_CARD_TEXTURES_CACHE,
                                G_PARAM_WRITABLE |
                                G_PARAM_READABLE |
                                G_PARAM_CONSTRUCT_ONLY |
@@ -131,7 +130,7 @@
 }
 
 ClutterActor *
-aisleriot_card_new (AisleriotCardCache *cache, Card card)
+aisleriot_card_new (GamesCardTexturesCache *cache, Card card)
 {
   ClutterActor *self = g_object_new (AISLERIOT_TYPE_CARD,
                                      "cache", cache,
@@ -174,7 +173,7 @@
       x_swapped = TRUE;
   }
 
-  tex = aisleriot_card_cache_get_card_texture (priv->cache, card_num,
+  tex = games_card_textures_cache_get_card_texture (priv->cache, card_num,
                                                priv->highlighted);
 
   tex_width = CLUTTER_INT_TO_FIXED (cogl_texture_get_width (tex));
@@ -287,7 +286,7 @@
 }
 
 static void
-aisleriot_card_set_cache (AisleriotCard *card, AisleriotCardCache *cache)
+aisleriot_card_set_cache (AisleriotCard *card, GamesCardTexturesCache *cache)
 {
   AisleriotCardPrivate *priv = card->priv;
 

Modified: trunk/aisleriot/card.h
==============================================================================
--- trunk/aisleriot/card.h	(original)
+++ trunk/aisleriot/card.h	Fri Dec  5 21:43:24 2008
@@ -20,8 +20,7 @@
 #define AISLERIOT_CARD_H
 
 #include <clutter/clutter.h>
-#include <libgames-support/games-card-images.h>
-#include "card-cache.h"
+#include <libgames-support/games-card-textures-cache.h>
 
 G_BEGIN_DECLS
 
@@ -64,7 +63,7 @@
 
 GType aisleriot_card_get_type (void) G_GNUC_CONST;
 
-ClutterActor *aisleriot_card_new (AisleriotCardCache *cache, Card card);
+ClutterActor *aisleriot_card_new (GamesCardTexturesCache *cache, Card card);
 
 void aisleriot_card_set_card (AisleriotCard *card, Card card_num);
 

Modified: trunk/aisleriot/slot-renderer.c
==============================================================================
--- trunk/aisleriot/slot-renderer.c	(original)
+++ trunk/aisleriot/slot-renderer.c	Fri Dec  5 21:43:24 2008
@@ -41,7 +41,7 @@
 static void aisleriot_slot_renderer_paint (ClutterActor *actor);
 
 static void aisleriot_slot_renderer_set_cache (AisleriotSlotRenderer *srend,
-                                               AisleriotCardCache *cache);
+                                               GamesCardTexturesCache *cache);
 
 static void completed_cb (AisleriotSlotRenderer *srend);
 
@@ -56,7 +56,7 @@
 
 struct _AisleriotSlotRendererPrivate
 {
-  AisleriotCardCache *cache;
+  GamesCardTexturesCache *cache;
 
   Slot *slot;
 
@@ -105,7 +105,7 @@
   actor_class->paint = aisleriot_slot_renderer_paint;
 
   pspec = g_param_spec_object ("cache", NULL, NULL,
-                               AISLERIOT_TYPE_CARD_CACHE,
+                               GAMES_TYPE_CARD_TEXTURES_CACHE,
                                G_PARAM_WRITABLE |
                                G_PARAM_CONSTRUCT_ONLY |
                                G_PARAM_STATIC_NAME |
@@ -200,7 +200,7 @@
 }
 
 ClutterActor *
-aisleriot_slot_renderer_new (AisleriotCardCache *cache, Slot *slot)
+aisleriot_slot_renderer_new (GamesCardTexturesCache *cache, Slot *slot)
 {
   ClutterActor *self = g_object_new (AISLERIOT_TYPE_SLOT_RENDERER,
                                      "cache", cache,
@@ -212,7 +212,7 @@
 
 static void
 aisleriot_slot_renderer_set_cache (AisleriotSlotRenderer *srend,
-                                   AisleriotCardCache *cache)
+                                   GamesCardTexturesCache *cache)
 {
   AisleriotSlotRendererPrivate *priv = srend->priv;
 
@@ -308,7 +308,7 @@
 
   is_highlighted = priv->show_highlight && (card_num >= priv->highlight_start);
 
-  cogl_tex = aisleriot_card_cache_get_card_texture (priv->cache,
+  cogl_tex = games_card_textures_cache_get_card_texture (priv->cache,
                                                     card,
                                                     is_highlighted);
 
@@ -351,7 +351,7 @@
     guint tex_width, tex_height;
     static const ClutterColor white = { 0xff, 0xff, 0xff, 0xff };
 
-    cogl_tex = aisleriot_card_cache_get_slot_texture (priv->cache,
+    cogl_tex = games_card_textures_cache_get_slot_texture (priv->cache,
                                                       priv->show_highlight);
     tex_width = cogl_texture_get_width (cogl_tex);
     tex_height = cogl_texture_get_height (cogl_tex);
@@ -518,7 +518,7 @@
       clutter_container_add (priv->animation_layer,
                              CLUTTER_ACTOR (anim_data.card_tex), NULL);
 
-    cogl_tex = aisleriot_card_cache_get_card_texture (priv->cache, card, FALSE);
+    cogl_tex = games_card_textures_cache_get_card_texture (priv->cache, card, FALSE);
     card_width = cogl_texture_get_width (cogl_tex);
     card_height = cogl_texture_get_height (cogl_tex);
 

Modified: trunk/aisleriot/slot-renderer.h
==============================================================================
--- trunk/aisleriot/slot-renderer.h	(original)
+++ trunk/aisleriot/slot-renderer.h	Fri Dec  5 21:43:24 2008
@@ -20,8 +20,7 @@
 #define __AISLERIOT_SLOT_RENDERER_H__
 
 #include <clutter/clutter.h>
-#include <libgames-support/games-card-images.h>
-#include "card-cache.h"
+#include <libgames-support/games-card-textures-cache.h>
 #include "game.h"
 
 G_BEGIN_DECLS
@@ -73,7 +72,7 @@
 
 GType aisleriot_slot_renderer_get_type (void) G_GNUC_CONST;
 
-ClutterActor *aisleriot_slot_renderer_new (AisleriotCardCache *cache,
+ClutterActor *aisleriot_slot_renderer_new (GamesCardTexturesCache *cache,
                                            Slot *slot);
 
 void aisleriot_slot_renderer_set_highlight (AisleriotSlotRenderer *srend,

Modified: trunk/libgames-support/Makefile.am
==============================================================================
--- trunk/libgames-support/Makefile.am	(original)
+++ trunk/libgames-support/Makefile.am	Fri Dec  5 21:43:24 2008
@@ -87,6 +87,13 @@
 endif
 endif
 
+if HAVE_CLUTTER
+libgames_support_la_SOURCES += \
+	games-card-textures-cache.c	\
+	games-card-textures-cache.c	\
+	$(NULL)
+endif
+
 libgames_support_la_CPPFLAGS = \
 	-DPKGDATADIR="\"$(pkgdatadir)\""			\
 	-DDATADIR="\"$(datadir)\""				\
@@ -140,6 +147,11 @@
 libgames_support_la_LIBADD += $(RSVG_LIBS)
 endif
 
+if HAVE_CLUTTER
+libgames_support_la_CFLAGS += $(CLUTTER_CFLAGS)
+libgames_support_la_LIBADD += $(CLUTTER_LIBS)
+endif
+
 if HAVE_GSTREAMER
 libgames_support_la_CFLAGS += $(GSTREAMER_CFLAGS)
 libgames_support_la_LIBADD += $(GSTREAMER_LIBS)

Copied: trunk/libgames-support/games-card-textures-cache.c (from r8350, /trunk/aisleriot/card-cache.c)
==============================================================================
--- /trunk/aisleriot/card-cache.c	(original)
+++ trunk/libgames-support/games-card-textures-cache.c	Fri Dec  5 21:43:24 2008
@@ -22,31 +22,9 @@
 #include <gtk/gtk.h>
 #include <cogl/cogl.h>
 
-#include <libgames-support/games-card-images.h>
+#include "games-card-textures-cache.h"
 
-#include "card-cache.h"
-
-static void aisleriot_card_cache_dispose (GObject *object);
-static void aisleriot_card_cache_finalize (GObject *object);
-
-static void aisleriot_card_cache_set_property (GObject      *self,
-                                               guint         property_id,
-                                               const GValue *value,
-                                               GParamSpec   *pspec);
-static void aisleriot_card_cache_get_property (GObject    *self,
-                                               guint       property_id,
-                                               GValue     *value,
-                                               GParamSpec *pspec);
-
-static void aisleriot_card_cache_unref_images (AisleriotCardCache *cache);
-
-G_DEFINE_TYPE (AisleriotCardCache, aisleriot_card_cache, G_TYPE_OBJECT);
-
-#define AISLERIOT_CARD_CACHE_GET_PRIVATE(obj) \
-  (G_TYPE_INSTANCE_GET_PRIVATE ((obj), AISLERIOT_TYPE_CARD_CACHE, \
-                                AisleriotCardCachePrivate))
-
-struct _AisleriotCardCachePrivate
+struct _GamesCardTexturesCachePrivate
 {
   CoglHandle *cards;
   GamesCardImages *card_images;
@@ -57,101 +35,101 @@
 enum
 {
   PROP_0,
-
   PROP_CARD_IMAGES
 };
 
-static void
-aisleriot_card_cache_class_init (AisleriotCardCacheClass *klass)
-{
-  GObjectClass *gobject_class = (GObjectClass *) klass;
-  GParamSpec *pspec;
+static void games_card_textures_cache_dispose (GObject *object);
+static void games_card_textures_cache_finalize (GObject *object);
 
-  gobject_class->dispose = aisleriot_card_cache_dispose;
-  gobject_class->finalize = aisleriot_card_cache_finalize;
-  gobject_class->set_property = aisleriot_card_cache_set_property;
-  gobject_class->get_property = aisleriot_card_cache_get_property;
+G_DEFINE_TYPE (GamesCardTexturesCache, games_card_textures_cache, G_TYPE_OBJECT);
 
-  g_type_class_add_private (klass, sizeof (AisleriotCardCachePrivate));
+#define GAMES_CARD_TEXTURES_CACHE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GAMES_TYPE_CARD_TEXTURES_CACHE, GamesCardTexturesCachePrivate))
 
-  pspec = g_param_spec_object ("card-images", NULL, NULL,
-                               GAMES_TYPE_CARD_IMAGES,
-                               G_PARAM_WRITABLE |
-                               G_PARAM_CONSTRUCT_ONLY |
-                               G_PARAM_STATIC_NAME |
-                               G_PARAM_STATIC_NICK |
-                               G_PARAM_STATIC_BLURB);
-  g_object_class_install_property (gobject_class, PROP_CARD_IMAGES, pspec);
-}
+/* Helper functions */
 
 static void
-aisleriot_card_cache_init (AisleriotCardCache *self)
+games_card_textures_cache_unref_images (GamesCardTexturesCache *cache)
 {
-  AisleriotCardCachePrivate *priv;
-
-  priv = self->priv = AISLERIOT_CARD_CACHE_GET_PRIVATE (self);
+  GamesCardTexturesCachePrivate *priv = cache->priv;
 
-  priv->cards = g_malloc0 (sizeof (ClutterActor *) * GAMES_CARDS_TOTAL * 2);
+  if (priv->card_images) {
+    g_signal_handler_disconnect (priv->card_images, priv->theme_handler);
+    g_object_unref (priv->card_images);
+    priv->card_images = NULL;
+  }
 }
 
 static void
-aisleriot_card_cache_dispose (GObject *object)
+games_card_textures_cache_set_card_images (GamesCardTexturesCache *cache,
+                                      GamesCardImages *card_images)
 {
-  AisleriotCardCache *self = (AisleriotCardCache *) object;
+  GamesCardTexturesCachePrivate *priv = cache->priv;
+
+  if (card_images)
+    g_object_ref (card_images);
 
-  aisleriot_card_cache_clear (self);
+  games_card_textures_cache_unref_images (cache);
 
-  aisleriot_card_cache_unref_images (self);
+  priv->card_images = card_images;
+
+  if (card_images)
+    priv->theme_handler
+      = g_signal_connect_swapped (card_images, "notify::theme",
+                                  G_CALLBACK (games_card_textures_cache_clear),
+                                  NULL);
+
+  games_card_textures_cache_clear (cache);
 
-  G_OBJECT_CLASS (aisleriot_card_cache_parent_class)->dispose (object);
+  g_object_notify (G_OBJECT (cache), "card-images");
 }
 
+/* Class implementation */
+
+
 static void
-aisleriot_card_cache_finalize (GObject *object)
+games_card_textures_cache_init (GamesCardTexturesCache *self)
 {
-  AisleriotCardCache *self = (AisleriotCardCache *) object;
-  AisleriotCardCachePrivate *priv = self->priv;
+  GamesCardTexturesCachePrivate *priv;
 
-  g_free (priv->cards);
+  priv = self->priv = GAMES_CARD_TEXTURES_CACHE_GET_PRIVATE (self);
 
-  G_OBJECT_CLASS (aisleriot_card_cache_parent_class)->finalize (object);
+  priv->cards = g_malloc0 (sizeof (ClutterActor *) * GAMES_CARDS_TOTAL * 2);
 }
 
 static void
-aisleriot_card_cache_set_card_images (AisleriotCardCache *cache,
-                                      GamesCardImages *card_images)
+games_card_textures_cache_dispose (GObject *object)
 {
-  AisleriotCardCachePrivate *priv = cache->priv;
+  GamesCardTexturesCache *self = (GamesCardTexturesCache *) object;
 
-  if (card_images)
-    g_object_ref (card_images);
+  games_card_textures_cache_clear (self);
 
-  aisleriot_card_cache_unref_images (cache);
+  games_card_textures_cache_unref_images (self);
 
-  priv->card_images = card_images;
+  G_OBJECT_CLASS (games_card_textures_cache_parent_class)->dispose (object);
+}
 
-  if (card_images)
-    priv->theme_handler
-      = g_signal_connect_swapped (card_images, "notify::theme",
-                                  G_CALLBACK (aisleriot_card_cache_clear),
-                                  NULL);
+static void
+games_card_textures_cache_finalize (GObject *object)
+{
+  GamesCardTexturesCache *self = (GamesCardTexturesCache *) object;
+  GamesCardTexturesCachePrivate *priv = self->priv;
 
-  aisleriot_card_cache_clear (cache);
+  g_free (priv->cards);
 
-  g_object_notify (G_OBJECT (cache), "card-images");
+  G_OBJECT_CLASS (games_card_textures_cache_parent_class)->finalize (object);
 }
 
 static void
-aisleriot_card_cache_set_property (GObject *self,
+games_card_textures_cache_set_property (GObject *self,
                                    guint property_id,
                                    const GValue *value,
                                    GParamSpec *pspec)
 {
-  AisleriotCardCache *cache = AISLERIOT_CARD_CACHE (self);
+  GamesCardTexturesCache *cache = GAMES_CARD_TEXTURES_CACHE (self);
 
   switch (property_id) {
     case PROP_CARD_IMAGES:
-      aisleriot_card_cache_set_card_images (cache, g_value_get_object (value));
+      games_card_textures_cache_set_card_images (cache, g_value_get_object (value));
       break;
 
     default:
@@ -161,13 +139,13 @@
 }
 
 static void
-aisleriot_card_cache_get_property (GObject *self,
+games_card_textures_cache_get_property (GObject *self,
                                    guint property_id,
                                    GValue *value,
                                    GParamSpec *pspec)
 {
-  AisleriotCardCache *cache = AISLERIOT_CARD_CACHE (self);
-  AisleriotCardCachePrivate *priv = cache->priv;
+  GamesCardTexturesCache *cache = GAMES_CARD_TEXTURES_CACHE (self);
+  GamesCardTexturesCachePrivate *priv = cache->priv;
 
   switch (property_id) {
     case PROP_CARD_IMAGES:
@@ -180,19 +158,49 @@
     }
 }
 
-AisleriotCardCache *
-aisleriot_card_cache_new (GamesCardImages *images)
+static void
+games_card_textures_cache_class_init (GamesCardTexturesCacheClass *klass)
 {
-  AisleriotCardCache *self = g_object_new (AISLERIOT_TYPE_CARD_CACHE,
-                                           "card-images", images, NULL);
+  GObjectClass *gobject_class = (GObjectClass *) klass;
+  GParamSpec *pspec;
+
+  gobject_class->dispose = games_card_textures_cache_dispose;
+  gobject_class->finalize = games_card_textures_cache_finalize;
+  gobject_class->set_property = games_card_textures_cache_set_property;
+  gobject_class->get_property = games_card_textures_cache_get_property;
 
-  return self;
+  g_type_class_add_private (klass, sizeof (GamesCardTexturesCachePrivate));
+
+  pspec = g_param_spec_object ("card-images", NULL, NULL,
+                               GAMES_TYPE_CARD_IMAGES,
+                               G_PARAM_WRITABLE |
+                               G_PARAM_CONSTRUCT_ONLY |
+                               G_PARAM_STATIC_NAME |
+                               G_PARAM_STATIC_NICK |
+                               G_PARAM_STATIC_BLURB);
+  g_object_class_install_property (gobject_class, PROP_CARD_IMAGES, pspec);
+}
+
+/* Public API */
+
+/**
+ * games_card_textures_cache_new:
+ *
+ * Returns: a new #GamesCardTexturesCache object
+ */
+GamesCardTexturesCache *
+games_card_textures_cache_new (GamesCardImages *images)
+{
+  return g_object_new (GAMES_TYPE_CARD_TEXTURES_CACHE,
+                       "card-images", images,
+                       NULL);
 }
 
+/* FIXME: make this private and automatic */
 void
-aisleriot_card_cache_clear (AisleriotCardCache *cache)
+games_card_textures_cache_clear (GamesCardTexturesCache *cache)
 {
-  AisleriotCardCachePrivate *priv = cache->priv;
+  GamesCardTexturesCachePrivate *priv = cache->priv;
   int i;
 
   for (i = 0; i < GAMES_CARDS_TOTAL * 2; i++)
@@ -202,15 +210,23 @@
     }
 }
 
+/**
+ * games_card_textures_cache_get_card_texture_by_id:
+ * @cache:
+ * @card_id:
+ * @highlighted:
+ *
+ * Returns: a cached #CoglHandle for @card_id.
+ */
 CoglHandle
-aisleriot_card_cache_get_card_texture_by_id (AisleriotCardCache *cache,
-                                             guint card_id,
-                                             gboolean highlighted)
+games_card_textures_cache_get_card_texture_by_id (GamesCardTexturesCache *cache,
+                                                  guint card_id,
+                                                  gboolean highlighted)
 {
-  AisleriotCardCachePrivate *priv;
+  GamesCardTexturesCachePrivate *priv;
   guint index;
 
-  g_return_val_if_fail (AISLERIOT_IS_CARD_CACHE (cache), NULL);
+  g_return_val_if_fail (GAMES_IS_CARD_TEXTURES_CACHE (cache), NULL);
   g_return_val_if_fail (card_id < GAMES_CARDS_TOTAL , NULL);
 
   priv = cache->priv;
@@ -244,34 +260,37 @@
   return priv->cards[index];
 }
 
+/**
+ * games_card_textures_cache_get_card_texture:
+ * @cache:
+ * @card:
+ * @highlighted:
+ *
+ * Returns: a cached #CoglHandle for @card.
+ */
 CoglHandle
-aisleriot_card_cache_get_card_texture (AisleriotCardCache *cache,
-                                       Card card,
-                                       gboolean highlighted)
+games_card_textures_cache_get_card_texture (GamesCardTexturesCache *cache,
+                                            Card card,
+                                            gboolean highlighted)
 {
   guint card_id = games_card_images_card_to_index (card);
 
-  return aisleriot_card_cache_get_card_texture_by_id (cache, card_id,
-                                                      highlighted);
+  return games_card_textures_cache_get_card_texture_by_id (cache, card_id,
+                                                           highlighted);
 }
 
+/**
+ * games_card_textures_cache_get_slot_texture:
+ * @cache:
+ * @highlighted:
+ *
+ * Returns: a cached #CoglHandle for the slot.
+ */
 CoglHandle
-aisleriot_card_cache_get_slot_texture (AisleriotCardCache *cache,
-                                       gboolean highlighted)
+games_card_textures_cache_get_slot_texture (GamesCardTexturesCache *cache,
+                                            gboolean highlighted)
 {
-  return aisleriot_card_cache_get_card_texture_by_id (cache,
-                                                      GAMES_CARD_SLOT,
-                                                      highlighted);
-}
-
-static void
-aisleriot_card_cache_unref_images (AisleriotCardCache *cache)
-{
-  AisleriotCardCachePrivate *priv = cache->priv;
-
-  if (priv->card_images) {
-    g_signal_handler_disconnect (priv->card_images, priv->theme_handler);
-    g_object_unref (priv->card_images);
-    priv->card_images = NULL;
-  }
+  return games_card_textures_cache_get_card_texture_by_id (cache,
+                                                           GAMES_CARD_SLOT,
+                                                           highlighted);
 }

Added: trunk/libgames-support/games-card-textures-cache.h
==============================================================================
--- (empty file)
+++ trunk/libgames-support/games-card-textures-cache.h	Fri Dec  5 21:43:24 2008
@@ -0,0 +1,71 @@
+/*
+ *  Copyright  2008 Neil Roberts
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2, or (at your option)
+ *  any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef GAMES_CARD_TEXTURES_CACHE_H
+#define GAMES_CARD_TEXTURES_CACHE_H
+
+#include <glib-object.h>
+#include <cogl/cogl.h>
+
+#include "games-card-images.h"
+
+G_BEGIN_DECLS
+
+#define GAMES_TYPE_CARD_TEXTURES_CACHE            (games_card_textures_cache_get_type())
+#define GAMES_CARD_TEXTURES_CACHE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_CARD_TEXTURES_CACHE, GamesCardTexturesCache))
+#define GAMES_CARD_TEXTURES_CACHE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_CARD_TEXTURES_CACHE, GamesCardTexturesCacheClass))
+#define GAMES_IS_CARD_TEXTURES_CACHE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_CARD_TEXTURES_CACHE))
+#define GAMES_IS_CARD_TEXTURES_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_CARD_TEXTURES_CACHE))
+#define GAMES_CARD_TEXTURES_CACHE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_CARD_TEXTURES_CACHE, GamesCardTexturesCacheClass))
+
+typedef struct _GamesCardTexturesCache        GamesCardTexturesCache;
+typedef struct _GamesCardTexturesCacheClass   GamesCardTexturesCacheClass;
+typedef struct _GamesCardTexturesCachePrivate GamesCardTexturesCachePrivate;
+
+struct _GamesCardTexturesCacheClass
+{
+  GObjectClass parent_class;
+};
+
+struct _GamesCardTexturesCache
+{
+  GObject parent;
+
+  GamesCardTexturesCachePrivate *priv;
+};
+
+GType games_card_textures_cache_get_type (void);
+
+GamesCardTexturesCache *games_card_textures_cache_new (GamesCardImages *images);
+
+CoglHandle games_card_textures_cache_get_card_texture (GamesCardTexturesCache *cache,
+                                                       Card card,
+                                                       gboolean highlighted);
+
+CoglHandle games_card_textures_cache_get_card_texture_by_id (GamesCardTexturesCache *cache,
+                                                             guint card_id,
+                                                             gboolean highlighted);
+
+CoglHandle games_card_textures_cache_get_slot_texture (GamesCardTexturesCache *cache,
+                                                       gboolean highlighted);
+
+void games_card_textures_cache_clear (GamesCardTexturesCache *cache);
+
+G_END_DECLS
+
+#endif /* GAMES_CARD_TEXTURES_CACHE_H */



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