From e8fad70e9ff924c66434cab62775478617550476 Mon Sep 17 00:00:00 2001 From: Not Zed Date: Thu, 15 Mar 2001 06:55:22 +0000 Subject: Changed the edit_filter to be a standalone window rather than a widget, so 2001-03-15 Not Zed * filter.glade: Changed the edit_filter to be a standalone window rather than a widget, so we can get the rule editor part out separately. Same for vfolder editor, and new score, and basic rule editors. * score-editor.c (score_editor_new): Turned back on object stuff, subclass rule-editor, and removed most of the code. * filter-editor.c (filter_editor_new): Turned into an object, subclass rule-editor, removed most of the code. Now we accept the source list during create, and plug that into the glade. * vfolder-editor.c (vfolder_editor_new): Turned back on object stuff, subclass rule-editor, and removed most of the code. * Makefile.am (libfilter_la_SOURCES): Added rule-editor.[ch]. * filter-filter.c (validate): inherit the validate function and also validate the actions part of a filterfilter. * filter-rule.c (filter_rule_validate): New method so that filter rules can validate themselves. (validate): Default implementation, validates base rules. * rule-editor.h: New generic rule editor, to be used for filter editor/vfolder editor/score editor/saved searches editor. svn path=/trunk/; revision=8729 --- filter/filter-rule.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'filter/filter-rule.c') diff --git a/filter/filter-rule.c b/filter/filter-rule.c index f99c79e89b..e63e7df5fd 100644 --- a/filter/filter-rule.c +++ b/filter/filter-rule.c @@ -30,6 +30,7 @@ #define d(x) +static int validate(FilterRule *); static xmlNodePtr xml_encode (FilterRule *); static int xml_decode (FilterRule *, xmlNodePtr, RuleContext *); static void build_code (FilterRule *, GString * out); @@ -86,6 +87,7 @@ filter_rule_class_init (FilterRuleClass * class) object_class->finalize = filter_rule_finalise; /* override methods */ + class->validate = validate; class->xml_encode = xml_encode; class->xml_decode = xml_decode; class->build_code = build_code; @@ -174,6 +176,29 @@ filter_rule_set_source (FilterRule *fr, const char *source) fr->source = g_strdup (source); } +int filter_rule_validate (FilterRule *fr) +{ + g_assert(IS_FILTER_RULE(fr)); + + return ((FilterRuleClass *) ((GtkObject *) fr)->klass)->validate(fr); +} + +static int +validate(FilterRule *fr) +{ + int valid = TRUE; + GList *parts; + + /* validate rule parts */ + parts = fr->parts; + while (parts && valid) { + valid = filter_part_validate((FilterPart *)parts->data); + parts = parts->next; + } + + return valid; +} + xmlNodePtr filter_rule_xml_encode (FilterRule *fr) { -- cgit