Support resetting cell renderer colors with NULL again

This functionality was lost when GdkRGBA was introduced.

Bug 632936
This commit is contained in:
Matthias Clasen 2010-10-25 11:17:24 -04:00
parent 546be63ecc
commit 503698f587
2 changed files with 52 additions and 26 deletions

View File

@ -493,28 +493,36 @@ gtk_cell_renderer_set_property (GObject *object,
{
GdkRGBA rgba;
if (!g_value_get_string (value))
set_cell_bg_color (cell, NULL);
else if (gdk_rgba_parse (g_value_get_string (value), &rgba))
set_cell_bg_color (cell, &rgba);
else
g_warning ("Don't know color `%s'", g_value_get_string (value));
if (!g_value_get_string (value))
set_cell_bg_color (cell, NULL);
else if (gdk_rgba_parse (g_value_get_string (value), &rgba))
set_cell_bg_color (cell, &rgba);
else
g_warning ("Don't know color `%s'", g_value_get_string (value));
g_object_notify (object, "cell-background-gdk");
g_object_notify (object, "cell-background-gdk");
}
break;
case PROP_CELL_BACKGROUND_GDK:
{
GdkColor *color;
GdkRGBA rgba;
color = g_value_get_boxed (value);
rgba.red = color->red / 65535.;
rgba.green = color->green / 65535.;
rgba.blue = color->blue / 65535.;
rgba.alpha = 1;
if (color)
{
GdkRGBA rgba;
set_cell_bg_color (cell, &rgba);
rgba.red = color->red / 65535.;
rgba.green = color->green / 65535.;
rgba.blue = color->blue / 65535.;
rgba.alpha = 1;
set_cell_bg_color (cell, &rgba);
}
else
{
set_cell_bg_color (cell, NULL);
}
}
break;
case PROP_CELL_BACKGROUND_RGBA:
@ -539,9 +547,9 @@ set_cell_bg_color (GtkCellRenderer *cell,
{
if (!priv->cell_background_set)
{
priv->cell_background_set = TRUE;
g_object_notify (G_OBJECT (cell), "cell-background-set");
}
priv->cell_background_set = TRUE;
g_object_notify (G_OBJECT (cell), "cell-background-set");
}
priv->cell_background = *rgba;
}

View File

@ -1206,28 +1206,46 @@ gtk_cell_renderer_text_set_property (GObject *object,
case PROP_BACKGROUND_GDK:
{
GdkColor *color;
GdkRGBA rgba;
color = g_value_get_boxed (value);
rgba.red = color->red / 65535.;
rgba.green = color->green / 65535.;
rgba.blue = color->blue / 65535.;
if (color)
{
GdkRGBA rgba;
set_bg_color (celltext, &rgba);
rgba.red = color->red / 65535.;
rgba.green = color->green / 65535.;
rgba.blue = color->blue / 65535.;
rgba.alpha = 1;
set_bg_color (celltext, &rgba);
}
else
{
set_bg_color (celltext, NULL);
}
}
break;
case PROP_FOREGROUND_GDK:
{
GdkColor *color;
GdkRGBA rgba;
color = g_value_get_boxed (value);
rgba.red = color->red / 65535.;
rgba.green = color->green / 65535.;
rgba.blue = color->blue / 65535.;
if (color)
{
GdkRGBA rgba;
set_fg_color (celltext, &rgba);
rgba.red = color->red / 65535.;
rgba.green = color->green / 65535.;
rgba.blue = color->blue / 65535.;
rgba.alpha = 1;
set_fg_color (celltext, &rgba);
}
else
{
set_fg_color (celltext, NULL);
}
}
break;