Re: How to use pixmaps in GTK+ applications?



My question is, how to use pixmaps in GTK+? Can I make them resouces
as in Win32?

(As already was said, it's more "GTKish" (and 100% portable) to
convert them into constant C data using gdk-pixbuf-csource. If you
really want to use Win32 resources, sure, that should work too.

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

I'd suggest just defining a simple directory under $datadir. 

These replies forgot that the original poster asked about Win32. It is
not typical at all to use fixed compile-time pathnames on Win32. (I
would go so far as taying it isn't even possible, in general, as there
is no drive letter that would be guaranteed to exist on all Win32
installations. My previous home machine had no C: drive, for
instance!)

Instead, you need to have your app look up its installation location
at run-time. Use something like this:

  wchar_t buf[1000];
  gchar *exename;

  GetModuleFileNameW(NULL, wbuf, G_N_ELEMENTS(wbuf));
  exename = g_utf16_to_utf8 (wbuf, -1, NULL, NULL, NULL);

to get the path to the .exe file, and then construct the path to the
image file(s) from that (assuming your installed installs the image
files in a fixed location relative to where the .exe gets installed).

(There is also g_win32_get_package_installation_directory(NULL, NULL)
which does more or less the same. Read the documentation.)

--tml




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]