From 782d2aa4983eb0343fe3a873784e73de0600829c Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Fri, 10 Apr 2015 13:46:29 +0200 Subject: [PATCH] Better relocation. --- .gitignore | 2 + config.h.in | 105 ---------------------------------- libgtkform/form.c | 34 ++++++++++- libgtkformui/gtkformdecoder.c | 32 ++++++++++- 4 files changed, 63 insertions(+), 110 deletions(-) delete mode 100644 config.h.in diff --git a/.gitignore b/.gitignore index faedc98..2efd53d 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,8 @@ Makefile.in.in Makevars aclocal.m4 autom4te.cache/ +compile +config.h.in config.guess config.log config.sub diff --git a/config.h.in b/config.h.in deleted file mode 100644 index 6299cd3..0000000 --- a/config.h.in +++ /dev/null @@ -1,105 +0,0 @@ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* always defined to indicate that i18n is enabled */ -#undef ENABLE_NLS - -/* The prefix for our gettext translation domains. */ -#undef GETTEXT_PACKAGE - -/* Define to 1 if you have the `bind_textdomain_codeset' function. */ -#undef HAVE_BIND_TEXTDOMAIN_CODESET - -/* Define to 1 if you have the `dcgettext' function. */ -#undef HAVE_DCGETTEXT - -/* Define to 1 if you have the header file. */ -#undef HAVE_DLFCN_H - -/* Define if the GNU gettext() function is already present or preinstalled. */ -#undef HAVE_GETTEXT - -/* Define to 1 if you have the header file. */ -#undef HAVE_INTTYPES_H - -/* Define if your file defines LC_MESSAGES. */ -#undef HAVE_LC_MESSAGES - -/* Define to 1 if you have the `localeconv' function. */ -#undef HAVE_LOCALECONV - -/* Define to 1 if you have the header file. */ -#undef HAVE_LOCALE_H - -/* Define to 1 if your system has a GNU libc compatible `malloc' function, and - to 0 otherwise. */ -#undef HAVE_MALLOC - -/* Define to 1 if you have the header file. */ -#undef HAVE_MEMORY_H - -/* Define to 1 if you have the `setlocale' function. */ -#undef HAVE_SETLOCALE - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDINT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDLIB_H - -/* Define to 1 if you have the `strcasecmp' function. */ -#undef HAVE_STRCASECMP - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRINGS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRING_H - -/* Define to 1 if you have the `strtol' function. */ -#undef HAVE_STRTOL - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_STAT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TYPES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_UNISTD_H - -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ -#undef LT_OBJDIR - -/* Name of package */ -#undef PACKAGE - -/* Define to the address where bug reports for this package should be sent. */ -#undef PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#undef PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#undef PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the home page for this package. */ -#undef PACKAGE_URL - -/* Define to the version of this package. */ -#undef PACKAGE_VERSION - -/* Define to 1 if you have the ANSI C header files. */ -#undef STDC_HEADERS - -/* Version number of package */ -#undef VERSION - -/* Define to empty if `const' does not conform to ANSI C. */ -#undef const - -/* Define to rpl_malloc if the replacement function should be used. */ -#undef malloc diff --git a/libgtkform/form.c b/libgtkform/form.c index eaacdd1..b678c8c 100644 --- a/libgtkform/form.c +++ b/libgtkform/form.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2013 Andrea Zagli + * Copyright (C) 2005-2015 Andrea Zagli * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -29,6 +29,10 @@ #include #include +#ifdef G_OS_WIN32 + #include +#endif + #include "form.h" #include "fieldboolean.h" @@ -122,6 +126,30 @@ struct _GtkFormPrivate G_DEFINE_TYPE (GtkForm, gtk_form, G_TYPE_OBJECT) +#ifdef G_OS_WIN32 +static HMODULE backend_dll = NULL; + +BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved); + +BOOL WINAPI +DllMain (HINSTANCE hinstDLL, + DWORD fdwReason, + LPVOID lpReserved) +{ + switch (fdwReason) + { + case DLL_PROCESS_ATTACH: + backend_dll = (HMODULE) hinstDLL; + break; + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + break; + } + return TRUE; +} +#endif + static void gtk_form_class_init (GtkFormClass *class) { @@ -198,7 +226,7 @@ GtkForm gchar *moddir; gchar *p; - moddir = g_win32_get_package_installation_directory_of_module (NULL); + moddir = g_win32_get_package_installation_directory_of_module (backend_dll); p = g_strrstr (moddir, g_strdup_printf ("%c", G_DIR_SEPARATOR)); if (p != NULL @@ -2999,7 +3027,7 @@ gtk_form_load_modules (GtkForm *form) gchar *moddir; gchar *p; - moddir = g_win32_get_package_installation_directory_of_module (NULL); + moddir = g_win32_get_package_installation_directory_of_module (backend_dll); p = g_strrstr (moddir, g_strdup_printf ("%c", G_DIR_SEPARATOR)); if (p != NULL diff --git a/libgtkformui/gtkformdecoder.c b/libgtkformui/gtkformdecoder.c index 428217c..f561ff0 100644 --- a/libgtkformui/gtkformdecoder.c +++ b/libgtkformui/gtkformdecoder.c @@ -1,7 +1,7 @@ /* * GtkFormDecoder widget for GTK+ * - * Copyright (C) 2011-2013 Andrea Zagli + * Copyright (C) 2011-2015 Andrea Zagli * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -25,6 +25,10 @@ #include +#ifdef G_OS_WIN32 + #include +#endif + #include #include @@ -123,6 +127,30 @@ G_DEFINE_TYPE_WITH_CODE (GtkFormDecoder, gtk_form_decoder, GTK_TYPE_BIN, G_IMPLEMENT_INTERFACE (GDAEX_QUERY_EDITOR_TYPE_IWIDGET, gtk_form_decoder_gdaex_query_editor_iwidget_interface_init)); +#ifdef G_OS_WIN32 +static HMODULE backend_dll = NULL; + +BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved); + +BOOL WINAPI +DllMain (HINSTANCE hinstDLL, + DWORD fdwReason, + LPVOID lpReserved) +{ + switch (fdwReason) + { + case DLL_PROCESS_ATTACH: + backend_dll = (HMODULE) hinstDLL; + break; + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + break; + } + return TRUE; +} +#endif + static void gtk_form_decoder_class_init (GtkFormDecoderClass *klass) { @@ -374,7 +402,7 @@ GtkWidget gchar *moddir; gchar *p; - moddir = g_win32_get_package_installation_directory_of_module (NULL); + moddir = g_win32_get_package_installation_directory_of_module (backend_dll); p = g_strrstr (moddir, g_strdup_printf ("%c", G_DIR_SEPARATOR)); if (p != NULL -- 2.49.0