gtk-demo: Port textview example to resources

This commit is contained in:
Benjamin Otte 2013-01-30 16:46:20 +01:00
parent d1c642d1f5
commit 68ee7c6848
2 changed files with 7 additions and 21 deletions

View File

@ -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>

View File

@ -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)
{