Re: How to use pixmaps in GTK+ applications?
- From: Iago Rubio <iago iagorubio com>
- To: gtk-app-devel-list gnome org
- Subject: Re: How to use pixmaps in GTK+ applications?
- Date: Mon, 17 Oct 2005 07:39:56 +0200
On Sun, 2005-10-16 at 15:03 +0800, åæå wrote:
Hi,
I'm new to GTK development.
In Windows environment, pixmaps are often compiled into the binary as
resources. Or by making an installer, they can be installed as
ordinary files, in a location that fixed relative to the binary
executable.
My question is, how to use pixmaps in GTK+? Can I make them resouces
as in Win32?
You can use files directly or convert the images to C source code with
the tool gdk-pixbuf-csource included with gtk.
As example:
gdk-pixbuf-csource --raw --name=image image.png > image.h
Then from your code:
#include "image.h"
pixbuf = gdk_pixbuf_new_from_inline (-1, image, FALSE, NULL);
This way you won't need the images to be physically on disk.
If I use them as ordinary files, how can I know the path
after users' installation? What should I do in the configure.ac and
Makefile.am?
You should install them in a "known" location defined in one
configure.ac macro.
As example if you've got the files in the "images" directory this code
in the root Makefile.am should do the trick to install them.
if test -d $(srcdir)/images; then \
$(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/images; \
for pixmap in $(srcdir)/images/*; do \
if test -f $$pixmap; then \
$(INSTALL_DATA) $$pixmap $(DESTDIR)$(pkgdatadir)/images; \
fi \
done \
fi
Then in your sources directory Makefile.amyou should define one macro to
use it in your sources:
INCLUDES = \
-DPACKAGE_DATA_DIR=\""$(pkgdatadir)"\" \
....
The images will be saved on:
PACKAGE_DATA_DIR "/images"
gdk_pixbuf_new_from_file (PACKAGE_DATA_DIR "/images/image.png ", NULL);
The questions may seem stupid to you, but I don't quite understand the
autotools.
The question is not stupid and autotools have its learning curve.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]