From 8eca7423c4dd8a6e60dd0f2d63e8b2cf7f047463 Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Thu, 19 May 2011 17:17:44 +0200 Subject: [PATCH] Better integration with windows. Added support for environment variable LIBGTKFORM_MODULESDIR. --- src/form.c | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/src/form.c b/src/form.c index 868fef4..1c341c2 100644 --- a/src/form.c +++ b/src/form.c @@ -188,7 +188,7 @@ GtkForm } else { - g_warning (_("Modules not supported from this operating system.")); + g_warning (_("Modules not supported by this operating system.")); } return form; @@ -2466,6 +2466,7 @@ gtk_form_show_check_error_dialog (GtkFormWidget *fwidget, static void gtk_form_load_modules (GtkForm *form) { + gchar *modulesdir; GDir *dir; GError *error; @@ -2474,9 +2475,38 @@ gtk_form_load_modules (GtkForm *form) GtkFormPrivate *priv = GTK_FORM_GET_PRIVATE (form); + modulesdir = (gchar *)g_getenv ("LIBGTKFORM_MODULESDIR"); + if (modulesdir == NULL) + { +#ifdef G_OS_WIN32 + + gchar *moddir; + gchar *p; + + moddir = g_win32_get_package_installation_directory_of_module (NULL); + + p = g_strrstr (moddir, g_strdup_printf ("%c", G_DIR_SEPARATOR)); + if (p != NULL + && (g_ascii_strcasecmp (p + 1, "src") == 0 + || g_ascii_strcasecmp (p + 1, ".libs") == 0)) + { + modulesdir = g_strdup (MODULESDIR); + } + else + { + modulesdir = g_build_filename (moddir, "lib", PACKAGE, "modules", NULL); + } + +#else + + modulesdir = g_strdup (MODULESDIR); + +#endif + } + /* for each file in MODULESDIR */ error = NULL; - dir = g_dir_open (MODULESDIR, 0, &error); + dir = g_dir_open (modulesdir, 0, &error); if (dir != NULL) { while ((filename = g_dir_read_name (dir)) != NULL) @@ -2486,13 +2516,18 @@ gtk_form_load_modules (GtkForm *form) if (module != NULL) { priv->modules = g_list_append (priv->modules, (gpointer)module); - } + g_message (_("Loaded %s."), filename); + } + else + { + g_warning (_("Unable to load %s: %s."), filename, g_module_error ()); + } } g_dir_close (dir); } else { - g_warning (_("Unable to open modules dir: %s."), error->message); + g_warning (_("Unable to open modules dir: %s."), error->message != NULL ? error->message : _("no details")); } } -- 2.49.0