summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Carl <danielcarl@gmx.de>2021-10-08 00:44:47 +0200
committerrafa_99 <raroma09@gmail.com>2021-10-15 23:19:41 +0100
commit6693b044e326361f8b82bb64fa7a4c8b256a839b (patch)
treed1b4a11629dbe18827ee33fccbc1f5d7a81a7628 /src
parentceff22d28a8978bda732ad2b89839dd8e4c5eca0 (diff)
Used macro to define status pattern and values together.
Use a more flexible way to specify how the setting flags are shown on statusbar.
Diffstat (limited to 'src')
-rw-r--r--src/config.def.h34
-rw-r--r--src/main.c19
2 files changed, 32 insertions, 21 deletions
diff --git a/src/config.def.h b/src/config.def.h
index fd70a51..772282c 100644
--- a/src/config.def.h
+++ b/src/config.def.h
@@ -91,13 +91,27 @@
#define SETTING_HINT_KEYS "0123456789"
-/* These are the three settings displayed when "status-bar-show-settings" is enabled
- * With booleans, please use GET_BOOL and append ( ? "on" : "off" )
- * With integers, you could just print the value and use GET_INT
- * Strings do not need any additional modifications, use GET_CHAR */
-#define STATUS_NAME1 "js"
-#define STATUS_TYPE1 GET_BOOL(c, "scripts") ? "on" : "off"
-#define STATUS_NAME2 "cookies"
-#define STATUS_TYPE2 GET_CHAR(c, "cookie-accept")
-#define STATUS_NAME3 "storage"
-#define STATUS_TYPE3 GET_BOOL(c, "html5-local-storage") ? "on" : "off"
+/* This status indicator is only shown if "status-bar-show-settings" is
+ * enabled.
+ * The CHAR_MAP(value, internalValue, outputValue, valueIfNotMapped) is a
+ * little workaround to translate internal used string value like for
+ * GET_CHAR(c, "cookie-accept") which is one of "always", "origin" or "never"
+ * to those values that should be shown on statusbar.
+ * The STATUS_VARAIBLE_SHOW is used as argument for a printf like function. So
+ * the first argument is the output pattern. */
+/*
+#define STATUS_VARAIBLE_SHOW "js: %s, cookies: %s, hint-timeout: %d", \
+ GET_BOOL(c, "scripts") ? "on" : "off", \
+ GET_CHAR(c, "cookie-accept"), \
+ GET_INT(c, "hint-timeout")
+*/
+#define COOKIE GET_CHAR(c, "cookie-accept")
+#define STATUS_VARAIBLE_SHOW "%c%c%c%c%c%c%c%c", \
+ CHAR_MAP(COOKIE, "always", 'A', CHAR_MAP(COOKIE, "origin", '@', 'a')), \
+ GET_BOOL(c, "dark-mode") ? 'D' : 'd', \
+ vb.incognito ? 'E' : 'e', \
+ GET_BOOL(c, "images") ? 'I' : 'i', \
+ GET_BOOL(c, "html5-local-storage") ? 'L' : 'l', \
+ GET_BOOL(c, "stylesheet") ? 'M' : 'm', \
+ GET_BOOL(c, "scripts") ? 'S' : 's', \
+ GET_BOOL(c, "strict-ssl") ? 'T' : 't'
diff --git a/src/main.c b/src/main.c
index b499918..cbd6b0f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -631,21 +631,18 @@ void vb_statusbar_update(Client *c)
statusbar_update_downloads(c, status);
- /**
- * These architectures have different kinds of issues with scroll
- * percentage, this is a somewhat clean fix that doesn't affect others.
- */
+ /* These architectures have different kinds of issues with scroll
+ * percentage, this is a somewhat clean fix that doesn't affect others. */
#if defined(_ARCH_PPC64) || defined(_ARCH_PPC) | defined(_ARCH_ARM)
- /* force the scroll percent to be 16-bit */
- c->state.scroll_percent = * (guint16*) ( &c->state.scroll_percent );
+ /* force the scroll percent to be 16-bit */
+ c->state.scroll_percent = *(guint16*)(&c->state.scroll_percent);
#endif
- if ( c->config.statusbar_show_settings ) {
- /* show 3 user defined variables on statusbar. can add more by using same template */
- g_string_append_printf(status, " %s: %s |", STATUS_NAME1, STATUS_TYPE1 );
- g_string_append_printf(status, " %s: %s |", STATUS_NAME2, STATUS_TYPE2 );
- g_string_append_printf(status, " %s: %s |", STATUS_NAME3, STATUS_TYPE3 );
+#ifdef STATUS_VARAIBLE_SHOW
+ if (c->config.statusbar_show_settings) {
+ g_string_append_printf(status, STATUS_VARAIBLE_SHOW);
}
+#endif
/* show the scroll status */
if (c->state.scroll_max == 0) {