[gnome-text-editor] page: tweak margin of lines renderer
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-text-editor] page: tweak margin of lines renderer
- Date: Sat, 19 Jun 2021 21:20:39 +0000 (UTC)
commit 2b294ff71bc03bce3da364501291c9e7e671a56b
Author: Christian Hergert <chergert redhat com>
Date: Sat Jun 19 14:20:11 2021 -0700
page: tweak margin of lines renderer
This is better since it ensures we have proper background color.
src/editor-page.c | 28 ++++++++++++++++++++++++----
1 file changed, 24 insertions(+), 4 deletions(-)
---
diff --git a/src/editor-page.c b/src/editor-page.c
index cc14c74..acacb39 100644
--- a/src/editor-page.c
+++ b/src/editor-page.c
@@ -46,6 +46,29 @@ G_DEFINE_TYPE (EditorPage, editor_page, GTK_TYPE_WIDGET)
static GParamSpec *properties [N_PROPS];
+static void
+editor_page_tweak_gutter_spacing (EditorPage *self)
+{
+ GtkSourceGutter *gutter;
+ GtkWidget *child;
+ guint n = 0;
+
+ g_assert (EDITOR_IS_PAGE (self));
+
+ /* Ensure we have a line gutter renderer to tweak */
+ gutter = gtk_source_view_get_gutter (self->view, GTK_TEXT_WINDOW_LEFT);
+ gtk_source_view_set_show_line_numbers (self->view, TRUE);
+
+ /* Add margin to first gutter renderer */
+ for (child = gtk_widget_get_first_child (GTK_WIDGET (gutter));
+ child != NULL;
+ child = gtk_widget_get_next_sibling (child), n++)
+ {
+ if (GTK_SOURCE_IS_GUTTER_RENDERER (child))
+ gtk_widget_set_margin_start (child, n == 0 ? 4 : 0);
+ }
+}
+
static void
editor_page_set_settings (EditorPage *self,
EditorPageSettings *settings)
@@ -578,12 +601,9 @@ static void
editor_page_init (EditorPage *self)
{
GtkDropTarget *dest;
- GtkSourceGutter *gutter;
gtk_widget_init_template (GTK_WIDGET (self));
-
- gutter = gtk_source_view_get_gutter (self->view, GTK_TEXT_WINDOW_LEFT);
- gtk_widget_set_margin_start (GTK_WIDGET (gutter), 4);
+ editor_page_tweak_gutter_spacing (self);
g_object_bind_property (self, "document", self->infobar, "document", 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]