[glade/composite-templates-new: 1/4] GtkButton adaptor: Fix the response id property load and save



commit f7d1f246046660848fea1d6d8e1129357bf0adf6
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Sun Mar 31 15:06:34 2013 +0900

    GtkButton adaptor: Fix the response id property load and save
    
    Make the response id optional in the UI. If the user never sets the
    response ID, then it will not be serialized in <action-widgets> of
    a dialog or info bar.
    
    This is needed because some buttons added to the action are not
    response widgets (for instance, the credits and licence pages of
    GtkAboutDialog) so it's important to not serialize them as such
    unless they are explicitly marked as response widgets.

 plugins/gtk+/glade-gtk-action-widgets.c |    6 ++++++
 plugins/gtk+/glade-gtk.c                |   16 ++++------------
 plugins/gtk+/gtk+.xml.in                |    3 ++-
 3 files changed, 12 insertions(+), 13 deletions(-)
---
diff --git a/plugins/gtk+/glade-gtk-action-widgets.c b/plugins/gtk+/glade-gtk-action-widgets.c
index c386d0a..3b4bc96 100644
--- a/plugins/gtk+/glade-gtk-action-widgets.c
+++ b/plugins/gtk+/glade-gtk-action-widgets.c
@@ -67,8 +67,11 @@ glade_gtk_action_widgets_read_responses (GladeWidget *widget,
       widget_name = glade_xml_get_content (node);
 
       if ((action_widget = glade_widget_find_child (action_area, widget_name)))
+       {
+         glade_widget_property_set_enabled (action_widget, "response-id", TRUE);
           glade_widget_property_set (action_widget, "response-id",
                                      g_ascii_strtoll (response, NULL, 10));
+       }
 
       g_free (response);
       g_free (widget_name);
@@ -118,6 +121,9 @@ glade_gtk_action_widgets_write_responses (GladeWidget *widget,
            glade_widget_get_property (action_widget, "response-id")) == NULL)
         continue;
 
+      if (!glade_property_get_enabled (property))
+       continue;
+
       widget_node = glade_xml_node_new (context, GLADE_TAG_ACTION_WIDGET);
       glade_xml_node_append_child (node, widget_node);
 
diff --git a/plugins/gtk+/glade-gtk.c b/plugins/gtk+/glade-gtk.c
index 11354a1..7804bd9 100644
--- a/plugins/gtk+/glade-gtk.c
+++ b/plugins/gtk+/glade-gtk.c
@@ -1680,18 +1680,11 @@ fix_response_id_on_child (GladeWidget * gbox, GObject * child, gboolean add)
     {
       if (add && (internal_name = glade_widget_get_internal (gbox)) &&
           !strcmp (internal_name, "action_area"))
-        {
-          glade_widget_property_set_sensitive (gchild, "response-id", TRUE,
-                                               NULL);
-          glade_widget_property_set_enabled (gchild, "response-id", TRUE);
-        }
+       glade_widget_property_set_sensitive (gchild, "response-id", TRUE,
+                                            NULL);
       else
-        {
-          glade_widget_property_set_sensitive (gchild, "response-id", FALSE,
-                                               RESPID_INSENSITIVE_MSG);
-          glade_widget_property_set_enabled (gchild, "response-id", FALSE);
-
-        }
+       glade_widget_property_set_sensitive (gchild, "response-id", FALSE,
+                                            RESPID_INSENSITIVE_MSG);
     }
 }
 
@@ -4216,7 +4209,6 @@ glade_gtk_button_post_create (GladeWidgetAdaptor * adaptor,
   /* Disabled response-id until its in an action area */
   glade_widget_property_set_sensitive (gbutton, "response-id", FALSE,
                                        RESPID_INSENSITIVE_MSG);
-  glade_widget_property_set_enabled (gbutton, "response-id", FALSE);
 
   if (reason == GLADE_CREATE_LOAD)
     g_signal_connect (glade_widget_get_project (gbutton), "parse-finished",
diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in
index fc80dc2..831c553 100644
--- a/plugins/gtk+/gtk+.xml.in
+++ b/plugins/gtk+/gtk+.xml.in
@@ -1042,7 +1042,8 @@ embedded in another object</_tooltip>
          </parameter-spec>
         </property>
        <property id="image-position" custom-layout="True"/>
-       <property id="response-id" _name="Response ID" default="0" common="False" ignore="True" save="False">
+       <property id="response-id" _name="Response ID" default="0" optional="True"
+                 optional-default="False" common="False" ignore="True" save="False">
          <parameter-spec>
            <type>GParamInt</type>
          </parameter-spec>


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