[gtk+] rgba: Invert the arguments and improve bindability
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] rgba: Invert the arguments and improve bindability
- Date: Sun, 28 Nov 2010 21:16:46 +0000 (UTC)
commit 1779ae79a13029a4efb77b2ab4b39393a3a9c9b8
Author: Emmanuele Bassi <ebassi linux intel com>
Date: Sun Nov 28 18:49:47 2010 +0000
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
gdk/gdkrgba.c | 6 +++---
gdk/gdkrgba.h | 4 ++--
gdk/tests/gdk-color.c | 16 ++++++++--------
gtk/gtkbuilder.c | 2 +-
gtk/gtkcellrenderer.c | 2 +-
gtk/gtkcellrenderertext.c | 4 ++--
6 files changed, 17 insertions(+), 17 deletions(-)
---
diff --git a/gdk/gdkrgba.c b/gdk/gdkrgba.c
index 732cf99..c2cf2fc 100644
--- a/gdk/gdkrgba.c
+++ b/gdk/gdkrgba.c
@@ -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;
diff --git a/gdk/gdkrgba.h b/gdk/gdkrgba.h
index 9875d10..2b76704 100644
--- a/gdk/gdkrgba.h
+++ b/gdk/gdkrgba.h
@@ -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,
diff --git a/gdk/tests/gdk-color.c b/gdk/tests/gdk-color.c
index 2dbe2ad..008f425 100644
--- a/gdk/tests/gdk-color.c
+++ b/gdk/tests/gdk-color.c
@@ -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");
diff --git a/gtk/gtkbuilder.c b/gtk/gtkbuilder.c
index 7ed026c..97b0053 100644
--- a/gtk/gtkbuilder.c
+++ b/gtk/gtkbuilder.c
@@ -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
{
diff --git a/gtk/gtkcellrenderer.c b/gtk/gtkcellrenderer.c
index fe8a67b..e05ec4c 100644
--- a/gtk/gtkcellrenderer.c
+++ b/gtk/gtkcellrenderer.c
@@ -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));
diff --git a/gtk/gtkcellrenderertext.c b/gtk/gtkcellrenderertext.c
index a93f16c..cf58d4d 100644
--- a/gtk/gtkcellrenderertext.c
+++ b/gtk/gtkcellrenderertext.c
@@ -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));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]