[gnome-builder/gnome-builder-3-18] prefs: add options to toggle drawing spaces within the editor



commit 241de4b633e968952261340f7f3e7b2a7f663186
Author: Christian Hergert <chergert redhat com>
Date:   Mon Oct 12 21:15:10 2015 -0400

    prefs: add options to toggle drawing spaces within the editor
    
    This gives some, long missing, checkboxes to toggle flags within GSettings.
    I mostly delayed on this before because I didn't have a clean way to do
    this. Not that this is super clean, but it is something!
    
    Translators, I'm sorry for putting this in so late in the 3.18.1 cycle,
    but I'd rather have it than not when 3.18.1 will most likely be our last
    3.18 release.

 data/ui/gb-preferences-page-editor.ui        |   75 ++++++++++++++++++++++++++
 src/preferences/gb-preferences-page-editor.c |   38 +++++++++++++
 2 files changed, 113 insertions(+), 0 deletions(-)
---
diff --git a/data/ui/gb-preferences-page-editor.ui b/data/ui/gb-preferences-page-editor.ui
index ce51d2a..f93f849 100644
--- a/data/ui/gb-preferences-page-editor.ui
+++ b/data/ui/gb-preferences-page-editor.ui
@@ -196,6 +196,81 @@
                 </child>
               </object>
             </child>
+            <child>
+              <object class="GtkLabel">
+                <property name="visible">true</property>
+                <property name="label" translatable="yes">Draw Spaces</property>
+                <property name="margin-top">12</property>
+                <property name="margin-bottom">6</property>
+                <property name="xalign">0.0</property>
+                <style>
+                  <class name="dim-label"/>
+                </style>
+                <attributes>
+                  <attribute name="weight" value="bold"/>
+                </attributes>
+              </object>
+            </child>
+            <child>
+              <object class="GtkCheckButton" id="draw_spaces_space">
+                <property name="action-name">editor.draw-spaces-space</property>
+                <property name="label" translatable="yes">Draw a circle over space characters.</property>
+                <property name="visible">true</property>
+                <property name="focus-on-click">false</property>
+                <property name="margin-start">6</property>
+                <property name="margin-top">6</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkCheckButton" id="draw_spaces_tab">
+                <property name="action-name">editor.draw-spaces-tab</property>
+                <property name="label" translatable="yes">Draw an arrow over tab characters.</property>
+                <property name="visible">true</property>
+                <property name="focus-on-click">false</property>
+                <property name="margin-start">6</property>
+                <property name="margin-top">6</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkCheckButton" id="draw_spaces_newline">
+                <property name="action-name">editor.draw-spaces-newline</property>
+                <property name="label" translatable="yes">Draw a carriage return over newline 
characters.</property>
+                <property name="visible">true</property>
+                <property name="focus-on-click">false</property>
+                <property name="margin-start">6</property>
+                <property name="margin-top">6</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkCheckButton" id="draw_spaces_nbsp">
+                <property name="action-name">editor.draw-spaces-nbsp</property>
+                <property name="label" translatable="yes">Draw indicators for non-breaking spaces.</property>
+                <property name="visible">true</property>
+                <property name="focus-on-click">false</property>
+                <property name="margin-start">6</property>
+                <property name="margin-top">6</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkCheckButton" id="draw_spaces_leading">
+                <property name="action-name">editor.draw-spaces-leading</property>
+                <property name="label" translatable="yes">Draw leading space only.</property>
+                <property name="visible">true</property>
+                <property name="focus-on-click">false</property>
+                <property name="margin-start">6</property>
+                <property name="margin-top">6</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkCheckButton" id="draw_spaces_trailing">
+                <property name="action-name">editor.draw-spaces-trailing</property>
+                <property name="label" translatable="yes">Draw trailing space only.</property>
+                <property name="visible">true</property>
+                <property name="focus-on-click">false</property>
+                <property name="margin-start">6</property>
+                <property name="margin-top">6</property>
+              </object>
+            </child>
           </object>
         </child>
       </object>
