* src/prefs_gtk.[ch]
authorAlfons Hoogervorst <alfons@proteus.demon.nl>
Wed, 19 Feb 2003 21:46:30 +0000 (21:46 +0000)
committerAlfons Hoogervorst <alfons@proteus.demon.nl>
Wed, 19 Feb 2003 21:46:30 +0000 (21:46 +0000)
* src/prefs_common.c
for color_new accept both plain integers and X11 style color
names (as found in /usr/lib/X11/rgb.txt

ChangeLog.claws
configure.ac
src/prefs_common.c
src/prefs_gtk.c
src/prefs_gtk.h

index 08a3d61..d4888a9 100644 (file)
@@ -1,3 +1,10 @@
+2003-02-19 [alfons]    0.8.10claws30
+
+       * src/prefs_gtk.[ch]
+       * src/prefs_common.c
+               for color_new accept both plain integers and X11 style color
+               names (as found in /usr/lib/X11/rgb.txt)
+
 2003-02-19 [paul]      0.8.10claws29
 
        * src/mainwindow.c
index 8e1dbb1..09f68c6 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=10
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws29
+EXTRA_VERSION=claws30
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 4a1579c..fc318a0 100644 (file)
@@ -829,7 +829,7 @@ static PrefParam param[] = {
        {"cache_min_keep_time", "15", &prefs_common.cache_min_keep_time, P_INT,
         NULL, NULL, NULL},
 
-       {"color_new", "179", &prefs_common.color_new, P_INT,
+       {"color_new", "179", &prefs_common.color_new, P_COLOR,
         NULL, NULL, NULL},
 
        {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
index 98d232f..51ac173 100644 (file)
 #include "utils.h"
 #include "gtkutils.h"
 
+#define CL(x)  (((gulong) (x) >> (gulong) 8) & 0xFFUL)
+#define RGB_FROM_GDK_COLOR(c) \
+       ((CL(c.red)   << (gulong) 16) | \
+        (CL(c.green) << (gulong)  8) | \
+        (CL(c.blue)))
+
 typedef enum
 {
        DUMMY_PARAM
@@ -95,6 +101,7 @@ void prefs_config_parse_one_line(PrefParam *param, const gchar *buf)
        gint i;
        gint name_len;
        const gchar *value;
+       GdkColor color;
 
        for (i = 0; param[i].name != NULL; i++) {
                name_len = strlen(param[i].name);
@@ -128,6 +135,13 @@ void prefs_config_parse_one_line(PrefParam *param, const gchar *buf)
                        *((gushort *)param[i].data) =
                                (gushort)atoi(value);
                        break;
+               case P_COLOR:
+                       if (gdk_color_parse(value, &color)) 
+                               *((gulong *)param[i].data) = RGB_FROM_GDK_COLOR(color); 
+                       else 
+                               /* be compatible and accept ints */
+                               *((gulong *)param[i].data) = strtoul(value, 0, 10); 
+                       break;
                default:
                        break;
                }
@@ -244,6 +258,10 @@ gint prefs_write_param(PrefParam *param, FILE *fp)
                        g_snprintf(buf, sizeof(buf), "%s=%d\n", param[i].name,
                                   *((gushort *)param[i].data));
                        break;
+               case P_COLOR:
+                       g_snprintf(buf, sizeof buf,  "%s=#%6.6lx\n", param[i].name,
+                                  *((gulong *) param[i].data));
+                       break;
                default:
                        buf[0] = '\0';
                }
@@ -262,6 +280,7 @@ gint prefs_write_param(PrefParam *param, FILE *fp)
 void prefs_set_default(PrefParam *param)
 {
        gint i;
+       GdkColor color;
 
        g_return_if_fail(param != NULL);
 
@@ -318,6 +337,16 @@ void prefs_set_default(PrefParam *param)
                        else
                                *((gushort *)param[i].data) = 0;
                        break;
+               case P_COLOR:
+                       if (param[i].defval != NULL && gdk_color_parse(param[i].defval, &color))
+                               *((gulong *)param[i].data) =
+                                       RGB_FROM_GDK_COLOR(color);
+                       else if (param[i].defval)
+                               /* be compatible and accept ints */
+                               *((gulong *)param[i].data) = strtoul(param[i].defval, 0, 10); 
+                       else
+                               *((gulong *)param[i].data) = 0; 
+                       break;
                default:
                        break;
                }
@@ -494,6 +523,7 @@ void prefs_set_dialog_to_default(PrefParam *param)
                        tmpparam.data = &enum_data;
                        break;
                case P_OTHER:
+               default:
                        break;
                }
                tmpparam.widget_set_func(&tmpparam);
@@ -505,6 +535,7 @@ void prefs_set_dialog_to_default(PrefParam *param)
 void prefs_set_data_from_entry(PrefParam *pparam)
 {
        gchar **str, *entry_str;
+       GdkColor color;
 
        g_return_if_fail(*pparam->widget != NULL);
 
index 9d0c4ea..4daf0e8 100644 (file)
@@ -50,6 +50,7 @@ typedef enum
        P_BOOL,
        P_ENUM,
        P_USHORT,
+       P_COLOR,
        P_OTHER
 } PrefType;