[glade] GladeButtonEditor: Now handle all subclasses in this editor.



commit 969e5b20b1d6d3fe7ca3ae64d5b7c2e75c191afe
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Mon Apr 15 15:43:44 2013 +0900

    GladeButtonEditor: Now handle all subclasses in this editor.
    
    Looks much nicer all formatted into the same editor... removed
    the other experimental radio/toggle editors

 plugins/gtk+/Makefile.am                       |   8 +-
 plugins/gtk+/glade-button-editor.c             |  83 ++++++++++++++---
 plugins/gtk+/glade-button-editor.ui            | 118 ++++++++++++++++++++-----
 plugins/gtk+/glade-gtk-resources.gresource.xml |   2 -
 plugins/gtk+/glade-gtk.c                       |   9 +-
 plugins/gtk+/glade-radio-button-editor.c       |  74 ----------------
 plugins/gtk+/glade-radio-button-editor.h       |  56 ------------
 plugins/gtk+/glade-radio-button-editor.ui      |  80 -----------------
 plugins/gtk+/glade-toggle-button-editor.c      |  74 ----------------
 plugins/gtk+/glade-toggle-button-editor.h      |  56 ------------
 plugins/gtk+/glade-toggle-button-editor.ui     |  97 --------------------
 po/POTFILES.in                                 |   4 -
 12 files changed, 169 insertions(+), 492 deletions(-)
---
diff --git a/plugins/gtk+/Makefile.am b/plugins/gtk+/Makefile.am
index d7acbf8..0389709 100644
--- a/plugins/gtk+/Makefile.am
+++ b/plugins/gtk+/Makefile.am
@@ -43,10 +43,8 @@ libgladegtk_la_SOURCES =             \
        glade-image-item-editor.c       \
        glade-label-editor.c            \
        glade-model-data.c              \
-       glade-radio-button-editor.c     \
        glade-store-editor.c            \
        glade-string-list.c             \
-       glade-toggle-button-editor.c    \
        glade-tool-button-editor.c      \
        glade-tool-item-group-editor.c  \
        glade-treeview-editor.c
@@ -71,10 +69,8 @@ noinst_HEADERS =                     \
        glade-image-item-editor.h       \
        glade-label-editor.h            \
        glade-model-data.h              \
-       glade-radio-button-editor.h     \
        glade-store-editor.h            \
        glade-string-list.h             \
-       glade-toggle-button-editor.h    \
        glade-tool-button-editor.h      \
        glade-tool-item-group-editor.h  \
        glade-treeview-editor.h
@@ -104,9 +100,7 @@ BUILT_SOURCES =             \
 
 UI_FILES =                             \
        glade-activatable-editor.ui     \
-       glade-button-editor.ui          \
-       glade-radio-button-editor.ui    \
-       glade-toggle-button-editor.ui
+       glade-button-editor.ui
 
 EXTRA_DIST =                                   \
        $(UI_FILES)                             \
