]> saetta.ns0.it Git - libgtkform/commitdiff
Better integration with windows.
authorAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Thu, 19 May 2011 15:17:44 +0000 (17:17 +0200)
committerAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Thu, 19 May 2011 15:17:44 +0000 (17:17 +0200)
Added support for environment variable LIBGTKFORM_MODULESDIR.

src/form.c

index 868fef40b47932463a191ff8771442c8d2795109..1c341c20b2d8c3a2fe7f1d2a2d37aad59c9edab7 100644 (file)
@@ -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"));
                }
 }