theme: set sane values if no theme found

This commit is contained in:
Johan Malm 2020-08-21 19:54:28 +01:00
parent e25118d8ec
commit cda27da33e
3 changed files with 25 additions and 1 deletions

View file

@ -91,6 +91,24 @@ static void process_line(char *line)
entry(key, value);
}
/*
* We generally use Openbox defaults, but if no theme file can be found it's
* better to populate the theme variables with some sane values as no-one
* wants to use openbox without a theme - it'll all just be black and white.
*
* Openbox doesn't actual start if it can't find a theme. As it's normally
* packaged with Clearlooks, this is not a problem, but for labwc I thought
* this was a bit hard-line. People might want to try labwc without having
* Openbox (and associated themes) installed.
*/
void theme_builtin(void)
{
parse_hexstr("#589bda", theme.window_active_title_bg_color);
parse_hexstr("#3c7cb7", theme.window_active_handle_bg_color);
parse_hexstr("#efece6", theme.window_inactive_title_bg_color);
parse_hexstr("#ffffff", theme.window_active_button_unpressed_image_color);
}
void theme_read(const char *theme_name)
{
FILE *stream;
@ -102,7 +120,8 @@ void theme_read(const char *theme_name)
info("reading themerc (%s)", themerc);
stream = fopen(themerc, "r");
if (!stream) {
warn("cannot read (%s)", themerc);
warn("cannot read (%s) - load built-in theme", themerc);
theme_builtin();
return;
}
while (getline(&line, &len, stream) != -1) {