update openbox to use the current parser interface in libobt

there is also some random bug fixes for other libobt stuff in here.
This commit is contained in:
Dana Jansens 2007-07-27 01:37:28 -04:00
parent 0667bbc3e2
commit fdabb69f4f
38 changed files with 639 additions and 1414 deletions

View file

@ -24,7 +24,6 @@ check_PROGRAMS = \
render/rendertest render/rendertest
lib_LTLIBRARIES = \ lib_LTLIBRARIES = \
parser/libobparser.la \
render/libobrender.la \ render/libobrender.la \
obt/libobt.la obt/libobt.la
@ -45,7 +44,7 @@ render_rendertest_CPPFLAGS = \
$(GLIB_CFLAGS) \ $(GLIB_CFLAGS) \
-DG_LOG_DOMAIN=\"RenderTest\" -DG_LOG_DOMAIN=\"RenderTest\"
render_rendertest_LDADD = \ render_rendertest_LDADD = \
parser/libobparser.la \ obt/libobt.la \
render/libobrender.la \ render/libobrender.la \
$(GLIB_LIBS) \ $(GLIB_LIBS) \
$(PANGO_LIBS) \ $(PANGO_LIBS) \
@ -65,7 +64,7 @@ render_libobrender_la_CPPFLAGS = \
render_libobrender_la_LDFLAGS = \ render_libobrender_la_LDFLAGS = \
-version-info $(RR_CURRENT):$(RR_REVISION):$(RR_AGE) -version-info $(RR_CURRENT):$(RR_REVISION):$(RR_AGE)
render_libobrender_la_LIBADD = \ render_libobrender_la_LIBADD = \
parser/libobparser.la \ obt/libobt.la \
$(X_LIBS) \ $(X_LIBS) \
$(PANGO_LIBS) \ $(PANGO_LIBS) \
$(XFT_LIBS) \ $(XFT_LIBS) \
@ -92,24 +91,6 @@ render_libobrender_la_SOURCES = \
render/theme.h \ render/theme.h \
render/theme.c 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 ##
obt_libobt_la_CPPFLAGS = \ obt_libobt_la_CPPFLAGS = \
@ -173,7 +154,6 @@ openbox_openbox_LDADD = \
$(EFENCE_LIBS) \ $(EFENCE_LIBS) \
$(LIBINTL) \ $(LIBINTL) \
render/libobrender.la \ render/libobrender.la \
parser/libobparser.la \
obt/libobt.la obt/libobt.la
openbox_openbox_LDFLAGS = -export-dynamic openbox_openbox_LDFLAGS = -export-dynamic
openbox_openbox_SOURCES = \ openbox_openbox_SOURCES = \
@ -398,9 +378,16 @@ pubinclude_HEADERS = \
render/mask.h \ render/mask.h \
render/render.h \ render/render.h \
render/theme.h \ render/theme.h \
parser/parse.h \
obt/display.h \ obt/display.h \
obt/display.c \
obt/keyboard.h \
obt/keyboard.c \
obt/mainloop.h \ obt/mainloop.h \
obt/mainloop.c \
obt/parse.h \
obt/parse.c \
obt/prop.h \
obt/prop.c \
obt/util.h obt/util.h
nodist_pubinclude_HEADERS = \ nodist_pubinclude_HEADERS = \
@ -408,7 +395,6 @@ nodist_pubinclude_HEADERS = \
nodist_pkgconfig_DATA = \ nodist_pkgconfig_DATA = \
render/obrender-4.0.pc \ render/obrender-4.0.pc \
parser/obparser-4.0.pc \
obt/obt-4.0.pc obt/obt-4.0.pc
## data ## ## data ##
@ -469,7 +455,6 @@ dist_noinst_DATA = \
doc/openbox-kde-session.1.sgml \ doc/openbox-kde-session.1.sgml \
doc/openbox-kde-session.1.in \ doc/openbox-kde-session.1.in \
render/obrender-4.0.pc.in \ render/obrender-4.0.pc.in \
parser/obparser-4.0.pc.in \
obt/obt-4.0.pc.in \ obt/obt-4.0.pc.in \
tools/themeupdate/themeupdate.py \ tools/themeupdate/themeupdate.py \
tests/hideshow.py \ tests/hideshow.py \

View file

@ -179,7 +179,6 @@ AC_CONFIG_FILES([
m4/Makefile m4/Makefile
po/Makefile.in po/Makefile.in
render/obrender-4.0.pc render/obrender-4.0.pc
parser/obparser-4.0.pc
obt/obt-4.0.pc obt/obt-4.0.pc
version.h version.h
]) ])

View file

@ -62,7 +62,7 @@ static void destfunc(struct Callback *c)
g_free(c); g_free(c);
} }
ObtParseInst* obt_parse_instance_new() ObtParseInst* obt_parse_instance_new(void)
{ {
ObtParseInst *i = g_new(ObtParseInst, 1); ObtParseInst *i = g_new(ObtParseInst, 1);
i->ref = 1; i->ref = 1;
@ -87,8 +87,20 @@ void obt_parse_instance_unref(ObtParseInst *i)
} }
} }
void parse_register(ObtParseInst *i, const gchar *tag, xmlDocPtr obt_parse_instance_doc(ObtParseInst *i)
ObtParseCallback func, gpointer data) {
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; struct Callback *c;
@ -119,7 +131,10 @@ static gboolean load_file(ObtParseInst *i,
gchar *path; gchar *path;
struct stat s; 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) { if (stat(path, &s) >= 0) {
/* XML_PARSE_BLANKS is needed apparently, or the tree can end up /* XML_PARSE_BLANKS is needed apparently, or the tree can end up
@ -154,6 +169,24 @@ static gboolean load_file(ObtParseInst *i,
return r; 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, gboolean obt_parse_load_config_file(ObtParseInst *i,
const gchar *domain, const gchar *domain,
const gchar *filename, const gchar *filename,
@ -266,7 +299,7 @@ void obt_parse_tree(ObtParseInst *i, xmlNodePtr node)
while (node) { while (node) {
struct Callback *c = g_hash_table_lookup(i->callbacks, node->name); 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; node = node->next;
} }
} }
@ -415,7 +448,7 @@ static GSList* split_paths(const gchar *paths)
return list; return list;
} }
void parse_paths_startup() void parse_paths_startup(void)
{ {
const gchar *path; const gchar *path;
@ -477,7 +510,7 @@ void parse_paths_startup()
(GSListFunc) g_slist_prepend); (GSListFunc) g_slist_prepend);
} }
void parse_paths_shutdown() void parse_paths_shutdown(void)
{ {
GSList *it; GSList *it;
@ -553,22 +586,22 @@ gboolean parse_mkdir_path(const gchar *path, gint mode)
return ret; return ret;
} }
const gchar* parse_xdg_config_home_path() const gchar* parse_xdg_config_home_path(void)
{ {
return xdg_config_home_path; 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; return xdg_data_home_path;
} }
GSList* parse_xdg_config_dir_paths() GSList* parse_xdg_config_dir_paths(void)
{ {
return xdg_config_dir_paths; return xdg_config_dir_paths;
} }
GSList* parse_xdg_data_dir_paths() GSList* parse_xdg_data_dir_paths(void)
{ {
return xdg_data_dir_paths; return xdg_data_dir_paths;
} }

View file

@ -28,13 +28,15 @@ G_BEGIN_DECLS
typedef struct _ObtParseInst ObtParseInst; typedef struct _ObtParseInst ObtParseInst;
typedef void (*ObtParseCallback)(ObtParseInst *i, xmlDocPtr doc, typedef void (*ObtParseCallback)(xmlNodePtr node, gpointer data);
xmlNodePtr node, gpointer data);
ObtParseInst* obt_parse_instance_new(); ObtParseInst* obt_parse_instance_new();
void obt_parse_instance_ref(ObtParseInst *inst); void obt_parse_instance_ref(ObtParseInst *inst);
void obt_parse_instance_unref(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, gboolean obt_parse_load_config_file(ObtParseInst *inst,
const gchar *domain, const gchar *domain,
const gchar *filename, const gchar *filename,
@ -51,6 +53,9 @@ gboolean obt_parse_load_theme_file(ObtParseInst *inst,
gboolean obt_parse_load_mem(ObtParseInst *inst, gboolean obt_parse_load_mem(ObtParseInst *inst,
gpointer data, guint len, const gchar *root_node); 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_close(ObtParseInst *inst);
void obt_parse_register(ObtParseInst *inst, const gchar *tag, void obt_parse_register(ObtParseInst *inst, const gchar *tag,
@ -60,7 +65,7 @@ void obt_parse_tree(ObtParseInst *i, xmlNodePtr node);
/* helpers */ /* 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); gboolean obt_parse_node_contains (xmlNodePtr node, const gchar *val);
gchar *obt_parse_node_string (xmlNodePtr node); gchar *obt_parse_node_string (xmlNodePtr node);

View file

@ -410,12 +410,11 @@ void obt_prop_set_array32(Window win, Atom prop, Atom type, gulong *val,
void obt_prop_set_string_locale(Window win, Atom prop, const gchar *val) 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); obt_prop_set_strings_locale(win, prop, s);
} }
void obt_prop_set_strings_locale(Window win, Atom prop, void obt_prop_set_strings_locale(Window win, Atom prop, gchar const **strs)
const gchar **strs)
{ {
gint i, count; gint i, count;
gchar **lstrs; gchar **lstrs;
@ -445,10 +444,10 @@ void obt_prop_set_string_utf8(Window win, Atom prop, const gchar *val)
PropModeReplace, (const guchar*)val, strlen(val)); 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; GString *str;
const gchar **s; gchar const **s;
str = g_string_sized_new(0); str = g_string_sized_new(0);
for (s = strs; *s; ++s) { for (s = strs; *s; ++s) {

View file

@ -225,10 +225,8 @@ void obt_prop_set_array32(Window win, Atom prop, Atom type, gulong *val,
guint num); guint num);
void obt_prop_set_string_locale(Window win, Atom prop, const gchar *val); 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_string_utf8(Window win, Atom prop, const gchar *val);
void obt_prop_set_strings_locale(Window win, Atom prop, void obt_prop_set_strings_locale(Window win, Atom prop, gchar const **strs);
const gchar **strs); void obt_prop_set_strings_utf8(Window win, Atom prop, gchar const **strs);
void obt_prop_set_strings_utf8(Window win, Atom prop,
const gchar **strs);
void obt_prop_erase(Window win, Atom prop); void obt_prop_erase(Window win, Atom prop);

View file

@ -158,23 +158,21 @@ ObActionsAct* actions_parse_string(const gchar *name)
if ((act = actions_build_act_from_string(name))) if ((act = actions_build_act_from_string(name)))
if (act->def->setup) if (act->def->setup)
act->options = act->def->setup(NULL, NULL, NULL); act->options = act->def->setup(NULL);
return act; return act;
} }
ObActionsAct* actions_parse(ObParseInst *i, ObActionsAct* actions_parse(xmlNodePtr node)
xmlDocPtr doc,
xmlNodePtr node)
{ {
gchar *name; gchar *name;
ObActionsAct *act = NULL; 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))) if ((act = actions_build_act_from_string(name)))
/* there is more stuff to parse here */ /* there is more stuff to parse here */
if (act->def->setup) if (act->def->setup)
act->options = act->def->setup(i, doc, node->xmlChildrenNode); act->options = act->def->setup(node->xmlChildrenNode);
g_free(name); g_free(name);
} }

View file

@ -18,7 +18,8 @@
#include "misc.h" #include "misc.h"
#include "frame.h" #include "frame.h"
#include "parser/parse.h" #include "obt/parse.h"
#include <glib.h> #include <glib.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
@ -30,8 +31,7 @@ typedef struct _ObActionsGlobalData ObActionsGlobalData;
typedef struct _ObActionsClientData ObActionsClientData; typedef struct _ObActionsClientData ObActionsClientData;
typedef struct _ObActionsSelectorData ObActionsSelectorData; typedef struct _ObActionsSelectorData ObActionsSelectorData;
typedef gpointer (*ObActionsDataSetupFunc)(ObParseInst *i, typedef gpointer (*ObActionsDataSetupFunc)(xmlNodePtr node);
xmlDocPtr doc, xmlNodePtr node);
typedef void (*ObActionsDataFreeFunc)(gpointer options); typedef void (*ObActionsDataFreeFunc)(gpointer options);
typedef gboolean (*ObActionsRunFunc)(ObActionsData *data, typedef gboolean (*ObActionsRunFunc)(ObActionsData *data,
gpointer options); gpointer options);
@ -64,9 +64,7 @@ gboolean actions_register(const gchar *name,
ObActionsInteractiveInputFunc i_input, ObActionsInteractiveInputFunc i_input,
ObActionsInteractiveCancelFunc i_cancel); ObActionsInteractiveCancelFunc i_cancel);
ObActionsAct* actions_parse(ObParseInst *i, ObActionsAct* actions_parse(xmlNodePtr node);
xmlDocPtr doc,
xmlNodePtr node);
ObActionsAct* actions_parse_string(const gchar *name); ObActionsAct* actions_parse_string(const gchar *name);
gboolean actions_act_is_interactive(ObActionsAct *act); gboolean actions_act_is_interactive(ObActionsAct *act);

View file

