X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fplugin.c;h=57d2f2bce7d664ad3d96cf17b445016806c02bc3;hb=d7b6c79c412c8067e30451c6e7a8f31266644efa;hp=e0067f22e808144750bb759d1954e573d0d8ea85;hpb=5bf68f762b8fc87cf5583b645b948b4fe55f179f;p=chaz%2Fopenbox diff --git a/openbox/plugin.c b/openbox/plugin.c index e0067f22..57d2f2bc 100644 --- a/openbox/plugin.c +++ b/openbox/plugin.c @@ -1,6 +1,7 @@ #include #include +typedef void (*PluginSetupConfig)(); typedef void (*PluginStartup)(); typedef void (*PluginShutdown)(); @@ -8,6 +9,7 @@ typedef struct { GModule *module; char *name; + PluginSetupConfig config; PluginStartup startup; PluginShutdown shutdown; } Plugin; @@ -30,26 +32,29 @@ static Plugin *plugin_new(char *name) p = g_new(Plugin, 1); - path = g_build_filename(PLUGINDIR, name, NULL); + path = g_build_filename(g_get_home_dir(), ".openbox", "plugins", name, + NULL); p->module = g_module_open(path, 0); g_free(path); if (p->module == NULL) { - path = g_build_filename(g_get_home_dir(), ".openbox", "plugins", name, - NULL); - p->module = g_module_open(path, 0); - g_free(path); + path = g_build_filename(PLUGINDIR, name, NULL); + p->module = g_module_open(path, 0); + g_free(path); } if (p->module == NULL) { + g_warning(g_module_error()); g_free(p); return NULL; } + p->config = (PluginSetupConfig)load_sym(p->module, name, + "plugin_setup_config"); p->startup = (PluginStartup)load_sym(p->module, name, "plugin_startup"); p->shutdown = (PluginShutdown)load_sym(p->module, name, "plugin_shutdown"); - if (p->startup == NULL || p->shutdown == NULL) { + if (p->config == NULL || p->startup == NULL || p->shutdown == NULL) { g_module_close(p->module); g_free(p); return NULL; @@ -94,9 +99,9 @@ gboolean plugin_open(char *name) g_warning("failed to load plugin '%s'", name); return FALSE; } - /* XXX p->plugin_set_config(); */ + p->config(); - g_datalist_set_data_full(&plugins, name, p, (GDestroyNotify) plugin_free); + g_datalist_set_data_full(&plugins, name, p, (GDestroyNotify) plugin_free); return TRUE; } @@ -144,6 +149,7 @@ void plugin_loadall() /* load the plugins in the rc file */ while (g_io_channel_read_line(io, &name, NULL, NULL, &err) == G_IO_STATUS_NORMAL) { + g_strstrip(name); plugin_open(name); g_free(name); }