[glade] Fold GtkToggleAction and GtkRadioAction properties into the Action editor.



commit edcc8eb9876d04bd0e39dec8667be4d5850ccee1
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Sun May 5 21:04:44 2013 +0900

    Fold GtkToggleAction and GtkRadioAction properties into the Action editor.

 plugins/gtk+/glade-action-editor.c  |   60 ++++++++++++++-
 plugins/gtk+/glade-action-editor.ui |  143 +++++++++++++++++++++++++++++++++-
 plugins/gtk+/gtk+.xml.in            |    9 ++-
 3 files changed, 204 insertions(+), 8 deletions(-)
---
diff --git a/plugins/gtk+/glade-action-editor.c b/plugins/gtk+/glade-action-editor.c
index ff6bb46..41ee87f 100644
--- a/plugins/gtk+/glade-action-editor.c
+++ b/plugins/gtk+/glade-action-editor.c
@@ -25,14 +25,28 @@
 
 #include "glade-action-editor.h"
 
+static void glade_action_editor_editable_init (GladeEditableIface * iface);
 static void glade_action_editor_grab_focus (GtkWidget * widget);
 
 struct _GladeActionEditorPrivate {
   GtkWidget *embed;
   GtkWidget *extension_port;
+
+  /* GtkToggleAction/GtkRadioAction widgets */
+  GtkWidget *toggle_title;
+  GtkWidget *radio_proxy_editor;
+  GtkWidget *toggle_active_editor;
+  GtkWidget *radio_group_label;
+  GtkWidget *radio_group_editor;
+  GtkWidget *radio_value_label;
+  GtkWidget *radio_value_editor;
 };
 
-G_DEFINE_TYPE (GladeActionEditor, glade_action_editor, GLADE_TYPE_EDITOR_SKELETON)
+static GladeEditableIface *parent_editable_iface;
+
+G_DEFINE_TYPE_WITH_CODE (GladeActionEditor, glade_action_editor, GLADE_TYPE_EDITOR_SKELETON,
+                         G_IMPLEMENT_INTERFACE (GLADE_TYPE_EDITABLE,
+                                                glade_action_editor_editable_init));
 
 static void
 glade_action_editor_class_init (GladeActionEditorClass * klass)
@@ -43,8 +57,15 @@ glade_action_editor_class_init (GladeActionEditorClass * klass)
   widget_class->grab_focus = glade_action_editor_grab_focus;
 
   gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/gladegtk/glade-action-editor.ui");
-  gtk_widget_class_bind_child (widget_class, GladeActionEditorPrivate, embed);
   gtk_widget_class_bind_child_internal (widget_class, GladeActionEditorPrivate, extension_port);
+  gtk_widget_class_bind_child (widget_class, GladeActionEditorPrivate, embed);
+  gtk_widget_class_bind_child (widget_class, GladeActionEditorPrivate, toggle_title);
+  gtk_widget_class_bind_child (widget_class, GladeActionEditorPrivate, radio_proxy_editor);
+  gtk_widget_class_bind_child (widget_class, GladeActionEditorPrivate, toggle_active_editor);
+  gtk_widget_class_bind_child (widget_class, GladeActionEditorPrivate, radio_group_label);
+  gtk_widget_class_bind_child (widget_class, GladeActionEditorPrivate, radio_group_editor);
+  gtk_widget_class_bind_child (widget_class, GladeActionEditorPrivate, radio_value_label);
+  gtk_widget_class_bind_child (widget_class, GladeActionEditorPrivate, radio_value_editor);
 
   g_type_class_add_private (object_class, sizeof (GladeActionEditorPrivate));  
 }
@@ -69,6 +90,41 @@ glade_action_editor_grab_focus (GtkWidget * widget)
   gtk_widget_grab_focus (action_editor->priv->embed);
 }
 
+static void
+glade_action_editor_load (GladeEditable *editable,
+                         GladeWidget   *gwidget)
+{
+  GladeActionEditor *action_editor = GLADE_ACTION_EDITOR (editable);
+  GladeActionEditorPrivate *priv = action_editor->priv;
+
+  /* Chain up to default implementation */
+  parent_editable_iface->load (editable, gwidget);
+
+  if (gwidget)
+    {
+      GObject *object = glade_widget_get_object (gwidget);
+      gboolean is_toggle = GTK_IS_TOGGLE_ACTION (object);
+      gboolean is_radio = GTK_IS_RADIO_ACTION (object);
+
+      /* Update subclass specific editor visibility */
+      gtk_widget_set_visible (priv->toggle_title, is_toggle);
+      gtk_widget_set_visible (priv->radio_proxy_editor, is_toggle);
+      gtk_widget_set_visible (priv->toggle_active_editor, is_toggle);
+      gtk_widget_set_visible (priv->radio_group_label, is_radio);
+      gtk_widget_set_visible (priv->radio_group_editor, is_radio);
+      gtk_widget_set_visible (priv->radio_value_label, is_radio);
+      gtk_widget_set_visible (priv->radio_value_editor, is_radio);
+    }
+}
+
+static void
+glade_action_editor_editable_init (GladeEditableIface * iface)
+{
+  parent_editable_iface = g_type_interface_peek_parent (iface);
+
+  iface->load = glade_action_editor_load;
+}
+
 /*************************************
  *                API                *
  *************************************/
