Use pointer to char for the hint colors too.
authorDaniel Carl <danielcarl@gmx.de>
Sat, 5 Jan 2013 14:19:23 +0000 (15:19 +0100)
committerDaniel Carl <danielcarl@gmx.de>
Sat, 5 Jan 2013 14:23:33 +0000 (15:23 +0100)
src/main.h
src/setting.c

index 2ce3bee..54bf697 100644 (file)
@@ -74,8 +74,6 @@
 #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,
@@ -242,9 +240,9 @@ typedef struct {
     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];
+    gchar*                hint_bg;
+    gchar*                hint_bg_focus;
+    gchar*                hint_fg;
     gchar*                hint_style;
     /* status bar */
     VpColor               status_bg[VP_STATUS_LAST];
index 65f2329..36621e6 100644 (file)
@@ -85,7 +85,6 @@ static Setting default_settings[] = {
     {NULL, "cookie-timeout", TYPE_INTEGER, setting_cookie_timeout, {.i = 4800}},
     {NULL, "scrollstep", TYPE_INTEGER, setting_scrollstep, {.i = 40}},
 
-    /* TODO set type to color */
     {NULL, "status-color-bg", TYPE_CHAR, setting_status_color_bg, {.s = "#000"}},
     {NULL, "status-color-fg", TYPE_CHAR, setting_status_color_fg, {.s = "#fff"}},
     {NULL, "status-font", TYPE_FONT, setting_status_font, {.s = "monospace bold 8"}},
@@ -491,24 +490,21 @@ static gboolean setting_hint_style(const Setting* s, const gboolean get)
         if (get) {
             setting_print_value(s, style->hint_bg);
         } else {
-            strncpy(style->hint_bg, s->arg.s, HEX_COLOR_LEN - 1);
-            style->hint_bg[HEX_COLOR_LEN - 1] = '\0';
+            OVERWRITE_STRING(style->hint_bg, s->arg.s)
         }
     } else if (!g_strcmp0(s->name, "hint-bg-focus")) {
         if (get) {
             setting_print_value(s, style->hint_bg_focus);
         } else {
-            strncpy(style->hint_bg_focus, s->arg.s, HEX_COLOR_LEN - 1);
-            style->hint_bg_focus[HEX_COLOR_LEN - 1] = '\0';
+            OVERWRITE_STRING(style->hint_bg_focus, s->arg.s)
         }
     } else if (!g_strcmp0(s->name, "hint-fg")) {
         if (get) {
-            setting_print_value(s, style->hint_bg_focus);
+            setting_print_value(s, style->hint_fg);
         } else {
-            strncpy(style->hint_fg, s->arg.s, HEX_COLOR_LEN - 1);
-            style->hint_fg[HEX_COLOR_LEN - 1] = '\0';
+            OVERWRITE_STRING(style->hint_fg, s->arg.s)
         }
-    } else if (!g_strcmp0(s->name, "hint-style")) {
+    } else {
         if (get) {
             setting_print_value(s, style->hint_style);
         } else {