[gtksourceview] gutter: snapshot color node for current line
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview] gutter: snapshot color node for current line
- Date: Tue, 20 Jul 2021 23:06:42 +0000 (UTC)
commit 01a72cc42d8239d0a4f71abc4afc2500b04e1a19
Author: Christian Hergert <chergert redhat com>
Date: Tue Jul 20 15:47:03 2021 -0700
gutter: snapshot color node for current line
We can avoid a bunch of machinery here by just using a premixed color from
the GtkSourceView when possible. Additionally, we can get closer to
supporting generic coloring like #29 will require.
gtksourceview/gtksourcegutter.c | 23 +++++++++--------------
1 file changed, 9 insertions(+), 14 deletions(-)
---
diff --git a/gtksourceview/gtksourcegutter.c b/gtksourceview/gtksourcegutter.c
index cdfb47c3..8f2cb649 100644
--- a/gtksourceview/gtksourcegutter.c
+++ b/gtksourceview/gtksourcegutter.c
@@ -26,7 +26,7 @@
#include "gtksourcegutterlines-private.h"
#include "gtksourcesignalgroup-private.h"
#include "gtksourcestylescheme-private.h"
-#include "gtksourceview.h"
+#include "gtksourceview-private.h"
#include "gtksourcegutterrenderer.h"
#include "gtksourcegutterrenderer-private.h"
@@ -706,7 +706,6 @@ gtk_source_gutter_snapshot (GtkWidget *widget,
{
GtkSourceGutter *gutter = GTK_SOURCE_GUTTER (widget);
GtkTextView *text_view = GTK_TEXT_VIEW (gutter->view);
- GtkStyleContext *style_context;
const GList *list;
GdkRectangle visible_rect;
GtkTextIter begin;
@@ -721,8 +720,6 @@ gtk_source_gutter_snapshot (GtkWidget *widget,
return;
}
- style_context = gtk_widget_get_style_context (GTK_WIDGET (gutter));
-
gtk_text_view_get_visible_rect (text_view, &visible_rect);
gtk_text_view_get_iter_at_location (text_view, &begin,
visible_rect.x, visible_rect.y);
@@ -752,6 +749,7 @@ gtk_source_gutter_snapshot (GtkWidget *widget,
if (cursor_line >= gtk_source_gutter_lines_get_first (gutter->lines) &&
cursor_line <= gtk_source_gutter_lines_get_last (gutter->lines))
{
+ GdkRGBA highlight;
gint y;
gint height;
@@ -761,17 +759,14 @@ gtk_source_gutter_snapshot (GtkWidget *widget,
&y,
&height);
- gtk_style_context_save (style_context);
- gtk_style_context_add_class (style_context, "current-line-number");
-
- gtk_snapshot_render_background (snapshot,
- style_context,
- 0,
- y,
- gtk_widget_get_width (widget),
- height);
+ if (_gtk_source_view_get_current_line_number_background (gutter->view, &highlight))
+ {
+ int width = gtk_widget_get_width (widget);
- gtk_style_context_restore (style_context);
+ gtk_snapshot_append_color (snapshot,
+ &highlight,
+ &GRAPHENE_RECT_INIT (0, y, width, height));
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]