summaryrefslogtreecommitdiff
path: root/openbox/config.c
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2008-02-29 23:16:31 -0500
committerDana Jansens <danakj@orodu.net>2008-02-29 23:37:57 -0500
commitdb781556d63d1a50bd1b1b4b6b5423ef703bf2c7 (patch)
tree8418803f72b28ce910d6e11f59237aa8a1b4089f /openbox/config.c
parent173b9b764887929b7ff5d30b3e33f0602b0afda6 (diff)
Add a hook system. They hooks don't run yet but they parse from the config file.
Diffstat (limited to 'openbox/config.c')
-rw-r--r--openbox/config.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/openbox/config.c b/openbox/config.c
index 109b2150..cc86ce7c 100644
--- a/openbox/config.c
+++ b/openbox/config.c
@@ -22,6 +22,7 @@
#include "mouse.h"
#include "actions.h"
#include "translate.h"
+#include "hooks.h"
#include "client.h"
#include "screen.h"
#include "openbox.h"
@@ -342,6 +343,47 @@ static void parse_per_app_settings(xmlNodePtr node, gpointer d)
}
}
+static void parse_hook(xmlNodePtr node, gpointer d)
+{
+ gchar *name;
+ ObHook hook;
+ xmlNodePtr n;
+
+
+ if (!obt_parse_attr_string(node, "name", &name)) {
+ g_message(_("Hook in config file is missing a name"));
+ return;
+ }
+
+ hook = hooks_hook_from_name(name);
+ if (!hook)
+ g_message(_("Unknown hook \"%s\" in config file"), name);
+ else {
+ if ((n = obt_parse_find_node(node->children, "action")))
+ while (n) {
+ ObActionsAct *action;
+
+ action = actions_parse(n);
+ if (action)
+ hooks_add(hook, action);
+ n = obt_parse_find_node(n->next, "action");
+ }
+ }
+
+ g_free(name);
+}
+
+static void parse_hooks(xmlNodePtr node, gpointer d)
+{
+ xmlNodePtr n;
+
+ if ((n = obt_parse_find_node(node->children, "hook")))
+ while (n) {
+ parse_hook(n, NULL);
+ n = obt_parse_find_node(n->next, "hook");
+ }
+}
+
/*
<keybind key="C-x">
@@ -987,6 +1029,8 @@ void config_startup(ObtParseInst *i)
obt_parse_register(i, "menu", parse_menu, NULL);
+ obt_parse_register(i, "hooks", parse_hooks, NULL);
+
config_per_app_settings = NULL;
obt_parse_register(i, "applications", parse_per_app_settings, NULL);