[gtk+/parser] symboliccolor: Allow props == NULL when resolving
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/parser] symboliccolor: Allow props == NULL when resolving
- Date: Wed, 18 May 2011 16:43:59 +0000 (UTC)
commit e7bcd307148dd43227e622d327dd251ae0d81c1a
Author: Benjamin Otte <otte redhat com>
Date: Wed May 18 12:58:11 2011 +0200
symboliccolor: Allow props == NULL when resolving
If props == NULL in gtk_symbolic_color_resolve(), fail sanely for named
colors. The docs used to say it was not allowed to pass NULL for named
color, but that had problems:
1) You do not know if a color was created that way. This is especially
hard for generic users (like language bindings).
2) It wasn't even true. Colors using other symbolic colors would also
fail when trying to resolve their named colors, but the docs didn't
say so.
And because I want to use the function to resolve static colors early
where possible, I changed things.
gtk/gtksymboliccolor.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtksymboliccolor.c b/gtk/gtksymboliccolor.c
index a359fe1..d99aa13 100644
--- a/gtk/gtksymboliccolor.c
+++ b/gtk/gtksymboliccolor.c
@@ -474,8 +474,9 @@ _shade_color (GdkRGBA *color,
* if @color can't be resolved, it is due to it being defined on
* top of a named color that doesn't exist in @props.
*
- * @props must be non-%NULL if @color was created using
- * gtk_symbolic_color_named_new(), but can be omitted in other cases.
+ * When @props is %NULL, resolving of named colors will fail, so if
+ * your @color is or references such a color, this function will
+ * return %FALSE.
*
* Returns: %TRUE if the color has been resolved
*
@@ -488,6 +489,7 @@ gtk_symbolic_color_resolve (GtkSymbolicColor *color,
{
g_return_val_if_fail (color != NULL, FALSE);
g_return_val_if_fail (resolved_color != NULL, FALSE);
+ g_return_val_if_fail (props == NULL || GTK_IS_STYLE_PROPERTIES (props), FALSE);
switch (color->type)
{
@@ -498,7 +500,8 @@ gtk_symbolic_color_resolve (GtkSymbolicColor *color,
{
GtkSymbolicColor *named_color;
- g_return_val_if_fail (GTK_IS_STYLE_PROPERTIES (props), FALSE);
+ if (props == NULL)
+ return FALSE;
named_color = gtk_style_properties_lookup_color (props, color->name);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]