[glade/evaluate-sensitivity] Rework the last commit to only introduce GladeWidgetAdaptor->evaluate_property_sensitivity()



commit f668962165821ed885367bebf85b86642dd56e50
Author: Denis Washington <denisw src gnome org>
Date:   Sun Dec 11 09:44:26 2011 +0100

    Rework the last commit to only introduce GladeWidgetAdaptor->evaluate_property_sensitivity()
    
    As discussed with Tristan van Berkom on the mailing list. Instead of
    recording property sensitivity changes directly in the command system,
    a "property invalidated" signal will be added to the "gbinding" branch
    to make sure that property bindings with invalidated source properties
    are properly removed.
    
    What remains in this branch, though, is a new virtual function
    GladeWidgetAdaptor::evaluate_property_sensitivity() which centralizes
    all the property sensitivity management which is currently scattered
    around the plugins/gtk+/ codebase. As the invalidated-source-property
    issue will now be solved directly in the "gbinding" branch, this is now
    a purely cosmetic work, but nevertheless I will continue it (and probably
    rebase the gbinding branch to it).
    
    As in the last commit, of the code in plugins/gtk+/ only the GtkEntry
    adaptor has been ported to use evaluate_property_sensitivity(), but the
    others will eventually follow.

 gladeui/glade-command.c           |  145 ----------------------------
 gladeui/glade-command.h           |    5 -
 gladeui/glade-property.c          |    6 +
 gladeui/glade-widget-adaptor.c    |   40 ++++-----
 gladeui/glade-widget-adaptor.h    |   27 +++---
 gladeui/glade-widget.c            |   19 ----
 gladeui/glade-widget.h            |    3 -
 gladeui/glade-xml-utils.h         |    2 +-
 plugins/gtk+/glade-entry-editor.c |   10 --
 plugins/gtk+/glade-gtk.c          |  189 ++++++++++++++++---------------------
 plugins/gtk+/gtk+.xml.in          |    1 +
 11 files changed, 120 insertions(+), 327 deletions(-)
---
diff --git a/gladeui/glade-command.c b/gladeui/glade-command.c
index 45fdd40..617994c 100644
--- a/gladeui/glade-command.c
+++ b/gladeui/glade-command.c
@@ -786,151 +786,6 @@ glade_command_set_property (GladeProperty * property, ...)
   glade_command_set_property_value (property, value);
 }
 
