From: Dana Jansens Date: Mon, 8 Aug 2011 17:18:52 +0000 (-0400) Subject: Convert the focus parsing section to the new config parser X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=861f2e5e1777b3326d59ed8481606bed742636fb;p=dana%2Fopenbox.git Convert the focus parsing section to the new config parser --- diff --git a/openbox/config.c b/openbox/config.c index 5b7caad1..f3b161de 100644 --- a/openbox/config.c +++ b/openbox/config.c @@ -18,7 +18,7 @@ */ #include "config.h" -#include "config_value.h" +#include "config_parser.h" #include "keyboard.h" #include "mouse.h" #include "action.h" @@ -540,28 +540,6 @@ static void parse_mouse(xmlNodePtr node, gpointer d) } } -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; @@ -1011,17 +989,19 @@ static void bind_default_mouse(void) 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; diff --git a/openbox/config.h b/openbox/config.h index 834193de..cae09e59 100644 --- a/openbox/config.h +++ b/openbox/config.h @@ -33,6 +33,8 @@ #include +struct _ObConfigParser; + typedef struct _ObAppSettings ObAppSettings; struct _ObAppSettings @@ -204,7 +206,7 @@ extern GSList *config_menu_files; /*! 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 */ diff --git a/openbox/config_parser.c b/openbox/config_parser.c index cd9a6e18..941216b3 100644 --- a/openbox/config_parser.c +++ b/openbox/config_parser.c @@ -151,7 +151,7 @@ void config_parser_bool(ObConfigParser *p, } 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); @@ -338,15 +338,6 @@ void config_parser_options(void) 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", diff --git a/openbox/config_parser.h b/openbox/config_parser.h index 50b6db5b..877cc2d5 100644 --- a/openbox/config_parser.h +++ b/openbox/config_parser.h @@ -35,7 +35,7 @@ void config_parser_unref(ObConfigParser *p); 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); diff --git a/openbox/openbox.c b/openbox/openbox.c index 14d0bd27..a27106b4 100644 --- a/openbox/openbox.c +++ b/openbox/openbox.c @@ -41,6 +41,7 @@ #include "grab.h" #include "group.h" #include "config.h" +#include "config_parser.h" #include "ping.h" #include "prompt.h" #include "gettext.h" @@ -230,17 +231,19 @@ gint main(gint argc, gchar **argv) 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 && @@ -248,6 +251,7 @@ gint main(gint argc, gchar **argv) 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); } @@ -268,6 +272,7 @@ gint main(gint argc, gchar **argv) /* 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 */