diff --git a/src/preferences/gb-preferences-page-editor.c b/src/preferences/gb-preferences-page-editor.c
index 8f23546..632c722 100644
--- a/src/preferences/gb-preferences-page-editor.c
+++ b/src/preferences/gb-preferences-page-editor.c
@@ -18,6 +18,7 @@
 
 #define G_LOG_DOMAIN "prefs-page-editor"
 
+#include <egg-settings-flag-action.h>
 #include <glib/gi18n.h>
 #include <gtksourceview/gtksource.h>
 
@@ -40,6 +41,12 @@ struct _GbPreferencesPageEditor
   GtkBox                            *scroll_off_container;
   GtkWidget                         *auto_hide_map_switch;
   GtkWidget                         *show_map_switch;
+  GtkCheckButton                    *draw_spaces_space;
+  GtkCheckButton                    *draw_spaces_tab;
+  GtkCheckButton                    *draw_spaces_newline;
+  GtkCheckButton                    *draw_spaces_nbsp;
+  GtkCheckButton                    *draw_spaces_leading;
+  GtkCheckButton                    *draw_spaces_trailing;
 };
 
 G_DEFINE_TYPE (GbPreferencesPageEditor, gb_preferences_page_editor, GB_TYPE_PREFERENCES_PAGE)
@@ -83,13 +90,34 @@ gb_preferences_page_editor_class_init (GbPreferencesPageEditorClass *klass)
   GB_WIDGET_CLASS_BIND (widget_class, GbPreferencesPageEditor, scroll_off_spin);
   GB_WIDGET_CLASS_BIND (widget_class, GbPreferencesPageEditor, show_diff_switch);
   GB_WIDGET_CLASS_BIND (widget_class, GbPreferencesPageEditor, show_line_numbers_switch);
+  GB_WIDGET_CLASS_BIND (widget_class, GbPreferencesPageEditor, draw_spaces_space);
+  GB_WIDGET_CLASS_BIND (widget_class, GbPreferencesPageEditor, draw_spaces_tab);
+  GB_WIDGET_CLASS_BIND (widget_class, GbPreferencesPageEditor, draw_spaces_newline);
+  GB_WIDGET_CLASS_BIND (widget_class, GbPreferencesPageEditor, draw_spaces_nbsp);
+  GB_WIDGET_CLASS_BIND (widget_class, GbPreferencesPageEditor, draw_spaces_leading);
+  GB_WIDGET_CLASS_BIND (widget_class, GbPreferencesPageEditor, draw_spaces_trailing);
 }
 
 static void
 gb_preferences_page_editor_init (GbPreferencesPageEditor *self)
 {
+  static const gchar *keys[] = { "space", "tab", "newline", "nbsp", "trailing", "leading", NULL };
+  GActionMap *actions;
+  guint i;
+
   gtk_widget_init_template (GTK_WIDGET (self));
 
+  actions = G_ACTION_MAP (g_simple_action_group_new ());
+  gtk_widget_insert_action_group (GTK_WIDGET (self), "editor", G_ACTION_GROUP (actions));
+
+  for (i = 0; keys [i]; i++)
+    {
+      GAction *action;
+
+      action = egg_settings_flag_action_new ("org.gnome.builder.editor", "draw-spaces", keys [i]);
+      g_action_map_add_action (actions, action);
+    }
+
   gb_preferences_page_set_keywords_for_widget (GB_PREFERENCES_PAGE (self),
   /* To translators: This is a list of keywords for the preferences page */
                                                _("restore insert cursor mark"),
@@ -132,4 +160,14 @@ gb_preferences_page_editor_init (GbPreferencesPageEditor *self)
                                                self->show_map_switch,
                                                self->auto_hide_map_switch,
                                                NULL);
+  gb_preferences_page_set_keywords_for_widget (GB_PREFERENCES_PAGE (self),
+  /* To translators: This is a list of keywords for the preferences page */
+                                               _("draw spaces space tab newline nbsp non-breaking whitespace 
trailing leading"),
+                                               self->draw_spaces_space,
+                                               self->draw_spaces_tab,
+                                               self->draw_spaces_newline,
+                                               self->draw_spaces_nbsp,
+                                               self->draw_spaces_leading,
+                                               self->draw_spaces_trailing,
+                                               NULL);
 }


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