-/***********************************************************/
-/*******     GLADE_COMMAND_SET_PROPERTY_SENSITIVE     ******/
-/***********************************************************/
-
-/* create a new GladeCommandSetPropertySensitive class.  Objects of this class will
- * encapsulate a "set property (in)sensitive" operation */
-
-typedef struct
-{
-  GladeCommand parent;
-  GladeProperty *property;
-  gboolean sensitive;
-  gchar *new_reason;
-  gchar *old_reason;
-  gboolean undo;
-} GladeCommandSetPropertySensitive;
-
-/* standard macros */
-GLADE_MAKE_COMMAND (GladeCommandSetPropertySensitive, glade_command_set_property_sensitive);
-#define GLADE_COMMAND_SET_PROPERTY_SENSITIVE_TYPE	(glade_command_set_property_sensitive_get_type ())
-#define GLADE_COMMAND_SET_PROPERTY_SENSITIVE(o)	  	(G_TYPE_CHECK_INSTANCE_CAST ((o), GLADE_COMMAND_SET_PROPERTY_SENSITIVE_TYPE, GladeCommandSetPropertySensitive))
-#define GLADE_COMMAND_SET_PROPERTY_SENSITIVE_CLASS(k)	(G_TYPE_CHECK_CLASS_CAST ((k), GLADE_COMMAND_SET_PROPERTY_SENSITIVE_TYPE, GladeCommandSetPropertySensitiveClass))
-#define GLADE_IS_COMMAND_SET_PROPERTY_SENSITIVE(o)	(G_TYPE_CHECK_INSTANCE_TYPE ((o), GLADE_COMMAND_SET_PROPERTY_SENSITIVE_TYPE))
-#define GLADE_IS_COMMAND_SET_PROPERTY_SENSITIVE_CLASS(k)	(G_TYPE_CHECK_CLASS_TYPE ((k), GLADE_COMMAND_SET_PROPERTY_SENSITIVE_TYPE))
-
-/* Undo the last "set property (in)sensitive" command" */
-static gboolean
-glade_command_set_property_sensitive_undo (GladeCommand * cmd)
-{
-  return glade_command_set_property_sensitive_execute (cmd);
-}
-
-/*
- * Execute the set property command and revert it. IE, after the execution of
- * this function cmd will point to the undo action
- */
-static gboolean
-glade_command_set_property_sensitive_execute (GladeCommand * cmd)
-{
-  GladeCommandSetPropertySensitive *scmd;
-
-  g_return_val_if_fail (GLADE_IS_COMMAND_SET_PROPERTY_SENSITIVE (cmd), TRUE);
-
-  scmd = GLADE_COMMAND_SET_PROPERTY_SENSITIVE (cmd);
-  glade_property_set_sensitive (scmd->property,
-                                scmd->undo ? !scmd->sensitive : scmd->sensitive,
-                                scmd->undo ? scmd->old_reason : scmd->new_reason);
-
-  scmd->undo = !scmd->undo;
-  return TRUE;
-}
-
-static void
-glade_command_set_property_sensitive_finalize (GObject * obj)
-{
-  GladeCommandSetPropertySensitive *cmd;
-
-  cmd = GLADE_COMMAND_SET_PROPERTY_SENSITIVE (obj);
-  g_free (cmd->new_reason);
-  g_free (cmd->old_reason);
-
-  glade_command_finalize (obj);
-}
-
-static gboolean
-glade_command_set_property_sensitive_unifies (GladeCommand * this_cmd,
-                                              GladeCommand * other_cmd)
-{
-  GladeCommandSetPropertySensitive *cmd1, *cmd2;
-
-  if (GLADE_IS_COMMAND_SET_PROPERTY_SENSITIVE (this_cmd) &&
-      GLADE_IS_COMMAND_SET_PROPERTY_SENSITIVE (other_cmd))
-    {
-      cmd1 = GLADE_COMMAND_SET_PROPERTY_SENSITIVE (this_cmd);
-      cmd2 = GLADE_COMMAND_SET_PROPERTY_SENSITIVE (other_cmd);
-
-      return (cmd1->property == cmd2->property &&
-              cmd1->new_reason == cmd2->new_reason);
-    }
-
-  return FALSE;
-}
-
-static void
-glade_command_set_property_sensitive_collapse (GladeCommand * this_cmd,
-                                               GladeCommand * other_cmd)
-{
-  g_return_if_fail (GLADE_IS_COMMAND_SET_PROPERTY_SENSITIVE (this_cmd));
-  g_return_if_fail (GLADE_IS_COMMAND_SET_PROPERTY_SENSITIVE (other_cmd));
-
-  /* Nothing to do */
-}
-
-void
-glade_command_widget_set_property_sensitive (GladeWidget * widget,
-                                             const gchar * property_id,
-                                             gboolean sensitive,
-                                             const gchar * reason)
-{
-  GladeProperty *property;
-
-  g_return_if_fail (GLADE_IS_WIDGET (widget));
-  g_return_if_fail (property_id != NULL);
-
-  if ((property = glade_widget_get_property (widget, property_id)) != NULL)
-    glade_command_set_property_sensitive (property, sensitive, reason);
-}
-
-void
-glade_command_set_property_sensitive (GladeProperty * property,
-                                      gboolean sensitive,
-                                      const gchar * reason)
-{
-  GladeCommandSetPropertySensitive *me;
-  GladeCommand *cmd;
-
-  g_return_if_fail (GLADE_IS_PROPERTY (property));
-
-  me = g_object_new (GLADE_COMMAND_SET_PROPERTY_SENSITIVE_TYPE, NULL);
-  me->undo = FALSE;
-  me->property = property;
-  me->sensitive = sensitive;
-
-  me->new_reason = g_strdup (reason);
-  me->old_reason = g_strdup (glade_propert_get_insensitive_tooltip (me->property));
-  if (me->old_reason)
-    me->old_reason = g_strdup (me->old_reason);
-
-  cmd = GLADE_COMMAND (me);
-  cmd->priv->project =
-    glade_widget_get_project (glade_property_get_widget (me->property));
-
-  /* This command is always part of a group, thus its description should
-   * never be visible
-   */
-  cmd->priv->description = g_strdup ("dummy");
-
-  glade_command_check_group (GLADE_COMMAND (me));
-
-  if (glade_command_set_property_sensitive_execute (GLADE_COMMAND (me)))
-    glade_project_push_undo (cmd->priv->project, cmd);
-  else
-    g_object_unref (G_OBJECT (me));
-}
-
 /**************************************************/
 /*******       GLADE_COMMAND_SET_NAME       *******/
 /**************************************************/
