From d5a3b16e2db146ab911044adb05800935500daf2 Mon Sep 17 00:00:00 2001 From: Daniel Carl Date: Sun, 23 Dec 2012 02:54:22 +0100 Subject: [PATCH] Allow to set the style of hints on runtime. --- src/hints.c | 15 ++------------- src/main.c | 6 +++--- src/main.h | 1 + src/setting.c | 7 +++++++ 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/hints.c b/src/hints.c index 906207e..213dd5d 100644 --- a/src/hints.c +++ b/src/hints.c @@ -28,18 +28,7 @@ #define HINT_CLASS "__hint" #define HINT_CONTAINER_STYLE "line-height:1em;" -#define HINT_STYLE "z-index:100000;"\ - "position:absolute;"\ - "font-family:monospace;"\ - "font-size:10px;"\ - "font-weight:bold;"\ - "color:#000;"\ - "background-color:#fff;"\ - "margin:0;"\ - "padding:0px 1px;"\ - "border:1px solid #444;"\ - "opacity:0.7;"\ - "left:%lipx;top:%lipx;" +#define HINT_STYLE "z-index:100000;position:absolute;left:%lipx;top:%lipx;%s" typedef struct { gulong num; @@ -281,7 +270,7 @@ static void hints_create_for_window(const gchar* input, Window* win, gulong hint gulong left = rect.left - 3; gulong top = rect.top - 3; - dom_element_set_style(hint, HINT_STYLE, left, top); + dom_element_set_style(hint, HINT_STYLE, left, top, vp.style.hint_style); gchar* num = g_strdup_printf("%li", newHint->num); webkit_dom_html_element_set_inner_text(WEBKIT_DOM_HTML_ELEMENT(hint), num, NULL); diff --git a/src/main.c b/src/main.c index bbcccfa..6023a47 100644 --- a/src/main.c +++ b/src/main.c @@ -437,12 +437,12 @@ static void vp_init(void) /* initialize the keybindings */ keybind_init(); - /* initialize settings */ - setting_init(); - /* initialize the hints */ hints_init(); + /* initialize settings */ + setting_init(); + vp_read_config(); } diff --git a/src/main.h b/src/main.h index c944f51..7120caf 100644 --- a/src/main.h +++ b/src/main.h @@ -221,6 +221,7 @@ typedef struct { gchar hint_bg[HEX_COLOR_LEN]; gchar hint_bg_focus[HEX_COLOR_LEN]; gchar hint_fg[HEX_COLOR_LEN]; + gchar* hint_style; } Style; typedef struct { diff --git a/src/setting.c b/src/setting.c index 271ced3..7ef26e7 100644 --- a/src/setting.c +++ b/src/setting.c @@ -100,6 +100,7 @@ static Setting default_settings[] = { {NULL, "hint-bg", TYPE_CHAR, setting_hint_style, {.s = "#ff0"}}, {NULL, "hint-bg-focus", TYPE_CHAR, setting_hint_style, {.s = "#8f0"}}, {NULL, "hint-fg", TYPE_CHAR, setting_hint_style, {.s = "#000"}}, + {NULL, "hint-style", TYPE_CHAR, setting_hint_style, {.s = "font-family:monospace;font-weight:bold;color:#000;background-color:#fff;margin:0;padding:0px 1px;border:1px solid #444;opacity:0.7;"}}, }; @@ -289,6 +290,12 @@ static gboolean setting_hint_style(const Setting* s) } else if (!g_strcmp0(s->name, "hint-fg")) { strncpy(style->hint_fg, s->arg.s, HEX_COLOR_LEN - 1); style->hint_fg[HEX_COLOR_LEN - 1] = '\0'; + } else if (!g_strcmp0(s->name, "hint-style")) { + if (style->hint_style) { + g_free(style->hint_style); + style->hint_style = NULL; + } + style->hint_style = g_strdup(s->arg.s); } return TRUE; -- 2.20.1