X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=openbox%2Fplugin.c;h=e0067f22e808144750bb759d1954e573d0d8ea85;hb=fdf4265a13f5aacc87b4bdf7ae851505eff780a6;hp=247d490a5faa03fe5b1c090f8cc6a6f33a2aae52;hpb=bfea000a7407e51b5659590415e410a47f6f046b;p=chaz%2Fopenbox diff --git a/openbox/plugin.c b/openbox/plugin.c index 247d490a..e0067f22 100644 --- a/openbox/plugin.c +++ b/openbox/plugin.c @@ -46,8 +46,8 @@ static Plugin *plugin_new(char *name) return NULL; } - p->startup = load_sym(p->module, name, "plugin_startup"); - p->shutdown = load_sym(p->module, name, "plugin_shutdown"); + 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) { g_module_close(p->module); @@ -94,9 +94,9 @@ gboolean plugin_open(char *name) g_warning("failed to load plugin '%s'", name); return FALSE; } + /* XXX p->plugin_set_config(); */ g_datalist_set_data_full(&plugins, name, p, (GDestroyNotify) plugin_free); - p->startup(); return TRUE; } @@ -104,3 +104,49 @@ void plugin_close(char *name) { g_datalist_remove_data(&plugins, name); } + +static void foreach_start(GQuark key, Plugin *p, gpointer *foo) +{ + p->startup(); +} + +void plugin_startall() +{ + g_datalist_foreach(&plugins, (GDataForeachFunc)foreach_start, NULL); +} + +void plugin_loadall() +{ + GIOChannel *io; + GError *err; + char *path, *name; + + path = g_build_filename(g_get_home_dir(), ".openbox", "pluginrc", NULL); + err = NULL; + io = g_io_channel_new_file(path, "r", &err); + g_free(path); + + if (io == NULL) { + path = g_build_filename(RCDIR, "pluginrc", NULL); + err = NULL; + io = g_io_channel_new_file(path, "r", &err); + g_free(path); + } + + if (io == NULL) { + /* load the default plugins */ + plugin_open("focus"); + plugin_open("keyboard"); + plugin_open("mouse"); + plugin_open("placement"); + plugin_open("resistance"); + } else { + /* load the plugins in the rc file */ + while (g_io_channel_read_line(io, &name, NULL, NULL, &err) == + G_IO_STATUS_NORMAL) { + plugin_open(name); + g_free(name); + } + g_io_channel_unref(io); + } +}