GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Fri Dec 19, 2014 9:41 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Embedded Icons in binaries
PostPosted: Mon Jun 09, 2008 9:06 am 
Offline

Joined: Fri Jun 06, 2008 8:58 am
Posts: 1
Hello,

I'm new to GTK development and I'm trying to have my resources (mainly icons) embedded in the final binaries, so that I don't rely on these files to be on the user's disk (they might get accidentally deleted or whatever). This was a simple task to implement in Win32 programming. How can I do this?
Thanks,
Ionut


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 09, 2008 3:41 pm 
Offline
Never Seen the Sunlight

Joined: Thu Jun 14, 2007 11:02 pm
Posts: 923
Location: Falun, WI USA
you can use gdk-pixbuf-csource to convert an image into a C file:
http://library.gnome.org/devel/gdk-pixb ... ource.html
then you can use GdkPixbuf and GtkImage to display the data:
http://library.gnome.org/devel/gdk-pixb ... rom-inline
http://library.gnome.org/devel/gtk/stab ... rom-pixbuf

this example is based off of the command:
[code=]gdk-pixbuf-csource --raw --extern --name=test_png_inline test.png > test.png.c[/code]
Code:
#include <gtk/gtk.h>

extern guint8 test_png_inline;

int main(int argc, char **argv)
{
   GtkWidget *win;
   GdkPixbuf *pb;
   GtkWidget *im;

   gtk_init(&argc, &argv);

   win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
   g_signal_connect(G_OBJECT(win), "delete_event", G_CALLBACK(gtk_main_quit), NULL);
   gtk_container_set_border_width(GTK_CONTAINER(win), 10);

   pb = gdk_pixbuf_new_from_inline(-1, &test_png_inline, FALSE, NULL);
   im = gtk_image_new_from_pixbuf(pb);
   gtk_container_add(GTK_CONTAINER(win), im);
   gtk_widget_show(im);

   gtk_widget_show(win);

   gtk_main();
   return 0;
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: zerohour and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group