summaryrefslogtreecommitdiff
path: root/gladeui
diff options
context:
space:
mode:
Diffstat (limited to 'gladeui')
-rw-r--r--gladeui/glade-command.c145
-rw-r--r--gladeui/glade-command.h5
-rw-r--r--gladeui/glade-property.c6
-rw-r--r--gladeui/glade-widget-adaptor.c40
-rw-r--r--gladeui/glade-widget-adaptor.h27
-rw-r--r--gladeui/glade-widget.c19
-rw-r--r--gladeui/glade-widget.h3
-rw-r--r--gladeui/glade-xml-utils.h2
8 files changed, 37 insertions, 210 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 *******/
/**************************************************/
diff --git a/gladeui/glade-command.h b/gladeui/glade-command.h
index 7bc0cf41..0e7837d7 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 08eb6deb..5abbe519 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 eb266877..55ab934e 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 a1a2a29f..4c5bb31a 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 b8eb1bac..53226bda 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 038c090c..aa0726f2 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 8dcdc94a..20e7fc2b 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"