diff options
| author | Chun-wei Fan <fanchunwei@src.gnome.org> | 2015-08-06 00:30:52 +0800 |
|---|---|---|
| committer | Chun-wei Fan <fanchunwei@src.gnome.org> | 2015-08-07 00:51:15 +0800 |
| commit | f58c9879c1986d4b77c68bd81879f692a0c62d07 (patch) | |
| tree | 07346b5e0698b0dce8c1f00e19845ac6b47fd745 | |
| parent | 407985ae9220df2189d529f8d602679e42af6b0b (diff) | |
| download | libsoup-f58c9879c1986d4b77c68bd81879f692a0c62d07.tar.gz | |
libsoup/soup-session.c: Don't Hardcode Paths on Windows
On Windows, use g_win32_get_package_installation_directory_of_module()
and g_build_filename() to acquire the localedir to find the translations
on Windows, instead of relying on the LOCALEDIR which is hardcoded at
compile time, so that the libsoup DLL can be relocated on Windows with its
translations. Therefore, we define a simple DllMain() which is used to
acquire the proper HMODULE for the purpose.
https://bugzilla.gnome.org/show_bug.cgi?id=752952
| -rw-r--r-- | libsoup/soup-session.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/libsoup/soup-session.c b/libsoup/soup-session.c index 64201838..ca8d80c8 100644 --- a/libsoup/soup-session.c +++ b/libsoup/soup-session.c @@ -77,10 +77,43 @@ * subtypes) have a #SoupContentDecoder by default. **/ +#if defined (G_OS_WIN32) +#define WIN32_LEAN_AND_MEAN +#include <windows.h> + +HMODULE soup_dll; + +BOOL WINAPI +DllMain (HINSTANCE hinstDLL, + DWORD fdwReason, + LPVOID lpvReserved) +{ + switch (fdwReason) { + case DLL_PROCESS_ATTACH: + soup_dll = hinstDLL; + break; + + case DLL_THREAD_DETACH: + + default: + /* do nothing */ + ; + } +} +#endif + static void soup_init (void) { +#ifdef G_OS_WIN32 + char *basedir = g_win32_get_package_installation_directory_of_module (soup_dll); + char *localedir = g_build_filename (basedir, "share", "locale", NULL); + bindtextdomain (GETTEXT_PACKAGE, localedir); + g_free (localedir); + g_free (basedir); +#else bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); +#endif #ifdef HAVE_BIND_TEXTDOMAIN_CODESET bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); #endif |
