aboutsummaryrefslogtreecommitdiffstats
path: root/filter/filter-xml.c
diff options
context:
space:
mode:
authorNotZed <NotZed@HelixCode.com>2000-02-22 18:09:07 +0800
committerMichael Zucci <zucchi@src.gnome.org>2000-02-22 18:09:07 +0800
commit7c6897ee95e4346e991185c014bcfce003809fd8 (patch)
treeb34cb809263e9641c3311168c43b8977812e91be /filter/filter-xml.c
parent6b21505b40126e00636603c705b771e5c857beef (diff)
downloadgsoc2013-evolution-7c6897ee95e4346e991185c014bcfce003809fd8.tar.gz
gsoc2013-evolution-7c6897ee95e4346e991185c014bcfce003809fd8.tar.zst
gsoc2013-evolution-7c6897ee95e4346e991185c014bcfce003809fd8.zip
New utility functions for working with the internal rule format.
2000-02-22 NotZed <NotZed@HelixCode.com> * filter-xml.c (filter_clone_optionrule): (filter_clone_optionrule_free): (filter_optionrule_new_from_rule): New utility functions for working with the internal rule format. * filter-arg.[ch]: Added new callbacks for editing a single value, and a new editor which shows all items in a list, and allows you to edit them via the single-edit method. This needs some cleanup for some unused/unusable virtual methods (edit_values, write_html?). * Makefile: Add the druid for build. * filter-druid.c: A 'druid' widget for editing a single filter rule. svn path=/trunk/; revision=1901
Diffstat (limited to 'filter/filter-xml.c')
-rw-r--r--filter/filter-xml.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/filter/filter-xml.c b/filter/filter-xml.c
index 144bd88f0d..2371acc5a1 100644
--- a/filter/filter-xml.c
+++ b/filter/filter-xml.c
@@ -388,6 +388,72 @@ filter_write_optionset(xmlDocPtr doc, GList *optionl)
return root;
}
+/* utility functions */
+struct filter_optionrule *
+filter_clone_optionrule(struct filter_optionrule *or)
+{
+ GList *arg;
+ struct filter_optionrule *rule;
+
+ rule = g_malloc0(sizeof(*rule));
+
+ rule->rule = or->rule;
+ arg = or->args;
+ while (arg) {
+ rule->args = g_list_append(rule->args, filter_arg_clone(FILTER_ARG(arg->data)));
+ arg = g_list_next(arg);
+ }
+ return rule;
+}
+
+void
+filter_clone_optionrule_free(struct filter_optionrule *or)
+{
+ GList *argl;
+ struct filter_optionrule *rule;
+
+ argl = or->args;
+ while (argl) {
+ gtk_object_unref(GTK_OBJECT(argl->data));
+ argl = g_list_next(argl);
+ }
+ g_list_free(or->args);
+ g_free(or);
+}
+
+struct filter_optionrule *
+filter_optionrule_new_from_rule(struct filter_rule *rule)
+{
+ struct filter_optionrule *or;
+ GList *descl;
+
+ or = g_malloc0(sizeof(*or));
+
+ or->rule = rule;
+
+ descl = rule->description;
+ while (descl) {
+ struct filter_desc *desc = descl->data;
+ if (desc->varname && desc->vartype != -1) {
+ FilterArg *arg = NULL;
+ switch (desc->vartype) {
+ case FILTER_XML_ADDRESS:
+ arg = filter_arg_address_new(desc->varname);
+ break;
+ case FILTER_XML_FOLDER:
+ arg = filter_arg_folder_new(desc->varname);
+ break;
+ }
+ if (arg) {
+ or->args = g_list_append(or->args, arg);
+ }
+ }
+ descl = g_list_next(descl);
+ }
+ return or;
+}
+
+
#ifdef TESTER
int main(int argc, char **argv)
{