[gtksourceview/wip/chergert/gsv-gtk4: 172/259] view: apply style scheme to gutter and renderers
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/gsv-gtk4: 172/259] view: apply style scheme to gutter and renderers
- Date: Mon, 21 Sep 2020 23:27:46 +0000 (UTC)
commit 7a5951e80e82b377de4d2f90ea694b6eee5a0960
Author: Christian Hergert <chergert redhat com>
Date: Fri Apr 17 14:34:50 2020 -0700
view: apply style scheme to gutter and renderers
gtksourceview/gtksourcegutter-private.h | 18 ++++++----
gtksourceview/gtksourcegutter.c | 59 +++++++++++++++++++++++++++++++++
gtksourceview/gtksourceview.c | 8 ++---
3 files changed, 75 insertions(+), 10 deletions(-)
---
diff --git a/gtksourceview/gtksourcegutter-private.h b/gtksourceview/gtksourcegutter-private.h
index 0d0c0006..030cfffc 100644
--- a/gtksourceview/gtksourcegutter-private.h
+++ b/gtksourceview/gtksourcegutter-private.h
@@ -26,14 +26,20 @@
G_BEGIN_DECLS
G_GNUC_INTERNAL
-GtkSourceGutter *_gtk_source_gutter_new (GtkTextWindowType type,
- GtkSourceView *view);
+GtkSourceGutter *_gtk_source_gutter_new (GtkTextWindowType type,
+ GtkSourceView *view);
G_GNUC_INTERNAL
-GtkSourceGutterLines *_gtk_source_gutter_get_lines (GtkSourceGutter *gutter);
+GtkSourceGutterLines *_gtk_source_gutter_get_lines (GtkSourceGutter *gutter);
G_GNUC_INTERNAL
-void _gtk_source_gutter_queue_draw (GtkSourceGutter *gutter);
+void _gtk_source_gutter_queue_draw (GtkSourceGutter *gutter);
G_GNUC_INTERNAL
-void _gtk_source_gutter_css_changed (GtkSourceGutter *gutter,
- GtkCssStyleChange *change);
+void _gtk_source_gutter_css_changed (GtkSourceGutter *gutter,
+ GtkCssStyleChange *change);
+G_GNUC_INTERNAL
+void _gtk_source_gutter_apply_scheme (GtkSourceGutter *gutter,
+ GtkSourceStyleScheme *scheme);
+G_GNUC_INTERNAL
+void _gtk_source_gutter_unapply_scheme (GtkSourceGutter *gutter,
+ GtkSourceStyleScheme *scheme);
G_END_DECLS
diff --git a/gtksourceview/gtksourcegutter.c b/gtksourceview/gtksourcegutter.c
index 68042218..56aa09b6 100644
--- a/gtksourceview/gtksourcegutter.c
+++ b/gtksourceview/gtksourcegutter.c
@@ -19,10 +19,12 @@
#include "config.h"
+#include "gtksourcebuffer.h"
#include "gtksourcegutter.h"
#include "gtksourcegutter-private.h"
#include "gtksourcegutterlines.h"
#include "gtksourcegutterlines-private.h"
+#include "gtksourcestylescheme-private.h"
#include "gtksourceview.h"
#include "gtksourcegutterrenderer.h"
#include "gtksourcegutterrenderer-private.h"
@@ -590,6 +592,25 @@ gtk_source_gutter_insert (GtkSourceGutter *gutter,
g_return_val_if_fail (GTK_SOURCE_IS_GUTTER_RENDERER (renderer), FALSE);
g_return_val_if_fail (gtk_source_gutter_renderer_get_view (renderer) == NULL, FALSE);
+ if (gutter->view != NULL)
+ {
+ GtkTextBuffer *buffer;
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (gutter->view));
+
+ if (GTK_SOURCE_IS_BUFFER (buffer))
+ {
+ GtkSourceStyleScheme *scheme;
+
+ scheme = gtk_source_buffer_get_style_scheme (GTK_SOURCE_BUFFER (buffer));
+
+ if (scheme != NULL)
+ {
+ _gtk_source_style_scheme_apply (scheme, GTK_WIDGET (renderer));
+ }
+ }
+ }
+
internal_renderer = renderer_new (gutter, renderer, position);
append_renderer (gutter, internal_renderer);
gtk_widget_set_parent (GTK_WIDGET (renderer), GTK_WIDGET (gutter));
@@ -1090,3 +1111,41 @@ _gtk_source_gutter_queue_draw (GtkSourceGutter *gutter)
gtk_widget_queue_allocate (GTK_WIDGET (renderer->renderer));
}
}
+
+void
+_gtk_source_gutter_apply_scheme (GtkSourceGutter *gutter,
+ GtkSourceStyleScheme *scheme)
+{
+ if (gutter == NULL)
+ {
+ return;
+ }
+
+ _gtk_source_style_scheme_apply (scheme, GTK_WIDGET (gutter));
+
+ for (const GList *iter = gutter->renderers; iter; iter = iter->next)
+ {
+ Renderer *renderer = iter->data;
+
+ _gtk_source_style_scheme_apply (scheme, GTK_WIDGET (renderer->renderer));
+ }
+}
+
+void
+_gtk_source_gutter_unapply_scheme (GtkSourceGutter *gutter,
+ GtkSourceStyleScheme *scheme)
+{
+ if (gutter == NULL)
+ {
+ return;
+ }
+
+ _gtk_source_style_scheme_unapply (scheme, GTK_WIDGET (gutter));
+
+ for (const GList *iter = gutter->renderers; iter; iter = iter->next)
+ {
+ Renderer *renderer = iter->data;
+
+ _gtk_source_style_scheme_unapply (scheme, GTK_WIDGET (renderer->renderer));
+ }
+}
diff --git a/gtksourceview/gtksourceview.c b/gtksourceview/gtksourceview.c
index 8e7a2fe3..38c8c42d 100644
--- a/gtksourceview/gtksourceview.c
+++ b/gtksourceview/gtksourceview.c
@@ -4600,8 +4600,8 @@ gtk_source_view_update_style_scheme (GtkSourceView *view)
if (priv->style_scheme != NULL)
{
_gtk_source_style_scheme_unapply (priv->style_scheme, GTK_WIDGET (view));
- _gtk_source_style_scheme_unapply (priv->style_scheme, GTK_WIDGET (priv->left_gutter));
- _gtk_source_style_scheme_unapply (priv->style_scheme, GTK_WIDGET (priv->right_gutter));
+ _gtk_source_gutter_unapply_scheme (priv->left_gutter, priv->style_scheme);
+ _gtk_source_gutter_unapply_scheme (priv->right_gutter, priv->style_scheme);
}
g_set_object (&priv->style_scheme, new_scheme);
@@ -4609,8 +4609,8 @@ gtk_source_view_update_style_scheme (GtkSourceView *view)
if (priv->style_scheme != NULL)
{
_gtk_source_style_scheme_apply (priv->style_scheme, GTK_WIDGET (view));
- _gtk_source_style_scheme_apply (priv->style_scheme, GTK_WIDGET (priv->left_gutter));
- _gtk_source_style_scheme_apply (priv->style_scheme, GTK_WIDGET (priv->right_gutter));
+ _gtk_source_gutter_apply_scheme (priv->left_gutter, priv->style_scheme);
+ _gtk_source_gutter_apply_scheme (priv->right_gutter, priv->style_scheme);
}
update_style (view);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]