diff --git a/gladeui/glade-command.h b/gladeui/glade-command.h
index 7bc0cf4..0e7837d 100644
--- a/gladeui/glade-command.h
+++ b/gladeui/glade-command.h
@@ -95,11 +95,6 @@ void           glade_command_set_properties      (GladeProperty *property,
 void           glade_command_set_properties_list (GladeProject  *project, 
 						  GList         *props); /* list of GCSetPropData */
 
-void           glade_command_widget_set_property_sensitive (GladeWidget *widget,
-							    const gchar *property_id,
-							    gboolean     sensitive,
-							    const gchar *reason);
-
 /************************** name ******************************/
 
 void           glade_command_set_name      (GladeWidget       *glade_widget, const gchar  *name);
diff --git a/gladeui/glade-property.c b/gladeui/glade-property.c
index 08eb6de..5abbe51 100644
--- a/gladeui/glade-property.c
+++ b/gladeui/glade-property.c
@@ -362,10 +362,16 @@ glade_property_set_value_impl (GladeProperty * property, const GValue * value)
 
   if (changed && property->priv->widget)
     {
+      GladeWidgetAdaptor *adaptor;
+
       g_signal_emit (G_OBJECT (property),
                      glade_property_signals[VALUE_CHANGED],
                      0, &old_value, property->priv->value);
 
+      /* Make sure that property sensitivity is right after the change */
+      adaptor = glade_widget_get_adaptor (property->priv->widget);
+      glade_widget_adaptor_evaluate_property_sensitivity (adaptor, property->priv->widget);
+
       glade_project_verify_property (property);
     }
 
diff --git a/gladeui/glade-widget-adaptor.c b/gladeui/glade-widget-adaptor.c
index eb26687..55ab934 100644
--- a/gladeui/glade-widget-adaptor.c
+++ b/gladeui/glade-widget-adaptor.c
@@ -1303,6 +1303,13 @@ glade_widget_adaptor_object_create_editable (GladeWidgetAdaptor * adaptor,
   return (GladeEditable *) glade_editor_table_new (adaptor, type);
 }
 
+static void
+glade_widget_adaptor_object_evaluate_property_sensitivity (GladeWidgetAdaptor * adaptor,
+                                                           GladeWidget        * widget)
+{
+  /* Nothing to do */
+}
+
 static GList *
 glade_widget_adaptor_object_get_children (GladeWidgetAdaptor *adaptor,
                                           GObject *object)
@@ -1325,13 +1332,6 @@ glade_widget_adaptor_object_get_children (GladeWidgetAdaptor *adaptor,
   return children;
 }
 
-static void
-glade_widget_adaptor_object_adjust_property_flags (GladeWidgetAdaptor * adaptor,
-                                                   GladeWidget * widget,
-                                                   gboolean use_command)
-{
-  /* Nothing to do */
-}
 
 /*******************************************************************************
             GladeWidgetAdaptor type registration and class initializer
@@ -1385,7 +1385,7 @@ glade_widget_adaptor_class_init (GladeWidgetAdaptorClass * adaptor_class)
   adaptor_class->create_eprop = glade_widget_adaptor_object_create_eprop;
   adaptor_class->string_from_value = glade_widget_adaptor_object_string_from_value;
   adaptor_class->create_editable = glade_widget_adaptor_object_create_editable;
-  adaptor_class->adjust_property_flags = glade_widget_adaptor_object_adjust_property_flags;
+  adaptor_class->evaluate_property_sensitivity = glade_widget_adaptor_object_evaluate_property_sensitivity;
 
   /* Base defaults here */
   adaptor_class->toplevel = FALSE;
@@ -1654,9 +1654,9 @@ gwa_extend_with_node_load_sym (GladeWidgetAdaptorClass * klass,
     klass->create_editable = symbol;
 
   if (glade_xml_load_sym_from_node (node, module,
-                                    GLADE_TAG_ADJUST_PROPERTY_FLAGS_FUNCTION,
+                                    GLADE_TAG_EVALUATE_PROPERTY_SENSITIVITY_FUNCTION,
                                     &symbol))
-    klass->adjust_property_flags = symbol;
+      klass->evaluate_property_sensitivity = symbol;
 }
 
 static void
@@ -4372,23 +4372,19 @@ glade_widget_adaptor_create_editable (GladeWidgetAdaptor * adaptor,
 }
 
 /**
- * glade_widget_adaptor_adjust_property_flags:
+ * glade_widget_adaptor_evaluate_property_sensitivity:
  * @adaptor: A #GladeWidgetAdaptor
- * @widget: The #GladeWidget
- * @use_command: whether to use the GladeCommand interface
+ * @widget: A #GladeWidget
  *
- * This is called after a widget is loaded or a widget's
- * property value has changed. It allows the backend to keep the
- * sensitive/enabled flags of all properties consistent with the
- * property values.
+ * This is used to allow the backend to adjust the sensitivity of a
+ * widget's properties to match their values.
  */
 void
-glade_widget_adaptor_adjust_property_flags (GladeWidgetAdaptor * adaptor,
-                                            GladeWidget * widget,
-                                            gboolean use_command)
+glade_widget_adaptor_evaluate_property_sensitivity (GladeWidgetAdaptor * adaptor,
+                                                    GladeWidget * widget)
 {
   g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
 
-  GLADE_WIDGET_ADAPTOR_GET_CLASS
-      (adaptor)->adjust_property_flags (adaptor, widget, use_command);
+  return GLADE_WIDGET_ADAPTOR_GET_CLASS
+      (adaptor)->evaluate_property_sensitivity (adaptor, widget);
 }
diff --git a/gladeui/glade-widget-adaptor.h b/gladeui/glade-widget-adaptor.h
index a1a2a29..4c5bb31 100644
--- a/gladeui/glade-widget-adaptor.h
+++ b/gladeui/glade-widget-adaptor.h
@@ -553,20 +553,19 @@ typedef GladeEditable *(* GladeCreateEditableFunc) (GladeWidgetAdaptor   *adapto
 						    GladeEditorPageType   type);
 
 
+
 /**
- * GladeAdjustPropertyFlagsFunc:
+ * GladeEvaluatePropertySensitivityFunc:
  * @adaptor: A #GladeWidgetAdaptor
  * @widget: The #GladeWidget
- * @use_command: whether to use the GladeCommand interface
  *
- * This is called after a widget is loaded or a widget's
- * property value has changed. It allows the backend to keep the
- * sensitive/enabled flags of all properties consistent with the
- * property values.
+ * This is used to allow the backend to adjust the sensitivity of a
+ * widget's properties to match their values.
  */
-typedef void (* GladeAdjustPropertyFlagsFunc) (GladeWidgetAdaptor *adaptor,
-					       GladeWidget        *widget,
-					       gboolean            use_command);
+typedef void     (* GladeEvaluatePropertySensitivityFunc) (GladeWidgetAdaptor *adaptor,
+                                                           GladeWidget        *widget);
+
+
 
 /* Note that everything that must be processed at the creation of
  * every instance is managed on the instance structure, and everywhere
@@ -674,8 +673,8 @@ struct _GladeWidgetAdaptorClass
   GladeCreateEPropFunc         create_eprop;      /* Creates a GladeEditorProperty */
   GladeStringFromValueFunc     string_from_value; /* Creates a string for a value */
   GladeCreateEditableFunc      create_editable;   /* Creates a page for the editor */
-  GladeAdjustPropertyFlagsFunc adjust_property_flags; /* Appropiately sets all properties' sensitive/enabled flags */
-  
+  GladeEvaluatePropertySensitivityFunc evaluate_property_sensitivity; /* Adjusts sensitivity of properties */
+    
   void   (* glade_reserved1)   (void);
   void   (* glade_reserved2)   (void);
   void   (* glade_reserved3)   (void);
@@ -854,16 +853,14 @@ gchar                *glade_widget_adaptor_string_from_value  (GladeWidgetAdapto
 							       const GValue       *value);
 GladeEditable        *glade_widget_adaptor_create_editable    (GladeWidgetAdaptor *adaptor,
 							       GladeEditorPageType type);
+void                  glade_widget_adaptor_evaluate_property_sensitivity (GladeWidgetAdaptor *adaptor,
+                                                                          GladeWidget        *widget);
 GladeSignalClass     *glade_widget_adaptor_get_signal_class   (GladeWidgetAdaptor *adaptor,
 							       const gchar        *name);
 GladeWidgetAdaptor   *glade_widget_adaptor_get_parent_adaptor (GladeWidgetAdaptor *adaptor);
 
 gboolean              glade_widget_adaptor_has_internal_children (GladeWidgetAdaptor *adaptor);
 
-void                  glade_widget_adaptor_adjust_property_flags (GladeWidgetAdaptor *adaptor,
-								  GladeWidget        *widget,
-								  gboolean            use_command);
-
 G_END_DECLS
 
 #endif /* _GLADE_WIDGET_ADAPTOR_H_ */
diff --git a/gladeui/glade-widget.c b/gladeui/glade-widget.c
index b8eb1ba..53226bd 100644
--- a/gladeui/glade-widget.c
+++ b/gladeui/glade-widget.c
@@ -3779,9 +3779,6 @@ glade_widget_read (GladeProject * project,
                 }
 
               glade_widget_adaptor_read_widget (adaptor, widget, node);
-
-              /* Set initial property sensitivity */
-              glade_widget_adaptor_adjust_property_flags (adaptor, widget, FALSE);
             }
           else
             {
@@ -3999,22 +3996,6 @@ glade_widget_is_ancestor (GladeWidget * widget, GladeWidget * ancestor)
   return FALSE;
 }
 
