From 68c910b194dc9e2756820b86f8cfed38daae27ee Mon Sep 17 00:00:00 2001 From: Scott Moynes Date: Wed, 23 Jul 2003 02:01:56 +0000 Subject: [PATCH] Added include_menu.c as an example of how one could write a plugin. --- Makefile.am | 18 ++++++++++- plugins/menu/include_menu.c | 64 +++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 plugins/menu/include_menu.c diff --git a/Makefile.am b/Makefile.am index 05925504..341518c3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 index 00000000..b4f38322 --- /dev/null +++ b/plugins/menu/include_menu.c @@ -0,0 +1,64 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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); +} -- 2.45.2