[gtk+] gtk-demo: Port textview example to resources
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] gtk-demo: Port textview example to resources
- Date: Fri, 1 Feb 2013 16:47:39 +0000 (UTC)
commit 68ee7c6848a4dd4da6e1defdbf6f7202c4d9e888
Author: Benjamin Otte <otte redhat com>
Date: Wed Jan 30 16:46:20 2013 +0100
gtk-demo: Port textview example to resources
demos/gtk-demo/demo.gresource.xml | 4 ++++
demos/gtk-demo/textview.c | 24 +++---------------------
2 files changed, 7 insertions(+), 21 deletions(-)
---
diff --git a/demos/gtk-demo/demo.gresource.xml b/demos/gtk-demo/demo.gresource.xml
index 53f8650..e836f86 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 dd966f7..31aeea6 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)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]