[gnome-games] aisleriot: Don't use GdkPixbuf to load the baize



commit b44d9211d7e94ed47cefb57c4f983aeb6594b384
Author: Christian Persch <chpe gnome org>
Date:   Thu Jan 21 15:26:09 2010 +0100

    aisleriot: Don't use GdkPixbuf to load the baize
    
    Use clutter_texture_set_from_file() instead.

 aisleriot/baize.c |   47 ++++++++++-------------------------------------
 1 files changed, 10 insertions(+), 37 deletions(-)
---
diff --git a/aisleriot/baize.c b/aisleriot/baize.c
index f298977..e49f12f 100644
--- a/aisleriot/baize.c
+++ b/aisleriot/baize.c
@@ -30,42 +30,6 @@
 
 static void aisleriot_baize_paint (ClutterActor *actor);
 
-static void
-load_background (AisleriotBaize *baize)
-{
-  GError *error = NULL;
-  GdkPixbuf *pixbuf;
-  char *path;
-
-  path = games_runtime_get_file (GAMES_RUNTIME_PIXMAP_DIRECTORY, "baize.png");
-
-  pixbuf = gdk_pixbuf_new_from_file (path, &error);
-  g_free (path);
-  if (error) {
-    g_warning ("Failed to load the baize pixbuf: %s\n", error->message);
-    g_error_free (error);
-    return;
-  }
-
-  g_assert (pixbuf != NULL);
-
-  clutter_texture_set_from_rgb_data (CLUTTER_TEXTURE (baize),
-                                     gdk_pixbuf_get_pixels (pixbuf),
-                                     gdk_pixbuf_get_has_alpha (pixbuf),
-                                     gdk_pixbuf_get_width (pixbuf),
-                                     gdk_pixbuf_get_height (pixbuf),
-                                     gdk_pixbuf_get_rowstride (pixbuf),
-                                     gdk_pixbuf_get_has_alpha (pixbuf) ? 4 : 3,
-                                     0,
-                                     &error);
-  if (error) {
-    g_warning ("Failed to set texture from pixbuf: %s", error->message);
-    g_error_free (error);
-  }
-
-  g_object_unref (pixbuf);
-}
-
 G_DEFINE_TYPE (AisleriotBaize, aisleriot_baize, CLUTTER_TYPE_TEXTURE);
 
 static void
@@ -79,7 +43,16 @@ aisleriot_baize_class_init (AisleriotBaizeClass *klass)
 static void
 aisleriot_baize_init (AisleriotBaize *baize)
 {
-  load_background (baize);
+  char *path;
+  GError *error = NULL;
+
+  path = games_runtime_get_file (GAMES_RUNTIME_PIXMAP_DIRECTORY, "baize.png");
+  if (!clutter_texture_set_from_file (CLUTTER_TEXTURE (baize), path, &error)) {
+    g_warning ("Failed to load the baize from '%s': %s\n", path, error->message);
+    g_error_free (error);
+  }
+
+  g_free (path);
 }
 
 ClutterActor *



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