[glade] Enhancing GtkComboBoxText editor



commit 8ed9111ee5ce07781fcc3414363f2a1755e25be8
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Mon May 13 18:12:18 2013 +0900

    Enhancing GtkComboBoxText editor
    
    Now the entry related properties are insensitive if 'has-entry' is
    false, added the entry related properties to the GtkComboBoxText editor.

 plugins/gtk+/glade-combo-box-text-editor.ui |   80 +++++++++++++++++++++++++-
 plugins/gtk+/glade-gtk-cell-layout.h        |    2 +
 plugins/gtk+/glade-gtk-combo-box.c          |   35 +++++++++---
 plugins/gtk+/gtk+.xml.in                    |    7 +-
 4 files changed, 109 insertions(+), 15 deletions(-)
---
diff --git a/plugins/gtk+/glade-combo-box-text-editor.ui b/plugins/gtk+/glade-combo-box-text-editor.ui
index 53b5dc4..5b6dc45 100644
--- a/plugins/gtk+/glade-combo-box-text-editor.ui
+++ b/plugins/gtk+/glade-combo-box-text-editor.ui
@@ -49,11 +49,12 @@
             <property name="margin_left">12</property>
             <property name="hexpand">False</property>
             <property name="property_name">glade-items</property>
+            <property name="custom_text" translatable="yes">List of items:</property>
           </object>
           <packing>
             <property name="left_attach">0</property>
             <property name="top_attach">2</property>
-            <property name="width">2</property>
+            <property name="width">5</property>
             <property name="height">1</property>
           </packing>
         </child>
@@ -82,7 +83,7 @@
           </object>
           <packing>
             <property name="left_attach">0</property>
-            <property name="top_attach">6</property>
+            <property name="top_attach">8</property>
             <property name="width">2</property>
             <property name="height">1</property>
           </packing>
@@ -97,7 +98,7 @@
           </object>
           <packing>
             <property name="left_attach">2</property>
-            <property name="top_attach">6</property>
+            <property name="top_attach">8</property>
             <property name="width">3</property>
             <property name="height">1</property>
           </packing>
@@ -142,7 +143,7 @@
           <packing>
             <property name="left_attach">2</property>
             <property name="top_attach">4</property>
-            <property name="width">3</property>
+            <property name="width">2</property>
             <property name="height">1</property>
           </packing>
         </child>
@@ -156,11 +157,78 @@
           <packing>
             <property name="left_attach">2</property>
             <property name="top_attach">5</property>
+            <property name="width">2</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GladePropertyShell" id="has_entry_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">has-entry</property>
+            <property name="editor_type">GladeEpropCheck</property>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">7</property>
+            <property name="width">2</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GladePropertyShell" id="has_frame_editor">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="hexpand">False</property>
+            <property name="property_name">has-frame</property>
+            <property name="editor_type">GladeEpropCheck</property>
+            <property name="custom_text" translatable="yes">Draw frame around entry</property>
+          </object>
+          <packing>
+            <property name="left_attach">2</property>
+            <property name="top_attach">7</property>
             <property name="width">3</property>
             <property name="height">1</property>
           </packing>
         </child>
         <child>
+          <object class="GladePropertyLabel" id="button_sensitivity_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">button-sensitivity</property>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">6</property>
+            <property name="width">2</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GladePropertyShell" id="button_sensitivity_editor">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="hexpand">False</property>
+            <property name="property_name">button-sensitivity</property>
+          </object>
+          <packing>
+            <property name="left_attach">2</property>
+            <property name="top_attach">6</property>
+            <property name="width">2</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
           <placeholder/>
         </child>
         <child>
@@ -198,6 +266,10 @@
       <editor id="active_id_label"/>
       <editor id="active_editor"/>
       <editor id="active_id_editor"/>
+      <editor id="has_entry_editor"/>
+      <editor id="has_frame_editor"/>
+      <editor id="button_sensitivity_label"/>
+      <editor id="button_sensitivity_editor"/>
     </child-editors>
   </template>
 </interface>
diff --git a/plugins/gtk+/glade-gtk-cell-layout.h b/plugins/gtk+/glade-gtk-cell-layout.h
index 5fe3eb6..fee6dca 100644
--- a/plugins/gtk+/glade-gtk-cell-layout.h
+++ b/plugins/gtk+/glade-gtk-cell-layout.h
@@ -39,6 +39,8 @@ gboolean glade_gtk_cell_layout_move_child       (GladeBaseEditor * editor,
                                                 GladeWidget * gparent,
                                                 GladeWidget * gchild,
                                                 gpointer data); 
