}
}
+#define READ_INT(x_resstr, x_var, x_min, x_max, x_def) \
+ if (!read_int(db, x_resstr, & x_var) || \
+ x_var < x_min || x_var > x_max) \
+ x_var = x_def;
+
RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
gboolean allow_fallback,
RrFont *active_window_font, RrFont *inactive_window_font,
return NULL;
}
- theme = g_new0(RrTheme, 1);
+ theme = g_slice_new0(RrTheme);
theme->inst = inst;
theme->name = g_strdup(name ? name : DEFAULT_THEME);
theme->osd_font_unhilite = get_font(inactive_osd_font, &default_font,inst);
/* load direct dimensions */
- if ((!read_int(db, "menu.overlap.x", &theme->menu_overlap_x) &&
- !read_int(db, "menu.overlap", &theme->menu_overlap_x)) ||
- theme->menu_overlap_x < -100 || theme->menu_overlap_x > 100)
- theme->menu_overlap_x = 0;
- if ((!read_int(db, "menu.overlap.y", &theme->menu_overlap_y) &&
- !read_int(db, "menu.overlap", &theme->menu_overlap_y)) ||
- theme->menu_overlap_y < -100 || theme->menu_overlap_y > 100)
- theme->menu_overlap_y = 0;
- if (!read_int(db, "window.handle.width", &theme->handle_height) ||
- theme->handle_height < 0 || theme->handle_height > 100)
- theme->handle_height = 6;
- if (!read_int(db, "padding.width", &theme->paddingx) ||
- theme->paddingx < 0 || theme->paddingx > 100)
- theme->paddingx = 3;
- if (!read_int(db, "padding.height", &theme->paddingy) ||
- theme->paddingy < 0 || theme->paddingy > 100)
- theme->paddingy = theme->paddingx;
- if (!read_int(db, "border.width", &theme->fbwidth) ||
- theme->fbwidth < 0 || theme->fbwidth > 100)
- theme->fbwidth = 1;
- /* menu border width inherits from the frame border width */
- if (!read_int(db, "menu.border.width", &theme->mbwidth) ||
- theme->mbwidth < 0 || theme->mbwidth > 100)
- theme->mbwidth = theme->fbwidth;
- /* osd border width inherits from the frame border width */
- if (!read_int(db, "osd.border.width", &theme->obwidth) ||
- theme->obwidth < 0 || theme->obwidth > 100)
- theme->obwidth = theme->fbwidth;
- if (!read_int(db, "window.client.padding.width", &theme->cbwidthx) ||
- theme->cbwidthx < 0 || theme->cbwidthx > 100)
- theme->cbwidthx = theme->paddingx;
- if (!read_int(db, "window.client.padding.height", &theme->cbwidthy) ||
- theme->cbwidthy < 0 || theme->cbwidthy > 100)
- theme->cbwidthy = theme->cbwidthx;
- if (!read_int(db, "menu.separator.width", &theme->menu_sep_width) ||
- theme->menu_sep_width < 1 || theme->menu_sep_width > 100)
- theme->menu_sep_width = 1;
- if (!read_int(db, "menu.separator.padding.width",
- &theme->menu_sep_paddingx) ||
- theme->menu_sep_paddingx < 0 || theme->menu_sep_paddingx > 100)
- theme->menu_sep_paddingx = 6;
- if (!read_int(db, "menu.separator.padding.height",
- &theme->menu_sep_paddingy) ||
- theme->menu_sep_paddingy < 0 || theme->menu_sep_paddingy > 100)
- theme->menu_sep_paddingy = 3;
+
+ /* TODO: Need fallback for menu.overlap */
+ READ_INT("menu.overlap.x", theme->menu_overlap_x, -100, 100, 0);
+ READ_INT("menu.overlap.y", theme->menu_overlap_y, -100, 100, 0);
+ READ_INT("window.handle.width", theme->handle_height, 0, 100, 6);
+ READ_INT("padding.width", theme->paddingx, 0, 100, 3);
+ READ_INT("padding.height", theme->paddingy, 0, 100, theme->paddingx);
+ READ_INT("border.width", theme->fbwidth, 0, 100, 1);
+ READ_INT("menu.border.width", theme->mbwidth, 0, 100, theme->fbwidth);
+ READ_INT("osd.border.width", theme->obwidth, 0, 100, theme->fbwidth);
+ READ_INT("window.client.padding.width", theme->cbwidthx, 0, 100, theme->paddingx);
+ READ_INT("window.client.padding.height", theme->cbwidthy, 0, 100, theme->cbwidthx);
+ READ_INT("menu.separator.width", theme->menu_sep_width, 1, 100, 1);
+ READ_INT("menu.separator.padding.width", theme->menu_sep_paddingx, 0, 100, 6);
+ READ_INT("menu.separator.padding.height", theme->menu_sep_paddingy, 0, 100, 3);
/* load colors */
if (!read_color(db, inst,
theme->osd_hilite_label->texture[0].data.text.color =
theme->osd_text_active_color;
- theme->osd_unhilite_label->texture[0].type = RR_TEXTURE_TEXT;
- theme->osd_unhilite_label->texture[0].data.text.justify = RR_JUSTIFY_LEFT;
- theme->osd_unhilite_label->texture[0].data.text.font =
- theme->osd_font_unhilite;
- theme->osd_unhilite_label->texture[0].data.text.color =
- theme->osd_text_inactive_color;
-
if (read_string(db, "osd.active.label.text.font", &str) ||
read_string(db, "osd.label.text.font", &str))
{
theme->osd_hilite_label->texture[0].data.text.shadow_alpha =
theme->osd_text_active_shadow_alpha;
+ theme->a_unfocused_label->texture[0].type = RR_TEXTURE_TEXT;
+ theme->a_unfocused_label->texture[0].data.text.justify = winjust;
+ theme->a_unfocused_label->texture[0].data.text.font =
+ theme->win_font_unfocused;
+ theme->a_unfocused_label->texture[0].data.text.color =
+ theme->title_unfocused_color;
+
+ if (read_string(db, "window.inactive.label.text.font", &str)) {
+ char *p;
+ gint i = 0;
+ gint j;
+ if (strstr(str, "shadow=y")) {
+ if ((p = strstr(str, "shadowoffset=")))
+ i = parse_inline_number(p + strlen("shadowoffset="));
+ else
+ i = 1;
+ theme->a_unfocused_label->texture[0].data.text.shadow_offset_x = i;
+ theme->a_unfocused_label->texture[0].data.text.shadow_offset_y = i;
+ }
+ if ((p = strstr(str, "shadowtint=")))
+ {
+ i = parse_inline_number(p + strlen("shadowtint="));
+ j = (i > 0 ? 0 : 255);
+ i = ABS(i*255/100);
+
+ theme->title_unfocused_shadow_color = RrColorNew(inst, j, j, j);
+ theme->title_unfocused_shadow_alpha = i;
+ } else {
+ theme->title_unfocused_shadow_color = RrColorNew(inst, 0, 0, 0);
+ theme->title_unfocused_shadow_alpha = 50;
+ }
+ }
+
+ theme->a_unfocused_label->texture[0].data.text.shadow_color =
+ theme->title_unfocused_shadow_color;
+ theme->a_unfocused_label->texture[0].data.text.shadow_alpha =
+ theme->title_unfocused_shadow_alpha;
+
+ theme->osd_unhilite_label->texture[0].type = RR_TEXTURE_TEXT;
+ theme->osd_unhilite_label->texture[0].data.text.justify = RR_JUSTIFY_LEFT;
+ theme->osd_unhilite_label->texture[0].data.text.font =
+ theme->osd_font_unhilite;
+ theme->osd_unhilite_label->texture[0].data.text.color =
+ theme->osd_text_inactive_color;
+
if (read_string(db, "osd.inactive.label.text.font", &str))
{
char *p;
theme->osd_text_inactive_shadow_alpha = 50;
}
} else {
- /* inherit the font settings from the focused label */
+ /* inherit the font settings from the unfocused label */
theme->osd_unhilite_label->texture[0].data.text.shadow_offset_x =
theme->a_unfocused_label->texture[0].data.text.shadow_offset_x;
theme->osd_unhilite_label->texture[0].data.text.shadow_offset_y =
theme->osd_unhilite_label->texture[0].data.text.shadow_alpha =
theme->osd_text_inactive_shadow_alpha;
- theme->a_unfocused_label->texture[0].type = RR_TEXTURE_TEXT;
- theme->a_unfocused_label->texture[0].data.text.justify = winjust;
- theme->a_unfocused_label->texture[0].data.text.font =
- theme->win_font_unfocused;
- theme->a_unfocused_label->texture[0].data.text.color =
- theme->title_unfocused_color;
-
- if (read_string(db, "window.inactive.label.text.font", &str)) {
- char *p;
- gint i = 0;
- gint j;
- if (strstr(str, "shadow=y")) {
- if ((p = strstr(str, "shadowoffset=")))
- i = parse_inline_number(p + strlen("shadowoffset="));
- else
- i = 1;
- theme->a_unfocused_label->texture[0].data.text.shadow_offset_x = i;
- theme->a_unfocused_label->texture[0].data.text.shadow_offset_y = i;
- }
- if ((p = strstr(str, "shadowtint=")))
- {
- i = parse_inline_number(p + strlen("shadowtint="));
- j = (i > 0 ? 0 : 255);
- i = ABS(i*255/100);
-
- theme->title_unfocused_shadow_color = RrColorNew(inst, j, j, j);
- theme->title_unfocused_shadow_alpha = i;
- } else {
- theme->title_unfocused_shadow_color = RrColorNew(inst, 0, 0, 0);
- theme->title_unfocused_shadow_alpha = 50;
- }
- }
-
- theme->a_unfocused_label->texture[0].data.text.shadow_color =
- theme->title_unfocused_shadow_color;
- theme->a_unfocused_label->texture[0].data.text.shadow_alpha =
- theme->title_unfocused_shadow_alpha;
-
theme->a_menu_text_title->texture[0].type = RR_TEXTURE_TEXT;
theme->a_menu_text_title->texture[0].data.text.justify = mtitlejust;
theme->a_menu_text_title->texture[0].data.text.font =
RrAppearanceFree(theme->osd_unhilite_bg);
RrAppearanceFree(theme->osd_unhilite_label);
- g_free(theme);
+ g_slice_free(RrTheme, theme);
}
}