diff options
author | Denis Washington <denisw@src.gnome.org> | 2011-12-11 09:44:26 +0100 |
---|---|---|
committer | Denis Washington <denisw@src.gnome.org> | 2011-12-13 07:49:03 +0100 |
commit | c2ea20f941dc9bf079b52e519e37b12ac2e0f271 (patch) | |
tree | e8d3aa0b90b4aee062da6b5292194d883fbf4e86 /gladeui/glade-command.c | |
parent | e015ce5bb4d422586fb8371a24db1af8e4c11441 (diff) | |
download | glade-evaluate-sensitivity.tar.gz |
Rework the last commit to only introduce GladeWidgetAdaptor->evaluate_property_sensitivity()evaluate-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.
Diffstat (limited to 'gladeui/glade-command.c')
-rw-r--r-- | gladeui/glade-command.c | 145 |
1 files changed, 0 insertions, 145 deletions
diff --git a/gladeui/glade-command.c b/gladeui/glade-command.c index 45fdd402..617994cc 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 *******/ /**************************************************/ |