X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=src%2Fgis-plugin.c;h=8c3ba3674a39847ff10f6eb0b886e8ffbe45e68b;hb=b088e18d9e838064bb264a145ff66e57886ee42a;hp=b0619f9b3e2fe16db971bccf26d95af54448055f;hpb=7cde9672c505332bcca7b47d94acfdf28c7729fe;p=grits diff --git a/src/gis-plugin.c b/src/gis-plugin.c index b0619f9..8c3ba36 100644 --- a/src/gis-plugin.c +++ b/src/gis-plugin.c @@ -49,14 +49,20 @@ GType gis_plugin_get_type() void gis_plugin_expose(GisPlugin *self) { - g_return_if_fail(GIS_IS_PLUGIN(self)); + if (!GIS_IS_PLUGIN(self)) + return; + GisPluginInterface *iface = GIS_PLUGIN_GET_INTERFACE(self); + if (iface->expose) + return GIS_PLUGIN_GET_INTERFACE(self)->expose(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); + if (!GIS_IS_PLUGIN(self)) + return NULL; + GisPluginInterface *iface = GIS_PLUGIN_GET_INTERFACE(self); + return iface->get_config ? iface->get_config (self) : NULL; } @@ -107,7 +113,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); @@ -118,20 +124,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, GisPrefs *prefs) { g_debug("GisPlugins: load %s", name); gchar *path = g_strdup_printf("%s/%s.%s", self->dir, name, G_MODULE_SUFFIX); + 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()); @@ -152,7 +160,7 @@ GisPlugin *gis_plugins_load(GisPlugins *self, const char *name, GisPluginStore *store = g_new0(GisPluginStore, 1); store->name = g_strdup(name); - store->plugin = constructor(world, view, opengl, prefs); + store->plugin = constructor(viewer, prefs); g_ptr_array_add(self->plugins, store); return store->plugin; } @@ -174,6 +182,8 @@ gboolean gis_plugins_unload(GisPlugins *self, const char *name) void gis_plugins_foreach(GisPlugins *self, GCallback _callback, gpointer user_data) { g_debug("GisPlugins: foreach"); + if (self == NULL) + return; typedef void (*CBFunc)(GisPlugin *, const gchar *, gpointer); CBFunc callback = (CBFunc)_callback; for (int i = 0; i < self->plugins->len; i++) {