From cbbf90a718ecc6836ef7a77b9040aebb9da348b8 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sat, 5 Apr 2003 20:27:03 +0000 Subject: change how rc parsing will work. a=b will be parsed in any [section] and given to a separate parsing callback. no more general config infrastructure needed/ --- plugins/placement/history.c | 8 ++++---- plugins/placement/placement.c | 44 ++++++++++++++++++++++--------------------- 2 files changed, 27 insertions(+), 25 deletions(-) (limited to 'plugins/placement') diff --git a/plugins/placement/history.c b/plugins/placement/history.c index fbfbf252..dfdcea28 100644 --- a/plugins/placement/history.c +++ b/plugins/placement/history.c @@ -1,7 +1,7 @@ -#include "../../kernel/openbox.h" -#include "../../kernel/dispatch.h" -#include "../../kernel/frame.h" -#include "../../kernel/client.h" +#include "kernel/openbox.h" +#include "kernel/dispatch.h" +#include "kernel/frame.h" +#include "kernel/client.h" #include #include #ifdef HAVE_STDLIB_H diff --git a/plugins/placement/placement.c b/plugins/placement/placement.c index 76b45525..23ffbb5d 100644 --- a/plugins/placement/placement.c +++ b/plugins/placement/placement.c @@ -1,24 +1,31 @@ -#include "../../kernel/dispatch.h" -#include "../../kernel/client.h" -#include "../../kernel/frame.h" -#include "../../kernel/screen.h" -#include "../../kernel/openbox.h" -#include "../../kernel/config.h" +#include "kernel/dispatch.h" +#include "kernel/client.h" +#include "kernel/frame.h" +#include "kernel/screen.h" +#include "kernel/openbox.h" +#include "kernel/parse.h" #include "history.h" #include -gboolean history = TRUE; +static gboolean history; + +static void parse_assign(char *name, ParseToken *value) +{ + if (!g_ascii_strcasecmp(name, "remember")) { + if (value->type != TOKEN_BOOL) + yyerror("invalid value"); + else + history = value->data.bool; + } else + yyerror("invalid option"); + parse_free_token(value); +} void plugin_setup_config() { - ConfigValue val; - - config_def_set(config_def_new("placement.remember", Config_Bool, - "Remember Window Positions", - "Place windows where they last were " - "positioned.")); - val.bool = TRUE; - config_set("placement.remember", Config_Bool, val); + history = TRUE; + + parse_reg_section("placement", NULL, parse_assign); } static void place_random(Client *c) @@ -48,17 +55,12 @@ static void place_random(Client *c) static void event(ObEvent *e, void *foo) { - ConfigValue remember; - g_assert(e->type == Event_Client_New); /* requested a position */ if (e->data.c.client->positioned) return; - if (!config_get("placement.remember", Config_Bool, &remember)) - g_assert_not_reached(); - - if (!remember.bool || !place_history(e->data.c.client)) + if (!history || !place_history(e->data.c.client)) place_random(e->data.c.client); } -- cgit v1.2.3