[gnome-builder/wip/gtk4-port: 420/736] libide/editor: wire up overview map setting




commit 32887b08d6262cb0264a2c343799e3534f71c803
Author: Christian Hergert <chergert redhat com>
Date:   Tue Apr 5 18:10:29 2022 -0700

    libide/editor: wire up overview map setting

 src/libide/editor/ide-editor-page-settings.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
---
diff --git a/src/libide/editor/ide-editor-page-settings.c b/src/libide/editor/ide-editor-page-settings.c
index 70531e1e8..090148a97 100644
--- a/src/libide/editor/ide-editor-page-settings.c
+++ b/src/libide/editor/ide-editor-page-settings.c
@@ -64,9 +64,24 @@ _ide_editor_page_settings_reload (IdeEditorPage *self)
   IDE_EXIT;
 }
 
+static gboolean
+show_map_to_vscrollbar_policy (GValue   *value,
+                               GVariant *variant,
+                               gpointer  user_data)
+{
+  if (g_variant_get_boolean (variant))
+    g_value_set_enum (value, GTK_POLICY_EXTERNAL);
+  else
+    g_value_set_enum (value, GTK_POLICY_AUTOMATIC);
+
+  return TRUE;
+}
+
 void
 _ide_editor_page_settings_init (IdeEditorPage *self)
 {
+  static GSettings *editor_settings;
+
   IDE_ENTRY;
 
   g_return_if_fail (IDE_IS_MAIN_THREAD ());
@@ -76,6 +91,9 @@ _ide_editor_page_settings_init (IdeEditorPage *self)
   g_return_if_fail (self->buffer_file_settings == NULL);
   g_return_if_fail (self->view_file_settings == NULL);
 
+  if (editor_settings == NULL)
+    editor_settings = g_settings_new ("org.gnome.builder.editor");
+
   g_object_bind_property (IDE_APPLICATION_DEFAULT, "style-scheme",
                           self->buffer, "style-scheme-name",
                           G_BINDING_SYNC_CREATE);
@@ -106,6 +124,15 @@ _ide_editor_page_settings_init (IdeEditorPage *self)
                           "tab-width", self->view, "tab-width",
                           G_BINDING_SYNC_CREATE);
 
+  g_settings_bind (editor_settings, "show-map",
+                   self->map_revealer, "reveal-child",
+                   G_SETTINGS_BIND_DEFAULT);
+  g_settings_bind_with_mapping (editor_settings, "show-map",
+                                self->scroller, "vscrollbar-policy",
+                                G_SETTINGS_BIND_GET,
+                                show_map_to_vscrollbar_policy,
+                                NULL, NULL, NULL);
+
 #if 0
   ide_binding_group_bind (self->view_file_settings,
                           "insert-matching-brace", self->view, "insert-matching-brace",


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