]> git.mdlowis.com Git - proto/labwc.git/commitdiff
theme: set sane values if no theme found
authorJohan Malm <jgm323@gmail.com>
Fri, 21 Aug 2020 18:54:28 +0000 (19:54 +0100)
committerJohan Malm <jgm323@gmail.com>
Fri, 21 Aug 2020 18:54:28 +0000 (19:54 +0100)
data/themes/labwc-default/openbox-3/themerc
src/theme/theme.c
src/theme/xbm/xbm.c

index c698a50da55ce58dce7ebe6463cd35f413ee1fd9..1a1c033c8d8c469898d0e8513d15215286fe0499 100644 (file)
@@ -2,3 +2,6 @@ window.active.title.bg.color: #589bda
 window.active.handle.bg.color: #3c7cb7
 
 window.inactive.title.bg.color: #efece6
+
+window.active.button.unpressed.image.color = #ffffff
+
index 9a016707630bea621a8bbeaf5538a0171f3eb899..d4ddd53616108aa7fe3f455478dc7d5a6bc6f8a1 100644 (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) {
index d1b2969b73449e6a631c19b6dc2d36b18bef28ef..85a6882620726fb903e4d2e00e2493b5e98d37d0 100644 (file)
@@ -69,6 +69,7 @@ out:
                *texture = texture_from_builtin(renderer, button);
 }
 
+/* clang-format off */
 void xbm_load(struct wlr_renderer *r)
 {
        parse_set_color(theme.window_active_button_unpressed_image_color);
@@ -76,3 +77,4 @@ void xbm_load(struct wlr_renderer *r)
        load_button(r, "max.xbm", &theme.xbm_maximize, max_button_normal);
        load_button(r, "iconify.xbm", &theme.xbm_iconify, iconify_button_normal);
 }
+/* clang-format on */