mirror of https://github.com/GNOME/gimp.git
Merged from trunk:
2007-12-13 Sven Neumann <sven@gimp.org> Merged from trunk: * libgimpbase/gimpenv.c (gimp_toplevel_directory) [Win32]: Use the location of the libgimpbase DLL and not that of the main executable (which will be the Python interpreter in the case of python-fu) to determine the top-level GIMP installation folder. (#502506) svn path=/branches/gimp-2-4/; revision=24348
This commit is contained in:
parent
a4c4a07376
commit
42eb5485f4
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2007-12-13 Sven Neumann <sven@gimp.org>
|
||||
|
||||
Merged from trunk:
|
||||
|
||||
* libgimpbase/gimpenv.c (gimp_toplevel_directory) [Win32]: Use
|
||||
the location of the libgimpbase DLL and not that of the main
|
||||
executable (which will be the Python interpreter in the case of
|
||||
python-fu) to determine the top-level GIMP installation
|
||||
folder. (#502506)
|
||||
|
||||
2007-12-12 Sven Neumann <sven@gimp.org>
|
||||
|
||||
Merged from trunk:
|
||||
|
|
|
@ -236,6 +236,34 @@ gimp_directory (void)
|
|||
return gimp_dir;
|
||||
}
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
|
||||
static HMODULE libgimpbase_dll = NULL;
|
||||
|
||||
/* Minimal DllMain that just stores the handle to this DLL */
|
||||
|
||||
BOOL WINAPI /* Avoid silly "no previous prototype" gcc warning */
|
||||
DllMain (HINSTANCE hinstDLL,
|
||||
DWORD fdwReason,
|
||||
LPVOID lpvReserved);
|
||||
|
||||
BOOL WINAPI
|
||||
DllMain (HINSTANCE hinstDLL,
|
||||
DWORD fdwReason,
|
||||
LPVOID lpvReserved)
|
||||
{
|
||||
switch (fdwReason)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
libgimpbase_dll = hinstDLL;
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static const gchar *
|
||||
gimp_toplevel_directory (void)
|
||||
{
|
||||
|
@ -246,23 +274,22 @@ gimp_toplevel_directory (void)
|
|||
|
||||
#ifdef G_OS_WIN32
|
||||
{
|
||||
/* Figure it out from the executable name */
|
||||
/* Figure it out from the location of this DLL */
|
||||
gchar *filename;
|
||||
gchar *sep1, *sep2;
|
||||
|
||||
wchar_t w_filename[MAX_PATH];
|
||||
|
||||
if (GetModuleFileNameW (NULL, w_filename, G_N_ELEMENTS (w_filename)) == 0)
|
||||
if (GetModuleFileNameW (libgimpbase_dll, w_filename, G_N_ELEMENTS (w_filename)) == 0)
|
||||
g_error ("GetModuleFilenameW failed");
|
||||
|
||||
filename = g_utf16_to_utf8 (w_filename, -1, NULL, NULL, NULL);
|
||||
if (filename == NULL)
|
||||
g_error ("Converting module filename to UTF-8 failed");
|
||||
|
||||
/* If the executable file name is of the format
|
||||
* <foobar>\bin\*.exe or
|
||||
* <foobar>\lib\gimp\GIMP_API_VERSION\plug-ins\*.exe, use <foobar>.
|
||||
* Otherwise, use the directory where the executable is.
|
||||
/* If the DLL file name is of the format
|
||||
* <foobar>\bin\*.dll, use <foobar>.
|
||||
* Otherwise, use the directory where the DLL is.
|
||||
*/
|
||||
|
||||
sep1 = strrchr (filename, '\\');
|
||||
|
@ -275,20 +302,6 @@ gimp_toplevel_directory (void)
|
|||
{
|
||||
*sep2 = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
gchar test[MAX_PATH];
|
||||
|
||||
g_snprintf (test, sizeof (test) - 1,
|
||||
"\\lib\\gimp\\%s\\plug-ins", GIMP_API_VERSION);
|
||||
|
||||
if (strlen (filename) > strlen (test) &&
|
||||
g_ascii_strcasecmp (filename + strlen (filename) - strlen (test),
|
||||
test) == 0)
|
||||
{
|
||||
filename[strlen (filename) - strlen (test)] = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
toplevel = filename;
|
||||
|
|
Loading…
Reference in New Issue