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.
This commit is contained in:
Benjamin Otte
2011-05-18 12:58:11 +02:00
parent 8111d99183
commit 9e18d8b448

View File

@ -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);