summaryrefslogtreecommitdiff
path: root/demos
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2013-01-30 16:57:13 +0100
committerBenjamin Otte <otte@redhat.com>2013-02-01 17:42:45 +0100
commit159dabd0a54d3e758863c7024ab409b68bead276 (patch)
treed2146b3f15326c2bbf1fea337f30a4711e700a65 /demos
parent68ee7c6848a4dd4da6e1defdbf6f7202c4d9e888 (diff)
downloadgtk+-159dabd0a54d3e758863c7024ab409b68bead276.tar.gz
gtk-demo: Port pixbufs example to resources
Diffstat (limited to 'demos')
-rw-r--r--demos/gtk-demo/demo.gresource.xml11
-rw-r--r--demos/gtk-demo/pixbufs.c38
2 files changed, 22 insertions, 27 deletions
diff --git a/demos/gtk-demo/demo.gresource.xml b/demos/gtk-demo/demo.gresource.xml
index e836f86dd2..cc4397d390 100644
--- a/demos/gtk-demo/demo.gresource.xml
+++ b/demos/gtk-demo/demo.gresource.xml
@@ -58,6 +58,17 @@
<file>floppybuddy.gif</file>
<file>gtk-logo-rgb.gif</file>
</gresource>
+ <gresource prefix="/pixbufs">
+ <file>apple-red.png</file>
+ <file>background.jpg</file>
+ <file>gnome-applets.png</file>
+ <file>gnome-calendar.png</file>
+ <file>gnome-foot.png</file>
+ <file>gnome-gmush.png</file>
+ <file>gnome-gimp.png</file>
+ <file>gnome-gsame.png</file>
+ <file>gnu-keys.png</file>
+ </gresource>
<gresource prefix="/sources">
<file>application.c</file>
<file>appwindow.c</file>
diff --git a/demos/gtk-demo/pixbufs.c b/demos/gtk-demo/pixbufs.c
index 5e0d7dfa24..3f4f896abe 100644
--- a/demos/gtk-demo/pixbufs.c
+++ b/demos/gtk-demo/pixbufs.c
@@ -20,17 +20,17 @@
#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 +56,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,12 +69,7 @@ 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 */