diff --git a/plugins/gtk+/glade-button-editor.c b/plugins/gtk+/glade-button-editor.c
index bc7bd48..f40d2a6 100644
--- a/plugins/gtk+/glade-button-editor.c
+++ b/plugins/gtk+/glade-button-editor.c
@@ -42,6 +42,25 @@ struct _GladeButtonEditorPrivate
 {
   GtkWidget *embed;
 
+  /* Radio Button */
+  GtkWidget *group_label;
+  GtkWidget *group_shell;
+
+  /* Toggle Button */
+  GtkWidget *active_shell;
+  GtkWidget *inconsistent_shell;
+  GtkWidget *draw_indicator_shell;
+
+  /* Button */
+  GtkWidget *content_label;
+  GtkWidget *content_frame;
+
+  GtkWidget *relief_label;
+  GtkWidget *relief_shell;
+
+  GtkWidget *response_label;
+  GtkWidget *response_shell;
+
   GtkWidget *standard_radio; /* Use standard properties to layout a button */
   GtkWidget *custom_radio;   /* Use a placeholder in the button */
 
@@ -77,6 +96,17 @@ glade_button_editor_class_init (GladeButtonEditorClass * klass)
   gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/gladegtk/glade-button-editor.ui");
 
   gtk_widget_class_bind_child (widget_class, GladeButtonEditorPrivate, embed);
+  gtk_widget_class_bind_child (widget_class, GladeButtonEditorPrivate, relief_label);
+  gtk_widget_class_bind_child (widget_class, GladeButtonEditorPrivate, relief_shell);
+  gtk_widget_class_bind_child (widget_class, GladeButtonEditorPrivate, response_label);
+  gtk_widget_class_bind_child (widget_class, GladeButtonEditorPrivate, response_shell);
+  gtk_widget_class_bind_child (widget_class, GladeButtonEditorPrivate, content_label);
+  gtk_widget_class_bind_child (widget_class, GladeButtonEditorPrivate, content_frame);
+  gtk_widget_class_bind_child (widget_class, GladeButtonEditorPrivate, group_shell);
+  gtk_widget_class_bind_child (widget_class, GladeButtonEditorPrivate, group_label);
+  gtk_widget_class_bind_child (widget_class, GladeButtonEditorPrivate, active_shell);
+  gtk_widget_class_bind_child (widget_class, GladeButtonEditorPrivate, inconsistent_shell);
+  gtk_widget_class_bind_child (widget_class, GladeButtonEditorPrivate, draw_indicator_shell);
   gtk_widget_class_bind_child (widget_class, GladeButtonEditorPrivate, standard_radio);
   gtk_widget_class_bind_child (widget_class, GladeButtonEditorPrivate, custom_radio);
   gtk_widget_class_bind_child (widget_class, GladeButtonEditorPrivate, stock_radio);
@@ -108,16 +138,45 @@ static void
 glade_button_editor_load (GladeEditable * editable, GladeWidget * widget)
 {
   GladeButtonEditor *button_editor = GLADE_BUTTON_EDITOR (editable);
+  GladeButtonEditorPrivate *priv = button_editor->priv;
   GladeWidget *gchild = NULL;
   GtkWidget *child, *button;
   gboolean use_stock = FALSE;
 
+  if (widget)
+    button = GTK_WIDGET (glade_widget_get_object (widget));
+
+  /* If the widget changed, adjust some visibility
+   */
+  if (widget && glade_editable_loaded_widget (editable) != widget)
+    {
+      gboolean is_toggle = GTK_IS_TOGGLE_BUTTON (button);
+      gboolean is_check  = GTK_IS_CHECK_BUTTON (button);
+      gboolean is_radio  = GTK_IS_RADIO_BUTTON (button);
+      gboolean is_menu   = GTK_IS_MENU_BUTTON (button);
+
+      gtk_widget_set_visible (priv->active_shell, is_toggle);
+      gtk_widget_set_visible (priv->inconsistent_shell, is_toggle);
+      gtk_widget_set_visible (priv->draw_indicator_shell, is_toggle);
+
+      gtk_widget_set_visible (priv->relief_label, !is_check);
+      gtk_widget_set_visible (priv->relief_shell, !is_check);
+
+      gtk_widget_set_visible (priv->response_label, !is_toggle);
+      gtk_widget_set_visible (priv->response_shell, !is_toggle);
+
+      gtk_widget_set_visible (priv->group_label, is_radio);
+      gtk_widget_set_visible (priv->group_shell, is_radio);
+
+      gtk_widget_set_visible (priv->content_label, !is_menu);
+      gtk_widget_set_visible (priv->content_frame, !is_menu);
+    }
+
   /* Chain up to default implementation */
   parent_editable_iface->load (editable, widget);
 
   if (widget)
     {
-      button = GTK_WIDGET (glade_widget_get_object (widget));
       child = gtk_bin_get_child (GTK_BIN (button));
       if (child)
         gchild = glade_widget_get_from_gobject (child);
@@ -127,32 +186,30 @@ glade_button_editor_load (GladeEditable * editable, GladeWidget * widget)
           GLADE_IS_PLACEHOLDER (child)) // placeholder there, custom mode
         {
           /* Custom */
-          gtk_widget_set_sensitive (button_editor->priv->standard_frame, FALSE);
+          gtk_widget_set_sensitive (priv->standard_frame, FALSE);
           gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
-                                        (button_editor->priv->custom_radio), TRUE);
+                                        (priv->custom_radio), TRUE);
         }
       else
         {
           /* Standard */
-          gtk_widget_set_sensitive (button_editor->priv->standard_frame, TRUE);
+          gtk_widget_set_sensitive (priv->standard_frame, TRUE);
           gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
-                                        (button_editor->priv->standard_radio), TRUE);
+                                        (priv->standard_radio), TRUE);
 
           glade_widget_property_get (widget, "use-stock", &use_stock);
 
           if (use_stock)
             {
-              gtk_widget_set_sensitive (button_editor->priv->stock_frame, TRUE);
-              gtk_widget_set_sensitive (button_editor->priv->label_frame, FALSE);
-              gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
-                                            (button_editor->priv->stock_radio), TRUE);
+              gtk_widget_set_sensitive (priv->stock_frame, TRUE);
+              gtk_widget_set_sensitive (priv->label_frame, FALSE);
+              gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->stock_radio), TRUE);
             }
           else
             {
-              gtk_widget_set_sensitive (button_editor->priv->stock_frame, FALSE);
-              gtk_widget_set_sensitive (button_editor->priv->label_frame, TRUE);
-              gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
-                                            (button_editor->priv->label_radio), TRUE);
+              gtk_widget_set_sensitive (priv->stock_frame, FALSE);
+              gtk_widget_set_sensitive (priv->label_frame, TRUE);
+              gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->label_radio), TRUE);
             }
         }
     }
