Comp_Func func, const char* input, const char* prefix);
static GList* completion_update(GList* completion, GList* active, gboolean back);
static void completion_show(gboolean back);
-static void completion_set_color(Completion* completion, const VpColor* fg, const VpColor* bg, PangoFontDescription* font);
static void completion_set_entry_text(Completion* c);
static char* completion_get_text(Completion* c);
static Completion* completion_get_new(const char* label, const char* prefix);
}
}
- completion_set_color(
- old->data,
- &core.style.comp_fg[VP_COMP_NORMAL],
- &core.style.comp_bg[VP_COMP_NORMAL],
- core.style.comp_font[VP_COMP_NORMAL]
- );
- completion_set_color(
- new->data,
- &core.style.comp_fg[VP_COMP_ACTIVE],
- &core.style.comp_bg[VP_COMP_ACTIVE],
- core.style.comp_font[VP_COMP_ACTIVE]
- );
+ VP_WIDGET_SET_STATE(((Completion*)old->data)->label, VP_GTK_STATE_NORMAL);
+ VP_WIDGET_SET_STATE(((Completion*)old->data)->event, VP_GTK_STATE_NORMAL);
+ VP_WIDGET_SET_STATE(((Completion*)new->data)->label, VP_GTK_STATE_ACTIVE);
+ VP_WIDGET_SET_STATE(((Completion*)new->data)->event, VP_GTK_STATE_ACTIVE);
active = new;
completion_set_entry_text(active->data);
}
}
if (vp.comps.active != NULL) {
- completion_set_color(
- vp.comps.active->data,
- &core.style.comp_fg[VP_COMP_ACTIVE],
- &core.style.comp_bg[VP_COMP_ACTIVE],
- core.style.comp_font[VP_COMP_ACTIVE]
- );
- completion_set_entry_text(vp.comps.active->data);
+ Completion* active = (Completion*)vp.comps.active->data;
+ VP_WIDGET_SET_STATE(active->label, VP_GTK_STATE_ACTIVE);
+ VP_WIDGET_SET_STATE(active->event, VP_GTK_STATE_ACTIVE);
+
+ completion_set_entry_text(active);
gtk_widget_show(vp.gui.compbox);
}
}
-static void completion_set_color(Completion* completion, const VpColor* fg, const VpColor* bg, PangoFontDescription* font)
-{
- VP_WIDGET_OVERRIDE_COLOR(completion->label, GTK_STATE_NORMAL, fg);
- VP_WIDGET_OVERRIDE_BACKGROUND(completion->event, GTK_STATE_NORMAL, bg);
- /* TODO is it really necessary to set the font for each item */
- VP_WIDGET_OVERRIDE_FONT(completion->label, font);
-}
-
static void completion_set_entry_text(Completion* c)
{
char* text = completion_get_text(c);
gtk_label_set_ellipsize(GTK_LABEL(c->label), PANGO_ELLIPSIZE_MIDDLE);
gtk_misc_set_alignment(GTK_MISC(c->label), 0.0, 0.5);
- completion_set_color(
- c,
- &core.style.comp_fg[VP_COMP_NORMAL],
- &core.style.comp_bg[VP_COMP_NORMAL],
- core.style.comp_font[VP_COMP_NORMAL]
- );
+ VP_WIDGET_SET_STATE(c->label, VP_GTK_STATE_NORMAL);
+ VP_WIDGET_SET_STATE(c->event, VP_GTK_STATE_NORMAL);
+
+ VP_WIDGET_OVERRIDE_COLOR(c->label, GTK_STATE_NORMAL, &core.style.comp_fg[VP_COMP_NORMAL]);
+ VP_WIDGET_OVERRIDE_COLOR(c->label, GTK_STATE_ACTIVE, &core.style.comp_fg[VP_COMP_ACTIVE]);
+ VP_WIDGET_OVERRIDE_BACKGROUND(c->event, GTK_STATE_NORMAL, &core.style.comp_bg[VP_COMP_NORMAL]);
+ VP_WIDGET_OVERRIDE_BACKGROUND(c->event, GTK_STATE_ACTIVE, &core.style.comp_bg[VP_COMP_ACTIVE]);
+ VP_WIDGET_OVERRIDE_FONT(c->label, core.style.comp_font);
GtkWidget *alignment = gtk_alignment_new(0.5, 0.5, 1, 1);
gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), padding, padding, padding, padding);
#define VP_WIDGET_OVERRIDE_COLOR gtk_widget_override_color
#define VP_WIDGET_OVERRIDE_TEXT gtk_widget_override_color
#define VP_WIDGET_OVERRIDE_FONT gtk_widget_override_font
+
+#define VP_GTK_STATE_NORMAL GTK_STATE_FLAG_NORMAL
+#define VP_GTK_STATE_ACTIVE GTK_STATE_FLAG_ACTIVE
+#define VP_WIDGET_SET_STATE(w, s) gtk_widget_set_state_flags(w, s, true)
+
#else
+
#define VpColor GdkColor
#define VP_COLOR_PARSE(color, string) (gdk_color_parse(string, color))
#define VP_COLOR_TO_STRING(color) (gdk_color_to_string(color))
#define VP_WIDGET_OVERRIDE_COLOR gtk_widget_modify_fg
#define VP_WIDGET_OVERRIDE_TEXT gtk_widget_modify_text
#define VP_WIDGET_OVERRIDE_FONT gtk_widget_modify_font
+
+#define VP_GTK_STATE_NORMAL GTK_STATE_NORMAL
+#define VP_GTK_STATE_ACTIVE GTK_STATE_ACTIVE
+#define VP_WIDGET_SET_STATE(w, s) gtk_widget_set_state(w, s)
#endif
/* enums */
/* completion */
VpColor comp_fg[VP_COMP_LAST];
VpColor comp_bg[VP_COMP_LAST];
- PangoFontDescription* comp_font[VP_COMP_LAST];
+ PangoFontDescription* comp_font;
/* hint style */
char* hint_bg;
char* hint_bg_focus;
{NULL, "input-fg-error", TYPE_COLOR, setting_input_style, {.s = "#000"}},
{NULL, "input-font-normal", TYPE_FONT, setting_input_style, {.s = "monospace normal 8"}},
{NULL, "input-font-error", TYPE_FONT, setting_input_style, {.s = "monospace bold 8"}},
- {NULL, "completion-font-normal", TYPE_FONT, setting_completion_style, {.s = "monospace normal 8"}},
- {NULL, "completion-font-active", TYPE_FONT, setting_completion_style, {.s = "monospace bold 8"}},
+ {NULL, "completion-font", TYPE_FONT, setting_completion_style, {.s = "monospace normal 8"}},
{NULL, "completion-fg-normal", TYPE_COLOR, setting_completion_style, {.s = "#f6f3e8"}},
{NULL, "completion-fg-active", TYPE_COLOR, setting_completion_style, {.s = "#fff"}},
{NULL, "completion-bg-normal", TYPE_COLOR, setting_completion_style, {.s = "#656565"}},
}
} else if (s->type == TYPE_FONT) {
if (type == SETTING_GET) {
- setting_print_value(s, style->comp_font[ctype]);
+ setting_print_value(s, style->comp_font);
} else {
- if (style->comp_font[ctype]) {
- pango_font_description_free(style->comp_font[ctype]);
+ if (style->comp_font) {
+ pango_font_description_free(style->comp_font);
}
- style->comp_font[ctype] = pango_font_description_from_string(s->arg.s);
+ style->comp_font = pango_font_description_from_string(s->arg.s);
}
} else {
VpColor* color = NULL;