]> Dogcows Code - chaz/openbox/blobdiff - openbox/plugin.c
change the menu plugin interface, no need for the create/destroy functions any more.
[chaz/openbox] / openbox / plugin.c
index e95d03e9444a4100ce8f64552766e9352ef4cb3f..b8d9be4beb4cb9f983fefd3e8af346e840b2c592 100644 (file)
@@ -1,4 +1,5 @@
 #include "plugins/interface.h"
+#include "parser/parse.h"
 
 #include <glib.h>
 #include <gmodule.h>
@@ -10,8 +11,6 @@ typedef struct {
     PluginSetupConfig config;
     PluginStartup startup;
     PluginShutdown shutdown;
-    PluginCreate create;
-    PluginDestroy destroy;
 } Plugin;
 
 static gpointer load_sym(GModule *module, char *name, char *symbol,
@@ -57,9 +56,6 @@ static Plugin *plugin_new(char *name)
                                         FALSE);
     p->shutdown = (PluginShutdown)load_sym(p->module, name, "plugin_shutdown",
                                           FALSE);
-    p->create = (PluginCreate)load_sym(p->module, name, "plugin_create", TRUE);
-    p->destroy = (PluginDestroy)load_sym(p->module, name, "plugin_destroy",
-                                        TRUE);
 
     if (p->config == NULL || p->startup == NULL || p->shutdown == NULL) {
         g_module_close(p->module);
@@ -92,7 +88,7 @@ void plugin_shutdown()
     g_datalist_clear(&plugins);
 }
 
-gboolean plugin_open_full(char *name, gboolean reopen)
+gboolean plugin_open_full(char *name, gboolean reopen, ObParseInst *i)
 {
     Plugin *p;
 
@@ -107,18 +103,18 @@ gboolean plugin_open_full(char *name, gboolean reopen)
         g_warning("failed to load plugin '%s'", name);
         return FALSE;
     }
-    p->config();
+    p->config(i);
 
     g_datalist_set_data_full(&plugins, name, p, (GDestroyNotify) plugin_free);
     return TRUE;
 }
 
-gboolean plugin_open(char *name) {
-    return plugin_open_full(name, FALSE);
+gboolean plugin_open(char *name, ObParseInst *i) {
+    return plugin_open_full(name, FALSE, i);
 }
 
-gboolean plugin_open_reopen(char *name) {
-    return plugin_open_full(name, TRUE);
+gboolean plugin_open_reopen(char *name, ObParseInst *i) {
+    return plugin_open_full(name, TRUE, i);
 }
 
 void plugin_close(char *name)
@@ -136,7 +132,7 @@ void plugin_startall()
     g_datalist_foreach(&plugins, (GDataForeachFunc)foreach_start, NULL);
 }
 
-void plugin_loadall()
+void plugin_loadall(ObParseInst *i)
 {
     GIOChannel *io;
     GError *err;
@@ -156,58 +152,20 @@ void plugin_loadall()
 
     if (io == NULL) {
         /* load the default plugins */
-        plugin_open("placement");
-        plugin_open("resistance");
+        plugin_open("placement", i);
 
         /* XXX rm me when the parser loads me magically */
-        plugin_open("client_menu");
+        plugin_open("client_menu", i);
+        plugin_open("client_list_menu", i);
     } else {
         /* 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);
             if (name[0] != '\0' && name[0] != '#')
-                plugin_open(name);
+                plugin_open(name, i);
             g_free(name);
         }
         g_io_channel_unref(io);
     }
 }
-
-void *plugin_create(char *name, void *data)
-{
-    Plugin *p = (Plugin *)g_datalist_get_data(&plugins, name);
-
-    if (p == NULL) {
-       g_warning("Unable to find plugin for create: %s", name);
-       return NULL;
-    }
-
-    if (p->create == NULL || p->destroy == NULL) {
-       g_critical("Unsupported create/destroy: %s", name);
-       return NULL;
-    }
-
-    return p->create(data);
-}
-
-void plugin_destroy(char *name, void *data)
-{
-    Plugin *p = (Plugin *)g_datalist_get_data(&plugins, name);
-
-    if (p == NULL) {
-       g_critical("Unable to find plugin for destroy: %s", name);
-       /* really shouldn't happen, but attempt to free something anyway? */
-       g_free(data);
-       return;
-    }
-
-    if (p->destroy == NULL || p->create == NULL) {
-       g_critical("Unsupported create/destroy: %s", name);
-       /* really, really shouldn't happen, but attempt to free anyway? */
-       g_free(data);
-       return;
-    }
-
-    p->destroy(data);
-}
This page took 0.022967 seconds and 4 git commands to generate.