[gnome-builder] preferences: add option to wrap text



commit 42e59b49bc02dd33cb3b86803f3352a2ed149132
Author: Christian Hergert <chergert redhat com>
Date:   Thu Apr 13 02:14:06 2017 -0700

    preferences: add option to wrap text
    
    I avoided this for the longest time because it really tanks scrolling
    performance. But we can at least have it as an option and disable it
    by default.

 .../gsettings/org.gnome.builder.editor.gschema.xml |    5 +++++
 libide/editor/ide-editor-frame.c                   |   14 ++++++++++++++
 libide/preferences/ide-preferences-builtin.c       |    1 +
 3 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/data/gsettings/org.gnome.builder.editor.gschema.xml 
b/data/gsettings/org.gnome.builder.editor.gschema.xml
index d6a5d72..8224939 100644
--- a/data/gsettings/org.gnome.builder.editor.gschema.xml
+++ b/data/gsettings/org.gnome.builder.editor.gschema.xml
@@ -94,5 +94,10 @@
       <summary>Overscroll</summary>
       <description>The number of lines to scroll beyond the end of the buffer.</description>
     </key>
+    <key name="wrap-text" type="b">
+      <default>false</default>
+      <summary>Wrap Text</summary>
+      <description>If enabled, Builder will automatically wrap text so all of the line text is 
visible.</description>
+    </key>
   </schema>
 </schemalist>
diff --git a/libide/editor/ide-editor-frame.c b/libide/editor/ide-editor-frame.c
index b76a7ad..e42795a 100644
--- a/libide/editor/ide-editor-frame.c
+++ b/libide/editor/ide-editor-frame.c
@@ -689,6 +689,19 @@ get_smart_home_end (GValue   *value,
   return TRUE;
 }
 
+static gboolean
+get_wrap_mode (GValue   *value,
+               GVariant *variant,
+               gpointer  user_data)
+{
+  if (g_variant_get_boolean (variant))
+    g_value_set_enum (value, GTK_WRAP_WORD);
+  else
+    g_value_set_enum (value, GTK_WRAP_NONE);
+
+  return TRUE;
+}
+
 static void
 keybindings_changed (GSettings     *settings,
                      const gchar   *key,
@@ -1231,6 +1244,7 @@ ide_editor_frame_init (IdeEditorFrame *self)
   g_settings_bind (settings, "show-line-numbers", self->source_view, "show-line-numbers", 
G_SETTINGS_BIND_GET);
   g_settings_bind (settings, "smart-backspace", self->source_view, "smart-backspace", G_SETTINGS_BIND_GET);
   g_settings_bind_with_mapping (settings, "smart-home-end", self->source_view, "smart-home-end", 
G_SETTINGS_BIND_GET, get_smart_home_end, NULL, NULL, NULL);
+  g_settings_bind_with_mapping (settings, "wrap-text", self->source_view, "wrap-mode", G_SETTINGS_BIND_GET, 
get_wrap_mode, NULL, NULL, NULL);
   g_settings_bind (settings, "show-map", self, "show-map", G_SETTINGS_BIND_GET);
   g_settings_bind (settings, "auto-hide-map", self, "auto-hide-map", G_SETTINGS_BIND_GET);
   g_signal_connect_object (settings, "changed::keybindings", G_CALLBACK (keybindings_changed), self, 0);
diff --git a/libide/preferences/ide-preferences-builtin.c b/libide/preferences/ide-preferences-builtin.c
index c30504c..651884d 100644
--- a/libide/preferences/ide-preferences-builtin.c
+++ b/libide/preferences/ide-preferences-builtin.c
@@ -157,6 +157,7 @@ ide_preferences_builtin_register_editor (IdePreferences *preferences)
 
   ide_preferences_add_list_group (preferences, "editor", "position", _("Cursor"), GTK_SELECTION_NONE, 0);
   ide_preferences_add_switch (preferences, "editor", "position", "org.gnome.builder.editor", 
"restore-insert-mark", NULL, NULL, _("Restore cursor position"), _("Restore cursor position when a file is 
reopened"), NULL, 0);
+  ide_preferences_add_switch (preferences, "editor", "position", "org.gnome.builder.editor", "wrap-text", 
NULL, NULL, _("Enable text wrapping"), _("Wrap text that is too wide to display"), NULL, 5);
   ide_preferences_add_spin_button (preferences, "editor", "position", "org.gnome.builder.editor", 
"scroll-offset", NULL, _("Scroll Offset"), _("Minimum number of lines to keep above and below the cursor"), 
NULL, 10);
   ide_preferences_add_spin_button (preferences, "editor", "position", "org.gnome.builder.editor", 
"overscroll", NULL, _("Overscroll"), _("Allow the editor to scroll past the end of the buffer"), NULL, 20);
 


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