]> Pileus Git - ~andy/gtk/commitdiff
gtk-demo: Port textview example to resources
authorBenjamin Otte <otte@redhat.com>
Wed, 30 Jan 2013 15:46:20 +0000 (16:46 +0100)
committerBenjamin Otte <otte@redhat.com>
Fri, 1 Feb 2013 16:42:45 +0000 (17:42 +0100)
demos/gtk-demo/demo.gresource.xml
demos/gtk-demo/textview.c

index 53f8650588042753d209016b07560d8d894c5221..e836f86dd2e7534f3decefd92d9c886910a83225 100644 (file)
     <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>
index dd966f7d7c9cfc80a072f2de234d5d6b924522de..31aeea62eb20fe11df6c545bdf5362ebf53210de 100644 (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)
         {