[gnome-builder] libide/editor: bind wrap mode to source view



commit 2c6c6b1f576caac462b735dba88deaed04eafa61
Author: Christian Hergert <chergert redhat com>
Date:   Tue Sep 6 16:47:16 2022 -0700

    libide/editor: bind wrap mode to source view
    
    Fixes #1783

 src/libide/editor/ide-editor-page-settings.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
---
diff --git a/src/libide/editor/ide-editor-page-settings.c b/src/libide/editor/ide-editor-page-settings.c
index 13b2c60aa..7f4c0273d 100644
--- a/src/libide/editor/ide-editor-page-settings.c
+++ b/src/libide/editor/ide-editor-page-settings.c
@@ -109,6 +109,27 @@ font_name_to_font_desc (GValue   *value,
   return TRUE;
 }
 
+static gboolean
+wrap_text_to_wrap_mode (GValue   *value,
+                        GVariant *variant,
+                        gpointer  user_data)
+{
+  GtkWrapMode mode = GTK_WRAP_NONE;
+  const char *str;
+
+  if ((str = g_variant_get_string (variant, NULL)))
+    {
+      if (ide_str_equal0 (str, "whitespace"))
+        mode = GTK_WRAP_WORD;
+      else if (ide_str_equal0 (str, "always"))
+        mode = GTK_WRAP_CHAR;
+    }
+
+  g_value_set_enum (value, mode);
+
+  return TRUE;
+}
+
 static void
 notify_interactive_completion_cb (IdeEditorPage *self,
                                   const char    *key,
@@ -278,6 +299,11 @@ _ide_editor_page_settings_init (IdeEditorPage *self)
                    gtk_source_view_get_completion (GTK_SOURCE_VIEW (self->view)),
                    "page-size",
                    G_SETTINGS_BIND_GET);
+  g_settings_bind_with_mapping (editor_settings, "wrap-text",
+                                self->view, "wrap-mode",
+                                G_SETTINGS_BIND_GET,
+                               wrap_text_to_wrap_mode,
+                               NULL, NULL, NULL);
 
   g_settings_bind_with_mapping (editor_settings, "font-name",
                                 self->view, "font-desc",


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