Allow to set the style of hints on runtime.
authorDaniel Carl <danielcarl@gmx.de>
Sun, 23 Dec 2012 01:54:22 +0000 (02:54 +0100)
committerDaniel Carl <danielcarl@gmx.de>
Sun, 23 Dec 2012 01:54:22 +0000 (02:54 +0100)
src/hints.c
src/main.c
src/main.h
src/setting.c

index 906207e..213dd5d 100644 (file)
 #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);
index bbcccfa..6023a47 100644 (file)
@@ -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();
 }
 
index c944f51..7120caf 100644 (file)
@@ -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 {
index 271ced3..7ef26e7 100644 (file)
@@ -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;