[glade] GladeActivatableEditor: Hide the actionable properties if not actionable.



commit 992a332ccf47bbdedd8492583dd06e910316e95c
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Sun Apr 28 19:02:10 2013 +0900

    GladeActivatableEditor: Hide the actionable properties if not actionable.

 plugins/gtk+/glade-activatable-editor.c  |   43 +++++++++++++++++++++++++++++-
 plugins/gtk+/glade-activatable-editor.ui |   28 ++++++++++++++++---
 2 files changed, 66 insertions(+), 5 deletions(-)
---
diff --git a/plugins/gtk+/glade-activatable-editor.c b/plugins/gtk+/glade-activatable-editor.c
index 7cd7c8f..8f84309 100644
--- a/plugins/gtk+/glade-activatable-editor.c
+++ b/plugins/gtk+/glade-activatable-editor.c
@@ -25,13 +25,21 @@
 
 #include "glade-activatable-editor.h"
 
+static void glade_activatable_editor_editable_init (GladeEditableIface * iface);
 static void glade_activatable_editor_grab_focus (GtkWidget * widget);
 
 struct _GladeActivatableEditorPrivate {
   GtkWidget *embed;
+
+  GtkWidget *action_name_label;
+  GtkWidget *action_name_editor;
 };
 
-G_DEFINE_TYPE (GladeActivatableEditor, glade_activatable_editor, GLADE_TYPE_EDITOR_SKELETON);
+static GladeEditableIface *parent_editable_iface;
+
+G_DEFINE_TYPE_WITH_CODE (GladeActivatableEditor, glade_activatable_editor, GLADE_TYPE_EDITOR_SKELETON,
+                         G_IMPLEMENT_INTERFACE (GLADE_TYPE_EDITABLE,
+                                                glade_activatable_editor_editable_init));
 
 static void
 glade_activatable_editor_class_init (GladeActivatableEditorClass * klass)
@@ -43,6 +51,8 @@ glade_activatable_editor_class_init (GladeActivatableEditorClass * klass)
 
   gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/gladegtk/glade-activatable-editor.ui");
   gtk_widget_class_bind_child (widget_class, GladeActivatableEditorPrivate, embed);
+  gtk_widget_class_bind_child (widget_class, GladeActivatableEditorPrivate, action_name_label);
+  gtk_widget_class_bind_child (widget_class, GladeActivatableEditorPrivate, action_name_editor);
 
   g_type_class_add_private (object_class, sizeof (GladeActivatableEditorPrivate));  
 
@@ -68,6 +78,37 @@ glade_activatable_editor_grab_focus (GtkWidget * widget)
   gtk_widget_grab_focus (activatable_editor->priv->embed);
 }
 
+static void
+glade_activatable_editor_load (GladeEditable *editable,
+                              GladeWidget   *gwidget)
+{
+  GladeActivatableEditor *activatable_editor = GLADE_ACTIVATABLE_EDITOR (editable);
+  GladeActivatableEditorPrivate *priv = activatable_editor->priv;
+  GtkWidget *widget;
+
+  /* Chain up to default implementation */
+  parent_editable_iface->load (editable, gwidget);
+
+  if (gwidget)
+    {
+      gboolean actionable;
+
+      widget = (GtkWidget *)glade_widget_get_object (gwidget);
+      actionable = GTK_IS_ACTIONABLE (widget);
+
+      gtk_widget_set_visible (priv->action_name_label, actionable);
+      gtk_widget_set_visible (priv->action_name_editor, actionable);
+    }
+}
+
+static void
+glade_activatable_editor_editable_init (GladeEditableIface * iface)
+{
+  parent_editable_iface = g_type_interface_peek_parent (iface);
+
+  iface->load = glade_activatable_editor_load;
+}
+
 GtkWidget *
 glade_activatable_editor_new (GladeWidgetAdaptor * adaptor,
                               GladeEditable * embed)
diff --git a/plugins/gtk+/glade-activatable-editor.ui b/plugins/gtk+/glade-activatable-editor.ui
index 1648877..798a103 100644
--- a/plugins/gtk+/glade-activatable-editor.ui
+++ b/plugins/gtk+/glade-activatable-editor.ui
@@ -5,18 +5,24 @@
   <template class="GladeActivatableEditor" parent="GladeEditorSkeleton">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
+    <property name="has_focus">False</property>
+    <property name="is_focus">False</property>
     <property name="orientation">vertical</property>
     <property name="spacing">4</property>
     <child>
       <object class="GtkGrid" id="grid1">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
+        <property name="has_focus">False</property>
+        <property name="is_focus">False</property>
         <property name="row_spacing">6</property>
         <property name="column_spacing">6</property>
         <child>
           <object class="GladePropertyLabel" id="propertylabel1">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
+            <property name="has_focus">False</property>
+            <property name="is_focus">False</property>
             <property name="margin_left">12</property>
             <property name="hexpand">False</property>
             <property name="property_name">related-action</property>
@@ -32,6 +38,8 @@
           <object class="GladePropertyShell" id="propertyshell1">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
+            <property name="has_focus">False</property>
+            <property name="is_focus">False</property>
             <property name="hexpand">True</property>
             <property name="property_name">related-action</property>
           </object>
@@ -46,6 +54,8 @@
           <object class="GladePropertyLabel" id="propertylabel2">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
+            <property name="has_focus">False</property>
+            <property name="is_focus">False</property>
             <property name="margin_left">12</property>
             <property name="hexpand">False</property>
             <property name="property_name">use-action-appearance</property>
@@ -61,6 +71,8 @@
           <object class="GladePropertyShell" id="propertyshell2">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
+            <property name="has_focus">False</property>
+            <property name="is_focus">False</property>
             <property name="hexpand">True</property>
             <property name="property_name">use-action-appearance</property>
           </object>
@@ -72,9 +84,11 @@
           </packing>
         </child>
         <child>
-          <object class="GladePropertyLabel" id="propertylabel3">
+          <object class="GladePropertyLabel" id="action_name_label">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
+            <property name="has_focus">False</property>
+            <property name="is_focus">False</property>
             <property name="margin_left">12</property>
             <property name="hexpand">False</property>
             <property name="property_name">action-name</property>
@@ -87,9 +101,11 @@
           </packing>
         </child>
         <child>
-          <object class="GladePropertyShell" id="propertyshell3">
+          <object class="GladePropertyShell" id="action_name_editor">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
+            <property name="has_focus">False</property>
+            <property name="is_focus">False</property>
             <property name="hexpand">True</property>
             <property name="property_name">action-name</property>
           </object>
@@ -104,6 +120,8 @@
           <object class="GtkLabel" id="label1">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
+            <property name="has_focus">False</property>
+            <property name="is_focus">False</property>
             <property name="halign">start</property>
             <property name="valign">center</property>
             <property name="margin_bottom">2</property>
@@ -124,6 +142,8 @@
           <object class="GladeEditorTable" id="embed">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
+            <property name="has_focus">False</property>
+            <property name="is_focus">False</property>
           </object>
           <packing>
             <property name="left_attach">0</property>
@@ -144,8 +164,8 @@
       <editor id="propertyshell1"/>
       <editor id="propertylabel2"/>
       <editor id="propertyshell2"/>
-      <editor id="propertylabel3"/>
-      <editor id="propertyshell3"/>
+      <editor id="action_name_label"/>
+      <editor id="action_name_editor"/>
       <editor id="embed"/>
     </child-editors>
   </template>


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