gtk 2 program icon question

Charles Curley charlescurley at charlescurley.com
Mon Sep 20 08:25:10 MDT 2010


On Sun, 19 Sep 2010 23:46:39 -0600
Stuart Jansen <sjansen at buscaluz.org> wrote:

> On Sun, 2010-09-19 at 22:53 -0600, Charles Curley wrote:
> > I'd like to set the program icon for a gtk 2 application written in
> > C. To do this, I know to use gtk_window_set_icon (). It takes a GDK
> > pixbuf. I can create a pixbuf from an external file using
> > gdk_pixbuf_new_from_file, but that's a bit tacky. I'd rather
> > compile it into the program. Supposedly you can do it, but how?
> 
> 
> http://library.gnome.org/devel/gdk-pixbuf/stable/gdk-pixbuf-creating.html#gdk-pixbuf-new-from-xpm-data
> 
> or
> 
> http://library.gnome.org/devel/gdk-pixbuf/stable/gdk-pixbuf-creating.html#gdk-pixbuf-new-from-inline

Thank you, that did it, with a nice one-liner:


        /* Set our icon. */
        gtk_window_set_icon ((GtkWindow *)window,
                             gdk_pixbuf_new_from_inline ( -1,
        iconPixBuf, false, NULL));

I went with the pixbuf rather than xpm because the pixbuf will be as
portable as gkt+ lets it be, and everything else graphical in the
program is gtk+.


-- 

Charles Curley                  /"\    ASCII Ribbon Campaign
Looking for fine software       \ /    Respect for open standards
and/or writing?                  X     No HTML/RTF in email
http://www.charlescurley.com    / \    No M$ Word docs in email

Key fingerprint = CE5C 6645 A45A 64E4 94C0  809C FFF6 4C48 4ECD DFDB


More information about the PLUG mailing list