const gchar* url;
/* reset the colors and fonts to defalts */
- vp_set_widget_font(vp.gui.inputbox, inputbox_font[0], inputbox_bg[0], inputbox_fg[0]);
+ vp_set_widget_font(
+ vp.gui.inputbox,
+ &vp.style.input_fg[VP_MSG_NORMAL],
+ &vp.style.input_bg[VP_MSG_NORMAL],
+ vp.style.input_font[VP_MSG_NORMAL]
+ );
/* remove content from input box */
gtk_entry_set_text(GTK_ENTRY(vp.gui.inputbox), "");
#define START_PAGE "http://sourceforge.net/apps/trac/vimprobable"
- /* normal error */
-const char *inputbox_font[2] = { "monospace normal 8", "monospace bold 8"};
-const char *inputbox_fg[2] = { "#000000", "#000000" };
-const char *inputbox_bg[2] = { "#ffffff", "#ff0000" };
-
#define SETTING_DEFAUL_FONT_SIZE 12
#define SETTING_USER_AGENT PROJECT "/" VERSION " (X11; Linux i686) AppleWebKit/535.22+ Compatible (Safari)"
#define SETTING_MAX_CONNS 25
if (vp.state.mode == VP_MODE_COMMAND) {
return FALSE;
}
- const MessageType type = VP_MSG_NORMAL;
- vp_set_widget_font(vp.gui.inputbox, inputbox_font[type], inputbox_bg[type], inputbox_fg[type]);
+
+ vp_set_widget_font(
+ vp.gui.inputbox,
+ &vp.style.input_fg[VP_MSG_NORMAL],
+ &vp.style.input_bg[VP_MSG_NORMAL],
+ vp.style.input_font[VP_MSG_NORMAL]
+ );
+
gtk_entry_set_text(GTK_ENTRY(vp.gui.inputbox), "");
return FALSE;
}
/* set the collors according to message type */
- vp_set_widget_font(vp.gui.inputbox, inputbox_font[type], inputbox_bg[type], inputbox_fg[type]);
+ vp_set_widget_font(
+ vp.gui.inputbox,
+ &vp.style.input_fg[type],
+ &vp.style.input_bg[type],
+ vp.style.input_font[type]
+ );
gtk_entry_set_text(GTK_ENTRY(vp.gui.inputbox), message);
g_timeout_add_seconds(2, (GSourceFunc)vp_hide_message, NULL);
}
gtk_entry_set_inner_border(GTK_ENTRY(gui->inputbox), NULL);
g_object_set(gtk_widget_get_settings(gui->inputbox), "gtk-entry-select-on-focus", FALSE, NULL);
- vp_set_widget_font(gui->inputbox, inputbox_font[0], inputbox_bg[0], inputbox_fg[0]);
-
/* Prepare the statusbar */
gui->statusbar.box = GTK_BOX(gtk_hbox_new(FALSE, 0));
gui->statusbar.left = gtk_label_new(NULL);
g_free(path);
}
-void vp_set_widget_font(GtkWidget* widget, const gchar* font_definition, const gchar* bg_color, const gchar* fg_color)
+void vp_set_widget_font(GtkWidget* widget, const GdkColor* fg, const GdkColor* bg, PangoFontDescription* font)
{
- GdkColor fg, bg;
- PangoFontDescription *font;
-
- font = pango_font_description_from_string(font_definition);
gtk_widget_modify_font(widget, font);
- pango_font_description_free(font);
-
- if (fg_color) {
- gdk_color_parse(fg_color, &fg);
- }
- if (bg_color) {
- gdk_color_parse(bg_color, &bg);
- }
-
- gtk_widget_modify_text(widget, GTK_STATE_NORMAL, fg_color ? &fg : NULL);
- gtk_widget_modify_base(widget, GTK_STATE_NORMAL, bg_color ? &bg : NULL);
+ gtk_widget_modify_text(widget, GTK_STATE_NORMAL, fg);
+ gtk_widget_modify_base(widget, GTK_STATE_NORMAL, bg);
}
static void vp_setup_signals(void)
};
typedef enum {
VP_MSG_NORMAL,
- VP_MSG_ERROR
+ VP_MSG_ERROR,
+ VP_MSG_LAST
} MessageType;
enum {
GList* active;
} Completions;
+typedef struct {
+ GdkColor input_fg[VP_MSG_LAST];
+ GdkColor input_bg[VP_MSG_LAST];
+ PangoFontDescription* input_font[VP_MSG_LAST];
+} Style;
+
/* core struct */
typedef struct {
Gui gui;
#endif
Config config;
Completions comps;
+ Style style;
#if 0
Ssl ssl;
Communication comm;
/* functions */
void vp_update_statusbar(void);
void vp_update_urlbar(const gchar* uri);
-void vp_echo(const MessageType type, const char *error, ...);
+void vp_echo(const MessageType type, const char* error, ...);
gboolean vp_set_mode(const Arg* arg);
-void vp_set_widget_font(GtkWidget* widget, const gchar* font_definition, const gchar* bg_color, const gchar* fg_color);
+void vp_set_widget_font(GtkWidget* widget, const GdkColor* fg, const GdkColor* bg, PangoFontDescription* font);
gboolean vp_load_uri(const Arg* arg);
void vp_clean_up(void);
static gboolean setting_status_color_bg(const Setting* s);
static gboolean setting_status_color_fg(const Setting* s);
static gboolean setting_status_font(const Setting* s);
+static gboolean setting_style(const Setting* s);
static Setting default_settings[] = {
/* webkit settings */
{"status-color-bg", TYPE_CHAR, setting_status_color_bg, {.s = "#000"}},
{"status-color-fg", TYPE_CHAR, setting_status_color_fg, {.s = "#fff"}},
{"status-font", TYPE_CHAR, setting_status_font, {.s = "monospace bold 8"}},
+ {"input-bg-normal", TYPE_CHAR, setting_style, {.s = "#fff"}},
+ {"input-bg-error", TYPE_CHAR, setting_style, {.s = "#f00"}},
+ {"input-fg-normal", TYPE_CHAR, setting_style, {.s = "#000"}},
+ {"input-fg-error", TYPE_CHAR, setting_style, {.s = "#000"}},
+ {"input-font-normal", TYPE_CHAR, setting_style, {.s = "monospace normal 8"}},
+ {"input-font-error", TYPE_CHAR, setting_style, {.s = "monospace bold 8"}},
};
static GHashTable* settings = NULL;
a = util_char_to_arg(param, s->type);
if (a == NULL) {
vp_echo(VP_MSG_ERROR, "No valid value");
- return FALSE;
+ return FALSE;
}
s->arg = *a;
return TRUE;
}
+
+static gboolean setting_style(const Setting* s)
+{
+ Style* style = &vp.style;
+
+ MessageType type = g_str_has_suffix(s->name, "error") ? VP_MSG_ERROR : VP_MSG_NORMAL;
+
+ if (g_str_has_prefix(s->name, "input-bg")) {
+ PRINT_DEBUG("Set style %s -> %s", s->name, s->arg.s);
+ gdk_color_parse(s->arg.s, &style->input_bg[type]);
+ } else if (g_str_has_prefix(s->name, "input-fg")) {
+ PRINT_DEBUG("Set style %s -> %s", s->name, s->arg.s);
+ gdk_color_parse(s->name, &style->input_fg[type]);
+ } else if (g_str_has_prefix(s->arg.s, "input-font")) {
+ PRINT_DEBUG("Set style %s -> %s", s->name, s->arg.s);
+ if (style->input_font[type]) {
+ pango_font_description_free(style->input_font[type]);
+ }
+ style->input_font[type] = pango_font_description_from_string(s->arg.s);
+ }
+
+ return TRUE;
+}