+GList   *glade_gtk_cell_layout_get_children     (GladeWidgetAdaptor * adaptor,
+                                                GObject * container);
 
 G_END_DECLS
 
diff --git a/plugins/gtk+/glade-gtk-combo-box.c b/plugins/gtk+/glade-gtk-combo-box.c
index eb25d25..3309ccf 100644
--- a/plugins/gtk+/glade-gtk-combo-box.c
+++ b/plugins/gtk+/glade-gtk-combo-box.c
@@ -25,6 +25,33 @@
 #include <glib/gi18n-lib.h>
 #include <gladeui/glade.h>
 
+#include "glade-gtk-cell-layout.h"
+
+#define NO_ENTRY_MSG _("This combo box is not configured to have an entry")
+
+void
+glade_gtk_combo_box_post_create (GladeWidgetAdaptor *adaptor,
+                                GObject            *object, 
+                                GladeCreateReason   reason)
+{
+  GladeWidget *widget;
+
+  /* Chain Up */
+  GWA_GET_CLASS (GTK_TYPE_CONTAINER)->post_create (adaptor, object, reason);
+
+  widget = glade_widget_get_from_gobject (object);
+  if (gtk_combo_box_get_has_entry (GTK_COMBO_BOX (object)))
+    {
+      glade_widget_property_set_sensitive (widget, "entry-text-column", TRUE, NULL);
+      glade_widget_property_set_sensitive (widget, "has-frame", TRUE, NULL);
+    }
+  else
+    {
+      glade_widget_property_set_sensitive (widget, "entry-text-column", FALSE, NO_ENTRY_MSG);
+      glade_widget_property_set_sensitive (widget, "has-frame", FALSE, NO_ENTRY_MSG);
+    }
+}
+
 void
 glade_gtk_combo_box_set_property (GladeWidgetAdaptor * adaptor,
                                   GObject * object,
@@ -48,9 +75,6 @@ glade_gtk_combo_box_set_property (GladeWidgetAdaptor * adaptor,
                                                       object, id, value);
 }
 
-GList *glade_gtk_cell_layout_get_children (GladeWidgetAdaptor * adaptor,
-                                           GObject * container);
-
 GList *
 glade_gtk_combo_box_get_children (GladeWidgetAdaptor * adaptor,
                                   GtkComboBox * combo)
@@ -59,11 +83,6 @@ glade_gtk_combo_box_get_children (GladeWidgetAdaptor * adaptor,
 
   list = glade_gtk_cell_layout_get_children (adaptor, G_OBJECT (combo));
 
-  /* return the internal entry.
-   *
-   * FIXME: for recent gtk+ we have no comboboxentry
-   * but a "has-entry" property instead
-   */
   if (gtk_combo_box_get_has_entry (combo))
     list = g_list_append (list, gtk_bin_get_child (GTK_BIN (combo)));
 
diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in
index 5d49a40..5d6d9fd 100644
--- a/plugins/gtk+/gtk+.xml.in
+++ b/plugins/gtk+/gtk+.xml.in
@@ -1508,6 +1508,7 @@ range of values</_tooltip>
     </glade-widget-class>
 
     <glade-widget-class name="GtkComboBox" generic-name="combobox" _title="Combo Box">
+      <post-create-function>glade_gtk_combo_box_post_create</post-create-function>
       <set-property-function>glade_gtk_combo_box_set_property</set-property-function>
       <add-child-verify-function>glade_gtk_cell_layout_add_verify</add-child-verify-function>
       <add-child-function>glade_gtk_cell_layout_add_child</add-child-function>
@@ -1581,14 +1582,14 @@ range of values</_tooltip>
        <property id="row-span-column" disabled="True"/>
        <property id="column-span-column" disabled="True"/>
        <property id="add-tearoffs" disabled="True"/>
-       <property id="has-frame" disabled="True"/>
        <property id="tearoff-title" disabled="True"/>
-       <property id="has-entry" disabled="True"/>
-       <property id="button-sensitivity" disabled="True"/>
        <property id="entry-text-column" disabled="True"/>
        <property id="id-column" disabled="True"/>
        <property id="cell-area" disabled="True"/>
 
+       <property id="has-entry" custom-layout="True"/>
+       <property id="has-frame" custom-layout="True"/>
+       <property id="button-sensitivity" custom-layout="True"/>
        <property id="active" custom-layout="True"/>
        <property id="active-id" custom-layout="True"/>
        <property id="focus-on-click" custom-layout="True"/>


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