]> git.mdlowis.com Git - proto/labwc.git/commitdiff
Split theme-builtin.c into a separate file
authorJohan Malm <jgm323@gmail.com>
Tue, 15 Sep 2020 19:01:41 +0000 (20:01 +0100)
committerJohan Malm <jgm323@gmail.com>
Tue, 15 Sep 2020 19:01:41 +0000 (20:01 +0100)
include/theme/theme.h
src/theme/meson.build
src/theme/theme-builtin.c [new file with mode: 0644]
src/theme/theme.c

index 351b136270277914a138256decad1d1ec20b1c96..5483ccd1cd1303d8bf215e56a4697b087d039cba 100644 (file)
@@ -30,6 +30,13 @@ struct theme {
 
 extern struct theme theme;
 
+/**
+ * parse_hexstr - parse #rrggbb
+ * @hex: hex string to be parsed
+ * @rgba: pointer to float[4] for return value
+ */
+void parse_hexstr(const char *hex, float *rgba);
+
 /**
  * theme_read - read theme into global theme struct
  * @theme_name: theme-name in <theme-dir>/<theme-name>/openbox-3/themerc
@@ -37,4 +44,11 @@ extern struct theme theme;
  */
 void theme_read(const char *theme_name);
 
+/**
+ * theme_builin - apply built-in theme similar to Clearlooks
+ * Note: Only used if no theme can be found. Default values for individual
+ * theme options are as per openbox spec and are typically black/white.
+ */
+void theme_builtin(void);
+
 #endif /* __LABWC_THEME_H */
index a9bef667c75b0ed293cbaafb46bdb0723123eda4..7800344ac802eb2ae1540efd7ea43b7ab42273e2 100644 (file)
@@ -1,4 +1,5 @@
 labwc_sources += files(
   'theme.c',
+  'theme-builtin.c',
 )
 
diff --git a/src/theme/theme-builtin.c b/src/theme/theme-builtin.c
new file mode 100644 (file)
index 0000000..e99f78f
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+#include "theme/theme.h"
+
+/* clang-format off */
+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);
+       parse_hexstr("#000000", theme.window_inactive_button_unpressed_image_color);
+}
+/* clang-format on */
index 5942d0c618e81862e3882696357a24ac13042000..a588beb23507c7a2ae26cf64d1f8e21c358a1711 100644 (file)
@@ -21,7 +21,7 @@ static int hex_to_dec(char c)
        return 0;
 }
 
-static void parse_hexstr(const char *hex, float *rgba)
+void parse_hexstr(const char *hex, float *rgba)
 {
        if (!hex || hex[0] != '#' || strlen(hex) < 7)
                return;
@@ -95,27 +95,6 @@ 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.
- */
-/* clang-format off */
-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);
-       parse_hexstr("#000000", theme.window_inactive_button_unpressed_image_color);
-}
-/* clang-format on */
-
 void theme_read(const char *theme_name)
 {
        FILE *stream = NULL;