-/**
- * glade_widget_adjust_property_flags:
- * @widget: A #GladeWidget
- * @use_command: whether to use the GladeCommand interface
- *
- * Adjusts the sensitive/enabled flags of all widget properties to match
- * the widget's property values.
- */
-void
-glade_widget_adjust_property_flags (GladeWidget * widget, gboolean use_command)
-{
-  g_return_if_fail (GLADE_IS_WIDGET (widget));
-
-  glade_widget_adaptor_adjust_property_flags (widget->priv->adaptor,
-                                              widget, use_command);
-}
 
 static gint glade_widget_su_stack = 0;
 
diff --git a/gladeui/glade-widget.h b/gladeui/glade-widget.h
index 038c090..aa0726f 100644
--- a/gladeui/glade-widget.h
+++ b/gladeui/glade-widget.h
@@ -216,9 +216,6 @@ gchar                  *glade_widget_generate_path_name     (GladeWidget      *w
 gboolean                glade_widget_is_ancestor            (GladeWidget      *widget,
 							     GladeWidget      *ancestor);
 
-void                    glade_widget_adjust_property_flags  (GladeWidget      *widget,
-                                                             gboolean          use_command);
-
 /*******************************************************************************
                       Project, object property references
  *******************************************************************************/
diff --git a/gladeui/glade-xml-utils.h b/gladeui/glade-xml-utils.h
index 8dcdc94..20e7fc2 100644
--- a/gladeui/glade-xml-utils.h
+++ b/gladeui/glade-xml-utils.h
@@ -113,7 +113,7 @@ typedef struct _GladeProject        GladeProject;
 #define GLADE_TAG_CREATE_EPROP_FUNCTION           "create-editor-property-function"
 #define GLADE_TAG_STRING_FROM_VALUE_FUNCTION      "string-from-value-function"
 #define GLADE_TAG_CREATE_EDITABLE_FUNCTION        "create-editable-function"
-#define GLADE_TAG_ADJUST_PROPERTY_FLAGS_FUNCTION  "adjust-property-flags-function"
+#define GLADE_TAG_EVALUATE_PROPERTY_SENSITIVITY_FUNCTION "evaluate-property-sensitivity-function"
 #define GLADE_TAG_PROPERTIES                      "properties"
 #define GLADE_TAG_PACKING_PROPERTIES              "packing-properties"
 #define GLADE_TAG_PROPERTY                        "property"
diff --git a/plugins/gtk+/glade-entry-editor.c b/plugins/gtk+/glade-entry-editor.c
index 4cf3f18..86320da 100644
--- a/plugins/gtk+/glade-entry-editor.c
+++ b/plugins/gtk+/glade-entry-editor.c
@@ -24,11 +24,9 @@
 #include <glib/gi18n-lib.h>
 #include <gdk/gdkkeysyms.h>
 
-#include "glade-gtk.h"
 #include "glade-entry-editor.h"
 #include "glade-image-editor.h" // For GladeImageEditMode
 
-#include <gladeui/glade-widget-adaptor.h>
 
 static void glade_entry_editor_finalize (GObject * object);
 
@@ -210,7 +208,6 @@ text_toggled (GtkWidget * widget, GladeEntryEditor * entry_editor)
   /* Incase the NULL text didnt change */
   glade_property_sync (property);
 
-  glade_widget_adjust_property_flags (gwidget, TRUE);
   glade_command_pop_group ();
 
   glade_editable_unblock (GLADE_EDITABLE (entry_editor));
@@ -245,7 +242,6 @@ buffer_toggled (GtkWidget * widget, GladeEntryEditor * entry_editor)
       glade_widget_get_property (gwidget, "use-entry-buffer");
   glade_command_set_property (property, TRUE);
 
-  glade_widget_adjust_property_flags (gwidget, TRUE);
   glade_command_pop_group ();
 
   glade_editable_unblock (GLADE_EDITABLE (entry_editor));
@@ -328,7 +324,6 @@ primary_stock_toggled (GtkWidget * widget, GladeEntryEditor * entry_editor)
   glade_command_push_group (_("Setting %s to use a primary icon from stock"),
                             glade_widget_get_name (gwidget));
   set_stock_mode (entry_editor, TRUE);
-  glade_widget_adjust_property_flags (gwidget, TRUE);
   glade_command_pop_group ();
 
   glade_editable_unblock (GLADE_EDITABLE (entry_editor));
@@ -355,7 +350,6 @@ primary_icon_name_toggled (GtkWidget * widget, GladeEntryEditor * entry_editor)
   glade_command_push_group (_("Setting %s to use a primary icon from the icon theme"),
                             glade_widget_get_name (gwidget));
   set_icon_name_mode (entry_editor, TRUE);
-  glade_widget_adjust_property_flags (gwidget, TRUE);
   glade_command_pop_group ();
 
   glade_editable_unblock (GLADE_EDITABLE (entry_editor));
@@ -381,7 +375,6 @@ primary_pixbuf_toggled (GtkWidget * widget, GladeEntryEditor * entry_editor)
   glade_command_push_group (_("Setting %s to use a primary icon from filename"),
                             glade_widget_get_name (gwidget));
   set_pixbuf_mode (entry_editor, TRUE);
-  glade_widget_adjust_property_flags (gwidget, TRUE);
   glade_command_pop_group ();
 
   glade_editable_unblock (GLADE_EDITABLE (entry_editor));
@@ -408,7 +401,6 @@ secondary_stock_toggled (GtkWidget * widget, GladeEntryEditor * entry_editor)
   glade_command_push_group (_("Setting %s to use a secondary icon from stock"),
                             glade_widget_get_name (gwidget));
   set_stock_mode (entry_editor, FALSE);
-  glade_widget_adjust_property_flags (gwidget, TRUE);
   glade_command_pop_group ();
 
   glade_editable_unblock (GLADE_EDITABLE (entry_editor));
@@ -436,7 +428,6 @@ secondary_icon_name_toggled (GtkWidget * widget,
   glade_command_push_group (_("Setting %s to use a secondary icon from the icon theme"),
                             glade_widget_get_name (gwidget));
   set_icon_name_mode (entry_editor, FALSE);
-  glade_widget_adjust_property_flags (gwidget, TRUE);
   glade_command_pop_group ();
 
   glade_editable_unblock (GLADE_EDITABLE (entry_editor));
@@ -462,7 +453,6 @@ secondary_pixbuf_toggled (GtkWidget * widget, GladeEntryEditor * entry_editor)
   glade_command_push_group (_("Setting %s to use a secondary icon from filename"),
                             glade_widget_get_name (gwidget));
   set_pixbuf_mode (entry_editor, FALSE);
-  glade_widget_adjust_property_flags (gwidget, TRUE);
   glade_command_pop_group ();
 
   glade_editable_unblock (GLADE_EDITABLE (entry_editor));
diff --git a/plugins/gtk+/glade-gtk.c b/plugins/gtk+/glade-gtk.c
index d4076b3..e422be6 100644
--- a/plugins/gtk+/glade-gtk.c
+++ b/plugins/gtk+/glade-gtk.c
@@ -1053,23 +1053,6 @@ glade_gtk_widget_action_submenu (GladeWidgetAdaptor * adaptor,
   return NULL;
 }
 
-static void
-glade_gtk_widget_property_set_sensitive (GladeWidget * gwidget,
-                                         const gchar * id, gboolean sensitive,
-                                         const gchar * reason,
-                                         gboolean use_command)
-{
-  if (use_command)
-    {
-      GladeProperty *property;
-
-      if ((property = glade_widget_get_property (gwidget, id)) != NULL)
-        glade_command_set_property_sensitive (property, sensitive, reason);
-    }
-  else
-    glade_widget_property_set_sensitive (gwidget, id, sensitive, reason);
-}
-
 /* ----------------------------- GtkContainer ------------------------------ */
 void
 glade_gtk_container_post_create (GladeWidgetAdaptor * adaptor,
@@ -3426,6 +3409,77 @@ glade_gtk_entry_create_editable (GladeWidgetAdaptor * adaptor,
   return editable;
 }
 
+static void
+glade_gtk_entry_evaluate_icon_mode_sensitivity (GladeWidgetAdaptor * adaptor,
+                                                GladeWidget * widget,
+                                                const gchar * prefix)
+{
+  gchar *icon_mode_prop = g_strdup_printf ("%s-icon-mode", prefix);
+  gchar *icon_stock_prop = g_strdup_printf ("%s-icon-stock", prefix);
+  gchar *icon_name_prop = g_strdup_printf ("%s-icon-name", prefix);
+  gchar *icon_pixbuf_prop = g_strdup_printf ("%s-icon-pixbuf", prefix);
+  int icon_mode;
+
+  glade_widget_property_get (widget, icon_mode_prop, &icon_mode);
+  switch (icon_mode)
+    {
+    case GLADE_IMAGE_MODE_STOCK:
+      glade_widget_property_set_sensitive (widget, icon_stock_prop,
+                                           TRUE, NULL);
+      glade_widget_property_set_sensitive (widget, icon_name_prop,
+                                           FALSE, NULL);
+      glade_widget_property_set_sensitive (widget, icon_pixbuf_prop,
+                                           FALSE, NULL);
+      break;
+    case GLADE_IMAGE_MODE_ICON:
+      glade_widget_property_set_sensitive (widget, icon_name_prop,
+                                           TRUE, NULL);
+      glade_widget_property_set_sensitive (widget, icon_stock_prop,
+                                           FALSE, NULL);
+      glade_widget_property_set_sensitive (widget, icon_pixbuf_prop,
+                                           FALSE, NULL);
+      break;
+    case GLADE_IMAGE_MODE_FILENAME:
+      glade_widget_property_set_sensitive (widget, icon_pixbuf_prop,
+                                           TRUE, NULL);
+      glade_widget_property_set_sensitive (widget, icon_stock_prop,
+                                           FALSE, NULL);
+      glade_widget_property_set_sensitive (widget, icon_name_prop,
+                                           FALSE, NULL);
+      break;
+    }
+
+  g_free (icon_mode_prop);
+  g_free (icon_stock_prop);
+  g_free (icon_pixbuf_prop);
+  g_free (icon_name_prop);
+}
+
+void
+glade_gtk_entry_evaluate_property_sensitivity (GladeWidgetAdaptor * adaptor,
+                                               GladeWidget * widget)
+{
+  gboolean use_entry_buffer;
+
+  glade_widget_property_get (widget, "use-entry-buffer", &use_entry_buffer);
+  if (use_entry_buffer)
+    {
+      glade_widget_property_set_sensitive (widget, "buffer", TRUE,
+                                           NOT_SELECTED_MSG);
+      glade_widget_property_set_sensitive (widget, "text", FALSE,
+                                           NOT_SELECTED_MSG);
+    }
+  else
+    {
+      glade_widget_property_set_sensitive (widget, "text", TRUE,
+                                           NOT_SELECTED_MSG);
+      glade_widget_property_set_sensitive (widget, "buffer", FALSE,
+                                           NOT_SELECTED_MSG);
+    }
+
+  glade_gtk_entry_evaluate_icon_mode_sensitivity (adaptor, widget, "primary");
+  glade_gtk_entry_evaluate_icon_mode_sensitivity (adaptor, widget, "secondary");
+}
 
 void
 glade_gtk_entry_set_property (GladeWidgetAdaptor * adaptor,
@@ -3435,8 +3489,15 @@ glade_gtk_entry_set_property (GladeWidgetAdaptor * adaptor,
   GladeWidget *gwidget = glade_widget_get_from_gobject (object);
   GladeProperty *property = glade_widget_get_property (gwidget, id);
 
-  if (!strcmp (id, "primary-icon-tooltip-text") ||
-      !strcmp (id, "primary-icon-tooltip-markup"))
+  if (!strcmp (id, "use-entry-buffer") != 0 ||
+      !strcmp (id, "primary-icon-mode") != 0 ||
+      !strcmp (id, "secondary-icon-mode") != 0)
+    {
+      /* Virtual properties, GtkEntry doesn't have them */
+      return;
+    }
+  else if (!strcmp (id, "primary-icon-tooltip-text") ||
+           !strcmp (id, "primary-icon-tooltip-markup"))
     {
       /* Avoid a silly crash in GTK+ */
       if (gtk_entry_get_icon_storage_type (GTK_ENTRY (object),
@@ -3467,100 +3528,14 @@ glade_gtk_entry_set_property (GladeWidgetAdaptor * adaptor,
 
       g_signal_handlers_unblock_by_func (object, glade_gtk_entry_changed,
                                          gwidget);
+
     }
-  else if (strcmp (id, "use-entry-buffer") != 0 && /* virtual */
-           strcmp (id, "primary-icon-mode") != 0 && /* virtual */
-           strcmp (id, "secondary-icon-mode") != 0 && /* virtual */
-           GPC_VERSION_CHECK
+  else if (GPC_VERSION_CHECK
            (glade_property_get_class (property), gtk_major_version, gtk_minor_version + 1))
     GWA_GET_CLASS (GTK_TYPE_WIDGET)->set_property (adaptor, object, id, value);
 }
 
 void
-glade_gtk_entry_adjust_property_flags (GladeWidgetAdaptor * adaptor,
-                                       GladeWidget * widget, gboolean use_command)
-{
-  gboolean use_buffer;
-  GladeImageEditMode mode;
-
-  GWA_GET_CLASS (GTK_TYPE_WIDGET)->adjust_property_flags (adaptor, widget, use_command);
-
-  glade_widget_property_get (widget, "use-entry-buffer", &use_buffer);
-  if (use_buffer)
-    {
-      glade_gtk_widget_property_set_sensitive (widget, "buffer", TRUE,
-                                               NULL, use_command);
-      glade_gtk_widget_property_set_sensitive (widget, "text", FALSE,
-                                               NOT_SELECTED_MSG, use_command);
-    }
-  else
-    {
-      glade_gtk_widget_property_set_sensitive (widget, "text", TRUE,
-                                               NULL, use_command);
-      glade_gtk_widget_property_set_sensitive (widget, "buffer", FALSE,
-                                               NOT_SELECTED_MSG, use_command);
-    }
-
-  glade_widget_property_get (widget, "primary-icon-mode", &mode);
-  switch (mode)
-    {
-    case GLADE_IMAGE_MODE_STOCK:
-      glade_gtk_widget_property_set_sensitive (widget, "primary-icon-stock", TRUE,
-                                               NULL, use_command);
-      glade_gtk_widget_property_set_sensitive (widget, "primary-icon-name", FALSE,
-                                               NULL, use_command);
-      glade_gtk_widget_property_set_sensitive (widget, "primary-icon-pixbuf", FALSE,
-                                               NULL, use_command);
-      break;
-    case GLADE_IMAGE_MODE_ICON:
-      glade_gtk_widget_property_set_sensitive (widget, "primary-icon-name", TRUE,
-                                               NULL, use_command);
-      glade_gtk_widget_property_set_sensitive (widget, "primary-icon-stock", FALSE,
-                                               NULL, use_command);
-      glade_gtk_widget_property_set_sensitive (widget, "primary-icon-pixbuf", FALSE,
-                                               NULL, use_command);
-      break;
-    case GLADE_IMAGE_MODE_FILENAME:
-      glade_gtk_widget_property_set_sensitive (widget, "primary-icon-pixbuf", TRUE,
-                                               NULL, use_command);
-      glade_gtk_widget_property_set_sensitive (widget, "primary-icon-stock", FALSE,
-                                               NULL, use_command);
-      glade_gtk_widget_property_set_sensitive (widget, "primary-icon-name", FALSE,
-                                               NULL, use_command);
-      break;
-    }
-
-  glade_widget_property_get (widget, "secondary-icon-mode", &mode);
-  switch (mode)
-    {
-    case GLADE_IMAGE_MODE_STOCK:
-      glade_gtk_widget_property_set_sensitive (widget, "secondary-icon-stock", TRUE,
-                                               NULL, use_command);
-      glade_gtk_widget_property_set_sensitive (widget, "secondary-icon-name", FALSE,
-                                               NULL, use_command);
-      glade_gtk_widget_property_set_sensitive (widget, "secondary-icon-pixbuf", FALSE,
-                                               NULL, use_command);
-      break;
-    case GLADE_IMAGE_MODE_ICON:
-      glade_gtk_widget_property_set_sensitive (widget, "secondary-icon-name", TRUE,
-                                               NULL, use_command);
-      glade_gtk_widget_property_set_sensitive (widget, "secondary-icon-stock", FALSE,
-                                               NULL, use_command);
-      glade_gtk_widget_property_set_sensitive (widget, "secondary-icon-pixbuf", FALSE,
-                                               NULL, use_command);
-      break;
-    case GLADE_IMAGE_MODE_FILENAME:
-      glade_gtk_widget_property_set_sensitive (widget, "secondary-icon-pixbuf", TRUE,
-                                               NULL, use_command);
-      glade_gtk_widget_property_set_sensitive (widget, "secondary-icon-stock", FALSE,
-                                               NULL, use_command);
-      glade_gtk_widget_property_set_sensitive (widget, "secondary-icon-name", FALSE,
-                                               NULL, use_command);
-      break;
-    }
-}
-
-void
 glade_gtk_entry_read_widget (GladeWidgetAdaptor * adaptor,
                              GladeWidget * widget, GladeXmlNode * node)
 {
diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in
index 4103a46..bc13b43 100644
--- a/plugins/gtk+/gtk+.xml.in
+++ b/plugins/gtk+/gtk+.xml.in
@@ -908,6 +908,7 @@ embedded in another object</_tooltip>
       <set-property-function>glade_gtk_entry_set_property</set-property-function>
       <read-widget-function>glade_gtk_entry_read_widget</read-widget-function>
       <depends-function>glade_gtk_entry_depends</depends-function>
+      <evaluate-property-sensitivity-function>glade_gtk_entry_evaluate_property_sensitivity</evaluate-property-sensitivity-function>
 
       <signals>
 	<signal id="icon-press" since="2.16"/>



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