make the openbox engine use the new config shit instead of the themerc shit.
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.
This commit is contained in:
parent
4cc0d9b72d
commit
5bf68f762b
8 changed files with 98 additions and 31 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue