#include "font.h"
#include "mask.h"
#include "theme.h"
+#include "icon.h"
+#include "parser/parse.h"
#include <X11/Xlib.h>
#include <X11/Xresource.h>
static gboolean read_appearance(XrmDatabase db, 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)
theme->app_hilite_bg = RrAppearanceNew(inst, 0);
theme->app_unhilite_bg = RrAppearanceNew(inst, 0);
+ theme->app_hilite_fg = RrAppearanceNew(inst, 0);
+ theme->app_unhilite_fg = RrAppearanceNew(inst, 0);
theme->app_hilite_label = RrAppearanceNew(inst, 1);
theme->app_unhilite_label = RrAppearanceNew(inst, 1);
theme->iconify_hover_mask = RrPixmapMaskCopy(theme->iconify_mask);
}
+ theme->def_win_icon = read_c_image(OB_DEFAULT_ICON_WIDTH,
+ OB_DEFAULT_ICON_HEIGHT,
+ OB_DEFAULT_ICON_pixel_data);
+
if (read_mask(inst, "desk.xbm", theme, &theme->desk_mask)) {
if (!read_mask(inst, "desk_pressed.xbm", theme,
&theme->desk_pressed_mask)) {
"window.active.label.bg", theme->app_hilite_label,
TRUE))
set_default_appearance(theme->app_hilite_label);
+ if (!read_appearance(db, inst,
+ "window.active.label.bg", theme->app_hilite_fg,
+ TRUE))
+ set_default_appearance(theme->app_hilite_fg);
+ else if (theme->app_hilite_label->surface.grad == RR_SURFACE_PARENTREL) {
+ if (!read_appearance(db, inst,
+ "window.active.title.bg",
+ theme->app_hilite_fg,
+ FALSE))
+ set_default_appearance(theme->app_hilite_fg);
+ }
if (!read_appearance(db, inst,
"window.inactive.title.bg", theme->app_unhilite_bg,
FALSE))
"window.inactive.label.bg", theme->app_unhilite_label,
TRUE))
set_default_appearance(theme->app_unhilite_label);
+ if (!read_appearance(db, inst,
+ "window.inactive.label.bg", theme->app_unhilite_fg,
+ TRUE))
+ set_default_appearance(theme->app_unhilite_fg);
+ else if (theme->app_unhilite_label->surface.grad == RR_SURFACE_PARENTREL) {
+ if (!read_appearance(db, inst,
+ "window.inactive.title.bg",
+ theme->app_unhilite_fg,
+ FALSE))
+ set_default_appearance(theme->app_unhilite_fg);
+ }
+
/* read buttons textures */
if (!read_appearance(db, inst,
void RrThemeFree(RrTheme *theme)
{
if (theme) {
+ g_free(theme->path);
g_free(theme->name);
RrColorFree(theme->b_color);
RrColorFree(theme->menu_disabled_color);
RrColorFree(theme->menu_selected_color);
+ g_free(theme->def_win_icon);
+
RrPixmapMaskFree(theme->max_mask);
RrPixmapMaskFree(theme->max_toggled_mask);
RrPixmapMaskFree(theme->max_disabled_mask);
RrAppearanceFree(theme->a_clear_tex);
RrAppearanceFree(theme->app_hilite_bg);
RrAppearanceFree(theme->app_unhilite_bg);
+ RrAppearanceFree(theme->app_hilite_fg);
+ RrAppearanceFree(theme->app_unhilite_fg);
RrAppearanceFree(theme->app_hilite_label);
RrAppearanceFree(theme->app_unhilite_label);
+
+ g_free(theme);
}
}
static XrmDatabase loaddb(RrTheme *theme, char *name)
{
- XrmDatabase db;
+ GSList *it;
+ XrmDatabase db = NULL;
+ gchar *s;
- char *s = g_build_filename(g_get_home_dir(), ".openbox", "themes",
- name, "themerc", NULL);
- if ((db = XrmGetFileDatabase(s)))
- theme->path = g_path_get_dirname(s);
- g_free(s);
- if (db == NULL) {
- char *s = g_build_filename(THEMEDIR, name, "themerc", NULL);
+ if (name[0] == '/') {
+ s = g_build_filename(name, "openbox-3", "themerc", NULL);
if ((db = XrmGetFileDatabase(s)))
theme->path = g_path_get_dirname(s);
- g_free(s);
+ g_free(s);
+ } else {
+ for (it = parse_xdg_data_dir_paths(); !db && it;
+ it = g_slist_next(it))
+ {
+ s = g_build_filename(it->data, "themes", name,
+ "openbox-3", "themerc", NULL);
+ if ((db = XrmGetFileDatabase(s)))
+ theme->path = g_path_get_dirname(s);
+ g_free(s);
+ }
}
+
if (db == NULL) {
- char *s = g_build_filename(name, "themerc", NULL);
+ s = g_build_filename(name, "themerc", NULL);
if ((db = XrmGetFileDatabase(s)))
theme->path = g_path_get_dirname(s);
g_free(s);
a->surface.primary = RrColorNew(a->inst, 0, 0, 0);
a->surface.secondary = RrColorNew(a->inst, 0, 0, 0);
}
+
+/* Reads the output from gimp's C-Source file format into valid RGBA data for
+ an RrTextureRGBA. */
+static RrPixel32* read_c_image(gint width, gint height, const guint8 *data)
+{
+ RrPixel32 *im, *p;
+ gint i;
+
+ p = im = g_memdup(data, width * height * sizeof(RrPixel32));
+
+ for (i = 0; i < width * height; ++i) {
+ guchar a = ((*p >> 24) & 0xff);
+ guchar b = ((*p >> 16) & 0xff);
+ guchar g = ((*p >> 8) & 0xff);
+ guchar r = ((*p >> 0) & 0xff);
+
+ *p = ((r << RrDefaultRedOffset) +
+ (g << RrDefaultGreenOffset) +
+ (b << RrDefaultBlueOffset) +
+ (a << RrDefaultAlphaOffset));
+ p++;
+ }
+
+ return im;
+}