[dia] Bug 488269 - empty undo actions when no properties are changed
- From: Hans Breuer <hans src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia] Bug 488269 - empty undo actions when no properties are changed
- Date: Sun, 12 Jun 2011 13:38:09 +0000 (UTC)
commit 081fa89e1aa7080ffbe11ba000a83bdf1a6aa452
Author: Hans Breuer <hans breuer org>
Date: Sun Jun 12 15:37:17 2011 +0200
Bug 488269 - empty undo actions when no properties are changed
This is not a complete fix, but some related behavior change.
The dict property was claiming a change even when not touched,
that's corrected now. But creating an empty change is necessary
to fulfill the contract of DiaObject::apply_props_from_dialog().
We could implement some silent ignoring of these empty changes,
but IMO it would be better to not enable the Apply/Ok at all,
if there is nothing to change.
lib/prop_dict.c | 13 +++++++++----
lib/propobject.c | 4 +++-
2 files changed, 12 insertions(+), 5 deletions(-)
---
diff --git a/lib/prop_dict.c b/lib/prop_dict.c
index c739ae7..a03f393 100644
--- a/lib/prop_dict.c
+++ b/lib/prop_dict.c
@@ -211,7 +211,7 @@ edited (GtkCellRendererText *cell,
gtk_tree_model_get_iter (model, &iter, path);
gtk_tree_store_set (GTK_TREE_STORE (model), &iter, VALUE_COLUMN, new_text, -1);
-
+ g_object_set_data (G_OBJECT (model), "modified", GINT_TO_POINTER (1));
gtk_tree_path_free (path);
}
@@ -259,7 +259,9 @@ dictprop_get_widget (DictProperty *prop, PropDialog *dialog)
GtkWidget *ret;
ret = _create_view (_create_model (prop));
gtk_widget_show_all (ret);
- /* FIXME: prophandler_connect(&prop->common, G_OBJECT(ret), "value_changed"); */
+ /* prophandler_connect(&prop->common, G_OBJECT(ret), "value_changed");
+ * It's not so easy, we are maintaining our own changed state via edited signal
+ */
return ret;
}
static void
@@ -277,6 +279,8 @@ dictprop_reset_widget(DictProperty *prop, GtkWidget *widget)
prop->dict = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
g_hash_table_foreach (prop->dict, _keyvalue_fill_model, model);
+ g_object_set_data (G_OBJECT (model), "modified", GINT_TO_POINTER (0));
+
/* also add the well known ? */
for (wkk = _well_known; wkk->name != NULL; ++wkk) {
gchar *val;
@@ -316,8 +320,9 @@ dictprop_set_from_widget(DictProperty *prop, GtkWidget *widget)
g_hash_table_insert (prop->dict, key, val);
else /* delete stuff which has no value any longer */
g_hash_table_remove (prop->dict, key);
- /* FIXME: enough to replace prophandler_connect() ? */
- prop->common.experience &= ~PXP_NOTSET;
+ /* enough to replace prophandler_connect() ? */
+ if (g_object_get_data (G_OBJECT (model), "modified"))
+ prop->common.experience &= ~PXP_NOTSET;
}
} while (gtk_tree_model_iter_next (model, &iter));
}
diff --git a/lib/propobject.c b/lib/propobject.c
index 2f9d268..026b35a 100644
--- a/lib/propobject.c
+++ b/lib/propobject.c
@@ -217,7 +217,9 @@ object_apply_props_from_dialog(DiaObject *obj, WIDGET *dialog_widget)
if ((p->experience & PXP_NOTSET) == 0)
g_ptr_array_add(props, p);
}
-
+ /* with an empty list there is no change at all but simply
+ * returning NULL is against the contract ...
+ */
if (!obj->ops->apply_properties_list) {
g_warning("using a fallback function to apply properties;"
" undo may not work correctly");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]