*/
#include "config.h"
-#include "config_value.h"
+#include "config_parser.h"
#include "keyboard.h"
#include "mouse.h"
#include "action.h"
}
}
-static void parse_focus(xmlNodePtr node, gpointer d)
-{
- xmlNodePtr n;
-
- node = node->children;
-
- if ((n = obt_xml_find_sibling(node, "focusNew")))
- config_focus_new = obt_xml_node_bool(n);
- if ((n = obt_xml_find_sibling(node, "followMouse")))
- config_focus_follow = obt_xml_node_bool(n);
- if ((n = obt_xml_find_sibling(node, "focusDelay")))
- config_focus_delay = obt_xml_node_int(n);
- if ((n = obt_xml_find_sibling(node, "raiseOnFocus")))
- config_focus_raise = obt_xml_node_bool(n);
- if ((n = obt_xml_find_sibling(node, "focusLast")))
- config_focus_last = obt_xml_node_bool(n);
- if ((n = obt_xml_find_sibling(node, "underMouse")))
- config_focus_under_mouse = obt_xml_node_bool(n);
- if ((n = obt_xml_find_sibling(node, "unfocusOnLeave")))
- config_unfocus_leave = obt_xml_node_bool(n);
-}
-
static void parse_placement(xmlNodePtr node, gpointer d)
{
xmlNodePtr n;
action_parser_unref(p);
}
-void config_startup(ObtXmlInst *i)
+#define BOOL config_parser_bool
+#define INT config_parser_int
+#define STRING config_parser_string
+
+void config_startup(ObConfigParser *p, ObtXmlInst *i)
{
- config_focus_new = TRUE;
- config_focus_follow = FALSE;
- config_focus_delay = 0;
- config_focus_raise = FALSE;
- config_focus_last = TRUE;
- config_focus_under_mouse = FALSE;
- config_unfocus_leave = FALSE;
-
- obt_xml_register(i, "focus", parse_focus, NULL);
+ BOOL(p, "focus/focusNew", "yes", &config_focus_new);
+ BOOL(p, "focus/followMouse", "no", &config_focus_follow);
+ INT(p, "focus/focusDelay", "0", &config_focus_delay);
+ BOOL(p, "focus/raiseOnFocus", "no", &config_focus_raise);
+ BOOL(p, "focus/focusLast", "yes", &config_focus_last);
+ BOOL(p, "focus/underMouse", "no", &config_focus_under_mouse);
+ BOOL(p, "focus/unfocusOnLeave", "no", &config_unfocus_leave);
config_place_policy = OB_PLACE_POLICY_SMART;
config_place_center = TRUE;
#include <glib.h>
+struct _ObConfigParser;
+
typedef struct _ObAppSettings ObAppSettings;
struct _ObAppSettings
/*! Per app settings */
extern GSList *config_per_app_settings;
-void config_startup(ObtXmlInst *i);
+void config_startup(struct _ObConfigParser *p, ObtXmlInst *i);
void config_shutdown(void);
/*! Create an ObAppSettings structure with the default values */
}
void config_parser_int(ObConfigParser *p,
- const gchar *name, const gchar *def, gint *v)
+ const gchar *name, const gchar *def, guint *v)
{
ObConfigValue *cv = config_value_new_string(def);
add(p, name, cv, OB_CONFIG_VALUE_INTEGER, (ObConfigValueDataPtr)v);
obt_xml_new_file(i, "openbox_config");
root = obt_xml_root(i);
- n = obt_xml_tree_get_node("focus");
- config_focus_new = read_bool(n, "focusnew", TRUE);
- config_focus_follow = read_bool(n, "followmouse", FALSE);
- config_focus_delay = read_int(n, "focusdelay", 0);
- config_focus_raise = read_bool(n, "raiseonfocus", FALSE);
- config_focus_last = read_bool(n, "focuslast", TRUE);
- config_focus_under_mouse = read_bool(n, "undermouse", FALSE);
- config_unfocus_leave = read_bool(n, "unfocusonleave", FALSE);
-
n = obt_xml_tree_get_node("placement");
config_place_policy = read_enum(
n, "policy",
void config_parser_bool(ObConfigParser *p,
const gchar *name, const gchar *def, gboolean *v);
void config_parser_int(ObConfigParser *p,
- const gchar *name, const gchar *def, gint *v);
+ const gchar *name, const gchar *def, guint *v);
void config_parser_string(ObConfigParser *p,
const gchar *name, const gchar *def,
const gchar **v);
#include "grab.h"
#include "group.h"
#include "config.h"
+#include "config_parser.h"
#include "ping.h"
#include "prompt.h"
#include "gettext.h"
if (reconfigure) obt_keyboard_reload();
{
+ ObConfigParser *p;
ObtXmlInst *i;
/* startup the parsing so everything can register sections
of the rc */
+ p = config_parser_new();
i = obt_xml_instance_new();
/* register all the available actions and filters */
action_startup(reconfigure);
action_filter_startup(reconfigure);
/* start up config which sets up with the parser */
- config_startup(i);
+ config_startup(p, i);
/* parse/load user options */
if ((config_file &&
obt_xml_load_config_file(i, "openbox", "rc",
"openbox_config"))
{
+ config_parser_read(p, i);
obt_xml_tree_from_root(i);
obt_xml_close(i);
}
/* we're done with parsing now, kill it */
obt_xml_instance_unref(i);
+ config_parser_unref(p);
}
/* load the theme specified in the rc file */