[gtksourceview/wip/chergert/gsv-gtk4: 160/175] rendererlines: set style class while processing current line



commit 53367f9816ed3debea7d77e1e480355efd65a103
Author: Christian Hergert <chergert redhat com>
Date:   Fri Apr 17 14:05:03 2020 -0700

    rendererlines: set style class while processing current line

 gtksourceview/gtksourcegutterrendererlines.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
---
diff --git a/gtksourceview/gtksourcegutterrendererlines.c b/gtksourceview/gtksourcegutterrendererlines.c
index b5ef2f24..32ad855f 100644
--- a/gtksourceview/gtksourcegutterrendererlines.c
+++ b/gtksourceview/gtksourcegutterrendererlines.c
@@ -391,6 +391,31 @@ gtk_source_gutter_renderer_lines_query_data (GtkSourceGutterRenderer *renderer,
        }
 }
 
+static void
+gutter_renderer_snapshot_line (GtkSourceGutterRenderer *renderer,
+                               GtkSnapshot             *snapshot,
+                               GtkSourceGutterLines    *lines,
+                               guint                    line)
+{
+       g_assert (GTK_SOURCE_IS_GUTTER_RENDERER_LINES (renderer));
+       g_assert (GTK_IS_SNAPSHOT (snapshot));
+       g_assert (GTK_SOURCE_IS_GUTTER_LINES (lines));
+
+       if G_LIKELY (gtk_source_gutter_lines_is_cursor (lines, line))
+       {
+               GTK_SOURCE_GUTTER_RENDERER_CLASS 
(_gtk_source_gutter_renderer_lines_parent_class)->snapshot_line (renderer, snapshot, lines, line);
+       }
+       else
+       {
+               GtkStyleContext *style_context = gtk_widget_get_style_context (GTK_WIDGET (renderer));
+
+               gtk_style_context_save (style_context);
+               gtk_style_context_add_class (style_context, "current-line-number");
+               GTK_SOURCE_GUTTER_RENDERER_CLASS 
(_gtk_source_gutter_renderer_lines_parent_class)->snapshot_line (renderer, snapshot, lines, line);
+               gtk_style_context_restore (style_context);
+       }
+}
+
 static void
 _gtk_source_gutter_renderer_lines_class_init (GtkSourceGutterRendererLinesClass *klass)
 {
@@ -405,6 +430,7 @@ _gtk_source_gutter_renderer_lines_class_init (GtkSourceGutterRendererLinesClass
        renderer_class->activate = gutter_renderer_activate;
        renderer_class->change_buffer = gutter_renderer_change_buffer;
        renderer_class->change_view = gutter_renderer_change_view;
+       renderer_class->snapshot_line = gutter_renderer_snapshot_line;
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]