On Mon, 20 Sep 2010 08:25:10 -0600 Charles Curley <[email protected]> wrote:
> On Sun, 19 Sep 2010 23:46:39 -0600 > Stuart Jansen <[email protected]> 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+. > > Arrgghh. GTK 2.24.31 (on Debian 9.1, stretch) informs me that gdk_pixbuf_new_from_inline () is deprecated. The documentation tells me I should use a Gresource instead but gives no clue how. After much frustrating experimentation and searching, I figured out how to create a suitable icon.c and icon.h (I think). The function in icon.h is: extern GResource *gnome_gps_get_resource (void); What I don't have is the code to insert a Gresource into the window. Ideas? Suggestions? -- The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no Warrants shall issue, but upon probable cause, supported by Oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. -- U.S. Const. Amendment IV Key fingerprint = CE5C 6645 A45A 64E4 94C0 809C FFF6 4C48 4ECD DFDB /* PLUG: http://plug.org, #utah on irc.freenode.net Unsubscribe: http://plug.org/mailman/options/plug Don't fear the penguin. */