diff --git a/plugins/gtk+/glade-button-editor.ui b/plugins/gtk+/glade-button-editor.ui
index 4ad7c84..8c613ca 100644
--- a/plugins/gtk+/glade-button-editor.ui
+++ b/plugins/gtk+/glade-button-editor.ui
@@ -46,53 +46,53 @@
         <property name="row_spacing">6</property>
         <property name="column_spacing">6</property>
         <child>
-          <object class="GladePropertyLabel" id="propertylabel8">
+          <object class="GladePropertyLabel" id="response_label">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="property_name">response-id</property>
           </object>
           <packing>
             <property name="left_attach">0</property>
-            <property name="top_attach">1</property>
+            <property name="top_attach">2</property>
             <property name="width">1</property>
             <property name="height">1</property>
           </packing>
         </child>
         <child>
-          <object class="GladePropertyShell" id="propertyshell12">
+          <object class="GladePropertyShell" id="response_shell">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="property_name">response-id</property>
           </object>
           <packing>
             <property name="left_attach">1</property>
-            <property name="top_attach">1</property>
+            <property name="top_attach">2</property>
             <property name="width">1</property>
             <property name="height">1</property>
           </packing>
         </child>
         <child>
-          <object class="GladePropertyLabel" id="propertylabel7">
+          <object class="GladePropertyLabel" id="relief_label">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="property_name">relief</property>
           </object>
           <packing>
             <property name="left_attach">0</property>
-            <property name="top_attach">0</property>
+            <property name="top_attach">1</property>
             <property name="width">1</property>
             <property name="height">1</property>
           </packing>
         </child>
         <child>
-          <object class="GladePropertyShell" id="propertyshell11">
+          <object class="GladePropertyShell" id="relief_shell">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="property_name">relief</property>
           </object>
           <packing>
             <property name="left_attach">1</property>
-            <property name="top_attach">0</property>
+            <property name="top_attach">1</property>
             <property name="width">1</property>
             <property name="height">1</property>
           </packing>
