use the plugins' plugin_setup_config function
This commit is contained in:
parent
5f44c45f06
commit
5d7d6038ca
1 changed files with 13 additions and 8 deletions
|
@ -1,6 +1,7 @@
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <gmodule.h>
|
#include <gmodule.h>
|
||||||
|
|
||||||
|
typedef void (*PluginSetupConfig)();
|
||||||
typedef void (*PluginStartup)();
|
typedef void (*PluginStartup)();
|
||||||
typedef void (*PluginShutdown)();
|
typedef void (*PluginShutdown)();
|
||||||
|
|
||||||
|
@ -8,6 +9,7 @@ typedef struct {
|
||||||
GModule *module;
|
GModule *module;
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
|
PluginSetupConfig config;
|
||||||
PluginStartup startup;
|
PluginStartup startup;
|
||||||
PluginShutdown shutdown;
|
PluginShutdown shutdown;
|
||||||
} Plugin;
|
} Plugin;
|
||||||
|
@ -30,15 +32,15 @@ static Plugin *plugin_new(char *name)
|
||||||
|
|
||||||
p = g_new(Plugin, 1);
|
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);
|
p->module = g_module_open(path, 0);
|
||||||
g_free(path);
|
g_free(path);
|
||||||
|
|
||||||
if (p->module == NULL) {
|
if (p->module == NULL) {
|
||||||
path = g_build_filename(g_get_home_dir(), ".openbox", "plugins", name,
|
path = g_build_filename(PLUGINDIR, name, NULL);
|
||||||
NULL);
|
p->module = g_module_open(path, 0);
|
||||||
p->module = g_module_open(path, 0);
|
g_free(path);
|
||||||
g_free(path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->module == NULL) {
|
if (p->module == NULL) {
|
||||||
|
@ -46,10 +48,12 @@ static Plugin *plugin_new(char *name)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p->config = (PluginSetupConfig)load_sym(p->module, name,
|
||||||
|
"plugin_setup_config");
|
||||||
p->startup = (PluginStartup)load_sym(p->module, name, "plugin_startup");
|
p->startup = (PluginStartup)load_sym(p->module, name, "plugin_startup");
|
||||||
p->shutdown = (PluginShutdown)load_sym(p->module, name, "plugin_shutdown");
|
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_module_close(p->module);
|
||||||
g_free(p);
|
g_free(p);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -94,9 +98,9 @@ gboolean plugin_open(char *name)
|
||||||
g_warning("failed to load plugin '%s'", name);
|
g_warning("failed to load plugin '%s'", name);
|
||||||
return FALSE;
|
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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,6 +148,7 @@ void plugin_loadall()
|
||||||
/* load the plugins in the rc file */
|
/* load the plugins in the rc file */
|
||||||
while (g_io_channel_read_line(io, &name, NULL, NULL, &err) ==
|
while (g_io_channel_read_line(io, &name, NULL, NULL, &err) ==
|
||||||
G_IO_STATUS_NORMAL) {
|
G_IO_STATUS_NORMAL) {
|
||||||
|
g_strstrip(name);
|
||||||
plugin_open(name);
|
plugin_open(name);
|
||||||
g_free(name);
|
g_free(name);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue