Added include_menu.c as an example of how one could write a plugin.

This commit is contained in:
Scott Moynes 2003-07-23 02:01:56 +00:00
parent 0e69ae2b96
commit 68c910b194
2 changed files with 81 additions and 1 deletions

View 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 = \

View file

@ -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);
}