@@ -107,7 +107,7 @@
           </object>
           <packing>
             <property name="left_attach">0</property>
-            <property name="top_attach">2</property>
+            <property name="top_attach">3</property>
             <property name="width">1</property>
             <property name="height">1</property>
           </packing>
@@ -122,7 +122,7 @@
           </object>
           <packing>
             <property name="left_attach">0</property>
-            <property name="top_attach">3</property>
+            <property name="top_attach">4</property>
             <property name="width">1</property>
             <property name="height">1</property>
           </packing>
@@ -137,7 +137,7 @@
           </object>
           <packing>
             <property name="left_attach">0</property>
-            <property name="top_attach">4</property>
+            <property name="top_attach">5</property>
             <property name="width">1</property>
             <property name="height">1</property>
           </packing>
@@ -150,7 +150,7 @@
           </object>
           <packing>
             <property name="left_attach">1</property>
-            <property name="top_attach">3</property>
+            <property name="top_attach">4</property>
             <property name="width">1</property>
             <property name="height">1</property>
           </packing>
@@ -163,7 +163,7 @@
           </object>
           <packing>
             <property name="left_attach">1</property>
-            <property name="top_attach">4</property>
+            <property name="top_attach">5</property>
             <property name="width">1</property>
             <property name="height">1</property>
           </packing>
@@ -179,13 +179,84 @@
           </object>
           <packing>
             <property name="left_attach">0</property>
-            <property name="top_attach">5</property>
+            <property name="top_attach">6</property>
             <property name="width">1</property>
             <property name="height">1</property>
           </packing>
         </child>
         <child>
-          <placeholder/>
+          <object class="GladePropertyShell" id="active_shell">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="halign">start</property>
+            <property name="valign">center</property>
+            <property name="property_name">active</property>
+            <property name="editor_type">GladeEpropCheck</property>
+          </object>
+          <packing>
+            <property name="left_attach">1</property>
+            <property name="top_attach">6</property>
+            <property name="width">1</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GladePropertyShell" id="inconsistent_shell">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="halign">start</property>
+            <property name="valign">center</property>
+            <property name="property_name">inconsistent</property>
+            <property name="editor_type">GladeEpropCheck</property>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">7</property>
+            <property name="width">1</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GladePropertyShell" id="draw_indicator_shell">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="halign">start</property>
+            <property name="valign">center</property>
+            <property name="property_name">draw-indicator</property>
+            <property name="editor_type">GladeEpropCheck</property>
+          </object>
+          <packing>
+            <property name="left_attach">1</property>
+            <property name="top_attach">7</property>
+            <property name="width">1</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GladePropertyLabel" id="group_label">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="property_name">group</property>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">0</property>
+            <property name="width">1</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GladePropertyShell" id="group_shell">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="property_name">group</property>
+          </object>
+          <packing>
+            <property name="left_attach">1</property>
+            <property name="top_attach">0</property>
+            <property name="width">1</property>
+            <property name="height">1</property>
+          </packing>
         </child>
         <child>
           <placeholder/>
@@ -198,7 +269,7 @@
       </packing>
     </child>
     <child>
-      <object class="GtkLabel" id="label3">
+      <object class="GtkLabel" id="content_label">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <property name="halign">start</property>
@@ -215,7 +286,7 @@
       </packing>
     </child>
     <child>
-      <object class="GtkFrame" id="frame1">
+      <object class="GtkFrame" id="content_frame">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <property name="label_xalign">0</property>
@@ -553,15 +624,20 @@
     </child>
     <child-editors>
       <editor id="embed"/>
-      <editor id="propertylabel8"/>
-      <editor id="propertyshell12"/>
-      <editor id="propertylabel7"/>
-      <editor id="propertyshell11"/>
+      <editor id="response_label"/>
+      <editor id="response_shell"/>
+      <editor id="relief_label"/>
+      <editor id="relief_shell"/>
       <editor id="propertylabel3"/>
       <editor id="propertylabel4"/>
       <editor id="propertyshell9"/>
       <editor id="propertyshell10"/>
       <editor id="propertyshell13"/>
