pidgin: Fix GdkColor vs GdkRGBA -Wincompatible-pointer-types warnings

Mon, 05 Nov 2018 17:01:57 -0600

author
Mike Ruprecht <cmaiku@gmail.com>
date
Mon, 05 Nov 2018 17:01:57 -0600
changeset 39277
68c17ba18f33
parent 39276
89f307c3aa27
child 39278
4ada2c1d4c50

pidgin: Fix GdkColor vs GdkRGBA -Wincompatible-pointer-types warnings

Most of the instances which call pidgin_style_adjust_contrast() pass
it a GdkRGBA pointer. The function expects a GdkColor pointer. This
patch ports it to instead accept a GdkRGBA pointer, which consequently
simplifies it somewhat.

pidgin/gtkconv.c file | annotate | diff | comparison | revisions
pidgin/gtkstyle.c file | annotate | diff | comparison | revisions
pidgin/gtkstyle.h file | annotate | diff | comparison | revisions
--- a/pidgin/gtkconv.c	Mon Nov 05 17:01:29 2018 -0600
+++ b/pidgin/gtkconv.c	Mon Nov 05 17:01:57 2018 -0600
@@ -8876,17 +8876,21 @@
 		now = gtk_rc_get_style_by_paths(settings, styles[iter].labelname, NULL, G_TYPE_NONE);
 		if (parent == now ||
 				(parent && now && parent->rc_style == now->rc_style)) {
-			GdkColor color;
-			gdk_color_parse(styles[iter].color, &color);
+			GdkRGBA color;
+			gchar *color_str;
+
+			gdk_rgba_parse(&color, styles[iter].color);
 			pidgin_style_adjust_contrast(gtk_widget_get_default_style(), &color);
 
+			color_str = gdk_rgba_to_string(&color);
 			g_string_append_printf(str, "style \"%s\" {\n"
 					"fg[ACTIVE] = \"%s\"\n"
 					"}\n"
 					"widget \"*%s\" style \"%s\"\n",
 					styles[iter].stylename,
-					gdk_color_to_string(&color),
+					color_str,
 					styles[iter].labelname, styles[iter].stylename);
+			g_free(color_str);
 		}
 	}
 	gtk_rc_parse_string(str->str);
--- a/pidgin/gtkstyle.c	Mon Nov 05 17:01:29 2018 -0600
+++ b/pidgin/gtkstyle.c	Mon Nov 05 17:01:57 2018 -0600
@@ -47,24 +47,16 @@
 }
 
 void
-pidgin_style_adjust_contrast(GtkStyle *style, GdkColor *color) {
+pidgin_style_adjust_contrast(GtkStyle *style, GdkRGBA *rgba) {
 	if (pidgin_style_is_dark(style)) {
-		gdouble r, g, b, h, s, v;
+		gdouble h, s, v;
 
-		r = ((gdouble) color->red) / 65535.0;
-		g = ((gdouble) color->green) / 65535.0;
-		b = ((gdouble) color->blue) / 65535.0;
-
-		gtk_rgb_to_hsv(r, g, b, &h, &s, &v);
+		gtk_rgb_to_hsv(rgba->red, rgba->green, rgba->blue, &h, &s, &v);
 
 		v += 0.3;
 		v = v > 1.0 ? 1.0 : v;
 		s = 0.7;
 
-		gtk_hsv_to_rgb(h, s, v, &r, &g, &b);
-
-		color->red = (guint16) (r * 65535.0);
-		color->green = (guint16) (g * 65535.0);
-		color->blue = (guint16) (b * 65535.0);
+		gtk_hsv_to_rgb(h, s, v, &rgba->red, &rgba->green, &rgba->blue);
 	}
 }
--- a/pidgin/gtkstyle.h	Mon Nov 05 17:01:29 2018 -0600
+++ b/pidgin/gtkstyle.h	Mon Nov 05 17:01:57 2018 -0600
@@ -52,7 +52,7 @@
  * Lighten a color if dark mode is enabled.
  */
 
-void pidgin_style_adjust_contrast(GtkStyle *style, GdkColor *color);
+void pidgin_style_adjust_contrast(GtkStyle *style, GdkRGBA *color);
 
 G_END_DECLS
 

mercurial