summaryrefslogtreecommitdiff
path: root/gtk/gtktextdisplay.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2015-11-10 21:18:10 -0500
committerMatthias Clasen <mclasen@redhat.com>2015-11-10 21:18:10 -0500
commitbb786ac2404e99bfd14097006724dde177e0220d (patch)
tree0b872e1f38cce006299a456dfa03218d10e1ea42 /gtk/gtktextdisplay.c
parent735a71da112cbf3cc6ae0cce8ea2147db510d109 (diff)
downloadgtk+-bb786ac2404e99bfd14097006724dde177e0220d.tar.gz
textview: Use a CSS node for selection rendering
Use a CSS node with name selection, like we do for entries and labels. Unlike those widgets, we currently don't user gtk_render_background, but just use the background color. That will require more effort.
Diffstat (limited to 'gtk/gtktextdisplay.c')
-rw-r--r--gtk/gtktextdisplay.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/gtk/gtktextdisplay.c b/gtk/gtktextdisplay.c
index 6b5dbf4190..24372d2bd8 100644
--- a/gtk/gtktextdisplay.c
+++ b/gtk/gtktextdisplay.c
@@ -596,6 +596,8 @@ get_selected_clip (GtkTextRenderer *text_renderer,
return clip_region;
}
+extern GtkCssNode *gtk_text_view_get_selection_node (GtkTextView *text_view);
+
static void
render_para (GtkTextRenderer *text_renderer,
GtkTextLineDisplay *line_display,
@@ -603,7 +605,6 @@ render_para (GtkTextRenderer *text_renderer,
int selection_end_index)
{
GtkStyleContext *context;
- GtkStateFlags state;
PangoLayout *layout = line_display->layout;
int byte_offset = 0;
PangoLayoutIter *iter;
@@ -611,6 +612,7 @@ render_para (GtkTextRenderer *text_renderer,
int screen_width;
GdkRGBA selection;
gboolean first = TRUE;
+ GtkCssNode *selection_node;
iter = pango_layout_get_iter (layout);
@@ -624,14 +626,11 @@ render_para (GtkTextRenderer *text_renderer,
screen_width = line_display->total_width;
context = gtk_widget_get_style_context (text_renderer->widget);
- gtk_style_context_save (context);
-
- state = gtk_style_context_get_state (context);
- state |= GTK_STATE_FLAG_SELECTED;
- gtk_style_context_set_state (context, state);
+ selection_node = gtk_text_view_get_selection_node ((GtkTextView*)text_renderer->widget);
+ gtk_style_context_save_to_node (context, selection_node);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- gtk_style_context_get_background_color (context, state, &selection);
+ gtk_style_context_get_background_color (context, gtk_style_context_get_state (context), &selection);
G_GNUC_END_IGNORE_DEPRECATIONS
gtk_style_context_restore (context);
@@ -825,9 +824,8 @@ G_GNUC_END_IGNORE_DEPRECATIONS
{
GdkRGBA color;
- state = gtk_style_context_get_state (context);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- gtk_style_context_get_background_color (context, state, &color);
+ gtk_style_context_get_background_color (context, gtk_style_context_get_state (context), &color);
G_GNUC_END_IGNORE_DEPRECATIONS
gdk_cairo_set_source_rgba (cr, &color);