+      <editor id="active_shell"/>
+      <editor id="inconsistent_shell"/>
+      <editor id="draw_indicator_shell"/>
+      <editor id="group_label"/>
+      <editor id="group_shell"/>
       <editor id="propertylabel1"/>
       <editor id="propertylabel2"/>
       <editor id="propertyshell2"/>
diff --git a/plugins/gtk+/glade-gtk-resources.gresource.xml b/plugins/gtk+/glade-gtk-resources.gresource.xml
index 9c9a4d4..c0b13b3 100644
--- a/plugins/gtk+/glade-gtk-resources.gresource.xml
+++ b/plugins/gtk+/glade-gtk-resources.gresource.xml
@@ -3,7 +3,5 @@
   <gresource prefix="/org/gnome/gladegtk">
     <file compressed="true" preprocess="xml-stripblanks">glade-activatable-editor.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">glade-button-editor.ui</file>
-    <file compressed="true" preprocess="xml-stripblanks">glade-radio-button-editor.ui</file>
-    <file compressed="true" preprocess="xml-stripblanks">glade-toggle-button-editor.ui</file>
   </gresource>
 </gresources>
diff --git a/plugins/gtk+/glade-gtk.c b/plugins/gtk+/glade-gtk.c
index 0dd1c3c..b731c70 100644
--- a/plugins/gtk+/glade-gtk.c
+++ b/plugins/gtk+/glade-gtk.c
@@ -42,8 +42,6 @@
 #include "glade-entry-editor.h"
 #include "glade-activatable-editor.h"
 #include "glade-tool-item-group-editor.h"
-#include "glade-toggle-button-editor.h"
-#include "glade-radio-button-editor.h"
 #include "glade-string-list.h"
 #include "glade-fixed.h"
 #include "glade-gtk-action-widgets.h"
@@ -3713,12 +3711,7 @@ glade_gtk_button_create_editable (GladeWidgetAdaptor * adaptor,
 {
   if (type == GLADE_PAGE_GENERAL)
     {
-      if (g_type_is_a (glade_widget_adaptor_get_object_type (adaptor), GTK_TYPE_RADIO_BUTTON))
-       return (GladeEditable *) glade_radio_button_editor_new ();
-      else if (g_type_is_a (glade_widget_adaptor_get_object_type (adaptor), GTK_TYPE_TOGGLE_BUTTON))
-       return (GladeEditable *) glade_toggle_button_editor_new ();
-      else
-       return (GladeEditable *) glade_button_editor_new (adaptor, NULL);
+      return (GladeEditable *) glade_button_editor_new (adaptor, NULL);
     }
 
   return GWA_GET_CLASS (GTK_TYPE_CONTAINER)->create_editable (adaptor, type);
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 37a08c1..eb41f4d 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -69,10 +69,8 @@ plugins/gtk+/glade-image-editor.c
 plugins/gtk+/glade-image-item-editor.c
 plugins/gtk+/glade-label-editor.c
 plugins/gtk+/glade-model-data.c
-plugins/gtk+/glade-radio-button-editor.c
 plugins/gtk+/glade-store-editor.c
 plugins/gtk+/glade-string-list.c
-plugins/gtk+/glade-toggle-button-editor.c
 plugins/gtk+/glade-tool-button-editor.c
 plugins/gtk+/glade-tool-item-group-editor.c
 plugins/gtk+/glade-treeview-editor.c
@@ -80,5 +78,3 @@ plugins/gtk+/gtkunixprint.xml.in
 plugins/gtk+/gtk+.xml.in
 [type: gettext/glade]plugins/gtk+/glade-activatable-editor.ui
 [type: gettext/glade]plugins/gtk+/glade-button-editor.ui
-[type: gettext/glade]plugins/gtk+/glade-radio-button-editor.ui
-[type: gettext/glade]plugins/gtk+/glade-toggle-button-editor.ui


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