diff options
author | Not Zed <NotZed@Ximian.com> | 2004-06-17 15:34:07 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2004-06-17 15:34:07 +0800 |
commit | 5d5f3b88c3ad76e0b81763f9c48b7fee84df2292 (patch) | |
tree | 09183c61366e096483b998752eb9eb37224c210f | |
parent | 7ca7b54a79f4abb9aa3e173e4ef245049d7c72bc (diff) | |
download | gsoc2013-evolution-5d5f3b88c3ad76e0b81763f9c48b7fee84df2292.tar.gz gsoc2013-evolution-5d5f3b88c3ad76e0b81763f9c48b7fee84df2292.tar.zst gsoc2013-evolution-5d5f3b88c3ad76e0b81763f9c48b7fee84df2292.zip |
** See #59885.
2004-06-17 Not Zed <NotZed@Ximian.com>
** See #59885.
** Moved all of the mailer specific filter stuff into mail/*.
* filter-element.c (copy_value): implement for base types.
* filter-element.c (filter_element_copy_value): do this as a
virtual method.
* filter.glade: moved the vfolder stuff to mail/
* libfilter-i18n.h: removed, moved to mailer.
* filter-errors.xml: moved the vfolder/filtering errors to the
mail error file.
* Makefile.am (EXTRA_DIST): moved *types.xml to mail.
(INCLUDES): removed a bunch of mail dependencies.
* filter-*.[ch], vfolder-*.[ch]: Moved all mail related filter and
vfolder stuff to mail directory.
* score-*.[ch]: Removed all of it.
* vfolder-context.c (vfolder_new_element): and for vfolders.
* filter-context.c (filter_new_element): implement for filter
element types.
* rule-context.c (rc_new_element): replacement for old
filter_element_new_type_name. only has the basics.
* filter-part.c (filter_part_xml_create): take a rule context
as an argument & and look up the element name off the context.
* rule-context.c (rule_context_new_element): new virtual method to
get an element for a given name.
* filter-element.c (filter_element_new_type_name): removed.
svn path=/trunk/; revision=26379
38 files changed, 159 insertions, 5731 deletions
diff --git a/filter/ChangeLog b/filter/ChangeLog index b085bdd673..ebacac378d 100644 --- a/filter/ChangeLog +++ b/filter/ChangeLog @@ -1,3 +1,45 @@ +2004-06-17 Not Zed <NotZed@Ximian.com> + + ** See #59885. + + ** Moved all of the mailer specific filter stuff into mail/*. + + * filter-element.c (copy_value): implement for base types. + + * filter-element.c (filter_element_copy_value): do this as a + virtual method. + + * filter.glade: moved the vfolder stuff to mail/ + + * libfilter-i18n.h: removed, moved to mailer. + + * filter-errors.xml: moved the vfolder/filtering errors to the + mail error file. + + * Makefile.am (EXTRA_DIST): moved *types.xml to mail. + (INCLUDES): removed a bunch of mail dependencies. + + * filter-*.[ch], vfolder-*.[ch]: Moved all mail related filter and + vfolder stuff to mail directory. + + * score-*.[ch]: Removed all of it. + + * vfolder-context.c (vfolder_new_element): and for vfolders. + + * filter-context.c (filter_new_element): implement for filter + element types. + + * rule-context.c (rc_new_element): replacement for old + filter_element_new_type_name. only has the basics. + + * filter-part.c (filter_part_xml_create): take a rule context + as an argument & and look up the element name off the context. + + * rule-context.c (rule_context_new_element): new virtual method to + get an element for a given name. + + * filter-element.c (filter_element_new_type_name): removed. + 2004-06-08 Not Zed <NotZed@Ximian.com> * filtertypes.xml: give the junk test a unique name. #59567. diff --git a/filter/Makefile.am b/filter/Makefile.am index 0e7fd2f4b7..f84be24c73 100644 --- a/filter/Makefile.am +++ b/filter/Makefile.am @@ -3,9 +3,7 @@ glade_DATA = filter.glade INCLUDES = \ -I $(top_srcdir) \ - -I $(top_srcdir)/camel \ -I $(top_srcdir)/e-util \ - -I $(top_srcdir)/shell \ -I $(top_srcdir)/widgets/misc \ -DFILTER_GLADEDIR=\"$(gladedir)\" \ -DG_LOG_DOMAIN=\"filter\" \ @@ -19,20 +17,12 @@ libfilter_la_SOURCES = \ filter-code.h \ filter-colour.c \ filter-colour.h \ - filter-context.c \ - filter-context.h \ filter-datespec.c \ filter-datespec.h \ - filter-editor.c \ - filter-editor.h \ filter-element.c \ filter-element.h \ filter-file.c \ filter-file.h \ - filter-filter.c \ - filter-filter.h \ - filter-folder.c \ - filter-folder.h \ filter-input.c \ filter-input.h \ filter-int.c \ @@ -47,54 +37,25 @@ libfilter_la_SOURCES = \ filter-part.h \ filter-rule.c \ filter-rule.h \ - filter-source.h \ - filter-source.c \ rule-context.c \ rule-context.h \ rule-editor.c \ - rule-editor.h \ - score-context.c \ - score-context.h \ - score-editor.c \ - score-editor.h \ - score-rule.c \ - score-rule.h \ - vfolder-context.c \ - vfolder-context.h \ - vfolder-editor.c \ - vfolder-editor.h \ - vfolder-rule.c \ - vfolder-rule.h - -libfilter_la_DEPENDENCIES = libfilter-i18n.h + rule-editor.h EXTRA_DIST = \ $(glade_DATA) \ $(error_DATA) \ $(error_i18n) \ ChangeLog.pre-1-4 \ - filter-marshal.list \ - filtertypes.xml \ - libfilter-i18n.h \ - vfoldertypes.xml \ - searchtypes.xml + filter-marshal.list # basic rules. -filterdir = $(privdatadir) -filter_DATA = filtertypes.xml vfoldertypes.xml searchtypes.xml - error_DATA = filter-errors.xml error_i18n = $(error_DATA:.xml=.xml.h) errordir = $(privdatadir)/errors %.xml.h: %.xml $(top_builddir)/e-util/e-error-tool $^ -libfilter-i18n.h: filtertypes.xml vfoldertypes.xml - echo "/* Automatically generated. Do not edit. */" > $@; \ - cat $(srcdir)/filtertypes.xml $(srcdir)/vfoldertypes.xml | \ - sed -n -e 's:.*<title>\(.*\)</title>:char *s = N_("\1");:p' | \ - sort -u >> $@ - MARSHAL_GENERATED = filter-marshal.c filter-marshal.h @EVO_MARSHAL_RULE@ diff --git a/filter/filter-context.c b/filter/filter-context.c deleted file mode 100644 index 3e82bc4c39..0000000000 --- a/filter/filter-context.c +++ /dev/null @@ -1,279 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 Ximian Inc. - * - * Authors: Not Zed <notzed@lostzed.mmc.com.au> - * Jeffrey Stedfast <fejj@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <string.h> - -#include "filter-context.h" -#include "filter-filter.h" - -/* For poking into filter-folder guts */ -#include "filter-folder.h" - -#define d(x) - -static void filter_context_class_init (FilterContextClass *klass); -static void filter_context_init (FilterContext *fc); -static void filter_context_finalise (GObject *obj); - -static GList *filter_rename_uri (RuleContext *rc, const char *olduri, const char *newuri, GCompareFunc cmp); -static GList *filter_delete_uri (RuleContext *rc, const char *uri, GCompareFunc cmp); - - -static RuleContextClass *parent_class = NULL; - - -GType -filter_context_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (FilterContextClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) filter_context_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (FilterContext), - 0, /* n_preallocs */ - (GInstanceInitFunc) filter_context_init, - }; - - type = g_type_register_static (RULE_TYPE_CONTEXT, "FilterContext", &info, 0); - } - - return type; -} - -static void -filter_context_class_init (FilterContextClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - RuleContextClass *rc_class = RULE_CONTEXT_CLASS (klass); - - parent_class = g_type_class_ref (RULE_TYPE_CONTEXT); - - object_class->finalize = filter_context_finalise; - - /* override methods */ - rc_class->rename_uri = filter_rename_uri; - rc_class->delete_uri = filter_delete_uri; -} - -static void -filter_context_init (FilterContext *fc) -{ - rule_context_add_part_set ((RuleContext *) fc, "partset", filter_part_get_type (), - rule_context_add_part, rule_context_next_part); - rule_context_add_part_set ((RuleContext *) fc, "actionset", filter_part_get_type (), - (RCPartFunc) filter_context_add_action, - (RCNextPartFunc) filter_context_next_action); - - rule_context_add_rule_set ((RuleContext *) fc, "ruleset", filter_filter_get_type (), - (RCRuleFunc) rule_context_add_rule, rule_context_next_rule); -} - -static void -filter_context_finalise (GObject *obj) -{ - FilterContext *fc = (FilterContext *)obj; - - g_list_foreach (fc->actions, (GFunc)g_object_unref, NULL); - g_list_free (fc->actions); - - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -/** - * filter_context_new: - * - * Create a new FilterContext object. - * - * Return value: A new #FilterContext object. - **/ -FilterContext * -filter_context_new (void) -{ - return (FilterContext *) g_object_new (FILTER_TYPE_CONTEXT, NULL, NULL); -} - -void -filter_context_add_action (FilterContext *fc, FilterPart *action) -{ - d(printf("find action : ")); - fc->actions = g_list_append (fc->actions, action); -} - -FilterPart * -filter_context_find_action (FilterContext *fc, const char *name) -{ - d(printf("find action : ")); - return filter_part_find_list (fc->actions, name); -} - -FilterPart * -filter_context_create_action (FilterContext *fc, const char *name) -{ - FilterPart *part; - - if ((part = filter_context_find_action (fc, name))) - return filter_part_clone (part); - - return NULL; -} - -FilterPart * -filter_context_next_action (FilterContext *fc, FilterPart *last) -{ - return filter_part_next_list (fc->actions, last); -} - -/* We search for any folders in our actions list that need updating, update them */ -static GList * -filter_rename_uri (RuleContext *rc, const char *olduri, const char *newuri, GCompareFunc cmp) -{ - FilterRule *rule; - GList *l, *el; - FilterPart *action; - FilterElement *element; - int count = 0; - GList *changed = NULL; - - d(printf("uri '%s' renamed to '%s'\n", olduri, newuri)); - - /* For all rules, for all actions, for all elements, rename any folder elements */ - /* Yes we could do this inside each part itself, but not today */ - rule = NULL; - while ((rule = rule_context_next_rule (rc, rule, NULL))) { - int rulecount = 0; - - d(printf("checking rule '%s'\n", rule->name)); - - l = FILTER_FILTER (rule)->actions; - while (l) { - action = l->data; - - d(printf("checking action '%s'\n", action->name)); - - el = action->elements; - while (el) { - element = el->data; - - d(printf("checking element '%s'\n", element->name)); - if (IS_FILTER_FOLDER (element)) { - d(printf(" is folder, existing uri = '%s'\n", - FILTER_FOLDER (element)->uri)); - } - - if (IS_FILTER_FOLDER (element) - && cmp(((FilterFolder *)element)->uri, olduri)) { - d(printf(" Changed!\n")); - filter_folder_set_value((FilterFolder *)element, newuri); - rulecount++; - } - el = el->next; - } - l = l->next; - } - - if (rulecount) { - changed = g_list_append (changed, g_strdup (rule->name)); - filter_rule_emit_changed (rule); - } - - count += rulecount; - } - - /* might need to call parent class, if it did anything ... parent_class->rename_uri(f, olduri, newuri, cmp); */ - - return changed; -} - -static GList * -filter_delete_uri (RuleContext *rc, const char *uri, GCompareFunc cmp) -{ - /* We basically do similar to above, but when we find it, - Remove the action, and if thats the last action, this might create an empty rule? remove the rule? */ - - FilterRule *rule; - GList *l, *el; - FilterPart *action; - FilterElement *element; - int count = 0; - GList *deleted = NULL; - - d(printf("uri '%s' deleted\n", uri)); - - /* For all rules, for all actions, for all elements, check deleted folder elements */ - /* Yes we could do this inside each part itself, but not today */ - rule = NULL; - while ((rule = rule_context_next_rule (rc, rule, NULL))) { - int recorded = 0; - - d(printf("checking rule '%s'\n", rule->name)); - - l = FILTER_FILTER (rule)->actions; - while (l) { - action = l->data; - - d(printf("checking action '%s'\n", action->name)); - - el = action->elements; - while (el) { - element = el->data; - - d(printf("checking element '%s'\n", element->name)); - if (IS_FILTER_FOLDER (element)) { - d(printf(" is folder, existing uri = '%s'\n", - FILTER_FOLDER (element)->uri)); - } - - if (IS_FILTER_FOLDER (element) - && cmp(((FilterFolder *)element)->uri, uri)) { - d(printf(" Deleted!\n")); - /* check if last action, if so, remove rule instead? */ - l = l->next; - filter_filter_remove_action ((FilterFilter *)rule, action); - g_object_unref (action); - count++; - if (!recorded) - deleted = g_list_append (deleted, g_strdup (rule->name)); - goto next_action; - } - el = el->next; - } - l = l->next; - next_action: - ; - } - } - - /* TODO: could call parent and merge lists */ - - return deleted; -} diff --git a/filter/filter-context.h b/filter/filter-context.h deleted file mode 100644 index 157ee6f1de..0000000000 --- a/filter/filter-context.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 Ximian Inc. - * - * Authors: Not Zed <notzed@lostzed.mmc.com.au> - * Jeffrey Stedfast <fejj@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - - -#ifndef _FILTER_CONTEXT_H -#define _FILTER_CONTEXT_H - -#include "rule-context.h" - -#define FILTER_TYPE_CONTEXT (filter_context_get_type ()) -#define FILTER_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FILTER_TYPE_CONTEXT, FilterContext)) -#define FILTER_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FILTER_TYPE_CONTEXT, FilterContextClass)) -#define IS_FILTER_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FILTER_TYPE_CONTEXT)) -#define IS_FILTER_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FILTER_TYPE_CONTEXT)) -#define FILTER_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FILTER_TYPE_CONTEXT, FilterContextClass)) - -typedef struct _FilterContext FilterContext; -typedef struct _FilterContextClass FilterContextClass; - -struct _FilterContext { - RuleContext parent_object; - - GList *actions; -}; - -struct _FilterContextClass { - RuleContextClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - -GType filter_context_get_type (void); -FilterContext *filter_context_new (void); - -/* methods */ -void filter_context_add_action (FilterContext *fc, FilterPart *action); -FilterPart *filter_context_find_action (FilterContext *fc, const char *name); -FilterPart *filter_context_create_action (FilterContext *fc, const char *name); -FilterPart *filter_context_next_action (FilterContext *fc, FilterPart *last); - -#endif /* ! _FILTER_CONTEXT_H */ diff --git a/filter/filter-editor.c b/filter/filter-editor.c deleted file mode 100644 index 884721f862..0000000000 --- a/filter/filter-editor.c +++ /dev/null @@ -1,164 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 Ximian Inc. - * - * Authors: Not Zed <notzed@lostzed.mmc.com.au> - * Jeffrey Stedfast <fejj@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gtk/gtk.h> -#include <libgnome/gnome-i18n.h> - -#include "filter-editor.h" -#include "filter-filter.h" - -#define d(x) - -static FilterRule *create_rule (RuleEditor *re); - -static void filter_editor_class_init (FilterEditorClass *klass); -static void filter_editor_init (FilterEditor *fe); -static void filter_editor_finalise (GObject *obj); - - -static RuleEditorClass *parent_class = NULL; - - -GtkType -filter_editor_get_type (void) -{ - static GtkType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (FilterEditorClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) filter_editor_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (FilterEditor), - 0, /* n_preallocs */ - (GInstanceInitFunc) filter_editor_init, - }; - - type = g_type_register_static (RULE_TYPE_EDITOR, "FilterEditor", &info, 0); - } - - return type; -} - -static void -filter_editor_class_init (FilterEditorClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - RuleEditorClass *re_class = (RuleEditorClass *) klass; - - parent_class = g_type_class_ref (rule_editor_get_type ()); - - gobject_class->finalize = filter_editor_finalise; - - /* override methods */ - re_class->create_rule = create_rule; -} - -static void -filter_editor_init (FilterEditor *fe) -{ - ; -} - -static void -filter_editor_finalise (GObject *obj) -{ - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -/** - * filter_editor_new: - * - * Create a new FilterEditor object. - * - * Return value: A new #FilterEditor object. - **/ -FilterEditor * -filter_editor_new (FilterContext *fc, const char **source_names) -{ - FilterEditor *fe = (FilterEditor *) g_object_new (FILTER_TYPE_EDITOR, NULL); - GladeXML *gui; - - gui = glade_xml_new (FILTER_GLADEDIR "/filter.glade", "rule_editor", NULL); - filter_editor_construct (fe, fc, gui, source_names); - g_object_unref (gui); - - return fe; -} - -static void -select_source (GtkMenuItem *mi, FilterEditor *fe) -{ - char *source; - - source = g_object_get_data(G_OBJECT(mi), "source"); - g_assert (source); - - rule_editor_set_source ((RuleEditor *)fe, source); -} - -void -filter_editor_construct (FilterEditor *fe, FilterContext *fc, GladeXML *gui, const char **source_names) -{ - GtkWidget *menu, *item, *omenu; - int i; - - omenu = glade_xml_get_widget (gui, "filter_source"); - gtk_option_menu_remove_menu (GTK_OPTION_MENU (omenu)); - menu = gtk_menu_new (); - - for (i = 0; source_names[i]; i++) { - item = gtk_menu_item_new_with_label (_(source_names[i])); - g_object_set_data_full (G_OBJECT (item), "source", g_strdup (source_names[i]), g_free); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); - gtk_widget_show (item); - g_signal_connect (item, "activate", G_CALLBACK (select_source), fe); - } - gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu); - gtk_widget_show (omenu); - - rule_editor_construct ((RuleEditor *) fe, (RuleContext *) fc, gui, source_names[0], _("_Filter Rules")); -} - -static FilterRule * -create_rule (RuleEditor *re) -{ - FilterRule *rule = filter_rule_new (); - FilterPart *part; - - /* create a rule with 1 part & 1 action in it */ - rule = (FilterRule *)filter_filter_new (); - part = rule_context_next_part (re->context, NULL); - filter_rule_add_part (rule, filter_part_clone (part)); - part = filter_context_next_action ((FilterContext *)re->context, NULL); - filter_filter_add_action ((FilterFilter *)rule, filter_part_clone (part)); - - return rule; -} diff --git a/filter/filter-editor.h b/filter/filter-editor.h deleted file mode 100644 index 4b01e3b877..0000000000 --- a/filter/filter-editor.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 Ximian Inc. - * - * Authors: Not Zed <notzed@lostzed.mmc.com.au> - * Jeffrey Stedfast <fejj@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - - -#ifndef _FILTER_EDITOR_H -#define _FILTER_EDITOR_H - -#include "rule-editor.h" -#include "filter-context.h" - -#define FILTER_TYPE_EDITOR (filter_editor_get_type ()) -#define FILTER_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FILTER_TYPE_EDITOR, FilterEditor)) -#define FILTER_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FILTER_TYPE_EDITOR, FilterEditorClass)) -#define IS_FILTER_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FILTER_TYPE_EDITOR)) -#define IS_FILTER_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FILTER_TYPE_EDITOR)) -#define FILTER_EDITOR_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), FILTER_TYPE_EDITOR, FilterEditorClass)) - -typedef struct _FilterEditor FilterEditor; -typedef struct _FilterEditorClass FilterEditorClass; - -struct _FilterEditor { - RuleEditor parent_object; - -}; - -struct _FilterEditorClass { - RuleEditorClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - -GtkType filter_editor_get_type (void); - -FilterEditor *filter_editor_new (FilterContext *f, const char **source_names); -void filter_editor_construct (FilterEditor *fe, FilterContext *fc, GladeXML *gui, const char **source_names); - -#endif /* ! _FILTER_EDITOR_H */ diff --git a/filter/filter-element.c b/filter/filter-element.c index 5f68f78804..14aef0a015 100644 --- a/filter/filter-element.c +++ b/filter/filter-element.c @@ -29,30 +29,26 @@ #include <stdlib.h> #include "filter-element.h" -#include "filter-input.h" -#include "filter-option.h" -#include "filter-code.h" -#include "filter-colour.h" -#include "filter-datespec.h" -#include "filter-int.h" -#include "filter-folder.h" -#include "filter-source.h" -#include "filter-file.h" -#include "filter-label.h" +struct _element_type { + char *name; + + FilterElementFunc create; + void *data; +}; static gboolean validate (FilterElement *fe); static int element_eq(FilterElement *fe, FilterElement *cm); static void xml_create(FilterElement *fe, xmlNodePtr node); static FilterElement *clone(FilterElement *fe); +static void copy_value(FilterElement *de, FilterElement *se); static void filter_element_class_init (FilterElementClass *klass); static void filter_element_init (FilterElement *fe); static void filter_element_finalise (GObject *obj); - static GObjectClass *parent_class = NULL; - +static GHashTable *fe_table; GType filter_element_get_type (void) @@ -71,7 +67,7 @@ filter_element_get_type (void) 0, /* n_preallocs */ (GInstanceInitFunc) filter_element_init, }; - + fe_table = g_hash_table_new(g_str_hash, g_str_equal); type = g_type_register_static (G_TYPE_OBJECT, "FilterElement", &info, 0); } @@ -81,17 +77,16 @@ filter_element_get_type (void) static void filter_element_class_init (FilterElementClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); - parent_class = g_type_class_ref (G_TYPE_OBJECT); - object_class->finalize = filter_element_finalise; + ((GObjectClass *)klass)->finalize = filter_element_finalise; /* override methods */ klass->validate = validate; klass->eq = element_eq; klass->xml_create = xml_create; klass->clone = clone; + klass->copy_value = copy_value; } static void @@ -238,55 +233,6 @@ filter_element_format_sexp (FilterElement *fe, GString *out) FILTER_ELEMENT_GET_CLASS (fe)->format_sexp (fe, out); } -/** - * filter_element_new_type_name: - * @type: filter element type - * - * Create a new filter element based on its type name. - * - * Return value: - **/ -FilterElement * -filter_element_new_type_name (const char *type) -{ - if (type == NULL) - return NULL; - - if (!strcmp (type, "string")) { - return (FilterElement *) filter_input_new (); - } else if (!strcmp (type, "folder")) { - return (FilterElement *) filter_folder_new (); - } else if (!strcmp (type, "address")) { - /* FIXME: temporary ... need real address type */ - return (FilterElement *) filter_input_new_type_name (type); - } else if (!strcmp (type, "code")) { - return (FilterElement *) filter_code_new (); - } else if (!strcmp (type, "colour")) { - return (FilterElement *) filter_colour_new (); - } else if (!strcmp (type, "optionlist") || !strcmp (type, "system-flag")) { - return (FilterElement *) filter_option_new (); - } else if (!strcmp (type, "datespec")) { - return (FilterElement *) filter_datespec_new (); - } else if (!strcmp (type, "score")) { - return (FilterElement *) filter_int_new_type("score", -3, 3); - } else if (!strcmp (type, "integer")) { - return (FilterElement *) filter_int_new (); - } else if (!strcmp (type, "regex")) { - return (FilterElement *) filter_input_new_type_name (type); - } else if (!strcmp (type, "source")) { - return (FilterElement *) filter_source_new (); - } else if (!strcmp (type, "command")) { - return (FilterElement *) filter_file_new_type_name (type); - } else if (!strcmp (type, "file")) { - return (FilterElement *) filter_file_new_type_name (type); - } else if (!strcmp (type, "label")) { - return (FilterElement *) filter_label_new (); - } else { - g_warning("Unknown filter type '%s'", type); - return NULL; - } -} - void filter_element_set_data (FilterElement *fe, gpointer data) { @@ -327,12 +273,19 @@ clone (FilterElement *fe) return new; } -/* only copies the value, not the name/type */ -void -filter_element_copy_value (FilterElement *de, FilterElement *se) -{ - /* bit of a hack, but saves having to do the same in each type ? */ +/* This is somewhat hackish, implement all the base cases in here */ +#include "filter-input.h" +#include "filter-option.h" +#include "filter-code.h" +#include "filter-colour.h" +#include "filter-datespec.h" +#include "filter-int.h" +#include "filter-file.h" +#include "filter-label.h" +static void +copy_value(FilterElement *de, FilterElement *se) +{ if (IS_FILTER_INPUT(se)) { if (IS_FILTER_INPUT(de)) { if (((FilterInput *)se)->values) @@ -340,10 +293,6 @@ filter_element_copy_value (FilterElement *de, FilterElement *se) } else if (IS_FILTER_INT(de)) { ((FilterInt *)de)->val = atoi((char *) ((FilterInput *)se)->values->data); } - } else if (IS_FILTER_FOLDER(se)) { - if (IS_FILTER_FOLDER(de)) { - filter_folder_set_value((FilterFolder *)de, ((FilterFolder *)se)->uri); - } } else if (IS_FILTER_COLOUR(se)) { if (IS_FILTER_COLOUR(de)) { FilterColour *s = (FilterColour *)se, *d = (FilterColour *)de; @@ -383,3 +332,10 @@ filter_element_copy_value (FilterElement *de, FilterElement *se) } } } + +/* only copies the value, not the name/type */ +void +filter_element_copy_value (FilterElement *de, FilterElement *se) +{ + FILTER_ELEMENT_GET_CLASS (de)->copy_value(de, se); +} diff --git a/filter/filter-element.h b/filter/filter-element.h index 75627686ae..12fb3b9251 100644 --- a/filter/filter-element.h +++ b/filter/filter-element.h @@ -39,6 +39,8 @@ typedef struct _FilterElement FilterElement; typedef struct _FilterElementClass FilterElementClass; +typedef FilterElement *(*FilterElementFunc)(void *data); + struct _FilterElement { GObject parent_object; @@ -60,7 +62,8 @@ struct _FilterElementClass { int (*xml_decode) (FilterElement *, xmlNodePtr); FilterElement *(*clone) (FilterElement *fe); - + void (*copy_value)(FilterElement *fe, FilterElement *se); + GtkWidget *(*get_widget) (FilterElement *); void (*build_code) (FilterElement *, GString *, struct _FilterPart *ff); void (*format_sexp) (FilterElement *, GString *); @@ -71,8 +74,6 @@ struct _FilterElementClass { GType filter_element_get_type (void); FilterElement *filter_element_new (void); -FilterElement *filter_element_new_type_name (const char *type); - void filter_element_set_data (FilterElement *fe, gpointer data); /* methods */ diff --git a/filter/filter-errors.xml b/filter/filter-errors.xml index d7ad6ab55b..21487f04f7 100644 --- a/filter/filter-errors.xml +++ b/filter/filter-errors.xml @@ -16,11 +16,6 @@ <secondary>You must specify a file name.</secondary> </error> - <error id="no-folder" type="error"> - <primary>Missing folder.</primary> - <secondary>You must specify a folder.</secondary> - </error> - <error id="bad-regexp" type="error"> <primary>Bad regular expression "{0}".</primary> <secondary>Could not compile regular expression "{1}".</secondary> @@ -31,21 +26,9 @@ <secondary>You must name this filter.</secondary> </error> - <error id="no-name-vfolder" type="error"> - <primary>Missing name.</primary> - <secondary>You must name this vFolder.</secondary> - </error> - <error id="bad-name-notunique" type="error"> <primary>Name "{0}" already used.</primary> <secondary>Please choose another name.</secondary> </error> - <error id="vfolder-no-source" type="error"> - <primary>No sources selected.</primary> - <secondary>You must specify at least one folder as a source. -Either by selecting the folders individually, and/or by selecting -all local folders, all remote folders, or both.</secondary> - </error> - </error-list>
\ No newline at end of file diff --git a/filter/filter-errors.xml.h b/filter/filter-errors.xml.h index f8ed2d6ffb..f14c26698b 100644 --- a/filter/filter-errors.xml.h +++ b/filter/filter-errors.xml.h @@ -10,10 +10,6 @@ char *s = N_("You must specify a file name."); char *s = N_("File \"{0}\" does not exist or is not a regular file."); /* filter:bad-file secondary */ char *s = N_("You must specify a file name."); -/* filter:no-folder primary */ -char *s = N_("Missing folder."); -/* filter:no-folder secondary */ -char *s = N_("You must specify a folder."); /* filter:bad-regexp primary */ char *s = N_("Bad regular expression \"{0}\"."); /* filter:bad-regexp secondary */ @@ -22,17 +18,7 @@ char *s = N_("Could not compile regular expression \"{1}\"."); char *s = N_("Missing name."); /* filter:no-name secondary */ char *s = N_("You must name this filter."); -/* filter:no-name-vfolder primary */ -char *s = N_("Missing name."); -/* filter:no-name-vfolder secondary */ -char *s = N_("You must name this vFolder."); /* filter:bad-name-notunique primary */ char *s = N_("Name \"{0}\" already used."); /* filter:bad-name-notunique secondary */ char *s = N_("Please choose another name."); -/* filter:vfolder-no-source primary */ -char *s = N_("No sources selected."); -/* filter:vfolder-no-source secondary */ -char *s = N_("You must specify at least one folder as a source.\n" - "Either by selecting the folders individually, and/or by selecting\n" - "all local folders, all remote folders, or both."); diff --git a/filter/filter-filter.c b/filter/filter-filter.c deleted file mode 100644 index 6dc53d9593..0000000000 --- a/filter/filter-filter.c +++ /dev/null @@ -1,548 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 Ximian Inc. - * - * Authors: Not Zed <notzed@ximian.com> - * Jeffrey Stedfast <fejj@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <string.h> - -#include <gtk/gtk.h> -#include <libgnome/gnome-i18n.h> - -#include "filter-filter.h" -#include "filter-context.h" - -#define d(x) - -static int validate(FilterRule *fr); -static int filter_eq(FilterRule *fr, FilterRule *cm); -static xmlNodePtr xml_encode (FilterRule *fr); -static int xml_decode (FilterRule *fr, xmlNodePtr, RuleContext *rc); -static void rule_copy (FilterRule *dest, FilterRule *src); -/*static void build_code(FilterRule *, GString *out);*/ -static GtkWidget *get_widget (FilterRule *fr, RuleContext *rc); - -static void filter_filter_class_init (FilterFilterClass *klass); -static void filter_filter_init (FilterFilter *ff); -static void filter_filter_finalise (GObject *obj); - - -static FilterRuleClass *parent_class = NULL; - - -GType -filter_filter_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (FilterFilterClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) filter_filter_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (FilterFilter), - 0, /* n_preallocs */ - (GInstanceInitFunc) filter_filter_init, - }; - - type = g_type_register_static (FILTER_TYPE_RULE, "FilterFilter", &info, 0); - } - - return type; -} - -static void -filter_filter_class_init (FilterFilterClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - FilterRuleClass *fr_class = (FilterRuleClass *) klass; - - parent_class = g_type_class_ref (FILTER_TYPE_RULE); - - object_class->finalize = filter_filter_finalise; - - /* override methods */ - fr_class->validate = validate; - fr_class->eq = filter_eq; - fr_class->xml_encode = xml_encode; - fr_class->xml_decode = xml_decode; - /*fr_class->build_code = build_code;*/ - fr_class->copy = rule_copy; - fr_class->get_widget = get_widget; -} - -static void -filter_filter_init (FilterFilter *ff) -{ - ; -} - -static void -unref_list (GList *l) -{ - while (l) { - g_object_unref (l->data); - l = l->next; - } -} - -static void -filter_filter_finalise (GObject *obj) -{ - FilterFilter *ff = (FilterFilter *) obj; - - unref_list (ff->actions); - g_list_free (ff->actions); - - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -/** - * filter_filter_new: - * - * Create a new FilterFilter object. - * - * Return value: A new #FilterFilter object. - **/ -FilterFilter * -filter_filter_new (void) -{ - return (FilterFilter *) g_object_new (FILTER_TYPE_FILTER, NULL, NULL); -} - -void -filter_filter_add_action (FilterFilter *fr, FilterPart *fp) -{ - fr->actions = g_list_append (fr->actions, fp); - - filter_rule_emit_changed ((FilterRule *) fr); -} - -void -filter_filter_remove_action (FilterFilter *fr, FilterPart *fp) -{ - fr->actions = g_list_remove (fr->actions, fp); - - filter_rule_emit_changed ((FilterRule *) fr); -} - -void -filter_filter_replace_action (FilterFilter *fr, FilterPart *fp, FilterPart *new) -{ - GList *l; - - l = g_list_find (fr->actions, fp); - if (l) { - l->data = new; - } else { - fr->actions = g_list_append (fr->actions, new); - } - - filter_rule_emit_changed ((FilterRule *) fr); -} - -void -filter_filter_build_action (FilterFilter *fr, GString *out) -{ - g_string_append (out, "(begin\n"); - filter_part_build_code_list (fr->actions, out); - g_string_append (out, ")\n"); -} - -static int -validate (FilterRule *fr) -{ - FilterFilter *ff = (FilterFilter *) fr; - GList *parts; - int valid; - - valid = FILTER_RULE_CLASS (parent_class)->validate (fr); - - /* validate rule actions */ - parts = ff->actions; - while (parts && valid) { - valid = filter_part_validate ((FilterPart *) parts->data); - parts = parts->next; - } - - return valid; -} - -static int -list_eq (GList *al, GList *bl) -{ - int truth = TRUE; - - while (truth && al && bl) { - FilterPart *a = al->data, *b = bl->data; - - truth = filter_part_eq (a, b); - al = al->next; - bl = bl->next; - } - - return truth && al == NULL && bl == NULL; -} - -static int -filter_eq (FilterRule *fr, FilterRule *cm) -{ - return FILTER_RULE_CLASS (parent_class)->eq (fr, cm) - && list_eq (((FilterFilter *) fr)->actions, ((FilterFilter *) cm)->actions); -} - -static xmlNodePtr -xml_encode (FilterRule *fr) -{ - FilterFilter *ff = (FilterFilter *) fr; - xmlNodePtr node, set, work; - GList *l; - - node = FILTER_RULE_CLASS (parent_class)->xml_encode (fr); - g_assert (node != NULL); - set = xmlNewNode (NULL, "actionset"); - xmlAddChild (node, set); - l = ff->actions; - while (l) { - work = filter_part_xml_encode ((FilterPart *) l->data); - xmlAddChild (set, work); - l = l->next; - } - - return node; - -} - -static void -load_set (xmlNodePtr node, FilterFilter *ff, RuleContext *rc) -{ - xmlNodePtr work; - char *rulename; - FilterPart *part; - - work = node->children; - while (work) { - if (!strcmp (work->name, "part")) { - rulename = xmlGetProp (work, "name"); - part = filter_context_find_action ((FilterContext *) rc, rulename); - if (part) { - part = filter_part_clone (part); - filter_part_xml_decode (part, work); - filter_filter_add_action (ff, part); - } else { - g_warning ("cannot find rule part '%s'\n", rulename); - } - xmlFree (rulename); - } else if (work->type == XML_ELEMENT_NODE) { - g_warning ("Unknown xml node in part: %s", work->name); - } - work = work->next; - } -} - -static int -xml_decode (FilterRule *fr, xmlNodePtr node, RuleContext *rc) -{ - FilterFilter *ff = (FilterFilter *) fr; - xmlNodePtr work; - int result; - - result = FILTER_RULE_CLASS (parent_class)->xml_decode (fr, node, rc); - if (result != 0) - return result; - - work = node->children; - while (work) { - if (!strcmp (work->name, "actionset")) { - load_set (work, ff, rc); - } - work = work->next; - } - - return 0; -} - -static void -rule_copy (FilterRule *dest, FilterRule *src) -{ - FilterFilter *fdest, *fsrc; - GList *node; - - fdest = (FilterFilter *) dest; - fsrc = (FilterFilter *) src; - - if (fdest->actions) { - g_list_foreach (fdest->actions, (GFunc) g_object_unref, NULL); - g_list_free (fdest->actions); - fdest->actions = NULL; - } - - node = fsrc->actions; - while (node) { - FilterPart *part = node->data; - - g_object_ref (part); - fdest->actions = g_list_append (fdest->actions, part); - node = node->next; - } - - FILTER_RULE_CLASS (parent_class)->copy (dest, src); -} - -/*static void build_code(FilterRule *fr, GString *out) -{ - return FILTER_RULE_CLASS (parent_class)->build_code (fr, out); -}*/ - -struct _part_data { - FilterRule *fr; - FilterContext *f; - FilterPart *part; - GtkWidget *partwidget, *container; -}; - -static void -option_activate (GtkMenuItem *item, struct _part_data *data) -{ - FilterPart *part = g_object_get_data ((GObject *) item, "part"); - FilterPart *newpart; - - /* dont update if we haven't changed */ - if (!strcmp (part->title, data->part->title)) - return; - - /* here we do a widget shuffle, throw away the old widget/rulepart, - and create another */ - if (data->partwidget) - gtk_container_remove (GTK_CONTAINER (data->container), data->partwidget); - - newpart = filter_part_clone (part); - filter_part_copy_values (newpart, data->part); - filter_filter_replace_action ((FilterFilter *) data->fr, data->part, newpart); - g_object_unref (data->part); - data->part = newpart; - data->partwidget = filter_part_get_widget (newpart); - if (data->partwidget) - gtk_box_pack_start (GTK_BOX (data->container), data->partwidget, FALSE, FALSE, 0); - - g_object_set_data ((GObject *) data->container, "part", newpart); -} - -static GtkWidget * -get_rule_part_widget (FilterContext *f, FilterPart *newpart, FilterRule *fr) -{ - FilterPart *part = NULL; - GtkWidget *menu; - GtkWidget *item; - GtkWidget *omenu; - GtkWidget *hbox; - GtkWidget *p; - int index = 0, current = 0; - struct _part_data *data; - - data = g_malloc0 (sizeof (*data)); - data->fr = fr; - data->f = f; - data->part = newpart; - - hbox = gtk_hbox_new (FALSE, 0); - p = filter_part_get_widget (newpart); - - data->partwidget = p; - data->container = hbox; - - menu = gtk_menu_new (); - while ((part = filter_context_next_action (f, part))) { - item = gtk_menu_item_new_with_label (_(part->title)); - - g_object_set_data ((GObject *) item, "part", part); - g_signal_connect (item, "activate", G_CALLBACK (option_activate), data); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); - gtk_widget_show (item); - - if (!strcmp (newpart->title, part->title)) - current = index; - - index++; - } - - omenu = gtk_option_menu_new (); - gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu); - gtk_option_menu_set_history (GTK_OPTION_MENU (omenu), current); - gtk_widget_show (omenu); - - gtk_box_pack_start (GTK_BOX (hbox), omenu, FALSE, FALSE, 0); - if (p) - gtk_box_pack_start (GTK_BOX (hbox), p, FALSE, FALSE, 0); - - gtk_widget_show_all (hbox); - - return hbox; -} - -struct _rule_data { - FilterRule *fr; - FilterContext *f; - GtkWidget *parts; -}; - -static void -less_parts (GtkWidget *button, struct _rule_data *data) -{ - FilterPart *part; - GtkWidget *rule; - GList *l; - - l = ((FilterFilter *) data->fr)->actions; - if (g_list_length (l) < 2) - return; - - rule = g_object_get_data ((GObject *) button, "rule"); - part = g_object_get_data ((GObject *) rule, "part"); - - /* remove the part from the list */ - filter_filter_remove_action ((FilterFilter *) data->fr, part); - g_object_unref (part); - - /* and from the display */ - gtk_container_remove (GTK_CONTAINER (data->parts), rule); - gtk_container_remove (GTK_CONTAINER (data->parts), button); -} - -static void -attach_rule (GtkWidget *rule, struct _rule_data *data, FilterPart *part, int row) -{ - GtkWidget *remove; - - gtk_table_attach (GTK_TABLE (data->parts), rule, 0, 1, row, row + 1, - GTK_EXPAND | GTK_FILL, 0, 0, 0); - - remove = gtk_button_new_from_stock (GTK_STOCK_REMOVE); - g_object_set_data ((GObject *) remove, "rule", rule); - g_object_set_data ((GObject *) rule, "part", part); - /*gtk_button_set_relief (GTK_BUTTON (remove), GTK_RELIEF_NONE);*/ - g_signal_connect (remove, "clicked", G_CALLBACK (less_parts), data); - gtk_table_attach (GTK_TABLE (data->parts), remove, 1, 2, row, row + 1, - 0, 0, 0, 0); - gtk_widget_show (remove); -} - -static void -more_parts (GtkWidget *button, struct _rule_data *data) -{ - FilterPart *new; - - /* create a new rule entry, use the first type of rule */ - new = filter_context_next_action ((FilterContext *) data->f, NULL); - if (new) { - GtkWidget *w; - guint16 rows; - - new = filter_part_clone (new); - filter_filter_add_action ((FilterFilter *) data->fr, new); - w = get_rule_part_widget (data->f, new, data->fr); - - rows = GTK_TABLE (data->parts)->nrows; - gtk_table_resize (GTK_TABLE (data->parts), rows + 1, 2); - attach_rule (w, data, new, rows); - } -} - -static GtkWidget * -get_widget (FilterRule *fr, RuleContext *rc) -{ - GtkWidget *widget, *hbox, *add, *label; - GtkWidget *parts, *inframe, *w; - GtkWidget *scrolledwindow; - GtkObject *hadj, *vadj; - GList *l; - FilterPart *part; - struct _rule_data *data; - FilterFilter *ff = (FilterFilter *)fr; - int rows, i = 0; - - widget = FILTER_RULE_CLASS (parent_class)->get_widget (fr, rc); - - /* and now for the action area */ - label = gtk_label_new (_("<b>Then</b>")); - gtk_label_set_use_markup (GTK_LABEL (label), TRUE); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); - gtk_box_pack_start (GTK_BOX (widget), label, FALSE, FALSE, 0); - gtk_widget_show (label); - - hbox = gtk_hbox_new (FALSE, 12); - gtk_box_pack_start (GTK_BOX (widget), hbox, TRUE, TRUE, 0); - gtk_widget_show (hbox); - - label = gtk_label_new (""); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - gtk_widget_show (label); - - inframe = gtk_vbox_new (FALSE, 6); - gtk_box_pack_start (GTK_BOX (hbox), inframe, TRUE, TRUE, 0); - - rows = g_list_length (ff->actions); - parts = gtk_table_new (rows, 2, FALSE); - data = g_malloc0 (sizeof (*data)); - data->f = (FilterContext *) rc; - data->fr = fr; - data->parts = parts; - - hbox = gtk_hbox_new (FALSE, 3); - - add = gtk_button_new_from_stock (GTK_STOCK_ADD); - /* gtk_button_set_relief (GTK_BUTTON (add), GTK_RELIEF_NONE); */ - g_signal_connect (add, "clicked", G_CALLBACK (more_parts), data); - gtk_box_pack_start (GTK_BOX (hbox), add, FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX (inframe), hbox, FALSE, FALSE, 3); - - l = ff->actions; - while (l) { - part = l->data; - d(printf ("adding action %s\n", part->title)); - w = get_rule_part_widget ((FilterContext *) rc, part, fr); - attach_rule (w, data, part, i++); - l = l->next; - } - - hadj = gtk_adjustment_new (0.0, 0.0, 1.0, 1.0 ,1.0, 1.0); - vadj = gtk_adjustment_new (0.0, 0.0, 1.0, 1.0 ,1.0, 1.0); - scrolledwindow = gtk_scrolled_window_new (GTK_ADJUSTMENT (hadj), GTK_ADJUSTMENT (vadj)); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - - gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolledwindow), parts); - - gtk_box_pack_start (GTK_BOX (inframe), scrolledwindow, TRUE, TRUE, 0); - - /*gtk_box_pack_start (GTK_BOX (inframe), parts, FALSE, FALSE, 3);*/ - - gtk_widget_show_all (widget); - - return widget; -} diff --git a/filter/filter-filter.h b/filter/filter-filter.h deleted file mode 100644 index 1fcff3fa3a..0000000000 --- a/filter/filter-filter.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 Ximian Inc. - * - * Authors: Not Zed <notzed@lostzed.mmc.com.au> - * Jeffrey Stedfast <fejj@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - - -#ifndef _FILTER_FILTER_H -#define _FILTER_FILTER_H - -#include "filter-rule.h" - -#define FILTER_TYPE_FILTER (filter_filter_get_type ()) -#define FILTER_FILTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FILTER_TYPE_FILTER, FilterFilter)) -#define FILTER_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FILTER_TYPE_FILTER, FilterFilterClass)) -#define IS_FILTER_FILTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FILTER_TYPE_FILTER)) -#define IS_FILTER_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FILTER_TYPE_FILTER)) -#define FILTER_FILTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FILTER_TYPE_FILTER, FilterFilterClass)) - -typedef struct _FilterFilter FilterFilter; -typedef struct _FilterFilterClass FilterFilterClass; - -struct _FilterFilter { - FilterRule parent_object; - - GList *actions; -}; - -struct _FilterFilterClass { - FilterRuleClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - -GType filter_filter_get_type (void); -FilterFilter *filter_filter_new (void); - -/* methods */ -void filter_filter_add_action (FilterFilter *fr, FilterPart *fp); -void filter_filter_remove_action (FilterFilter *fr, FilterPart *fp); -void filter_filter_replace_action (FilterFilter *fr, FilterPart *fp, FilterPart *new); - -void filter_filter_build_action (FilterFilter *fr, GString *out); - -#endif /* ! _FILTER_FILTER_H */ diff --git a/filter/filter-folder.c b/filter/filter-folder.c deleted file mode 100644 index 7c6e56a247..0000000000 --- a/filter/filter-folder.c +++ /dev/null @@ -1,260 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 Ximian Inc. - * - * Authors: Not Zed <notzed@lostzed.mmc.com.au> - * Jeffrey Stedfast <fejj@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <string.h> - -#include <gtk/gtk.h> -#include <libgnome/gnome-i18n.h> - -#include "filter-folder.h" -#include "mail/em-folder-selection-button.h" -#include "mail/mail-component.h" -#include "mail/em-utils.h" -#include "e-util/e-sexp.h" -#include "widgets/misc/e-error.h" - -#define d(x) - -static gboolean validate (FilterElement *fe); -static int folder_eq (FilterElement *fe, FilterElement *cm); -static void xml_create (FilterElement *fe, xmlNodePtr node); -static xmlNodePtr xml_encode (FilterElement *fe); -static int xml_decode (FilterElement *fe, xmlNodePtr node); -static GtkWidget *get_widget (FilterElement *fe); -static void build_code (FilterElement *fe, GString *out, struct _FilterPart *ff); -static void format_sexp (FilterElement *, GString *); - -static void filter_folder_class_init (FilterFolderClass *class); -static void filter_folder_init (FilterFolder *ff); -static void filter_folder_finalise (GObject *obj); - - -static FilterElementClass *parent_class = NULL; - - -GType -filter_folder_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (FilterFolderClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) filter_folder_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (FilterFolder), - 0, /* n_preallocs */ - (GInstanceInitFunc) filter_folder_init, - }; - - type = g_type_register_static (FILTER_TYPE_ELEMENT, "FilterFolder", &info, 0); - } - - return type; -} - -static void -filter_folder_class_init (FilterFolderClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - FilterElementClass *fe_class = FILTER_ELEMENT_CLASS (klass); - - parent_class = g_type_class_ref (FILTER_TYPE_ELEMENT); - - object_class->finalize = filter_folder_finalise; - - /* override methods */ - fe_class->validate = validate; - fe_class->eq = folder_eq; - fe_class->xml_create = xml_create; - fe_class->xml_encode = xml_encode; - fe_class->xml_decode = xml_decode; - fe_class->get_widget = get_widget; - fe_class->build_code = build_code; - fe_class->format_sexp = format_sexp; -} - -static void -filter_folder_init (FilterFolder *ff) -{ - ; -} - -static void -filter_folder_finalise (GObject *obj) -{ - FilterFolder *ff = (FilterFolder *) obj; - - g_free (ff->uri); - - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -/** - * filter_folder_new: - * - * Create a new FilterFolder object. - * - * Return value: A new #FilterFolder object. - **/ -FilterFolder * -filter_folder_new (void) -{ - return (FilterFolder *) g_object_new (FILTER_TYPE_FOLDER, NULL, NULL); -} - -void -filter_folder_set_value (FilterFolder *ff, const char *uri) -{ - g_free (ff->uri); - ff->uri = g_strdup (uri); -} - -static gboolean -validate (FilterElement *fe) -{ - FilterFolder *ff = (FilterFolder *) fe; - - if (ff->uri && *ff->uri) { - return TRUE; - } else { - /* FIXME: FilterElement should probably have a - GtkWidget member pointing to the value gotten with - ::get_widget() so that we can get the parent window - here. */ - e_error_run(NULL, "filter:no-folder", NULL); - - return FALSE; - } -} - -static int -folder_eq (FilterElement *fe, FilterElement *cm) -{ - return FILTER_ELEMENT_CLASS (parent_class)->eq (fe, cm) - && strcmp(((FilterFolder *)fe)->uri, ((FilterFolder *)cm)->uri) == 0; -} - -static void -xml_create (FilterElement *fe, xmlNodePtr node) -{ - /* parent implementation */ - FILTER_ELEMENT_CLASS (parent_class)->xml_create (fe, node); -} - -static xmlNodePtr -xml_encode (FilterElement *fe) -{ - xmlNodePtr value, work; - FilterFolder *ff = (FilterFolder *)fe; - - d(printf ("Encoding folder as xml\n")); - - value = xmlNewNode (NULL, "value"); - xmlSetProp (value, "name", fe->name); - xmlSetProp (value, "type", "folder"); - - work = xmlNewChild (value, NULL, "folder", NULL); - xmlSetProp (work, "uri", ff->uri); - - return value; -} - -static int -xml_decode (FilterElement *fe, xmlNodePtr node) -{ - FilterFolder *ff = (FilterFolder *)fe; - xmlNodePtr n; - - d(printf ("Decoding folder from xml %p\n", fe)); - - xmlFree (fe->name); - fe->name = xmlGetProp (node, "name"); - - n = node->children; - while (n) { - if (!strcmp (n->name, "folder")) { - char *uri; - - uri = xmlGetProp (n, "uri"); - g_free (ff->uri); - ff->uri = g_strdup (uri); - xmlFree (uri); - break; - } - n = n->next; - } - - return 0; -} - -static void -folder_selected(EMFolderSelectionButton *button, FilterFolder *ff) -{ - const char *uri; - - uri = em_folder_selection_button_get_selection(button); - g_free(ff->uri); - ff->uri = uri!=NULL?em_uri_from_camel(uri):NULL; - - gdk_window_raise (GTK_WIDGET (gtk_widget_get_ancestor (GTK_WIDGET (button), GTK_TYPE_WINDOW))->window); -} - -static GtkWidget * -get_widget (FilterElement *fe) -{ - FilterFolder *ff = (FilterFolder *)fe; - GtkWidget *button; - char *uri; - - uri = em_uri_to_camel(ff->uri); - button = em_folder_selection_button_new (_("Select Folder"), NULL); - em_folder_selection_button_set_selection(EM_FOLDER_SELECTION_BUTTON(button), uri); - g_free(uri); - - gtk_widget_show (button); - g_signal_connect (button, "selected", G_CALLBACK (folder_selected), ff); - - return button; -} - -static void -build_code (FilterElement *fe, GString *out, struct _FilterPart *ff) -{ - return; -} - -static void -format_sexp (FilterElement *fe, GString *out) -{ - FilterFolder *ff = (FilterFolder *)fe; - - e_sexp_encode_string (out, ff->uri); -} diff --git a/filter/filter-folder.h b/filter/filter-folder.h deleted file mode 100644 index 0e541a580b..0000000000 --- a/filter/filter-folder.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 Ximian Inc. - * - * Authors: Not Zed <notzed@lostzed.mmc.com.au> - * Jeffrey Stedfast <fejj@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - - -#ifndef _FILTER_FOLDER_H -#define _FILTER_FOLDER_H - -#include "filter-element.h" - -#define FILTER_TYPE_FOLDER (filter_folder_get_type ()) -#define FILTER_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FILTER_TYPE_FOLDER, FilterFolder)) -#define FILTER_FOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FILTER_TYPE_FOLDER, FilterFolderClass)) -#define IS_FILTER_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FILTER_TYPE_FOLDER)) -#define IS_FILTER_FOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FILTER_TYPE_FOLDER)) -#define FILTER_FOLDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FILTER_TYPE_FOLDER, FilterFolderClass)) - -typedef struct _FilterFolder FilterFolder; -typedef struct _FilterFolderClass FilterFolderClass; - -struct _FilterFolder { - FilterElement parent_object; - - char *uri; -}; - -struct _FilterFolderClass { - FilterElementClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - -GType filter_folder_get_type (void); -FilterFolder *filter_folder_new (void); - -/* methods */ -void filter_folder_set_value (FilterFolder *ff, const char *uri); - -#endif /* ! _FILTER_FOLDER_H */ diff --git a/filter/filter-part.c b/filter/filter-part.c index f82d354dee..2ed6794876 100644 --- a/filter/filter-part.c +++ b/filter/filter-part.c @@ -33,7 +33,7 @@ #include <libgnome/gnome-i18n.h> #include "filter-part.h" - +#include "rule-context.h" #define d(x) @@ -164,7 +164,7 @@ filter_part_eq (FilterPart *fp, FilterPart *fc) } int -filter_part_xml_create (FilterPart *ff, xmlNodePtr node) +filter_part_xml_create (FilterPart *ff, xmlNodePtr node, RuleContext *rc) { xmlNodePtr n; char *type, *str; @@ -181,7 +181,7 @@ filter_part_xml_create (FilterPart *ff, xmlNodePtr node) type = xmlGetProp (n, "type"); d(printf ("creating new element type input '%s'\n", type)); if (type != NULL - && (el = filter_element_new_type_name (type)) != NULL) { + && (el = rule_context_new_element(rc, type)) != NULL) { filter_element_xml_create (el, n); xmlFree (type); d(printf ("adding element part %p %s\n", ff, el, el->name)); diff --git a/filter/filter-part.h b/filter/filter-part.h index b1281522ea..1c7aa7dbb7 100644 --- a/filter/filter-part.h +++ b/filter/filter-part.h @@ -28,6 +28,8 @@ #include "filter-input.h" +struct _RuleContext; + #define FILTER_TYPE_PART (filter_part_get_type ()) #define FILTER_PART(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FILTER_TYPE_PART, FilterPart)) #define FILTER_PART_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FILTER_TYPE_PART, FilterPartClass)) @@ -63,7 +65,7 @@ FilterPart *filter_part_new (void); gboolean filter_part_validate (FilterPart *fp); int filter_part_eq (FilterPart *fp, FilterPart *fc); -int filter_part_xml_create (FilterPart *ff, xmlNodePtr node); +int filter_part_xml_create (FilterPart *ff, xmlNodePtr node, struct _RuleContext *rc); xmlNodePtr filter_part_xml_encode (FilterPart *fe); int filter_part_xml_decode (FilterPart *fe, xmlNodePtr node); diff --git a/filter/filter-rule.c b/filter/filter-rule.c index 2088d7133c..bd48afeb2e 100644 --- a/filter/filter-rule.c +++ b/filter/filter-rule.c @@ -31,7 +31,7 @@ #include "widgets/misc/e-error.h" #include "filter-rule.h" -#include "filter-context.h" +#include "rule-context.h" #include "filter-marshal.h" #define d(x) diff --git a/filter/filter-source.c b/filter/filter-source.c deleted file mode 100644 index c5955eb733..0000000000 --- a/filter/filter-source.c +++ /dev/null @@ -1,377 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Jon Trowbridge <trow@ximian.com> - * Jeffrey Stedfast <fejj@ximian.com> - * - * Copyright 2001-2002 Ximian, Inc. (www.ximian.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <string.h> - -#include "filter-source.h" - -#include <gtk/gtk.h> -#include <e-util/e-url.h> -#include <e-util/e-sexp.h> -#include <e-util/e-account-list.h> -#include <camel/camel-url.h> - - -static void filter_source_class_init (FilterSourceClass *klass); -static void filter_source_init (FilterSource *fs); -static void filter_source_finalize (GObject *obj); - -static int source_eq (FilterElement *fe, FilterElement *cm); -static void xml_create (FilterElement *fe, xmlNodePtr node); -static xmlNodePtr xml_encode (FilterElement *fe); -static int xml_decode (FilterElement *fe, xmlNodePtr node); -static FilterElement *clone (FilterElement *fe); -static GtkWidget *get_widget (FilterElement *fe); -static void build_code (FilterElement *fe, GString *out, struct _FilterPart *ff); -static void format_sexp (FilterElement *, GString *); - -static void filter_source_add_source (FilterSource *fs, const char *account_name, const char *name, - const char *addr, const char *url); -static void filter_source_get_sources (FilterSource *fs); - -typedef struct _SourceInfo { - char *account_name; - char *name; - char *address; - char *url; -} SourceInfo; - -struct _FilterSourcePrivate { - GList *sources; - char *current_url; -}; - - -static FilterElementClass *parent_class = NULL; - - -GType -filter_source_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (FilterSourceClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) filter_source_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (FilterSource), - 0, /* n_preallocs */ - (GInstanceInitFunc) filter_source_init, - }; - - type = g_type_register_static (FILTER_TYPE_ELEMENT, "FilterSource", &info, 0); - } - - return type; -} - -static void -filter_source_class_init (FilterSourceClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - FilterElementClass *fe_class = FILTER_ELEMENT_CLASS (klass); - - parent_class = g_type_class_ref (FILTER_TYPE_ELEMENT); - - object_class->finalize = filter_source_finalize; - - /* override methods */ - fe_class->eq = source_eq; - fe_class->xml_create = xml_create; - fe_class->xml_encode = xml_encode; - fe_class->xml_decode = xml_decode; - fe_class->clone = clone; - fe_class->get_widget = get_widget; - fe_class->build_code = build_code; - fe_class->format_sexp = format_sexp; -} - -static void -filter_source_init (FilterSource *fs) -{ - fs->priv = g_new (struct _FilterSourcePrivate, 1); - fs->priv->sources = NULL; - fs->priv->current_url = NULL; -} - -static void -filter_source_finalize (GObject *obj) -{ - FilterSource *fs = FILTER_SOURCE (obj); - GList *i = fs->priv->sources; - - while (i) { - SourceInfo *info = i->data; - g_free (info->account_name); - g_free (info->name); - g_free (info->address); - g_free (info->url); - g_free (info); - i = g_list_next (i); - } - - g_list_free (fs->priv->sources); - g_free (fs->priv->current_url); - - g_free (fs->priv); - - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -FilterSource * -filter_source_new (void) -{ - return (FilterSource *) g_object_new (FILTER_TYPE_SOURCE, NULL, NULL); -} - -static int -source_eq (FilterElement *fe, FilterElement *cm) -{ - FilterSource *fs = (FilterSource *)fe, *cs = (FilterSource *)cm; - - return FILTER_ELEMENT_CLASS (parent_class)->eq (fe, cm) - && ((fs->priv->current_url && cs->priv->current_url - && strcmp (fs->priv->current_url, cs->priv->current_url) == 0) - || (fs->priv->current_url == NULL && cs->priv->current_url == NULL)); -} - -static void -xml_create (FilterElement *fe, xmlNodePtr node) -{ - /* Call parent implementation */ - FILTER_ELEMENT_CLASS (parent_class)->xml_create (fe, node); -} - -static xmlNodePtr -xml_encode (FilterElement *fe) -{ - xmlNodePtr value; - - FilterSource *fs = (FilterSource *) fe; - - value = xmlNewNode (NULL, "value"); - xmlSetProp (value, "name", fe->name); - xmlSetProp (value, "type", "uri"); - - if (fs->priv->current_url) - xmlNewTextChild (value, NULL, "uri", fs->priv->current_url); - - return value; -} - -static gint -xml_decode (FilterElement *fe, xmlNodePtr node) -{ - FilterSource *fs = (FilterSource *) fe; - CamelURL *url; - char *uri; - - node = node->children; - while (node != NULL) { - if (!strcmp (node->name, "uri")) { - uri = xmlNodeGetContent (node); - url = camel_url_new (uri, NULL); - xmlFree (uri); - - g_free (fs->priv->current_url); - fs->priv->current_url = camel_url_to_string (url, CAMEL_URL_HIDE_ALL); - camel_url_free (url); - break; - } - - node = node->next; - } - - return 0; -} - -static FilterElement * -clone (FilterElement *fe) -{ - FilterSource *fs = (FilterSource *) fe; - FilterSource *cpy = filter_source_new (); - GList *i; - - ((FilterElement *) cpy)->name = xmlStrdup (fe->name); - - cpy->priv->current_url = g_strdup (fs->priv->current_url); - - for (i = fs->priv->sources; i != NULL; i = g_list_next (i)) { - SourceInfo *info = (SourceInfo *) i->data; - filter_source_add_source (cpy, info->account_name, info->name, info->address, info->url); - } - - return (FilterElement *) cpy; -} - -static void -source_changed (GtkWidget *item, FilterSource *fs) -{ - SourceInfo *info = (SourceInfo *) g_object_get_data ((GObject *) item, "source"); - - g_free (fs->priv->current_url); - fs->priv->current_url = g_strdup (info->url); -} - -static GtkWidget * -get_widget (FilterElement *fe) -{ - FilterSource *fs = (FilterSource *) fe; - GtkWidget *menu; - GtkWidget *omenu; - GtkWidget *item; - GList *i; - SourceInfo *first = NULL; - int index, current_index; - - if (fs->priv->sources == NULL) - filter_source_get_sources (fs); - - menu = gtk_menu_new (); - - index = 0; - current_index = -1; - - for (i = fs->priv->sources; i != NULL; i = g_list_next (i)) { - SourceInfo *info = (SourceInfo *) i->data; - char *label; - - if (info->url != NULL) { - if (first == NULL) - first = info; - - if (info->account_name && strcmp (info->account_name, info->address)) - label = g_strdup_printf ("%s <%s> (%s)", info->name, - info->address, info->account_name); - else - label = g_strdup_printf ("%s <%s>", info->name, info->address); - - item = gtk_menu_item_new_with_label (label); - g_free (label); - - g_object_set_data ((GObject *) item, "source", info); - g_signal_connect (item, "activate", G_CALLBACK (source_changed), fs); - - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - gtk_widget_show (item); - - if (fs->priv->current_url && !strcmp (info->url, fs->priv->current_url)) - current_index = index; - - index++; - } - } - - omenu = gtk_option_menu_new (); - gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu); - - if (current_index >= 0) { - gtk_option_menu_set_history (GTK_OPTION_MENU (omenu), current_index); - } else { - gtk_option_menu_set_history (GTK_OPTION_MENU (omenu), 0); - g_free (fs->priv->current_url); - - if (first) - fs->priv->current_url = g_strdup (first->url); - else - fs->priv->current_url = NULL; - } - - return omenu; -} - -static void -build_code (FilterElement *fe, GString *out, struct _FilterPart *ff) -{ - /* We are doing nothing on purpose. */ -} - -static void -format_sexp (FilterElement *fe, GString *out) -{ - FilterSource *fs = (FilterSource *) fe; - - e_sexp_encode_string (out, fs->priv->current_url); -} - - -static void -filter_source_add_source (FilterSource *fs, const char *account_name, const char *name, - const char *addr, const char *url) -{ - SourceInfo *info; - - g_return_if_fail (IS_FILTER_SOURCE (fs)); - - info = g_new0 (SourceInfo, 1); - info->account_name = g_strdup (account_name); - info->name = g_strdup (name); - info->address = g_strdup (addr); - info->url = g_strdup (url); - - fs->priv->sources = g_list_append (fs->priv->sources, info); -} - -static void -filter_source_get_sources (FilterSource *fs) -{ - EAccountList *accounts; - const EAccount *account; - GConfClient *gconf; - EIterator *it; - char *uri; - CamelURL *url; - - /* should this get the global object from mail? */ - gconf = gconf_client_get_default (); - accounts = e_account_list_new (gconf); - g_object_unref (gconf); - - for (it = e_list_get_iterator((EList *)accounts); - e_iterator_is_valid(it); - e_iterator_next(it)) { - account = (const EAccount *)e_iterator_get(it); - - if (account->source == NULL || account->source->url == NULL) - continue; - - /* hide secret stuff */ - url = camel_url_new (account->source->url, NULL); - uri = camel_url_to_string (url, CAMEL_URL_HIDE_ALL); - camel_url_free (url); - - filter_source_add_source (fs, account->name, account->id->name, account->id->address, uri); - g_free(uri); - } - g_object_unref(it); - g_object_unref(accounts); -} diff --git a/filter/filter-source.h b/filter/filter-source.h deleted file mode 100644 index 73bd63f503..0000000000 --- a/filter/filter-source.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Jon Trowbridge <trow@ximian.com> - * Jeffrey Stedfast <fejj@ximian.com> - * - * Copyright 2001-2002 Ximian, Inc. (www.ximian.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - - -#ifndef __FILTER_SOURCE_H__ -#define __FILTER_SOURCE_H__ - -#include "filter-element.h" - -#define FILTER_TYPE_SOURCE (filter_source_get_type ()) -#define FILTER_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FILTER_TYPE_SOURCE, FilterSource)) -#define FILTER_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FILTER_TYPE_SOURCE, FilterSourceClass)) -#define IS_FILTER_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FILTER_TYPE_SOURCE)) -#define IS_FILTER_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FILTER_TYPE_SOURCE)) -#define FILTER_SOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FILTER_TYPE_SOURCE, FilterSourceClass)) - -typedef struct _FilterSource FilterSource; -typedef struct _FilterSourceClass FilterSourceClass; - -struct _FilterSource { - FilterElement parent_object; - struct _FilterSourcePrivate *priv; -}; - -struct _FilterSourceClass { - FilterElementClass parent_class; - -}; - - -GType filter_source_get_type (void); -FilterSource *filter_source_new (void); - -void filter_source_set_current (FilterSource *src, const char *url); - -#endif /* __FILTER_SOURCE_H__ */ diff --git a/filter/filter.glade b/filter/filter.glade index 7d9ee76d13..64a0d85375 100644 --- a/filter/filter.glade +++ b/filter/filter.glade @@ -4,284 +4,6 @@ <glade-interface> <requires lib="gnome"/> -<widget class="GtkDialog" id="vfolder-source"> - <property name="border_width">6</property> - <property name="visible">True</property> - <property name="title" translatable="yes"></property> - <property name="type">GTK_WINDOW_TOPLEVEL</property> - <property name="window_position">GTK_WIN_POS_NONE</property> - <property name="modal">False</property> - <property name="resizable">True</property> - <property name="destroy_with_parent">False</property> - <property name="has_separator">False</property> - - <child internal-child="vbox"> - <widget class="GtkVBox" id="dialog-vbox3"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">6</property> - - <child internal-child="action_area"> - <widget class="GtkHButtonBox" id="dialog-action_area3"> - <property name="visible">True</property> - <property name="layout_style">GTK_BUTTONBOX_END</property> - - <child> - <widget class="GtkButton" id="cancel_button"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-cancel</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="response_id">-6</property> - </widget> - </child> - - <child> - <widget class="GtkButton" id="apply_button"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-apply</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="response_id">0</property> - </widget> - </child> - - <child> - <widget class="GtkButton" id="ok_button"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-ok</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="response_id">-5</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="pack_type">GTK_PACK_END</property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="vfolder_source_frame"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">6</property> - - <child> - <widget class="GtkLabel" id="label13"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>vFolder Sources</b></property> - <property name="use_underline">False</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkHBox" id="hbox9"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> - - <child> - <widget class="GtkLabel" id="label14"> - <property name="visible">True</property> - <property name="label" translatable="yes"> </property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="vbox3"> - <property name="border_width">6</property> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">6</property> - - <child> - <widget class="GtkOptionMenu" id="source_option"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="history">0</property> - - <child internal-child="menu"> - <widget class="GtkMenu" id="convertwidget8"> - <property name="visible">True</property> - - <child> - <widget class="GtkMenuItem" id="convertwidget9"> - <property name="visible">True</property> - <property name="label" translatable="yes">specific folders only</property> - <property name="use_underline">True</property> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="convertwidget10"> - <property name="visible">True</property> - <property name="label" translatable="yes">with all local folders</property> - <property name="use_underline">True</property> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="convertwidget11"> - <property name="visible">True</property> - <property name="label" translatable="yes">with all active remote folders</property> - <property name="use_underline">True</property> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="convertwidget12"> - <property name="visible">True</property> - <property name="label" translatable="yes">with all local and active remote folders</property> - <property name="use_underline">True</property> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkHBox" id="hbox3"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">6</property> - - <child> - <widget class="Custom" id="source_list"> - <property name="visible">True</property> - <property name="creation_function">vfolder_editor_sourcelist_new</property> - <property name="int1">0</property> - <property name="int2">0</property> - <property name="last_modification_time">Fri, 13 Dec 2002 00:22:39 GMT</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="vbox3"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">1</property> - - <child> - <widget class="GtkVButtonBox" id="vbuttonbox3"> - <property name="visible">True</property> - <property name="layout_style">GTK_BUTTONBOX_DEFAULT_STYLE</property> - <property name="spacing">6</property> - - <child> - <widget class="GtkButton" id="source_add"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-add</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - </widget> - </child> - - <child> - <widget class="GtkButton" id="source_remove"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-remove</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">3</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - </child> -</widget> - <widget class="GtkWindow" id="rule-editor"> <property name="visible">True</property> <property name="title" translatable="yes">window1</property> diff --git a/filter/filtertypes.xml b/filter/filtertypes.xml deleted file mode 100644 index dffa4e965f..0000000000 --- a/filter/filtertypes.xml +++ /dev/null @@ -1,746 +0,0 @@ -<?xml version="1.0"?> -<filterdescription> -<partset> - <part name="sender"> - <title>Sender</title> - <input type="optionlist" name="sender-type"> - <option value="contains"> - <title>contains</title> - <code> - (match-all (header-contains "From" ${sender})) - </code> - </option> - <option value="not contains"> - <title>does not contain</title> - <code> - (match-all (not (header-contains "From" ${sender}))) - </code> - </option> - <option value="is"> - <title>is</title> - <code> - (match-all (header-matches "From" ${sender})) - </code> - </option> - <option value="is not"> - <title>is not</title> - <code> - (match-all (not (header-matches "From" ${sender}))) - </code> - </option> - <option value="starts with"> - <title>starts with</title> - <code> - (match-all (header-starts-with "From" ${sender})) - </code> - </option> - <option value="not starts with"> - <title>does not start with</title> - <code> - (match-all (not (header-starts-with "From" ${sender}))) - </code> - </option> - <option value="ends with"> - <title>ends with</title> - <code> - (match-all (header-ends-with "From" ${sender})) - </code> - </option> - <option value="not ends with"> - <title>does not end with</title> - <code> - (match-all (not (header-ends-with "From" ${sender}))) - </code> - </option> - <option value="matches soundex"> - <title>sounds like</title> - <code> - (match-all (header-soundex "From" ${sender})) - </code> - </option> - <option value="not match soundex"> - <title>does not sound like</title> - <code> - (match-all (not (header-soundex "From" ${sender}))) - </code> - </option> - </input> - <input type="string" name="sender"/> - </part> - - <part name="to"> - <title>Recipients</title> - <input type="optionlist" name="recipient-type"> - <option value="contains"> - <title>contains</title> - <code> - (match-all (or (header-contains "To" ${recipient}) - (header-contains "Cc" ${recipient}))) - </code> - </option> - <option value="not contains"> - <title>does not contain</title> - <code> - (match-all (not (or - (header-contains "To" ${recipient}) - (header-contains "Cc" ${recipient})))) - </code> - </option> - <option value="is"> - <title>is</title> - <code> - (match-all (or (header-matches "To" ${recipient}) - (header-matches "Cc" ${recipient}))) - </code> - </option> - <option value="is not"> - <title>is not</title> - <code> - (match-all (not (or - (header-matches "To" ${recipient}) - (header-matches "Cc" ${recipient})))) - </code> - </option> - <option value="starts with"> - <title>starts with</title> - <code> - (match-all (or (header-starts-with "To" ${recipient}) - (header-starts-with "Cc" ${recipient}))) - </code> - </option> - <option value="not starts with"> - <title>does not start with</title> - <code> - (match-all (not (or - (header-starts-with "To" ${recipient}) - (header-starts-with "Cc" ${recipient})))) - </code> - </option> - <option value="ends with"> - <title>ends with</title> - <code> - (match-all (or (header-ends-with "To" ${recipient}) - (header-ends-with "Cc" ${recipient}))) - </code> - </option> - <option value="not ends with"> - <title>does not end with</title> - <code> - (match-all (not (or - (header-ends-with "To" ${recipient}) - (header-ends-with "Cc" ${recipient})))) - </code> - </option> - <option value="matches soundex"> - <title>sounds like</title> - <code> - (match-all (or (header-soundex "To" ${recipient}) - (header-soundex "Cc" ${recipient}))) - </code> - </option> - <option value="not match soundex"> - <title>does not sound like</title> - <code> - (match-all (not (or - (header-soundex "To" ${recipient}) - (header-soundex "Cc" ${recipient})))) - </code> - </option> - </input> - <input type="address" name="recipient"/> - </part> - - <part name="subject"> - <title>Subject</title> - <input type="optionlist" name="subject-type"> - <option value="contains"> - <title>contains</title> - <code> - (match-all (header-contains "Subject" ${subject})) - </code> - </option> - <option value="not contains"> - <title>does not contain</title> - <code> - (match-all (not (header-contains "Subject" ${subject}))) - </code> - </option> - <option value="is"> - <title>is</title> - <code> - (match-all (header-matches "Subject" ${subject})) - </code> - </option> - <option value="is not"> - <title>is not</title> - <code> - (match-all (not (header-matches "Subject" ${subject}))) - </code> - </option> - <option value="starts with"> - <title>starts with</title> - <code> - (match-all (header-starts-with "Subject" ${subject})) - </code> - </option> - <option value="not starts with"> - <title>does not start with</title> - <code> - (match-all (not (header-starts-with "Subject" ${subject}))) - </code> - </option> - <option value="ends with"> - <title>ends with</title> - <code> - (match-all (header-ends-with "Subject" ${subject})) - </code> - </option> - <option value="not ends with"> - <title>does not end with</title> - <code> - (match-all (not (header-ends-with "Subject" ${subject}))) - </code> - </option> - <option value="matches soundex"> - <title>sounds like</title> - <code> - (match-all (header-soundex "Subject" ${subject})) - </code> - </option> - <option value="not match soundex"> - <title>does not sound like</title> - <code> - (match-all (not (header-soundex "Subject" ${subject}))) - </code> - </option> - </input> - <input type="string" name="subject"/> - </part> - - <part name="header"> - <title>Specific header</title> - <input type="string" name="header-field"/> - <input type="optionlist" name="header-type"> - <option value="contains"> - <title>contains</title> - <code> - (match-all (header-contains ${header-field} ${word})) - </code> - </option> - <option value="not contains"> - <title>does not contain</title> - <code> - (match-all (not (header-contains ${header-field} ${word}))) - </code> - </option> - <option value="is"> - <title>is</title> - <code> - (match-all (header-matches ${header-field} ${word})) - </code> - </option> - <option value="is not"> - <title>is not</title> - <code> - (match-all (not (header-matches ${header-field} ${word}))) - </code> - </option> - <option value="starts with"> - <title>starts with</title> - <code> - (match-all (header-starts-with ${header-field} ${word})) - </code> - </option> - <option value="not starts with"> - <title>does not start with</title> - <code> - (match-all (not (header-starts-with ${header-field} ${word}))) - </code> - </option> - <option value="ends with"> - <title>ends with</title> - <code> - (match-all (header-ends-with ${header-field} ${word})) - </code> - </option> - <option value="not ends with"> - <title>does not end with</title> - <code> - (match-all (not (header-ends-with ${header-field} ${word}))) - </code> - </option> - <option value="exists"> - <title>exists</title> - <code> - (match-all (header-exists ${header-field})) - </code> - </option> - <option value="not exists"> - <title>does not exist</title> - <code> - (match-all (not (header-exists ${header-field}))) - </code> - </option> - <option value="matches soundex"> - <title>sounds like</title> - <code> - (match-all (header-soundex ${header-field} ${word})) - </code> - </option> - <option value="not match soundex"> - <title>does not sound like</title> - <code> - (match-all (not (header-soundex ${header-field} ${word}))) - </code> - </option> - </input> - <input type="string" name="word"/> - </part> - - <part name="body"> - <title>Message Body</title> - <input type="optionlist" name="body-type"> - <option value="contains"> - <title>contains</title> - <code> - (body-contains ${word}) - </code> - </option> - <option value="not contains"> - <title>does not contain</title> - <code> - (match-all (not (body-contains ${word}))) - </code> - </option> - </input> - <input type="string" name="word"/> - </part> - - <part name="sexp"> - <title>Expression</title> - <input type="code" name="code"/> - </part> - - <part name="sent-date"> - <title>Date sent</title> - <input type="optionlist" name="date-spec-type"> - <option value="is"> - <title>is</title> - <code> - (match-all (= (get-sent-date) ${versus})) - </code> - </option> - <option value="is-not"> - <title>is not</title> - <code> - (match-all (not (= (get-sent-date) ${versus}))) - </code> - </option> - <option value="before"> - <title>is before</title> - <code> - (match-all (< (get-sent-date) ${versus})) - </code> - </option> - <option value="after"> - <title>is after</title> - <code> - (match-all (> (get-sent-date) ${versus})) - </code> - </option> - </input> - <input type="datespec" name="versus"/> - </part> - - <part name="recv-date"> - <title>Date received</title> - <input type="optionlist" name="date-spec-type"> - <option value="is"> - <title>is</title> - <code> - (match-all (= (get-received-date) ${versus})) - </code> - </option> - <option value="is-not"> - <title>is not</title> - <code> - (match-all (not (= (get-received-date) ${versus}))) - </code> - </option> - <option value="before"> - <title>is before</title> - <code> - (match-all (< (get-received-date) ${versus})) - </code> - </option> - <option value="after"> - <title>is after</title> - <code> - (match-all (> (get-received-date) ${versus})) - </code> - </option> - </input> - <input type="datespec" name="versus"/> - </part> - - <part name="label"> - <title>Label</title> - <input type="optionlist" name="label-type"> - <option value="is"> - <title>is</title> - <code> - (match-all (= (user-tag "label") ${versus})) - </code> - </option> - <option value="is-not"> - <title>is not</title> - <code> - (match-all (not (= (user-tag "label") ${versus}))) - </code> - </option> - </input> - <input type="label" name="versus"/> - </part> - - <part name="score"> - <title>Score</title> - <input type="optionlist" name="score-type"> - <option value="is"> - <title>is</title> - <code> - (match-all (= (cast-int (user-tag "score")) ${versus})) - </code> - </option> - <option value="is-not"> - <title>is not</title> - <code> - (match-all (not (= (cast-int (user-tag "score")) ${versus}))) - </code> - </option> - <option value="greater-than"> - <title>is greater than</title> - <code> - (match-all (> (cast-int (user-tag "score")) ${versus})) - </code> - </option> - <option value="less-than"> - <title>is less than</title> - <code> - (match-all (< (cast-int (user-tag "score")) ${versus})) - </code> - </option> - </input> - <input type="score" name="versus"/> - </part> - - <part name="size"> - <title>Size (kB)</title> - <input type="optionlist" name="size-type"> - <option value="greater-than"> - <title>is greater than</title> - <code> - (match-all (> (get-size) ${versus})) - </code> - </option> - <option value="less-than"> - <title>is less than</title> - <code> - (match-all (< (get-size) ${versus})) - </code> - </option> - </input> - <input type="integer" name="versus"/> - </part> - - <part name="status"> - <title>Status</title> - <input type="optionlist" name="match-type"> - <option value="is"> - <title>is</title> - <code> - (match-all (system-flag ${flag})) - </code> - </option> - <option value="is not"> - <title>is not</title> - <code> - (match-all (not (system-flag ${flag}))) - </code> - </option> - </input> - <input type="optionlist" name="flag"> - <option value="Answered"> - <title>Replied to</title> - </option> - <option value="Draft"> - <title>Draft</title> - </option> - <option value="Flagged"> - <title>Important</title> - </option> - <option value="Seen"> - <title>Read</title> - </option> - <option value="Junk"> - <title>Junk</title> - </option> - </input> - </part> - - <part name="follow-up"> - <title>Follow Up</title> - <input type="optionlist" name="match-type"> - <option value="is"> - <title>is Flagged</title> - <code> - (match-all (not (= (user-tag "follow-up") ""))) - </code> - </option> - <option value="is not"> - <title>is not Flagged</title> - <code> - (match-all (= (user-tag "follow-up") "")) - </code> - </option> - </input> - </part> - - <part name="attachments"> - <title>Attachments</title> - <input type="optionlist" name="match-type"> - <option value="exist"> - <title>Exist</title> - <code> - (match-all (system-flag "Attachments")) - </code> - </option> - <option value="not exist"> - <title>Do Not Exist</title> - <code> - (match-all (not (system-flag "Attachments"))) - </code> - </option> - </input> - </part> - - <part name="mlist"> - <title>Mailing list</title> - <input type="optionlist" name="mlist-type"> - <option value="is"> - <title>is</title> - <code>(match-all (header-matches "x-camel-mlist" ${mlist}))</code> - </option> - <option value="is not"> - <title>is not</title> - <code>(match-all (not (header-matches "x-camel-mlist" ${mlist})))</code> - </option> - <option value="contains"> - <title>contains</title> - <code>(match-all (header-contains "x-camel-mlist" ${mlist}))</code> - </option> - <option value="not contains"> - <title>does not contain</title> - <code>(match-all (not (header-contains "x-camel-mlist" ${mlist})))</code> - </option> - </input> - <input type="string" name="mlist"/> - </part> - - <part name="regex"> - <title>Regex Match</title> - <input type="optionlist" name="match-type"> - <option value="header"> - <title>Message Header</title> - <code> - (match-all (header-full-regex ${expression})) - </code> - </option> - <option value="body"> - <title>Message Body</title> - <code> - (match-all (body-regex ${expression})) - </code> - </option> - </input> - <input type="regex" name="expression"/> - </part> - - <part name="source"> - <title>Source Account</title> - <input type="optionlist" name="srcmatch-type"> - <option value="is"> - <title>is</title> - <code> - (match-all (header-source ${source})) - </code> - </option> - <option value="is-not"> - <title>is not</title> - <code> - (match-all (not (header-source ${source}))) - </code> - </option> - </input> - <input type="source" name="source"/> - </part> - - <part name="pipe"> - <title>Pipe to Program</title> - <input type="command" name="command"/> - <input type="optionlist" name="retval-type"> - <option value="is"> - <title>returns</title> - <code> - (match-all (= (pipe-message "/bin/sh" "-c" ${command}) ${retval})) - </code> - </option> - <option value="is-not"> - <title>does not return</title> - <code> - (match-all (not (= (pipe-message "/bin/sh" "-c" ${command}) ${retval}))) - </code> - </option> - <option value="greater-than"> - <title>returns greater than</title> - <code> - (match-all (> (pipe-message "/bin/sh" "-c" ${command}) ${retval})) - </code> - </option> - <option value="less-than"> - <title>returns less than</title> - <code> - (match-all (< (pipe-message "/bin/sh" "-c" ${command}) ${retval})) - </code> - </option> - </input> - <input type="integer" name="retval"/> - </part> - - <part name="junk"> - <title>Junk Test</title> - <input type="optionlist" name="retval-type"> - <option value="is-junk"> - <title>Message is Junk</title> - <code> - (match-all (junk-test)) - </code> - </option> - <option value="is-not-junk"> - <title>Message is not Junk</title> - <code> - (match-all (not (junk-test))) - </code> - </option> - </input> - </part> - -</partset> - - -<actionset> - <part name="move-to-folder"> - <title>Move to Folder</title> - <code>(move-to ${folder})</code> - <input type="folder" name="folder"/> - </part> - <part name="copy-to-folder"> - <title>Copy to Folder</title> - <code>(copy-to ${folder})</code> - <input type="folder" name="folder"/> - </part> - <part name="delete"> - <title>Delete</title> - <code>(delete)</code> - </part> - <part name="stop"> - <title>Stop Processing</title> - <code>(stop)</code> - </part> - <part name="colour"> - <title>Assign Color</title> - <code>(set-colour ${colour})</code> - <input type="colour" name="colour"/> - </part> - <part name="score"> - <title>Assign Score</title> - <code>(set-score ${score})</code> - <input type="score" name="score"/> - </part> - <part name="adj-score"> - <title>Adjust Score</title> - <code>(adjust-score ${score})</code> - <input type="score" name="score"/> - </part> - <part name="set-status"> - <title>Set Status</title> - <code> - (set-system-flag ${flag}) - </code> - <input type="optionlist" name="flag"> - <option value="Answered"> - <title>Replied to</title> - </option> - <option value="Deleted"> - <title>Deleted</title> - </option> - <option value="Draft"> - <title>Draft</title> - </option> - <option value="Flagged"> - <title>Important</title> - </option> - <option value="Seen"> - <title>Read</title> - </option> - <option value="Junk"> - <title>Junk</title> - </option> - </input> - </part> - <part name="unset-status"> - <title>Unset Status</title> - <code> - (unset-system-flag ${flag}) - </code> - <input type="optionlist" name="flag"> - <option value="Answered"> - <title>Replied to</title> - </option> - <option value="Deleted"> - <title>Deleted</title> - </option> - <option value="Draft"> - <title>Draft</title> - </option> - <option value="Flagged"> - <title>Important</title> - </option> - <option value="Seen"> - <title>Read</title> - </option> - <option value="Junk"> - <title>Junk</title> - </option> - </input> - </part> - <part name="beep"> - <title>Beep</title> - <code>(beep)</code> - </part> - <part name="play-sound"> - <title>Play Sound</title> - <code>(play-sound ${sound})</code> - <input type="file" name="sound"/> - </part> - <part name="shell"> - <title>Run Program</title> - <code>(shell "/bin/sh" "-c" ${command})</code> - <input type="command" name="command"/> - </part> - <part name="pipe"> - <title>Pipe to Program</title> - <code>(pipe-message "/bin/sh" "-c" ${command})</code> - <input type="command" name="command"/> - </part> -</actionset> -</filterdescription> diff --git a/filter/rule-context.c b/filter/rule-context.c index 291f9d303f..560e9100a4 100644 --- a/filter/rule-context.c +++ b/filter/rule-context.c @@ -41,6 +41,15 @@ #include "filter-rule.h" #include "filter-marshal.h" +#include "filter-input.h" +#include "filter-option.h" +#include "filter-code.h" +#include "filter-colour.h" +#include "filter-datespec.h" +#include "filter-int.h" +#include "filter-file.h" +#include "filter-label.h" + #define d(x) static int load(RuleContext *rc, const char *system, const char *user); @@ -48,6 +57,7 @@ static int save(RuleContext *rc, const char *user); static int revert(RuleContext *rc, const char *user); static GList *rename_uri(RuleContext *rc, const char *olduri, const char *newuri, GCompareFunc cmp); static GList *delete_uri(RuleContext *rc, const char *uri, GCompareFunc cmp); +static FilterElement *new_element(RuleContext *rc, const char *name); static void rule_context_class_init(RuleContextClass *klass); static void rule_context_init(RuleContext *rc); @@ -110,7 +120,8 @@ rule_context_class_init(RuleContextClass *klass) klass->revert = revert; klass->rename_uri = rename_uri; klass->delete_uri = delete_uri; - + klass->new_element = new_element; + /* signals */ signals[RULE_ADDED] = g_signal_new("rule_added", @@ -326,7 +337,7 @@ load(RuleContext *rc, const char *system, const char *user) if (!strcmp(rule->name, "part")) { FilterPart *part = FILTER_PART(g_object_new(part_map->type, NULL, NULL)); - if (filter_part_xml_create(part, rule) == 0) { + if (filter_part_xml_create(part, rule, rc) == 0) { part_map->append(rc, part); } else { g_object_unref(part); @@ -883,3 +894,54 @@ rule_context_free_uri_list(RuleContext *rc, GList *uris) l = n; } } + +static FilterElement * +new_element(RuleContext *rc, const char *type) +{ + if (!strcmp (type, "string")) { + return (FilterElement *) filter_input_new (); + } else if (!strcmp (type, "address")) { + /* FIXME: temporary ... need real address type */ + return (FilterElement *) filter_input_new_type_name (type); + } else if (!strcmp (type, "code")) { + return (FilterElement *) filter_code_new (); + } else if (!strcmp (type, "colour")) { + return (FilterElement *) filter_colour_new (); + } else if (!strcmp (type, "optionlist")) { + return (FilterElement *) filter_option_new (); + } else if (!strcmp (type, "datespec")) { + return (FilterElement *) filter_datespec_new (); + } else if (!strcmp (type, "command")) { + return (FilterElement *) filter_file_new_type_name (type); + } else if (!strcmp (type, "file")) { + return (FilterElement *) filter_file_new_type_name (type); + } else if (!strcmp (type, "integer")) { + return (FilterElement *) filter_int_new (); + } else if (!strcmp (type, "regex")) { + return (FilterElement *) filter_input_new_type_name (type); + } else if (!strcmp (type, "label")) { + return (FilterElement *) filter_label_new (); + } else { + g_warning("Unknown filter type '%s'", type); + return NULL; + } +} + +/** + * rule_context_new_element: + * @rc: + * @name: + * + * create a new filter element based on name. + * + * Return value: + **/ +FilterElement * +rule_context_new_element(RuleContext *rc, const char *name) +{ + if (name == NULL) + return NULL; + + return RULE_CONTEXT_GET_CLASS(rc)->new_element(rc, name); +} + diff --git a/filter/rule-context.h b/filter/rule-context.h index 2f54a574f8..25b0c0e4c9 100644 --- a/filter/rule-context.h +++ b/filter/rule-context.h @@ -68,7 +68,7 @@ typedef void (*RCRegisterFunc) (RuleContext *rc, FilterRule *rule, gpointer user struct _RuleContextClass { GObjectClass parent_class; - + /* virtual methods */ int (*load) (RuleContext *rc, const char *system, const char *user); int (*save) (RuleContext *rc, const char *user); @@ -76,6 +76,8 @@ struct _RuleContextClass { GList *(*delete_uri) (RuleContext *rc, const char *uri, GCompareFunc cmp); GList *(*rename_uri) (RuleContext *rc, const char *olduri, const char *newuri, GCompareFunc cmp); + + FilterElement *(*new_element)(RuleContext *rc, const char *name); /* signals */ void (*rule_added) (RuleContext *rc, FilterRule *rule); @@ -103,9 +105,11 @@ struct _rule_set_map { }; GType rule_context_get_type (void); -RuleContext *rule_context_new (void); /* methods */ +RuleContext *rule_context_new (void); + +/* io */ int rule_context_load (RuleContext *rc, const char *system, const char *user); int rule_context_save (RuleContext *rc, const char *user); int rule_context_revert (RuleContext *rc, const char *user); @@ -132,6 +136,9 @@ void rule_context_add_part_set (RuleContext *rc, const char *setname, GType part void rule_context_add_rule_set (RuleContext *rc, const char *setname, GType rule_type, RCRuleFunc append, RCNextRuleFunc next); +/* dynamic element types */ +FilterElement *rule_context_new_element(RuleContext *rc, const char *name); + /* uri's disappear/renamed externally */ GList *rule_context_delete_uri (RuleContext *rc, const char *uri, GCompareFunc cmp); GList *rule_context_rename_uri (RuleContext *rc, const char *olduri, const char *newuri, GCompareFunc cmp); diff --git a/filter/rule-editor.c b/filter/rule-editor.c index 907f1f917e..f23edec8dc 100644 --- a/filter/rule-editor.c +++ b/filter/rule-editor.c @@ -718,7 +718,7 @@ rule_editor_construct (RuleEditor *re, RuleContext *context, GladeXML *gui, cons gtk_box_pack_start((GtkBox *)((GtkDialog *)re)->vbox, w, TRUE, TRUE, 3); for (i = 0; i < BUTTON_LAST; i++) { - re->priv->buttons[i] = (GtkButton *) w = glade_xml_get_widget (gui, edit_buttons[i].name); + re->priv->buttons[i] = (GtkButton *) (w = glade_xml_get_widget (gui, edit_buttons[i].name)); g_signal_connect (w, "clicked", edit_buttons[i].func, re); } diff --git a/filter/score-context.c b/filter/score-context.c deleted file mode 100644 index dd3663ffab..0000000000 --- a/filter/score-context.c +++ /dev/null @@ -1,101 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 Ximian Inc. - * - * Authors: Not Zed <notzed@lostzed.mmc.com.au> - * Jeffrey Stedfast <fejj@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "score-context.h" -#include "score-rule.h" - - -static void score_context_class_init (ScoreContextClass *klass); -static void score_context_init (ScoreContext *sc); -static void score_context_finalise (GObject *obj); - - -static RuleContextClass *parent_class = NULL; - - -GType -score_context_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (ScoreContextClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) score_context_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (ScoreContext), - 0, /* n_preallocs */ - (GInstanceInitFunc) score_context_init, - }; - - type = g_type_register_static (RULE_TYPE_CONTEXT, "ScoreContext", &info, 0); - } - - return type; -} - -static void -score_context_class_init (ScoreContextClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_ref (rule_context_get_type ()); - - object_class->finalize = score_context_finalise; -} - -static void -score_context_init (ScoreContext *sc) -{ - rule_context_add_part_set ((RuleContext *) sc, "partset", filter_part_get_type (), - rule_context_add_part, rule_context_next_part); - - rule_context_add_rule_set ((RuleContext *) sc, "ruleset", score_rule_get_type (), - rule_context_add_rule, rule_context_next_rule); -} - -static void -score_context_finalise (GObject *obj) -{ - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -/** - * score_context_new: - * - * Create a new ScoreContext object. - * - * Return value: A new #ScoreContext object. - **/ -ScoreContext * -score_context_new (void) -{ - return (ScoreContext *) g_object_new (SCORE_TYPE_CONTEXT, NULL, NULL); -} diff --git a/filter/score-context.h b/filter/score-context.h deleted file mode 100644 index 7a76ac8d32..0000000000 --- a/filter/score-context.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 Ximian Inc. - * - * Authors: Not Zed <notzed@lostzed.mmc.com.au> - * Jeffrey Stedfast <fejj@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef _SCORE_CONTEXT_H -#define _SCORE_CONTEXT_H - -#include "rule-context.h" - -#define SCORE_TYPE_CONTEXT (score_context_get_type ()) -#define SCORE_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SCORE_TYPE_CONTEXT, ScoreContext)) -#define SCORE_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SCORE_TYPE_CONTEXT, ScoreContextClass)) -#define IS_SCORE_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SCORE_TYPE_CONTEXT)) -#define IS_SCORE_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SCORE_TYPE_CONTEXT)) -#define SCORE_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SCORE_TYPE_CONTEXT, ScoreContextClass)) - -typedef struct _ScoreContext ScoreContext; -typedef struct _ScoreContextClass ScoreContextClass; - -struct _ScoreContext { - RuleContext parent_object; - -}; - -struct _ScoreContextClass { - RuleContextClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - - -GType score_context_get_type (void); - -ScoreContext *score_context_new (void); - -/* methods */ - -#endif /* ! _SCORE_CONTEXT_H */ diff --git a/filter/score-editor.c b/filter/score-editor.c deleted file mode 100644 index e52edf7c02..0000000000 --- a/filter/score-editor.c +++ /dev/null @@ -1,128 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2001-2002 Ximian Inc. - * - * Authors: Not Zed <notzed@lostzed.mmc.com.au> - * Jeffrey Stedfast <fejj@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gtk/gtk.h> -#include <libgnome/gnome-i18n.h> - -#include "score-editor.h" -#include "score-rule.h" - -#define d(x) - -static FilterRule * create_rule(RuleEditor *re); - -static void score_editor_class_init (ScoreEditorClass *klass); -static void score_editor_init (ScoreEditor *se); -static void score_editor_finalise (GObject *obj); - - -static RuleEditorClass *parent_class = NULL; - - -GtkType -score_editor_get_type (void) -{ - static GtkType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (ScoreEditorClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) score_editor_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (ScoreEditor), - 0, /* n_preallocs */ - (GInstanceInitFunc) score_editor_init, - }; - - type = g_type_register_static (RULE_TYPE_EDITOR, "ScoreEditor", &info, 0); - } - - return type; -} - -static void -score_editor_class_init (ScoreEditorClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - RuleEditorClass *re_class = (RuleEditorClass *) klass; - - parent_class = g_type_class_ref(rule_editor_get_type ()); - - gobject_class->finalize = score_editor_finalise; - - /* override methods */ - re_class->create_rule = create_rule; -} - -static void -score_editor_init (ScoreEditor *se) -{ - ; -} - -static void -score_editor_finalise (GObject *obj) -{ - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -/** - * score_editor_new: - * - * Create a new ScoreEditor object. - * - * Return value: A new #ScoreEditor object. - **/ -ScoreEditor * -score_editor_new (ScoreContext *sc) -{ - ScoreEditor *se = (ScoreEditor *) g_object_new (SCORE_TYPE_EDITOR, NULL); - GladeXML *gui; - - gui = glade_xml_new (FILTER_GLADEDIR "/filter.glade", "rule_editor", NULL); - rule_editor_construct ((RuleEditor *) se, (RuleContext *) sc, gui, NULL, _("_Score Rules")); - g_object_unref (gui); - - return se; -} - -static FilterRule * -create_rule (RuleEditor *re) -{ - FilterRule *rule = filter_rule_new (); - FilterPart *part; - - /* create a rule with 1 part in it */ - rule = (FilterRule *) score_rule_new (); - part = rule_context_next_part (re->context, NULL); - filter_rule_add_part (rule, filter_part_clone (part)); - - return rule; -} diff --git a/filter/score-editor.h b/filter/score-editor.h deleted file mode 100644 index 85bff02140..0000000000 --- a/filter/score-editor.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 Ximian Inc. - * - * Authors: Not Zed <notzed@lostzed.mmc.com.au> - * Jeffrey Stedfast <fejj@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - - -#ifndef _SCORE_EDITOR_H -#define _SCORE_EDITOR_H - -#include "rule-editor.h" -#include "score-context.h" - -#define SCORE_TYPE_EDITOR (score_editor_get_type ()) -#define SCORE_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SCORE_TYPE_EDITOR, ScoreEditor)) -#define SCORE_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SCORE_TYPE_EDITOR, ScoreEditorClass)) -#define IS_SCORE_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SCORE_TYPE_EDITOR)) -#define IS_SCORE_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SCORE_TYPE_EDITOR)) -#define SCORE_EDITOR_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), SCORE_TYPE_EDITOR, ScoreEditorClass)) - -typedef struct _ScoreEditor ScoreEditor; -typedef struct _ScoreEditorClass ScoreEditorClass; - -struct _ScoreEditor { - RuleEditor parent_object; - -}; - -struct _ScoreEditorClass { - RuleEditorClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - - -GType score_editor_get_type (void); - -ScoreEditor *score_editor_new (ScoreContext *sc); - -#endif /* ! _SCORE_EDITOR_H */ diff --git a/filter/score-rule.c b/filter/score-rule.c deleted file mode 100644 index 9865b320cf..0000000000 --- a/filter/score-rule.c +++ /dev/null @@ -1,201 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 Ximian Inc. - * - * Authors: Not Zed <notzed@lostzed.mmc.com.au> - * Jeffrey Stedfast <fejj@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <string.h> - -#include <gtk/gtk.h> -#include <libgnome/gnome-i18n.h> - -#include "score-rule.h" - -static xmlNodePtr xml_encode(FilterRule *); -static int xml_decode(FilterRule *, xmlNodePtr, struct _RuleContext *f); -/*static void build_code(FilterRule *, GString *out);*/ -static GtkWidget *get_widget(FilterRule *fr, struct _RuleContext *f); - -static void score_rule_class_init (ScoreRuleClass *klass); -static void score_rule_init (ScoreRule *sr); -static void score_rule_finalise (GObject *obj); - - -static FilterRuleClass *parent_class = NULL; - - -GType -score_rule_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (ScoreRuleClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) score_rule_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (ScoreRule), - 0, /* n_preallocs */ - (GInstanceInitFunc) score_rule_init, - }; - - type = g_type_register_static (FILTER_TYPE_RULE, "ScoreRule", &info, 0); - } - - return type; -} - -static void -score_rule_class_init (ScoreRuleClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - FilterRuleClass *rule_class = (FilterRuleClass *) klass; - - parent_class = g_type_class_ref (FILTER_TYPE_RULE); - - object_class->finalize = score_rule_finalise; - - /* override methods */ - rule_class->xml_encode = xml_encode; - rule_class->xml_decode = xml_decode; -/* rule_class->build_code = build_code;*/ - rule_class->get_widget = get_widget; -} - -static void -score_rule_init (ScoreRule *sr) -{ - ; -} - -static void -score_rule_finalise (GObject *obj) -{ - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -/** - * score_rule_new: - * - * Create a new ScoreRule object. - * - * Return value: A new #ScoreRule object. - **/ -ScoreRule * -score_rule_new (void) -{ - return (ScoreRule *) g_object_new (SCORE_TYPE_RULE, NULL, NULL); -} - -static xmlNodePtr -xml_encode (FilterRule *fr) -{ - ScoreRule *sr = (ScoreRule *)fr; - xmlNodePtr node, value; - char number[16]; - - node = FILTER_RULE_CLASS (parent_class)->xml_encode (fr); - sprintf (number, "%d", sr->score); - value = xmlNewNode (NULL, "score"); - xmlSetProp (value, "value", number); - xmlAddChild (node, value); - - return node; -} - -static int -xml_decode (FilterRule *fr, xmlNodePtr node, struct _RuleContext *f) -{ - ScoreRule *sr = (ScoreRule *) fr; - xmlNodePtr value; - int result; - char *str; - - result = FILTER_RULE_CLASS (parent_class)->xml_decode (fr, node, f); - if (result != 0) - return result; - - value = node->children; - while (value) { - if (!strcmp (value->name, "score")) { - str = xmlGetProp (value, "value"); - sscanf (str, "%d", &sr->score); - xmlFree (str); - - /* score range is -3 to +3 */ - if (sr->score > 3) - sr->score = 3; - else if (sr->score < -3) - sr->score = -3; - } - value = value->next; - } - - return 0; -} - -/*static void build_code(FilterRule *fr, GString *out) -{ -}*/ - -static void -spin_changed (GtkAdjustment *adj, ScoreRule *sr) -{ - sr->score = adj->value; -} - -static GtkWidget * -get_widget (FilterRule *fr, struct _RuleContext *f) -{ - GtkWidget *widget; - GtkWidget *frame; - GtkWidget *label; - GtkWidget *hbox; - GtkAdjustment *adj; - ScoreRule *sr = (ScoreRule *)fr; - GtkWidget *spin; - - widget = FILTER_RULE_CLASS (parent_class)->get_widget (fr, f); - - frame = gtk_frame_new (_("Score")); - hbox = gtk_hbox_new (FALSE, 3); - label = gtk_label_new (_("Score")); - - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 3); - adj = (GtkAdjustment *) gtk_adjustment_new ((float) sr->score, -3.0, 3.0, 1.0, 1.0, 1.0); - g_signal_connect (adj, "value_changed", G_CALLBACK (spin_changed), sr); - - spin = gtk_spin_button_new (adj, 1.0, 0); - gtk_box_pack_start (GTK_BOX (hbox), spin, FALSE, FALSE, 3); - gtk_container_add (GTK_CONTAINER (frame), hbox); - - gtk_widget_show_all (frame); - - gtk_box_pack_start (GTK_BOX (widget), frame, FALSE, FALSE, 3); - - return widget; -} diff --git a/filter/score-rule.h b/filter/score-rule.h deleted file mode 100644 index fbd8f649de..0000000000 --- a/filter/score-rule.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 Ximian Inc. - * - * Authors: Not Zed <notzed@lostzed.mmc.com.au> - * Jeffrey Stedfast <fejj@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - - -#ifndef _SCORE_RULE_H -#define _SCORE_RULE_H - -#include "filter-rule.h" - -#define SCORE_TYPE_RULE (score_rule_get_type ()) -#define SCORE_RULE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SCORE_TYPE_RULE, ScoreRule)) -#define SCORE_RULE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SCORE_TYPE_RULE, ScoreRuleClass)) -#define IS_SCORE_RULE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SCORE_TYPE_RULE)) -#define IS_SCORE_RULE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SCORE_TYPE_RULE)) -#define SCORE_RULE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SCORE_TYPE_RULE, ScoreRuleClass)) - -typedef struct _ScoreRule ScoreRule; -typedef struct _ScoreRuleClass ScoreRuleClass; - -struct _ScoreRule { - FilterRule parent_object; - - int score; -}; - -struct _ScoreRuleClass { - FilterRuleClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - - -GType score_rule_get_type (void); - -ScoreRule *score_rule_new (void); - -/* methods */ - -#endif /* ! _SCORE_RULE_H */ diff --git a/filter/searchtypes.xml b/filter/searchtypes.xml deleted file mode 100644 index 8185b4a593..0000000000 --- a/filter/searchtypes.xml +++ /dev/null @@ -1,529 +0,0 @@ -<?xml version="1.0"?> -<filterdescription> -<partset> - <part name="sender"> - <title>Sender</title> - <input type="optionlist" name="sender-type"> - <option value="contains"> - <title>contains</title> - <code>(match-all (header-contains "From" ${sender}))</code> - </option> - <option value="not contains"> - <title>does not contain</title> - <code>(match-all (not (header-contains "From" ${sender})))</code> - </option> - <option value="is"> - <title>is</title> - <code>(match-all (header-matches "From" ${sender}))</code> - </option> - <option value="is not"> - <title>is not</title> - <code>(match-all (not (header-matches "From" ${sender})))</code> - </option> - <option value="starts with"> - <title>starts with</title> - <code> - (match-all (header-starts-with "From" ${sender})) - </code> - </option> - <option value="not starts with"> - <title>does not start with</title> - <code> - (match-all (not (header-starts-with "From" ${sender}))) - </code> - </option> - <option value="ends with"> - <title>ends with</title> - <code> - (match-all (header-ends-with "From" ${sender})) - </code> - </option> - <option value="not ends with"> - <title>does not end with</title> - <code> - (match-all (not (header-ends-with "From" ${sender}))) - </code> - </option> - </input> - <input type="string" name="sender"/> - </part> - - <part name="to"> - <title>Recipients</title> - <input type="optionlist" name="recipient-type"> - <option value="contains"> - <title>contains</title> - <code> - (match-all (or (header-contains "To" ${recipient}) - (header-contains "Cc" ${recipient}))) - </code> - </option> - <option value="not contains"> - <title>does not contain</title> - <code> - (match-all (not (or - (header-contains "To" ${recipient}) - (header-contains "Cc" ${recipient})))) - </code> - </option> - <option value="is"> - <title>is</title> - <code> - (match-all (or (header-matches "To" ${recipient}) - (header-matches "Cc" ${recipient}))) - </code> - </option> - <option value="is not"> - <title>is not</title> - <code> - (match-all (not (or - (header-matches "To" ${recipient}) - (header-matches "Cc" ${recipient})))) - </code> - </option> - <option value="starts with"> - <title>starts with</title> - <code> - (match-all (or (header-starts-with "To" ${recipient}) - (header-starts-with "Cc" ${recipient}))) - </code> - </option> - <option value="not starts with"> - <title>does not start with</title> - <code> - (match-all (not (or - (header-starts-with "To" ${recipient}) - (header-starts-with "Cc" ${recipient})))) - </code> - </option> - <option value="ends with"> - <title>ends with</title> - <code> - (match-all (or (header-ends-with "To" ${recipient}) - (header-ends-with "Cc" ${recipient}))) - </code> - </option> - <option value="not ends with"> - <title>does not end with</title> - <code> - (match-all (not (or - (header-ends-with "To" ${recipient}) - (header-ends-with "Cc" ${recipient})))) - </code> - </option> - </input> - <input type="address" name="recipient"/> - </part> - - <part name="subject"> - <title>Subject</title> - <input type="optionlist" name="subject-type"> - <option value="contains"> - <title>contains</title> - <code> - (match-all (header-contains "Subject" ${subject})) - </code> - </option> - <option value="not contains"> - <title>does not contain</title> - <code> - (match-all (not (header-contains "Subject" ${subject}))) - </code> - </option> - <option value="is"> - <title>is</title> - <code> - (match-all (header-matches "Subject" ${subject})) - </code> - </option> - <option value="is not"> - <title>is not</title> - <code> - (match-all (not (header-matches "Subject" ${subject}))) - </code> - </option> - <option value="starts with"> - <title>starts with</title> - <code> - (match-all (header-starts-with "Subject" ${subject})) - </code> - </option> - <option value="not starts with"> - <title>does not start with</title> - <code> - (match-all (not (header-starts-with "Subject" ${subject}))) - </code> - </option> - <option value="ends with"> - <title>ends with</title> - <code> - (match-all (header-ends-with "Subject" ${subject})) - </code> - </option> - <option value="not ends with"> - <title>does not end with</title> - <code> - (match-all (not (header-ends-with "Subject" ${subject}))) - </code> - </option> - </input> - <input type="string" name="subject"/> - </part> - <part name="body"> - <title>Message Body</title> - <input type="optionlist" name="body-type"> - <option value="contains"> - <title>contains</title> - <code> - (body-contains ${word}) - </code> - </option> - <option value="not contains"> - <title>does not contain</title> - <code> - (not (body-contains ${word})) - </code> - </option> - </input> - <input type="string" name="word"/> - </part> - <part name="sexp"> - <title>Expression</title> - <input type="code" name="code"/> - </part> - - <part name="sent-date"> - <title>Date sent</title> - <input type="optionlist" name="date-spec-type"> - <option value="is"> - <title>is</title> - <code> - (match-all (= (get-sent-date) ${versus})) - </code> - </option> - <option value="is-not"> - <title>is not</title> - <code> - (match-all (not (= (get-sent-date) ${versus}))) - </code> - </option> - <option value="before"> - <title>is before</title> - <code> - (match-all (< (get-sent-date) ${versus})) - </code> - </option> - <option value="after"> - <title>is after</title> - <code> - (match-all (> (get-sent-date) ${versus})) - </code> - </option> - </input> - <input type="datespec" name="versus"/> - </part> - - <part name="recv-date"> - <title>Date received</title> - <input type="optionlist" name="date-spec-type"> - <option value="is"> - <title>is</title> - <code> - (match-all (= (get-received-date) ${versus})) - </code> - </option> - <option value="is-not"> - <title>is not</title> - <code> - (match-all (not (= (get-received-date) ${versus}))) - </code> - </option> - <option value="before"> - <title>is before</title> - <code> - (match-all (< (get-received-date) ${versus})) - </code> - </option> - <option value="after"> - <title>is after</title> - <code> - (match-all (> (get-received-date) ${versus})) - </code> - </option> - </input> - <input type="datespec" name="versus"/> - </part> - - <part name="label"> - <title>Label</title> - <input type="optionlist" name="label-type"> - <option value="is"> - <title>is</title> - <code> - (match-all (= (user-tag "label") ${versus})) - </code> - </option> - <option value="is-not"> - <title>is not</title> - <code> - (match-all (not (= (user-tag "label") ${versus}))) - </code> - </option> - </input> - <input type="label" name="versus"/> - </part> - - <part name="score"> - <title>Score</title> - <input type="optionlist" name="score-type"> - <option value="is"> - <title>is</title> - <code> - (match-all (= (cast-int (user-tag "score")) ${versus})) - </code> - </option> - <option value="is-not"> - <title>is not</title> - <code> - (match-all (not (= (cast-int (user-tag "score")) ${versus}))) - </code> - </option> - <option value="greater-than"> - <title>is greater than</title> - <code> - (match-all (> (cast-int (user-tag "score")) ${versus})) - </code> - </option> - <option value="less-than"> - <title>is less than</title> - <code> - (match-all (< (cast-int (user-tag "score")) ${versus})) - </code> - </option> - </input> - <input type="score" name="versus"/> - </part> - - <part name="size"> - <title>Size (kB)</title> - <input type="optionlist" name="size-type"> - <option value="greater-than"> - <title>is greater than</title> - <code> - (match-all (> (get-size) ${versus})) - </code> - </option> - <option value="less-than"> - <title>is less than</title> - <code> - (match-all (< (get-size) ${versus})) - </code> - </option> - </input> - <input type="integer" name="versus"/> - </part> - - <part name="status"> - <title>Status</title> - <input type="optionlist" name="match-type"> - <option value="is"> - <title>is</title> - <code> - (match-all (system-flag ${flag})) - </code> - </option> - <option value="is not"> - <title>is not</title> - <code> - (match-all (not (system-flag ${flag}))) - </code> - </option> - </input> - <input type="optionlist" name="flag"> - <option value="Answered"> - <title>Replied to</title> - </option> - <option value="Deleted"> - <title>Deleted</title> - </option> - <option value="Draft"> - <title>Draft</title> - </option> - <option value="Flagged"> - <title>Important</title> - </option> - <option value="Seen"> - <title>Read</title> - </option> - </input> - </part> - - <part name="follow-up"> - <title>Follow Up</title> - <input type="optionlist" name="match-type"> - <option value="is"> - <title>is Flagged</title> - <code> - (match-all (not (= (user-tag "follow-up") ""))) - </code> - </option> - <option value="is not"> - <title>is not Flagged</title> - <code> - (match-all (= (user-tag "follow-up") "")) - </code> - </option> - </input> - </part> - - <part name="attachments"> - <title>Attachments</title> - <input type="optionlist" name="match-type"> - <option value="exist"> - <title>Exist</title> - <code> - (match-all (system-flag "Attachments")) - </code> - </option> - <option value="not exist"> - <title>Do Not Exist</title> - <code> - (match-all (not (system-flag "Attachments"))) - </code> - </option> - </input> - </part> - - <part name="mlist"> - <title>Mailing list</title> - <input type="optionlist" name="mlist-type"> - <option value="is"> - <title>is</title> - <code>(match-all (header-matches "x-camel-mlist" ${mlist}))</code> - </option> - <option value="is not"> - <title>is not</title> - <code>(match-all (not (header-matches "x-camel-mlist" ${mlist})))</code> - </option> - <option value="contains"> - <title>contains</title> - <code>(match-all (header-contains "x-camel-mlist" ${mlist}))</code> - </option> - <option value="not contains"> - <title>does not contain</title> - <code>(match-all (not (header-contains "x-camel-mlist" ${mlist})))</code> - </option> - </input> - <input type="string" name="mlist"/> - </part> - -</partset> - - <ruleset> - - <rule grouping="any" source="demand"> - <_title>Subject contains</_title> - <partset> - <part name="subject"> - <value name="subject-type" type="option" value="contains"/> - <value name="subject" type="string"/> - </part> - </partset> - <sources/> - </rule> - - <rule grouping="any" source="demand"> - <_title>Subject does not contain</_title> - <partset> - <part name="subject"> - <value name="subject-type" type="option" value="not contains"/> - <value name="subject" type="string"/> - </part> - </partset> - <sources/> - </rule> - - <rule grouping="any" source="demand"> - <_title>Sender contains</_title> - <partset> - <part name="sender"> - <value name="sender-type" type="option" value="contains"/> - <value name="sender" type="string"/> - </part> - </partset> - <sources/> - </rule> - - <rule grouping="any" source="demand"> - <_title>Recipients contain</_title> - <partset> - <part name="to"> - <value name="recipient-type" type="option" value="contains"/> - <value name="recipient" type="address"/> - </part> - </partset> - <sources/> - </rule> - - <rule grouping="any" source="demand"> - <_title>Body contains</_title> - <partset> - <part name="body"> - <value name="body-type" type="option" value="contains"/> - <value name="word" type="string"/> - </part> - </partset> - <sources/> - </rule> - - <rule grouping="any" source="demand"> - <_title>Body does not contain</_title> - <partset> - <part name="body"> - <value name="body-type" type="option" value="not contains"/> - <value name="word" type="string"/> - </part> - </partset> - <sources/> - </rule> - - <rule grouping="any" source="demand"> - <_title>Body or subject contains</_title> - <partset> - <part name="subject"> - <value name="subject-type" type="option" value="contains"/> - <value name="subject" type="string"/> - </part> - <part name="body"> - <value name="body-type" type="option" value="contains"/> - <value name="word" type="string"/> - </part> - </partset> - <sources/> - </rule> - - <rule grouping="any" source="demand"> - <_title>Message contains</_title> - <partset> - <part name="subject"> - <value name="subject-type" type="option" value="contains"/> - <value name="subject" type="string"/> - </part> - <part name="body"> - <value name="body-type" type="option" value="contains"/> - <value name="word" type="string"/> - </part> - <part name="sender"> - <value name="sender-type" type="option" value="contains"/> - <value name="sender" type="string"/> - </part> - <part name="to"> - <value name="recipient-type" type="option" value="contains"/> - <value name="recipient" type="address"/> - </part> - </partset> - <sources/> - </rule> - - </ruleset> -</filterdescription> diff --git a/filter/vfolder-context.c b/filter/vfolder-context.c deleted file mode 100644 index a904305787..0000000000 --- a/filter/vfolder-context.c +++ /dev/null @@ -1,102 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 Ximian Inc. - * - * Authors: Not Zed <notzed@lostzed.mmc.com.au> - * Jeffrey Stedfast <fejj@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "vfolder-context.h" -#include "vfolder-rule.h" - -static void vfolder_context_class_init (VfolderContextClass *klass); -static void vfolder_context_init (VfolderContext *vc); -static void vfolder_context_finalise (GObject *obj); - - -static RuleContextClass *parent_class = NULL; - - -GType -vfolder_context_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (VfolderContextClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) vfolder_context_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (VfolderContext), - 0, /* n_preallocs */ - (GInstanceInitFunc) vfolder_context_init, - }; - - type = g_type_register_static (RULE_TYPE_CONTEXT, "VfolderContext", &info, 0); - } - - return type; -} - -static void -vfolder_context_class_init (VfolderContextClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_ref (RULE_TYPE_CONTEXT); - - object_class->finalize = vfolder_context_finalise; -} - -static void -vfolder_context_init (VfolderContext *vc) -{ - rule_context_add_part_set ((RuleContext *) vc, "partset", filter_part_get_type (), - rule_context_add_part, rule_context_next_part); - - rule_context_add_rule_set ((RuleContext *) vc, "ruleset", vfolder_rule_get_type (), - rule_context_add_rule, rule_context_next_rule); - - ((RuleContext *)vc)->flags = RULE_CONTEXT_THREADING | RULE_CONTEXT_GROUPING; -} - -static void -vfolder_context_finalise (GObject *obj) -{ - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -/** - * vfolder_context_new: - * - * Create a new VfolderContext object. - * - * Return value: A new #VfolderContext object. - **/ -VfolderContext * -vfolder_context_new (void) -{ - return (VfolderContext *) g_object_new (VFOLDER_TYPE_CONTEXT, NULL, NULL); -} diff --git a/filter/vfolder-context.h b/filter/vfolder-context.h deleted file mode 100644 index bed020127d..0000000000 --- a/filter/vfolder-context.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 Ximian Inc. - * - * Authors: Not Zed <notzed@lostzed.mmc.com.au> - * Jeffrey Stedfast <fejj@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - - -#ifndef _VFOLDER_CONTEXT_H -#define _VFOLDER_CONTEXT_H - -#include "rule-context.h" - -#define VFOLDER_TYPE_CONTEXT (vfolder_context_get_type ()) -#define VFOLDER_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VFOLDER_TYPE_CONTEXT, VfolderContext)) -#define VFOLDER_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VFOLDER_TYPE_CONTEXT, VfolderContextClass)) -#define IS_VFOLDER_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VFOLDER_TYPE_CONTEXT)) -#define IS_VFOLDER_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VFOLDER_TYPE_CONTEXT)) -#define VFOLDER_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VFOLDER_TYPE_CONTEXT, VfolderContextClass)) - -typedef struct _VfolderContext VfolderContext; -typedef struct _VfolderContextClass VfolderContextClass; - -struct _VfolderContext { - RuleContext parent_object; - -}; - -struct _VfolderContextClass { - RuleContextClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - - -GType vfolder_context_get_type (void); - -VfolderContext *vfolder_context_new (void); - -/* methods */ - -#endif /* ! _VFOLDER_CONTEXT_H */ diff --git a/filter/vfolder-editor.c b/filter/vfolder-editor.c deleted file mode 100644 index 84ebbc0f94..0000000000 --- a/filter/vfolder-editor.c +++ /dev/null @@ -1,127 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2001-2002 Ximian Inc. - * - * Authors: Not Zed <notzed@lostzed.mmc.com.au> - * Jeffrey Stedfast <fejj@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gtk/gtk.h> -#include <libgnome/gnome-i18n.h> - -#include "vfolder-editor.h" -#include "vfolder-rule.h" - -#define d(x) - -static FilterRule *create_rule (RuleEditor *re); - -static void vfolder_editor_class_init (VfolderEditorClass *klass); -static void vfolder_editor_init (VfolderEditor *ve); -static void vfolder_editor_finalise (GObject *obj); - -static RuleEditorClass *parent_class = NULL; - -GtkType -vfolder_editor_get_type (void) -{ - static GtkType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (VfolderEditorClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) vfolder_editor_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (VfolderEditor), - 0, /* n_preallocs */ - (GInstanceInitFunc) vfolder_editor_init, - }; - - type = g_type_register_static (RULE_TYPE_EDITOR, "VfolderEditor", &info, 0); - } - - return type; -} - -static void -vfolder_editor_class_init (VfolderEditorClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - RuleEditorClass *re_class = (RuleEditorClass *) klass; - - parent_class = g_type_class_ref (rule_editor_get_type ()); - - gobject_class->finalize = vfolder_editor_finalise; - - /* override methods */ - re_class->create_rule = create_rule; -} - -static void -vfolder_editor_init (VfolderEditor *ve) -{ - ; -} - -static void -vfolder_editor_finalise (GObject *obj) -{ - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -/** - * vfolder_editor_new: - * - * Create a new VfolderEditor object. - * - * Return value: A new #VfolderEditor object. - **/ -VfolderEditor * -vfolder_editor_new (VfolderContext *vc) -{ - VfolderEditor *ve = (VfolderEditor *) g_object_new (VFOLDER_TYPE_EDITOR, NULL); - GladeXML *gui; - - gui = glade_xml_new (FILTER_GLADEDIR "/filter.glade", "rule_editor", NULL); - rule_editor_construct ((RuleEditor *) ve, (RuleContext *) vc, gui, NULL, _("Virtual _Folders")); - gtk_widget_hide(glade_xml_get_widget (gui, "filter_source")); - g_object_unref (gui); - - return ve; -} - -static FilterRule * -create_rule (RuleEditor *re) -{ - FilterRule *rule = filter_rule_new (); - FilterPart *part; - - /* create a rule with 1 part in it */ - rule = (FilterRule *) vfolder_rule_new (); - part = rule_context_next_part (re->context, NULL); - filter_rule_add_part (rule, filter_part_clone (part)); - - return rule; -} diff --git a/filter/vfolder-editor.h b/filter/vfolder-editor.h deleted file mode 100644 index c33f896eb3..0000000000 --- a/filter/vfolder-editor.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 Ximian Inc. - * - * Authors: Not Zed <notzed@lostzed.mmc.com.au> - * Jeffrey Stedfast <fejj@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - - -#ifndef _VFOLDER_EDITOR_H -#define _VFOLDER_EDITOR_H - -#include "rule-editor.h" -#include "vfolder-context.h" - -#define VFOLDER_TYPE_EDITOR (vfolder_editor_get_type ()) -#define VFOLDER_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VFOLDER_TYPE_EDITOR, VfolderEditor)) -#define VFOLDER_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VFOLDER_TYPE_EDITOR, VfolderEditorClass)) -#define IS_VFOLDER_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VFOLDER_TYPE_EDITOR)) -#define IS_VFOLDER_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VFOLDER_TYPE_EDITOR)) -#define VFOLDER_EDITOR_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), VFOLDER_TYPE_EDITOR, VfolderEditorClass)) - -typedef struct _VfolderEditor VfolderEditor; -typedef struct _VfolderEditorClass VfolderEditorClass; - -struct _VfolderEditor { - RuleEditor parent_object; - -}; - -struct _VfolderEditorClass { - RuleEditorClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - - -GtkType vfolder_editor_get_type (void); - -VfolderEditor *vfolder_editor_new (VfolderContext *vc); - -#endif /* ! _VFOLDER_EDITOR_H */ diff --git a/filter/vfolder-rule.c b/filter/vfolder-rule.c deleted file mode 100644 index d796b97d75..0000000000 --- a/filter/vfolder-rule.c +++ /dev/null @@ -1,644 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 Ximian Inc. - * - * Author: Not Zed <notzed@lostzed.mmc.com.au> - * Jeffrey Stedfast <fejj@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <string.h> - -#include <gtk/gtk.h> -#include <glade/glade.h> -#include <libgnome/gnome-i18n.h> - -#include "camel/camel-url.h" -#include "vfolder-context.h" -#include "vfolder-rule.h" -#include "mail/em-utils.h" -#include "mail/em-folder-tree.h" -#include "mail/em-folder-selector.h" -#include "mail/mail-component.h" -#include "widgets/misc/e-error.h" - -#define d(x) - -static int validate(FilterRule *); -static int vfolder_eq(FilterRule *fr, FilterRule *cm); -static xmlNodePtr xml_encode(FilterRule *); -static int xml_decode(FilterRule *, xmlNodePtr, RuleContext *f); -static void rule_copy (FilterRule *dest, FilterRule *src); -/*static void build_code(FilterRule *, GString *out);*/ -static GtkWidget *get_widget(FilterRule *fr, RuleContext *f); - -static void vfolder_rule_class_init (VfolderRuleClass *klass); -static void vfolder_rule_init (VfolderRule *vr); -static void vfolder_rule_finalise (GObject *obj); - -/* DO NOT internationalise these strings */ -const char *with_names[] = { - "specific", - "local", - "remote_active", - "local_remote_active" -}; - -static FilterRuleClass *parent_class = NULL; - -GType -vfolder_rule_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (VfolderRuleClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) vfolder_rule_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (VfolderRule), - 0, /* n_preallocs */ - (GInstanceInitFunc) vfolder_rule_init, - }; - - type = g_type_register_static (FILTER_TYPE_RULE, "VfolderRule", &info, 0); - } - - return type; -} - -static void -vfolder_rule_class_init (VfolderRuleClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - FilterRuleClass *fr_class = (FilterRuleClass *) klass; - - parent_class = g_type_class_ref (FILTER_TYPE_RULE); - - object_class->finalize = vfolder_rule_finalise; - - /* override methods */ - fr_class->validate = validate; - fr_class->eq = vfolder_eq; - fr_class->xml_encode = xml_encode; - fr_class->xml_decode = xml_decode; - fr_class->copy = rule_copy; - /*fr_class->build_code = build_code;*/ - fr_class->get_widget = get_widget; -} - -static void -vfolder_rule_init (VfolderRule *vr) -{ - vr->with = VFOLDER_RULE_WITH_SPECIFIC; -} - -static void -vfolder_rule_finalise (GObject *obj) -{ - VfolderRule *vr = (VfolderRule *) obj; - - g_list_foreach (vr->sources, (GFunc) g_free, NULL); - g_list_free (vr->sources); - - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -/** - * vfolder_rule_new: - * - * Create a new VfolderRule object. - * - * Return value: A new #VfolderRule object. - **/ -VfolderRule * -vfolder_rule_new (void) -{ - return (VfolderRule *) g_object_new (VFOLDER_TYPE_RULE, NULL, NULL); -} - -void -vfolder_rule_add_source (VfolderRule *vr, const char *uri) -{ - g_assert (IS_VFOLDER_RULE (vr)); - - vr->sources = g_list_append (vr->sources, g_strdup (uri)); - - filter_rule_emit_changed ((FilterRule *) vr); -} - -const char * -vfolder_rule_find_source (VfolderRule *vr, const char *uri) -{ - GList *l; - - g_assert (IS_VFOLDER_RULE (vr)); - - /* only does a simple string or address comparison, should - probably do a decoded url comparison */ - l = vr->sources; - while (l) { - if (l->data == uri || !strcmp (l->data, uri)) - return l->data; - l = l->next; - } - - return NULL; -} - -void -vfolder_rule_remove_source (VfolderRule *vr, const char *uri) -{ - char *found; - - g_assert (IS_VFOLDER_RULE (vr)); - - found = (char *) vfolder_rule_find_source (vr, uri); - if (found) { - vr->sources = g_list_remove (vr->sources, found); - g_free (found); - filter_rule_emit_changed ((FilterRule *) vr); - } -} - -const char * -vfolder_rule_next_source (VfolderRule *vr, const char *last) -{ - GList *node; - - if (last == NULL) { - node = vr->sources; - } else { - node = g_list_find (vr->sources, (char *) last); - if (node == NULL) - node = vr->sources; - else - node = g_list_next (node); - } - - if (node) - return (const char *) node->data; - - return NULL; -} - -static int -validate (FilterRule *fr) -{ - g_return_val_if_fail (fr != NULL, FALSE); - - if (!fr->name || !*fr->name) { - /* FIXME: set a aprent window? */ - e_error_run(NULL, "filter:no-name-vfolder", NULL); - return 0; - } - - /* We have to have at least one source set in the "specific" case. - Do not translate this string! */ - if (((VfolderRule *)fr)->with == VFOLDER_RULE_WITH_SPECIFIC && ((VfolderRule *)fr)->sources == NULL) { - /* FIXME: set a parent window? */ - e_error_run(NULL, "filter:vfolder-no-source", NULL); - return 0; - } - - return FILTER_RULE_CLASS (parent_class)->validate (fr); -} - -static int -list_eq (GList *al, GList *bl) -{ - int truth = TRUE; - - while (truth && al && bl) { - char *a = al->data, *b = bl->data; - - truth = strcmp (a, b) == 0; - al = al->next; - bl = bl->next; - } - - return truth && al == NULL && bl == NULL; -} - -static int -vfolder_eq (FilterRule *fr, FilterRule *cm) -{ - return FILTER_RULE_CLASS (parent_class)->eq (fr, cm) - && list_eq (((VfolderRule *) fr)->sources, ((VfolderRule *) cm)->sources); -} - -static xmlNodePtr -xml_encode (FilterRule *fr) -{ - VfolderRule *vr = (VfolderRule *) fr; - xmlNodePtr node, set, work; - GList *l; - - node = FILTER_RULE_CLASS (parent_class)->xml_encode (fr); - g_assert(node != NULL); - g_assert(vr->with >= 0 && vr->with < sizeof(with_names)/sizeof(with_names[0])); - set = xmlNewNode (NULL, "sources"); - xmlAddChild (node, set); - xmlSetProp(set, "with", with_names[vr->with]); - l = vr->sources; - while (l) { - work = xmlNewNode (NULL, "folder"); - xmlSetProp (work, "uri", l->data); - xmlAddChild (set, work); - l = l->next; - } - - return node; -} - -static void -set_with(VfolderRule *vr, const char *name) -{ - int i; - - for (i=0;i<sizeof(with_names)/sizeof(with_names[0]);i++) { - if (!strcmp(name, with_names[i])) { - vr->with = i; - return; - } - } - - vr->with = 0; -} - -static int -xml_decode (FilterRule *fr, xmlNodePtr node, struct _RuleContext *f) -{ - xmlNodePtr set, work; - int result; - VfolderRule *vr = (VfolderRule *)fr; - char *tmp; - - result = FILTER_RULE_CLASS (parent_class)->xml_decode (fr, node, f); - if (result != 0) - return result; - - /* handle old format file, vfolder source is in filterrule */ - if (strcmp(fr->source, "incoming") != 0) { - set_with(vr, fr->source); - g_free(fr->source); - fr->source = g_strdup("incoming"); - } - - set = node->children; - while (set) { - if (!strcmp(set->name, "sources")) { - tmp = xmlGetProp(set, "with"); - if (tmp) { - set_with(vr, tmp); - xmlFree(tmp); - } - work = set->children; - while (work) { - if (!strcmp(work->name, "folder")) { - tmp = xmlGetProp(work, "uri"); - if (tmp) { - vr->sources = g_list_append(vr->sources, g_strdup(tmp)); - xmlFree(tmp); - } - } - work = work->next; - } - } - set = set->next; - } - return 0; -} - -static void -rule_copy (FilterRule *dest, FilterRule *src) -{ - VfolderRule *vdest, *vsrc; - GList *node; - - vdest = (VfolderRule *) dest; - vsrc = (VfolderRule *) src; - - if (vdest->sources) { - g_list_foreach (vdest->sources, (GFunc) g_free, NULL); - g_list_free (vdest->sources); - vdest->sources = NULL; - } - - node = vsrc->sources; - while (node) { - char *uri = node->data; - - vdest->sources = g_list_append (vdest->sources, g_strdup (uri)); - node = node->next; - } - - vdest->with = vsrc->with; - - FILTER_RULE_CLASS (parent_class)->copy (dest, src); -} - -enum { - BUTTON_ADD, - BUTTON_REMOVE, - BUTTON_LAST, -}; - -struct _source_data { - RuleContext *rc; - VfolderRule *vr; - const char *current; - GtkListStore *model; - GtkTreeView *list; - GtkButton *buttons[BUTTON_LAST]; -}; - -static void source_add(GtkWidget *widget, struct _source_data *data); -static void source_remove(GtkWidget *widget, struct _source_data *data); - -static struct { - char *name; - GtkSignalFunc func; -} edit_buttons[] = { - { "source_add", G_CALLBACK (source_add) }, - { "source_remove", G_CALLBACK (source_remove) }, -}; - -static void -set_sensitive (struct _source_data *data) -{ - gtk_widget_set_sensitive ((GtkWidget *) data->buttons[BUTTON_ADD], TRUE); - gtk_widget_set_sensitive ((GtkWidget *) data->buttons[BUTTON_REMOVE], data->current != NULL); -} - -static void -select_source (GtkWidget *list, struct _source_data *data) -{ - GtkTreeViewColumn *column; - GtkTreePath *path; - GtkTreeIter iter; - - gtk_tree_view_get_cursor (data->list, &path, &column); - gtk_tree_model_get_iter (GTK_TREE_MODEL (data->model), &iter, path); - gtk_tree_path_free (path); - - gtk_tree_model_get (GTK_TREE_MODEL (data->model), &iter, 0, &data->current, -1); - - set_sensitive (data); -} - -static void -select_source_with_changed(GtkWidget *widget, struct _source_data *data) -{ - vfolder_rule_with_t with; - - with = gtk_option_menu_get_history((GtkOptionMenu *)widget); - if (with < VFOLDER_RULE_WITH_SPECIFIC || with > VFOLDER_RULE_WITH_LOCAL_REMOTE_ACTIVE) - with = 0; - data->vr->with = with; -} - -/* attempt to make a 'nice' folder name out of the raw uri */ -static char *format_source(const char *euri) -{ - CamelURL *url; - GString *out; - char *res, *uri; - - /* This should really probably base it on the account name? */ - uri = em_uri_to_camel(euri); - url = camel_url_new(uri, NULL); - - /* bad uri */ - if (url == NULL) - return uri; - - g_free(uri); - - out = g_string_new(url->protocol); - g_string_append_c(out, ':'); - if (url->user && url->host) { - g_string_append_printf(out, "%s@%s", url->user, url->host); - if (url->port) - g_string_append_printf(out, ":%d", url->port); - } - if (url->fragment) - g_string_append(out, url->fragment); - else if (url->path) - g_string_append(out, url->path); - - res = out->str; - g_string_free(out, FALSE); - - return res; -} - -static void -vfr_folder_response(GtkWidget *dialog, gint button, struct _source_data *data) -{ - const char *uri = em_folder_selector_get_selected_uri((EMFolderSelector *)dialog); - - if (button == GTK_RESPONSE_OK && uri != NULL) { - char *urinice, *euri; - GtkTreeSelection *selection; - GtkTreeIter iter; - - euri = em_uri_from_camel(uri); - - data->vr->sources = g_list_append (data->vr->sources, euri); - - gtk_list_store_append (data->model, &iter); - urinice = format_source(euri); - gtk_list_store_set(data->model, &iter, 0, urinice, 1, euri, -1); - g_free(urinice); - selection = gtk_tree_view_get_selection(data->list); - gtk_tree_selection_select_iter(selection, &iter); - data->current = euri; - - set_sensitive(data); - } - - gtk_widget_destroy(dialog); -} - -static void -source_add(GtkWidget *widget, struct _source_data *data) -{ - EMFolderTree *emft; - GtkWidget *dialog; - - emft = (EMFolderTree *) em_folder_tree_new_with_model(mail_component_peek_tree_model(mail_component_peek())); - - dialog = em_folder_selector_new(emft, EM_FOLDER_SELECTOR_CAN_CREATE, _("Select Folder"), NULL, _("_Add")); - gtk_window_set_transient_for((GtkWindow *)dialog, (GtkWindow *)gtk_widget_get_toplevel(widget)); - gtk_window_set_modal((GtkWindow *)dialog, TRUE); - g_signal_connect(dialog, "response", G_CALLBACK(vfr_folder_response), data); - gtk_widget_show(dialog); -} - -static void -source_remove (GtkWidget *widget, struct _source_data *data) -{ - GtkTreeSelection *selection; - const char *source; - GtkTreePath *path; - GtkTreeIter iter; - int index = 0; - int n; - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (data->list)); - - source = NULL; - while ((source = vfolder_rule_next_source (data->vr, source))) { - path = gtk_tree_path_new (); - gtk_tree_path_append_index (path, index); - - if (gtk_tree_selection_path_is_selected (selection, path)) { - gtk_tree_model_get_iter (GTK_TREE_MODEL (data->model), &iter, path); - - vfolder_rule_remove_source (data->vr, source); - gtk_list_store_remove (data->model, &iter); - gtk_tree_path_free (path); - - /* now select the next rule */ - n = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (data->model), NULL); - index = index >= n ? n - 1 : index; - - if (index >= 0) { - path = gtk_tree_path_new (); - gtk_tree_path_append_index (path, index); - gtk_tree_model_get_iter (GTK_TREE_MODEL (data->model), &iter, path); - gtk_tree_path_free (path); - - gtk_tree_selection_select_iter (selection, &iter); - gtk_tree_model_get (GTK_TREE_MODEL (data->model), &iter, 0, &data->current, -1); - } else { - data->current = NULL; - } - - break; - } - - index++; - gtk_tree_path_free (path); - } - - set_sensitive (data); -} - - -GtkWidget *vfolder_editor_sourcelist_new (char *widget_name, char *string1, char *string2, - int int1, int int2); - -GtkWidget * -vfolder_editor_sourcelist_new (char *widget_name, char *string1, char *string2, int int1, int int2) -{ - GtkWidget *table, *scrolled; - GtkTreeSelection *selection; - GtkCellRenderer *renderer; - GtkListStore *model; - - scrolled = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled), GTK_SHADOW_IN); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - - model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER); - table = gtk_tree_view_new_with_model ((GtkTreeModel *) model); - gtk_tree_view_set_headers_visible ((GtkTreeView *) table, FALSE); - - renderer = gtk_cell_renderer_text_new (); - gtk_tree_view_insert_column_with_attributes ((GtkTreeView *) table, -1, - _("VFolder source"), renderer, - "text", 0, NULL); - - selection = gtk_tree_view_get_selection ((GtkTreeView *) table); - gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); - - gtk_container_add (GTK_CONTAINER (scrolled), table); - - g_object_set_data ((GObject *) scrolled, "table", table); - g_object_set_data ((GObject *) scrolled, "model", model); - - gtk_widget_show (scrolled); - gtk_widget_show (table); - - return scrolled; -} - -static GtkWidget * -get_widget (FilterRule *fr, RuleContext *rc) -{ - VfolderRule *vr = (VfolderRule *) fr; - GtkWidget *widget, *frame, *list; - struct _source_data *data; - GtkOptionMenu *omenu; - const char *source; - GtkTreeIter iter; - GladeXML *gui; - int i; - - widget = FILTER_RULE_CLASS (parent_class)->get_widget (fr, rc); - - data = g_malloc0 (sizeof (*data)); - data->rc = rc; - data->vr = vr; - - gui = glade_xml_new (FILTER_GLADEDIR "/filter.glade", "vfolder_source_frame", NULL); - frame = glade_xml_get_widget (gui, "vfolder_source_frame"); - - g_object_set_data_full ((GObject *) frame, "data", data, g_free); - - for (i = 0; i < BUTTON_LAST; i++) { - data->buttons[i] = (GtkButton *) glade_xml_get_widget (gui, edit_buttons[i].name); - g_signal_connect (data->buttons[i], "clicked", edit_buttons[i].func, data); - } - - list = glade_xml_get_widget (gui, "source_list"); - data->list = (GtkTreeView *) g_object_get_data ((GObject *) list, "table"); - data->model = (GtkListStore *) g_object_get_data ((GObject *) list, "model"); - - source = NULL; - while ((source = vfolder_rule_next_source (vr, source))) { - char *nice = format_source(source); - - gtk_list_store_append (data->model, &iter); - gtk_list_store_set (data->model, &iter, 0, nice, 1, source, -1); - g_free(nice); - } - - g_signal_connect (data->list, "cursor-changed", G_CALLBACK (select_source), data); - - omenu = (GtkOptionMenu *) glade_xml_get_widget (gui, "source_option"); - gtk_option_menu_set_history(omenu, vr->with); - g_signal_connect(omenu, "changed", G_CALLBACK(select_source_with_changed), data); - - set_sensitive (data); - - g_object_unref (gui); - - gtk_box_pack_start (GTK_BOX (widget), frame, TRUE, TRUE, 3); - - return widget; -} diff --git a/filter/vfolder-rule.h b/filter/vfolder-rule.h deleted file mode 100644 index 88604be5de..0000000000 --- a/filter/vfolder-rule.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 Ximian Inc. - * - * Author: NotZed <notzed@ximian.com> - * Jeffrey Stedfast <fejj@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - - -#ifndef _VFOLDER_RULE_H -#define _VFOLDER_RULE_H - -#include "filter-rule.h" - -#define VFOLDER_TYPE_RULE (vfolder_rule_get_type ()) -#define VFOLDER_RULE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VFOLDER_TYPE_RULE, VfolderRule)) -#define VFOLDER_RULE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VFOLDER_TYPE_RULE, VfolderRuleClass)) -#define IS_VFOLDER_RULE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VFOLDER_TYPE_RULE)) -#define IS_VFOLDER_RULE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VFOLDER_TYPE_RULE)) -#define VFOLDER_RULE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VFOLDER_TYPE_RULE, VfolderRuleClass)) - -/* perhaps should be bits? */ -enum _vfolder_rule_with_t { - VFOLDER_RULE_WITH_SPECIFIC, - VFOLDER_RULE_WITH_LOCAL, - VFOLDER_RULE_WITH_REMOTE_ACTIVE, - VFOLDER_RULE_WITH_LOCAL_REMOTE_ACTIVE, -}; - -typedef struct _VfolderRule VfolderRule; -typedef struct _VfolderRuleClass VfolderRuleClass; - -typedef enum _vfolder_rule_with_t vfolder_rule_with_t; - -struct _VfolderRule { - FilterRule rule; - - vfolder_rule_with_t with; - GList *sources; /* uri's of the source folders */ -}; - -struct _VfolderRuleClass { - FilterRuleClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - -GType vfolder_rule_get_type (void); -VfolderRule *vfolder_rule_new (void); - -/* methods */ -void vfolder_rule_add_source (VfolderRule *vr, const char *uri); -void vfolder_rule_remove_source (VfolderRule *vr, const char *uri); -const char *vfolder_rule_find_source (VfolderRule *vr, const char *uri); -const char *vfolder_rule_next_source (VfolderRule *vr, const char *last); - -#endif /* ! _VFOLDER_RULE_H */ diff --git a/filter/vfoldertypes.xml b/filter/vfoldertypes.xml deleted file mode 100644 index d9e2b86841..0000000000 --- a/filter/vfoldertypes.xml +++ /dev/null @@ -1,424 +0,0 @@ -<?xml version="1.0"?> -<filterdescription> -<partset> - <part name="sender"> - <title>Sender</title> - <input type="optionlist" name="sender-type"> - <option value="contains"> - <title>contains</title> - <code>(match-all (header-contains "From" ${sender}))</code> - </option> - <option value="not contains"> - <title>does not contain</title> - <code>(match-all (not (header-contains "From" ${sender})))</code> - </option> - <option value="is"> - <title>is</title> - <code>(match-all (header-matches "From" ${sender}))</code> - </option> - <option value="is not"> - <title>is not</title> - <code>(match-all (not (header-matches "From" ${sender})))</code> - </option> - <option value="starts with"> - <title>starts with</title> - <code> - (match-all (header-starts-with "From" ${sender})) - </code> - </option> - <option value="not starts with"> - <title>does not start with</title> - <code> - (match-all (not (header-starts-with "From" ${sender}))) - </code> - </option> - <option value="ends with"> - <title>ends with</title> - <code> - (match-all (header-ends-with "From" ${sender})) - </code> - </option> - <option value="not ends with"> - <title>does not end with</title> - <code> - (match-all (not (header-ends-with "From" ${sender}))) - </code> - </option> - </input> - <input type="string" name="sender"/> - </part> - - <part name="to"> - <title>Recipients</title> - <input type="optionlist" name="recipient-type"> - <option value="contains"> - <title>contains</title> - <code> - (match-all (or (header-contains "To" ${recipient}) - (header-contains "Cc" ${recipient}))) - </code> - </option> - <option value="not contains"> - <title>does not contain</title> - <code> - (match-all (not (or - (header-contains "To" ${recipient}) - (header-contains "Cc" ${recipient})))) - </code> - </option> - <option value="is"> - <title>is</title> - <code> - (match-all (or (header-matches "To" ${recipient}) - (header-matches "Cc" ${recipient}))) - </code> - </option> - <option value="is not"> - <title>is not</title> - <code> - (match-all (not (or - (header-matches "To" ${recipient}) - (header-matches "Cc" ${recipient})))) - </code> - </option> - <option value="starts with"> - <title>starts with</title> - <code> - (match-all (or (header-starts-with "To" ${recipient}) - (header-starts-with "Cc" ${recipient}))) - </code> - </option> - <option value="not starts with"> - <title>does not start with</title> - <code> - (match-all (not (or - (header-starts-with "To" ${recipient}) - (header-starts-with "Cc" ${recipient})))) - </code> - </option> - <option value="ends with"> - <title>ends with</title> - <code> - (match-all (or (header-ends-with "To" ${recipient}) - (header-ends-with "Cc" ${recipient}))) - </code> - </option> - <option value="not ends with"> - <title>does not end with</title> - <code> - (match-all (not (or - (header-ends-with "To" ${recipient}) - (header-ends-with "Cc" ${recipient})))) - </code> - </option> - </input> - <input type="address" name="recipient"/> - </part> - - <part name="subject"> - <title>Subject</title> - <input type="optionlist" name="subject-type"> - <option value="contains"> - <title>contains</title> - <code> - (match-all (header-contains "Subject" ${subject})) - </code> - </option> - <option value="not contains"> - <title>does not contain</title> - <code> - (match-all (not (header-contains "Subject" ${subject}))) - </code> - </option> - <option value="is"> - <title>is</title> - <code> - (match-all (header-matches "Subject" ${subject})) - </code> - </option> - <option value="is not"> - <title>is not</title> - <code> - (match-all (not (header-matches "Subject" ${subject}))) - </code> - </option> - <option value="starts with"> - <title>starts with</title> - <code> - (match-all (header-starts-with "Subject" ${subject})) - </code> - </option> - <option value="not starts with"> - <title>does not start with</title> - <code> - (match-all (not (header-starts-with "Subject" ${subject}))) - </code> - </option> - <option value="ends with"> - <title>ends with</title> - <code> - (match-all (header-ends-with "Subject" ${subject})) - </code> - </option> - <option value="not ends with"> - <title>does not end with</title> - <code> - (match-all (not (header-ends-with "Subject" ${subject}))) - </code> - </option> - </input> - <input type="string" name="subject"/> - </part> - <part name="body"> - <title>Message Body</title> - <input type="optionlist" name="body-type"> - <option value="contains"> - <title>contains</title> - <code> - (body-contains ${word}) - </code> - </option> - <option value="not contains"> - <title>does not contain</title> - <code> - (not (body-contains ${word})) - </code> - </option> - </input> - <input type="string" name="word"/> - </part> - <part name="sexp"> - <title>Expression</title> - <input type="code" name="code"/> - </part> - - <part name="sent-date"> - <title>Date sent</title> - <input type="optionlist" name="date-spec-type"> - <option value="is"> - <title>is</title> - <code> - (match-all (= (get-sent-date) ${versus})) - </code> - </option> - <option value="is-not"> - <title>is not</title> - <code> - (match-all (not (= (get-sent-date) ${versus}))) - </code> - </option> - <option value="before"> - <title>is before</title> - <code> - (match-all (< (get-sent-date) ${versus})) - </code> - </option> - <option value="after"> - <title>is after</title> - <code> - (match-all (> (get-sent-date) ${versus})) - </code> - </option> - </input> - <input type="datespec" name="versus"/> - </part> - - <part name="recv-date"> - <title>Date received</title> - <input type="optionlist" name="date-spec-type"> - <option value="is"> - <title>is</title> - <code> - (match-all (= (get-received-date) ${versus})) - </code> - </option> - <option value="is-not"> - <title>is not</title> - <code> - (match-all (not (= (get-received-date) ${versus}))) - </code> - </option> - <option value="before"> - <title>is before</title> - <code> - (match-all (< (get-received-date) ${versus})) - </code> - </option> - <option value="after"> - <title>is after</title> - <code> - (match-all (> (get-received-date) ${versus})) - </code> - </option> - </input> - <input type="datespec" name="versus"/> - </part> - - <part name="label"> - <title>Label</title> - <input type="optionlist" name="label-type"> - <option value="is"> - <title>is</title> - <code> - (match-all (= (user-tag "label") ${versus})) - </code> - </option> - <option value="is-not"> - <title>is not</title> - <code> - (match-all (not (= (user-tag "label") ${versus}))) - </code> - </option> - </input> - <input type="label" name="versus"/> - </part> - - <part name="score"> - <title>Score</title> - <input type="optionlist" name="score-type"> - <option value="is"> - <title>is</title> - <code> - (match-all (= (cast-int (user-tag "score")) ${versus})) - </code> - </option> - <option value="is-not"> - <title>is not</title> - <code> - (match-all (not (= (cast-int (user-tag "score")) ${versus}))) - </code> - </option> - <option value="greater-than"> - <title>is greater than</title> - <code> - (match-all (> (cast-int (user-tag "score")) ${versus})) - </code> - </option> - <option value="less-than"> - <title>is less than</title> - <code> - (match-all (< (cast-int (user-tag "score")) ${versus})) - </code> - </option> - </input> - <input type="score" name="versus"/> - </part> - - <part name="size"> - <title>Size (kB)</title> - <input type="optionlist" name="size-type"> - <option value="greater-than"> - <title>is greater than</title> - <code> - (match-all (> (get-size) ${versus})) - </code> - </option> - <option value="less-than"> - <title>is less than</title> - <code> - (match-all (< (get-size) ${versus})) - </code> - </option> - </input> - <input type="integer" name="versus"/> - </part> - - <part name="status"> - <title>Status</title> - <input type="optionlist" name="match-type"> - <option value="is"> - <title>is</title> - <code> - (match-all (system-flag ${flag})) - </code> - </option> - <option value="is not"> - <title>is not</title> - <code> - (match-all (not (system-flag ${flag}))) - </code> - </option> - </input> - <input type="optionlist" name="flag"> - <option value="Answered"> - <title>Replied to</title> - </option> - <option value="Deleted"> - <title>Deleted</title> - </option> - <option value="Draft"> - <title>Draft</title> - </option> - <option value="Flagged"> - <title>Important</title> - </option> - <option value="Seen"> - <title>Read</title> - </option> - <option value="Junk"> - <title>Junk</title> - </option> - </input> - </part> - - <part name="follow-up"> - <title>Follow Up</title> - <input type="optionlist" name="match-type"> - <option value="is"> - <title>is Flagged</title> - <code> - (match-all (not (= (user-tag "follow-up") ""))) - </code> - </option> - <option value="is not"> - <title>is not Flagged</title> - <code> - (match-all (= (user-tag "follow-up") "")) - </code> - </option> - </input> - </part> - - <part name="attachments"> - <title>Attachments</title> - <input type="optionlist" name="match-type"> - <option value="exist"> - <title>Exist</title> - <code> - (match-all (system-flag "Attachments")) - </code> - </option> - <option value="not exist"> - <title>Do Not Exist</title> - <code> - (match-all (not (system-flag "Attachments"))) - </code> - </option> - </input> - </part> - - <part name="mlist"> - <title>Mailing list</title> - <input type="optionlist" name="mlist-type"> - <option value="is"> - <title>is</title> - <code>(match-all (header-matches "x-camel-mlist" ${mlist}))</code> - </option> - <option value="is not"> - <title>is not</title> - <code>(match-all (not (header-matches "x-camel-mlist" ${mlist})))</code> - </option> - <option value="contains"> - <title>contains</title> - <code>(match-all (header-contains "x-camel-mlist" ${mlist}))</code> - </option> - <option value="not contains"> - <title>does not contain</title> - <code>(match-all (not (header-contains "x-camel-mlist" ${mlist})))</code> - </option> - </input> - <input type="string" name="mlist"/> - </part> - -</partset> -</filterdescription> |