summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Carl <danielcarl@gmx.de>2012-11-01 19:19:39 +0100
committerDaniel Carl <danielcarl@gmx.de>2012-11-10 14:43:03 +0100
commit18182e7052b06fcefe8821eec8e67171139279ce (patch)
treecbb15172d69b4b333a1caaccbdc18b343654a9fd
parent26f9b8e6d7b3ac4a93da2a9b15ccb39ba437990e (diff)
Allow to set status font and colors during runtime.
-rw-r--r--src/command.c2
-rw-r--r--src/config.h4
-rw-r--r--src/main.c13
-rw-r--r--src/main.h3
-rw-r--r--src/setting.c45
-rwxr-xr-xvimp_dbgbin0 -> 106075 bytes
6 files changed, 50 insertions, 17 deletions
diff --git a/src/command.c b/src/command.c
index f1328f8..add7da5 100644
--- a/src/command.c
+++ b/src/command.c
@@ -137,8 +137,8 @@ gboolean command_input(const Arg* arg)
gboolean command_close(const Arg* arg)
{
- vp_clean_up();
gtk_main_quit();
+ vp_clean_up();
return TRUE;
}
diff --git a/src/config.h b/src/config.h
index 3061064..99c7a7c 100644
--- a/src/config.h
+++ b/src/config.h
@@ -24,10 +24,6 @@
#define START_PAGE "http://sourceforge.net/apps/trac/vimprobable"
-#define STATUS_BG_COLOR "#000000" /* background color for status bar */
-#define STATUS_FG_COLOR "#ffffff" /* foreground color for status bar */
-#define STATUS_BAR_FONT "monospace bold 8"
-
/* normal error */
const char *inputbox_font[2] = { "monospace normal 8", "monospace bold 8"};
const char *inputbox_fg[2] = { "#000000", "#000000" };
diff --git a/src/main.c b/src/main.c
index c21c8af..4bb88c5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -304,7 +304,7 @@ void vp_update_urlbar(const gchar* uri)
{
gchar* markup;
- markup = g_markup_printf_escaped("<span font=\"%s\">%s</span>", STATUS_BAR_FONT, uri);
+ markup = g_markup_printf_escaped("<span font=\"%s\">%s</span>", vp.config.status_font, uri);
gtk_label_set_markup(GTK_LABEL(vp.gui.statusbar.left), markup);
g_free(markup);
}
@@ -335,7 +335,7 @@ void vp_update_statusbar(void)
g_string_append_printf(status, " %d%%", val);
}
- markup = g_markup_printf_escaped("<span font=\"%s\">%s</span>", STATUS_BAR_FONT, status->str);
+ markup = g_markup_printf_escaped("<span font=\"%s\">%s</span>", vp.config.status_font, status->str);
gtk_label_set_markup(GTK_LABEL(vp.gui.statusbar.right), markup);
g_free(markup);
}
@@ -420,7 +420,6 @@ static void vp_read_config(void)
static void vp_init_gui(void)
{
Gui* gui = &vp.gui;
- GdkColor bg, fg;
gui->sb_h = GTK_SCROLLBAR(gtk_hscrollbar_new(NULL));
gui->sb_v = GTK_SCROLLBAR(gtk_vscrollbar_new(NULL));
@@ -467,10 +466,6 @@ static void vp_init_gui(void)
/* Prepare the event box */
gui->eventbox = gtk_event_box_new();
- gdk_color_parse(STATUS_BG_COLOR, &bg);
- gdk_color_parse(STATUS_FG_COLOR, &fg);
- gtk_widget_modify_bg(gui->eventbox, GTK_STATE_NORMAL, &bg);
- gtk_widget_modify_fg(gui->eventbox, GTK_STATE_NORMAL, &fg);
vp_setup_signals();
@@ -482,10 +477,6 @@ static void vp_init_gui(void)
gtk_misc_set_alignment(GTK_MISC(gui->statusbar.right), 1.0, 0.0);
gtk_box_pack_start(gui->statusbar.box, gui->statusbar.left, TRUE, TRUE, 2);
gtk_box_pack_start(gui->statusbar.box, gui->statusbar.right, FALSE, FALSE, 2);
- gtk_widget_modify_bg(GTK_WIDGET(gui->statusbar.left), GTK_STATE_NORMAL, &bg);
- gtk_widget_modify_fg(GTK_WIDGET(gui->statusbar.left), GTK_STATE_NORMAL, &fg);
- gtk_widget_modify_bg(GTK_WIDGET(gui->statusbar.right), GTK_STATE_NORMAL, &bg);
- gtk_widget_modify_fg(GTK_WIDGET(gui->statusbar.right), GTK_STATE_NORMAL, &fg);
gtk_box_pack_start(gui->box, gui->viewport, TRUE, TRUE, 0);
gtk_box_pack_start(gui->box, gui->eventbox, FALSE, FALSE, 0);
diff --git a/src/main.h b/src/main.h
index 28af613..898bf2f 100644
--- a/src/main.h
+++ b/src/main.h
@@ -155,6 +155,9 @@ typedef struct {
typedef struct {
time_t cookie_timeout;
gint scrollstep;
+ gchar* status_color_bg;
+ gchar* status_color_fg;
+ gchar* status_font;
} Config;
/* core struct */
diff --git a/src/setting.c b/src/setting.c
index 5b713f1..ead6328 100644
--- a/src/setting.c
+++ b/src/setting.c
@@ -23,6 +23,9 @@
static gboolean setting_webkit(const Setting* s);
static gboolean setting_cookie_timeout(const Setting* s);
static gboolean setting_scrollstep(const Setting* s);
+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 Setting default_settings[] = {
/* webkit settings */
@@ -73,6 +76,9 @@ static Setting default_settings[] = {
/* internal variables */
{"cookie-timeout", TYPE_INTEGER, setting_cookie_timeout, {.i = 4800}},
{"scrollstep", TYPE_INTEGER, setting_scrollstep, {.i = 40}},
+ {"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"}},
};
static GHashTable* settings = NULL;
@@ -166,8 +172,45 @@ static gboolean setting_cookie_timeout(const Setting* s)
static gboolean setting_scrollstep(const Setting* s)
{
- PRINT_DEBUG("Set scrollstep to %d", s->arg.i);
vp.config.scrollstep = s->arg.i;
return TRUE;
}
+
+static gboolean setting_status_color_bg(const Setting* s)
+{
+ GdkColor color;
+
+ gdk_color_parse(s->arg.s, &color);
+ gtk_widget_modify_bg(vp.gui.eventbox, GTK_STATE_NORMAL, &color);
+ gtk_widget_modify_bg(GTK_WIDGET(vp.gui.statusbar.left), GTK_STATE_NORMAL, &color);
+ gtk_widget_modify_bg(GTK_WIDGET(vp.gui.statusbar.right), GTK_STATE_NORMAL, &color);
+
+ return TRUE;
+}
+
+static gboolean setting_status_color_fg(const Setting* s)
+{
+ GdkColor color;
+
+ gdk_color_parse(s->arg.s, &color);
+ gtk_widget_modify_fg(vp.gui.eventbox, GTK_STATE_NORMAL, &color);
+ gtk_widget_modify_fg(GTK_WIDGET(vp.gui.statusbar.left), GTK_STATE_NORMAL, &color);
+ gtk_widget_modify_fg(GTK_WIDGET(vp.gui.statusbar.right), GTK_STATE_NORMAL, &color);
+
+ return TRUE;
+}
+
+static gboolean setting_status_font(const Setting* s)
+{
+ if (vp.config.status_font) {
+ g_free(vp.config.status_font);
+ }
+ vp.config.status_font = g_strdup(s->arg.s);
+
+ /* update status bar to apply changed settings */
+ vp_update_statusbar();
+ vp_update_urlbar();
+
+ return TRUE;
+}
diff --git a/vimp_dbg b/vimp_dbg
new file mode 100755
index 0000000..2b0117b
--- /dev/null
+++ b/vimp_dbg
Binary files differ