Commit 1779ae79 authored by Emmanuele Bassi's avatar Emmanuele Bassi

rgba: Invert the arguments and improve bindability

Since parse() is a method of the Gdk.RGBA class, the GdkRGBA pointer
should be the first argument, and the string the second one, to allow a
more natural binding.

https://bugzilla.gnome.org/show_bug.cgi?id=635879
parent b0bf2b52
......@@ -115,8 +115,8 @@ parse_rgb_value (const char *str,
/**
* gdk_rgba_parse:
* @spec: the string specifying the color
* @rgba: the #GdkRGBA struct to fill in
* @spec: the string specifying the color
*
* Parses a textual representation of a color, filling in
* the <structfield>red</structfield>, <structfield>green</structfield>,
......@@ -150,8 +150,8 @@ parse_rgb_value (const char *str,
* Since: 3.0
**/
gboolean
gdk_rgba_parse (const gchar *spec,
GdkRGBA *rgba)
gdk_rgba_parse (GdkRGBA *rgba,
const gchar *spec)
{
gboolean has_alpha;
gdouble r, g, b, a;
......
......@@ -48,8 +48,8 @@ struct _GdkRGBA
GdkRGBA * gdk_rgba_copy (GdkRGBA *rgba);
void gdk_rgba_free (GdkRGBA *rgba);
gboolean gdk_rgba_parse (const gchar *spec,
GdkRGBA *rgba);
gboolean gdk_rgba_parse (GdkRGBA *rgba,
const gchar *spec);
guint gdk_rgba_hash (gconstpointer p);
gboolean gdk_rgba_equal (gconstpointer p1,
......
......@@ -8,17 +8,17 @@ test_color_parse (void)
GdkRGBA expected;
gboolean res;
res = gdk_rgba_parse ("foo", &color);
res = gdk_rgba_parse (&color, "foo");
g_assert (!res);
res = gdk_rgba_parse ("", &color);
res = gdk_rgba_parse (&color, "");
g_assert (!res);
expected.red = 100/255.;
expected.green = 90/255.;
expected.blue = 80/255.;
expected.alpha = 0.1;
res = gdk_rgba_parse ("rgba(100,90,80,0.1)", &color);
res = gdk_rgba_parse (&color, "rgba(100,90,80,0.1)");
g_assert (res);
g_assert (gdk_rgba_equal (&color, &expected));
......@@ -26,11 +26,11 @@ test_color_parse (void)
expected.green = 0.3;
expected.blue = 0.2;
expected.alpha = 0.1;
res = gdk_rgba_parse ("rgba(40%,30%,20%,0.1)", &color);
res = gdk_rgba_parse (&color, "rgba(40%,30%,20%,0.1)");
g_assert (res);
g_assert (gdk_rgba_equal (&color, &expected));
res = gdk_rgba_parse ("rgba( 40 % , 30 % , 20 % , 0.1 )", &color);
res = gdk_rgba_parse (&color, "rgba( 40 % , 30 % , 20 % , 0.1 )");
g_assert (res);
g_assert (gdk_rgba_equal (&color, &expected));
......@@ -38,7 +38,7 @@ test_color_parse (void)
expected.green = 0.0;
expected.blue = 0.0;
expected.alpha = 1.0;
res = gdk_rgba_parse ("red", &color);
res = gdk_rgba_parse (&color, "red");
g_assert (res);
g_assert (gdk_rgba_equal (&color, &expected));
......@@ -46,7 +46,7 @@ test_color_parse (void)
expected.green = 0x8080 / 65535.;
expected.blue = 1.0;
expected.alpha = 1.0;
res = gdk_rgba_parse ("#0080ff", &color);
res = gdk_rgba_parse (&color, "#0080ff");
g_assert (res);
g_assert (gdk_rgba_equal (&color, &expected));
}
......@@ -71,7 +71,7 @@ test_color_to_string (void)
orig = g_strdup (setlocale (LC_ALL, NULL));
res = gdk_rgba_to_string (&rgba);
gdk_rgba_parse (res, &out);
gdk_rgba_parse (&out, res);
g_assert (gdk_rgba_equal (&rgba, &out));
setlocale (LC_ALL, "de_DE.utf-8");
......
......@@ -1563,7 +1563,7 @@ gtk_builder_value_from_string_type (GtkBuilder *builder,
{
GdkRGBA rgba = { 0 };
if (gdk_rgba_parse (string, &rgba))
if (gdk_rgba_parse (&rgba, string))
g_value_set_boxed (value, &rgba);
else
{
......
......@@ -534,7 +534,7 @@ gtk_cell_renderer_set_property (GObject *object,
if (!g_value_get_string (value))
set_cell_bg_color (cell, NULL);
else if (gdk_rgba_parse (g_value_get_string (value), &rgba))
else if (gdk_rgba_parse (&rgba, g_value_get_string (value)))
set_cell_bg_color (cell, &rgba);
else
g_warning ("Don't know color `%s'", g_value_get_string (value));
......
......@@ -1193,7 +1193,7 @@ gtk_cell_renderer_text_set_property (GObject *object,
if (!g_value_get_string (value))
set_bg_color (celltext, NULL); /* reset to background_set to FALSE */
else if (gdk_rgba_parse (g_value_get_string (value), &rgba))
else if (gdk_rgba_parse (&rgba, g_value_get_string (value)))
set_bg_color (celltext, &rgba);
else
g_warning ("Don't know color `%s'", g_value_get_string (value));
......@@ -1208,7 +1208,7 @@ gtk_cell_renderer_text_set_property (GObject *object,
if (!g_value_get_string (value))
set_fg_color (celltext, NULL); /* reset to foreground_set to FALSE */
else if (gdk_rgba_parse (g_value_get_string (value), &rgba))
else if (gdk_rgba_parse (&rgba, g_value_get_string (value)))
set_fg_color (celltext, &rgba);
else
g_warning ("Don't know color `%s'", g_value_get_string (value));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment