treeview: use gtk_tree_view_ensure_background() consistently

In gtk_tree_view_state_flags_changed() we were setting the background on
the bin_window without the necessary "view" style class, making the
treeview render with the wrong color in some circumstances (such as when
adding an empty treeview in a window, as spotted by Brian Smith).
This commit is contained in:
Cosimo Cecchi 2011-11-16 16:01:36 -05:00
parent 8d97d8ca3c
commit 9986b26c0b

View File

@ -2199,7 +2199,6 @@ static void
gtk_tree_view_realize (GtkWidget *widget) gtk_tree_view_realize (GtkWidget *widget)
{ {
GtkAllocation allocation; GtkAllocation allocation;
GtkStyleContext *context;
GtkTreeView *tree_view = GTK_TREE_VIEW (widget); GtkTreeView *tree_view = GTK_TREE_VIEW (widget);
GdkWindow *window; GdkWindow *window;
GdkWindowAttr attributes; GdkWindowAttr attributes;
@ -2268,14 +2267,7 @@ gtk_tree_view_realize (GtkWidget *widget)
&attributes, attributes_mask); &attributes, attributes_mask);
gdk_window_set_user_data (tree_view->priv->header_window, widget); gdk_window_set_user_data (tree_view->priv->header_window, widget);
context = gtk_widget_get_style_context (widget); gtk_tree_view_ensure_background (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_restore (context);
gtk_style_context_set_background (context, tree_view->priv->header_window);
tmp_list = tree_view->priv->children; tmp_list = tree_view->priv->children;
while (tmp_list) while (tmp_list)
@ -8479,16 +8471,7 @@ gtk_tree_view_style_updated (GtkWidget *widget)
if (gtk_widget_get_realized (widget)) if (gtk_widget_get_realized (widget))
{ {
GtkStyleContext *context; gtk_tree_view_ensure_background (tree_view);
context = gtk_widget_get_style_context (widget);
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_restore (context);
gtk_style_context_set_background (context, tree_view->priv->header_window);
gtk_tree_view_set_grid_lines (tree_view, tree_view->priv->grid_lines); gtk_tree_view_set_grid_lines (tree_view, tree_view->priv->grid_lines);
gtk_tree_view_set_enable_tree_lines (tree_view, tree_view->priv->tree_lines_enabled); gtk_tree_view_set_enable_tree_lines (tree_view, tree_view->priv->tree_lines_enabled);
@ -15922,13 +15905,7 @@ gtk_tree_view_state_flags_changed (GtkWidget *widget,
GtkStateFlags previous_state) GtkStateFlags previous_state)
{ {
if (gtk_widget_get_realized (widget)) if (gtk_widget_get_realized (widget))
{ gtk_tree_view_ensure_background (GTK_TREE_VIEW (widget));
GtkTreeView *tree_view = GTK_TREE_VIEW (widget);
GtkStyleContext *context;
context = gtk_widget_get_style_context (widget);
gtk_style_context_set_background (context, tree_view->priv->bin_window);
}
gtk_widget_queue_draw (widget); gtk_widget_queue_draw (widget);
} }