From f6b959c9ecc0af67fb7607de5ae6645b4f3e2cbc Mon Sep 17 00:00:00 2001 From: Not Zed Date: Thu, 8 Aug 2002 02:49:56 +0000 Subject: Dont allow duplicate names. (edit_editor_clicked): Same here. For #24803. 2002-08-08 Not Zed * rule-editor.c (add_editor_clicked): Dont allow duplicate names. (edit_editor_clicked): Same here. For #24803. svn path=/trunk/; revision=17739 --- filter/ChangeLog | 5 +++++ filter/rule-editor.c | 31 +++++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/filter/ChangeLog b/filter/ChangeLog index 496a401448..fa6ddced4d 100644 --- a/filter/ChangeLog +++ b/filter/ChangeLog @@ -1,3 +1,8 @@ +2002-08-08 Not Zed + + * rule-editor.c (add_editor_clicked): Dont allow duplicate names. + (edit_editor_clicked): Same here. For #24803. + 2002-08-06 Jeffrey Stedfast * rule-context.c (save): Don't need to save temp/backup files diff --git a/filter/rule-editor.c b/filter/rule-editor.c index f9350ea372..9ef0084340 100644 --- a/filter/rule-editor.c +++ b/filter/rule-editor.c @@ -25,8 +25,9 @@ #include #include #include +#include +#include #include - #include #include #include "rule-editor.h" @@ -230,6 +231,18 @@ add_editor_clicked (GtkWidget *dialog, int button, RuleEditor *re) /* no need to popup a dialog because the validate code does that. */ return; } + + if (rule_context_find_rule(re->context, re->edit->name, re->edit->source)) { + GtkWidget *dialog; + char *what; + + what = g_strdup_printf(_("Rule name '%s' is not unique, choose another"), re->edit->name); + dialog = gnome_ok_dialog (what); + g_free(what); + gnome_dialog_run_and_close (GNOME_DIALOG (dialog)); + + return; + } gtk_object_ref (GTK_OBJECT (re->edit)); string = e_utf8_to_gtk_string (GTK_WIDGET (re->list), re->edit->name); @@ -305,13 +318,27 @@ edit_editor_clicked (GtkWidget *dialog, int button, RuleEditor *re) GtkWidget *item; char *string; int pos; - + struct _FilterRule *rule; + switch (button) { case 0: if (!filter_rule_validate (re->edit)) { /* no need to popup a dialog because the validate code does that. */ return; } + + rule = rule_context_find_rule(re->context, re->edit->name, re->edit->source); + if (rule != NULL && rule != re->current) { + GtkWidget *dialog; + char *what; + + what = g_strdup_printf(_("Rule name '%s' is not unique, choose another"), re->edit->name); + dialog = gnome_ok_dialog (what); + g_free(what); + gnome_dialog_run_and_close (GNOME_DIALOG (dialog)); + + return; + } pos = rule_context_get_rank_rule (re->context, re->current, re->source); if (pos != -1) { -- cgit v1.2.3