From e01b1d7c259f148847e97d4c3e609933e26a73cf Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Wed, 12 Sep 2001 22:06:46 +0000 Subject: Clone the current rule before editing it so that changes can be undone. 2001-09-12 Jeffrey Stedfast * rule-editor.c (rule_edit): Clone the current rule before editing it so that changes can be undone. (edit_editor_clicked): If the user hit OK, replace the original rule with the new one. * vfolder-rule.c (vfolder_rule_finalise): Free the sources list. (rule_copy): Implemented. * filter-filter.c (rule_copy): Implemented. * filter-rule.c (filter_rule_copy): New convenience function to copy one rule "into" another. (rule_copy): Default implementation. (filter_rule_clone): Use filter_rule_copy() internally to get rid of the nastiness/slowness of xml encoding and then decoding. svn path=/trunk/; revision=12787 --- filter/rule-editor.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'filter/rule-editor.c') diff --git a/filter/rule-editor.c b/filter/rule-editor.c index 5a6718660d..e966ef89ad 100644 --- a/filter/rule-editor.c +++ b/filter/rule-editor.c @@ -271,6 +271,9 @@ edit_editor_clicked (GtkWidget *dialog, int button, RuleEditor *re) string = e_utf8_to_gtk_string (GTK_WIDGET (item), re->current->name); gtk_label_set_text (GTK_LABEL (GTK_BIN (item)->child), string); g_free (string); + + /* replace the old rule with the new rule */ + filter_rule_copy (re->current, re->edit); } case 1: default: @@ -292,10 +295,9 @@ rule_edit (GtkWidget *widget, RuleEditor *re) if (re->current == NULL) return; - re->edit = re->current; - gtk_object_ref (GTK_OBJECT (re->edit)); + re->edit = filter_rule_clone (re->current); - rules = filter_rule_get_widget (re->current, re->context); + rules = filter_rule_get_widget (re->edit, re->context); dialog = gnome_dialog_new (_("Edit Rule"), GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_CANCEL, -- cgit v1.2.3