summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Carl <danielcarl@gmx.de>2012-12-23 02:40:42 +0100
committerDaniel Carl <danielcarl@gmx.de>2012-12-23 02:40:42 +0100
commit06e7ae451015635c07b79f019c5ef0870c53f8bc (patch)
treedbdba09b75ba9ce4dccd71e5e106c54fe8c89a54 /src
parente8f998d384578e9fac75a3e85448fee3313b1840 (diff)
Allow to set hint element style on runtime.
Diffstat (limited to 'src')
-rw-r--r--src/hints.c12
-rw-r--r--src/main.h6
-rw-r--r--src/setting.c21
3 files changed, 31 insertions, 8 deletions
diff --git a/src/hints.c b/src/hints.c
index 8f81cdb..906207e 100644
--- a/src/hints.c
+++ b/src/hints.c
@@ -27,10 +27,6 @@
#define HINT_CONTAINER_ID "__hint_container"
#define HINT_CLASS "__hint"
-#define ELEM_BACKGROUND "#ff0"
-#define ELEM_BACKGROUND_FOCUS "#8f0"
-#define ELEM_COLOR "#000"
-
#define HINT_CONTAINER_STYLE "line-height:1em;"
#define HINT_STYLE "z-index:100000;"\
"position:absolute;"\
@@ -293,8 +289,8 @@ static void hints_create_for_window(const gchar* input, Window* win, gulong hint
g_free(num);
/* change the style of the hinted element */
- dom_element_style_set_property(newHint->elem, "background-color", ELEM_BACKGROUND);
- dom_element_style_set_property(newHint->elem, "color", ELEM_COLOR);
+ dom_element_style_set_property(newHint->elem, "background-color", vp.style.hint_bg);
+ dom_element_style_set_property(newHint->elem, "color", vp.style.hint_fg);
webkit_dom_node_append_child(WEBKIT_DOM_NODE(container), WEBKIT_DOM_NODE(hint), NULL);
}
@@ -322,7 +318,7 @@ static void hints_focus(const gulong num)
Hint* hint = hints_get_hint_by_number(vp.hints.focusNum);
if (hint) {
/* reset previous focused element */
- dom_element_style_set_property(hint->elem, "background-color", ELEM_BACKGROUND);
+ dom_element_style_set_property(hint->elem, "background-color", vp.style.hint_bg);
doc = webkit_dom_node_get_owner_document(WEBKIT_DOM_NODE(hint->elem));
dom_dispatch_mouse_event(doc, hint->elem, "mouseout", 0);
@@ -331,7 +327,7 @@ static void hints_focus(const gulong num)
hint = hints_get_hint_by_number(num);
if (hint) {
/* mark new hint as focused */
- dom_element_style_set_property(hint->elem, "background-color", ELEM_BACKGROUND_FOCUS);
+ dom_element_style_set_property(hint->elem, "background-color", vp.style.hint_bg_focus);
doc = webkit_dom_node_get_owner_document(WEBKIT_DOM_NODE(hint->elem));
dom_dispatch_mouse_event(doc, hint->elem, "mouseover", 0);
diff --git a/src/main.h b/src/main.h
index 1159946..c944f51 100644
--- a/src/main.h
+++ b/src/main.h
@@ -69,6 +69,8 @@
#define VP_WIDGET_OVERRIDE_FONT gtk_widget_modify_font
#endif
+#define HEX_COLOR_LEN 8
+
/* enums */
typedef enum _vp_mode {
VP_MODE_NORMAL = 1<<0,
@@ -215,6 +217,10 @@ typedef struct {
VpColor comp_fg[VP_COMP_LAST];
VpColor comp_bg[VP_COMP_LAST];
PangoFontDescription* comp_font[VP_COMP_LAST];
+ /* hint style */
+ gchar hint_bg[HEX_COLOR_LEN];
+ gchar hint_bg_focus[HEX_COLOR_LEN];
+ gchar hint_fg[HEX_COLOR_LEN];
} Style;
typedef struct {
diff --git a/src/setting.c b/src/setting.c
index fa083bf..271ced3 100644
--- a/src/setting.c
+++ b/src/setting.c
@@ -30,6 +30,7 @@ static gboolean setting_status_color_fg(const Setting* s);
static gboolean setting_status_font(const Setting* s);
static gboolean setting_input_style(const Setting* s);
static gboolean setting_completion_style(const Setting* s);
+static gboolean setting_hint_style(const Setting* s);
static Setting default_settings[] = {
/* webkit settings */
@@ -96,6 +97,9 @@ static Setting default_settings[] = {
{NULL, "completion-fg-active", TYPE_CHAR, setting_completion_style, {.s = "#fff"}},
{NULL, "completion-bg-normal", TYPE_CHAR, setting_completion_style, {.s = "#656565"}},
{NULL, "completion-bg-active", TYPE_CHAR, setting_completion_style, {.s = "#777777"}},
+ {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"}},
};
@@ -272,3 +276,20 @@ static gboolean setting_completion_style(const Setting* s)
return TRUE;
}
+
+static gboolean setting_hint_style(const Setting* s)
+{
+ Style* style = &vp.style;
+ if (!g_strcmp0(s->name, "hint-bg")) {
+ strncpy(style->hint_bg, s->arg.s, HEX_COLOR_LEN - 1);
+ style->hint_bg[HEX_COLOR_LEN - 1] = '\0';
+ } else if (!g_strcmp0(s->name, "hint-bg-focus")) {
+ strncpy(style->hint_bg_focus, s->arg.s, HEX_COLOR_LEN - 1);
+ style->hint_bg_focus[HEX_COLOR_LEN] = '\0';
+ } 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';
+ }
+
+ return TRUE;
+}