summaryrefslogtreecommitdiff
path: root/demos
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2013-01-30 16:46:20 +0100
committerBenjamin Otte <otte@redhat.com>2013-02-01 17:42:45 +0100
commit68ee7c6848a4dd4da6e1defdbf6f7202c4d9e888 (patch)
tree31e8423f648362ceb74b9471a2c6319cfd88de83 /demos
parentd1c642d1f54e5b3045ffdd7e5fb2b24bf3cb18ec (diff)
downloadgtk+-68ee7c6848a4dd4da6e1defdbf6f7202c4d9e888.tar.gz
gtk-demo: Port textview example to resources
Diffstat (limited to 'demos')
-rw-r--r--demos/gtk-demo/demo.gresource.xml4
-rw-r--r--demos/gtk-demo/textview.c24
2 files changed, 7 insertions, 21 deletions
diff --git a/demos/gtk-demo/demo.gresource.xml b/demos/gtk-demo/demo.gresource.xml
index 53f8650588..e836f86dd2 100644
--- a/demos/gtk-demo/demo.gresource.xml
+++ b/demos/gtk-demo/demo.gresource.xml
@@ -107,4 +107,8 @@
<file>transparent.c</file>
<file>tree_store.c</file>
</gresource>
+ <gresource prefix="/textview">
+ <file>floppybuddy.gif</file>
+ <file>gtk-logo-rgb.gif</file>
+ </gresource>
</gresources>
diff --git a/demos/gtk-demo/textview.c b/demos/gtk-demo/textview.c
index dd966f7d7c..31aeea62eb 100644
--- a/demos/gtk-demo/textview.c
+++ b/demos/gtk-demo/textview.c
@@ -132,25 +132,9 @@ insert_text (GtkTextBuffer *buffer)
GtkTextIter start, end;
GdkPixbuf *pixbuf;
GdkPixbuf *scaled;
- char *filename;
- /* 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.
- */
- pixbuf = NULL;
- filename = demo_find_file ("gtk-logo-rgb.gif", NULL);
- if (filename)
- {
- pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
- g_free (filename);
- }
-
- if (pixbuf == NULL)
- {
- g_printerr ("Failed to load image file gtk-logo-rgb.gif\n");
- exit (1);
- }
+ pixbuf = gdk_pixbuf_new_from_resource ("/textview/gtk-logo-rgb.gif", NULL);
+ g_assert (pixbuf);
scaled = gdk_pixbuf_scale_simple (pixbuf, 32, 32, GDK_INTERP_BILINEAR);
g_object_unref (pixbuf);
@@ -453,9 +437,7 @@ attach_widgets (GtkTextView *text_view)
}
else if (i == 3)
{
- gchar *filename = demo_find_file ("floppybuddy.gif", NULL);
- widget = gtk_image_new_from_file (filename);
- g_free (filename);
+ widget = gtk_image_new_from_resource ("/textview/floppybuddy.gif");
}
else if (i == 4)
{