[gspell/wip/gspell-init] Extern the gspell HMODULE



commit 4b0e8fa7c8bdefc446dc533fc8215f76339d96ed
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Fri Mar 25 23:11:47 2016 +0100

    Extern the gspell HMODULE
    
    This is to avoid redeclaring the DllMain function

 gspell/Makefile.am       |    3 ++-
 gspell/gspell-init.c     |    1 +
 gspell/gspell-init.h     |   30 ++++++++++++++++++++++++++++++
 gspell/gspell-language.c |   34 ++--------------------------------
 4 files changed, 35 insertions(+), 33 deletions(-)
---
diff --git a/gspell/Makefile.am b/gspell/Makefile.am
index f025b4d..4803e6c 100644
--- a/gspell/Makefile.am
+++ b/gspell/Makefile.am
@@ -46,7 +46,8 @@ gspell_private_headers =                      \
        gspell-inline-checker-text-buffer.h     \
        gspell-text-iter.h                      \
        gspell-text-region.h                    \
-       gspell-utils.h
+       gspell-utils.h                          \
+       gspell-init.h
 
 gspell_private_c_files =                       \
        gspell-init.c                           \
diff --git a/gspell/gspell-init.c b/gspell/gspell-init.c
index 0631cdb..c6cb358 100644
--- a/gspell/gspell-init.c
+++ b/gspell/gspell-init.c
@@ -27,6 +27,7 @@
 #include <glib.h>
 #include <glib/gi18n-lib.h>
 #include "gconstructor.h"
+#include "glib-init.h"
 
 #ifdef G_OS_WIN32
 #define WIN32_LEAN_AND_MEAN
diff --git a/gspell/gspell-init.h b/gspell/gspell-init.h
new file mode 100644
index 0000000..afe903d
--- /dev/null
+++ b/gspell/gspell-init.h
@@ -0,0 +1,30 @@
+/*
+ * This file is part of gspell, a spell-checking library.
+ *
+ * Copyright 2016 - Ignacio Casal Quinteiro <icq gnome org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GSPELL_INIT_H__
+#define __GSPELL_INIT_H__
+
+#ifdef G_OS_WIN32
+#include <windows.h>
+extern HMODULE gspell_dll;
+#endif
+
+#endif /* __GSPELL_INIT_H__ */
+
+/* ex:set ts=8 noet: */
diff --git a/gspell/gspell-language.c b/gspell/gspell-language.c
index 42ecc95..b18c144 100644
--- a/gspell/gspell-language.c
+++ b/gspell/gspell-language.c
@@ -21,6 +21,7 @@
 
 #include "config.h"
 #include "gspell-language.h"
+#include "gspell-init.h"
 #include <string.h>
 #include <glib/gi18n-lib.h>
 #include <enchant.h>
@@ -62,44 +63,13 @@ G_DEFINE_BOXED_TYPE (GspellLanguage,
                     gspell_language_copy,
                     gspell_language_free)
 
-#ifdef G_OS_WIN32
-
-#ifdef DATADIR
-#undef DATADIR
-#endif
-
-#include <shlobj.h>
-static HMODULE hmodule;
-
-BOOL WINAPI
-DllMain (HINSTANCE hinstDLL,
-         DWORD     fdwReason,
-         LPVOID    lpvReserved);
-
-BOOL WINAPI
-DllMain (HINSTANCE hinstDLL,
-        DWORD     fdwReason,
-        LPVOID    lpvReserved)
-{
-       switch (fdwReason)
-       {
-               case DLL_PROCESS_ATTACH:
-                       hmodule = hinstDLL;
-                       break;
-       }
-
-       return TRUE;
-}
-
-#endif /* G_OS_WIN32 */
-
 static gchar *
 get_iso_codes_prefix (void)
 {
        gchar *prefix = NULL;
 
 #ifdef G_OS_WIN32
-       prefix = g_win32_get_package_installation_directory_of_module ((gpointer) hmodule);
+       prefix = g_win32_get_package_installation_directory_of_module ((gpointer) gspell_dll);
 #endif
 
        if (prefix == NULL)


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