X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=openbox%2Fengine.c;h=5012fecf872bb49bece7b00c186834361122ec3e;hb=af21cb131a784b3d76e9930421a3595f5819dc71;hp=c654d26380d942a287543528163b7f1fcb64d547;hpb=5bf68f762b8fc87cf5583b645b948b4fe55f179f;p=chaz%2Fopenbox diff --git a/openbox/engine.c b/openbox/engine.c index c654d263..5012fecf 100644 --- a/openbox/engine.c +++ b/openbox/engine.c @@ -1,5 +1,5 @@ #include "engine.h" -#include "config.h" +#include "parse.h" #include #include @@ -7,9 +7,17 @@ # include #endif -static GModule *module; -static EngineStartup *estartup; -static EngineShutdown *eshutdown; +char *engine_name; +char *engine_theme; +char *engine_layout; +char *engine_font; +gboolean engine_shadow; +int engine_shadow_offset; +int engine_shadow_tint; + +static GModule *module = NULL; +static EngineStartup *estartup = NULL; +static EngineShutdown *eshutdown = NULL; #define LOADSYM(name, var) \ if (!g_module_symbol(module, #name, (gpointer*)&var)) { \ @@ -59,18 +67,81 @@ static gboolean load(char *name) return TRUE; } -void engine_startup() +static void parse_assign(char *name, ParseToken *value) { - ConfigValue engine; + if (!g_ascii_strcasecmp(name, "engine")) { + if (value->type != TOKEN_STRING) + yyerror("invalid value"); + else { + g_free(engine_name); + engine_name = g_strdup(value->data.string); + } + } else if (!g_ascii_strcasecmp(name, "theme")) { + if (value->type != TOKEN_STRING) + yyerror("invalid value"); + else { + g_free(engine_theme); + engine_theme = g_strdup(value->data.string); + } + } else if (!g_ascii_strcasecmp(name, "titlebarlayout")) { + if (value->type != TOKEN_STRING) + yyerror("invalid value"); + else { + g_free(engine_layout); + engine_layout = g_strdup(value->data.string); + } + } else if (!g_ascii_strcasecmp(name, "font.title")) { + if (value->type != TOKEN_STRING) + yyerror("invalid value"); + else { + g_free(engine_font); + engine_font = g_strdup(value->data.string); + } + } else if (!g_ascii_strcasecmp(name, "font.title.shadow")) { + if (value->type != TOKEN_BOOL) + yyerror("invalid value"); + else { + engine_shadow = value->data.bool; + } + } else if (!g_ascii_strcasecmp(name, "font.title.shadow.offset")) { + if (value->type != TOKEN_INTEGER) + yyerror("invalid value"); + else { + engine_shadow_offset = value->data.integer; + } + } else if (!g_ascii_strcasecmp(name, "font.title.shadow.tint")) { + if (value->type != TOKEN_INTEGER) + yyerror("invalid value"); + else { + engine_shadow_tint = value->data.integer; + if (engine_shadow_tint < -100) engine_shadow_tint = -100; + else if (engine_shadow_tint > 100) engine_shadow_tint = 100; + } + } else + yyerror("invalid option"); + parse_free_token(value); +} +void engine_startup() +{ module = NULL; + engine_name = g_strdup(DEFAULT_ENGINE); + engine_theme = NULL; + engine_layout = g_strdup("NLIMC"); + engine_font = g_strdup("Sans-7"); + engine_shadow = FALSE; + engine_shadow_offset = 1; + engine_shadow_tint = 25; - if (config_get("engine", Config_String, &engine)) { - if (load(engine.string)) - return; - g_warning("Failed to load the engine '%s'", engine.string); - g_message("Falling back to the default: '%s'", DEFAULT_ENGINE); - } + parse_reg_section("engine", NULL, parse_assign); +} + +void engine_load() +{ + if (load(engine_name)) + return; + g_warning("Failed to load the engine '%s'", engine_name); + g_message("Falling back to the default: '%s'", DEFAULT_ENGINE); if (!load(DEFAULT_ENGINE)) { g_critical("Failed to load the engine '%s'. Aborting", DEFAULT_ENGINE); exit(1); @@ -79,6 +150,7 @@ void engine_startup() void engine_shutdown() { + g_free(engine_name); if (module != NULL) { eshutdown(); g_module_close(module);