+/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
+
+ theme.c for the Openbox window manager
+ Copyright (c) 2003 Ben Jansens
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ See the COPYING file for a copy of the GNU General Public License.
+*/
+
-static XrmDatabase loaddb(RrTheme *theme, char *name);
-static gboolean read_int(XrmDatabase db, char *rname, int *value);
-static gboolean read_string(XrmDatabase db, char *rname, char **value);
+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,
gchar *rname, RrColor **value);
static gboolean read_mask(const RrInstance *inst,
static gboolean read_color(XrmDatabase db, const RrInstance *inst,
gchar *rname, RrColor **value);
static gboolean read_mask(const RrInstance *inst,
static gboolean read_appearance(XrmDatabase db, const RrInstance *inst,
gchar *rname, RrAppearance *value,
gboolean allow_trans);
static gboolean read_appearance(XrmDatabase db, const RrInstance *inst,
gchar *rname, RrAppearance *value,
gboolean allow_trans);
if (!read_string(db, "window.active.label.text.font", &font_str))
font_str = "arial,sans:bold:pixelsize=10:shadow=y:shadowtint=50";
if (!read_string(db, "window.active.label.text.font", &font_str))
font_str = "arial,sans:bold:pixelsize=10:shadow=y:shadowtint=50";
if (!read_string(db, "menu.title.text.font", &font_str))
font_str = "arial,sans:bold:pixelsize=12:shadow=y";
if (!read_string(db, "menu.title.text.font", &font_str))
font_str = "arial,sans:bold:pixelsize=12:shadow=y";
if (!read_string(db, "menu.items.font", &font_str))
font_str = "arial,sans:bold:pixelsize=11:shadow=y";
if (!read_string(db, "menu.items.font", &font_str))
font_str = "arial,sans:bold:pixelsize=11:shadow=y";
if (theme->handle_height <= 0 || theme->handle_height > 100)
theme->handle_height = 6;
if (!read_int(db, "padding.width", &theme->padding) ||
if (theme->handle_height <= 0 || theme->handle_height > 100)
theme->handle_height = 6;
if (!read_int(db, "padding.width", &theme->padding) ||
theme->cbwidth = theme->padding;
/* load colors */
if (!read_color(db, inst,
"border.color", &theme->b_color))
theme->cbwidth = theme->padding;
/* load colors */
if (!read_color(db, inst,
"border.color", &theme->b_color))
if (!read_color(db, inst,
"window.active.client.color",
&theme->cb_focused_color))
if (!read_color(db, inst,
"window.active.client.color",
&theme->cb_focused_color))
if (!read_color(db, inst,
"window.inactive.client.color",
&theme->cb_unfocused_color))
if (!read_color(db, inst,
"window.inactive.client.color",
&theme->cb_unfocused_color))
if (!read_color(db, inst,
"window.active.label.text.color",
&theme->title_focused_color))
if (!read_color(db, inst,
"window.active.label.text.color",
&theme->title_focused_color))
if (!read_color(db, inst,
"window.inactive.label.text.color",
&theme->title_unfocused_color))
if (!read_color(db, inst,
"window.inactive.label.text.color",
&theme->title_unfocused_color))
if (!read_color(db, inst,
"window.active.button.unpressed.image.color",
&theme->titlebut_focused_unpressed_color))
if (!read_color(db, inst,
"window.active.button.unpressed.image.color",
&theme->titlebut_focused_unpressed_color))
if (!read_color(db, inst,
"window.inactive.button.unpressed.image.color",
&theme->titlebut_unfocused_unpressed_color))
if (!read_color(db, inst,
"window.inactive.button.unpressed.image.color",
&theme->titlebut_unfocused_unpressed_color))
RrColorNew(inst, 0xff, 0xff, 0xff);
if (!read_color(db, inst,
"window.active.button.pressed.image.color",
&theme->titlebut_focused_pressed_color))
RrColorNew(inst, 0xff, 0xff, 0xff);
if (!read_color(db, inst,
"window.active.button.pressed.image.color",
&theme->titlebut_focused_pressed_color))
if (!read_color(db, inst,
"window.inactive.button.pressed.image.color",
&theme->titlebut_unfocused_pressed_color))
if (!read_color(db, inst,
"window.inactive.button.pressed.image.color",
&theme->titlebut_unfocused_pressed_color))
if (!read_color(db, inst,
"window.active.button.disabled.image.color",
&theme->titlebut_disabled_focused_color))
if (!read_color(db, inst,
"window.active.button.disabled.image.color",
&theme->titlebut_disabled_focused_color))
RrColorNew(inst, 0xff, 0xff, 0xff);
if (!read_color(db, inst,
"window.inactive.button.disabled.image.color",
&theme->titlebut_disabled_unfocused_color))
RrColorNew(inst, 0xff, 0xff, 0xff);
if (!read_color(db, inst,
"window.inactive.button.disabled.image.color",
&theme->titlebut_disabled_unfocused_color))
if (!read_color(db, inst,
"window.active.button.hover.image.color",
&theme->titlebut_hover_focused_color))
if (!read_color(db, inst,
"window.active.button.hover.image.color",
&theme->titlebut_hover_focused_color))
if (!read_color(db, inst,
"window.inactive.button.hover.image.color",
&theme->titlebut_hover_unfocused_color))
if (!read_color(db, inst,
"window.inactive.button.hover.image.color",
&theme->titlebut_hover_unfocused_color))
if (!read_color(db, inst,
"window.active.button.toggled.image.color",
&theme->titlebut_toggled_focused_color))
if (!read_color(db, inst,
"window.active.button.toggled.image.color",
&theme->titlebut_toggled_focused_color))
if (!read_color(db, inst,
"window.inactive.button.toggled.image.color",
&theme->titlebut_toggled_unfocused_color))
if (!read_color(db, inst,
"window.inactive.button.toggled.image.color",
&theme->titlebut_toggled_unfocused_color))
if (!read_mask(inst, "max_hover.xbm", theme, &theme->max_hover_mask)) {
theme->max_hover_mask = RrPixmapMaskCopy(theme->max_mask);
}
if (!read_mask(inst, "max_hover.xbm", theme, &theme->max_hover_mask)) {
theme->max_hover_mask = RrPixmapMaskCopy(theme->max_mask);
}
{
guchar data[] = { 0x7f, 0x7f, 0x7f, 0x41, 0x41, 0x41, 0x7f };
{
guchar data[] = { 0x7f, 0x7f, 0x7f, 0x41, 0x41, 0x41, 0x7f };
}
{
guchar data[] = { 0x7c, 0x44, 0x47, 0x47, 0x7f, 0x1f, 0x1f };
}
{
guchar data[] = { 0x7c, 0x44, 0x47, 0x47, 0x7f, 0x1f, 0x1f };
} else {
{
guchar data[] = { 0x00, 0x00, 0x00, 0x00, 0x7f, 0x7f, 0x7f };
} else {
{
guchar data[] = { 0x00, 0x00, 0x00, 0x00, 0x7f, 0x7f, 0x7f };
}
theme->iconify_pressed_mask = RrPixmapMaskCopy(theme->iconify_mask);
theme->iconify_disabled_mask = RrPixmapMaskCopy(theme->iconify_mask);
theme->iconify_hover_mask = RrPixmapMaskCopy(theme->iconify_mask);
}
}
theme->iconify_pressed_mask = RrPixmapMaskCopy(theme->iconify_mask);
theme->iconify_disabled_mask = RrPixmapMaskCopy(theme->iconify_mask);
theme->iconify_hover_mask = RrPixmapMaskCopy(theme->iconify_mask);
}
if (read_mask(inst, "desk.xbm", theme, &theme->desk_mask)) {
if (!read_mask(inst, "desk_pressed.xbm", theme,
&theme->desk_pressed_mask)) {
if (read_mask(inst, "desk.xbm", theme, &theme->desk_mask)) {
if (!read_mask(inst, "desk_pressed.xbm", theme,
&theme->desk_pressed_mask)) {
} else {
{
guchar data[] = { 0x63, 0x63, 0x00, 0x00, 0x00, 0x63, 0x63 };
} else {
{
guchar data[] = { 0x63, 0x63, 0x00, 0x00, 0x00, 0x63, 0x63 };
}
{
guchar data[] = { 0x00, 0x36, 0x36, 0x08, 0x36, 0x36, 0x00 };
theme->desk_toggled_mask = RrPixmapMaskNew(inst, 7, 7,
}
{
guchar data[] = { 0x00, 0x36, 0x36, 0x08, 0x36, 0x36, 0x00 };
theme->desk_toggled_mask = RrPixmapMaskNew(inst, 7, 7,
} else {
{
guchar data[] = { 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00 };
} else {
{
guchar data[] = { 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00 };
}
{
guchar data[] = { 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x7f };
theme->shade_toggled_mask = RrPixmapMaskNew(inst, 7, 7,
}
{
guchar data[] = { 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x7f };
theme->shade_toggled_mask = RrPixmapMaskNew(inst, 7, 7,
} else {
{
guchar data[] = { 0x63, 0x77, 0x3e, 0x1c, 0x3e, 0x77, 0x63 };
} else {
{
guchar data[] = { 0x63, 0x77, 0x3e, 0x1c, 0x3e, 0x77, 0x63 };
if (!read_mask(inst, "bullet.xbm", theme, &theme->menu_bullet_mask)) {
guchar data[] = { 0x01, 0x03, 0x07, 0x0f, 0x07, 0x03, 0x01 };
if (!read_mask(inst, "bullet.xbm", theme, &theme->menu_bullet_mask)) {
guchar data[] = { 0x01, 0x03, 0x07, 0x0f, 0x07, 0x03, 0x01 };
}
/* read the decoration textures */
if (!read_appearance(db, inst,
"window.active.title.bg", theme->a_focused_title,
FALSE))
}
/* read the decoration textures */
if (!read_appearance(db, inst,
"window.active.title.bg", theme->a_focused_title,
FALSE))
if (!read_appearance(db, inst,
"window.inactive.title.bg", theme->a_unfocused_title,
FALSE))
if (!read_appearance(db, inst,
"window.inactive.title.bg", theme->a_unfocused_title,
FALSE))
if (!read_appearance(db, inst,
"window.active.label.bg", theme->a_focused_label,
TRUE))
if (!read_appearance(db, inst,
"window.active.label.bg", theme->a_focused_label,
TRUE))
if (!read_appearance(db, inst,
"window.inactive.label.bg", theme->a_unfocused_label,
TRUE))
if (!read_appearance(db, inst,
"window.inactive.label.bg", theme->a_unfocused_label,
TRUE))
if (!read_appearance(db, inst,
"window.active.handle.bg", theme->a_focused_handle,
FALSE))
if (!read_appearance(db, inst,
"window.active.handle.bg", theme->a_focused_handle,
FALSE))
if (!read_appearance(db, inst,
"window.inactive.handle.bg",theme->a_unfocused_handle,
FALSE))
if (!read_appearance(db, inst,
"window.inactive.handle.bg",theme->a_unfocused_handle,
FALSE))
if (!read_appearance(db, inst,
"window.active.grip.bg", theme->a_focused_grip,
TRUE))
if (!read_appearance(db, inst,
"window.active.grip.bg", theme->a_focused_grip,
TRUE))
if (!read_appearance(db, inst,
"window.inactive.grip.bg", theme->a_unfocused_grip,
TRUE))
if (!read_appearance(db, inst,
"window.inactive.grip.bg", theme->a_unfocused_grip,
TRUE))
if (!read_appearance(db, inst,
"menu.items.bg", theme->a_menu,
FALSE))
if (!read_appearance(db, inst,
"menu.items.bg", theme->a_menu,
FALSE))
if (!read_appearance(db, inst,
"menu.title.bg", theme->a_menu_title,
FALSE))
if (!read_appearance(db, inst,
"menu.title.bg", theme->a_menu_title,
FALSE))
if (!read_appearance(db, inst,
"menu.items.active.bg", theme->a_menu_selected,
TRUE))
if (!read_appearance(db, inst,
"menu.items.active.bg", theme->a_menu_selected,
TRUE))
- if (!read_appearance(db, inst,
- "window.active.title.bg", theme->app_hilite_bg,
- FALSE))
- set_default_appearance(theme->app_hilite_bg);
- if (!read_appearance(db, inst,
- "window.active.label.bg", theme->app_hilite_label,
- TRUE))
- set_default_appearance(theme->app_hilite_label);
- if (!read_appearance(db, inst,
- "window.inactive.title.bg", theme->app_unhilite_bg,
- FALSE))
- set_default_appearance(theme->app_unhilite_bg);
- if (!read_appearance(db, inst,
- "window.inactive.label.bg", theme->app_unhilite_label,
- TRUE))
- set_default_appearance(theme->app_unhilite_label);
+ theme->app_hilite_bg = RrAppearanceCopy(theme->a_focused_title);
+ theme->app_hilite_label = RrAppearanceCopy(theme->a_focused_label);
+ if (theme->a_focused_label->surface.grad != RR_SURFACE_PARENTREL)
+ theme->app_hilite_fg = RrAppearanceCopy(theme->a_focused_label);
+ else
+ theme->app_hilite_fg = RrAppearanceCopy(theme->a_focused_title);
+ theme->app_unhilite_bg = RrAppearanceCopy(theme->a_unfocused_title);
+ theme->app_unhilite_label = RrAppearanceCopy(theme->a_unfocused_label);
+ if (theme->a_unfocused_label->surface.grad != RR_SURFACE_PARENTREL)
+ theme->app_unhilite_fg = RrAppearanceCopy(theme->a_unfocused_label);
+ else
+ theme->app_unhilite_fg = RrAppearanceCopy(theme->a_unfocused_title);
/* read buttons textures */
if (!read_appearance(db, inst,
"window.active.button.disabled.bg",
/* read buttons textures */
if (!read_appearance(db, inst,
"window.active.button.disabled.bg",
TRUE))
set_default_appearance(theme->a_disabled_focused_max);
if (!read_appearance(db, inst,
"window.inactive.button.disabled.bg",
TRUE))
set_default_appearance(theme->a_disabled_focused_max);
if (!read_appearance(db, inst,
"window.inactive.button.disabled.bg",
TRUE))
set_default_appearance(theme->a_disabled_unfocused_max);
if (!read_appearance(db, inst,
"window.active.button.pressed.bg",
TRUE))
set_default_appearance(theme->a_disabled_unfocused_max);
if (!read_appearance(db, inst,
"window.active.button.pressed.bg",
TRUE))
set_default_appearance(theme->a_focused_pressed_max);
if (!read_appearance(db, inst,
"window.inactive.button.pressed.bg",
TRUE))
set_default_appearance(theme->a_focused_pressed_max);
if (!read_appearance(db, inst,
"window.inactive.button.pressed.bg",
TRUE))
set_default_appearance(theme->a_unfocused_pressed_max);
if (!read_appearance(db, inst,
"window.active.button.toggled.bg",
TRUE))
set_default_appearance(theme->a_unfocused_pressed_max);
if (!read_appearance(db, inst,
"window.active.button.toggled.bg",
}
if (!read_appearance(db, inst,
"window.inactive.button.toggled.bg",
}
if (!read_appearance(db, inst,
"window.inactive.button.toggled.bg",
}
if (!read_appearance(db, inst,
"window.active.button.unpressed.bg",
}
if (!read_appearance(db, inst,
"window.active.button.unpressed.bg",
if (!read_appearance(db, inst,
"window.inactive.button.unpressed.bg",
if (!read_appearance(db, inst,
"window.inactive.button.unpressed.bg",
if (!read_appearance(db, inst,
"window.active.button.hover.bg",
if (!read_appearance(db, inst,
"window.active.button.hover.bg",
}
if (!read_appearance(db, inst,
"window.inactive.button.hover.bg",
}
if (!read_appearance(db, inst,
"window.inactive.button.hover.bg",
theme->app_hilite_label->texture[0].data.text.justify = RR_JUSTIFY_LEFT;
theme->a_focused_label->texture[0].data.text.font =
theme->app_hilite_label->texture[0].data.text.font =
theme->app_hilite_label->texture[0].data.text.justify = RR_JUSTIFY_LEFT;
theme->a_focused_label->texture[0].data.text.font =
theme->app_hilite_label->texture[0].data.text.font =
theme->a_unfocused_label->texture[0].data.text.color =
theme->app_unhilite_label->texture[0].data.text.color =
theme->title_unfocused_color;
theme->a_menu_title->texture[0].type = RR_TEXTURE_TEXT;
theme->a_menu_title->texture[0].data.text.justify = mtitlejust;
theme->a_unfocused_label->texture[0].data.text.color =
theme->app_unhilite_label->texture[0].data.text.color =
theme->title_unfocused_color;
theme->a_menu_title->texture[0].type = RR_TEXTURE_TEXT;
theme->a_menu_title->texture[0].data.text.justify = mtitlejust;
theme->a_menu_text_normal->texture[0].data.text.color = theme->menu_color;
theme->a_menu_text_disabled->texture[0].data.text.color =
theme->menu_disabled_color;
theme->a_menu_text_normal->texture[0].data.text.color = theme->menu_color;
theme->a_menu_text_disabled->texture[0].data.text.color =
theme->menu_disabled_color;
theme->a_unfocused_unpressed_shade->texture[0].data.mask.color =
theme->a_unfocused_unpressed_iconify->texture[0].data.mask.color =
theme->titlebut_unfocused_unpressed_color;
theme->a_unfocused_unpressed_shade->texture[0].data.mask.color =
theme->a_unfocused_unpressed_iconify->texture[0].data.mask.color =
theme->titlebut_unfocused_unpressed_color;
theme->a_unfocused_pressed_close->texture[0].data.mask.color =
theme->a_unfocused_pressed_desk->texture[0].data.mask.color =
theme->a_unfocused_pressed_shade->texture[0].data.mask.color =
theme->a_unfocused_pressed_close->texture[0].data.mask.color =
theme->a_unfocused_pressed_desk->texture[0].data.mask.color =
theme->a_unfocused_pressed_shade->texture[0].data.mask.color =
RrMargins(theme->a_focused_label, &fl, &ft, &fr, &fb);
RrMargins(theme->a_unfocused_label, &ul, &ut, &ur, &ub);
RrMargins(theme->a_focused_label, &fl, &ft, &fr, &fb);
RrMargins(theme->a_unfocused_label, &ul, &ut, &ur, &ub);
- theme->label_height = theme->winfont_height
- + MAX(ft + fb, ut + ub);
+ theme->label_height = theme->win_font_height + MAX(ft + fb, ut + ub);
+
+ /* this would be nice I think, since padding.width can now be 0,
+ but it breaks frame.c horribly and I don't feel like fixing that
+ right now, so if anyone complains, here is how to keep text from
+ going over the title's bevel/border with a padding.width of 0 and a
+ bevelless/borderless label
+ RrMargins(theme->a_focused_title, &fl, &ft, &fr, &fb);
+ RrMargins(theme->a_unfocused_title, &ul, &ut, &ur, &ub);
+ theme->title_height = theme->label_height +
+ MAX(MAX(theme->padding * 2, ft + fb),
+ MAX(theme->padding * 2, ut + ub));
+ */
+ theme->title_height = theme->label_height + theme->padding * 2;
+ /* this should match the above title_height given the same font size
+ for both. */
+ theme->menu_title_height = theme->menu_title_font_height +
+ theme->padding * 2;
- RrFontClose(theme->winfont_focused);
- RrFontClose(theme->winfont_unfocused);
- RrFontClose(theme->mtitlefont);
- RrFontClose(theme->mfont);
+ RrFontClose(theme->win_font_focused);
+ RrFontClose(theme->win_font_unfocused);
+ RrFontClose(theme->menu_title_font);
+ RrFontClose(theme->menu_font);
- 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 ((db = XrmGetFileDatabase(s)))
+ 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);
+ } else {
+ /* XXX backwards compatibility, remove me sometime later */
+ s = g_build_filename(g_get_home_dir(), ".themes", name,
+ "openbox-3", "themerc", NULL);
+ if ((db = XrmGetFileDatabase(s)))
+ g_free(s);
+
+ 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);
+ }
- retvalue.addr != NULL) {
- *value = (int)strtol(retvalue.addr, &end, 10);
- if (end != retvalue.addr)
- ret = TRUE;
+ retvalue.addr != NULL) {
+ *value = (gint)strtol(retvalue.addr, &end, 10);
+ if (end != retvalue.addr)
+ ret = TRUE;
s = g_build_filename(theme->path, maskname, NULL);
if (XReadBitmapFileData(s, &w, &h, &b, &hx, &hy) == BitmapSuccess) {
ret = TRUE;
s = g_build_filename(theme->path, maskname, NULL);
if (XReadBitmapFileData(s, &w, &h, &b, &hx, &hy) == BitmapSuccess) {
ret = TRUE;
- if (strstr(tex, "gradient") != NULL) {
- if (strstr(tex, "crossdiagonal") != NULL)
- *grad = RR_SURFACE_CROSS_DIAGONAL;
- else if (strstr(tex, "pyramid") != NULL)
- *grad = RR_SURFACE_PYRAMID;
- else if (strstr(tex, "horizontal") != NULL)
- *grad = RR_SURFACE_HORIZONTAL;
- else if (strstr(tex, "vertical") != NULL)
- *grad = RR_SURFACE_VERTICAL;
- else
- *grad = RR_SURFACE_DIAGONAL;
- } else {
- *grad = RR_SURFACE_SOLID;
- }
-
- if (strstr(tex, "sunken") != NULL)
- *relief = RR_RELIEF_SUNKEN;
- else if (strstr(tex, "flat") != NULL)
- *relief = RR_RELIEF_FLAT;
- else
- *relief = RR_RELIEF_RAISED;
-
- *border = FALSE;
- if (*relief == RR_RELIEF_FLAT) {
- if (strstr(tex, "border") != NULL)
- *border = TRUE;
- } else {
- if (strstr(tex, "bevel2") != NULL)
- *bevel = RR_BEVEL_2;
- else
- *bevel = RR_BEVEL_1;
- }
-
- if (strstr(tex, "interlaced") != NULL)
- *interlaced = TRUE;
- else
- *interlaced = FALSE;
+ if (strstr(tex, "gradient") != NULL) {
+ if (strstr(tex, "crossdiagonal") != NULL)
+ *grad = RR_SURFACE_CROSS_DIAGONAL;
+ else if (strstr(tex, "pyramid") != NULL)
+ *grad = RR_SURFACE_PYRAMID;
+ else if (strstr(tex, "horizontal") != NULL)
+ *grad = RR_SURFACE_HORIZONTAL;
+ else if (strstr(tex, "vertical") != NULL)
+ *grad = RR_SURFACE_VERTICAL;
+ else
+ *grad = RR_SURFACE_DIAGONAL;
+ } else {
+ *grad = RR_SURFACE_SOLID;
+ }
+
+ if (strstr(tex, "sunken") != NULL)
+ *relief = RR_RELIEF_SUNKEN;
+ else if (strstr(tex, "flat") != NULL)
+ *relief = RR_RELIEF_FLAT;
+ else
+ *relief = RR_RELIEF_RAISED;
+
+ *border = FALSE;
+ if (*relief == RR_RELIEF_FLAT) {
+ if (strstr(tex, "border") != NULL)
+ *border = TRUE;
+ } else {
+ if (strstr(tex, "bevel2") != NULL)
+ *bevel = RR_BEVEL_2;
+ else
+ *bevel = RR_BEVEL_1;
+ }
+
+ if (strstr(tex, "interlaced") != NULL)
+ *interlaced = TRUE;
+ else
+ *interlaced = FALSE;
- char *rclass = create_class_name(rname);
- char *cname, *ctoname, *bcname, *icname;
- char *rettype;
+ gchar *rclass = create_class_name(rname);
+ gchar *cname, *ctoname, *bcname, *icname;
+ gchar *rettype;
icname = g_strconcat(rname, ".interlace.color", NULL);
if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
icname = g_strconcat(rname, ".interlace.color", NULL);
if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
- retvalue.addr != NULL) {
- parse_appearance(retvalue.addr,
- &value->surface.grad,
- &value->surface.relief,
- &value->surface.bevel,
- &value->surface.interlaced,
- &value->surface.border,
+ retvalue.addr != NULL) {
+ parse_appearance(retvalue.addr,
+ &value->surface.grad,
+ &value->surface.relief,
+ &value->surface.bevel,
+ &value->surface.interlaced,
+ &value->surface.border,
- if (!read_color(db, inst, cname, &value->surface.primary))
- value->surface.primary = RrColorNew(inst, 0, 0, 0);
- if (!read_color(db, inst, ctoname, &value->surface.secondary))
- value->surface.secondary = RrColorNew(inst, 0, 0, 0);
- if (value->surface.border)
- if (!read_color(db, inst, bcname,
- &value->surface.border_color))
- value->surface.border_color = RrColorNew(inst, 0, 0, 0);
+ if (!read_color(db, inst, cname, &value->surface.primary))
+ value->surface.primary = RrColorNew(inst, 0, 0, 0);
+ if (!read_color(db, inst, ctoname, &value->surface.secondary))
+ value->surface.secondary = RrColorNew(inst, 0, 0, 0);
+ if (value->surface.border)
+ if (!read_color(db, inst, bcname,
+ &value->surface.border_color))
+ value->surface.border_color = RrColorNew(inst, 0, 0, 0);
- if (!read_color(db, inst, icname,
- &value->surface.interlace_color))
- value->surface.interlace_color = RrColorNew(inst, 0, 0, 0);
- ret = TRUE;
+ if (!read_color(db, inst, icname,
+ &value->surface.interlace_color))
+ value->surface.interlace_color = RrColorNew(inst, 0, 0, 0);
+ ret = TRUE;
a->surface.primary = RrColorNew(a->inst, 0, 0, 0);
a->surface.secondary = RrColorNew(a->inst, 0, 0, 0);
}
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;
+}