]> Dogcows Code - chaz/openbox/commitdiff
make the openbox engine use the new config shit instead of the themerc shit.
authorDana Jansens <danakj@orodu.net>
Sat, 22 Mar 2003 23:26:43 +0000 (23:26 +0000)
committerDana Jansens <danakj@orodu.net>
Sat, 22 Mar 2003 23:26:43 +0000 (23:26 +0000)
order te startup so that plugins can set up their config shit before parsing the config, then the config is parsed, engine is loaded, and finally the plugins are officially started.

engines/openbox/Makefile.am
engines/openbox/openbox.c
engines/openbox/theme.c
openbox/config.c
openbox/engine.c
openbox/openbox.c
openbox/plugin.c
openbox/plugin.h

index 512a754c476014576408e0dff76ad1238e4c604d..1cfa3e5b889df34df9aac557f2fa7b8b2c0d0fa1 100644 (file)
@@ -5,6 +5,7 @@ CPPFLAGS=$(XFT_CFLAGS) $(GLIB_CFLAGS) @CPPFLAGS@ \
 -DENGINEDIR=\"$(enginedir)\" \
 -DTHEMEDIR=\"$(themedir)\" \
 -DDEFAULT_THEME=\"nyz\" \
+-DDEFAULT_FONT=\"Sans-6\" \
 -DG_LOG_DOMAIN=\"Openbox-Engine\"
 
 engine_LTLIBRARIES=openbox.la
index 0123f474246e30466a6f491cddb9bc61ed71e3d1..f9ac31d4c3f2c5a5f5770c8e19d2e0df08884f9d 100644 (file)
@@ -3,7 +3,7 @@
 #include "../../kernel/screen.h"
 #include "../../kernel/extensions.h"
 #include "../../kernel/dispatch.h"
-#include "../../kernel/themerc.h"
+#include "../../kernel/config.h"
 #include "../../kernel/frame.h"
 #include "../../render/render.h"
 #include "../../render/color.h"
@@ -605,12 +605,18 @@ static void layout_title(ObFrame *self)
     const char *lc;
     int x;
     gboolean n, d, i, l, m ,c;
+    ConfigValue layout;
 
     n = d = i = l = m = c = FALSE;
 
+    if (!config_get("titlebar.layout", Config_String, &layout)) {
+        layout.string = "NDLIMC";
+        config_set("titlebar.layout", Config_String, layout);
+    }
+
     /* figure out whats being shown, and the width of the label */
     self->label_width = self->width - (s_bevel + 1) * 2;
