[gnome-builder/wip/gtk4-port: 1294/1774] plugins/editorui: allow toggling spaces v tabs




commit aff5e84f6cf1623c9a6fb162889b917cf8a127e3
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jun 1 15:49:20 2022 -0700

    plugins/editorui: allow toggling spaces v tabs

 src/plugins/editorui/gbp-editorui-workspace-addin.c |  4 ++++
 src/plugins/editorui/gtk/menus.ui                   | 10 ++--------
 2 files changed, 6 insertions(+), 8 deletions(-)
---
diff --git a/src/plugins/editorui/gbp-editorui-workspace-addin.c 
b/src/plugins/editorui/gbp-editorui-workspace-addin.c
index b2bd9795e..3501757a2 100644
--- a/src/plugins/editorui/gbp-editorui-workspace-addin.c
+++ b/src/plugins/editorui/gbp-editorui-workspace-addin.c
@@ -514,6 +514,7 @@ gbp_editorui_workspace_addin_page_changed (IdeWorkspaceAddin *addin,
   g_action_map_remove_action (G_ACTION_MAP (self->actions), "newline-type");
   g_action_map_remove_action (G_ACTION_MAP (self->actions), "indent-width");
   g_action_map_remove_action (G_ACTION_MAP (self->actions), "tab-width");
+  g_action_map_remove_action (G_ACTION_MAP (self->actions), "use-spaces");
 
   if (!IDE_IS_EDITOR_PAGE (page))
     page = NULL;
@@ -524,6 +525,7 @@ gbp_editorui_workspace_addin_page_changed (IdeWorkspaceAddin *addin,
       g_autoptr(GPropertyAction) newline_action = NULL;
       g_autoptr(GPropertyAction) indent_width = NULL;
       g_autoptr(GPropertyAction) tab_width = NULL;
+      g_autoptr(GPropertyAction) tabs_v_spaces = NULL;
 
       view = ide_editor_page_get_view (IDE_EDITOR_PAGE (page));
       buffer = ide_editor_page_get_buffer (IDE_EDITOR_PAGE (page));
@@ -532,11 +534,13 @@ gbp_editorui_workspace_addin_page_changed (IdeWorkspaceAddin *addin,
       newline_action = g_property_action_new ("newline-type", buffer, "newline-type");
       indent_width = g_property_action_new ("indent-width", view, "indent-width");
       tab_width = g_property_action_new ("tab-width", view, "tab-width");
+      tabs_v_spaces = g_property_action_new ("use-spaces", view, "insert-spaces-instead-of-tabs");
 
       g_action_map_add_action (G_ACTION_MAP (self->actions), G_ACTION (encoding_action));
       g_action_map_add_action (G_ACTION_MAP (self->actions), G_ACTION (newline_action));
       g_action_map_add_action (G_ACTION_MAP (self->actions), G_ACTION (tab_width));
       g_action_map_add_action (G_ACTION_MAP (self->actions), G_ACTION (indent_width));
+      g_action_map_add_action (G_ACTION_MAP (self->actions), G_ACTION (tabs_v_spaces));
     }
 
   ide_binding_group_set_source (self->buffer_bindings, buffer);
diff --git a/src/plugins/editorui/gtk/menus.ui b/src/plugins/editorui/gtk/menus.ui
index 1b9a6cdaa..8b3d9f7f0 100644
--- a/src/plugins/editorui/gtk/menus.ui
+++ b/src/plugins/editorui/gtk/menus.ui
@@ -4,14 +4,8 @@
     <section id="editorui-indent-section">
       <attribute name="label" translatable="yes">Indentation</attribute>
       <item>
-        <attribute name="label" translatable="yes">Tabs</attribute>
-        <attribute name="action">indent.style('tabs')</attribute>
-        <attribute name="role">radio</attribute>
-      </item>
-      <item>
-        <attribute name="label" translatable="yes">Spaces</attribute>
-        <attribute name="action">indent.style('spaces')</attribute>
-        <attribute name="role">radio</attribute>
+        <attribute name="label" translatable="yes">Indent Using Spaces</attribute>
+        <attribute name="action">editorui.use-spaces</attribute>
       </item>
     </section>
     <section id="editorui-tab-section">


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