[Commits] [SCM] claws branch, gtk3, updated. 3.16.0-458-g1352e3c

ticho at claws-mail.org ticho at claws-mail.org
Mon Nov 5 21:02:52 CET 2018


The branch, gtk3 has been updated
       via  1352e3c210ccb913eaa19930d16c03aac0000320 (commit)
      from  3d616afd6dcf638ab0bb1634f53f573e8b72df78 (commit)

Summary of changes:
 src/prefs_gtk.c |   27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)


- Log -----------------------------------------------------------------
commit 1352e3c210ccb913eaa19930d16c03aac0000320
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Mon Nov 5 20:59:55 2018 +0100

    Correctly convert integers as P_COLOR prefs for backwards compatibility.

diff --git a/src/prefs_gtk.c b/src/prefs_gtk.c
index 3d8a63f..4efdc58 100644
--- a/src/prefs_gtk.c
+++ b/src/prefs_gtk.c
@@ -49,6 +49,13 @@
 	 (CL(c.green) << (gulong)  8) | \
 	 (CL(c.blue)))
 
+/* Kept for backwards compatibility */
+#define INTCOLOR_TO_GDKRGBA(intcolor, rgba) \
+	rgba.red   = (gdouble)(((intcolor >> 16UL) & 0xFFUL) << 8UL) / 65535; \
+	rgba.green = (gdouble)(((intcolor >>  8UL) & 0xFFUL) << 8UL) / 65535; \
+	rgba.blue  = (gdouble)(((intcolor        ) & 0xFFUL) << 8UL) / 65535;
+
+
 typedef enum
 {
 	DUMMY_PARAM
@@ -197,12 +204,11 @@ static void prefs_config_parse_one_line(PrefParam *param, const gchar *buf)
 				(gushort)atoi(value);
 			break;
 		case P_COLOR:
-			if (gdk_rgba_parse(&color, value)) {
-				*((GdkRGBA *)param[i].data) = color;
-			}
-			else 
+			if (!gdk_rgba_parse(&color, value)) {
 				/* be compatible and accept ints */
-				*((gulong *)param[i].data) = strtoul(value, 0, 10); 
+				INTCOLOR_TO_GDKRGBA(strtoul(value, 0, 10), color);
+			}
+			*((GdkRGBA *)param[i].data) = color;
 			break;
 		default:
 			break;
@@ -459,11 +465,14 @@ void prefs_set_default(PrefParam *param)
 		case P_COLOR:
 			if (param[i].defval != NULL && gdk_rgba_parse(&color, param[i].defval))
 				*((GdkRGBA *)param[i].data) = color;
-			else if (param[i].defval)
+			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; 
+				INTCOLOR_TO_GDKRGBA(strtoul(param[i].defval, 0, 10), color);
+				*((GdkRGBA *)param[i].data) = color;
+			} else {
+				color.red = color.green = color.blue = 0; color.alpha = 1;
+				*((GdkRGBA *)param[i].data) = color;
+			}
 			break;
 		default:
 			break;

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list