[gnome-builder] editor: use properties group from dazzle



commit 37bdee9ce92cc3169abee2096653da6e88da3c2f
Author: Christian Hergert <chergert redhat com>
Date:   Fri Jul 7 02:49:09 2017 -0700

    editor: use properties group from dazzle
    
    This still doesn't work for our "insert-spaces-instead-of-tabs" case,
    but in all honestly, I consider that a Gtk but in that it's action
    helper does not know how to deal with stateful vs actionable GAction.
    
    We need to work around it like we did previously (which was to create
    our own stateful GSimpleAction and keep it up to date).

 libide/editor/ide-editor-properties.ui  |   28 +++++++++++++++-------------
 libide/editor/ide-editor-view-actions.c |   21 +++++++++++----------
 2 files changed, 26 insertions(+), 23 deletions(-)
---
diff --git a/libide/editor/ide-editor-properties.ui b/libide/editor/ide-editor-properties.ui
index a2f0bf3..25765e4 100644
--- a/libide/editor/ide-editor-properties.ui
+++ b/libide/editor/ide-editor-properties.ui
@@ -31,7 +31,7 @@
                 <property name="text" translatable="yes">Show line numbers</property>
                 <property name="role">check</property>
                 <property name="halign">fill</property>
-                <property name="action-name">editor-view.show-line-numbers</property>
+                <property name="action-name">source-view.show-line-numbers</property>
               </object>
             </child>
             <child>
@@ -40,7 +40,7 @@
                 <property name="text" translatable="yes">Show right margin</property>
                 <property name="role">check</property>
                 <property name="halign">fill</property>
-                <property name="action-name">editor-view.show-right-margin</property>
+                <property name="action-name">source-view.show-right-margin</property>
               </object>
             </child>
             <child>
@@ -49,7 +49,7 @@
                 <property name="text" translatable="yes">Highlight current line</property>
                 <property name="role">check</property>
                 <property name="halign">fill</property>
-                <property name="action-name">editor-view.highlight-current-line</property>
+                <property name="action-name">source-view.highlight-current-line</property>
               </object>
             </child>
             <child>
@@ -72,7 +72,7 @@
                 <property name="visible">true</property>
                 <property name="text" translatable="yes">Auto indent</property>
                 <property name="halign">fill</property>
-                <property name="action-name">editor-view.auto-indent</property>
+                <property name="action-name">source-view.auto-indent</property>
               </object>
             </child>
             <child>
@@ -80,7 +80,7 @@
                 <property name="visible">true</property>
                 <property name="text" translatable="yes">Smart Backspace</property>
                 <property name="halign">fill</property>
-                <property name="action-name">editor-view.smart-backspace</property>
+                <property name="action-name">source-view.smart-backspace</property>
               </object>
             </child>
             <child>
@@ -102,22 +102,24 @@
                       <class name="linked"/>
                     </style>
                     <child>
-                      <object class="GtkToggleButton">
+                      <object class="GtkRadioButton">
+                        <property name="draw-indicator">false</property>
                         <property name="visible">true</property>
                         <property name="label" translatable="yes">Spaces</property>
                         <property name="focus-on-click">false</property>
                         <property name="halign">fill</property>
-                        <property name="action-name">editor-view.insert-spaces-instead-of-tabs</property>
+                        <property name="action-name">source-view.insert-spaces-instead-of-tabs</property>
                         <property name="action-target">true</property>
                       </object>
                     </child>
                     <child>
-                      <object class="GtkToggleButton" id="tabs_button">
+                      <object class="GtkRadioButton" id="tabs_button">
+                        <property name="draw-indicator">false</property>
                         <property name="visible">true</property>
                         <property name="label" translatable="yes">Tabs</property>
                         <property name="focus-on-click">false</property>
                         <property name="halign">fill</property>
-                        <property name="action-name">editor-view.insert-spaces-instead-of-tabs</property>
+                        <property name="action-name">source-view.insert-spaces-instead-of-tabs</property>
                         <property name="action-target">false</property>
                       </object>
                     </child>
@@ -137,7 +139,7 @@
                         <property name="label" translatable="yes">2</property>
                         <property name="focus-on-click">false</property>
                         <property name="halign">fill</property>
-                        <property name="action-name">editor-view.tab-width</property>
+                        <property name="action-name">source-view.tab-width</property>
                         <property name="action-target">uint32 2</property>
                       </object>
                     </child>
@@ -147,7 +149,7 @@
                         <property name="label" translatable="yes">3</property>
                         <property name="focus-on-click">false</property>
                         <property name="halign">fill</property>
-                        <property name="action-name">editor-view.tab-width</property>
+                        <property name="action-name">source-view.tab-width</property>
                         <property name="action-target">uint32 3</property>
                       </object>
                     </child>
@@ -157,7 +159,7 @@
                         <property name="label" translatable="yes">4</property>
                         <property name="focus-on-click">false</property>
                         <property name="halign">fill</property>
-                        <property name="action-name">editor-view.tab-width</property>
+                        <property name="action-name">source-view.tab-width</property>
                         <property name="action-target">uint32 4</property>
                       </object>
                     </child>
@@ -167,7 +169,7 @@
                         <property name="label" translatable="yes">8</property>
                         <property name="focus-on-click">false</property>
                         <property name="halign">fill</property>
-                        <property name="action-name">editor-view.tab-width</property>
+                        <property name="action-name">source-view.tab-width</property>
                         <property name="action-target">uint32 8</property>
                       </object>
                     </child>
diff --git a/libide/editor/ide-editor-view-actions.c b/libide/editor/ide-editor-view-actions.c
index 047269b..9c616c2 100644
--- a/libide/editor/ide-editor-view-actions.c
+++ b/libide/editor/ide-editor-view-actions.c
@@ -396,6 +396,7 @@ void
 _ide_editor_view_init_actions (IdeEditorView *self)
 {
   g_autoptr(GSimpleActionGroup) group = NULL;
+  g_autoptr(DzlPropertiesGroup) properties = NULL;
 
   g_return_if_fail (IDE_IS_EDITOR_VIEW (self));
 
@@ -405,20 +406,20 @@ _ide_editor_view_init_actions (IdeEditorView *self)
                                    G_N_ELEMENTS (editor_view_entries),
                                    self);
 
+  /* We want to access some settings properties as stateful GAction so they
+   * manipulated using regular Gtk widgets from the properties panel.
+   */
+  properties = dzl_properties_group_new (G_OBJECT (self->source_view));
   for (guint i = 0; i < G_N_ELEMENTS (source_view_property_actions); i++)
     {
       const gchar *name = source_view_property_actions[i];
-      g_autoptr(GPropertyAction) action = NULL;
-
-      /* Warning: GPropertyAction takes a reference on the object, which in
-       * this case is our sourceview. That means we must be diligent in
-       * removing/destroying our actions when GtkWidgetClass.destroy() is
-       * called.
-       */
-
-      action = g_property_action_new (name, self->source_view, name);
-      g_action_map_add_action (G_ACTION_MAP (group), G_ACTION (action));
+      dzl_properties_group_add_property (properties, name, name);
     }
 
+  /* Our groups will be copied up to be accessed outside of our widget
+   * hierarchy. So we expose them all on the IdeEditorView directly
+   * for that purpose.
+   */
   gtk_widget_insert_action_group (GTK_WIDGET (self), "editor-view", G_ACTION_GROUP (group));
+  gtk_widget_insert_action_group (GTK_WIDGET (self), "source-view", G_ACTION_GROUP (properties));
 }


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