tree-view: don't use gtk_style_context_set_background()

Render a background with gtk_render_background() in draw() instead.
Note that we still use gtk_style_context_set_background() for the header
window.

https://bugzilla.gnome.org/show_bug.cgi?id=688744
This commit is contained in:
Cosimo Cecchi 2012-11-20 12:43:37 -05:00
parent da09447914
commit ddceddaa84

View File

@ -1768,6 +1768,9 @@ gtk_tree_view_init (GtkTreeView *tree_view)
gtk_tree_view_do_set_vadjustment (tree_view, NULL); gtk_tree_view_do_set_vadjustment (tree_view, NULL);
gtk_tree_view_do_set_hadjustment (tree_view, NULL); gtk_tree_view_do_set_hadjustment (tree_view, NULL);
gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (tree_view)),
GTK_STYLE_CLASS_VIEW);
} }
@ -2190,13 +2193,6 @@ gtk_tree_view_ensure_background (GtkTreeView *tree_view)
GtkStyleContext *context; GtkStyleContext *context;
context = gtk_widget_get_style_context (GTK_WIDGET (tree_view)); context = gtk_widget_get_style_context (GTK_WIDGET (tree_view));
gtk_style_context_save (context);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_VIEW);
gtk_style_context_set_background (context, tree_view->priv->bin_window);
gtk_style_context_set_background (context, gtk_widget_get_window (GTK_WIDGET (tree_view)));
gtk_style_context_restore (context);
gtk_style_context_set_background (context, tree_view->priv->header_window); gtk_style_context_set_background (context, tree_view->priv->header_window);
} }
@ -5349,24 +5345,23 @@ gtk_tree_view_draw (GtkWidget *widget,
{ {
GtkTreeView *tree_view = GTK_TREE_VIEW (widget); GtkTreeView *tree_view = GTK_TREE_VIEW (widget);
GtkWidget *button; GtkWidget *button;
GtkStyleContext *context;
context = gtk_widget_get_style_context (widget);
gtk_render_background (context, cr,
0, 0,
gtk_widget_get_allocated_width (widget),
gtk_widget_get_allocated_height (widget));
if (gtk_cairo_should_draw_window (cr, tree_view->priv->bin_window)) if (gtk_cairo_should_draw_window (cr, tree_view->priv->bin_window))
{ {
GtkStyleContext *context;
GList *tmp_list; GList *tmp_list;
context = gtk_widget_get_style_context (widget);
cairo_save (cr); cairo_save (cr);
gtk_style_context_save (context);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_VIEW);
gtk_cairo_transform_to_window (cr, widget, tree_view->priv->bin_window); gtk_cairo_transform_to_window (cr, widget, tree_view->priv->bin_window);
gtk_tree_view_bin_draw (widget, cr); gtk_tree_view_bin_draw (widget, cr);
gtk_style_context_restore (context);
cairo_restore (cr); cairo_restore (cr);
/* We can't just chain up to Container::draw as it will try to send the /* We can't just chain up to Container::draw as it will try to send the
@ -5383,6 +5378,9 @@ gtk_tree_view_draw (GtkWidget *widget,
} }
} }
gtk_style_context_save (context);
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_VIEW);
if (gtk_cairo_should_draw_window (cr, tree_view->priv->header_window)) if (gtk_cairo_should_draw_window (cr, tree_view->priv->header_window))
{ {
GList *list; GList *list;
@ -5411,6 +5409,8 @@ gtk_tree_view_draw (GtkWidget *widget,
button, cr); button, cr);
} }
gtk_style_context_restore (context);
return FALSE; return FALSE;
} }
@ -14564,8 +14564,6 @@ gtk_tree_view_create_row_drag_icon (GtkTreeView *tree_view,
context = gtk_widget_get_style_context (widget); context = gtk_widget_get_style_context (widget);
gtk_style_context_save (context); gtk_style_context_save (context);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_VIEW);
gtk_style_context_add_region (context, GTK_STYLE_REGION_COLUMN, 0); gtk_style_context_add_region (context, GTK_STYLE_REGION_COLUMN, 0);
gtk_widget_style_get (widget, gtk_widget_style_get (widget,