there is also some random bug fixes for other libobt stuff in here.
render/rendertest
lib_LTLIBRARIES = \
- parser/libobparser.la \
render/libobrender.la \
obt/libobt.la
$(GLIB_CFLAGS) \
-DG_LOG_DOMAIN=\"RenderTest\"
render_rendertest_LDADD = \
- parser/libobparser.la \
+ obt/libobt.la \
render/libobrender.la \
$(GLIB_LIBS) \
$(PANGO_LIBS) \
render_libobrender_la_LDFLAGS = \
-version-info $(RR_CURRENT):$(RR_REVISION):$(RR_AGE)
render_libobrender_la_LIBADD = \
- parser/libobparser.la \
+ obt/libobt.la \
$(X_LIBS) \
$(PANGO_LIBS) \
$(XFT_LIBS) \
render/theme.h \
render/theme.c
-## parser ##
-
-parser_libobparser_la_CPPFLAGS = \
- $(GLIB_CFLAGS) \
- $(XML_CFLAGS) \
- -DG_LOG_DOMAIN=\"ObParser\" \
- -DLOCALEDIR=\"$(localedir)\" \
- -DDATADIR=\"$(datadir)\" \
- -DCONFIGDIR=\"$(configdir)\"
-parser_libobparser_la_LDFLAGS = \
- -version-info $(RR_CURRENT):$(RR_REVISION):$(RR_AGE)
-parser_libobparser_la_LIBADD = \
- $(GLIB_LIBS) \
- $(XML_LIBS)
-parser_libobparser_la_SOURCES = \
- parser/parse.h \
- parser/parse.c
-
## obt ##
obt_libobt_la_CPPFLAGS = \
$(EFENCE_LIBS) \
$(LIBINTL) \
render/libobrender.la \
- parser/libobparser.la \
obt/libobt.la
openbox_openbox_LDFLAGS = -export-dynamic
openbox_openbox_SOURCES = \
render/mask.h \
render/render.h \
render/theme.h \
- parser/parse.h \
obt/display.h \
+ obt/display.c \
+ obt/keyboard.h \
+ obt/keyboard.c \
obt/mainloop.h \
+ obt/mainloop.c \
+ obt/parse.h \
+ obt/parse.c \
+ obt/prop.h \
+ obt/prop.c \
obt/util.h
nodist_pubinclude_HEADERS = \
nodist_pkgconfig_DATA = \
render/obrender-4.0.pc \
- parser/obparser-4.0.pc \
obt/obt-4.0.pc
## data ##
doc/openbox-kde-session.1.sgml \
doc/openbox-kde-session.1.in \
render/obrender-4.0.pc.in \
- parser/obparser-4.0.pc.in \
obt/obt-4.0.pc.in \
tools/themeupdate/themeupdate.py \
tests/hideshow.py \
m4/Makefile
po/Makefile.in
render/obrender-4.0.pc
- parser/obparser-4.0.pc
obt/obt-4.0.pc
version.h
])
g_free(c);
}
-ObtParseInst* obt_parse_instance_new()
+ObtParseInst* obt_parse_instance_new(void)
{
ObtParseInst *i = g_new(ObtParseInst, 1);
i->ref = 1;
}
}
-void parse_register(ObtParseInst *i, const gchar *tag,
- ObtParseCallback func, gpointer data)
+xmlDocPtr obt_parse_instance_doc(ObtParseInst *i)
+{
+ g_assert(i->doc); /* a doc is open? */
+ return i->doc;
+}
+
+xmlNodePtr obt_parse_instance_root(ObtParseInst *i)
+{
+ g_assert(i->doc); /* a doc is open? */
+ return i->root;
+}
+
+void obt_parse_register(ObtParseInst *i, const gchar *tag,
+ ObtParseCallback func, gpointer data)
{
struct Callback *c;
gchar *path;
struct stat s;
- path = g_build_filename(it->data, domain, filename, NULL);
+ if (!domain && !filename) /* given a full path to the file */
+ path = g_strdup(it->data);
+ else
+ path = g_build_filename(it->data, domain, filename, NULL);
if (stat(path, &s) >= 0) {
/* XML_PARSE_BLANKS is needed apparently, or the tree can end up
return r;
}
+gboolean obt_parse_load_file(ObtParseInst *i,
+ const gchar *path,
+ const gchar *root_node)
+{
+ GSList *paths;
+ gboolean r;
+
+ paths = g_slist_append(NULL, g_strdup(path));
+
+ r = load_file(i, NULL, NULL, root_node, paths);
+
+ while (paths) {
+ g_free(paths->data);
+ paths = g_slist_delete_link(paths, paths);
+ }
+ return r;
+}
+
gboolean obt_parse_load_config_file(ObtParseInst *i,
const gchar *domain,
const gchar *filename,
while (node) {
struct Callback *c = g_hash_table_lookup(i->callbacks, node->name);
- if (c) c->func(i, i->doc, node, c->data);
+ if (c) c->func(node, c->data);
node = node->next;
}
}
return list;
}
-void parse_paths_startup()
+void parse_paths_startup(void)
{
const gchar *path;
(GSListFunc) g_slist_prepend);
}
-void parse_paths_shutdown()
+void parse_paths_shutdown(void)
{
GSList *it;
return ret;
}
-const gchar* parse_xdg_config_home_path()
+const gchar* parse_xdg_config_home_path(void)
{
return xdg_config_home_path;
}
-const gchar* parse_xdg_data_home_path()
+const gchar* parse_xdg_data_home_path(void)
{
return xdg_data_home_path;
}
-GSList* parse_xdg_config_dir_paths()
+GSList* parse_xdg_config_dir_paths(void)
{
return xdg_config_dir_paths;
}
-GSList* parse_xdg_data_dir_paths()
+GSList* parse_xdg_data_dir_paths(void)
{
return xdg_data_dir_paths;
}
typedef struct _ObtParseInst ObtParseInst;
-typedef void (*ObtParseCallback)(ObtParseInst *i, xmlDocPtr doc,
- xmlNodePtr node, gpointer data);
+typedef void (*ObtParseCallback)(xmlNodePtr node, gpointer data);
ObtParseInst* obt_parse_instance_new();
void obt_parse_instance_ref(ObtParseInst *inst);
void obt_parse_instance_unref(ObtParseInst *inst);
+gboolean obt_parse_load_file(ObtParseInst *inst,
+ const gchar *path,
+ const gchar *root_node);
gboolean obt_parse_load_config_file(ObtParseInst *inst,
const gchar *domain,
const gchar *filename,
gboolean obt_parse_load_mem(ObtParseInst *inst,
gpointer data, guint len, const gchar *root_node);
+xmlDocPtr obt_parse_instance_doc(ObtParseInst *inst);
+xmlNodePtr obt_parse_instance_root(ObtParseInst *inst);
+
void obt_parse_close(ObtParseInst *inst);
void obt_parse_register(ObtParseInst *inst, const gchar *tag,
/* helpers */
-xmlNodePtr obt_parse_find_node(xmlNodePtr node, const gchar *tag);
+xmlNodePtr obt_parse_find_node(xmlNodePtr node, const gchar *name);
gboolean obt_parse_node_contains (xmlNodePtr node, const gchar *val);
gchar *obt_parse_node_string (xmlNodePtr node);
void obt_prop_set_string_locale(Window win, Atom prop, const gchar *val)
{
- const gchar *s[2] = { val, NULL };
+ gchar const *s[2] = { val, NULL };
obt_prop_set_strings_locale(win, prop, s);
}
-void obt_prop_set_strings_locale(Window win, Atom prop,
- const gchar **strs)
+void obt_prop_set_strings_locale(Window win, Atom prop, gchar const **strs)
{
gint i, count;
gchar **lstrs;
PropModeReplace, (const guchar*)val, strlen(val));
}
-void obt_prop_set_strings_utf8(Window win, Atom prop, const gchar **strs)
+void obt_prop_set_strings_utf8(Window win, Atom prop, gchar const **strs)
{
GString *str;
- const gchar **s;
+ gchar const **s;
str = g_string_sized_new(0);
for (s = strs; *s; ++s) {
guint num);
void obt_prop_set_string_locale(Window win, Atom prop, const gchar *val);
void obt_prop_set_string_utf8(Window win, Atom prop, const gchar *val);
-void obt_prop_set_strings_locale(Window win, Atom prop,
- const gchar **strs);
-void obt_prop_set_strings_utf8(Window win, Atom prop,
- const gchar **strs);
+void obt_prop_set_strings_locale(Window win, Atom prop, gchar const **strs);
+void obt_prop_set_strings_utf8(Window win, Atom prop, gchar const **strs);
void obt_prop_erase(Window win, Atom prop);
if ((act = actions_build_act_from_string(name)))
if (act->def->setup)
- act->options = act->def->setup(NULL, NULL, NULL);
+ act->options = act->def->setup(NULL);
return act;
}
-ObActionsAct* actions_parse(ObParseInst *i,
- xmlDocPtr doc,
- xmlNodePtr node)
+ObActionsAct* actions_parse(xmlNodePtr node)
{
gchar *name;
ObActionsAct *act = NULL;
- if (parse_attr_string("name", node, &name)) {
+ if (obt_parse_attr_string(node, "name", &name)) {
if ((act = actions_build_act_from_string(name)))
/* there is more stuff to parse here */
if (act->def->setup)
- act->options = act->def->setup(i, doc, node->xmlChildrenNode);
+ act->options = act->def->setup(node->xmlChildrenNode);
g_free(name);
}
#include "misc.h"
#include "frame.h"
-#include "parser/parse.h"
+#include "obt/parse.h"
+
#include <glib.h>
#include <X11/Xlib.h>
typedef struct _ObActionsClientData ObActionsClientData;
typedef struct _ObActionsSelectorData ObActionsSelectorData;
-typedef gpointer (*ObActionsDataSetupFunc)(ObParseInst *i,
- xmlDocPtr doc, xmlNodePtr node);
+typedef gpointer (*ObActionsDataSetupFunc)(xmlNodePtr node);
typedef void (*ObActionsDataFreeFunc)(gpointer options);
typedef gboolean (*ObActionsRunFunc)(ObActionsData *data,
gpointer options);
ObActionsInteractiveInputFunc i_input,
ObActionsInteractiveCancelFunc i_cancel);
-ObActionsAct* actions_parse(ObParseInst *i,
- xmlDocPtr doc,
- xmlNodePtr node);
+ObActionsAct* actions_parse(xmlNodePtr node);
ObActionsAct* actions_parse_string(const gchar *name);
gboolean actions_act_is_interactive(ObActionsAct *act);
gboolean add;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static gpointer setup_add_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static gpointer setup_remove_func(ObParseInst *i,
- xmlDocPtr doc, xmlNodePtr node);
-static void free_func(gpointer options);
+static gpointer setup_func(xmlNodePtr node);
+static gpointer setup_add_func(xmlNodePtr node);
+static gpointer setup_remove_func(xmlNodePtr node);
static gboolean run_func(ObActionsData *data, gpointer options);
void action_addremovedesktop_startup(void)
{
- actions_register("AddDesktop",
- setup_add_func,
- free_func,
- run_func,
+ actions_register("AddDesktop", setup_add_func, g_free, run_func,
NULL, NULL);
- actions_register("RemoveDesktop",
- setup_remove_func,
- free_func,
- run_func,
+ actions_register("RemoveDesktop", setup_remove_func, g_free, run_func,
NULL, NULL);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
- if ((n = parse_find_node("where", node))) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_parse_find_node(node, "where"))) {
+ gchar *s = obt_parse_node_string(n);
if (!g_ascii_strcasecmp(s, "last"))
o->current = FALSE;
else if (!g_ascii_strcasecmp(s, "current"))
return o;
}
-static gpointer setup_add_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_add_func(xmlNodePtr node)
{
- Options *o = setup_func(i, doc, node);
+ Options *o = setup_func(node);
o->add = TRUE;
return o;
}
-static gpointer setup_remove_func(ObParseInst *i,
- xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_remove_func(xmlNodePtr node)
{
- Options *o = setup_func(i, doc, node);
+ Options *o = setup_func(node);
o->add = FALSE;
return o;
}
-static void free_func(gpointer options)
-{
- Options *o = options;
-
- g_free(o);
-}
-
/* Always return FALSE because its not interactive */
static gboolean run_func(ObActionsData *data, gpointer options)
{
static gboolean cycling = FALSE;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static gpointer setup_forward_func(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node);
-static gpointer setup_backward_func(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node);
+static gpointer setup_func(xmlNodePtr node);
+static gpointer setup_forward_func(xmlNodePtr node);
+static gpointer setup_backward_func(xmlNodePtr node);
static void free_func(gpointer options);
static gboolean run_func(ObActionsData *data, gpointer options);
static gboolean i_input_func(guint initial_state,
run_func, i_input_func, i_cancel_func);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o->dialog = TRUE;
o->bar = TRUE;
- if ((n = parse_find_node("linear", node)))
- o->linear = parse_bool(doc, n);
- if ((n = parse_find_node("dialog", node)))
- o->dialog = parse_bool(doc, n);
- if ((n = parse_find_node("bar", node)))
- o->bar = parse_bool(doc, n);
- if ((n = parse_find_node("raise", node)))
- o->raise = parse_bool(doc, n);
- if ((n = parse_find_node("panels", node)))
- o->dock_windows = parse_bool(doc, n);
- if ((n = parse_find_node("desktop", node)))
- o->desktop_windows = parse_bool(doc, n);
- if ((n = parse_find_node("allDesktops", node)))
- o->all_desktops = parse_bool(doc, n);
-
- if ((n = parse_find_node("finalactions", node))) {
+ if ((n = obt_parse_find_node(node, "linear")))
+ o->linear = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "dialog")))
+ o->dialog = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "bar")))
+ o->bar = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "raise")))
+ o->raise = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "panels")))
+ o->dock_windows = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "desktop")))
+ o->desktop_windows = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "allDesktops")))
+ o->all_desktops = obt_parse_node_bool(n);
+
+ if ((n = obt_parse_find_node(node, "finalactions"))) {
xmlNodePtr m;
- m = parse_find_node("action", n->xmlChildrenNode);
+ m = obt_parse_find_node(n->xmlChildrenNode, "action");
while (m) {
- ObActionsAct *action = actions_parse(i, doc, m);
+ ObActionsAct *action = actions_parse(m);
if (action) o->actions = g_slist_prepend(o->actions, action);
- m = parse_find_node("action", m->next);
+ m = obt_parse_find_node(m->next, "action");
}
}
else {
return o;
}
-static gpointer setup_forward_func(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node)
+static gpointer setup_forward_func(xmlNodePtr node)
{
- Options *o = setup_func(i, doc, node);
+ Options *o = setup_func(node);
o->forward = TRUE;
return o;
}
-static gpointer setup_backward_func(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node)
+static gpointer setup_backward_func(xmlNodePtr node)
{
- Options *o = setup_func(i, doc, node);
+ Options *o = setup_func(node);
o->forward = FALSE;
return o;
}
gchar *str;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
+static gpointer setup_func(xmlNodePtr node);
static void free_func(gpointer options);
static gboolean run_func(ObActionsData *data, gpointer options);
void action_debug_startup(void)
{
- actions_register("Debug",
- setup_func,
- free_func,
- run_func,
- NULL, NULL);
+ actions_register("Debug", setup_func, free_func, run_func, NULL, NULL);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
- if ((n = parse_find_node("string", node)))
- o->str = parse_string(doc, n);
+ if ((n = obt_parse_find_node(node, "string")))
+ o->str = obt_parse_node_string(n);
return o;
}
static void free_func(gpointer options)
{
Options *o = options;
-
- if (o) {
- g_free(o->str);
- g_free(o);
- }
+ g_free(o->str);
+ g_free(o);
}
/* Always return FALSE because its not interactive */
gboolean follow;
} Options;
-static gpointer setup_go_func(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node);
-static gpointer setup_send_func(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node);
+static gpointer setup_go_func(xmlNodePtr node);
+static gpointer setup_send_func(xmlNodePtr node);
static gboolean run_func(ObActionsData *data, gpointer options);
void action_desktop_startup(void)
NULL, NULL);
}
-static gpointer setup_go_func(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node)
+static gpointer setup_go_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
/* wrap by default - it's handy! */
o->rel.wrap = TRUE;
- if ((n = parse_find_node("to", node))) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_parse_find_node(node, "to"))) {
+ gchar *s = obt_parse_node_string(n);
if (!g_ascii_strcasecmp(s, "last"))
o->type = LAST;
else if (!g_ascii_strcasecmp(s, "next")) {
}
else {
o->type = ABSOLUTE;
- o->abs.desktop = parse_int(doc, n) - 1;
+ o->abs.desktop = obt_parse_node_int(n) - 1;
}
g_free(s);
}
- if ((n = parse_find_node("wrap", node)))
- o->rel.wrap = parse_bool(doc, n);
+ if ((n = obt_parse_find_node(node, "wrap")))
+ o->rel.wrap = obt_parse_node_bool(n);
return o;
}
-static gpointer setup_send_func(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node)
+static gpointer setup_send_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
- o = setup_go_func(i, doc, node);
+ o = setup_go_func(node);
o->send = TRUE;
o->follow = TRUE;
- if ((n = parse_find_node("follow", node)))
- o->follow = parse_bool(doc, n);
+ if ((n = obt_parse_find_node(node, "follow")))
+ o->follow = obt_parse_node_bool(n);
return o;
}
static gboolean cycling = FALSE;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static gpointer setup_cycle_func(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node);
-static gpointer setup_target_func(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node);
+static gpointer setup_func(xmlNodePtr node);
+static gpointer setup_cycle_func(xmlNodePtr node);
+static gpointer setup_target_func(xmlNodePtr node);
static void free_func(gpointer options);
static gboolean run_func(ObActionsData *data, gpointer options);
static gboolean i_input_func(guint initial_state,
run_func, NULL, NULL);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o->dialog = TRUE;
o->bar = TRUE;
- if ((n = parse_find_node("dialog", node)))
- o->dialog = parse_bool(doc, n);
- if ((n = parse_find_node("bar", node)))
- o->bar = parse_bool(doc, n);
- if ((n = parse_find_node("raise", node)))
- o->raise = parse_bool(doc, n);
- if ((n = parse_find_node("panels", node)))
- o->dock_windows = parse_bool(doc, n);
- if ((n = parse_find_node("desktop", node)))
- o->desktop_windows = parse_bool(doc, n);
- if ((n = parse_find_node("direction", node))) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_parse_find_node(node, "dialog")))
+ o->dialog = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "bar")))
+ o->bar = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "raise")))
+ o->raise = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "panels")))
+ o->dock_windows = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "desktop")))
+ o->desktop_windows = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "direction"))) {
+ gchar *s = obt_parse_node_string(n);
if (!g_ascii_strcasecmp(s, "north") ||
!g_ascii_strcasecmp(s, "up"))
o->direction = OB_DIRECTION_NORTH;
g_free(s);
}
- if ((n = parse_find_node("finalactions", node))) {
+ if ((n = obt_parse_find_node(node, "finalactions"))) {
xmlNodePtr m;
- m = parse_find_node("action", n->xmlChildrenNode);
+ m = obt_parse_find_node(n->xmlChildrenNode, "action");
while (m) {
- ObActionsAct *action = actions_parse(i, doc, m);
+ ObActionsAct *action = actions_parse(m);
if (action) o->actions = g_slist_prepend(o->actions, action);
- m = parse_find_node("action", m->next);
+ m = obt_parse_find_node(m->next, "action");
}
}
else {
return o;
}
-static gpointer setup_cycle_func(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node)
+static gpointer setup_cycle_func(xmlNodePtr node)
{
- Options *o = setup_func(i, doc, node);
+ Options *o = setup_func(node);
o->interactive = TRUE;
return o;
}
-static gpointer setup_target_func(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node)
+static gpointer setup_target_func(xmlNodePtr node)
{
- Options *o = setup_func(i, doc, node);
+ Options *o = setup_func(node);
o->interactive = FALSE;
return o;
}
gchar *sn_wmclass;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
+static gpointer setup_func(xmlNodePtr node);
static void free_func(gpointer options);
static gboolean run_func(ObActionsData *data, gpointer options);
/*
void action_execute_startup(void)
{
- actions_register("Execute",
- setup_func,
- free_func,
- run_func,
- NULL, NULL);
+ actions_register("Execute", setup_func, free_func, run_func, NULL, NULL);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
- if ((n = parse_find_node("command", node)) ||
- (n = parse_find_node("execute", node)))
+ if ((n = obt_parse_find_node(node, "command")) ||
+ (n = obt_parse_find_node(node, "execute")))
{
- gchar *s = parse_string(doc, n);
+ gchar *s = obt_parse_node_string(n);
o->cmd = parse_expand_tilde(s);
g_free(s);
}
- if ((n = parse_find_node("startupnotify", node))) {
+ if ((n = obt_parse_find_node(node, "startupnotify"))) {
xmlNodePtr m;
- if ((m = parse_find_node("enabled", n->xmlChildrenNode)))
- o->sn = parse_bool(doc, m);
- if ((m = parse_find_node("name", n->xmlChildrenNode)))
- o->sn_name = parse_string(doc, m);
- if ((m = parse_find_node("icon", n->xmlChildrenNode)))
- o->sn_icon = parse_string(doc, m);
- if ((m = parse_find_node("wmclass", n->xmlChildrenNode)))
- o->sn_wmclass = parse_string(doc, m);
+ if ((m = obt_parse_find_node(n->xmlChildrenNode, "enabled")))
+ o->sn = obt_parse_node_bool(m);
+ if ((m = obt_parse_find_node(n->xmlChildrenNode, "name")))
+ o->sn_name = obt_parse_node_string(m);
+ if ((m = obt_parse_find_node(n->xmlChildrenNode, "icon")))
+ o->sn_icon = obt_parse_node_string(m);
+ if ((m = obt_parse_find_node(n->xmlChildrenNode, "wmclass")))
+ o->sn_wmclass = obt_parse_node_string(m);
}
return o;
}
gboolean here;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static void free_func(gpointer options);
+static gpointer setup_func(xmlNodePtr node);
static gboolean run_func(ObActionsData *data, gpointer options);
void action_focus_startup(void)
{
- actions_register("Focus",
- setup_func,
- free_func,
- run_func,
- NULL, NULL);
+ actions_register("Focus", setup_func, g_free, run_func, NULL, NULL);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
- if ((n = parse_find_node("here", node)))
- o->here = parse_bool(doc, n);
+ if ((n = obt_parse_find_node(node, "here")))
+ o->here = obt_parse_node_bool(n);
return o;
}
-static void free_func(gpointer options)
-{
- Options *o = options;
-
- g_free(o);
-}
-
/* Always return FALSE because its not interactive */
static gboolean run_func(ObActionsData *data, gpointer options)
{
gboolean shrink;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static gpointer setup_shrink_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static void free_func(gpointer options);
+static gpointer setup_func(xmlNodePtr node);
+static gpointer setup_shrink_func(xmlNodePtr node);
static gboolean run_func(ObActionsData *data, gpointer options);
void action_growtoedge_startup(void)
{
- actions_register("GrowToEdge",
- setup_func,
- free_func,
- run_func,
- NULL, NULL);
-
- actions_register("ShrinkToEdge",
- setup_shrink_func,
- free_func,
- run_func,
- NULL, NULL);
+ actions_register("GrowToEdge", setup_func,
+ g_free, run_func, NULL, NULL);
+ actions_register("ShrinkToEdge", setup_shrink_func,
+ g_free, run_func, NULL, NULL);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o->dir = OB_DIRECTION_NORTH;
o->shrink = FALSE;
- if ((n = parse_find_node("direction", node))) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_parse_find_node(node, "direction"))) {
+ gchar *s = obt_parse_node_string(n);
if (!g_ascii_strcasecmp(s, "north") ||
!g_ascii_strcasecmp(s, "up"))
o->dir = OB_DIRECTION_NORTH;
return o;
}
-static gpointer setup_shrink_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_shrink_func(xmlNodePtr node)
{
Options *o;
- o = setup_func(i, doc, node);
+ o = setup_func(node);
o->shrink = TRUE;
return o;
}
-static void free_func(gpointer options)
-{
- Options *o = options;
-
- g_free(o);
-}
-
static gboolean do_grow(ObActionsData *data, gint x, gint y, gint w, gint h)
{
gint realw, realh, lw, lh;
GSList *elseacts;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
+static gpointer setup_func(xmlNodePtr node);
static void free_func(gpointer options);
static gboolean run_func(ObActionsData *data, gpointer options);
void action_if_startup(void)
{
- actions_register("If",
- setup_func,
- free_func,
- run_func,
- NULL, NULL);
+ actions_register("If", setup_func, free_func, run_func, NULL, NULL);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
- if ((n = parse_find_node("shaded", node))) {
- if (parse_bool(doc, n))
+ if ((n = obt_parse_find_node(node, "shaded"))) {
+ if (obt_parse_node_bool(n))
o->shaded_on = TRUE;
else
o->shaded_off = TRUE;
}
- if ((n = parse_find_node("maximized", node))) {
- if (parse_bool(doc, n))
+ if ((n = obt_parse_find_node(node, "maximized"))) {
+ if (obt_parse_node_bool(n))
o->maxfull_on = TRUE;
else
o->maxfull_off = TRUE;
}
- if ((n = parse_find_node("maximizedhorizontal", node))) {
- if (parse_bool(doc, n))
+ if ((n = obt_parse_find_node(node, "maximizedhorizontal"))) {
+ if (obt_parse_node_bool(n))
o->maxhorz_on = TRUE;
else
o->maxhorz_off = TRUE;
}
- if ((n = parse_find_node("maximizedvertical", node))) {
- if (parse_bool(doc, n))
+ if ((n = obt_parse_find_node(node, "maximizedvertical"))) {
+ if (obt_parse_node_bool(n))
o->maxvert_on = TRUE;
else
o->maxvert_off = TRUE;
}
- if ((n = parse_find_node("iconified", node))) {
- if (parse_bool(doc, n))
+ if ((n = obt_parse_find_node(node, "iconified"))) {
+ if (obt_parse_node_bool(n))
o->iconic_on = TRUE;
else
o->iconic_off = TRUE;
}
- if ((n = parse_find_node("focused", node))) {
- if (parse_bool(doc, n))
+ if ((n = obt_parse_find_node(node, "focused"))) {
+ if (obt_parse_node_bool(n))
o->focused = TRUE;
else
o->unfocused = TRUE;
}
- if ((n = parse_find_node("then", node))) {
+ if ((n = obt_parse_find_node(node, "then"))) {
xmlNodePtr m;
- m = parse_find_node("action", n->xmlChildrenNode);
+ m = obt_parse_find_node(n->xmlChildrenNode, "action");
while (m) {
- ObActionsAct *action = actions_parse(i, doc, m);
+ ObActionsAct *action = actions_parse(m);
if (action) o->thenacts = g_slist_prepend(o->thenacts, action);
- m = parse_find_node("action", m->next);
+ m = obt_parse_find_node(m->next, "action");
}
}
- if ((n = parse_find_node("else", node))) {
+ if ((n = obt_parse_find_node(node, "else"))) {
xmlNodePtr m;
- m = parse_find_node("action", n->xmlChildrenNode);
+ m = obt_parse_find_node(n->xmlChildrenNode, "action");
while (m) {
- ObActionsAct *action = actions_parse(i, doc, m);
+ ObActionsAct *action = actions_parse(m);
if (action) o->elseacts = g_slist_prepend(o->elseacts, action);
- m = parse_find_node("action", m->next);
+ m = obt_parse_find_node(m->next, "action");
}
}
{
Options *o = options;
+ while (o->thenacts) {
+ actions_act_unref(o->thenacts->data);
+ o->thenacts = g_slist_delete_link(o->thenacts, o->thenacts);
+ }
+ while (o->elseacts) {
+ actions_act_unref(o->elseacts->data);
+ o->elseacts = g_slist_delete_link(o->elseacts, o->elseacts);
+ }
+
g_free(o);
}
gboolean toggle;
} Options;
-static gpointer setup_func_top(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static gpointer setup_func_bottom(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node);
-static gpointer setup_func_send(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node);
+static gpointer setup_func_top(xmlNodePtr node);
+static gpointer setup_func_bottom(xmlNodePtr node);
+static gpointer setup_func_send(xmlNodePtr node);
static gboolean run_func(ObActionsData *data, gpointer options);
void action_layer_startup(void)
run_func, NULL, NULL);
}
-static gpointer setup_func_top(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func_top(xmlNodePtr node)
{
Options *o = g_new0(Options, 1);
o->layer = 1;
return o;
}
-static gpointer setup_func_bottom(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node)
+static gpointer setup_func_bottom(xmlNodePtr node)
{
Options *o = g_new0(Options, 1);
o->layer = -1;
return o;
}
-static gpointer setup_func_send(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node)
+static gpointer setup_func_send(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
- if ((n = parse_find_node("layer", node))) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_parse_find_node(node, "layer"))) {
+ gchar *s = obt_parse_node_string(n);
if (!g_ascii_strcasecmp(s, "above") ||
!g_ascii_strcasecmp(s, "top"))
o->layer = 1;
MaxDirection dir;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
+static gpointer setup_func(xmlNodePtr node);
static gboolean run_func_on(ObActionsData *data, gpointer options);
static gboolean run_func_off(ObActionsData *data, gpointer options);
static gboolean run_func_toggle(ObActionsData *data, gpointer options);
NULL, NULL);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
o->dir = BOTH;
- if ((n = parse_find_node("direction", node))) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_parse_find_node(node, "direction"))) {
+ gchar *s = obt_parse_node_string(n);
if (!g_ascii_strcasecmp(s, "vertical") ||
!g_ascii_strcasecmp(s, "vert"))
o->dir = VERT;
gint y;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static void free_func(gpointer options);
+static gpointer setup_func(xmlNodePtr node);
static gboolean run_func(ObActionsData *data, gpointer options);
void action_moverelative_startup(void)
{
- actions_register("MoveRelative",
- setup_func,
- free_func,
- run_func,
- NULL, NULL);
+ actions_register("MoveRelative", setup_func, g_free, run_func, NULL, NULL);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
- if ((n = parse_find_node("x", node)))
- o->x = parse_int(doc, n);
- if ((n = parse_find_node("y", node)))
- o->y = parse_int(doc, n);
+ if ((n = obt_parse_find_node(node, "x")))
+ o->x = obt_parse_node_int(n);
+ if ((n = obt_parse_find_node(node, "y")))
+ o->y = obt_parse_node_int(n);
return o;
}
-static void free_func(gpointer options)
-{
- Options *o = options;
-
- g_free(o);
-}
-
/* Always return FALSE because its not interactive */
static gboolean run_func(ObActionsData *data, gpointer options)
{
gint monitor;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static void free_func(gpointer options);
+static gpointer setup_func(xmlNodePtr node);
static gboolean run_func(ObActionsData *data, gpointer options);
void action_moveresizeto_startup(void)
{
- actions_register("MoveResizeTo",
- setup_func,
- free_func,
- run_func,
- NULL, NULL);
+ actions_register("MoveResizeTo", setup_func, g_free, run_func, NULL, NULL);
}
-static void parse_coord(xmlDocPtr doc, xmlNodePtr n, gint *pos,
+static void parse_coord(xmlNodePtr n, gint *pos,
gboolean *opposite, gboolean *center)
{
- gchar *s = parse_string(doc, n);
+ gchar *s = obt_parse_node_string(n);
if (g_ascii_strcasecmp(s, "current") != 0) {
if (!g_ascii_strcasecmp(s, "center"))
*center = TRUE;
g_free(s);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o->h = G_MININT;
o->monitor = CURRENT_MONITOR;
- if ((n = parse_find_node("x", node)))
- parse_coord(doc, n, &o->x, &o->xopposite, &o->xcenter);
+ if ((n = obt_parse_find_node(node, "x")))
+ parse_coord(n, &o->x, &o->xopposite, &o->xcenter);
- if ((n = parse_find_node("y", node)))
- parse_coord(doc, n, &o->y, &o->yopposite, &o->ycenter);
+ if ((n = obt_parse_find_node(node, "y")))
+ parse_coord(n, &o->y, &o->yopposite, &o->ycenter);
- if ((n = parse_find_node("width", node))) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_parse_find_node(node, "width"))) {
+ gchar *s = obt_parse_node_string(n);
if (g_ascii_strcasecmp(s, "current") != 0)
- o->w = parse_int(doc, n);
+ o->w = obt_parse_node_int(n);
g_free(s);
}
- if ((n = parse_find_node("height", node))) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_parse_find_node(node, "height"))) {
+ gchar *s = obt_parse_node_string(n);
if (g_ascii_strcasecmp(s, "current") != 0)
- o->h = parse_int(doc, n);
+ o->h = obt_parse_node_int(n);
g_free(s);
}
- if ((n = parse_find_node("monitor", node))) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_parse_find_node(node, "monitor"))) {
+ gchar *s = obt_parse_node_string(n);
if (g_ascii_strcasecmp(s, "current") != 0) {
if (!g_ascii_strcasecmp(s, "all"))
o->monitor = ALL_MONITORS;
else
- o->monitor = parse_int(doc, n) - 1;
+ o->monitor = obt_parse_node_int(n) - 1;
}
g_free(s);
}
return o;
}
-static void free_func(gpointer options)
-{
- Options *o = options;
-
- g_free(o);
-}
-
/* Always return FALSE because its not interactive */
static gboolean run_func(ObActionsData *data, gpointer options)
{
ObDirection dir;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static void free_func(gpointer options);
+static gpointer setup_func(xmlNodePtr node);
static gboolean run_func(ObActionsData *data, gpointer options);
void action_movetoedge_startup(void)
{
- actions_register("MoveToEdge",
- setup_func,
- free_func,
- run_func,
- NULL, NULL);
+ actions_register("MoveToEdge", setup_func, g_free, run_func, NULL, NULL);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
o->dir = OB_DIRECTION_NORTH;
- if ((n = parse_find_node("direction", node))) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_parse_find_node(node, "direction"))) {
+ gchar *s = obt_parse_node_string(n);
if (!g_ascii_strcasecmp(s, "north") ||
!g_ascii_strcasecmp(s, "up"))
o->dir = OB_DIRECTION_NORTH;
return o;
}
-static void free_func(gpointer options)
-{
- Options *o = options;
-
- g_free(o);
-}
-
/* Always return FALSE because its not interactive */
static gboolean run_func(ObActionsData *data, gpointer options)
{
guint32 corner;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static void free_func(gpointer options);
+static gpointer setup_func(xmlNodePtr node);
static gboolean run_func(ObActionsData *data, gpointer options);
static guint32 pick_corner(gint x, gint y, gint cx, gint cy, gint cw, gint ch,
void action_resize_startup(void)
{
- actions_register("Resize",
- setup_func,
- free_func,
- run_func,
- NULL, NULL);
+ actions_register("Resize", setup_func, g_free, run_func, NULL, NULL);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
- if ((n = parse_find_node("edge", node))) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_parse_find_node(node, "edge"))) {
+ gchar *s = obt_parse_node_string(n);
o->corner_specified = TRUE;
if (!g_ascii_strcasecmp(s, "top"))
return o;
}
-static void free_func(gpointer options)
-{
- Options *o = options;
-
- g_free(o);
-}
-
/* Always return FALSE because its not interactive */
static gboolean run_func(ObActionsData *data, gpointer options)
{
gint bottom;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static void free_func(gpointer options);
+static gpointer setup_func(xmlNodePtr node);
static gboolean run_func(ObActionsData *data, gpointer options);
void action_resizerelative_startup(void)
{
- actions_register("ResizeRelative",
- setup_func,
- free_func,
- run_func,
+ actions_register("ResizeRelative", setup_func, g_free, run_func,
NULL, NULL);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
- if ((n = parse_find_node("left", node)))
- o->left = parse_int(doc, n);
- if ((n = parse_find_node("right", node)))
- o->right = parse_int(doc, n);
- if ((n = parse_find_node("top", node)) ||
- (n = parse_find_node("up", node)))
- o->top = parse_int(doc, n);
- if ((n = parse_find_node("bottom", node)) ||
- (n = parse_find_node("down", node)))
- o->bottom = parse_int(doc, n);
+ if ((n = obt_parse_find_node(node, "left")))
+ o->left = obt_parse_node_int(n);
+ if ((n = obt_parse_find_node(node, "right")))
+ o->right = obt_parse_node_int(n);
+ if ((n = obt_parse_find_node(node, "top")) ||
+ (n = obt_parse_find_node(node, "up")))
+ o->top = obt_parse_node_int(n);
+ if ((n = obt_parse_find_node(node, "bottom")) ||
+ (n = obt_parse_find_node(node, "down")))
+ o->bottom = obt_parse_node_int(n);
return o;
}
-static void free_func(gpointer options)
-{
- Options *o = options;
-
- g_free(o);
-}
-
/* Always return FALSE because its not interactive */
static gboolean run_func(ObActionsData *data, gpointer options)
{
gchar *cmd;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
+static gpointer setup_func(xmlNodePtr node);
static void free_func(gpointer options);
static gboolean run_func(ObActionsData *data, gpointer options);
void action_restart_startup(void)
{
- actions_register("Restart",
- setup_func,
- free_func,
- run_func,
- NULL, NULL);
+ actions_register("Restart", setup_func, free_func, run_func, NULL, NULL);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
- if ((n = parse_find_node("command", node)) ||
- (n = parse_find_node("execute", node)))
+ if ((n = obt_parse_find_node(node, "command")) ||
+ (n = obt_parse_find_node(node, "execute")))
{
- gchar *s = parse_string(doc, n);
+ gchar *s = obt_parse_node_string(n);
o->cmd = parse_expand_tilde(s);
g_free(s);
}
static void free_func(gpointer options)
{
Options *o = options;
-
- if (o) {
- g_free(o->cmd);
- g_free(o);
- }
+ g_free(o->cmd);
+ g_free(o);
}
/* Always return FALSE because its not interactive */
gchar *name;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
+static gpointer setup_func(xmlNodePtr node);
static void free_func(gpointer options);
static gboolean run_func(ObActionsData *data, gpointer options);
NULL, NULL);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
- if ((n = parse_find_node("menu", node)))
- o->name = parse_string(doc, n);
+ if ((n = obt_parse_find_node(node, "menu")))
+ o->name = obt_parse_node_string(n);
return o;
}
#include "translate.h"
#include "client.h"
#include "screen.h"
-#include "parser/parse.h"
#include "openbox.h"
#include "gettext.h"
}
}
-static void config_parse_gravity_coord(xmlDocPtr doc, xmlNodePtr node,
- GravityCoord *c)
+static void config_parse_gravity_coord(xmlNodePtr node, GravityCoord *c)
{
- gchar *s = parse_string(doc, node);
+ gchar *s = obt_parse_node_string(node);
if (!g_ascii_strcasecmp(s, "center"))
c->center = TRUE;
else {
the monitor, so <position><x>center</x></position><monitor>2</monitor>
will center the window on the second monitor.
*/
-static void parse_per_app_settings(ObParseInst *inst, xmlDocPtr doc,
- xmlNodePtr node, gpointer data)
+static void parse_per_app_settings(xmlNodePtr node, gpointer d)
{
- xmlNodePtr app = parse_find_node("application", node->children);
+ xmlNodePtr app = obt_parse_find_node(node->children, "application");
gchar *name = NULL, *class = NULL, *role = NULL;
gboolean name_set, class_set;
gboolean x_pos_given;
while (app) {
name_set = class_set = x_pos_given = FALSE;
- class_set = parse_attr_string("class", app, &class);
- name_set = parse_attr_string("name", app, &name);
+ class_set = obt_parse_attr_string(app, "class", &class);
+ name_set = obt_parse_attr_string(app, "name", &name);
if (class_set || name_set) {
xmlNodePtr n, c;
ObAppSettings *settings = config_create_app_settings();;
if (class_set)
settings->class = g_pattern_spec_new(class);
- if (parse_attr_string("role", app, &role))
+ if (obt_parse_attr_string(app, "role", &role))
settings->role = g_pattern_spec_new(role);
- if ((n = parse_find_node("decor", app->children)))
- if (!parse_contains("default", doc, n))
- settings->decor = parse_bool(doc, n);
+ if ((n = obt_parse_find_node(app->children, "decor")))
+ if (!obt_parse_node_contains(n, "default"))
+ settings->decor = obt_parse_node_bool(n);
- if ((n = parse_find_node("shade", app->children)))
- if (!parse_contains("default", doc, n))
- settings->shade = parse_bool(doc, n);
+ if ((n = obt_parse_find_node(app->children, "shade")))
+ if (!obt_parse_node_contains(n, "default"))
+ settings->shade = obt_parse_node_bool(n);
- if ((n = parse_find_node("position", app->children))) {
- if ((c = parse_find_node("x", n->children)))
- if (!parse_contains("default", doc, c)) {
- config_parse_gravity_coord(doc, c,
- &settings->position.x);
+ if ((n = obt_parse_find_node(app->children, "position"))) {
+ if ((c = obt_parse_find_node(n->children, "x")))
+ if (!obt_parse_node_contains(c, "default")) {
+ config_parse_gravity_coord(c, &settings->position.x);
x_pos_given = TRUE;
}
- if (x_pos_given && (c = parse_find_node("y", n->children)))
- if (!parse_contains("default", doc, c)) {
- config_parse_gravity_coord(doc, c,
- &settings->position.y);
+ if (x_pos_given && (c = obt_parse_find_node(n->children, "y")))
+ if (!obt_parse_node_contains("default", doc, c)) {
+ config_parse_gravity_coord(c, &settings->position.y);
settings->pos_given = TRUE;
}
if (settings->pos_given &&
- (c = parse_find_node("monitor", n->children)))
- if (!parse_contains("default", doc, c)) {
- gchar *s = parse_string(doc, c);
+ (c = obt_parse_find_node(n->children, "monitor")))
+ if (!obt_parse_node_contains(c, "default")) {
+ gchar *s = obt_parse_node_string(c);
if (!g_ascii_strcasecmp(s, "mouse"))
settings->monitor = 0;
else
- settings->monitor = parse_int(doc, c) + 1;
+ settings->monitor = obt_parse_node_int(c) + 1;
g_free(s);
}
}
- if ((n = parse_find_node("focus", app->children)))
- if (!parse_contains("default", doc, n))
- settings->focus = parse_bool(doc, n);
+ if ((n = obt_parse_find_node(app->children, "focus")))
+ if (!obt_parse_node_contains(n, "default"))
+ settings->focus = obt_parse_node_bool(n);
- if ((n = parse_find_node("desktop", app->children))) {
- if (!parse_contains("default", doc, n)) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_parse_find_node(app->children, "desktop"))) {
+ if (!obt_parse_node_contains(n, "default")) {
+ gchar *s = obt_parse_node_string(n);
if (!g_ascii_strcasecmp(s, "all"))
settings->desktop = DESKTOP_ALL;
else {
- gint i = parse_int(doc, n);
+ gint i = obt_parse_node_int(n);
if (i > 0)
settings->desktop = i;
}
}
}
- if ((n = parse_find_node("layer", app->children)))
- if (!parse_contains("default", doc, n)) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_parse_find_node(app->children, "layer")))
+ if (!obt_parse_node_contains(n, "default")) {
+ gchar *s = obt_parse_node_string(n);
if (!g_ascii_strcasecmp(s, "above"))
settings->layer = 1;
else if (!g_ascii_strcasecmp(s, "below"))
g_free(s);
}
- if ((n = parse_find_node("iconic", app->children)))
- if (!parse_contains("default", doc, n))
- settings->iconic = parse_bool(doc, n);
+ if ((n = obt_parse_find_node(app->children, "iconic")))
+ if (!obt_parse_node_contains(n, "default"))
+ settings->iconic = obt_parse_node_bool(n);
- if ((n = parse_find_node("skip_pager", app->children)))
- if (!parse_contains("default", doc, n))
- settings->skip_pager = parse_bool(doc, n);
+ if ((n = obt_parse_find_node(app->children, "skip_pager")))
+ if (!obt_parse_node_contains(n, "default"))
+ settings->skip_pager = obt_parse_node_bool(n);
- if ((n = parse_find_node("skip_taskbar", app->children)))
- if (!parse_contains("default", doc, n))
- settings->skip_taskbar = parse_bool(doc, n);
+ if ((n = obt_parse_find_node(app->children, "skip_taskbar")))
+ if (!obt_parse_node_contains(n, "default"))
+ settings->skip_taskbar = obt_parse_node_bool(n);
- if ((n = parse_find_node("fullscreen", app->children)))
- if (!parse_contains("default", doc, n))
- settings->fullscreen = parse_bool(doc, n);
+ if ((n = obt_parse_find_node(app->children, "fullscreen")))
+ if (!obt_parse_node_contains(n, "default"))
+ settings->fullscreen = obt_parse_node_bool(n);
- if ((n = parse_find_node("maximized", app->children)))
- if (!parse_contains("default", doc, n)) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_parse_find_node(app->children, "maximized")))
+ if (!obt_parse_node_contains(n, "default")) {
+ gchar *s = obt_parse_node_string(n);
if (!g_ascii_strcasecmp(s, "horizontal")) {
settings->max_horz = TRUE;
settings->max_vert = FALSE;
settings->max_vert = TRUE;
} else
settings->max_horz = settings->max_vert =
- parse_bool(doc, n);
+ obt_parse_node_bool(n);
g_free(s);
}
name = class = role = NULL;
}
- app = parse_find_node("application", app->next);
+ app = obt_parse_find_node(app->next, "application");
}
}
*/
-static void parse_key(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
- GList *keylist)
+static void parse_key(xmlNodePtr node, GList *keylist)
{
gchar *key;
xmlNodePtr n;
gboolean is_chroot = FALSE;
- if (!parse_attr_string("key", node, &key))
+ if (!obt_parse_attr_string(node, "key", &key))
return;
- parse_attr_bool("chroot", node, &is_chroot);
+ obt_parse_attr_bool(node, "chroot", &is_chroot);
keylist = g_list_append(keylist, key);
- if ((n = parse_find_node("keybind", node->children))) {
+ if ((n = obt_parse_find_node(node->children, "keybind"))) {
while (n) {
- parse_key(i, doc, n, keylist);
- n = parse_find_node("keybind", n->next);
+ parse_key(n, keylist);
+ n = obt_parse_find_node(n->next, "keybind");
}
}
- else if ((n = parse_find_node("action", node->children))) {
+ else if ((n = obt_parse_find_node(node->children, "action"))) {
while (n) {
ObActionsAct *action;
- action = actions_parse(i, doc, n);
+ action = actions_parse(n);
if (action)
keyboard_bind(keylist, action);
- n = parse_find_node("action", n->next);
+ n = obt_parse_find_node(n->next, "action");
}
}
keylist = g_list_delete_link(keylist, g_list_last(keylist));
}
-static void parse_keyboard(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
- gpointer data)
+static void parse_keyboard(xmlNodePtr node, gpointer d)
{
xmlNodePtr n;
gchar *key;
keyboard_unbind_all();
- if ((n = parse_find_node("chainQuitKey", node->children))) {
- key = parse_string(doc, n);
+ if ((n = obt_parse_find_node(node->children, "chainQuitKey"))) {
+ key = obt_parse_node_string(n);
translate_key(key, &config_keyboard_reset_state,
&config_keyboard_reset_keycode);
g_free(key);
}
- if ((n = parse_find_node("keybind", node->children)))
+ if ((n = obt_parse_find_node(node->children, "keybind")))
while (n) {
- parse_key(i, doc, n, NULL);
- n = parse_find_node("keybind", n->next);
+ parse_key(n, NULL);
+ n = obt_parse_find_node(n->next, "keybind");
}
}
*/
-static void parse_mouse(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
- gpointer data)
+static void parse_mouse(xmlNodePtr node, gpointer d)
{
xmlNodePtr n, nbut, nact;
gchar *buttonstr;
node = node->children;
- if ((n = parse_find_node("dragThreshold", node)))
- config_mouse_threshold = parse_int(doc, n);
- if ((n = parse_find_node("doubleClickTime", node)))
- config_mouse_dclicktime = parse_int(doc, n);
- if ((n = parse_find_node("screenEdgeWarpTime", node)))
- config_mouse_screenedgetime = parse_int(doc, n);
+ if ((n = obt_parse_find_node(node, "dragThreshold")))
+ config_mouse_threshold = obt_parse_node_int(n);
+ if ((n = obt_parse_find_node(node, "doubleClickTime")))
+ config_mouse_dclicktime = obt_parse_node_int(n);
+ if ((n = obt_parse_find_node(node, "screenEdgeWarpTime")))
+ config_mouse_screenedgetime = obt_parse_node_int(n);
- n = parse_find_node("context", node);
+ n = obt_parse_find_node(node, "context");
while (n) {
- if (!parse_attr_string("name", n, &contextstr))
+ if (!obt_parse_attr_string(n, "name", &contextstr))
goto next_n;
- nbut = parse_find_node("mousebind", n->children);
+ nbut = obt_parse_find_node(n->children, "mousebind");
while (nbut) {
- if (!parse_attr_string("button", nbut, &buttonstr))
+ if (!obt_parse_attr_string(nbut, "button", &buttonstr))
goto next_nbut;
- if (parse_attr_contains("press", nbut, "action")) {
+ if (obt_parse_attr_contains(nbut, "action", "press")) {
mact = OB_MOUSE_ACTION_PRESS;
- } else if (parse_attr_contains("release", nbut, "action")) {
+ } else if (obt_parse_attr_contains(nbut, "action", "release")) {
mact = OB_MOUSE_ACTION_RELEASE;
- } else if (parse_attr_contains("click", nbut, "action")) {
+ } else if (obt_parse_attr_contains(nbut, "action", "click")) {
mact = OB_MOUSE_ACTION_CLICK;
- } else if (parse_attr_contains("doubleclick", nbut,"action")) {
+ } else if (obt_parse_attr_contains(nbut, "action","doubleclick")) {
mact = OB_MOUSE_ACTION_DOUBLE_CLICK;
- } else if (parse_attr_contains("drag", nbut, "action")) {
+ } else if (obt_parse_attr_contains(nbut, "action", "drag")) {
mact = OB_MOUSE_ACTION_MOTION;
} else
goto next_nbut;
- nact = parse_find_node("action", nbut->children);
+ nact = obt_parse_find_node(nbut->children, "action");
while (nact) {
ObActionsAct *action;
- if ((action = actions_parse(i, doc, nact)))
+ if ((action = actions_parse(nact)))
mouse_bind(buttonstr, contextstr, mact, action);
- nact = parse_find_node("action", nact->next);
+ nact = obt_parse_find_node(nact->next, "action");
}
g_free(buttonstr);
next_nbut:
- nbut = parse_find_node("mousebind", nbut->next);
+ nbut = obt_parse_find_node(nbut->next, "mousebind");
}
g_free(contextstr);
next_n:
- n = parse_find_node("context", n->next);
+ n = obt_parse_find_node(n->next, "context");
}
}
-static void parse_focus(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
- gpointer data)
+static void parse_focus(xmlNodePtr node, gpointer d)
{
xmlNodePtr n;
node = node->children;
- if ((n = parse_find_node("focusNew", node)))
- config_focus_new = parse_bool(doc, n);
- if ((n = parse_find_node("followMouse", node)))
- config_focus_follow = parse_bool(doc, n);
- if ((n = parse_find_node("focusDelay", node)))
- config_focus_delay = parse_int(doc, n);
- if ((n = parse_find_node("raiseOnFocus", node)))
- config_focus_raise = parse_bool(doc, n);
- if ((n = parse_find_node("focusLast", node)))
- config_focus_last = parse_bool(doc, n);
- if ((n = parse_find_node("underMouse", node)))
- config_focus_under_mouse = parse_bool(doc, n);
+ if ((n = obt_parse_find_node(node, "focusNew")))
+ config_focus_new = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "followMouse")))
+ config_focus_follow = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "focusDelay")))
+ config_focus_delay = obt_parse_node_int(n);
+ if ((n = obt_parse_find_node(node, "raiseOnFocus")))
+ config_focus_raise = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "focusLast")))
+ config_focus_last = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "underMouse")))
+ config_focus_under_mouse = obt_parse_node_bool(n);
}
-static void parse_placement(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
- gpointer data)
+static void parse_placement(xmlNodePtr node, gpointer d)
{
xmlNodePtr n;
node = node->children;
- if ((n = parse_find_node("policy", node)))
- if (parse_contains("UnderMouse", doc, n))
+ if ((n = obt_parse_find_node(node, "policy")))
+ if (obt_parse_node_contains(n, "UnderMouse"))
config_place_policy = OB_PLACE_POLICY_MOUSE;
- if ((n = parse_find_node("center", node)))
- config_place_center = parse_bool(doc, n);
- if ((n = parse_find_node("active", node)))
- config_place_active = parse_bool(doc, n);
+ if ((n = obt_parse_find_node(node, "center")))
+ config_place_center = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "active")))
+ config_place_active = obt_parse_node_bool(n);
}
-static void parse_margins(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
- gpointer data)
+static void parse_margins(xmlNodePtr node, gpointer d)
{
xmlNodePtr n;
node = node->children;
- if ((n = parse_find_node("top", node)))
- config_margins.top = MAX(0, parse_int(doc, n));
- if ((n = parse_find_node("left", node)))
- config_margins.left = MAX(0, parse_int(doc, n));
- if ((n = parse_find_node("right", node)))
- config_margins.right = MAX(0, parse_int(doc, n));
- if ((n = parse_find_node("bottom", node)))
- config_margins.bottom = MAX(0, parse_int(doc, n));
+ if ((n = obt_parse_find_node(node, "top")))
+ config_margins.top = MAX(0, obt_parse_node_int(n));
+ if ((n = obt_parse_find_node(node, "left")))
+ config_margins.left = MAX(0, obt_parse_node_int(n));
+ if ((n = obt_parse_find_node(node, "right")))
+ config_margins.right = MAX(0, obt_parse_node_int(n));
+ if ((n = obt_parse_find_node(node, "bottom")))
+ config_margins.bottom = MAX(0, obt_parse_node_int(n));
}
-static void parse_theme(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
- gpointer data)
+static void parse_theme(xmlNodePtr node, gpointer d)
{
xmlNodePtr n;
node = node->children;
- if ((n = parse_find_node("name", node))) {
+ if ((n = obt_parse_find_node(node, "name"))) {
gchar *c;
g_free(config_theme);
- c = parse_string(doc, n);
+ c = obt_parse_node_string(n);
config_theme = parse_expand_tilde(c);
g_free(c);
}
- if ((n = parse_find_node("titleLayout", node))) {
+ if ((n = obt_parse_find_node(node, "titleLayout"))) {
gchar *c, *d;
g_free(config_title_layout);
- config_title_layout = parse_string(doc, n);
+ config_title_layout = obt_parse_node_string(n);
/* replace duplicates with spaces */
for (c = config_title_layout; *c != '\0'; ++c)
for (d = c+1; *d != '\0'; ++d)
if (*c == *d) *d = ' ';
}
- if ((n = parse_find_node("keepBorder", node)))
- config_theme_keepborder = parse_bool(doc, n);
- if ((n = parse_find_node("animateIconify", node)))
- config_animate_iconify = parse_bool(doc, n);
+ if ((n = obt_parse_find_node(node, "keepBorder")))
+ config_theme_keepborder = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "animateIconify")))
+ config_animate_iconify = obt_parse_node_bool(n);
- n = parse_find_node("font", node);
+ n = obt_parse_find_node(node, "font");
while (n) {
xmlNodePtr fnode;
RrFont **font;
RrFontWeight weight = RrDefaultFontWeight;
RrFontSlant slant = RrDefaultFontSlant;
- if (parse_attr_contains("ActiveWindow", n, "place"))
+ if (obt_parse_attr_contains(n, "place", "ActiveWindow"))
font = &config_font_activewindow;
- else if (parse_attr_contains("InactiveWindow", n, "place"))
+ else if (obt_parse_attr_contains(n, "place", "InactiveWindow"))
font = &config_font_inactivewindow;
- else if (parse_attr_contains("MenuHeader", n, "place"))
+ else if (obt_parse_attr_contains(n, "place", "MenuHeader"))
font = &config_font_menutitle;
- else if (parse_attr_contains("MenuItem", n, "place"))
+ else if (obt_parse_attr_contains(n, "place", "MenuItem"))
font = &config_font_menuitem;
- else if (parse_attr_contains("OnScreenDisplay", n, "place"))
+ else if (obt_parse_attr_contains(n, "place", "OnScreenDisplay"))
font = &config_font_osd;
else
goto next_font;
- if ((fnode = parse_find_node("name", n->children))) {
+ if ((fnode = obt_parse_find_node(n->children, "name"))) {
g_free(name);
- name = parse_string(doc, fnode);
+ name = obt_parse_node_string(fnode);
}
- if ((fnode = parse_find_node("size", n->children))) {
- int s = parse_int(doc, fnode);
+ if ((fnode = obt_parse_find_node(n->children, "size"))) {
+ int s = obt_parse_node_int(fnode);
if (s > 0) size = s;
}
- if ((fnode = parse_find_node("weight", n->children))) {
- gchar *w = parse_string(doc, fnode);
+ if ((fnode = obt_parse_find_node(n->children, "weight"))) {
+ gchar *w = obt_parse_node_string(fnode);
if (!g_ascii_strcasecmp(w, "Bold"))
weight = RR_FONTWEIGHT_BOLD;
g_free(w);
}
- if ((fnode = parse_find_node("slant", n->children))) {
- gchar *s = parse_string(doc, fnode);
+ if ((fnode = obt_parse_find_node(n->children, "slant"))) {
+ gchar *s = obt_parse_node_string(fnode);
if (!g_ascii_strcasecmp(s, "Italic"))
slant = RR_FONTSLANT_ITALIC;
if (!g_ascii_strcasecmp(s, "Oblique"))
*font = RrFontOpen(ob_rr_inst, name, size, weight, slant);
g_free(name);
next_font:
- n = parse_find_node("font", n->next);
+ n = obt_parse_find_node(n->next, "font");
}
}
-static void parse_desktops(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
- gpointer data)
+static void parse_desktops(xmlNodePtr node, gpointer d)
{
xmlNodePtr n;
node = node->children;
- if ((n = parse_find_node("number", node))) {
- gint d = parse_int(doc, n);
+ if ((n = obt_parse_find_node(node, "number"))) {
+ gint d = obt_parse_node_int(n);
if (d > 0)
config_desktops_num = d;
}
- if ((n = parse_find_node("firstdesk", node))) {
- gint d = parse_int(doc, n);
+ if ((n = obt_parse_find_node(node, "firstdesk"))) {
+ gint d = obt_parse_node_int(n);
if (d > 0)
config_screen_firstdesk = (unsigned) d;
}
- if ((n = parse_find_node("names", node))) {
+ if ((n = obt_parse_find_node(node, "names"))) {
GSList *it;
xmlNodePtr nname;
g_slist_free(config_desktops_names);
config_desktops_names = NULL;
- nname = parse_find_node("name", n->children);
+ nname = obt_parse_find_node(n->children, "name");
while (nname) {
- config_desktops_names = g_slist_append(config_desktops_names,
- parse_string(doc, nname));
- nname = parse_find_node("name", nname->next);
+ config_desktops_names =
+ g_slist_append(config_desktops_names,
+ obt_parse_node_string(nname));
+ nname = obt_parse_find_node(nname->next, "name");
}
}
- if ((n = parse_find_node("popupTime", node)))
- config_desktop_popup_time = parse_int(doc, n);
+ if ((n = obt_parse_find_node(node, "popupTime")))
+ config_desktop_popup_time = obt_parse_node_int(n);
}
-static void parse_resize(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
- gpointer data)
+static void parse_resize(xmlNodePtr node, gpointer d)
{
xmlNodePtr n;
node = node->children;
- if ((n = parse_find_node("drawContents", node)))
- config_resize_redraw = parse_bool(doc, n);
- if ((n = parse_find_node("popupShow", node))) {
- config_resize_popup_show = parse_int(doc, n);
- if (parse_contains("Always", doc, n))
+ if ((n = obt_parse_find_node(node, "drawContents")))
+ config_resize_redraw = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "popupShow"))) {
+ config_resize_popup_show = obt_parse_node_int(n);
+ if (obt_parse_node_contains(n, "Always"))
config_resize_popup_show = 2;
- else if (parse_contains("Never", doc, n))
+ else if (obt_parse_node_contains(n, "Never"))
config_resize_popup_show = 0;
- else if (parse_contains("Nonpixel", doc, n))
+ else if (obt_parse_node_contains(n, "Nonpixel"))
config_resize_popup_show = 1;
}
- if ((n = parse_find_node("popupPosition", node))) {
- if (parse_contains("Top", doc, n))
+ if ((n = obt_parse_find_node(node, "popupPosition"))) {
+ if (obt_parse_node_contains(n, "Top"))
config_resize_popup_pos = OB_RESIZE_POS_TOP;
- else if (parse_contains("Center", doc, n))
+ else if (obt_parse_node_contains(n, "Center"))
config_resize_popup_pos = OB_RESIZE_POS_CENTER;
- else if (parse_contains("Fixed", doc, n)) {
+ else if (obt_parse_node_contains(n, "Fixed")) {
config_resize_popup_pos = OB_RESIZE_POS_FIXED;
- if ((n = parse_find_node("popupFixedPosition", node))) {
+ if ((n = obt_parse_find_node(node, "popupFixedPosition"))) {
xmlNodePtr n2;
- if ((n2 = parse_find_node("x", n->children)))
- config_parse_gravity_coord(doc, n2,
+ if ((n2 = obt_parse_find_node(n->children, "x")))
+ config_parse_gravity_coord(n2,
&config_resize_popup_fixed.x);
- if ((n2 = parse_find_node("y", n->children)))
- config_parse_gravity_coord(doc, n2,
+ if ((n2 = obt_parse_find_node(n->children, "y")))
+ config_parse_gravity_coord(n2,
&config_resize_popup_fixed.y);
}
}
}
}
-static void parse_dock(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
- gpointer data)
+static void parse_dock(xmlNodePtr node, gpointer d)
{
xmlNodePtr n;
node = node->children;
- if ((n = parse_find_node("position", node))) {
- if (parse_contains("TopLeft", doc, n))
+ if ((n = obt_parse_find_node(node, "position"))) {
+ if (obt_parse_node_contains(n, "TopLeft"))
config_dock_floating = FALSE,
config_dock_pos = OB_DIRECTION_NORTHWEST;
- else if (parse_contains("Top", doc, n))
+ else if (obt_parse_node_contains(n, "Top"))
config_dock_floating = FALSE,
config_dock_pos = OB_DIRECTION_NORTH;
- else if (parse_contains("TopRight", doc, n))
+ else if (obt_parse_node_contains(n, "TopRight"))
config_dock_floating = FALSE,
config_dock_pos = OB_DIRECTION_NORTHEAST;
- else if (parse_contains("Right", doc, n))
+ else if (obt_parse_node_contains(n, "Right"))
config_dock_floating = FALSE,
config_dock_pos = OB_DIRECTION_EAST;
- else if (parse_contains("BottomRight", doc, n))
+ else if (obt_parse_node_contains(n, "BottomRight"))
config_dock_floating = FALSE,
config_dock_pos = OB_DIRECTION_SOUTHEAST;
- else if (parse_contains("Bottom", doc, n))
+ else if (obt_parse_node_contains(n, "Bottom"))
config_dock_floating = FALSE,
config_dock_pos = OB_DIRECTION_SOUTH;
- else if (parse_contains("BottomLeft", doc, n))
+ else if (obt_parse_node_contains(n, "BottomLeft"))
config_dock_floating = FALSE,
config_dock_pos = OB_DIRECTION_SOUTHWEST;
- else if (parse_contains("Left", doc, n))
+ else if (obt_parse_node_contains(n, "Left"))
config_dock_floating = FALSE,
config_dock_pos = OB_DIRECTION_WEST;
- else if (parse_contains("Floating", doc, n))
+ else if (obt_parse_node_contains(n, "Floating"))
config_dock_floating = TRUE;
}
if (config_dock_floating) {
- if ((n = parse_find_node("floatingX", node)))
- config_dock_x = parse_int(doc, n);
- if ((n = parse_find_node("floatingY", node)))
- config_dock_y = parse_int(doc, n);
+ if ((n = obt_parse_find_node(node, "floatingX")))
+ config_dock_x = obt_parse_node_int(n);
+ if ((n = obt_parse_find_node(node, "floatingY")))
+ config_dock_y = obt_parse_node_int(n);
} else {
- if ((n = parse_find_node("noStrut", node)))
- config_dock_nostrut = parse_bool(doc, n);
+ if ((n = obt_parse_find_node(node, "noStrut")))
+ config_dock_nostrut = obt_parse_node_bool(n);
}
- if ((n = parse_find_node("stacking", node))) {
- if (parse_contains("above", doc, n))
- config_dock_layer = OB_STACKING_LAYER_ABOVE;
- else if (parse_contains("normal", doc, n))
+ if ((n = obt_parse_find_node(node, "stacking"))) {
+ if (obt_parse_node_contains(n, "normal"))
config_dock_layer = OB_STACKING_LAYER_NORMAL;
- else if (parse_contains("below", doc, n))
+ else if (obt_parse_node_contains(n, "below"))
config_dock_layer = OB_STACKING_LAYER_BELOW;
+ else if (obt_parse_node_contains(n, "above"))
+ config_dock_layer = OB_STACKING_LAYER_ABOVE;
}
- if ((n = parse_find_node("direction", node))) {
- if (parse_contains("horizontal", doc, n))
+ if ((n = obt_parse_find_node(node, "direction"))) {
+ if (obt_parse_node_contains(n, "horizontal"))
config_dock_orient = OB_ORIENTATION_HORZ;
- else if (parse_contains("vertical", doc, n))
+ else if (obt_parse_node_contains(n, "vertical"))
config_dock_orient = OB_ORIENTATION_VERT;
}
- if ((n = parse_find_node("autoHide", node)))
- config_dock_hide = parse_bool(doc, n);
- if ((n = parse_find_node("hideDelay", node)))
- config_dock_hide_delay = parse_int(doc, n);
- if ((n = parse_find_node("showDelay", node)))
- config_dock_show_delay = parse_int(doc, n);
- if ((n = parse_find_node("moveButton", node))) {
- gchar *str = parse_string(doc, n);
+ if ((n = obt_parse_find_node(node, "autoHide")))
+ config_dock_hide = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "hideDelay")))
+ config_dock_hide_delay = obt_parse_node_int(n);
+ if ((n = obt_parse_find_node(node, "showDelay")))
+ config_dock_show_delay = obt_parse_node_int(n);
+ if ((n = obt_parse_find_node(node, "moveButton"))) {
+ gchar *str = obt_parse_node_string(n);
guint b, s;
if (translate_button(str, &s, &b)) {
config_dock_app_move_button = b;
}
}
-static void parse_menu(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
- gpointer data)
+static void parse_menu(xmlNodePtr node, gpointer d)
{
xmlNodePtr n;
for (node = node->children; node; node = node->next) {
if (!xmlStrcasecmp(node->name, (const xmlChar*) "file")) {
gchar *c;
- c = parse_string(doc, node);
+ c = obt_parse_node_string(node);
config_menu_files = g_slist_append(config_menu_files,
parse_expand_tilde(c));
g_free(c);
}
- if ((n = parse_find_node("hideDelay", node)))
- config_menu_hide_delay = parse_int(doc, n);
- if ((n = parse_find_node("middle", node)))
- config_menu_middle = parse_bool(doc, n);
- if ((n = parse_find_node("submenuShowDelay", node)))
- config_submenu_show_delay = parse_int(doc, n);
- if ((n = parse_find_node("applicationIcons", node)))
- config_menu_client_list_icons = parse_bool(doc, n);
+ if ((n = obt_parse_find_node(node, "hideDelay")))
+ config_menu_hide_delay = obt_parse_node_int(n);
+ if ((n = obt_parse_find_node(node, "middle")))
+ config_menu_middle = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "submenuShowDelay")))
+ config_submenu_show_delay = obt_parse_node_int(n);
+ if ((n = obt_parse_find_node(node, "applicationIcons")))
+ config_menu_client_list_icons = obt_parse_node_bool(n);
}
}
-static void parse_resistance(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
- gpointer data)
+static void parse_resistance(xmlNodePtr node, gpointer d)
{
xmlNodePtr n;
node = node->children;
- if ((n = parse_find_node("strength", node)))
- config_resist_win = parse_int(doc, n);
- if ((n = parse_find_node("screen_edge_strength", node)))
- config_resist_edge = parse_int(doc, n);
+ if ((n = obt_parse_find_node(node, "strength")))
+ config_resist_win = obt_parse_node_int(n);
+ if ((n = obt_parse_find_node(node, "screen_edge_strength")))
+ config_resist_edge = obt_parse_node_int(n);
}
typedef struct
actions_parse_string(it->actname));
}
-void config_startup(ObParseInst *i)
+void config_startup(ObtParseInst *i)
{
config_focus_new = TRUE;
config_focus_follow = FALSE;
config_focus_last = TRUE;
config_focus_under_mouse = FALSE;
- parse_register(i, "focus", parse_focus, NULL);
+ obt_parse_register(i, "focus", parse_focus, NULL);
config_place_policy = OB_PLACE_POLICY_SMART;
config_place_center = TRUE;
config_place_active = FALSE;
- parse_register(i, "placement", parse_placement, NULL);
+ obt_parse_register(i, "placement", parse_placement, NULL);
STRUT_PARTIAL_SET(config_margins, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
- parse_register(i, "margins", parse_margins, NULL);
+ obt_parse_register(i, "margins", parse_margins, NULL);
config_theme = NULL;
config_font_menuitem = NULL;
config_font_menutitle = NULL;
- parse_register(i, "theme", parse_theme, NULL);
+ obt_parse_register(i, "theme", parse_theme, NULL);
config_desktops_num = 4;
config_screen_firstdesk = 1;
config_desktops_names = NULL;
config_desktop_popup_time = 875;
- parse_register(i, "desktops", parse_desktops, NULL);
+ obt_parse_register(i, "desktops", parse_desktops, NULL);
config_resize_redraw = TRUE;
config_resize_popup_show = 1; /* nonpixel increments */
GRAVITY_COORD_SET(config_resize_popup_fixed.x, 0, FALSE, FALSE);
GRAVITY_COORD_SET(config_resize_popup_fixed.y, 0, FALSE, FALSE);
- parse_register(i, "resize", parse_resize, NULL);
+ obt_parse_register(i, "resize", parse_resize, NULL);
config_dock_layer = OB_STACKING_LAYER_ABOVE;
config_dock_pos = OB_DIRECTION_NORTHEAST;
config_dock_app_move_button = 2; /* middle */
config_dock_app_move_modifiers = 0;
- parse_register(i, "dock", parse_dock, NULL);
+ obt_parse_register(i, "dock", parse_dock, NULL);
translate_key("C-g", &config_keyboard_reset_state,
&config_keyboard_reset_keycode);
bind_default_keyboard();
- parse_register(i, "keyboard", parse_keyboard, NULL);
+ obt_parse_register(i, "keyboard", parse_keyboard, NULL);
config_mouse_threshold = 8;
config_mouse_dclicktime = 200;
bind_default_mouse();
- parse_register(i, "mouse", parse_mouse, NULL);
+ obt_parse_register(i, "mouse", parse_mouse, NULL);
config_resist_win = 10;
config_resist_edge = 20;
- parse_register(i, "resistance", parse_resistance, NULL);
+ obt_parse_register(i, "resistance", parse_resistance, NULL);
config_menu_hide_delay = 250;
config_menu_middle = FALSE;
config_menu_client_list_icons = TRUE;
config_menu_files = NULL;
- parse_register(i, "menu", parse_menu, NULL);
+ obt_parse_register(i, "menu", parse_menu, NULL);
config_per_app_settings = NULL;
- parse_register(i, "applications", parse_per_app_settings, NULL);
+ obt_parse_register(i, "applications", parse_per_app_settings, NULL);
}
void config_shutdown(void)
#include "geom.h"
#include "moveresize.h"
#include "render/render.h"
+#include "obt/parse.h"
#include <glib.h>
-struct _ObParseInst;
-
typedef struct _ObAppSettings ObAppSettings;
struct _ObAppSettings
/*! Per app settings */
extern GSList *config_per_app_settings;
-void config_startup(struct _ObParseInst *i);
+void config_startup(ObtParseInst *i);
void config_shutdown();
/*! Create an ObAppSettings structure with the default values */
#include "client_list_menu.h"
#include "client_list_combined_menu.h"
#include "gettext.h"
-#include "parser/parse.h"
+#include "obt/parse.h"
typedef struct _ObMenuParseState ObMenuParseState;
};
static GHashTable *menu_hash = NULL;
-static ObParseInst *menu_parse_inst;
+static ObtParseInst *menu_parse_inst;
static ObMenuParseState menu_parse_state;
static gboolean menu_can_hide = FALSE;
static void menu_destroy_hash_value(ObMenu *self);
-static void parse_menu_item(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
- gpointer data);
-static void parse_menu_separator(ObParseInst *i,
- xmlDocPtr doc, xmlNodePtr node,
- gpointer data);
-static void parse_menu(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
- gpointer data);
+static void parse_menu_item(xmlNodePtr node, gpointer data);
+static void parse_menu_separator(xmlNodePtr node, gpointer data);
+static void parse_menu(xmlNodePtr node, gpointer data);
static gunichar parse_shortcut(const gchar *label, gboolean allow_shortcut,
gchar **strippedlabel, guint *position,
gboolean *always_show);
void menu_startup(gboolean reconfig)
{
- xmlDocPtr doc;
- xmlNodePtr node;
gboolean loaded = FALSE;
GSList *it;
client_list_combined_menu_startup(reconfig);
client_menu_startup();
- menu_parse_inst = parse_startup();
+ menu_parse_inst = obt_parse_instance_new();
menu_parse_state.parent = NULL;
menu_parse_state.pipe_creator = NULL;
- parse_register(menu_parse_inst, "menu", parse_menu, &menu_parse_state);
- parse_register(menu_parse_inst, "item", parse_menu_item,
- &menu_parse_state);
- parse_register(menu_parse_inst, "separator",
- parse_menu_separator, &menu_parse_state);
+ obt_parse_register(menu_parse_inst, "menu", parse_menu, &menu_parse_state);
+ obt_parse_register(menu_parse_inst, "item", parse_menu_item,
+ &menu_parse_state);
+ obt_parse_register(menu_parse_inst, "separator",
+ parse_menu_separator, &menu_parse_state);
for (it = config_menu_files; it; it = g_slist_next(it)) {
- if (parse_load_menu(it->data, &doc, &node)) {
+ if (obt_parse_load_config_file(menu_parse_inst,
+ "openbox",
+ it->data,
+ "openbox_menu"))
+ {
loaded = TRUE;
- parse_tree(menu_parse_inst, doc, node->children);
- xmlFreeDoc(doc);
+ obt_parse_tree(menu_parse_inst,
+ obt_parse_instance_root(menu_parse_inst)->children);
+ obt_parse_close(menu_parse_inst);
} else
g_message(_("Unable to find a valid menu file '%s'"),
(const gchar*)it->data);
}
if (!loaded) {
- if (parse_load_menu("menu.xml", &doc, &node)) {
- parse_tree(menu_parse_inst, doc, node->children);
- xmlFreeDoc(doc);
+ if (obt_parse_load_config_file(menu_parse_inst,
+ "openbox",
+ "menu.xml",
+ "openbox_menu"))
+ {
+ obt_parse_tree(menu_parse_inst,
+ obt_parse_instance_root(menu_parse_inst)->children);
+ obt_parse_close(menu_parse_inst);
} else
g_message(_("Unable to find a valid menu file '%s'"),
"menu.xml");
if (!reconfig)
client_remove_destroy_notify(client_dest);
- parse_shutdown(menu_parse_inst);
+ obt_parse_instance_unref(menu_parse_inst);
menu_parse_inst = NULL;
client_list_menu_shutdown(reconfig);
void menu_pipe_execute(ObMenu *self)
{
- xmlDocPtr doc;
xmlNodePtr node;
gchar *output;
GError *err = NULL;
return;
}
- if (parse_load_mem(output, strlen(output),
- "openbox_pipe_menu", &doc, &node))
+ if (obt_parse_load_mem(menu_parse_inst, output, strlen(output),
+ "openbox_pipe_menu"))
{
menu_parse_state.pipe_creator = self;
menu_parse_state.parent = self;
- parse_tree(menu_parse_inst, doc, node->children);
- xmlFreeDoc(doc);
+ obt_parse_tree(menu_parse_inst, node->children);
+ obt_parse_close(menu_parse_inst);
} else {
g_message(_("Invalid output from pipe-menu '%s'"), self->execute);
}
return shortcut;
}
-static void parse_menu_item(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
- gpointer data)
+static void parse_menu_item(xmlNodePtr node, gpointer data)
{
ObMenuParseState *state = data;
gchar *label;
if (state->parent) {
- if (parse_attr_string("label", node, &label)) {
+ if (obt_parse_attr_string(node, "label", &label)) {
GSList *acts = NULL;
for (node = node->children; node; node = node->next)
if (!xmlStrcasecmp(node->name, (const xmlChar*) "action")) {
- ObActionsAct *a = actions_parse(i, doc, node);
+ ObActionsAct *a = actions_parse(node);
if (a)
acts = g_slist_append(acts, a);
}
}
}
-static void parse_menu_separator(ObParseInst *i,
- xmlDocPtr doc, xmlNodePtr node,
- gpointer data)
+static void parse_menu_separator(xmlNodePtr node, gpointer data)
{
ObMenuParseState *state = data;
if (state->parent) {
gchar *label;
- if (!parse_attr_string("label", node, &label))
+ if (!obt_parse_attr_string(node, "label", &label))
label = NULL;
menu_add_separator(state->parent, -1, label);
}
}
-static void parse_menu(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
- gpointer data)
+static void parse_menu(xmlNodePtr node, gpointer data)
{
ObMenuParseState *state = data;
gchar *name = NULL, *title = NULL, *script = NULL;
ObMenu *menu;
- if (!parse_attr_string("id", node, &name))
+ if (!obt_parse_attr_string(node, "id", &name))
goto parse_menu_fail;
if (!g_hash_table_lookup(menu_hash, name)) {
- if (!parse_attr_string("label", node, &title))
+ if (!obt_parse_attr_string(node, "label", &title))
goto parse_menu_fail;
if ((menu = menu_new(name, title, TRUE, NULL))) {
menu->pipe_creator = state->pipe_creator;
- if (parse_attr_string("execute", node, &script)) {
+ if (obt_parse_attr_string(node, "execute", &script)) {
menu->execute = parse_expand_tilde(script);
} else {
ObMenu *old;
old = state->parent;
state->parent = menu;
- parse_tree(i, doc, node->children);
+ obt_parse_tree(menu_parse_inst, node->children);
state->parent = old;
}
}
#include "window.h"
#include "geom.h"
#include "render/render.h"
-#include "parser/parse.h"
+#include "obt/parse.h"
#include <glib.h>
#include "ping.h"
#include "mainloop.h"
#include "gettext.h"
-#include "parser/parse.h"
#include "render/render.h"
#include "render/theme.h"
#include "obt/display.h"
#include "obt/prop.h"
+#include "obt/keyboard.h"
+#include "obt/parse.h"
#ifdef HAVE_FCNTL_H
# include <fcntl.h>
keys[OB_KEY_DOWN] = obt_keyboard_keysym_to_keycode(XK_Down);
{
- ObParseInst *i;
- xmlDocPtr doc;
- xmlNodePtr node;
+ ObtParseInst *i;
/* startup the parsing so everything can register sections
of the rc */
- i = parse_startup();
+ i = obt_parse_instance_new();
/* register all the available actions */
actions_startup(reconfigure);
config_startup(i);
/* parse/load user options */
- if (parse_load_rc(NULL, &doc, &node)) {
- parse_tree(i, doc, node->xmlChildrenNode);
- parse_close(doc);
+ if (obt_parse_load_config_file(i, "openbox", "rc.xml",
+ "openbox_config"))
+ {
+ obt_parse_tree(i, obt_parse_instance_root(i)->children);
+ obt_parse_close(i);
} else
g_message(_("Unable to find a valid config file, using some simple defaults"));
*/
/* we're done with parsing now, kill it */
- parse_shutdown(i);
+ obt_parse_instance_unref(i);
}
/* load the theme specified in the rc file */
See the COPYING file for a copy of the GNU General Public License.
*/
+#include "resist.h"
#include "client.h"
#include "frame.h"
#include "stacking.h"
#include "screen.h"
#include "dock.h"
#include "config.h"
-#include "resist.h"
-#include "parser/parse.h"
#include <glib.h>
#include "client.h"
#include "focus.h"
#include "gettext.h"
-#include "parser/parse.h"
+#include "obt/parse.h"
#include <time.h>
#include <errno.h>
static void session_load_file(const gchar *path)
{
- xmlDocPtr doc;
+ ObtParseInst *i;
xmlNodePtr node, n, m;
GList *it, *inext;
- if (!parse_load(path, "openbox_session", &doc, &node))
+ i = obt_parse_instance_new();
+
+ if (!obt_parse_load_file(i, path, "openbox_session")) {
+ obt_parse_instance_unref(i);
return;
+ }
+ node = obt_parse_instance_root(i);
- if ((n = parse_find_node("desktop", node->children)))
- session_desktop = parse_int(doc, n);
+ if ((n = obt_parse_find_node(node->children, "desktop")))
+ session_desktop = obt_parse_node_int(n);
- if ((n = parse_find_node("numdesktops", node->children)))
- session_num_desktops = parse_int(doc, n);
+ if ((n = obt_parse_find_node(node->children, "numdesktops")))
+ session_num_desktops = obt_parse_node_int(n);
- if ((n = parse_find_node("desktoplayout", node->children))) {
+ if ((n = obt_parse_find_node(node->children, "desktoplayout"))) {
/* make sure they are all there for it to be valid */
- if ((m = parse_find_node("orientation", n->children)))
- session_desktop_layout.orientation = parse_int(doc, m);
- if (m && (m = parse_find_node("startcorner", n->children)))
- session_desktop_layout.start_corner = parse_int(doc, m);
- if (m && (m = parse_find_node("columns", n->children)))
- session_desktop_layout.columns = parse_int(doc, m);
- if (m && (m = parse_find_node("rows", n->children)))
- session_desktop_layout.rows = parse_int(doc, m);
+ if ((m = obt_parse_find_node(n->children, "orientation")))
+ session_desktop_layout.orientation = obt_parse_node_int(m);
+ if (m && (m = obt_parse_find_node(n->children, "startcorner")))
+ session_desktop_layout.start_corner = obt_parse_node_int(m);
+ if (m && (m = obt_parse_find_node(n->children, "columns")))
+ session_desktop_layout.columns = obt_parse_node_int(m);
+ if (m && (m = obt_parse_find_node(n->children, "rows")))
+ session_desktop_layout.rows = obt_parse_node_int(m);
session_desktop_layout_present = m != NULL;
}
- if ((n = parse_find_node("desktopnames", node->children))) {
- for (m = parse_find_node("name", n->children); m;
- m = parse_find_node("name", m->next))
+ if ((n = obt_parse_find_node(node->children, "desktopnames"))) {
+ for (m = obt_parse_find_node(n->children, "name"); m;
+ m = obt_parse_find_node(m->next, "name"))
{
session_desktop_names = g_slist_append(session_desktop_names,
- parse_string(doc, m));
+ obt_parse_node_string(m));
}
}
- for (node = parse_find_node("window", node->children); node != NULL;
- node = parse_find_node("window", node->next))
+ for (node = obt_parse_find_node(node->children, "window"); node != NULL;
+ node = obt_parse_find_node(node->next, "window"))
{
ObSessionState *state;
state = g_new0(ObSessionState, 1);
- if (!parse_attr_string("id", node, &state->id))
- if (!parse_attr_string("command", node, &state->command))
+ if (!obt_parse_attr_string(node, "id", &state->id))
+ if (!obt_parse_attr_string(node, "command", &state->command))
goto session_load_bail;
- if (!(n = parse_find_node("name", node->children)))
+ if (!(n = obt_parse_find_node(node->children, "name")))
goto session_load_bail;
- state->name = parse_string(doc, n);
- if (!(n = parse_find_node("class", node->children)))
+ state->name = obt_parse_node_string(n);
+ if (!(n = obt_parse_find_node(node->children, "class")))
goto session_load_bail;
- state->class = parse_string(doc, n);
- if (!(n = parse_find_node("role", node->children)))
+ state->class = obt_parse_node_string(n);
+ if (!(n = obt_parse_find_node(node->children, "role")))
goto session_load_bail;
- state->role = parse_string(doc, n);
- if (!(n = parse_find_node("windowtype", node->children)))
+ state->role = obt_parse_node_string(n);
+ if (!(n = obt_parse_find_node(node->children, "windowtype")))
goto session_load_bail;
- state->type = parse_int(doc, n);
- if (!(n = parse_find_node("desktop", node->children)))
+ state->type = obt_parse_node_int(n);
+ if (!(n = obt_parse_find_node(node->children, "desktop")))
goto session_load_bail;
- state->desktop = parse_int(doc, n);
- if (!(n = parse_find_node("x", node->children)))
+ state->desktop = obt_parse_node_int(n);
+ if (!(n = obt_parse_find_node(node->children, "x")))
goto session_load_bail;
- state->x = parse_int(doc, n);
- if (!(n = parse_find_node("y", node->children)))
+ state->x = obt_parse_node_int(n);
+ if (!(n = obt_parse_find_node(node->children, "y")))
goto session_load_bail;
- state->y = parse_int(doc, n);
- if (!(n = parse_find_node("width", node->children)))
+ state->y = obt_parse_node_int(n);
+ if (!(n = obt_parse_find_node(node->children, "width")))
goto session_load_bail;
- state->w = parse_int(doc, n);
- if (!(n = parse_find_node("height", node->children)))
+ state->w = obt_parse_node_int(n);
+ if (!(n = obt_parse_find_node(node->children, "height")))
goto session_load_bail;
- state->h = parse_int(doc, n);
+ state->h = obt_parse_node_int(n);
state->shaded =
- parse_find_node("shaded", node->children) != NULL;
+ obt_parse_find_node(node->children, "shaded") != NULL;
state->iconic =
- parse_find_node("iconic", node->children) != NULL;
+ obt_parse_find_node(node->children, "iconic") != NULL;
state->skip_pager =
- parse_find_node("skip_pager", node->children) != NULL;
+ obt_parse_find_node(node->children, "skip_pager") != NULL;
state->skip_taskbar =
- parse_find_node("skip_taskbar", node->children) != NULL;
+ obt_parse_find_node(node->children, "skip_taskbar") != NULL;
state->fullscreen =
- parse_find_node("fullscreen", node->children) != NULL;
+ obt_parse_find_node(node->children, "fullscreen") != NULL;
state->above =
- parse_find_node("above", node->children) != NULL;
+ obt_parse_find_node(node->children, "above") != NULL;
state->below =
- parse_find_node("below", node->children) != NULL;
+ obt_parse_find_node(node->children, "below") != NULL;
state->max_horz =
- parse_find_node("max_horz", node->children) != NULL;
+ obt_parse_find_node(node->children, "max_horz") != NULL;
state->max_vert =
- parse_find_node("max_vert", node->children) != NULL;
+ obt_parse_find_node(node->children, "max_vert") != NULL;
state->undecorated =
- parse_find_node("undecorated", node->children) != NULL;
+ obt_parse_find_node(node->children, "undecorated") != NULL;
state->focused =
- parse_find_node("focused", node->children) != NULL;
+ obt_parse_find_node(node->children, "focused") != NULL;
/* save this. they are in the file in stacking order, so preserve
that order here */
}
}
- xmlFreeDoc(doc);
+ obt_parse_instance_unref(i);
}
#endif
+++ /dev/null
-all clean install:
- $(MAKE) -C .. -$(MAKEFLAGS) $@
-
-.PHONY: all clean install
+++ /dev/null
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-
-Name: ObParser
-Description: Openbox config file parsing library
-Version: @VERSION@
-Requires: libxml-2.0 glib-2.0
-Libs: -L${libdir} -lobparser
-Cflags: -I${includedir}/openbox/@OB_VERSION@
+++ /dev/null
-/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
-
- parse.c for the Openbox window manager
- Copyright (c) 2003-2007 Dana Jansens
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- See the COPYING file for a copy of the GNU General Public License.
-*/
-
-#include "parse.h"
-#include <glib.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-static gboolean xdg_start;
-static gchar *xdg_config_home_path;
-static gchar *xdg_data_home_path;
-static GSList *xdg_config_dir_paths;
-static GSList *xdg_data_dir_paths;
-
-struct Callback {
- gchar *tag;
- ParseCallback func;
- gpointer data;
-};
-
-struct _ObParseInst {
- GHashTable *callbacks;
-};
-
-static void destfunc(struct Callback *c)
-{
- g_free(c->tag);
- g_free(c);
-}
-
-ObParseInst* parse_startup(void)
-{
- ObParseInst *i = g_new(ObParseInst, 1);
- i->callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
- (GDestroyNotify)destfunc);
- return i;
-}
-
-void parse_shutdown(ObParseInst *i)
-{
- if (i) {
- g_hash_table_destroy(i->callbacks);
- g_free(i);
- }
-}
-
-void parse_register(ObParseInst *i, const gchar *tag,
- ParseCallback func, gpointer data)
-{
- struct Callback *c;
-
- if ((c = g_hash_table_lookup(i->callbacks, tag))) {
- g_error("Tag '%s' already registered", tag);
- return;
- }
-
- c = g_new(struct Callback, 1);
- c->tag = g_strdup(tag);
- c->func = func;
- c->data = data;
- g_hash_table_insert(i->callbacks, c->tag, c);
-}
-
-gboolean parse_load_rc(const gchar *type, xmlDocPtr *doc, xmlNodePtr *root)
-{
- GSList *it;
- gboolean r = FALSE;
- gchar *fname;
-
- if (type == NULL)
- fname = g_strdup("rc.xml");
- else
- fname = g_strdup_printf("rc-%s.xml", type);
-
- for (it = xdg_config_dir_paths; !r && it; it = g_slist_next(it)) {
- gchar *path;
-
- path = g_build_filename(it->data, "openbox", fname, NULL);
- r = parse_load(path, "openbox_config", doc, root);
- g_free(path);
- }
- g_free(fname);
-
- return r;
-}
-
-gboolean parse_load_theme(const gchar *name, xmlDocPtr *doc, xmlNodePtr *root,
- gchar **retpath)
-{
- GSList *it;
- gchar *path;
- gboolean r = FALSE;
- gchar *eng;
-
- /* backward compatibility.. */
- path = g_build_filename(g_get_home_dir(), ".themes", name,
- "openbox-3", "themerc.xml", NULL);
- if (parse_load(path, "openbox_theme", doc, root) &&
- parse_attr_string("engine", *root, &eng))
- {
- if (!strcmp(eng, "box")) {
- *retpath = g_path_get_dirname(path);
- r = TRUE;
- }
- g_free(eng);
- }
- g_free(path);
-
- if (!r) {
- for (it = xdg_data_dir_paths; !r && it; it = g_slist_next(it)) {
- path = g_build_filename(it->data, "themes", name, "openbox-3",
- "themerc.xml", NULL);
- if (parse_load(path, "openbox_theme", doc, root) &&
- parse_attr_string("engine", *root, &eng))
- {
- if (!strcmp(eng, "box")) {
- *retpath = g_path_get_dirname(path);
- r = TRUE;
- }
- g_free(eng);
- }
- g_free(path);
- }
- }
- return r;
-}
-
-gboolean parse_load_menu(const gchar *file, xmlDocPtr *doc, xmlNodePtr *root)
-{
- GSList *it;
- gchar *path;
- gboolean r = FALSE;
-
- if (file[0] == '/') {
- r = parse_load(file, "openbox_menu", doc, root);
- } else {
- for (it = xdg_config_dir_paths; !r && it; it = g_slist_next(it)) {
- path = g_build_filename(it->data, "openbox", file, NULL);
- r = parse_load(path, "openbox_menu", doc, root);
- g_free(path);
- }
- }
- return r;
-}
-
-gboolean parse_load(const gchar *path, const gchar *rootname,
- xmlDocPtr *doc, xmlNodePtr *root)
-{
- struct stat s;
-
- if (stat(path, &s) < 0)
- return FALSE;
-
- /* XML_PARSE_BLANKS is needed apparently. When it loads a theme file,
- without this option, the tree is weird and has extra nodes in it. */
- if ((*doc = xmlReadFile(path, NULL,
- XML_PARSE_NOBLANKS | XML_PARSE_RECOVER))) {
- *root = xmlDocGetRootElement(*doc);
- if (!*root) {
- xmlFreeDoc(*doc);
- *doc = NULL;
- g_message("%s is an empty document", path);
- } else {
- if (xmlStrcmp((*root)->name, (const xmlChar*)rootname)) {
- xmlFreeDoc(*doc);
- *doc = NULL;
- g_message("XML Document %s is of wrong type. Root "
- "node is not '%s'", path, rootname);
- }
- }
- }
- if (!*doc)
- return FALSE;
- return TRUE;
-}
-
-gboolean parse_load_mem(gpointer data, guint len, const gchar *rootname,
- xmlDocPtr *doc, xmlNodePtr *root)
-{
- if ((*doc = xmlParseMemory(data, len))) {
- *root = xmlDocGetRootElement(*doc);
- if (!*root) {
- xmlFreeDoc(*doc);
- *doc = NULL;
- g_message("Given memory is an empty document");
- } else {
- if (xmlStrcmp((*root)->name, (const xmlChar*)rootname)) {
- xmlFreeDoc(*doc);
- *doc = NULL;
- g_message("XML Document in given memory is of wrong "
- "type. Root node is not '%s'\n", rootname);
- }
- }
- }
- if (!*doc)
- return FALSE;
- return TRUE;
-}
-
-void parse_close(xmlDocPtr doc)
-{
- xmlFreeDoc(doc);
-}
-
-void parse_tree(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
-{
- while (node) {
- struct Callback *c = g_hash_table_lookup(i->callbacks, node->name);
-
- if (c)
- c->func(i, doc, node, c->data);
-
- node = node->next;
- }
-}
-
-gchar *parse_string(xmlDocPtr doc, xmlNodePtr node)
-{
- xmlChar *c = xmlNodeListGetString(doc, node->children, TRUE);
- gchar *s = g_strdup(c ? (gchar*)c : "");
- xmlFree(c);
- return s;
-}
-
-gint parse_int(xmlDocPtr doc, xmlNodePtr node)
-{
- xmlChar *c = xmlNodeListGetString(doc, node->children, TRUE);
- gint i = c ? atoi((gchar*)c) : 0;
- xmlFree(c);
- return i;
-}
-
-gboolean parse_bool(xmlDocPtr doc, xmlNodePtr node)
-{
- xmlChar *c = xmlNodeListGetString(doc, node->children, TRUE);
- gboolean b = FALSE;
- if (c && !xmlStrcasecmp(c, (const xmlChar*) "true"))
- b = TRUE;
- else if (c && !xmlStrcasecmp(c, (const xmlChar*) "yes"))
- b = TRUE;
- else if (c && !xmlStrcasecmp(c, (const xmlChar*) "on"))
- b = TRUE;
- xmlFree(c);
- return b;
-}
-
-gboolean parse_contains(const gchar *val, xmlDocPtr doc, xmlNodePtr node)
-{
- xmlChar *c = xmlNodeListGetString(doc, node->children, TRUE);
- gboolean r;
- r = !xmlStrcasecmp(c, (const xmlChar*) val);
- xmlFree(c);
- return r;
-}
-
-xmlNodePtr parse_find_node(const gchar *tag, xmlNodePtr node)
-{
- while (node) {
- if (!xmlStrcmp(node->name, (const xmlChar*) tag))
- return node;
- node = node->next;
- }
- return NULL;
-}
-
-gboolean parse_attr_bool(const gchar *name, xmlNodePtr node, gboolean *value)
-{
- xmlChar *c = xmlGetProp(node, (const xmlChar*) name);
- gboolean r = FALSE;
- if (c) {
- if (!xmlStrcasecmp(c, (const xmlChar*) "true"))
- *value = TRUE, r = TRUE;
- else if (!xmlStrcasecmp(c, (const xmlChar*) "yes"))
- *value = TRUE, r = TRUE;
- else if (!xmlStrcasecmp(c, (const xmlChar*) "on"))
- *value = TRUE, r = TRUE;
- else if (!xmlStrcasecmp(c, (const xmlChar*) "false"))
- *value = FALSE, r = TRUE;
- else if (!xmlStrcasecmp(c, (const xmlChar*) "no"))
- *value = FALSE, r = TRUE;
- else if (!xmlStrcasecmp(c, (const xmlChar*) "off"))
- *value = FALSE, r = TRUE;
- }
- xmlFree(c);
- return r;
-}
-
-gboolean parse_attr_int(const gchar *name, xmlNodePtr node, gint *value)
-{
- xmlChar *c = xmlGetProp(node, (const xmlChar*) name);
- gboolean r = FALSE;
- if (c) {
- *value = atoi((gchar*)c);
- r = TRUE;
- }
- xmlFree(c);
- return r;
-}
-
-gboolean parse_attr_string(const gchar *name, xmlNodePtr node, gchar **value)
-{
- xmlChar *c = xmlGetProp(node, (const xmlChar*) name);
- gboolean r = FALSE;
- if (c) {
- *value = g_strdup((gchar*)c);
- r = TRUE;
- }
- xmlFree(c);
- return r;
-}
-
-gboolean parse_attr_contains(const gchar *val, xmlNodePtr node,
- const gchar *name)
-{
- xmlChar *c = xmlGetProp(node, (const xmlChar*) name);
- gboolean r = FALSE;
- if (c)
- r = !xmlStrcasecmp(c, (const xmlChar*) val);
- xmlFree(c);
- return r;
-}
-
-static gint slist_path_cmp(const gchar *a, const gchar *b)
-{
- return strcmp(a, b);
-}
-
-typedef GSList* (*GSListFunc) (gpointer list, gconstpointer data);
-
-static GSList* slist_path_add(GSList *list, gpointer data, GSListFunc func)
-{
- g_assert(func);
-
- if (!data)
- return list;
-
- if (!g_slist_find_custom(list, data, (GCompareFunc) slist_path_cmp))
- list = func(list, data);
- else
- g_free(data);
-
- return list;
-}
-
-static GSList* split_paths(const gchar *paths)
-{
- GSList *list = NULL;
- gchar **spl, **it;
-
- if (!paths)
- return NULL;
- spl = g_strsplit(paths, ":", -1);
- for (it = spl; *it; ++it)
- list = slist_path_add(list, *it, (GSListFunc) g_slist_append);
- g_free(spl);
- return list;
-}
-
-void parse_paths_startup(void)
-{
- const gchar *path;
-
- if (xdg_start)
- return;
- xdg_start = TRUE;
-
- path = g_getenv("XDG_CONFIG_HOME");
- if (path && path[0] != '\0') /* not unset or empty */
- xdg_config_home_path = g_build_filename(path, NULL);
- else
- xdg_config_home_path = g_build_filename(g_get_home_dir(), ".config",
- NULL);
-
- path = g_getenv("XDG_DATA_HOME");
- if (path && path[0] != '\0') /* not unset or empty */
- xdg_data_home_path = g_build_filename(path, NULL);
- else
- xdg_data_home_path = g_build_filename(g_get_home_dir(), ".local",
- "share", NULL);
-
- path = g_getenv("XDG_CONFIG_DIRS");
- if (path && path[0] != '\0') /* not unset or empty */
- xdg_config_dir_paths = split_paths(path);
- else {
- xdg_config_dir_paths = slist_path_add(xdg_config_dir_paths,
- g_strdup(CONFIGDIR),
- (GSListFunc) g_slist_append);
- xdg_config_dir_paths = slist_path_add(xdg_config_dir_paths,
- g_build_filename
- (G_DIR_SEPARATOR_S,
- "etc", "xdg", NULL),
- (GSListFunc) g_slist_append);
- }
- xdg_config_dir_paths = slist_path_add(xdg_config_dir_paths,
- g_strdup(xdg_config_home_path),
- (GSListFunc) g_slist_prepend);
-
- path = g_getenv("XDG_DATA_DIRS");
- if (path && path[0] != '\0') /* not unset or empty */
- xdg_data_dir_paths = split_paths(path);
- else {
- xdg_data_dir_paths = slist_path_add(xdg_data_dir_paths,
- g_strdup(DATADIR),
- (GSListFunc) g_slist_append);
- xdg_data_dir_paths = slist_path_add(xdg_data_dir_paths,
- g_build_filename
- (G_DIR_SEPARATOR_S,
- "usr", "local", "share", NULL),
- (GSListFunc) g_slist_append);
- xdg_data_dir_paths = slist_path_add(xdg_data_dir_paths,
- g_build_filename
- (G_DIR_SEPARATOR_S,
- "usr", "share", NULL),
- (GSListFunc) g_slist_append);
- }
- xdg_data_dir_paths = slist_path_add(xdg_data_dir_paths,
- g_strdup(xdg_data_home_path),
- (GSListFunc) g_slist_prepend);
-}
-
-void parse_paths_shutdown(void)
-{
- GSList *it;
-
- if (!xdg_start)
- return;
- xdg_start = FALSE;
-
- for (it = xdg_config_dir_paths; it; it = g_slist_next(it))
- g_free(it->data);
- g_slist_free(xdg_config_dir_paths);
- xdg_config_dir_paths = NULL;
- for (it = xdg_data_dir_paths; it; it = g_slist_next(it))
- g_free(it->data);
- g_slist_free(xdg_data_dir_paths);
- xdg_data_dir_paths = NULL;
- g_free(xdg_config_home_path);
- xdg_config_home_path = NULL;
- g_free(xdg_data_home_path);
- xdg_data_home_path = NULL;
-}
-
-gchar *parse_expand_tilde(const gchar *f)
-{
- gchar **spl;
- gchar *ret;
-
- if (!f)
- return NULL;
- spl = g_strsplit(f, "~", 0);
- ret = g_strjoinv(g_get_home_dir(), spl);
- g_strfreev(spl);
- return ret;
-}
-
-gboolean parse_mkdir(const gchar *path, gint mode)
-{
- gboolean ret = TRUE;
-
- g_return_val_if_fail(path != NULL, FALSE);
- g_return_val_if_fail(path[0] != '\0', FALSE);
-
- if (!g_file_test(path, G_FILE_TEST_IS_DIR))
- if (mkdir(path, mode) == -1)
- ret = FALSE;
-
- return ret;
-}
-
-gboolean parse_mkdir_path(const gchar *path, gint mode)
-{
- gboolean ret = TRUE;
-
- g_return_val_if_fail(path != NULL, FALSE);
- g_return_val_if_fail(path[0] == '/', FALSE);
-
- if (!g_file_test(path, G_FILE_TEST_IS_DIR)) {
- gchar *c, *e;
-
- c = g_strdup(path);
- e = c;
- while ((e = strchr(e + 1, '/'))) {
- *e = '\0';
- if (!(ret = parse_mkdir(c, mode)))
- goto parse_mkdir_path_end;
- *e = '/';
- }
- ret = parse_mkdir(c, mode);
-
- parse_mkdir_path_end:
- g_free(c);
- }
-
- return ret;
-}
-
-const gchar* parse_xdg_config_home_path(void)
-{
- return xdg_config_home_path;
-}
-
-const gchar* parse_xdg_data_home_path(void)
-{
- return xdg_data_home_path;
-}
-
-GSList* parse_xdg_config_dir_paths(void)
-{
- return xdg_config_dir_paths;
-}
-
-GSList* parse_xdg_data_dir_paths(void)
-{
- return xdg_data_dir_paths;
-}
+++ /dev/null
-/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
-
- parse.h for the Openbox window manager
- Copyright (c) 2003-2007 Dana Jansens
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- See the COPYING file for a copy of the GNU General Public License.
-*/
-
-#ifndef __parse_h
-#define __parse_h
-
-#include "version.h"
-
-#include <libxml/parser.h>
-#include <glib.h>
-
-G_BEGIN_DECLS
-
-typedef struct _ObParseInst ObParseInst;
-
-typedef void (*ParseCallback)(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
- gpointer data);
-
-ObParseInst* parse_startup();
-void parse_shutdown(ObParseInst *inst);
-
-/*! Loads Openbox's rc, from the normal paths
- @type The configuration type to load, or NULL to use the default.
- e.g. "gnome" would load rc-gnome.xml.
- */
-gboolean parse_load_rc(const gchar *type, xmlDocPtr *doc, xmlNodePtr *root);
-/* Loads an Openbox menu, from the normal paths */
-gboolean parse_load_menu(const gchar *file, xmlDocPtr *doc, xmlNodePtr *root);
-/* Loads an Openbox theme, from the normal paths */
-gboolean parse_load_theme(const gchar *name, xmlDocPtr *doc, xmlNodePtr *root,
- gchar **path);
-
-void parse_register(ObParseInst *inst, const gchar *tag,
- ParseCallback func, gpointer data);
-void parse_tree(ObParseInst *inst, xmlDocPtr doc, xmlNodePtr node);
-
-
-/* open/close */
-
-gboolean parse_load(const gchar *path, const gchar *rootname,
- xmlDocPtr *doc, xmlNodePtr *root);
-gboolean parse_load_mem(gpointer data, guint len, const gchar *rootname,
- xmlDocPtr *doc, xmlNodePtr *root);
-void parse_close(xmlDocPtr doc);
-
-
-/* helpers */
-
-xmlNodePtr parse_find_node(const gchar *tag, xmlNodePtr node);
-
-gchar *parse_string(xmlDocPtr doc, xmlNodePtr node);
-gint parse_int(xmlDocPtr doc, xmlNodePtr node);
-gboolean parse_bool(xmlDocPtr doc, xmlNodePtr node);
-
-gboolean parse_contains(const gchar *val, xmlDocPtr doc, xmlNodePtr node);
-gboolean parse_attr_contains(const gchar *val, xmlNodePtr node,
- const gchar *name);
-
-gboolean parse_attr_string(const gchar *name, xmlNodePtr node, gchar **value);
-gboolean parse_attr_int(const gchar *name, xmlNodePtr node, gint *value);
-gboolean parse_attr_bool(const gchar *name, xmlNodePtr node, gboolean *value);
-
-/* paths */
-
-void parse_paths_startup();
-void parse_paths_shutdown();
-
-const gchar* parse_xdg_config_home_path();
-const gchar* parse_xdg_data_home_path();
-GSList* parse_xdg_config_dir_paths();
-GSList* parse_xdg_data_dir_paths();
-
-/*! Expands the ~ character to the home directory throughout the given
- string */
-gchar *parse_expand_tilde(const gchar *f);
-/*! Makes a directory */
-gboolean parse_mkdir(const gchar *path, gint mode);
-/*! Makes a directory and all its parents */
-gboolean parse_mkdir_path(const gchar *path, gint mode);
-
-G_END_DECLS
-
-#endif
#include "mask.h"
#include "theme.h"
#include "icon.h"
-#include "parser/parse.h"
+#include "obt/parse.h"
#include <X11/Xlib.h>
#include <X11/Xresource.h>