]> Dogcows Code - chaz/openbox/blobdiff - openbox/engine.c
move config option loading for the kernel into config.c/h
[chaz/openbox] / openbox / engine.c
index 34d7291801aa105be3a3d00ea80e606ad5452be6..53e10debebf80701741ae03f7cba282a43e2063e 100644 (file)
@@ -1,5 +1,5 @@
 #include "engine.h"
-#include "parse.h"
+#include "config.h"
 
 #include <glib.h>
 #include <gmodule.h>
@@ -7,14 +7,6 @@
 #  include <stdlib.h>
 #endif
 
-char *engine_name;
-char *engine_theme;
-char *engine_layout;
-char *engine_font;
-gboolean engine_shadow;
-int engine_shadow_offset;
-int engine_shadow_tint;
-
 EngineFrameNew *engine_frame_new;
 EngineFrameGrabClient *engine_frame_grab_client;
 EngineFrameReleaseClient *engine_frame_release_client;
@@ -46,19 +38,21 @@ static gboolean load(char *name)
 
     g_assert(module == NULL);
 
-    path = g_build_filename(ENGINEDIR, name, NULL);
+    path = g_build_filename(g_get_home_dir(), ".openbox", "engines", name,
+                            NULL);
     module = g_module_open(path, 0);
     g_free(path);
 
     if (module == NULL) {
-       path = g_build_filename(g_get_home_dir(), ".openbox", "engines", name,
-                               NULL);
-       module = g_module_open(path, 0);
-       g_free(path);
+        path = g_build_filename(ENGINEDIR, name, NULL);
+        module = g_module_open(path, 0);
+        g_free(path);
     }
 
-    if (module == NULL)
+    if (module == NULL) {
+        g_warning(g_module_error());
        return FALSE;
+    }
 
     /* load the engine's symbols */
     LOADSYM(startup, estartup);
@@ -84,81 +78,21 @@ static gboolean load(char *name)
     return TRUE;
 }
 
-static void parse_assign(char *name, ParseToken *value)
-{
-    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;
-
-    parse_reg_section("engine", NULL, parse_assign);
 }
 
 void engine_load()
 {
-    if (load(engine_name))
+    if (load(config_engine_name))
         return;
-    g_warning("Failed to load the engine '%s'", engine_name);
+    g_warning("Failed to load the engine '%s'", config_engine_name);
     g_message("Falling back to the default: '%s'", DEFAULT_ENGINE);
+    if (module != NULL) {
+       g_module_close(module);
+        module = NULL;
+    }
     if (!load(DEFAULT_ENGINE)) {
        g_critical("Failed to load the engine '%s'. Aborting", DEFAULT_ENGINE);
        exit(1);
@@ -167,7 +101,6 @@ void engine_load()
 
 void engine_shutdown()
 {
-    g_free(engine_name);
     if (module != NULL) {
        eshutdown();
        g_module_close(module);
This page took 0.02575 seconds and 4 git commands to generate.