]> Dogcows Code - chaz/openbox/commitdiff
Added include_menu.c as an example of how one could write a plugin.
authorScott Moynes <smoynes@nexus.carleton.ca>
Wed, 23 Jul 2003 02:01:56 +0000 (02:01 +0000)
committerScott Moynes <smoynes@nexus.carleton.ca>
Wed, 23 Jul 2003 02:01:56 +0000 (02:01 +0000)
Makefile.am
plugins/menu/include_menu.c [new file with mode: 0644]

index 059255046de67d193cc89e6b1ec5832f069a5cc0..341518c3423183b23f1951fdd42559c1e28c4802 100644 (file)
@@ -30,7 +30,8 @@ plugin_LTLIBRARIES = \
        plugins/keyboard/keyboard.la \
        plugins/menu/timed_menu.la \
        plugins/menu/fifo_menu.la \
-       plugins/menu/client_menu.la
+       plugins/menu/client_menu.la \
+       plugins/menu/include_menu.la
 
 if OBCONF
 plugin_LTLIBRARIES += \
@@ -312,6 +313,21 @@ plugins_menu_client_menu_la_SOURCES = \
        plugins/menu/client_menu.c \
        plugins/menu/client_menu.h
 
+plugins_menu_include_menu_la_CPPFLAGS = \
+       $(XFT_CFLAGS) \
+       $(GLIB_CFLAGS) \
+       $(LIBSN_CFLAGS) \
+       $(XML_CFLAGS) \
+       -DPLUGINDIR=\"$(plugindir)\" \
+       -DG_LOG_DOMAIN=\"Plugin-Include-Menu\"
+plugins_menu_include_menu_la_LDFLAGS = \
+       -module \
+       -avoid-version
+plugins_menu_include_menu_la_SOURCES = \
+       plugins/menu/include_menu.c \
+       plugins/menu/include_menu.h
+
+
 ## themes ##
 
 dist_theme_DATA = \
diff --git a/plugins/menu/include_menu.c b/plugins/menu/include_menu.c
new file mode 100644 (file)
index 0000000..b4f3832
--- /dev/null
@@ -0,0 +1,64 @@
+#include <glib.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+#include "kernel/menu.h"
+#include "kernel/timer.h"
+#include "kernel/action.h"
+#include "kernel/event.h"
+
+static char *PLUGIN_NAME = "include_menu";
+
+void plugin_setup_config() { }
+void plugin_startup()
+{ }
+void plugin_shutdown() { }
+
+void include_menu_clean_up(ObMenu *m) { }
+
+void *plugin_create(PluginMenuCreateData *data)
+{
+    char *id;
+    char *label;
+    char *filename;
+    ObMenu *m;
+    
+    parse_attr_string("id", data->node, &id);
+    parse_attr_string("label", data->node, &label);
+    
+    m = menu_new( (label != NULL ? label : ""),
+                  (id != NULL ? id : PLUGIN_NAME),
+                  data->parent);
+
+    m->plugin = PLUGIN_NAME;
+
+    parse_attr_string("filename", data->node, &filename);
+
+    xmlDocPtr doc = xmlParseFile(filename);
+    if (doc) {
+        xmlNodePtr node = xmlDocGetRootElement(doc);
+        if (node) {
+            parse_menu_full(doc, node, m, FALSE);
+        }
+        xmlFreeDoc(doc);
+    }
+
+    if (data->parent)
+        menu_add_entry(data->parent, menu_entry_new_submenu(
+                           (label != NULL ? label : ""),
+                           m));
+
+    return (void *)m;
+}
+
+void plugin_destroy (void *m)
+{
+    include_menu_clean_up(m);
+}
This page took 0.028566 seconds and 4 git commands to generate.