[gnome-builder] editor: set back drawing spaces feature
- From: Sébastien Lafargue <slafargue src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] editor: set back drawing spaces feature
- Date: Sat, 29 Jul 2017 19:56:09 +0000 (UTC)
commit 626b3d6852d292cc95090af7bb32711ff4c3a088
Author: Sebastien Lafargue <slafargue gnome org>
Date: Sat Jul 29 21:52:14 2017 +0200
editor: set back drawing spaces feature
We set back drawing spaces using the new
GtkSourceVieww GtkSourceSpaceDrawer API
( GtkSourceView >= 3.24 )
libide/editor/ide-editor-view-settings.c | 69 ++++++++++++++++++++++++++++++
1 files changed, 69 insertions(+), 0 deletions(-)
---
diff --git a/libide/editor/ide-editor-view-settings.c b/libide/editor/ide-editor-view-settings.c
index 5d0d4ba..663de12 100644
--- a/libide/editor/ide-editor-view-settings.c
+++ b/libide/editor/ide-editor-view-settings.c
@@ -20,6 +20,8 @@
#include "ide-editor-private.h"
+#include <gtksourceview/gtksource.h>
+
static gboolean
get_smart_home_end (GValue *value,
GVariant *variant,
@@ -63,6 +65,65 @@ on_keybindings_changed (IdeEditorView *self,
IDE_SOURCE_VIEW_MODE_TYPE_PERMANENT);
}
+static void
+on_draw_spaces_changed (IdeEditorView *self,
+ const gchar *key,
+ GSettings *settings)
+{
+ GtkSourceView *source_view;
+ GtkSourceSpaceDrawer *drawer;
+ guint flags;
+ GtkSourceSpaceLocationFlags location_flags = GTK_SOURCE_SPACE_LOCATION_NONE;
+ GtkSourceSpaceTypeFlags type_flags = GTK_SOURCE_SPACE_TYPE_NONE;
+
+ g_assert (IDE_IS_EDITOR_VIEW (self));
+ g_assert (g_strcmp0 (key, "draw-spaces") == 0);
+ g_assert (G_IS_SETTINGS (settings));
+
+ source_view = GTK_SOURCE_VIEW (ide_editor_view_get_view (self));
+ drawer = gtk_source_view_get_space_drawer (source_view);
+ flags = g_settings_get_flags (settings, "draw-spaces");
+
+ if (flags == 0)
+ {
+ gtk_source_space_drawer_set_enable_matrix (drawer, FALSE);
+ return;
+ }
+
+ /* Reset the matrix before setting it */
+ gtk_source_space_drawer_set_types_for_locations (drawer, GTK_SOURCE_SPACE_LOCATION_ALL,
GTK_SOURCE_SPACE_TYPE_NONE);
+
+ if (flags & 1)
+ type_flags |= GTK_SOURCE_SPACE_TYPE_SPACE;
+
+ if (flags & 2)
+ type_flags |= GTK_SOURCE_SPACE_TYPE_TAB;
+
+ if (flags & 4)
+ {
+ gtk_source_space_drawer_set_types_for_locations (drawer, GTK_SOURCE_SPACE_LOCATION_ALL,
GTK_SOURCE_SPACE_TYPE_NEWLINE);
+ type_flags |= GTK_SOURCE_SPACE_TYPE_NEWLINE;
+ }
+
+ if (flags & 8)
+ type_flags |= GTK_SOURCE_SPACE_TYPE_NBSP;
+
+ if (flags & 16)
+ location_flags |= GTK_SOURCE_SPACE_LOCATION_LEADING;
+
+ if (flags & 32)
+ location_flags |= GTK_SOURCE_SPACE_LOCATION_INSIDE_TEXT;
+
+ if (flags & 64)
+ location_flags |= GTK_SOURCE_SPACE_LOCATION_TRAILING;
+
+ if (type_flags > 0 && location_flags == 0)
+ location_flags |= GTK_SOURCE_SPACE_LOCATION_ALL;
+
+ gtk_source_space_drawer_set_enable_matrix (drawer, TRUE);
+ gtk_source_space_drawer_set_types_for_locations (drawer, location_flags, type_flags);
+}
+
void
_ide_editor_view_init_settings (IdeEditorView *self)
{
@@ -144,6 +205,14 @@ _ide_editor_view_init_settings (IdeEditorView *self)
on_keybindings_changed (self, "keybindings", self->editor_settings);
+ g_signal_connect_object (self->editor_settings,
+ "changed::draw-spaces",
+ G_CALLBACK (on_draw_spaces_changed),
+ self,
+ G_CONNECT_SWAPPED);
+
+ on_draw_spaces_changed (self, "draw-spaces", self->editor_settings);
+
self->insight_settings = g_settings_new ("org.gnome.builder.code-insight");
g_settings_bind (self->insight_settings, "word-completion",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]