Update gtkstyle.c to account for removal of row-ending-details

The detail strings now have more "detail" by default, so gtkstyle.c
needed to be updated to properly handle this.  Tests like testtreeview,
testtreesort now have proper background drawing again.

This strncmp trick was the best I could think of so quickly, if anybody
has an idea to do this in a better way, let me know.
This commit is contained in:
Kristian Rietveld 2010-09-13 17:13:21 +02:00
parent ecaa37529c
commit a79d6676ac

View File

@ -2712,14 +2712,26 @@ gtk_default_draw_flat_box (GtkStyle *style,
if (detail) if (detail)
{ {
int trimmed_len = strlen (detail);
if (g_str_has_prefix (detail, "cell_"))
{
if (g_str_has_suffix (detail, "_start"))
trimmed_len -= 6;
else if (g_str_has_suffix (detail, "_middle"))
trimmed_len -= 7;
else if (g_str_has_suffix (detail, "_end"))
trimmed_len -= 4;
}
if (state_type == GTK_STATE_SELECTED) if (state_type == GTK_STATE_SELECTED)
{ {
if (!strcmp ("text", detail)) if (!strcmp ("text", detail))
gc1 = &style->bg[GTK_STATE_SELECTED]; gc1 = &style->bg[GTK_STATE_SELECTED];
else if (!strcmp ("cell_even", detail) || else if (!strncmp ("cell_even", detail, trimmed_len) ||
!strcmp ("cell_odd", detail) || !strncmp ("cell_odd", detail, trimmed_len) ||
!strcmp ("cell_even_ruled", detail) || !strncmp ("cell_even_ruled", detail, trimmed_len) ||
!strcmp ("cell_even_ruled_sorted", detail)) !strncmp ("cell_even_ruled_sorted", detail, trimmed_len))
{ {
/* This has to be really broken; alex made me do it. -jrb */ /* This has to be really broken; alex made me do it. -jrb */
if (widget && gtk_widget_has_focus (widget)) if (widget && gtk_widget_has_focus (widget))
@ -2727,8 +2739,8 @@ gtk_default_draw_flat_box (GtkStyle *style,
else else
gc1 = &style->base[GTK_STATE_ACTIVE]; gc1 = &style->base[GTK_STATE_ACTIVE];
} }
else if (!strcmp ("cell_odd_ruled", detail) || else if (!strncmp ("cell_odd_ruled", detail, trimmed_len) ||
!strcmp ("cell_odd_ruled_sorted", detail)) !strncmp ("cell_odd_ruled_sorted", detail, trimmed_len))
{ {
if (widget && gtk_widget_has_focus (widget)) if (widget && gtk_widget_has_focus (widget))
freeme = get_darkened (&style->base[state_type], 1); freeme = get_darkened (&style->base[state_type], 1);
@ -2753,9 +2765,9 @@ gtk_default_draw_flat_box (GtkStyle *style,
* for that row. * for that row.
*/ */
else if (!strcmp ("cell_even", detail) || else if (!strncmp ("cell_even", detail, trimmed_len) ||
!strcmp ("cell_odd", detail) || !strncmp ("cell_odd", detail, trimmed_len) ||
!strcmp ("cell_even_ruled", detail)) !strncmp ("cell_even_ruled", detail, trimmed_len))
{ {
GdkColor *color = NULL; GdkColor *color = NULL;
@ -2773,7 +2785,7 @@ gtk_default_draw_flat_box (GtkStyle *style,
else else
gc1 = &style->base[state_type]; gc1 = &style->base[state_type];
} }
else if (!strcmp ("cell_odd_ruled", detail)) else if (!strncmp ("cell_odd_ruled", detail, trimmed_len))
{ {
GdkColor *color = NULL; GdkColor *color = NULL;
@ -2804,13 +2816,13 @@ gtk_default_draw_flat_box (GtkStyle *style,
gc1 = freeme; gc1 = freeme;
} }
} }
else if (!strcmp ("cell_even_sorted", detail) || else if (!strncmp ("cell_even_sorted", detail, trimmed_len) ||
!strcmp ("cell_odd_sorted", detail) || !strncmp ("cell_odd_sorted", detail, trimmed_len) ||
!strcmp ("cell_even_ruled_sorted", detail)) !strncmp ("cell_even_ruled_sorted", detail, trimmed_len))
{ {
GdkColor *color = NULL; GdkColor *color = NULL;
if (!strcmp ("cell_odd_sorted", detail)) if (!strncmp ("cell_odd_sorted", detail, trimmed_len))
gtk_widget_style_get (widget, gtk_widget_style_get (widget,
"odd-row-color", &color, "odd-row-color", &color,
NULL); NULL);
@ -2832,7 +2844,7 @@ gtk_default_draw_flat_box (GtkStyle *style,
gc1 = freeme; gc1 = freeme;
} }
} }
else if (!strcmp ("cell_odd_ruled_sorted", detail)) else if (!strncmp ("cell_odd_ruled_sorted", detail, trimmed_len))
{ {
GdkColor *color = NULL; GdkColor *color = NULL;