[gnome-builder] plugins/editorui: per-language settings and groups



commit ce51f60c95e8008a1206018c5e2b140a42424d7e
Author: Christian Hergert <chergert redhat com>
Date:   Mon Aug 15 15:57:46 2022 -0700

    plugins/editorui: per-language settings and groups

 po/POTFILES.in                                   |  1 +
 src/plugins/editorui/gbp-editorui-tweaks-addin.c | 21 ++++--
 src/plugins/editorui/tweaks-language.ui          | 92 +++++++++++++++++++++++-
 3 files changed, 108 insertions(+), 6 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 0a0793d17..597d7bb13 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -172,6 +172,7 @@ src/plugins/editorconfig/gbp-editorconfig-file-settings.c
 src/plugins/editorui/gbp-editorui-application-addin.c
 src/plugins/editorui/gbp-editorui-position-label.c
 src/plugins/editorui/gbp-editorui-preferences-addin.c
+src/plugins/editorui/gbp-editorui-tweaks-addin.c
 src/plugins/editorui/gbp-editorui-workspace-addin.c
 src/plugins/editorui/gtk/menus.ui
 src/plugins/editorui/tweaks.ui
diff --git a/src/plugins/editorui/gbp-editorui-tweaks-addin.c 
b/src/plugins/editorui/gbp-editorui-tweaks-addin.c
index 2e0ce2ee2..149a9f21d 100644
--- a/src/plugins/editorui/gbp-editorui-tweaks-addin.c
+++ b/src/plugins/editorui/gbp-editorui-tweaks-addin.c
@@ -22,6 +22,8 @@
 
 #include "config.h"
 
+#include <glib/gi18n.h>
+
 #include <libide-gui.h>
 
 #include "gbp-editorui-preview.h"
@@ -66,6 +68,18 @@ editorui_create_style_scheme_selector (GbpEditoruiTweaksAddin *self,
                        NULL);
 }
 
