diff -Nru /tmp/a/openbox-3.2/openbox/config.c ./openbox/config.c --- /tmp/a/openbox-3.2/openbox/config.c 2004-04-17 14:12:49.000000000 +0200 +++ ./openbox/config.c 2004-06-28 05:33:44.000000000 +0200 @@ -35,6 +35,7 @@ gchar *config_theme; gboolean config_theme_keepborder; +GHashTable *config_theme_overrides; gchar *config_title_layout; @@ -235,6 +236,7 @@ gpointer d) { xmlNodePtr n; + int j; node = node->children; @@ -252,6 +254,24 @@ } if ((n = parse_find_node("keepBorder", node))) config_theme_keepborder = parse_bool(doc, n); + + /* Theme overrides */ + if (config_theme_overrides) + g_hash_table_destroy(config_theme_overrides); + config_theme_overrides = g_hash_table_new(g_str_hash, g_str_equal); + + n = parse_find_node("override", node); + while (n) { + gchar *key, *value; + xmlNodePtr nkey, nvalue; + + nkey = parse_find_node("key", n->children); + nvalue = parse_find_node("value", n->children); + key = parse_string(doc, nkey); + value = parse_string(doc, nvalue); + g_hash_table_insert(config_theme_overrides, key, value); + n = parse_find_node("override", n->next); + } } static void parse_desktops(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, @@ -542,6 +562,7 @@ parse_register(i, "placement", parse_placement, NULL); config_theme = NULL; + config_theme_overrides = NULL; config_title_layout = g_strdup("NLIMC"); config_theme_keepborder = TRUE; @@ -606,6 +627,7 @@ GSList *it; g_free(config_theme); + g_free(config_theme_overrides); g_free(config_title_layout); diff -Nru /tmp/a/openbox-3.2/openbox/config.h ./openbox/config.h --- /tmp/a/openbox-3.2/openbox/config.h 2004-03-21 21:06:40.000000000 +0100 +++ ./openbox/config.h 2004-06-28 05:03:56.000000000 +0200 @@ -77,6 +77,9 @@ /* The name of the theme */ extern gchar *config_theme; +/* Overrides for the theme */ +extern GHashTable *config_theme_overrides; + /* Show the onepixel border after toggleDecor */ extern gboolean config_theme_keepborder; /* Titlebar button layout */ diff -Nru /tmp/a/openbox-3.2/openbox/openbox.c ./openbox/openbox.c --- /tmp/a/openbox-3.2/openbox/openbox.c 2004-03-21 13:16:10.000000000 +0100 +++ ./openbox/openbox.c 2004-06-28 04:44:19.000000000 +0200 @@ -221,7 +221,8 @@ /* load the theme specified in the rc file */ { RrTheme *theme; - if ((theme = RrThemeNew(ob_rr_inst, config_theme))) { + if ((theme = RrThemeNew(ob_rr_inst, config_theme, + config_theme_overrides))) { RrThemeFree(ob_rr_theme); ob_rr_theme = theme; } diff -Nru /tmp/a/openbox-3.2/render/theme.c ./render/theme.c --- /tmp/a/openbox-3.2/render/theme.c 2004-03-21 02:03:00.000000000 +0100 +++ ./render/theme.c 2004-06-28 05:52:07.000000000 +0200 @@ -31,20 +31,24 @@ #include static XrmDatabase loaddb(RrTheme *theme, gchar *name); -static gboolean read_int(XrmDatabase db, gchar *rname, gint *value); -static gboolean read_string(XrmDatabase db, gchar *rname, gchar **value); -static gboolean read_color(XrmDatabase db, const RrInstance *inst, +static gboolean read_int(XrmDatabase db, GHashTable *override, gchar *rname, + gint *value); +static gboolean read_string(XrmDatabase db, GHashTable *override, + gchar *rname, gchar **value); +static gboolean read_color(XrmDatabase db, GHashTable *override, + const RrInstance *inst, gchar *rname, RrColor **value); static gboolean read_mask(const RrInstance *inst, gchar *maskname, RrTheme *theme, RrPixmapMask **value); -static gboolean read_appearance(XrmDatabase db, const RrInstance *inst, +static gboolean read_appearance(XrmDatabase db, GHashTable *override, + const RrInstance *inst, gchar *rname, RrAppearance *value, gboolean allow_trans); static RrPixel32* read_c_image(gint width, gint height, const guint8 *data); static void set_default_appearance(RrAppearance *a); -RrTheme* RrThemeNew(const RrInstance *inst, gchar *name) +RrTheme* RrThemeNew(const RrInstance *inst, gchar *name, GHashTable *override) { XrmDatabase db = NULL; RrJustify winjust, mtitlejust; @@ -109,7 +113,7 @@ } /* load the font stuff */ - if (!read_string(db, "window.active.label.text.font", &font_str)) + if (!read_string(db, override, "window.active.label.text.font", &font_str)) font_str = "arial,sans:bold:pixelsize=10:shadow=y:shadowtint=50"; if (!(theme->win_font_focused = RrFontOpen(inst, font_str))) { @@ -118,7 +122,8 @@ } theme->win_font_height = RrFontHeight(theme->win_font_focused); - if (!read_string(db, "window.inactive.label.text.font", &font_str)) + if (!read_string(db, override, "window.inactive.label.text.font", + &font_str)) /* font_str will already be set to the last one */; if (!(theme->win_font_unfocused = RrFontOpen(inst, font_str))) { @@ -129,14 +134,14 @@ RrFontHeight(theme->win_font_unfocused)); winjust = RR_JUSTIFY_LEFT; - if (read_string(db, "window.label.text.justify", &str)) { + if (read_string(db, override, "window.label.text.justify", &str)) { if (!g_ascii_strcasecmp(str, "right")) winjust = RR_JUSTIFY_RIGHT; else if (!g_ascii_strcasecmp(str, "center")) winjust = RR_JUSTIFY_CENTER; } - if (!read_string(db, "menu.title.text.font", &font_str)) + if (!read_string(db, override, "menu.title.text.font", &font_str)) font_str = "arial,sans:bold:pixelsize=12:shadow=y"; if (!(theme->menu_title_font = RrFontOpen(inst, font_str))) { @@ -146,14 +151,14 @@ theme->menu_title_font_height = RrFontHeight(theme->menu_title_font); mtitlejust = RR_JUSTIFY_LEFT; - if (read_string(db, "menu.title.text.justify", &str)) { + if (read_string(db, override, "menu.title.text.justify", &str)) { if (!g_ascii_strcasecmp(str, "right")) mtitlejust = RR_JUSTIFY_RIGHT; else if (!g_ascii_strcasecmp(str, "center")) mtitlejust = RR_JUSTIFY_CENTER; } - if (!read_string(db, "menu.items.font", &font_str)) + if (!read_string(db, override, "menu.items.font", &font_str)) font_str = "arial,sans:bold:pixelsize=11:shadow=y"; if (!(theme->menu_font = RrFontOpen(inst, font_str))) { @@ -163,55 +168,56 @@ theme->menu_font_height = RrFontHeight(theme->menu_font); /* load direct dimensions */ - if (!read_int(db, "menu.overlap", &theme->menu_overlap) || + if (!read_int(db, override, "menu.overlap", &theme->menu_overlap) || theme->menu_overlap < 0 || theme->menu_overlap > 20) theme->menu_overlap = 0; - if (!read_int(db, "window.handle.width", &theme->handle_height)) + if (!read_int(db, override, "window.handle.width", &theme->handle_height)) theme->handle_height = 6; if (!theme->handle_height) theme->show_handle = FALSE; if (theme->handle_height <= 0 || theme->handle_height > 100) theme->handle_height = 6; - if (!read_int(db, "padding.width", &theme->padding) || + if (!read_int(db, override, "padding.width", &theme->padding) || theme->padding < 0 || theme->padding > 100) theme->padding = 3; - if (!read_int(db, "border.width", &theme->bwidth) || + if (!read_int(db, override, "border.width", &theme->bwidth) || theme->bwidth < 0 || theme->bwidth > 100) theme->bwidth = 1; - if (!read_int(db, "window.client.padding.width", &theme->cbwidth) || + if (!read_int(db, override, "window.client.padding.width", + &theme->cbwidth) || theme->cbwidth < 0 || theme->cbwidth > 100) theme->cbwidth = theme->padding; /* load colors */ - if (!read_color(db, inst, + if (!read_color(db, override, inst, "border.color", &theme->b_color)) theme->b_color = RrColorNew(inst, 0, 0, 0); - if (!read_color(db, inst, + if (!read_color(db, override, inst, "window.active.client.color", &theme->cb_focused_color)) theme->cb_focused_color = RrColorNew(inst, 0xff, 0xff, 0xff); - if (!read_color(db, inst, + if (!read_color(db, override, inst, "window.inactive.client.color", &theme->cb_unfocused_color)) theme->cb_unfocused_color = RrColorNew(inst, 0xff, 0xff, 0xff); - if (!read_color(db, inst, + if (!read_color(db, override, inst, "window.active.label.text.color", &theme->title_focused_color)) theme->title_focused_color = RrColorNew(inst, 0x0, 0x0, 0x0); - if (!read_color(db, inst, + if (!read_color(db, override, inst, "window.inactive.label.text.color", &theme->title_unfocused_color)) theme->title_unfocused_color = RrColorNew(inst, 0xff, 0xff, 0xff); - if (!read_color(db, inst, + if (!read_color(db, override, inst, "window.active.button.unpressed.image.color", &theme->titlebut_focused_unpressed_color)) theme->titlebut_focused_unpressed_color = RrColorNew(inst, 0, 0, 0); - if (!read_color(db, inst, + if (!read_color(db, override, inst, "window.inactive.button.unpressed.image.color", &theme->titlebut_unfocused_unpressed_color)) theme->titlebut_unfocused_unpressed_color = RrColorNew(inst, 0xff, 0xff, 0xff); - if (!read_color(db, inst, + if (!read_color(db, override, inst, "window.active.button.pressed.image.color", &theme->titlebut_focused_pressed_color)) theme->titlebut_focused_pressed_color = @@ -219,7 +225,7 @@ theme->titlebut_focused_unpressed_color->r, theme->titlebut_focused_unpressed_color->g, theme->titlebut_focused_unpressed_color->b); - if (!read_color(db, inst, + if (!read_color(db, override, inst, "window.inactive.button.pressed.image.color", &theme->titlebut_unfocused_pressed_color)) theme->titlebut_unfocused_pressed_color = @@ -227,16 +233,16 @@ theme->titlebut_unfocused_unpressed_color->r, theme->titlebut_unfocused_unpressed_color->g, theme->titlebut_unfocused_unpressed_color->b); - if (!read_color(db, inst, + if (!read_color(db, override, inst, "window.active.button.disabled.image.color", &theme->titlebut_disabled_focused_color)) theme->titlebut_disabled_focused_color = RrColorNew(inst, 0xff, 0xff, 0xff); - if (!read_color(db, inst, + if (!read_color(db, override, inst, "window.inactive.button.disabled.image.color", &theme->titlebut_disabled_unfocused_color)) theme->titlebut_disabled_unfocused_color = RrColorNew(inst, 0, 0, 0); - if (!read_color(db, inst, + if (!read_color(db, override, inst, "window.active.button.hover.image.color", &theme->titlebut_hover_focused_color)) theme->titlebut_hover_focused_color = @@ -244,7 +250,7 @@ theme->titlebut_focused_unpressed_color->r, theme->titlebut_focused_unpressed_color->g, theme->titlebut_focused_unpressed_color->b); - if (!read_color(db, inst, + if (!read_color(db, override, inst, "window.inactive.button.hover.image.color", &theme->titlebut_hover_unfocused_color)) theme->titlebut_hover_unfocused_color = @@ -252,7 +258,7 @@ theme->titlebut_unfocused_unpressed_color->r, theme->titlebut_unfocused_unpressed_color->g, theme->titlebut_unfocused_unpressed_color->b); - if (!read_color(db, inst, + if (!read_color(db, override, inst, "window.active.button.toggled.image.color", &theme->titlebut_toggled_focused_color)) theme->titlebut_toggled_focused_color = @@ -260,7 +266,7 @@ theme->titlebut_focused_pressed_color->r, theme->titlebut_focused_pressed_color->g, theme->titlebut_focused_pressed_color->b); - if (!read_color(db, inst, + if (!read_color(db, override, inst, "window.inactive.button.toggled.image.color", &theme->titlebut_toggled_unfocused_color)) theme->titlebut_toggled_unfocused_color = @@ -268,17 +274,17 @@ theme->titlebut_unfocused_pressed_color->r, theme->titlebut_unfocused_pressed_color->g, theme->titlebut_unfocused_pressed_color->b); - if (!read_color(db, inst, + if (!read_color(db, override, inst, "menu.title.text.color", &theme->menu_title_color)) theme->menu_title_color = RrColorNew(inst, 0, 0, 0); - if (!read_color(db, inst, + if (!read_color(db, override, inst, "menu.items.text.color", &theme->menu_color)) theme->menu_color = RrColorNew(inst, 0xff, 0xff, 0xff); - if (!read_color(db, inst, + if (!read_color(db, override, inst, "menu.items.disabled.text.color", &theme->menu_disabled_color)) theme->menu_disabled_color = RrColorNew(inst, 0, 0, 0); - if (!read_color(db, inst, + if (!read_color(db, override, inst, "menu.items.active.text.color", &theme->menu_selected_color)) theme->menu_selected_color = RrColorNew(inst, 0, 0, 0); @@ -438,47 +444,47 @@ } /* read the decoration textures */ - if (!read_appearance(db, inst, + if (!read_appearance(db, override, inst, "window.active.title.bg", theme->a_focused_title, FALSE)) set_default_appearance(theme->a_focused_title); - if (!read_appearance(db, inst, + if (!read_appearance(db, override, inst, "window.inactive.title.bg", theme->a_unfocused_title, FALSE)) set_default_appearance(theme->a_unfocused_title); - if (!read_appearance(db, inst, + if (!read_appearance(db, override, inst, "window.active.label.bg", theme->a_focused_label, TRUE)) set_default_appearance(theme->a_focused_label); - if (!read_appearance(db, inst, + if (!read_appearance(db, override, inst, "window.inactive.label.bg", theme->a_unfocused_label, TRUE)) set_default_appearance(theme->a_unfocused_label); - if (!read_appearance(db, inst, + if (!read_appearance(db, override, inst, "window.active.handle.bg", theme->a_focused_handle, FALSE)) set_default_appearance(theme->a_focused_handle); - if (!read_appearance(db, inst, + if (!read_appearance(db, override, inst, "window.inactive.handle.bg",theme->a_unfocused_handle, FALSE)) set_default_appearance(theme->a_unfocused_handle); - if (!read_appearance(db, inst, + if (!read_appearance(db, override, inst, "window.active.grip.bg", theme->a_focused_grip, TRUE)) set_default_appearance(theme->a_focused_grip); - if (!read_appearance(db, inst, + if (!read_appearance(db, override, inst, "window.inactive.grip.bg", theme->a_unfocused_grip, TRUE)) set_default_appearance(theme->a_unfocused_grip); - if (!read_appearance(db, inst, + if (!read_appearance(db, override, inst, "menu.items.bg", theme->a_menu, FALSE)) set_default_appearance(theme->a_menu); - if (!read_appearance(db, inst, + if (!read_appearance(db, override, inst, "menu.title.bg", theme->a_menu_title, FALSE)) set_default_appearance(theme->a_menu_title); - if (!read_appearance(db, inst, + if (!read_appearance(db, override, inst, "menu.items.active.bg", theme->a_menu_selected, TRUE)) set_default_appearance(theme->a_menu_selected); @@ -498,27 +504,27 @@ theme->app_unhilite_fg = RrAppearanceCopy(theme->a_unfocused_title); /* read buttons textures */ - if (!read_appearance(db, inst, + if (!read_appearance(db, override, inst, "window.active.button.disabled.bg", theme->a_disabled_focused_max, TRUE)) set_default_appearance(theme->a_disabled_focused_max); - if (!read_appearance(db, inst, + if (!read_appearance(db, override, inst, "window.inactive.button.disabled.bg", theme->a_disabled_unfocused_max, TRUE)) set_default_appearance(theme->a_disabled_unfocused_max); - if (!read_appearance(db, inst, + if (!read_appearance(db, override, inst, "window.active.button.pressed.bg", theme->a_focused_pressed_max, TRUE)) set_default_appearance(theme->a_focused_pressed_max); - if (!read_appearance(db, inst, + if (!read_appearance(db, override, inst, "window.inactive.button.pressed.bg", theme->a_unfocused_pressed_max, TRUE)) set_default_appearance(theme->a_unfocused_pressed_max); - if (!read_appearance(db, inst, + if (!read_appearance(db, override, inst, "window.active.button.toggled.bg", theme->a_toggled_focused_max, TRUE)) @@ -527,7 +533,7 @@ theme->a_toggled_focused_max = RrAppearanceCopy(theme->a_focused_pressed_max); } - if (!read_appearance(db, inst, + if (!read_appearance(db, override, inst, "window.inactive.button.toggled.bg", theme->a_toggled_unfocused_max, TRUE)) @@ -536,17 +542,17 @@ theme->a_toggled_unfocused_max = RrAppearanceCopy(theme->a_unfocused_pressed_max); } - if (!read_appearance(db, inst, + if (!read_appearance(db, override, inst, "window.active.button.unpressed.bg", theme->a_focused_unpressed_max, TRUE)) set_default_appearance(theme->a_focused_unpressed_max); - if (!read_appearance(db, inst, + if (!read_appearance(db, override, inst, "window.inactive.button.unpressed.bg", theme->a_unfocused_unpressed_max, TRUE)) set_default_appearance(theme->a_unfocused_unpressed_max); - if (!read_appearance(db, inst, + if (!read_appearance(db, override, inst, "window.active.button.hover.bg", theme->a_hover_focused_max, TRUE)) @@ -555,7 +561,7 @@ theme->a_hover_focused_max = RrAppearanceCopy(theme->a_focused_unpressed_max); } - if (!read_appearance(db, inst, + if (!read_appearance(db, override, inst, "window.inactive.button.hover.bg", theme->a_hover_unfocused_max, TRUE)) @@ -1100,12 +1106,14 @@ return rclass; } -static gboolean read_int(XrmDatabase db, gchar *rname, gint *value) +static gboolean read_int(XrmDatabase db, GHashTable *override, gchar *rname, + gint *value) { gboolean ret = FALSE; gchar *rclass = create_class_name(rname); gchar *rettype, *end; XrmValue retvalue; + gpointer gh_retval; if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) && retvalue.addr != NULL) { @@ -1114,34 +1122,48 @@ ret = TRUE; } + if (override && (gh_retval = g_hash_table_lookup(override, rname))) { + *value = (gint)strtol(gh_retval, &end, 10); + if (end != gh_retval) + ret = TRUE; + } + g_free(rclass); return ret; } -static gboolean read_string(XrmDatabase db, gchar *rname, gchar **value) +static gboolean read_string(XrmDatabase db, GHashTable *override, gchar *rname, + gchar **value) { gboolean ret = FALSE; gchar *rclass = create_class_name(rname); gchar *rettype; XrmValue retvalue; - + if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) && retvalue.addr != NULL) { *value = retvalue.addr; ret = TRUE; } + if (override && g_hash_table_lookup(override, rname)) { + *value = g_hash_table_lookup(override, rname); + ret = TRUE; + } + g_free(rclass); return ret; } -static gboolean read_color(XrmDatabase db, const RrInstance *inst, +static gboolean read_color(XrmDatabase db, GHashTable *override, + const RrInstance *inst, gchar *rname, RrColor **value) { gboolean ret = FALSE; gchar *rclass = create_class_name(rname); gchar *rettype; XrmValue retvalue; + gpointer gh_retval; if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) && retvalue.addr != NULL) { @@ -1152,6 +1174,14 @@ } } + if (override && (gh_retval = g_hash_table_lookup(override, rname))) { + RrColor *c = RrColorParse(inst, gh_retval); + if (c != NULL) { + *value = c; + ret = TRUE; + } + } + g_free(rclass); return ret; } @@ -1167,6 +1197,7 @@ guchar *b; s = g_build_filename(theme->path, maskname, NULL); + if (XReadBitmapFileData(s, &w, &h, &b, &hx, &hy) == BitmapSuccess) { ret = TRUE; *value = RrPixmapMaskNew(inst, w, h, (gchar*)b); @@ -1232,7 +1263,8 @@ } -static gboolean read_appearance(XrmDatabase db, const RrInstance *inst, +static gboolean read_appearance(XrmDatabase db, GHashTable *override, + const RrInstance *inst, gchar *rname, RrAppearance *value, gboolean allow_trans) { @@ -1256,16 +1288,17 @@ &value->surface.interlaced, &value->surface.border, allow_trans); - if (!read_color(db, inst, cname, &value->surface.primary)) + if (!read_color(db, override, inst, cname, &value->surface.primary)) value->surface.primary = RrColorNew(inst, 0, 0, 0); - if (!read_color(db, inst, ctoname, &value->surface.secondary)) + if (!read_color(db, override, inst, ctoname, + &value->surface.secondary)) value->surface.secondary = RrColorNew(inst, 0, 0, 0); if (value->surface.border) - if (!read_color(db, inst, bcname, + if (!read_color(db, override, inst, bcname, &value->surface.border_color)) value->surface.border_color = RrColorNew(inst, 0, 0, 0); if (value->surface.interlaced) - if (!read_color(db, inst, icname, + if (!read_color(db, override, inst, icname, &value->surface.interlace_color)) value->surface.interlace_color = RrColorNew(inst, 0, 0, 0); ret = TRUE; diff -Nru /tmp/a/openbox-3.2/render/theme.h ./render/theme.h --- /tmp/a/openbox-3.2/render/theme.h 2003-09-26 00:48:04.000000000 +0200 +++ ./render/theme.h 2004-06-28 04:46:08.000000000 +0200 @@ -186,7 +186,8 @@ }; -RrTheme* RrThemeNew(const RrInstance *inst, gchar *theme); +RrTheme* RrThemeNew(const RrInstance *inst, gchar *theme, + GHashTable *override); void RrThemeFree(RrTheme *theme); G_END_DECLS