@ -7,36 +7,28 @@ typedef struct {
gboolean add; gboolean add;
} Options; } Options;
static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node); static gpointer setup_func(xmlNodePtr node);
static gpointer setup_add_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node); static gpointer setup_add_func(xmlNodePtr node);
static gpointer setup_remove_func(ObParseInst *i, static gpointer setup_remove_func(xmlNodePtr node);
xmlDocPtr doc, xmlNodePtr node);
static void free_func(gpointer options);
static gboolean run_func(ObActionsData *data, gpointer options); static gboolean run_func(ObActionsData *data, gpointer options);
void action_addremovedesktop_startup(void) void action_addremovedesktop_startup(void)
{ {
actions_register("AddDesktop", actions_register("AddDesktop", setup_add_func, g_free, run_func,
setup_add_func,
free_func,
run_func,
NULL, NULL); NULL, NULL);
actions_register("RemoveDesktop", actions_register("RemoveDesktop", setup_remove_func, g_free, run_func,
setup_remove_func,
free_func,
run_func,
NULL, NULL); NULL, NULL);
} }
static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) static gpointer setup_func(xmlNodePtr node)
{ {
xmlNodePtr n; xmlNodePtr n;
Options *o; Options *o;
o = g_new0(Options, 1); o = g_new0(Options, 1);
if ((n = parse_find_node("where", node))) { if ((n = obt_parse_find_node(node, "where"))) {
gchar *s = parse_string(doc, n); gchar *s = obt_parse_node_string(n);
if (!g_ascii_strcasecmp(s, "last")) if (!g_ascii_strcasecmp(s, "last"))
o->current = FALSE; o->current = FALSE;
else if (!g_ascii_strcasecmp(s, "current")) else if (!g_ascii_strcasecmp(s, "current"))
@ -47,28 +39,20 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
return o; 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; o->add = TRUE;
return o; return o;
} }
static gpointer setup_remove_func(ObParseInst *i, static gpointer setup_remove_func(xmlNodePtr node)
xmlDocPtr doc, xmlNodePtr node)
{ {
Options *o = setup_func(i, doc, node); Options *o = setup_func(node);
o->add = FALSE; o->add = FALSE;
return o; return o;
} }
static void free_func(gpointer options)
{
Options *o = options;
g_free(o);
}
/* Always return FALSE because its not interactive */ /* Always return FALSE because its not interactive */
static gboolean run_func(ObActionsData *data, gpointer options) static gboolean run_func(ObActionsData *data, gpointer options)
{ {

View file

@ -20,11 +20,9 @@ typedef struct {
static gboolean cycling = FALSE; static gboolean cycling = FALSE;
static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node); static gpointer setup_func(xmlNodePtr node);
static gpointer setup_forward_func(ObParseInst *i, xmlDocPtr doc, static gpointer setup_forward_func(xmlNodePtr node);
xmlNodePtr node); static gpointer setup_backward_func(xmlNodePtr node);
static gpointer setup_backward_func(ObParseInst *i, xmlDocPtr doc,
xmlNodePtr node);
static void free_func(gpointer options); static void free_func(gpointer options);
static gboolean run_func(ObActionsData *data, gpointer options); static gboolean run_func(ObActionsData *data, gpointer options);
static gboolean i_input_func(guint initial_state, static gboolean i_input_func(guint initial_state,
@ -43,7 +41,7 @@ void action_cyclewindows_startup(void)
run_func, i_input_func, i_cancel_func); 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; xmlNodePtr n;
Options *o; Options *o;
@ -52,29 +50,29 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
o->dialog = TRUE; o->dialog = TRUE;
o->bar = TRUE; o->bar = TRUE;
if ((n = parse_find_node("linear", node))) if ((n = obt_parse_find_node(node, "linear")))
o->linear = parse_bool(doc, n); o->linear = obt_parse_node_bool(n);
if ((n = parse_find_node("dialog", node))) if ((n = obt_parse_find_node(node, "dialog")))
o->dialog = parse_bool(doc, n); o->dialog = obt_parse_node_bool(n);
if ((n = parse_find_node("bar", node))) if ((n = obt_parse_find_node(node, "bar")))
o->bar = parse_bool(doc, n); o->bar = obt_parse_node_bool(n);
if ((n = parse_find_node("raise", node))) if ((n = obt_parse_find_node(node, "raise")))
o->raise = parse_bool(doc, n); o->raise = obt_parse_node_bool(n);
if ((n = parse_find_node("panels", node))) if ((n = obt_parse_find_node(node, "panels")))
o->dock_windows = parse_bool(doc, n); o->dock_windows = obt_parse_node_bool(n);
if ((n = parse_find_node("desktop", node))) if ((n = obt_parse_find_node(node, "desktop")))
o->desktop_windows = parse_bool(doc, n); o->desktop_windows = obt_parse_node_bool(n);
if ((n = parse_find_node("allDesktops", node))) if ((n = obt_parse_find_node(node, "allDesktops")))
o->all_desktops = parse_bool(doc, n); o->all_desktops = obt_parse_node_bool(n);
if ((n = parse_find_node("finalactions", node))) { if ((n = obt_parse_find_node(node, "finalactions"))) {
xmlNodePtr m; xmlNodePtr m;
m = parse_find_node("action", n->xmlChildrenNode); m = obt_parse_find_node(n->xmlChildrenNode, "action");
while (m) { while (m) {
ObActionsAct *action = actions_parse(i, doc, m); ObActionsAct *action = actions_parse(m);
if (action) o->actions = g_slist_prepend(o->actions, action); 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 { else {
@ -89,18 +87,16 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
return o; return o;
} }
static gpointer setup_forward_func(ObParseInst *i, xmlDocPtr doc, static gpointer setup_forward_func(xmlNodePtr node)
xmlNodePtr node)
{ {
Options *o = setup_func(i, doc, node); Options *o = setup_func(node);
o->forward = TRUE; o->forward = TRUE;
return o; return o;
} }
static gpointer setup_backward_func(ObParseInst *i, xmlDocPtr doc, static gpointer setup_backward_func(xmlNodePtr node)
xmlNodePtr node)
{ {
Options *o = setup_func(i, doc, node); Options *o = setup_func(node);
o->forward = FALSE; o->forward = FALSE;
return o; return o;
} }

View file

@ -5,39 +5,32 @@ typedef struct {
gchar *str; gchar *str;
} Options; } Options;
static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node); static gpointer setup_func(xmlNodePtr node);
static void free_func(gpointer options); static void free_func(gpointer options);
static gboolean run_func(ObActionsData *data, gpointer options); static gboolean run_func(ObActionsData *data, gpointer options);
void action_debug_startup(void) void action_debug_startup(void)
{ {
actions_register("Debug", actions_register("Debug", setup_func, free_func, run_func, NULL, NULL);
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; xmlNodePtr n;
Options *o; Options *o;
o = g_new0(Options, 1); o = g_new0(Options, 1);
if ((n = parse_find_node("string", node))) if ((n = obt_parse_find_node(node, "string")))
o->str = parse_string(doc, n); o->str = obt_parse_node_string(n);
return o; return o;
} }
static void free_func(gpointer options) static void free_func(gpointer options)
{ {
Options *o = options; Options *o = options;
g_free(o->str);
if (o) { g_free(o);
g_free(o->str);
g_free(o);
}
} }
/* Always return FALSE because its not interactive */ /* Always return FALSE because its not interactive */

View file

@ -26,10 +26,8 @@ typedef struct {
gboolean follow; gboolean follow;
} Options; } Options;
static gpointer setup_go_func(ObParseInst *i, xmlDocPtr doc, static gpointer setup_go_func(xmlNodePtr node);
xmlNodePtr node); static gpointer setup_send_func(xmlNodePtr node);
static gpointer setup_send_func(ObParseInst *i, xmlDocPtr doc,
xmlNodePtr node);
static gboolean run_func(ObActionsData *data, gpointer options); static gboolean run_func(ObActionsData *data, gpointer options);
void action_desktop_startup(void) void action_desktop_startup(void)
@ -40,8 +38,7 @@ void action_desktop_startup(void)
NULL, NULL); NULL, NULL);
} }
static gpointer setup_go_func(ObParseInst *i, xmlDocPtr doc, static gpointer setup_go_func(xmlNodePtr node)
xmlNodePtr node)
{ {
xmlNodePtr n; xmlNodePtr n;
Options *o; Options *o;
@ -53,8 +50,8 @@ static gpointer setup_go_func(ObParseInst *i, xmlDocPtr doc,
/* wrap by default - it's handy! */ /* wrap by default - it's handy! */
o->rel.wrap = TRUE; o->rel.wrap = TRUE;
if ((n = parse_find_node("to", node))) { if ((n = obt_parse_find_node(node, "to"))) {
gchar *s = parse_string(doc, n); gchar *s = obt_parse_node_string(n);
if (!g_ascii_strcasecmp(s, "last")) if (!g_ascii_strcasecmp(s, "last"))
o->type = LAST; o->type = LAST;
else if (!g_ascii_strcasecmp(s, "next")) { else if (!g_ascii_strcasecmp(s, "next")) {
@ -89,29 +86,28 @@ static gpointer setup_go_func(ObParseInst *i, xmlDocPtr doc,
} }
else { else {
o->type = ABSOLUTE; o->type = ABSOLUTE;
o->abs.desktop = parse_int(doc, n) - 1; o->abs.desktop = obt_parse_node_int(n) - 1;
} }
g_free(s); g_free(s);
} }
if ((n = parse_find_node("wrap", node))) if ((n = obt_parse_find_node(node, "wrap")))
o->rel.wrap = parse_bool(doc, n); o->rel.wrap = obt_parse_node_bool(n);
return o; return o;
} }
static gpointer setup_send_func(ObParseInst *i, xmlDocPtr doc, static gpointer setup_send_func(xmlNodePtr node)
xmlNodePtr node)
{ {
xmlNodePtr n; xmlNodePtr n;
Options *o; Options *o;
o = setup_go_func(i, doc, node); o = setup_go_func(node);
o->send = TRUE; o->send = TRUE;
o->follow = TRUE; o->follow = TRUE;
if ((n = parse_find_node("follow", node))) if ((n = obt_parse_find_node(node, "follow")))
o->follow = parse_bool(doc, n); o->follow = obt_parse_node_bool(n);
return o; return o;
} }

View file

@ -20,11 +20,9 @@ typedef struct {
static gboolean cycling = FALSE; static gboolean cycling = FALSE;
static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node); static gpointer setup_func(xmlNodePtr node);
static gpointer setup_cycle_func(ObParseInst *i, xmlDocPtr doc, static gpointer setup_cycle_func(xmlNodePtr node);
xmlNodePtr node); static gpointer setup_target_func(xmlNodePtr node);
static gpointer setup_target_func(ObParseInst *i, xmlDocPtr doc,
xmlNodePtr node);
static void free_func(gpointer options); static void free_func(gpointer options);
static gboolean run_func(ObActionsData *data, gpointer options); static gboolean run_func(ObActionsData *data, gpointer options);
static gboolean i_input_func(guint initial_state, static gboolean i_input_func(guint initial_state,
@ -43,7 +41,7 @@ void action_directionalwindows_startup(void)
run_func, NULL, NULL); run_func, NULL, NULL);
} }
static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) static gpointer setup_func(xmlNodePtr node)
{ {
xmlNodePtr n; xmlNodePtr n;
Options *o; Options *o;
@ -52,18 +50,18 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
o->dialog = TRUE; o->dialog = TRUE;
o->bar = TRUE; o->bar = TRUE;
if ((n = parse_find_node("dialog", node))) if ((n = obt_parse_find_node(node, "dialog")))
o->dialog = parse_bool(doc, n); o->dialog = obt_parse_node_bool(n);
if ((n = parse_find_node("bar", node))) if ((n = obt_parse_find_node(node, "bar")))
o->bar = parse_bool(doc, n); o->bar = obt_parse_node_bool(n);
if ((n = parse_find_node("raise", node))) if ((n = obt_parse_find_node(node, "raise")))
o->raise = parse_bool(doc, n); o->raise = obt_parse_node_bool(n);
if ((n = parse_find_node("panels", node))) if ((n = obt_parse_find_node(node, "panels")))
o->dock_windows = parse_bool(doc, n); o->dock_windows = obt_parse_node_bool(n);
if ((n = parse_find_node("desktop", node))) if ((n = obt_parse_find_node(node, "desktop")))
o->desktop_windows = parse_bool(doc, n); o->desktop_windows = obt_parse_node_bool(n);
if ((n = parse_find_node("direction", node))) { if ((n = obt_parse_find_node(node, "direction"))) {
gchar *s = parse_string(doc, n); gchar *s = obt_parse_node_string(n);
if (!g_ascii_strcasecmp(s, "north") || if (!g_ascii_strcasecmp(s, "north") ||
!g_ascii_strcasecmp(s, "up")) !g_ascii_strcasecmp(s, "up"))
o->direction = OB_DIRECTION_NORTH; o->direction = OB_DIRECTION_NORTH;
@ -87,14 +85,14 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
g_free(s); g_free(s);
} }
if ((n = parse_find_node("finalactions", node))) { if ((n = obt_parse_find_node(node, "finalactions"))) {
xmlNodePtr m; xmlNodePtr m;
m = parse_find_node("action", n->xmlChildrenNode); m = obt_parse_find_node(n->xmlChildrenNode, "action");
while (m) { while (m) {
ObActionsAct *action = actions_parse(i, doc, m); ObActionsAct *action = actions_parse(m);
if (action) o->actions = g_slist_prepend(o->actions, action); 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 { else {
@ -109,18 +107,16 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
return o; return o;
} }
static gpointer setup_cycle_func(ObParseInst *i, xmlDocPtr doc, static gpointer setup_cycle_func(xmlNodePtr node)
xmlNodePtr node)
{ {
Options *o = setup_func(i, doc, node); Options *o = setup_func(node);
o->interactive = TRUE; o->interactive = TRUE;
return o; return o;
} }
static gpointer setup_target_func(ObParseInst *i, xmlDocPtr doc, static gpointer setup_target_func(xmlNodePtr node)
xmlNodePtr node)
{ {
Options *o = setup_func(i, doc, node); Options *o = setup_func(node);
o->interactive = FALSE; o->interactive = FALSE;
return o; return o;
} }

View file

@ -12,7 +12,7 @@ typedef struct {
gchar *sn_wmclass; gchar *sn_wmclass;
} Options; } Options;
static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node); static gpointer setup_func(xmlNodePtr node);
static void free_func(gpointer options); static void free_func(gpointer options);
static gboolean run_func(ObActionsData *data, gpointer options); static gboolean run_func(ObActionsData *data, gpointer options);
/* /*
@ -25,38 +25,34 @@ static void i_cancel_func(gpointer options);
void action_execute_startup(void) void action_execute_startup(void)
{ {
actions_register("Execute", actions_register("Execute", setup_func, free_func, run_func, NULL, NULL);
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; xmlNodePtr n;
Options *o; Options *o;
o = g_new0(Options, 1); o = g_new0(Options, 1);
if ((n = parse_find_node("command", node)) || if ((n = obt_parse_find_node(node, "command")) ||
(n = parse_find_node("execute", node))) (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); o->cmd = parse_expand_tilde(s);
g_free(s); g_free(s);
} }
if ((n = parse_find_node("startupnotify", node))) { if ((n = obt_parse_find_node(node, "startupnotify"))) {
xmlNodePtr m; xmlNodePtr m;
if ((m = parse_find_node("enabled", n->xmlChildrenNode))) if ((m = obt_parse_find_node(n->xmlChildrenNode, "enabled")))
o->sn = parse_bool(doc, m); o->sn = obt_parse_node_bool(m);
if ((m = parse_find_node("name", n->xmlChildrenNode))) if ((m = obt_parse_find_node(n->xmlChildrenNode, "name")))
o->sn_name = parse_string(doc, m); o->sn_name = obt_parse_node_string(m);
if ((m = parse_find_node("icon", n->xmlChildrenNode))) if ((m = obt_parse_find_node(n->xmlChildrenNode, "icon")))
o->sn_icon = parse_string(doc, m); o->sn_icon = obt_parse_node_string(m);
if ((m = parse_find_node("wmclass", n->xmlChildrenNode))) if ((m = obt_parse_find_node(n->xmlChildrenNode, "wmclass")))
o->sn_wmclass = parse_string(doc, m); o->sn_wmclass = obt_parse_node_string(m);
} }
return o; return o;
} }

View file

@ -7,38 +7,26 @@ typedef struct {
gboolean here; gboolean here;
} Options; } 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); static gboolean run_func(ObActionsData *data, gpointer options);
void action_focus_startup(void) void action_focus_startup(void)
{ {
actions_register("Focus", actions_register("Focus", setup_func, g_free, run_func, NULL, NULL);
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; xmlNodePtr n;
Options *o; Options *o;
o = g_new0(Options, 1); o = g_new0(Options, 1);
if ((n = parse_find_node("here", node))) if ((n = obt_parse_find_node(node, "here")))
o->here = parse_bool(doc, n); o->here = obt_parse_node_bool(n);
return o; return o;
} }
static void free_func(gpointer options)
{
Options *o = options;
g_free(o);
}
/* Always return FALSE because its not interactive */ /* Always return FALSE because its not interactive */
static gboolean run_func(ObActionsData *data, gpointer options) static gboolean run_func(ObActionsData *data, gpointer options)
{ {

View file

@ -10,27 +10,19 @@ typedef struct {
gboolean shrink; gboolean shrink;
} Options; } Options;
static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node); static gpointer setup_func(xmlNodePtr node);
static gpointer setup_shrink_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node); static gpointer setup_shrink_func(xmlNodePtr node);
static void free_func(gpointer options);
static gboolean run_func(ObActionsData *data, gpointer options); static gboolean run_func(ObActionsData *data, gpointer options);
void action_growtoedge_startup(void) void action_growtoedge_startup(void)
{ {
actions_register("GrowToEdge", actions_register("GrowToEdge", setup_func,
setup_func, g_free, run_func, NULL, NULL);
free_func, actions_register("ShrinkToEdge", setup_shrink_func,
run_func, g_free, run_func, NULL, NULL);
NULL, NULL);
actions_register("ShrinkToEdge",
setup_shrink_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; xmlNodePtr n;
Options *o; Options *o;
@ -39,8 +31,8 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
o->dir = OB_DIRECTION_NORTH; o->dir = OB_DIRECTION_NORTH;
o->shrink = FALSE; o->shrink = FALSE;
if ((n = parse_find_node("direction", node))) { if ((n = obt_parse_find_node(node, "direction"))) {
gchar *s = parse_string(doc, n); gchar *s = obt_parse_node_string(n);
if (!g_ascii_strcasecmp(s, "north") || if (!g_ascii_strcasecmp(s, "north") ||
!g_ascii_strcasecmp(s, "up")) !g_ascii_strcasecmp(s, "up"))
o->dir = OB_DIRECTION_NORTH; o->dir = OB_DIRECTION_NORTH;
@ -59,23 +51,16 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
return o; return o;
} }
static gpointer setup_shrink_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) static gpointer setup_shrink_func(xmlNodePtr node)
{ {
Options *o; Options *o;
o = setup_func(i, doc, node); o = setup_func(node);
o->shrink = TRUE; o->shrink = TRUE;
return o; 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) static gboolean do_grow(ObActionsData *data, gint x, gint y, gint w, gint h)
{ {
gint realw, realh, lw, lh; gint realw, realh, lw, lh;

View file

@ -23,81 +23,77 @@ typedef struct {
GSList *elseacts; GSList *elseacts;
} Options; } Options;
static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node); static gpointer setup_func(xmlNodePtr node);
static void free_func(gpointer options); static void free_func(gpointer options);
static gboolean run_func(ObActionsData *data, gpointer options); static gboolean run_func(ObActionsData *data, gpointer options);
void action_if_startup(void) void action_if_startup(void)
{ {
actions_register("If", actions_register("If", setup_func, free_func, run_func, NULL, NULL);
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; xmlNodePtr n;
Options *o; Options *o;
o = g_new0(Options, 1); o = g_new0(Options, 1);
if ((n = parse_find_node("shaded", node))) { if ((n = obt_parse_find_node(node, "shaded"))) {
if (parse_bool(doc, n)) if (obt_parse_node_bool(n))
o->shaded_on = TRUE; o->shaded_on = TRUE;
else else
o->shaded_off = TRUE; o->shaded_off = TRUE;
} }
if ((n = parse_find_node("maximized", node))) { if ((n = obt_parse_find_node(node, "maximized"))) {
if (parse_bool(doc, n)) if (obt_parse_node_bool(n))
o->maxfull_on = TRUE; o->maxfull_on = TRUE;
else else
o->maxfull_off = TRUE; o->maxfull_off = TRUE;
} }
if ((n = parse_find_node("maximizedhorizontal", node))) { if ((n = obt_parse_find_node(node, "maximizedhorizontal"))) {
if (parse_bool(doc, n)) if (obt_parse_node_bool(n))
o->maxhorz_on = TRUE; o->maxhorz_on = TRUE;
else else
o->maxhorz_off = TRUE; o->maxhorz_off = TRUE;
} }
if ((n = parse_find_node("maximizedvertical", node))) { if ((n = obt_parse_find_node(node, "maximizedvertical"))) {
if (parse_bool(doc, n)) if (obt_parse_node_bool(n))
o->maxvert_on = TRUE; o->maxvert_on = TRUE;
else else
o->maxvert_off = TRUE; o->maxvert_off = TRUE;
} }
if ((n = parse_find_node("iconified", node))) { if ((n = obt_parse_find_node(node, "iconified"))) {
if (parse_bool(doc, n)) if (obt_parse_node_bool(n))
o->iconic_on = TRUE; o->iconic_on = TRUE;
else else
o->iconic_off = TRUE; o->iconic_off = TRUE;
} }
if ((n = parse_find_node("focused", node))) { if ((n = obt_parse_find_node(node, "focused"))) {
if (parse_bool(doc, n)) if (obt_parse_node_bool(n))
o->focused = TRUE; o->focused = TRUE;
else else
o->unfocused = TRUE; o->unfocused = TRUE;
} }
if ((n = parse_find_node("then", node))) { if ((n = obt_parse_find_node(node, "then"))) {
xmlNodePtr m; xmlNodePtr m;
m = parse_find_node("action", n->xmlChildrenNode); m = obt_parse_find_node(n->xmlChildrenNode, "action");
while (m) { while (m) {
ObActionsAct *action = actions_parse(i, doc, m); ObActionsAct *action = actions_parse(m);
if (action) o->thenacts = g_slist_prepend(o->thenacts, action); 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; xmlNodePtr m;
m = parse_find_node("action", n->xmlChildrenNode); m = obt_parse_find_node(n->xmlChildrenNode, "action");
while (m) { while (m) {
ObActionsAct *action = actions_parse(i, doc, m); ObActionsAct *action = actions_parse(m);
if (action) o->elseacts = g_slist_prepend(o->elseacts, action); 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");
} }
} }
@ -108,6 +104,15 @@ static void free_func(gpointer options)
{ {
Options *o = options; 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); g_free(o);
} }

View file

@ -6,11 +6,9 @@ typedef struct {
gboolean toggle; gboolean toggle;
} Options; } Options;
static gpointer setup_func_top(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node); static gpointer setup_func_top(xmlNodePtr node);
static gpointer setup_func_bottom(ObParseInst *i, xmlDocPtr doc, static gpointer setup_func_bottom(xmlNodePtr node);
xmlNodePtr node); static gpointer setup_func_send(xmlNodePtr node);
static gpointer setup_func_send(ObParseInst *i, xmlDocPtr doc,
xmlNodePtr node);
static gboolean run_func(ObActionsData *data, gpointer options); static gboolean run_func(ObActionsData *data, gpointer options);
void action_layer_startup(void) void action_layer_startup(void)
@ -23,7 +21,7 @@ void action_layer_startup(void)
run_func, NULL, NULL); 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); Options *o = g_new0(Options, 1);
o->layer = 1; o->layer = 1;
@ -31,8 +29,7 @@ static gpointer setup_func_top(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
return o; return o;
} }
static gpointer setup_func_bottom(ObParseInst *i, xmlDocPtr doc, static gpointer setup_func_bottom(xmlNodePtr node)
xmlNodePtr node)
{ {
Options *o = g_new0(Options, 1); Options *o = g_new0(Options, 1);
o->layer = -1; o->layer = -1;
@ -40,16 +37,15 @@ static gpointer setup_func_bottom(ObParseInst *i, xmlDocPtr doc,
return o; return o;
} }
static gpointer setup_func_send(ObParseInst *i, xmlDocPtr doc, static gpointer setup_func_send(xmlNodePtr node)
xmlNodePtr node)
{ {
xmlNodePtr n; xmlNodePtr n;
Options *o; Options *o;
o = g_new0(Options, 1); o = g_new0(Options, 1);
if ((n = parse_find_node("layer", node))) { if ((n = obt_parse_find_node(node, "layer"))) {
gchar *s = parse_string(doc, n); gchar *s = obt_parse_node_string(n);
if (!g_ascii_strcasecmp(s, "above") || if (!g_ascii_strcasecmp(s, "above") ||
!g_ascii_strcasecmp(s, "top")) !g_ascii_strcasecmp(s, "top"))
o->layer = 1; o->layer = 1;

View file

@ -12,7 +12,7 @@ typedef struct {
MaxDirection dir; MaxDirection dir;
} Options; } 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_on(ObActionsData *data, gpointer options);
static gboolean run_func_off(ObActionsData *data, gpointer options); static gboolean run_func_off(ObActionsData *data, gpointer options);
static gboolean run_func_toggle(ObActionsData *data, gpointer options); static gboolean run_func_toggle(ObActionsData *data, gpointer options);
@ -27,7 +27,7 @@ void action_maximize_startup(void)
NULL, NULL); NULL, NULL);
} }
static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) static gpointer setup_func(xmlNodePtr node)
{ {
xmlNodePtr n; xmlNodePtr n;
Options *o; Options *o;
@ -35,8 +35,8 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
o = g_new0(Options, 1); o = g_new0(Options, 1);
o->dir = BOTH; o->dir = BOTH;
if ((n = parse_find_node("direction", node))) { if ((n = obt_parse_find_node(node, "direction"))) {
gchar *s = parse_string(doc, n); gchar *s = obt_parse_node_string(n);
if (!g_ascii_strcasecmp(s, "vertical") || if (!g_ascii_strcasecmp(s, "vertical") ||
!g_ascii_strcasecmp(s, "vert")) !g_ascii_strcasecmp(s, "vert"))
o->dir = VERT; o->dir = VERT;

View file

@ -9,41 +9,29 @@ typedef struct {
gint y; gint y;
} Options; } 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); static gboolean run_func(ObActionsData *data, gpointer options);
void action_moverelative_startup(void) void action_moverelative_startup(void)
{ {
actions_register("MoveRelative", actions_register("MoveRelative", setup_func, g_free, run_func, NULL, NULL);
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; xmlNodePtr n;
Options *o; Options *o;
o = g_new0(Options, 1); o = g_new0(Options, 1);
if ((n = parse_find_node("x", node))) if ((n = obt_parse_find_node(node, "x")))
o->x = parse_int(doc, n); o->x = obt_parse_node_int(n);
if ((n = parse_find_node("y", node))) if ((n = obt_parse_find_node(node, "y")))
o->y = parse_int(doc, n); o->y = obt_parse_node_int(n);
return o; return o;
} }
static void free_func(gpointer options)
{
Options *o = options;
g_free(o);
}
/* Always return FALSE because its not interactive */ /* Always return FALSE because its not interactive */
static gboolean run_func(ObActionsData *data, gpointer options) static gboolean run_func(ObActionsData *data, gpointer options)
{ {

View file

@ -21,23 +21,18 @@ typedef struct {
gint monitor; gint monitor;
} Options; } 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); static gboolean run_func(ObActionsData *data, gpointer options);
void action_moveresizeto_startup(void) void action_moveresizeto_startup(void)
{ {
actions_register("MoveResizeTo", actions_register("MoveResizeTo", setup_func, g_free, run_func, NULL, NULL);
setup_func,
free_func,
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) 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, "current") != 0) {
if (!g_ascii_strcasecmp(s, "center")) if (!g_ascii_strcasecmp(s, "center"))
*center = TRUE; *center = TRUE;
@ -53,7 +48,7 @@ static void parse_coord(xmlDocPtr doc, xmlNodePtr n, gint *pos,
g_free(s); g_free(s);
} }
static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) static gpointer setup_func(xmlNodePtr node)
{ {
xmlNodePtr n; xmlNodePtr n;
Options *o; Options *o;
@ -65,32 +60,32 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
o->h = G_MININT; o->h = G_MININT;
o->monitor = CURRENT_MONITOR; o->monitor = CURRENT_MONITOR;
if ((n = parse_find_node("x", node))) if ((n = obt_parse_find_node(node, "x")))
parse_coord(doc, n, &o->x, &o->xopposite, &o->xcenter); parse_coord(n, &o->x, &o->xopposite, &o->xcenter);
if ((n = parse_find_node("y", node))) if ((n = obt_parse_find_node(node, "y")))
parse_coord(doc, n, &o->y, &o->yopposite, &o->ycenter); parse_coord(n, &o->y, &o->yopposite, &o->ycenter);
if ((n = parse_find_node("width", node))) { if ((n = obt_parse_find_node(node, "width"))) {
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, "current") != 0)
o->w = parse_int(doc, n); o->w = obt_parse_node_int(n);
g_free(s); g_free(s);
} }
if ((n = parse_find_node("height", node))) { if ((n = obt_parse_find_node(node, "height"))) {
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, "current") != 0)
o->h = parse_int(doc, n); o->h = obt_parse_node_int(n);
g_free(s); g_free(s);
} }
if ((n = parse_find_node("monitor", node))) { if ((n = obt_parse_find_node(node, "monitor"))) {
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, "current") != 0) {
if (!g_ascii_strcasecmp(s, "all")) if (!g_ascii_strcasecmp(s, "all"))
o->monitor = ALL_MONITORS; o->monitor = ALL_MONITORS;
else else
o->monitor = parse_int(doc, n) - 1; o->monitor = obt_parse_node_int(n) - 1;
} }
g_free(s); g_free(s);
} }
@ -98,13 +93,6 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
return o; return o;
} }
static void free_func(gpointer options)
{
Options *o = options;
g_free(o);
}
/* Always return FALSE because its not interactive */ /* Always return FALSE because its not interactive */
static gboolean run_func(ObActionsData *data, gpointer options) static gboolean run_func(ObActionsData *data, gpointer options)
{ {

View file

@ -9,20 +9,15 @@ typedef struct {
ObDirection dir; ObDirection dir;
} Options; } 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); static gboolean run_func(ObActionsData *data, gpointer options);
void action_movetoedge_startup(void) void action_movetoedge_startup(void)
{ {
actions_register("MoveToEdge", actions_register("MoveToEdge", setup_func, g_free, run_func, NULL, NULL);
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; xmlNodePtr n;
Options *o; Options *o;
@ -30,8 +25,8 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
o = g_new0(Options, 1); o = g_new0(Options, 1);
o->dir = OB_DIRECTION_NORTH; o->dir = OB_DIRECTION_NORTH;
if ((n = parse_find_node("direction", node))) { if ((n = obt_parse_find_node(node, "direction"))) {
gchar *s = parse_string(doc, n); gchar *s = obt_parse_node_string(n);
if (!g_ascii_strcasecmp(s, "north") || if (!g_ascii_strcasecmp(s, "north") ||
!g_ascii_strcasecmp(s, "up")) !g_ascii_strcasecmp(s, "up"))
o->dir = OB_DIRECTION_NORTH; o->dir = OB_DIRECTION_NORTH;
@ -50,13 +45,6 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
return o; return o;
} }
static void free_func(gpointer options)
{
Options *o = options;
g_free(o);
}
/* Always return FALSE because its not interactive */ /* Always return FALSE because its not interactive */
static gboolean run_func(ObActionsData *data, gpointer options) static gboolean run_func(ObActionsData *data, gpointer options)
{ {

View file

@ -9,8 +9,7 @@ typedef struct {
guint32 corner; guint32 corner;
} Options; } 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); static gboolean run_func(ObActionsData *data, gpointer options);
static guint32 pick_corner(gint x, gint y, gint cx, gint cy, gint cw, gint ch, static guint32 pick_corner(gint x, gint y, gint cx, gint cy, gint cw, gint ch,
@ -18,22 +17,18 @@ static guint32 pick_corner(gint x, gint y, gint cx, gint cy, gint cw, gint ch,
void action_resize_startup(void) void action_resize_startup(void)
{ {
actions_register("Resize", actions_register("Resize", setup_func, g_free, run_func, NULL, NULL);
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; xmlNodePtr n;
Options *o; Options *o;
o = g_new0(Options, 1); o = g_new0(Options, 1);
if ((n = parse_find_node("edge", node))) { if ((n = obt_parse_find_node(node, "edge"))) {
gchar *s = parse_string(doc, n); gchar *s = obt_parse_node_string(n);
o->corner_specified = TRUE; o->corner_specified = TRUE;
if (!g_ascii_strcasecmp(s, "top")) if (!g_ascii_strcasecmp(s, "top"))
@ -60,13 +55,6 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
return o; return o;
} }
static void free_func(gpointer options)
{
Options *o = options;
g_free(o);
}
/* Always return FALSE because its not interactive */ /* Always return FALSE because its not interactive */
static gboolean run_func(ObActionsData *data, gpointer options) static gboolean run_func(ObActionsData *data, gpointer options)
{ {

View file

@ -11,47 +11,36 @@ typedef struct {
gint bottom; gint bottom;
} Options; } 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); static gboolean run_func(ObActionsData *data, gpointer options);
void action_resizerelative_startup(void) void action_resizerelative_startup(void)
{ {
actions_register("ResizeRelative", actions_register("ResizeRelative", setup_func, g_free, run_func,
setup_func,
free_func,
run_func,
NULL, NULL); NULL, NULL);
} }
static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) static gpointer setup_func(xmlNodePtr node)
{ {
xmlNodePtr n; xmlNodePtr n;
Options *o; Options *o;
o = g_new0(Options, 1); o = g_new0(Options, 1);
if ((n = parse_find_node("left", node))) if ((n = obt_parse_find_node(node, "left")))
o->left = parse_int(doc, n); o->left = obt_parse_node_int(n);
if ((n = parse_find_node("right", node))) if ((n = obt_parse_find_node(node, "right")))
o->right = parse_int(doc, n); o->right = obt_parse_node_int(n);
if ((n = parse_find_node("top", node)) || if ((n = obt_parse_find_node(node, "top")) ||
(n = parse_find_node("up", node))) (n = obt_parse_find_node(node, "up")))
o->top = parse_int(doc, n); o->top = obt_parse_node_int(n);
if ((n = parse_find_node("bottom", node)) || if ((n = obt_parse_find_node(node, "bottom")) ||
(n = parse_find_node("down", node))) (n = obt_parse_find_node(node, "down")))
o->bottom = parse_int(doc, n); o->bottom = obt_parse_node_int(n);
return o; return o;
} }
static void free_func(gpointer options)
{
Options *o = options;
g_free(o);
}
/* Always return FALSE because its not interactive */ /* Always return FALSE because its not interactive */
static gboolean run_func(ObActionsData *data, gpointer options) static gboolean run_func(ObActionsData *data, gpointer options)
{ {

View file

@ -5,30 +5,26 @@ typedef struct {
gchar *cmd; gchar *cmd;
} Options; } Options;
static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node); static gpointer setup_func(xmlNodePtr node);
static void free_func(gpointer options); static void free_func(gpointer options);
static gboolean run_func(ObActionsData *data, gpointer options); static gboolean run_func(ObActionsData *data, gpointer options);
void action_restart_startup(void) void action_restart_startup(void)
{ {
actions_register("Restart", actions_register("Restart", setup_func, free_func, run_func, NULL, NULL);
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; xmlNodePtr n;
Options *o; Options *o;
o = g_new0(Options, 1); o = g_new0(Options, 1);
if ((n = parse_find_node("command", node)) || if ((n = obt_parse_find_node(node, "command")) ||
(n = parse_find_node("execute", node))) (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); o->cmd = parse_expand_tilde(s);
g_free(s); g_free(s);
} }
@ -38,11 +34,8 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
static void free_func(gpointer options) static void free_func(gpointer options)
{ {
Options *o = options; Options *o = options;
g_free(o->cmd);
if (o) { g_free(o);
g_free(o->cmd);
g_free(o);
}
} }
/* Always return FALSE because its not interactive */ /* Always return FALSE because its not interactive */

View file

@ -6,7 +6,7 @@ typedef struct {
gchar *name; gchar *name;
} Options; } Options;
static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node); static gpointer setup_func(xmlNodePtr node);
static void free_func(gpointer options); static void free_func(gpointer options);
static gboolean run_func(ObActionsData *data, gpointer options); static gboolean run_func(ObActionsData *data, gpointer options);
@ -16,15 +16,15 @@ void action_showmenu_startup(void)
NULL, NULL); NULL, NULL);
} }
static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) static gpointer setup_func(xmlNodePtr node)
{ {
xmlNodePtr n; xmlNodePtr n;
Options *o; Options *o;
o = g_new0(Options, 1); o = g_new0(Options, 1);
if ((n = parse_find_node("menu", node))) if ((n = obt_parse_find_node(node, "menu")))
o->name = parse_string(doc, n); o->name = obt_parse_node_string(n);
return o; return o;
} }

View file

@ -24,7 +24,6 @@
#include "translate.h" #include "translate.h"
#include "client.h" #include "client.h"
#include "screen.h" #include "screen.h"
#include "parser/parse.h"
#include "openbox.h" #include "openbox.h"
#include "gettext.h" #include "gettext.h"
@ -141,10 +140,9 @@ void config_app_settings_copy_non_defaults(const ObAppSettings *src,
} }
} }
static void config_parse_gravity_coord(xmlDocPtr doc, xmlNodePtr node, static void config_parse_gravity_coord(xmlNodePtr node, GravityCoord *c)
GravityCoord *c)
{ {
gchar *s = parse_string(doc, node); gchar *s = obt_parse_node_string(node);
if (!g_ascii_strcasecmp(s, "center")) if (!g_ascii_strcasecmp(s, "center"))
c->center = TRUE; c->center = TRUE;
else { else {
@ -186,10 +184,9 @@ static void config_parse_gravity_coord(xmlDocPtr doc, xmlNodePtr node,
the monitor, so <position><x>center</x></position><monitor>2</monitor> the monitor, so <position><x>center</x></position><monitor>2</monitor>
will center the window on the second monitor. will center the window on the second monitor.
*/ */
static void parse_per_app_settings(ObParseInst *inst, xmlDocPtr doc, static void parse_per_app_settings(xmlNodePtr node, gpointer d)
xmlNodePtr node, gpointer data)
{ {
xmlNodePtr app = parse_find_node("application", node->children); xmlNodePtr app = obt_parse_find_node(node->children, "application");
gchar *name = NULL, *class = NULL, *role = NULL; gchar *name = NULL, *class = NULL, *role = NULL;
gboolean name_set, class_set; gboolean name_set, class_set;
gboolean x_pos_given; gboolean x_pos_given;
@ -197,8 +194,8 @@ static void parse_per_app_settings(ObParseInst *inst, xmlDocPtr doc,
while (app) { while (app) {
name_set = class_set = x_pos_given = FALSE; name_set = class_set = x_pos_given = FALSE;
class_set = parse_attr_string("class", app, &class); class_set = obt_parse_attr_string(app, "class", &class);
name_set = parse_attr_string("name", app, &name); name_set = obt_parse_attr_string(app, "name", &name);
if (class_set || name_set) { if (class_set || name_set) {
xmlNodePtr n, c; xmlNodePtr n, c;
ObAppSettings *settings = config_create_app_settings();; ObAppSettings *settings = config_create_app_settings();;
@ -209,55 +206,53 @@ static void parse_per_app_settings(ObParseInst *inst, xmlDocPtr doc,
if (class_set) if (class_set)
settings->class = g_pattern_spec_new(class); 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); settings->role = g_pattern_spec_new(role);
if ((n = parse_find_node("decor", app->children))) if ((n = obt_parse_find_node(app->children, "decor")))
if (!parse_contains("default", doc, n)) if (!obt_parse_node_contains(n, "default"))
settings->decor = parse_bool(doc, n); settings->decor = obt_parse_node_bool(n);
if ((n = parse_find_node("shade", app->children))) if ((n = obt_parse_find_node(app->children, "shade")))
if (!parse_contains("default", doc, n)) if (!obt_parse_node_contains(n, "default"))
settings->shade = parse_bool(doc, n); settings->shade = obt_parse_node_bool(n);
if ((n = parse_find_node("position", app->children))) { if ((n = obt_parse_find_node(app->children, "position"))) {
if ((c = parse_find_node("x", n->children))) if ((c = obt_parse_find_node(n->children, "x")))
if (!parse_contains("default", doc, c)) { if (!obt_parse_node_contains(c, "default")) {
config_parse_gravity_coord(doc, c, config_parse_gravity_coord(c, &settings->position.x);
&settings->position.x);
x_pos_given = TRUE; x_pos_given = TRUE;
} }
if (x_pos_given && (c = parse_find_node("y", n->children))) if (x_pos_given && (c = obt_parse_find_node(n->children, "y")))
if (!parse_contains("default", doc, c)) { if (!obt_parse_node_contains("default", doc, c)) {
config_parse_gravity_coord(doc, c, config_parse_gravity_coord(c, &settings->position.y);
&settings->position.y);
settings->pos_given = TRUE; settings->pos_given = TRUE;
} }
if (settings->pos_given && if (settings->pos_given &&
(c = parse_find_node("monitor", n->children))) (c = obt_parse_find_node(n->children, "monitor")))
if (!parse_contains("default", doc, c)) { if (!obt_parse_node_contains(c, "default")) {
gchar *s = parse_string(doc, c); gchar *s = obt_parse_node_string(c);
if (!g_ascii_strcasecmp(s, "mouse")) if (!g_ascii_strcasecmp(s, "mouse"))
settings->monitor = 0; settings->monitor = 0;
else else
settings->monitor = parse_int(doc, c) + 1; settings->monitor = obt_parse_node_int(c) + 1;
g_free(s); g_free(s);
} }
} }
if ((n = parse_find_node("focus", app->children))) if ((n = obt_parse_find_node(app->children, "focus")))
if (!parse_contains("default", doc, n)) if (!obt_parse_node_contains(n, "default"))
settings->focus = parse_bool(doc, n); settings->focus = obt_parse_node_bool(n);
if ((n = parse_find_node("desktop", app->children))) { if ((n = obt_parse_find_node(app->children, "desktop"))) {
if (!parse_contains("default", doc, n)) { if (!obt_parse_node_contains(n, "default")) {
gchar *s = parse_string(doc, n); gchar *s = obt_parse_node_string(n);
if (!g_ascii_strcasecmp(s, "all")) if (!g_ascii_strcasecmp(s, "all"))
settings->desktop = DESKTOP_ALL; settings->desktop = DESKTOP_ALL;
else { else {
gint i = parse_int(doc, n); gint i = obt_parse_node_int(n);
if (i > 0) if (i > 0)
settings->desktop = i; settings->desktop = i;
} }
@ -265,9 +260,9 @@ static void parse_per_app_settings(ObParseInst *inst, xmlDocPtr doc,
} }
} }
if ((n = parse_find_node("layer", app->children))) if ((n = obt_parse_find_node(app->children, "layer")))
if (!parse_contains("default", doc, n)) { if (!obt_parse_node_contains(n, "default")) {
gchar *s = parse_string(doc, n); gchar *s = obt_parse_node_string(n);
if (!g_ascii_strcasecmp(s, "above")) if (!g_ascii_strcasecmp(s, "above"))
settings->layer = 1; settings->layer = 1;
else if (!g_ascii_strcasecmp(s, "below")) else if (!g_ascii_strcasecmp(s, "below"))
@ -277,25 +272,25 @@ static void parse_per_app_settings(ObParseInst *inst, xmlDocPtr doc,
g_free(s); g_free(s);
} }
if ((n = parse_find_node("iconic", app->children))) if ((n = obt_parse_find_node(app->children, "iconic")))
if (!parse_contains("default", doc, n)) if (!obt_parse_node_contains(n, "default"))
settings->iconic = parse_bool(doc, n); settings->iconic = obt_parse_node_bool(n);
if ((n = parse_find_node("skip_pager", app->children))) if ((n = obt_parse_find_node(app->children, "skip_pager")))
if (!parse_contains("default", doc, n)) if (!obt_parse_node_contains(n, "default"))
settings->skip_pager = parse_bool(doc, n); settings->skip_pager = obt_parse_node_bool(n);
if ((n = parse_find_node("skip_taskbar", app->children))) if ((n = obt_parse_find_node(app->children, "skip_taskbar")))
if (!parse_contains("default", doc, n)) if (!obt_parse_node_contains(n, "default"))
settings->skip_taskbar = parse_bool(doc, n); settings->skip_taskbar = obt_parse_node_bool(n);
if ((n = parse_find_node("fullscreen", app->children))) if ((n = obt_parse_find_node(app->children, "fullscreen")))
if (!parse_contains("default", doc, n)) if (!obt_parse_node_contains(n, "default"))
settings->fullscreen = parse_bool(doc, n); settings->fullscreen = obt_parse_node_bool(n);
if ((n = parse_find_node("maximized", app->children))) if ((n = obt_parse_find_node(app->children, "maximized")))
if (!parse_contains("default", doc, n)) { if (!obt_parse_node_contains(n, "default")) {
gchar *s = parse_string(doc, n); gchar *s = obt_parse_node_string(n);
if (!g_ascii_strcasecmp(s, "horizontal")) { if (!g_ascii_strcasecmp(s, "horizontal")) {
settings->max_horz = TRUE; settings->max_horz = TRUE;
settings->max_vert = FALSE; settings->max_vert = FALSE;
@ -304,7 +299,7 @@ static void parse_per_app_settings(ObParseInst *inst, xmlDocPtr doc,
settings->max_vert = TRUE; settings->max_vert = TRUE;
} else } else
settings->max_horz = settings->max_vert = settings->max_horz = settings->max_vert =
parse_bool(doc, n); obt_parse_node_bool(n);
g_free(s); g_free(s);
} }
@ -316,7 +311,7 @@ static void parse_per_app_settings(ObParseInst *inst, xmlDocPtr doc,
name = class = role = NULL; name = class = role = NULL;
} }
app = parse_find_node("application", app->next); app = obt_parse_find_node(app->next, "application");
} }
} }
@ -330,34 +325,33 @@ static void parse_per_app_settings(ObParseInst *inst, xmlDocPtr doc,
*/ */
static void parse_key(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, static void parse_key(xmlNodePtr node, GList *keylist)
GList *keylist)
{ {
gchar *key; gchar *key;
xmlNodePtr n; xmlNodePtr n;
gboolean is_chroot = FALSE; gboolean is_chroot = FALSE;
if (!parse_attr_string("key", node, &key)) if (!obt_parse_attr_string(node, "key", &key))
return; return;
parse_attr_bool("chroot", node, &is_chroot); obt_parse_attr_bool(node, "chroot", &is_chroot);
keylist = g_list_append(keylist, key); 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) { while (n) {
parse_key(i, doc, n, keylist); parse_key(n, keylist);
n = parse_find_node("keybind", n->next); 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) { while (n) {
ObActionsAct *action; ObActionsAct *action;
action = actions_parse(i, doc, n); action = actions_parse(n);
if (action) if (action)
keyboard_bind(keylist, action); keyboard_bind(keylist, action);
n = parse_find_node("action", n->next); n = obt_parse_find_node(n->next, "action");
} }
} }
@ -368,25 +362,24 @@ static void parse_key(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
keylist = g_list_delete_link(keylist, g_list_last(keylist)); keylist = g_list_delete_link(keylist, g_list_last(keylist));
} }
static void parse_keyboard(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, static void parse_keyboard(xmlNodePtr node, gpointer d)
gpointer data)
{ {
xmlNodePtr n; xmlNodePtr n;
gchar *key; gchar *key;
keyboard_unbind_all(); keyboard_unbind_all();
if ((n = parse_find_node("chainQuitKey", node->children))) { if ((n = obt_parse_find_node(node->children, "chainQuitKey"))) {
key = parse_string(doc, n); key = obt_parse_node_string(n);
translate_key(key, &config_keyboard_reset_state, translate_key(key, &config_keyboard_reset_state,
&config_keyboard_reset_keycode); &config_keyboard_reset_keycode);
g_free(key); g_free(key);
} }
if ((n = parse_find_node("keybind", node->children))) if ((n = obt_parse_find_node(node->children, "keybind")))
while (n) { while (n) {
parse_key(i, doc, n, NULL); parse_key(n, NULL);
n = parse_find_node("keybind", n->next); n = obt_parse_find_node(n->next, "keybind");
} }
} }
@ -400,8 +393,7 @@ static void parse_keyboard(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
*/ */
static void parse_mouse(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, static void parse_mouse(xmlNodePtr node, gpointer d)
gpointer data)
{ {
xmlNodePtr n, nbut, nact; xmlNodePtr n, nbut, nact;
gchar *buttonstr; gchar *buttonstr;
@ -412,137 +404,133 @@ static void parse_mouse(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
node = node->children; node = node->children;
if ((n = parse_find_node("dragThreshold", node))) if ((n = obt_parse_find_node(node, "dragThreshold")))
config_mouse_threshold = parse_int(doc, n); config_mouse_threshold = obt_parse_node_int(n);
if ((n = parse_find_node("doubleClickTime", node))) if ((n = obt_parse_find_node(node, "doubleClickTime")))
config_mouse_dclicktime = parse_int(doc, n); config_mouse_dclicktime = obt_parse_node_int(n);
if ((n = parse_find_node("screenEdgeWarpTime", node))) if ((n = obt_parse_find_node(node, "screenEdgeWarpTime")))
config_mouse_screenedgetime = parse_int(doc, n); config_mouse_screenedgetime = obt_parse_node_int(n);
n = parse_find_node("context", node); n = obt_parse_find_node(node, "context");
while (n) { while (n) {
if (!parse_attr_string("name", n, &contextstr)) if (!obt_parse_attr_string(n, "name", &contextstr))
goto next_n; goto next_n;
nbut = parse_find_node("mousebind", n->children); nbut = obt_parse_find_node(n->children, "mousebind");
while (nbut) { while (nbut) {
if (!parse_attr_string("button", nbut, &buttonstr)) if (!obt_parse_attr_string(nbut, "button", &buttonstr))
goto next_nbut; goto next_nbut;
if (parse_attr_contains("press", nbut, "action")) { if (obt_parse_attr_contains(nbut, "action", "press")) {
mact = OB_MOUSE_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; 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; 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; 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; mact = OB_MOUSE_ACTION_MOTION;
} else } else
goto next_nbut; goto next_nbut;
nact = parse_find_node("action", nbut->children); nact = obt_parse_find_node(nbut->children, "action");
while (nact) { while (nact) {
ObActionsAct *action; ObActionsAct *action;
if ((action = actions_parse(i, doc, nact))) if ((action = actions_parse(nact)))
mouse_bind(buttonstr, contextstr, mact, action); mouse_bind(buttonstr, contextstr, mact, action);
nact = parse_find_node("action", nact->next); nact = obt_parse_find_node(nact->next, "action");
} }
g_free(buttonstr); g_free(buttonstr);
next_nbut: next_nbut:
nbut = parse_find_node("mousebind", nbut->next); nbut = obt_parse_find_node(nbut->next, "mousebind");
} }
g_free(contextstr); g_free(contextstr);
next_n: 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, static void parse_focus(xmlNodePtr node, gpointer d)
gpointer data)
{ {
xmlNodePtr n; xmlNodePtr n;
node = node->children; node = node->children;
if ((n = parse_find_node("focusNew", node))) if ((n = obt_parse_find_node(node, "focusNew")))
config_focus_new = parse_bool(doc, n); config_focus_new = obt_parse_node_bool(n);
if ((n = parse_find_node("followMouse", node))) if ((n = obt_parse_find_node(node, "followMouse")))
config_focus_follow = parse_bool(doc, n); config_focus_follow = obt_parse_node_bool(n);
if ((n = parse_find_node("focusDelay", node))) if ((n = obt_parse_find_node(node, "focusDelay")))
config_focus_delay = parse_int(doc, n); config_focus_delay = obt_parse_node_int(n);
if ((n = parse_find_node("raiseOnFocus", node))) if ((n = obt_parse_find_node(node, "raiseOnFocus")))
config_focus_raise = parse_bool(doc, n); config_focus_raise = obt_parse_node_bool(n);
if ((n = parse_find_node("focusLast", node))) if ((n = obt_parse_find_node(node, "focusLast")))
config_focus_last = parse_bool(doc, n); config_focus_last = obt_parse_node_bool(n);
if ((n = parse_find_node("underMouse", node))) if ((n = obt_parse_find_node(node, "underMouse")))
config_focus_under_mouse = parse_bool(doc, n); config_focus_under_mouse = obt_parse_node_bool(n);
} }
static void parse_placement(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, static void parse_placement(xmlNodePtr node, gpointer d)
gpointer data)
{ {
xmlNodePtr n; xmlNodePtr n;
node = node->children; node = node->children;
if ((n = parse_find_node("policy", node))) if ((n = obt_parse_find_node(node, "policy")))
if (parse_contains("UnderMouse", doc, n)) if (obt_parse_node_contains(n, "UnderMouse"))
config_place_policy = OB_PLACE_POLICY_MOUSE; config_place_policy = OB_PLACE_POLICY_MOUSE;
if ((n = parse_find_node("center", node))) if ((n = obt_parse_find_node(node, "center")))
config_place_center = parse_bool(doc, n); config_place_center = obt_parse_node_bool(n);
if ((n = parse_find_node("active", node))) if ((n = obt_parse_find_node(node, "active")))
config_place_active = parse_bool(doc, n); config_place_active = obt_parse_node_bool(n);
} }
static void parse_margins(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, static void parse_margins(xmlNodePtr node, gpointer d)
gpointer data)
{ {
xmlNodePtr n; xmlNodePtr n;
node = node->children; node = node->children;
if ((n = parse_find_node("top", node))) if ((n = obt_parse_find_node(node, "top")))
config_margins.top = MAX(0, parse_int(doc, n)); config_margins.top = MAX(0, obt_parse_node_int(n));
if ((n = parse_find_node("left", node))) if ((n = obt_parse_find_node(node, "left")))
config_margins.left = MAX(0, parse_int(doc, n)); config_margins.left = MAX(0, obt_parse_node_int(n));
if ((n = parse_find_node("right", node))) if ((n = obt_parse_find_node(node, "right")))
config_margins.right = MAX(0, parse_int(doc, n)); config_margins.right = MAX(0, obt_parse_node_int(n));
if ((n = parse_find_node("bottom", node))) if ((n = obt_parse_find_node(node, "bottom")))
config_margins.bottom = MAX(0, parse_int(doc, n)); config_margins.bottom = MAX(0, obt_parse_node_int(n));
} }
static void parse_theme(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, static void parse_theme(xmlNodePtr node, gpointer d)
gpointer data)
{ {
xmlNodePtr n; xmlNodePtr n;
node = node->children; node = node->children;
if ((n = parse_find_node("name", node))) { if ((n = obt_parse_find_node(node, "name"))) {
gchar *c; gchar *c;
g_free(config_theme); g_free(config_theme);
c = parse_string(doc, n); c = obt_parse_node_string(n);
config_theme = parse_expand_tilde(c); config_theme = parse_expand_tilde(c);
g_free(c); g_free(c);
} }
if ((n = parse_find_node("titleLayout", node))) { if ((n = obt_parse_find_node(node, "titleLayout"))) {
gchar *c, *d; gchar *c, *d;
g_free(config_title_layout); g_free(config_title_layout);
config_title_layout = parse_string(doc, n); config_title_layout = obt_parse_node_string(n);
/* replace duplicates with spaces */ /* replace duplicates with spaces */
for (c = config_title_layout; *c != '\0'; ++c) for (c = config_title_layout; *c != '\0'; ++c)
for (d = c+1; *d != '\0'; ++d) for (d = c+1; *d != '\0'; ++d)
if (*c == *d) *d = ' '; if (*c == *d) *d = ' ';
} }
if ((n = parse_find_node("keepBorder", node))) if ((n = obt_parse_find_node(node, "keepBorder")))
config_theme_keepborder = parse_bool(doc, n); config_theme_keepborder = obt_parse_node_bool(n);
if ((n = parse_find_node("animateIconify", node))) if ((n = obt_parse_find_node(node, "animateIconify")))
config_animate_iconify = parse_bool(doc, n); config_animate_iconify = obt_parse_node_bool(n);
n = parse_find_node("font", node); n = obt_parse_find_node(node, "font");
while (n) { while (n) {
xmlNodePtr fnode; xmlNodePtr fnode;
RrFont **font; RrFont **font;
@ -551,35 +539,35 @@ static void parse_theme(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
RrFontWeight weight = RrDefaultFontWeight; RrFontWeight weight = RrDefaultFontWeight;
RrFontSlant slant = RrDefaultFontSlant; RrFontSlant slant = RrDefaultFontSlant;
if (parse_attr_contains("ActiveWindow", n, "place")) if (obt_parse_attr_contains(n, "place", "ActiveWindow"))
font = &config_font_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; 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; 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; 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; font = &config_font_osd;
else else
goto next_font; goto next_font;
if ((fnode = parse_find_node("name", n->children))) { if ((fnode = obt_parse_find_node(n->children, "name"))) {
g_free(name); g_free(name);
name = parse_string(doc, fnode); name = obt_parse_node_string(fnode);
} }
if ((fnode = parse_find_node("size", n->children))) { if ((fnode = obt_parse_find_node(n->children, "size"))) {
int s = parse_int(doc, fnode); int s = obt_parse_node_int(fnode);
if (s > 0) size = s; if (s > 0) size = s;
} }
if ((fnode = parse_find_node("weight", n->children))) { if ((fnode = obt_parse_find_node(n->children, "weight"))) {
gchar *w = parse_string(doc, fnode); gchar *w = obt_parse_node_string(fnode);
if (!g_ascii_strcasecmp(w, "Bold")) if (!g_ascii_strcasecmp(w, "Bold"))
weight = RR_FONTWEIGHT_BOLD; weight = RR_FONTWEIGHT_BOLD;
g_free(w); g_free(w);
} }
if ((fnode = parse_find_node("slant", n->children))) { if ((fnode = obt_parse_find_node(n->children, "slant"))) {
gchar *s = parse_string(doc, fnode); gchar *s = obt_parse_node_string(fnode);
if (!g_ascii_strcasecmp(s, "Italic")) if (!g_ascii_strcasecmp(s, "Italic"))
slant = RR_FONTSLANT_ITALIC; slant = RR_FONTSLANT_ITALIC;
if (!g_ascii_strcasecmp(s, "Oblique")) if (!g_ascii_strcasecmp(s, "Oblique"))
@ -590,28 +578,27 @@ static void parse_theme(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
*font = RrFontOpen(ob_rr_inst, name, size, weight, slant); *font = RrFontOpen(ob_rr_inst, name, size, weight, slant);
g_free(name); g_free(name);
next_font: 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, static void parse_desktops(xmlNodePtr node, gpointer d)
gpointer data)
{ {
xmlNodePtr n; xmlNodePtr n;
node = node->children; node = node->children;
if ((n = parse_find_node("number", node))) { if ((n = obt_parse_find_node(node, "number"))) {
gint d = parse_int(doc, n); gint d = obt_parse_node_int(n);
if (d > 0) if (d > 0)
config_desktops_num = d; config_desktops_num = d;
} }
if ((n = parse_find_node("firstdesk", node))) { if ((n = obt_parse_find_node(node, "firstdesk"))) {
gint d = parse_int(doc, n); gint d = obt_parse_node_int(n);
if (d > 0) if (d > 0)
config_screen_firstdesk = (unsigned) d; config_screen_firstdesk = (unsigned) d;
} }
if ((n = parse_find_node("names", node))) { if ((n = obt_parse_find_node(node, "names"))) {
GSList *it; GSList *it;
xmlNodePtr nname; xmlNodePtr nname;
@ -620,123 +607,122 @@ static void parse_desktops(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
g_slist_free(config_desktops_names); g_slist_free(config_desktops_names);
config_desktops_names = NULL; config_desktops_names = NULL;
nname = parse_find_node("name", n->children); nname = obt_parse_find_node(n->children, "name");
while (nname) { while (nname) {
config_desktops_names = g_slist_append(config_desktops_names, config_desktops_names =
parse_string(doc, nname)); g_slist_append(config_desktops_names,
nname = parse_find_node("name", nname->next); obt_parse_node_string(nname));
nname = obt_parse_find_node(nname->next, "name");
} }
} }
if ((n = parse_find_node("popupTime", node))) if ((n = obt_parse_find_node(node, "popupTime")))
config_desktop_popup_time = parse_int(doc, n); config_desktop_popup_time = obt_parse_node_int(n);
} }
static void parse_resize(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, static void parse_resize(xmlNodePtr node, gpointer d)
gpointer data)
{ {
xmlNodePtr n; xmlNodePtr n;
node = node->children; node = node->children;
if ((n = parse_find_node("drawContents", node))) if ((n = obt_parse_find_node(node, "drawContents")))
config_resize_redraw = parse_bool(doc, n); config_resize_redraw = obt_parse_node_bool(n);
if ((n = parse_find_node("popupShow", node))) { if ((n = obt_parse_find_node(node, "popupShow"))) {
config_resize_popup_show = parse_int(doc, n); config_resize_popup_show = obt_parse_node_int(n);
if (parse_contains("Always", doc, n)) if (obt_parse_node_contains(n, "Always"))
config_resize_popup_show = 2; 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; 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; config_resize_popup_show = 1;
} }
if ((n = parse_find_node("popupPosition", node))) { if ((n = obt_parse_find_node(node, "popupPosition"))) {
if (parse_contains("Top", doc, n)) if (obt_parse_node_contains(n, "Top"))
config_resize_popup_pos = OB_RESIZE_POS_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; 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; 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; xmlNodePtr n2;
if ((n2 = parse_find_node("x", n->children))) if ((n2 = obt_parse_find_node(n->children, "x")))
config_parse_gravity_coord(doc, n2, config_parse_gravity_coord(n2,
&config_resize_popup_fixed.x); &config_resize_popup_fixed.x);
if ((n2 = parse_find_node("y", n->children))) if ((n2 = obt_parse_find_node(n->children, "y")))
config_parse_gravity_coord(doc, n2, config_parse_gravity_coord(n2,
&config_resize_popup_fixed.y); &config_resize_popup_fixed.y);
} }
} }
} }
} }
static void parse_dock(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, static void parse_dock(xmlNodePtr node, gpointer d)
gpointer data)
{ {
xmlNodePtr n; xmlNodePtr n;
node = node->children; node = node->children;
if ((n = parse_find_node("position", node))) { if ((n = obt_parse_find_node(node, "position"))) {
if (parse_contains("TopLeft", doc, n)) if (obt_parse_node_contains(n, "TopLeft"))
config_dock_floating = FALSE, config_dock_floating = FALSE,
config_dock_pos = OB_DIRECTION_NORTHWEST; 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_floating = FALSE,
config_dock_pos = OB_DIRECTION_NORTH; 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_floating = FALSE,
config_dock_pos = OB_DIRECTION_NORTHEAST; 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_floating = FALSE,
config_dock_pos = OB_DIRECTION_EAST; 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_floating = FALSE,
config_dock_pos = OB_DIRECTION_SOUTHEAST; 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_floating = FALSE,
config_dock_pos = OB_DIRECTION_SOUTH; 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_floating = FALSE,
config_dock_pos = OB_DIRECTION_SOUTHWEST; 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_floating = FALSE,
config_dock_pos = OB_DIRECTION_WEST; 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; config_dock_floating = TRUE;
} }
if (config_dock_floating) { if (config_dock_floating) {
if ((n = parse_find_node("floatingX", node))) if ((n = obt_parse_find_node(node, "floatingX")))
config_dock_x = parse_int(doc, n); config_dock_x = obt_parse_node_int(n);
if ((n = parse_find_node("floatingY", node))) if ((n = obt_parse_find_node(node, "floatingY")))
config_dock_y = parse_int(doc, n); config_dock_y = obt_parse_node_int(n);
} else { } else {
if ((n = parse_find_node("noStrut", node))) if ((n = obt_parse_find_node(node, "noStrut")))
config_dock_nostrut = parse_bool(doc, n); config_dock_nostrut = obt_parse_node_bool(n);
} }
if ((n = parse_find_node("stacking", node))) { if ((n = obt_parse_find_node(node, "stacking"))) {
if (parse_contains("above", doc, n)) if (obt_parse_node_contains(n, "normal"))
config_dock_layer = OB_STACKING_LAYER_ABOVE;
else if (parse_contains("normal", doc, n))
config_dock_layer = OB_STACKING_LAYER_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; 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 ((n = obt_parse_find_node(node, "direction"))) {
if (parse_contains("horizontal", doc, n)) if (obt_parse_node_contains(n, "horizontal"))
config_dock_orient = OB_ORIENTATION_HORZ; 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; config_dock_orient = OB_ORIENTATION_VERT;
} }
if ((n = parse_find_node("autoHide", node))) if ((n = obt_parse_find_node(node, "autoHide")))
config_dock_hide = parse_bool(doc, n); config_dock_hide = obt_parse_node_bool(n);
if ((n = parse_find_node("hideDelay", node))) if ((n = obt_parse_find_node(node, "hideDelay")))
config_dock_hide_delay = parse_int(doc, n); config_dock_hide_delay = obt_parse_node_int(n);
if ((n = parse_find_node("showDelay", node))) if ((n = obt_parse_find_node(node, "showDelay")))
config_dock_show_delay = parse_int(doc, n); config_dock_show_delay = obt_parse_node_int(n);
if ((n = parse_find_node("moveButton", node))) { if ((n = obt_parse_find_node(node, "moveButton"))) {
gchar *str = parse_string(doc, n); gchar *str = obt_parse_node_string(n);
guint b, s; guint b, s;
if (translate_button(str, &s, &b)) { if (translate_button(str, &s, &b)) {
config_dock_app_move_button = b; config_dock_app_move_button = b;
@ -748,40 +734,38 @@ static void parse_dock(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
} }
} }
static void parse_menu(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, static void parse_menu(xmlNodePtr node, gpointer d)
gpointer data)
{ {
xmlNodePtr n; xmlNodePtr n;
for (node = node->children; node; node = node->next) { for (node = node->children; node; node = node->next) {
if (!xmlStrcasecmp(node->name, (const xmlChar*) "file")) { if (!xmlStrcasecmp(node->name, (const xmlChar*) "file")) {
gchar *c; gchar *c;
c = parse_string(doc, node); c = obt_parse_node_string(node);
config_menu_files = g_slist_append(config_menu_files, config_menu_files = g_slist_append(config_menu_files,
parse_expand_tilde(c)); parse_expand_tilde(c));
g_free(c); g_free(c);
} }
if ((n = parse_find_node("hideDelay", node))) if ((n = obt_parse_find_node(node, "hideDelay")))
config_menu_hide_delay = parse_int(doc, n); config_menu_hide_delay = obt_parse_node_int(n);
if ((n = parse_find_node("middle", node))) if ((n = obt_parse_find_node(node, "middle")))
config_menu_middle = parse_bool(doc, n); config_menu_middle = obt_parse_node_bool(n);
if ((n = parse_find_node("submenuShowDelay", node))) if ((n = obt_parse_find_node(node, "submenuShowDelay")))
config_submenu_show_delay = parse_int(doc, n); config_submenu_show_delay = obt_parse_node_int(n);
if ((n = parse_find_node("applicationIcons", node))) if ((n = obt_parse_find_node(node, "applicationIcons")))
config_menu_client_list_icons = parse_bool(doc, n); config_menu_client_list_icons = obt_parse_node_bool(n);
} }
} }
static void parse_resistance(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, static void parse_resistance(xmlNodePtr node, gpointer d)
gpointer data)
{ {
xmlNodePtr n; xmlNodePtr n;
node = node->children; node = node->children;
if ((n = parse_find_node("strength", node))) if ((n = obt_parse_find_node(node, "strength")))
config_resist_win = parse_int(doc, n); config_resist_win = obt_parse_node_int(n);
if ((n = parse_find_node("screen_edge_strength", node))) if ((n = obt_parse_find_node(node, "screen_edge_strength")))
config_resist_edge = parse_int(doc, n); config_resist_edge = obt_parse_node_int(n);
} }
typedef struct typedef struct
@ -872,7 +856,7 @@ static void bind_default_mouse(void)
actions_parse_string(it->actname)); actions_parse_string(it->actname));
} }
void config_startup(ObParseInst *i) void config_startup(ObtParseInst *i)
{ {
config_focus_new = TRUE; config_focus_new = TRUE;
config_focus_follow = FALSE; config_focus_follow = FALSE;
@ -881,17 +865,17 @@ void config_startup(ObParseInst *i)
config_focus_last = TRUE; config_focus_last = TRUE;
config_focus_under_mouse = FALSE; 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_policy = OB_PLACE_POLICY_SMART;
config_place_center = TRUE; config_place_center = TRUE;
config_place_active = FALSE; 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); 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_theme = NULL;
@ -904,14 +888,14 @@ void config_startup(ObParseInst *i)
config_font_menuitem = NULL; config_font_menuitem = NULL;
config_font_menutitle = 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_desktops_num = 4;
config_screen_firstdesk = 1; config_screen_firstdesk = 1;
config_desktops_names = NULL; config_desktops_names = NULL;
config_desktop_popup_time = 875; 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_redraw = TRUE;
config_resize_popup_show = 1; /* nonpixel increments */ config_resize_popup_show = 1; /* nonpixel increments */
@ -919,7 +903,7 @@ void config_startup(ObParseInst *i)
GRAVITY_COORD_SET(config_resize_popup_fixed.x, 0, FALSE, FALSE); GRAVITY_COORD_SET(config_resize_popup_fixed.x, 0, FALSE, FALSE);
GRAVITY_COORD_SET(config_resize_popup_fixed.y, 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_layer = OB_STACKING_LAYER_ABOVE;
config_dock_pos = OB_DIRECTION_NORTHEAST; config_dock_pos = OB_DIRECTION_NORTHEAST;
@ -934,14 +918,14 @@ void config_startup(ObParseInst *i)
config_dock_app_move_button = 2; /* middle */ config_dock_app_move_button = 2; /* middle */
config_dock_app_move_modifiers = 0; 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, translate_key("C-g", &config_keyboard_reset_state,
&config_keyboard_reset_keycode); &config_keyboard_reset_keycode);
bind_default_keyboard(); bind_default_keyboard();
parse_register(i, "keyboard", parse_keyboard, NULL); obt_parse_register(i, "keyboard", parse_keyboard, NULL);
config_mouse_threshold = 8; config_mouse_threshold = 8;
config_mouse_dclicktime = 200; config_mouse_dclicktime = 200;
@ -949,12 +933,12 @@ void config_startup(ObParseInst *i)
bind_default_mouse(); bind_default_mouse();
parse_register(i, "mouse", parse_mouse, NULL); obt_parse_register(i, "mouse", parse_mouse, NULL);
config_resist_win = 10; config_resist_win = 10;
config_resist_edge = 20; 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_hide_delay = 250;
config_menu_middle = FALSE; config_menu_middle = FALSE;
@ -962,11 +946,11 @@ void config_startup(ObParseInst *i)
config_menu_client_list_icons = TRUE; config_menu_client_list_icons = TRUE;
config_menu_files = NULL; config_menu_files = NULL;
parse_register(i, "menu", parse_menu, NULL); obt_parse_register(i, "menu", parse_menu, NULL);
config_per_app_settings = 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) void config_shutdown(void)

View file

@ -26,11 +26,10 @@
#include "geom.h" #include "geom.h"
#include "moveresize.h" #include "moveresize.h"
#include "render/render.h" #include "render/render.h"
#include "obt/parse.h"
#include <glib.h> #include <glib.h>
struct _ObParseInst;
typedef struct _ObAppSettings ObAppSettings; typedef struct _ObAppSettings ObAppSettings;
struct _ObAppSettings struct _ObAppSettings
@ -183,7 +182,7 @@ extern GSList *config_menu_files;
/*! Per app settings */ /*! Per app settings */
extern GSList *config_per_app_settings; extern GSList *config_per_app_settings;
void config_startup(struct _ObParseInst *i); void config_startup(ObtParseInst *i);
void config_shutdown(); void config_shutdown();
/*! Create an ObAppSettings structure with the default values */ /*! Create an ObAppSettings structure with the default values */

View file

@ -34,7 +34,7 @@
#include "client_list_menu.h" #include "client_list_menu.h"
#include "client_list_combined_menu.h" #include "client_list_combined_menu.h"
#include "gettext.h" #include "gettext.h"
#include "parser/parse.h" #include "obt/parse.h"
typedef struct _ObMenuParseState ObMenuParseState; typedef struct _ObMenuParseState ObMenuParseState;
@ -45,18 +45,14 @@ struct _ObMenuParseState
}; };
static GHashTable *menu_hash = NULL; static GHashTable *menu_hash = NULL;
static ObParseInst *menu_parse_inst; static ObtParseInst *menu_parse_inst;
static ObMenuParseState menu_parse_state; static ObMenuParseState menu_parse_state;
static gboolean menu_can_hide = FALSE; static gboolean menu_can_hide = FALSE;
static void menu_destroy_hash_value(ObMenu *self); static void menu_destroy_hash_value(ObMenu *self);
static void parse_menu_item(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, static void parse_menu_item(xmlNodePtr node, gpointer data);
gpointer data); static void parse_menu_separator(xmlNodePtr node, gpointer data);
static void parse_menu_separator(ObParseInst *i, static void parse_menu(xmlNodePtr node, gpointer data);
xmlDocPtr doc, xmlNodePtr node,
gpointer data);
static void parse_menu(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
gpointer data);
static gunichar parse_shortcut(const gchar *label, gboolean allow_shortcut, static gunichar parse_shortcut(const gchar *label, gboolean allow_shortcut,
gchar **strippedlabel, guint *position, gchar **strippedlabel, guint *position,
gboolean *always_show); gboolean *always_show);
@ -71,8 +67,6 @@ static void client_dest(ObClient *client, gpointer data)
void menu_startup(gboolean reconfig) void menu_startup(gboolean reconfig)
{ {
xmlDocPtr doc;
xmlNodePtr node;
gboolean loaded = FALSE; gboolean loaded = FALSE;
GSList *it; GSList *it;
@ -83,29 +77,39 @@ void menu_startup(gboolean reconfig)
client_list_combined_menu_startup(reconfig); client_list_combined_menu_startup(reconfig);
client_menu_startup(); client_menu_startup();
menu_parse_inst = parse_startup(); menu_parse_inst = obt_parse_instance_new();
menu_parse_state.parent = NULL; menu_parse_state.parent = NULL;
menu_parse_state.pipe_creator = NULL; menu_parse_state.pipe_creator = NULL;
parse_register(menu_parse_inst, "menu", parse_menu, &menu_parse_state); obt_parse_register(menu_parse_inst, "menu", parse_menu, &menu_parse_state);
parse_register(menu_parse_inst, "item", parse_menu_item, obt_parse_register(menu_parse_inst, "item", parse_menu_item,
&menu_parse_state); &menu_parse_state);
parse_register(menu_parse_inst, "separator", obt_parse_register(menu_parse_inst, "separator",
parse_menu_separator, &menu_parse_state); parse_menu_separator, &menu_parse_state);
for (it = config_menu_files; it; it = g_slist_next(it)) { 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; loaded = TRUE;
parse_tree(menu_parse_inst, doc, node->children); obt_parse_tree(menu_parse_inst,
xmlFreeDoc(doc); obt_parse_instance_root(menu_parse_inst)->children);
obt_parse_close(menu_parse_inst);
} else } else
g_message(_("Unable to find a valid menu file '%s'"), g_message(_("Unable to find a valid menu file '%s'"),
(const gchar*)it->data); (const gchar*)it->data);
} }
if (!loaded) { if (!loaded) {
if (parse_load_menu("menu.xml", &doc, &node)) { if (obt_parse_load_config_file(menu_parse_inst,
parse_tree(menu_parse_inst, doc, node->children); "openbox",
xmlFreeDoc(doc); "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 } else
g_message(_("Unable to find a valid menu file '%s'"), g_message(_("Unable to find a valid menu file '%s'"),
"menu.xml"); "menu.xml");
@ -122,7 +126,7 @@ void menu_shutdown(gboolean reconfig)
if (!reconfig) if (!reconfig)
client_remove_destroy_notify(client_dest); client_remove_destroy_notify(client_dest);
parse_shutdown(menu_parse_inst); obt_parse_instance_unref(menu_parse_inst);
menu_parse_inst = NULL; menu_parse_inst = NULL;
client_list_menu_shutdown(reconfig); client_list_menu_shutdown(reconfig);
@ -156,7 +160,6 @@ void menu_clear_pipe_caches(void)
void menu_pipe_execute(ObMenu *self) void menu_pipe_execute(ObMenu *self)
{ {
xmlDocPtr doc;
xmlNodePtr node; xmlNodePtr node;
gchar *output; gchar *output;
GError *err = NULL; GError *err = NULL;
@ -173,13 +176,13 @@ void menu_pipe_execute(ObMenu *self)
return; return;
} }
if (parse_load_mem(output, strlen(output), if (obt_parse_load_mem(menu_parse_inst, output, strlen(output),
"openbox_pipe_menu", &doc, &node)) "openbox_pipe_menu"))
{ {
menu_parse_state.pipe_creator = self; menu_parse_state.pipe_creator = self;
menu_parse_state.parent = self; menu_parse_state.parent = self;
parse_tree(menu_parse_inst, doc, node->children); obt_parse_tree(menu_parse_inst, node->children);
xmlFreeDoc(doc); obt_parse_close(menu_parse_inst);
} else { } else {
g_message(_("Invalid output from pipe-menu '%s'"), self->execute); g_message(_("Invalid output from pipe-menu '%s'"), self->execute);
} }
@ -262,19 +265,18 @@ static gunichar parse_shortcut(const gchar *label, gboolean allow_shortcut,
return shortcut; return shortcut;
} }
static void parse_menu_item(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, static void parse_menu_item(xmlNodePtr node, gpointer data)
gpointer data)
{ {
ObMenuParseState *state = data; ObMenuParseState *state = data;
gchar *label; gchar *label;
if (state->parent) { if (state->parent) {
if (parse_attr_string("label", node, &label)) { if (obt_parse_attr_string(node, "label", &label)) {
GSList *acts = NULL; GSList *acts = NULL;
for (node = node->children; node; node = node->next) for (node = node->children; node; node = node->next)
if (!xmlStrcasecmp(node->name, (const xmlChar*) "action")) { if (!xmlStrcasecmp(node->name, (const xmlChar*) "action")) {
ObActionsAct *a = actions_parse(i, doc, node); ObActionsAct *a = actions_parse(node);
if (a) if (a)
acts = g_slist_append(acts, a); acts = g_slist_append(acts, a);
} }
@ -284,16 +286,14 @@ static void parse_menu_item(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
} }
} }
static void parse_menu_separator(ObParseInst *i, static void parse_menu_separator(xmlNodePtr node, gpointer data)
xmlDocPtr doc, xmlNodePtr node,
gpointer data)
{ {
ObMenuParseState *state = data; ObMenuParseState *state = data;
if (state->parent) { if (state->parent) {
gchar *label; gchar *label;
if (!parse_attr_string("label", node, &label)) if (!obt_parse_attr_string(node, "label", &label))
label = NULL; label = NULL;
menu_add_separator(state->parent, -1, label); menu_add_separator(state->parent, -1, label);
@ -301,30 +301,29 @@ static void parse_menu_separator(ObParseInst *i,
} }
} }
static void parse_menu(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, static void parse_menu(xmlNodePtr node, gpointer data)
gpointer data)
{ {
ObMenuParseState *state = data; ObMenuParseState *state = data;
gchar *name = NULL, *title = NULL, *script = NULL; gchar *name = NULL, *title = NULL, *script = NULL;
ObMenu *menu; ObMenu *menu;
if (!parse_attr_string("id", node, &name)) if (!obt_parse_attr_string(node, "id", &name))
goto parse_menu_fail; goto parse_menu_fail;
if (!g_hash_table_lookup(menu_hash, name)) { 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; goto parse_menu_fail;
if ((menu = menu_new(name, title, TRUE, NULL))) { if ((menu = menu_new(name, title, TRUE, NULL))) {
menu->pipe_creator = state->pipe_creator; 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); menu->execute = parse_expand_tilde(script);
} else { } else {
ObMenu *old; ObMenu *old;
old = state->parent; old = state->parent;
state->parent = menu; state->parent = menu;
parse_tree(i, doc, node->children); obt_parse_tree(menu_parse_inst, node->children);
state->parent = old; state->parent = old;
} }
} }

View file

@ -22,7 +22,7 @@
#include "window.h" #include "window.h"
#include "geom.h" #include "geom.h"
#include "render/render.h" #include "render/render.h"
#include "parser/parse.h" #include "obt/parse.h"
#include <glib.h> #include <glib.h>

View file

@ -42,11 +42,12 @@
#include "ping.h" #include "ping.h"
#include "mainloop.h" #include "mainloop.h"
#include "gettext.h" #include "gettext.h"
#include "parser/parse.h"
#include "render/render.h" #include "render/render.h"
#include "render/theme.h" #include "render/theme.h"
#include "obt/display.h" #include "obt/display.h"
#include "obt/prop.h" #include "obt/prop.h"
#include "obt/keyboard.h"
#include "obt/parse.h"
#ifdef HAVE_FCNTL_H #ifdef HAVE_FCNTL_H
# include <fcntl.h> # include <fcntl.h>
@ -214,13 +215,11 @@ gint main(gint argc, gchar **argv)
keys[OB_KEY_DOWN] = obt_keyboard_keysym_to_keycode(XK_Down); keys[OB_KEY_DOWN] = obt_keyboard_keysym_to_keycode(XK_Down);
{ {
ObParseInst *i; ObtParseInst *i;
xmlDocPtr doc;
xmlNodePtr node;
/* startup the parsing so everything can register sections /* startup the parsing so everything can register sections
of the rc */ of the rc */
i = parse_startup(); i = obt_parse_instance_new();
/* register all the available actions */ /* register all the available actions */
actions_startup(reconfigure); actions_startup(reconfigure);
@ -228,9 +227,11 @@ gint main(gint argc, gchar **argv)
config_startup(i); config_startup(i);
/* parse/load user options */ /* parse/load user options */
if (parse_load_rc(NULL, &doc, &node)) { if (obt_parse_load_config_file(i, "openbox", "rc.xml",
parse_tree(i, doc, node->xmlChildrenNode); "openbox_config"))
parse_close(doc); {
obt_parse_tree(i, obt_parse_instance_root(i)->children);
obt_parse_close(i);
} else } else
g_message(_("Unable to find a valid config file, using some simple defaults")); g_message(_("Unable to find a valid config file, using some simple defaults"));
@ -241,7 +242,7 @@ gint main(gint argc, gchar **argv)
*/ */
/* we're done with parsing now, kill it */ /* we're done with parsing now, kill it */
parse_shutdown(i); obt_parse_instance_unref(i);
} }
/* load the theme specified in the rc file */ /* load the theme specified in the rc file */

View file

@ -17,14 +17,13 @@
See the COPYING file for a copy of the GNU General Public License. See the COPYING file for a copy of the GNU General Public License.
*/ */
#include "resist.h"
#include "client.h" #include "client.h"
#include "frame.h" #include "frame.h"
#include "stacking.h" #include "stacking.h"
#include "screen.h" #include "screen.h"
#include "dock.h" #include "dock.h"
#include "config.h" #include "config.h"
#include "resist.h"
#include "parser/parse.h"
#include <glib.h> #include <glib.h>

View file

@ -40,7 +40,7 @@ GList* session_state_find(struct _ObClient *c) { return NULL; }
#include "client.h" #include "client.h"
#include "focus.h" #include "focus.h"
#include "gettext.h" #include "gettext.h"
#include "parser/parse.h" #include "obt/parse.h"
#include <time.h> #include <time.h>
#include <errno.h> #include <errno.h>
@ -651,101 +651,106 @@ GList* session_state_find(ObClient *c)
static void session_load_file(const gchar *path) static void session_load_file(const gchar *path)
{ {
xmlDocPtr doc; ObtParseInst *i;
xmlNodePtr node, n, m; xmlNodePtr node, n, m;
GList *it, *inext; 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; return;
}
node = obt_parse_instance_root(i);
if ((n = parse_find_node("desktop", node->children))) if ((n = obt_parse_find_node(node->children, "desktop")))
session_desktop = parse_int(doc, n); session_desktop = obt_parse_node_int(n);
if ((n = parse_find_node("numdesktops", node->children))) if ((n = obt_parse_find_node(node->children, "numdesktops")))
session_num_desktops = parse_int(doc, n); 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 */ /* make sure they are all there for it to be valid */
if ((m = parse_find_node("orientation", n->children))) if ((m = obt_parse_find_node(n->children, "orientation")))
session_desktop_layout.orientation = parse_int(doc, m); session_desktop_layout.orientation = obt_parse_node_int(m);
if (m && (m = parse_find_node("startcorner", n->children))) if (m && (m = obt_parse_find_node(n->children, "startcorner")))
session_desktop_layout.start_corner = parse_int(doc, m); session_desktop_layout.start_corner = obt_parse_node_int(m);
if (m && (m = parse_find_node("columns", n->children))) if (m && (m = obt_parse_find_node(n->children, "columns")))
session_desktop_layout.columns = parse_int(doc, m); session_desktop_layout.columns = obt_parse_node_int(m);
if (m && (m = parse_find_node("rows", n->children))) if (m && (m = obt_parse_find_node(n->children, "rows")))
session_desktop_layout.rows = parse_int(doc, m); session_desktop_layout.rows = obt_parse_node_int(m);
session_desktop_layout_present = m != NULL; session_desktop_layout_present = m != NULL;
} }
if ((n = parse_find_node("desktopnames", node->children))) { if ((n = obt_parse_find_node(node->children, "desktopnames"))) {
for (m = parse_find_node("name", n->children); m; for (m = obt_parse_find_node(n->children, "name"); m;
m = parse_find_node("name", m->next)) m = obt_parse_find_node(m->next, "name"))
{ {
session_desktop_names = g_slist_append(session_desktop_names, 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; for (node = obt_parse_find_node(node->children, "window"); node != NULL;
node = parse_find_node("window", node->next)) node = obt_parse_find_node(node->next, "window"))
{ {
ObSessionState *state; ObSessionState *state;
state = g_new0(ObSessionState, 1); state = g_new0(ObSessionState, 1);
if (!parse_attr_string("id", node, &state->id)) if (!obt_parse_attr_string(node, "id", &state->id))
if (!parse_attr_string("command", node, &state->command)) if (!obt_parse_attr_string(node, "command", &state->command))
goto session_load_bail; 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; goto session_load_bail;
state->name = parse_string(doc, n); state->name = obt_parse_node_string(n);
if (!(n = parse_find_node("class", node->children))) if (!(n = obt_parse_find_node(node->children, "class")))
goto session_load_bail; goto session_load_bail;
state->class = parse_string(doc, n); state->class = obt_parse_node_string(n);
if (!(n = parse_find_node("role", node->children))) if (!(n = obt_parse_find_node(node->children, "role")))
goto session_load_bail; goto session_load_bail;
state->role = parse_string(doc, n); state->role = obt_parse_node_string(n);
if (!(n = parse_find_node("windowtype", node->children))) if (!(n = obt_parse_find_node(node->children, "windowtype")))
goto session_load_bail; goto session_load_bail;
state->type = parse_int(doc, n); state->type = obt_parse_node_int(n);
if (!(n = parse_find_node("desktop", node->children))) if (!(n = obt_parse_find_node(node->children, "desktop")))
goto session_load_bail; goto session_load_bail;
state->desktop = parse_int(doc, n); state->desktop = obt_parse_node_int(n);
if (!(n = parse_find_node("x", node->children))) if (!(n = obt_parse_find_node(node->children, "x")))
goto session_load_bail; goto session_load_bail;
state->x = parse_int(doc, n); state->x = obt_parse_node_int(n);
if (!(n = parse_find_node("y", node->children))) if (!(n = obt_parse_find_node(node->children, "y")))
goto session_load_bail; goto session_load_bail;
state->y = parse_int(doc, n); state->y = obt_parse_node_int(n);
if (!(n = parse_find_node("width", node->children))) if (!(n = obt_parse_find_node(node->children, "width")))
goto session_load_bail; goto session_load_bail;
state->w = parse_int(doc, n); state->w = obt_parse_node_int(n);
if (!(n = parse_find_node("height", node->children))) if (!(n = obt_parse_find_node(node->children, "height")))
goto session_load_bail; goto session_load_bail;
state->h = parse_int(doc, n); state->h = obt_parse_node_int(n);
state->shaded = state->shaded =
parse_find_node("shaded", node->children) != NULL; obt_parse_find_node(node->children, "shaded") != NULL;
state->iconic = state->iconic =
parse_find_node("iconic", node->children) != NULL; obt_parse_find_node(node->children, "iconic") != NULL;
state->skip_pager = state->skip_pager =
parse_find_node("skip_pager", node->children) != NULL; obt_parse_find_node(node->children, "skip_pager") != NULL;
state->skip_taskbar = state->skip_taskbar =
parse_find_node("skip_taskbar", node->children) != NULL; obt_parse_find_node(node->children, "skip_taskbar") != NULL;
state->fullscreen = state->fullscreen =
parse_find_node("fullscreen", node->children) != NULL; obt_parse_find_node(node->children, "fullscreen") != NULL;
state->above = state->above =
parse_find_node("above", node->children) != NULL; obt_parse_find_node(node->children, "above") != NULL;
state->below = state->below =
parse_find_node("below", node->children) != NULL; obt_parse_find_node(node->children, "below") != NULL;
state->max_horz = state->max_horz =
parse_find_node("max_horz", node->children) != NULL; obt_parse_find_node(node->children, "max_horz") != NULL;
state->max_vert = state->max_vert =
parse_find_node("max_vert", node->children) != NULL; obt_parse_find_node(node->children, "max_vert") != NULL;
state->undecorated = state->undecorated =
parse_find_node("undecorated", node->children) != NULL; obt_parse_find_node(node->children, "undecorated") != NULL;
state->focused = 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 /* save this. they are in the file in stacking order, so preserve
that order here */ that order here */
@ -800,7 +805,7 @@ static void session_load_file(const gchar *path)
} }
} }
xmlFreeDoc(doc); obt_parse_instance_unref(i);
} }
#endif #endif

View file

@ -1,4 +0,0 @@
all clean install:
$(MAKE) -C .. -$(MAKEFLAGS) $@
.PHONY: all clean install

View file

@ -1,11 +0,0 @@
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@

View file

@ -1,533 +0,0 @@
/* -*- 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;
}

View file

@ -1,98 +0,0 @@
/* -*- 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

View file

@ -23,7 +23,7 @@
#include "mask.h" #include "mask.h"
#include "theme.h" #include "theme.h"
#include "icon.h" #include "icon.h"
#include "parser/parse.h" #include "obt/parse.h"
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xresource.h> #include <X11/Xresource.h>