-    for (lc = themerc_titlebar_layout; *lc != '\0'; ++lc) {
+    for (lc = layout.string; *lc != '\0'; ++lc) {
        switch (*lc) {
        case 'N':
            if (!(self->frame.client->decorations & Decor_Icon)) break;
@@ -678,7 +684,7 @@ static void layout_title(ObFrame *self)
     }
 
     x = s_bevel + 1;
-    for (lc = themerc_titlebar_layout; *lc != '\0'; ++lc) {
+    for (lc = layout.string; *lc != '\0'; ++lc) {
        switch (*lc) {
        case 'N':
            if (!n) break;
index 915ec9b939ae92e9c965daaa6e7301da2fceb494..3c7c26970e8dc730b966d7246d60a2925a357f7c 100644 (file)
@@ -1,5 +1,5 @@
 #include "openbox.h"
-#include "../../kernel/themerc.h"
+#include "../../kernel/config.h"
 #include "../../kernel/openbox.h"
 
 #include <glib.h>
@@ -135,10 +135,14 @@ gboolean read_mask(XrmDatabase db, char *rname, pixmap_mask **value)
     int hx, hy; /* ignored */
     unsigned int w, h;
     unsigned char *b;
+    ConfigValue theme;
   
     if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
         retvalue.addr != NULL) {
-       button_dir = g_strdup_printf("%s_buttons", themerc_theme);
+        if (!config_get("theme", Config_String, &theme))
+            g_assert_not_reached(); /* where's the default!? its not set? */
+
+       button_dir = g_strdup_printf("%s_buttons", theme.string);
 
         s = g_build_filename(g_get_home_dir(), ".openbox", "themes",
                              "openbox", button_dir, retvalue.addr, NULL);
@@ -153,8 +157,8 @@ gboolean read_mask(XrmDatabase db, char *rname, pixmap_mask **value)
                 ret = TRUE;
             else {
                 g_free(s);
-                s = g_strdup_printf("%s_buttons/%s", themerc_theme, 
-                                    themerc_theme);
+                s = g_strdup_printf("%s_buttons/%s", theme.string,
+                                    theme.string);
                 if (XReadBitmapFileData(s, &w, &h, &b, &hx, &hy) ==
                     BitmapSuccess) 
                     ret = TRUE;
@@ -289,11 +293,12 @@ gboolean load()
     XrmDatabase db = NULL;
     Justify winjust;
     char *winjuststr;
+    ConfigValue theme, shadow, offset, font;
 
-    if (themerc_theme != NULL) {
-       db = loaddb(themerc_theme);
+    if (config_get("theme", Config_String, &theme)) {
+       db = loaddb(theme.string);
         if (db == NULL) {
-           g_warning("Failed to load the theme '%s'", themerc_theme);
+           g_warning("Failed to load the theme '%s'", theme.string);
            g_message("Falling back to the default: '%s'", DEFAULT_THEME);
        }
     }
@@ -304,14 +309,22 @@ gboolean load()
            return FALSE;
        }
         /* change to reflect what was actually loaded */
-        g_free(themerc_theme);
-        themerc_theme = g_strdup(DEFAULT_THEME);
+        theme.string = DEFAULT_THEME;
+        config_set("theme", Config_String, theme);
     }
 
-    /* load the font, not from the theme file tho, its in themerc_font */
+    /* load the font, not from the theme file tho, its in the config */
     s_winfont_shadow = 1; /* XXX read from themrc */
-    s_winfont_shadow_offset = 1; /* XXX read from themerc */
-    s_winfont = font_open(themerc_font);
+    if (!config_get("font.shadow.offset", Config_Integer, &offset) ||
+        offset.integer < 0 || offset.integer >= 10) {
+        s_winfont_shadow_offset = 1; /* default */
+    }
+    
+    if (!config_get("font", Config_String, &font)) {
+        font.string = DEFAULT_FONT;
+        config_set("font", Config_String, font);
+    }
+    s_winfont = font_open(font.string);
     s_winfont_height = font_height(s_winfont, s_winfont_shadow,
                                    s_winfont_shadow_offset);
 
index b9c24dedc147f8f9d9b855096f4c8a00415ee033..0f6be9a35348ad886e44f1e31ef1b9e8ba76c8c9 100644 (file)
@@ -27,8 +27,8 @@ void config_startup()
     config_def_set(config_def_new("engine", Config_String));
     config_def_set(config_def_new("theme", Config_String));
     config_def_set(config_def_new("font", Config_String));
+    config_def_set(config_def_new("font.shadow", Config_Integer));
     config_def_set(config_def_new("font.shadow.offset", Config_Integer));
-    config_def_set(config_def_new("font.shadow.tint", Config_Integer));
     config_def_set(config_def_new("titlebar.layout", Config_String));
 
     /*g_datalist_foreach(&config_def, print_config, NULL);*/
@@ -54,15 +54,15 @@ void config_parse()
         load = TRUE;
     }
     g_free(path);
-    g_free(path);
 
     if (!load) {
         /* load the system wide rc */
         path = g_build_filename(RCDIR, "rc3", NULL);
         if ((file = fopen(path, "r")) != NULL) {
-            cparse_go(path, file);
+            /*cparse_go(path, file);*/
             fclose(file);
         }
+        g_free(path);
     }
 }
 
index c4e24a39cb5dd49536e30c28488635796a8e439d..c654d26380d942a287543528163b7f1fcb64d547 100644 (file)
@@ -64,9 +64,8 @@ void engine_startup()
     ConfigValue engine;
 
     module = NULL;
-    g_message("ENGINE STARTUP");
+
     if (config_get("engine", Config_String, &engine)) {
-        g_warning("GOT ENGINE %s", engine.string);
        if (load(engine.string))
            return;
        g_warning("Failed to load the engine '%s'", engine.string);
index b32977b13d7260ed8352eb121938208a14961ac5..6645f5bbf8bf9e2d899fbe8f51675a42d6bb9e67 100644 (file)
@@ -147,23 +147,22 @@ int main(int argc, char **argv)
         config_startup();
        render_startup();
        font_startup();
-       themerc_startup();
+        plugin_startup();
+
+        /* load the plugins specified in the pluginrc */
+        plugin_loadall();
+        /* parse/load user options */
+        config_parse();
+
        engine_startup();
        event_startup();
        screen_startup();
        focus_startup();
        client_startup();
         grab_startup();
-        plugin_startup();
-
-        /* XXX load all plugins!! */
-        plugin_open("focus");
-        plugin_open("keyboard");
-        plugin_open("mouse");
-        plugin_open("placement");
-        plugin_open("resistance");
 
-        config_parse();
+        /* call startup for all the plugins */
+        plugin_startall();
 
        /* get all the existing windows */
        client_manage_all();
index a8556fc728ba56a900d8fabea74f3ba2c76ac799..e0067f22e808144750bb759d1954e573d0d8ea85 100644 (file)
@@ -94,9 +94,9 @@ gboolean plugin_open(char *name)
         g_warning("failed to load plugin '%s'", name);
         return FALSE;
     }
+    /* XXX p->plugin_set_config(); */
 
     g_datalist_set_data_full(&plugins, name, p,  (GDestroyNotify) plugin_free);
-    p->startup();
     return TRUE;
 }
 
@@ -104,3 +104,49 @@ void plugin_close(char *name)
 {
     g_datalist_remove_data(&plugins, name);
 }
+
+static void foreach_start(GQuark key, Plugin *p, gpointer *foo)
+{
+    p->startup();
+}
+
+void plugin_startall()
+{
+    g_datalist_foreach(&plugins, (GDataForeachFunc)foreach_start, NULL);
+}
+
+void plugin_loadall()
+{
+    GIOChannel *io;
+    GError *err;
+    char *path, *name;
+
+    path = g_build_filename(g_get_home_dir(), ".openbox", "pluginrc", NULL);
+    err = NULL;
+    io = g_io_channel_new_file(path, "r", &err);
+    g_free(path);
+
+    if (io == NULL) {
+        path = g_build_filename(RCDIR, "pluginrc", NULL);
+        err = NULL;
+        io = g_io_channel_new_file(path, "r", &err);
+        g_free(path);
+    }
+
+    if (io == NULL) {
+        /* load the default plugins */
+        plugin_open("focus");
+        plugin_open("keyboard");
+        plugin_open("mouse");
+        plugin_open("placement");
+        plugin_open("resistance");
+    } else {
+        /* load the plugins in the rc file */
+        while (g_io_channel_read_line(io, &name, NULL, NULL, &err) ==
+               G_IO_STATUS_NORMAL) {
+            plugin_open(name);
+            g_free(name);
+        }
+        g_io_channel_unref(io);
+    }
+}
index d5cb2f6f27747bfbe725fe1af20fc3291030bdbe..8595fbacc2c0159ef46ded7354845fe1f095a68e 100644 (file)
@@ -4,6 +4,9 @@
 void plugin_startup();
 void plugin_shutdown();
 
+void plugin_loadall();
+void plugin_startall();
+
 gboolean plugin_open(char *name);
 void plugin_close(char *name);
 
This page took 0.039504 seconds and 4 git commands to generate.