treeview: Draw background when empty

We have a function we call for drawing the empty case, but
it only renders a focus rectangle. Make it draw the background
as well.

https://bugzilla.gnome.org/show_bug.cgi?id=761309
This commit is contained in:
Matthias Clasen 2016-01-30 18:31:30 -05:00
parent 16726e31f0
commit 7d16b8df29

View File

@ -4798,29 +4798,26 @@ invalidate_empty_focus (GtkTreeView *tree_view)
gdk_window_invalidate_rect (tree_view->priv->bin_window, &area, FALSE); gdk_window_invalidate_rect (tree_view->priv->bin_window, &area, FALSE);
} }
/* Draws a focus rectangle near the edge of the bin_window; used when the tree /* Draws background and a focus rectangle near the edge of the bin_window;
* is empty. * used when the tree is empty.
*/ */
static void static void
draw_empty_focus (GtkTreeView *tree_view, cairo_t *cr) draw_empty (GtkTreeView *tree_view,
cairo_t *cr)
{ {
GtkWidget *widget = GTK_WIDGET (tree_view); GtkWidget *widget = GTK_WIDGET (tree_view);
gint w, h; GtkStyleContext *context;
gint width, height;
if (!gtk_widget_has_visible_focus (widget)) context = gtk_widget_get_style_context (widget);
return;
w = gdk_window_get_width (tree_view->priv->bin_window) - 2; width = gdk_window_get_width (tree_view->priv->bin_window);
h = gdk_window_get_height (tree_view->priv->bin_window) - 2; height = gdk_window_get_height (tree_view->priv->bin_window);
if (w > 0 && h > 0) gtk_render_background (context, cr, 0, 0, width, height);
{
GtkStyleContext *context;
context = gtk_widget_get_style_context (widget); if (gtk_widget_has_visible_focus (widget))
gtk_render_focus (context, cr, 0, 0, width, height);
gtk_render_focus (context, cr, 1, 1, w, h);
}
} }
typedef enum { typedef enum {
@ -4988,7 +4985,7 @@ gtk_tree_view_bin_draw (GtkWidget *widget,
if (tree_view->priv->tree == NULL) if (tree_view->priv->tree == NULL)
{ {
draw_empty_focus (tree_view, cr); draw_empty (tree_view, cr);
return TRUE; return TRUE;
} }
@ -5617,6 +5614,7 @@ gtk_tree_view_draw (GtkWidget *widget,
gtk_cairo_should_draw_window (cr, tree_view->priv->drag_highlight_window)) gtk_cairo_should_draw_window (cr, tree_view->priv->drag_highlight_window))
{ {
GdkRGBA color; GdkRGBA color;
gtk_style_context_get_color (context, gtk_style_context_get_state (context), &color); gtk_style_context_get_color (context, gtk_style_context_get_state (context), &color);
cairo_save (cr); cairo_save (cr);
gtk_cairo_transform_to_window (cr, GTK_WIDGET (tree_view), tree_view->priv->drag_highlight_window); gtk_cairo_transform_to_window (cr, GTK_WIDGET (tree_view), tree_view->priv->drag_highlight_window);