gtk win32 and env variables



Dan McMahill writes:
On windows, it is easy for the user to pick a different place to
install so I need to set those variables.

So my question is how do gtk apps ported to windows typically deal with 
something like that?

Typically they assume that all the application's data files are
located in known locations under the top-level installation
folder. (Data files here refers to such stuff like icons, help files,
message catalogs, plug-ins and other executable modules uses at
run-time, etc that are installed with the application, not "documents"
that the users of the application create.) Then it is simply a
question of looking up where the application's main executable is
located at run-time, and construct the path to the data file from
that. (Strip the "\bin\foo.exe" and append
"\share\foo\some\stuff.bar")

There is GLib API to help in this:
g_win32_get_package_installation_directory(). The API is a bit
over-engineered, in retrospect it would have been cleaner to offer
separate functions instead of all that "if this parameter is NULL,
then do this, otherwise if the other is NULL, do that, else do that".

Also ignore what its docs say about looking up from the Registry,
putting stuff there is really not recommended. Just call

   g_win32_get_package_installation_directory (NULL, NULL)

and it will return the path to the application's installation
folder. (Assuming the app's .exe is in a "bin" subfolder of that.) It
will return it in UTF-8, but that is what a well-behaving gtk app on
Win32 should use anyway for file names (and then use the gstdio
wrappers to manipulate files).

--tml




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