diff --git a/plugins/gtk+/glade-action-editor.ui b/plugins/gtk+/glade-action-editor.ui
index 515bc6f..ab2b513 100644
--- a/plugins/gtk+/glade-action-editor.ui
+++ b/plugins/gtk+/glade-action-editor.ui
@@ -276,7 +276,7 @@
           </object>
           <packing>
             <property name="left_attach">0</property>
-            <property name="top_attach">12</property>
+            <property name="top_attach">16</property>
             <property name="width">6</property>
             <property name="height">1</property>
           </packing>
@@ -292,7 +292,7 @@
           </object>
           <packing>
             <property name="left_attach">0</property>
-            <property name="top_attach">13</property>
+            <property name="top_attach">17</property>
             <property name="width">2</property>
             <property name="height">1</property>
           </packing>
@@ -308,7 +308,7 @@
           </object>
           <packing>
             <property name="left_attach">0</property>
-            <property name="top_attach">14</property>
+            <property name="top_attach">18</property>
             <property name="width">2</property>
             <property name="height">1</property>
           </packing>
@@ -323,7 +323,7 @@
           </object>
           <packing>
             <property name="left_attach">2</property>
-            <property name="top_attach">13</property>
+            <property name="top_attach">17</property>
             <property name="width">2</property>
             <property name="height">1</property>
           </packing>
@@ -338,7 +338,7 @@
           </object>
           <packing>
             <property name="left_attach">2</property>
-            <property name="top_attach">14</property>
+            <property name="top_attach">18</property>
             <property name="width">2</property>
             <property name="height">1</property>
           </packing>
@@ -372,6 +372,133 @@
           </packing>
         </child>
         <child>
+          <object class="GtkLabel" id="toggle_title">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="halign">start</property>
+            <property name="valign">center</property>
+            <property name="label" translatable="yes">Toggle and Radio</property>
+            <attributes>
+              <attribute name="weight" value="bold"/>
+            </attributes>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">12</property>
+            <property name="width">6</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GladePropertyLabel" id="radio_group_label">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="margin_left">12</property>
+            <property name="hexpand">False</property>
+            <property name="property_name">group</property>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">13</property>
+            <property name="width">2</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GladePropertyLabel" id="radio_value_label">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="margin_left">12</property>
+            <property name="hexpand">False</property>
+            <property name="property_name">value</property>
+            <property name="custom_text" translatable="yes">Value ID:</property>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">14</property>
+            <property name="width">2</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GladePropertyShell" id="radio_group_editor">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="hexpand">False</property>
+            <property name="property_name">group</property>
+          </object>
+          <packing>
+            <property name="left_attach">2</property>
+            <property name="top_attach">13</property>
+            <property name="width">2</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GladePropertyShell" id="radio_value_editor">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="hexpand">False</property>
+            <property name="property_name">value</property>
+          </object>
+          <packing>
+            <property name="left_attach">2</property>
+            <property name="top_attach">14</property>
+            <property name="width">2</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GladePropertyShell" id="toggle_active_editor">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="margin_left">12</property>
+            <property name="hexpand">False</property>
+            <property name="property_name">active</property>
+            <property name="editor_type">GladeEpropCheck</property>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">15</property>
+            <property name="width">2</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GladePropertyShell" id="radio_proxy_editor">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="hexpand">False</property>
+            <property name="property_name">draw-as-radio</property>
+            <property name="editor_type">GladeEpropCheck</property>
+            <property name="custom_text">Radio proxies</property>
+          </object>
+          <packing>
+            <property name="left_attach">2</property>
+            <property name="top_attach">15</property>
+            <property name="width">2</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
           <placeholder/>
         </child>
         <child>
@@ -454,6 +581,12 @@
       <editor id="is_important_editor"/>
       <editor id="accel_label"/>
       <editor id="accel_editor"/>
+      <editor id="radio_group_label"/>
+      <editor id="radio_value_label"/>
+      <editor id="radio_group_editor"/>
+      <editor id="radio_value_editor"/>
+      <editor id="toggle_active_editor"/>
+      <editor id="radio_proxy_editor"/>
     </child-editors>
   </template>
 </interface>
diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in
index 420957e..a36cdad 100644
--- a/plugins/gtk+/gtk+.xml.in
+++ b/plugins/gtk+/gtk+.xml.in
@@ -2512,9 +2512,16 @@ embedded in another object</_tooltip>
       </properties>
     </glade-widget-class>
 
-    <glade-widget-class name="GtkToggleAction" generic-name="toggleaction" _title="Toggle Action" />
+    <glade-widget-class name="GtkToggleAction" generic-name="toggleaction" _title="Toggle Action">
+      <properties>
+       <property id="active" custom-layout="True"/>
+       <property id="draw-as-radio" custom-layout="True"/>
+      </properties>
+    </glade-widget-class>
     <glade-widget-class name="GtkRadioAction" generic-name="radioaction" _title="Radio Action">
       <properties>
+       <property id="value" custom-layout="True"/>
+       <property id="group" custom-layout="True"/>
        <property id="current-value" disabled="True"/>
       </properties>
     </glade-widget-class>


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