+static GtkWidget *
+create_language_caption (IdeTweaks       *tweaks,
+                         IdeTweaksWidget *widget)
+{
+  return g_object_new (GTK_TYPE_LABEL,
+                       "css-classes", IDE_STRV_INIT ("caption", "dim-label"),
+                       "label", _("Settings provided .editorconfig and modelines specified within files take 
precedence over those below."),
+                       "xalign", .0f,
+                       "wrap", TRUE,
+                       NULL);
+}
+
 static void
 gbp_editorui_tweaks_addin_load (IdeTweaksAddin *addin,
                                 IdeTweaks      *tweaks)
@@ -92,10 +106,9 @@ gbp_editorui_tweaks_addin_load (IdeTweaksAddin *addin,
   ide_tweaks_addin_set_resource_paths (IDE_TWEAKS_ADDIN (self),
                                        IDE_STRV_INIT ("/plugins/editorui/tweaks.ui",
                                                       "/plugins/editorui/tweaks-language.ui"));
-  ide_tweaks_addin_bind_callback (IDE_TWEAKS_ADDIN (self),
-                                  editorui_create_style_scheme_preview);
-  ide_tweaks_addin_bind_callback (IDE_TWEAKS_ADDIN (self),
-                                  editorui_create_style_scheme_selector);
+  ide_tweaks_addin_bind_callback (IDE_TWEAKS_ADDIN (self), editorui_create_style_scheme_preview);
+  ide_tweaks_addin_bind_callback (IDE_TWEAKS_ADDIN (self), editorui_create_style_scheme_selector);
+  ide_tweaks_addin_bind_callback (IDE_TWEAKS_ADDIN (self), create_language_caption);
   ide_tweaks_expose_object (tweaks, "GtkSourceLanguages", G_OBJECT (store));
 
   IDE_TWEAKS_ADDIN_CLASS (gbp_editorui_tweaks_addin_parent_class)->load (addin, tweaks);
diff --git a/src/plugins/editorui/tweaks-language.ui b/src/plugins/editorui/tweaks-language.ui
index 9f325beb6..2a447a0e6 100644
--- a/src/plugins/editorui/tweaks-language.ui
+++ b/src/plugins/editorui/tweaks-language.ui
@@ -31,8 +31,44 @@
                       </object>
                     </child>
                     <child>
-                      <object class="IdeTweaksGroup" id="language_general_group">
-                        <property name="title" translatable="yes">General</property>
+                      <object class="IdeTweaksGroup" id="language_top_group">
+                        <child>
+                          <object class="IdeTweaksWidget" id="language_caption">
+                            <signal name="create" handler="create_language_caption" swapped="true" 
object="IdeTweaks"/>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="IdeTweaksGroup" id="language_formatting_group">
+                        <property name="title" translatable="yes">Indentation &amp; Formatting</property>
+                        <child>
+                          <object class="IdeTweaksCombo" id="insert_spaces_instead_of_tabs">
+                            <property name="title" translatable="yes">Tab Character</property>
+                            <property name="subtitle" translatable="yes">The character to be inserted for 
Tab</property>
+                            <property name="settings">language_page_settings</property>
+                            <property name="key">insert-spaces-instead-of-tabs</property>
+                            <child>
+                              <object class="IdeTweaksChoice" id="tab_choice">
+                                <property name="title" translatable="yes">Tab</property>
+                                <property name="action-target">false</property>
+                              </object>
+                            </child>
+                            <child>
+                              <object class="IdeTweaksChoice" id="space_choice">
+                                <property name="title" translatable="yes">Spaces</property>
+                                <property name="action-target">true</property>
+                              </object>
+                            </child>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="IdeTweaksSwitch" id="insert_trailing_newline">
+                            <property name="title" translatable="yes">Insert Trailing Newline</property>
+                            <property name="subtitle" translatable="yes">Ensure files end with a 
newline</property>
+                            <property 
name="action-name">settings.org.gnome.builder.editor.language.insert-trailing-newline</property>
+                          </object>
+                        </child>
                         <child>
                           <object class="IdeTweaksSwitch" id="trim_whitespace">
                             <property name="title" translatable="yes">Trim Trailing Space</property>
@@ -40,6 +76,58 @@
                             <property 
name="action-name">settings.org.gnome.builder.editor.language.trim-trailing-whitespace</property>
                           </object>
                         </child>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="IdeTweaksGroup" id="language_indentation_group">
+                        <child>
+                          <object class="IdeTweaksSwitch" id="auto_indent">
+                            <property name="title" translatable="yes">Auto Indent</property>
+                            <property name="subtitle" translatable="yes">Automatically indent source code as 
you type</property>
+                            <property 
name="action-name">settings.org.gnome.builder.editor.language.auto-indent</property>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="IdeTweaksSpin" id="tab_width">
+                            <property name="title" translatable="yes">Tab Size</property>
+                            <property name="subtitle" translatable="yes">The number of characters to indent 
for Tab</property>
+                            <property name="settings">language_page_settings</property>
+                            <property name="key">tab-width</property>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="IdeTweaksSpin" id="indent_width">
+                            <property name="title" translatable="yes">Indentation Size</property>
+                            <property name="subtitle" translatable="yes">The number of characters to indent, 
or -1 to use tab size</property>
+                            <property name="settings">language_page_settings</property>
+                            <property name="key">indent-width</property>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="IdeTweaksGroup" id="language_margin_group">
+                        <property name="title" translatable="yes">Margin</property>
+                        <child>
+                          <object class="IdeTweaksSwitch" id="show_right_margin">
+                            <property name="title" translatable="yes">Show Right Margin</property>
+                            <property name="subtitle" translatable="yes">Display a margin in the editor to 
indicate maximium desired width</property>
+                            <property 
name="action-name">settings.org.gnome.builder.editor.language.show-right-margin</property>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="IdeTweaksSpin" id="right_margin_position">
+                            <property name="title" translatable="yes">Right Margin Position</property>
+                            <property name="subtitle" translatable="yes">The desired maximum line 
length</property>
+                            <property name="settings">language_page_settings</property>
+                            <property name="key">right-margin-position</property>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="IdeTweaksGroup" id="language_behavior_group">
+                        <property name="title" translatable="yes">Behavior</property>
                         <child>
                           <object class="IdeTweaksSwitch" id="overwrite_braces">
                             <property name="title" translatable="yes">Overwrite Braces</property>


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