]> Pileus Git - ~andy/gtk/blobdiff - demos/gtk-demo/pixbufs.c
gtk-demo: Move resources into the tests they belong
[~andy/gtk] / demos / gtk-demo / pixbufs.c
index 0095790e45a237be4a0872917ad8884d7ea700b2..e46abc2d822cb3a886016284f50ed74b9a36f47f 100644 (file)
 #include <gtk/gtk.h>
 #include <math.h>
 
-#include "demo-common.h"
-
 #define FRAME_DELAY 50
 
-#define BACKGROUND_NAME "background.jpg"
+#define BACKGROUND_NAME "/pixbufs/background.jpg"
 
 static const char *image_names[] = {
-  "apple-red.png",
-  "gnome-applets.png",
-  "gnome-calendar.png",
-  "gnome-foot.png",
-  "gnome-gmush.png",
-  "gnome-gimp.png",
-  "gnome-gsame.png",
-  "gnu-keys.png"
+  "/pixbufs/apple-red.png",
+  "/pixbufs/gnome-applets.png",
+  "/pixbufs/gnome-calendar.png",
+  "/pixbufs/gnome-foot.png",
+  "/pixbufs/gnome-gmush.png",
+  "/pixbufs/gnome-gimp.png",
+  "/pixbufs/gnome-gsame.png",
+  "/pixbufs/gnu-keys.png"
 };
 
 #define N_IMAGES G_N_ELEMENTS (image_names)
@@ -56,22 +54,11 @@ static gboolean
 load_pixbufs (GError **error)
 {
   gint i;
-  char *filename;
 
   if (background)
     return TRUE; /* already loaded earlier */
 
-  /* demo_find_file() looks in the current directory first,
-   * so you can run gtk-demo without installing GTK, then looks
-   * in the location where the file is installed.
-   */
-  filename = demo_find_file (BACKGROUND_NAME, error);
-  if (!filename)
-    return FALSE; /* note that "error" was filled in and returned */
-
-  background = gdk_pixbuf_new_from_file (filename, error);
-  g_free (filename);
-  
+  background = gdk_pixbuf_new_from_resource (BACKGROUND_NAME, error);
   if (!background)
     return FALSE; /* Note that "error" was filled with a GError */
 
@@ -80,13 +67,8 @@ load_pixbufs (GError **error)
 
   for (i = 0; i < N_IMAGES; i++)
     {
-      filename = demo_find_file (image_names[i], error);
-      if (!filename)
-        return FALSE; /* Note that "error" was filled with a GError */
-      
-      images[i] = gdk_pixbuf_new_from_file (filename, error);
-      g_free (filename);
-      
+      images[i] = gdk_pixbuf_new_from_resource (image_names[i], error);
+
       if (!images[i])
         return FALSE; /* Note that "error" was filled with a GError */
     }
@@ -175,18 +157,16 @@ timeout (gpointer data)
                                : MAX (127, fabs (255 * cos (f * 2.0 * G_PI)))));
     }
 
-  GDK_THREADS_ENTER ();
   gtk_widget_queue_draw (da);
-  GDK_THREADS_LEAVE ();
 
   frame_num++;
-  return TRUE;
+  return G_SOURCE_CONTINUE;
 }
 
 static guint timeout_id;
 
 static void
-cleanup_callback (GtkObject *object,
+cleanup_callback (GObject   *object,
                   gpointer   data)
 {
   g_source_remove (timeout_id);