X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=src%2Fgis-plugin.c;h=f87b09a6ba50d860558fecb126af919ca8e35118;hb=a2a902d978b6050289f7a92794fb1dc0aa2b5e26;hp=c874095bd41795ac4381ca4a2ac97e728fd819a3;hpb=d836e9913e3fa991c935a8e7d5064f9adb51e191;p=grits diff --git a/src/gis-plugin.c b/src/gis-plugin.c index c874095..f87b09a 100644 --- a/src/gis-plugin.c +++ b/src/gis-plugin.c @@ -1,16 +1,16 @@ /* * Copyright (C) 2009 Andy Spencer - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program 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 General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ @@ -56,7 +56,8 @@ void gis_plugin_expose(GisPlugin *self) GtkWidget *gis_plugin_get_config(GisPlugin *self) { g_return_val_if_fail(GIS_IS_PLUGIN(self), NULL); - return GIS_PLUGIN_GET_INTERFACE(self)->get_config(self); + GisPluginInterface *iface = GIS_PLUGIN_GET_INTERFACE(self); + return iface->get_config ? iface->get_config (self) : NULL; } @@ -99,6 +100,7 @@ GList *gis_plugins_available(GisPlugins *self) g_debug("GisPlugins: available"); GList *list = NULL; gchar *dirs[] = {self->dir, PLUGINSDIR}; + g_debug("pluginsdir=%s", PLUGINSDIR); for (int i = 0; i<2; i++) { GDir *dir = g_dir_open(dirs[i], 0, NULL); if (dir == NULL) @@ -106,7 +108,7 @@ GList *gis_plugins_available(GisPlugins *self) g_debug(" checking %s", dirs[i]); const gchar *name; while ((name = g_dir_read_name(dir))) { - if (g_pattern_match_simple("*.so", name)) { + if (g_pattern_match_simple("*." G_MODULE_SUFFIX, name)) { gchar **parts = g_strsplit(name, ".", 2); list = g_list_prepend(list, g_strdup(parts[0])); g_strfreev(parts); @@ -117,17 +119,22 @@ GList *gis_plugins_available(GisPlugins *self) } GisPlugin *gis_plugins_load(GisPlugins *self, const char *name, - GisWorld *world, GisView *view, GisOpenGL *opengl, GisPrefs *prefs) + GisViewer *viewer, GisOpenGL *opengl, GisPrefs *prefs) { g_debug("GisPlugins: load %s", name); gchar *path = g_strdup_printf("%s/%s.%s", self->dir, name, G_MODULE_SUFFIX); - if (!g_file_test(path, G_FILE_TEST_EXISTS)) + g_debug("GisPlugins: load - trying %s", path); + if (!g_file_test(path, G_FILE_TEST_EXISTS)) { + g_free(path); path = g_strdup_printf("%s/%s.%s", PLUGINSDIR, name, G_MODULE_SUFFIX); + } + g_debug("GisPlugins: load - trying %s", path); if (!g_file_test(path, G_FILE_TEST_EXISTS)) { g_warning("Module %s not found", name); + g_free(path); return NULL; } - GModule *module = g_module_open(path, 0); + GModule *module = g_module_open(path, G_MODULE_BIND_LAZY); g_free(path); if (module == NULL) { g_warning("Unable to load module %s: %s", name, g_module_error()); @@ -146,9 +153,9 @@ GisPlugin *gis_plugins_load(GisPlugins *self, const char *name, g_free(constructor_str); GisPluginConstructor constructor = constructor_ptr; - GisPluginStore *store = g_malloc(sizeof(GisPluginStore)); + GisPluginStore *store = g_new0(GisPluginStore, 1); store->name = g_strdup(name); - store->plugin = constructor(world, view, opengl, prefs); + store->plugin = constructor(viewer, opengl, prefs); g_ptr_array_add(self->plugins, store); return store->plugin; }