From 2e129e04c509cffde9e3072bbd94cc1640b05d23 Mon Sep 17 00:00:00 2001 From: nobody Date: Tue, 22 Aug 2000 12:05:30 +0000 Subject: This commit was manufactured by cvs2svn to create tag 'gnomemm-1_1_11'. svn path=/tags/gnomemm-1_1_11/; revision=4958 --- filter/.cvsignore | 9 - filter/ChangeLog | 647 ------------------------------------------- filter/Makefile.am | 72 ----- filter/filter-code.c | 121 -------- filter/filter-code.h | 53 ---- filter/filter-colour.c | 220 --------------- filter/filter-colour.h | 55 ---- filter/filter-context.c | 148 ---------- filter/filter-context.h | 59 ---- filter/filter-datespec.c | 703 ----------------------------------------------- filter/filter-datespec.h | 64 ----- filter/filter-driver.c | 636 ------------------------------------------ filter/filter-driver.h | 71 ----- filter/filter-editor.c | 389 -------------------------- filter/filter-editor.h | 61 ---- filter/filter-element.c | 267 ------------------ filter/filter-element.h | 77 ------ filter/filter-filter.c | 411 --------------------------- filter/filter-filter.h | 60 ---- filter/filter-folder.c | 267 ------------------ filter/filter-folder.h | 56 ---- filter/filter-input.c | 260 ------------------ filter/filter-input.h | 59 ---- filter/filter-option.c | 311 --------------------- filter/filter-option.h | 64 ----- filter/filter-part.c | 432 ----------------------------- filter/filter-part.h | 75 ----- filter/filter-rule.c | 574 -------------------------------------- filter/filter-rule.h | 99 ------- filter/filter.glade | 702 ---------------------------------------------- filter/filtertypes.xml | 177 ------------ filter/rule-context.c | 427 ---------------------------- filter/rule-context.h | 118 -------- filter/score-context.c | 100 ------- filter/score-context.h | 53 ---- filter/score-editor.c | 313 --------------------- filter/score-editor.h | 59 ---- filter/score-rule.c | 190 ------------- filter/score-rule.h | 56 ---- filter/vfolder-context.c | 116 -------- filter/vfolder-context.h | 55 ---- filter/vfolder-editor.c | 339 ----------------------- filter/vfolder-editor.h | 61 ---- filter/vfolder-rule.c | 354 ------------------------ filter/vfolder-rule.h | 59 ---- filter/vfoldertypes.xml | 144 ---------- 46 files changed, 9643 deletions(-) delete mode 100644 filter/.cvsignore delete mode 100644 filter/ChangeLog delete mode 100644 filter/Makefile.am delete mode 100644 filter/filter-code.c delete mode 100644 filter/filter-code.h delete mode 100644 filter/filter-colour.c delete mode 100644 filter/filter-colour.h delete mode 100644 filter/filter-context.c delete mode 100644 filter/filter-context.h delete mode 100644 filter/filter-datespec.c delete mode 100644 filter/filter-datespec.h delete mode 100644 filter/filter-driver.c delete mode 100644 filter/filter-driver.h delete mode 100644 filter/filter-editor.c delete mode 100644 filter/filter-editor.h delete mode 100644 filter/filter-element.c delete mode 100644 filter/filter-element.h delete mode 100644 filter/filter-filter.c delete mode 100644 filter/filter-filter.h delete mode 100644 filter/filter-folder.c delete mode 100644 filter/filter-folder.h delete mode 100644 filter/filter-input.c delete mode 100644 filter/filter-input.h delete mode 100644 filter/filter-option.c delete mode 100644 filter/filter-option.h delete mode 100644 filter/filter-part.c delete mode 100644 filter/filter-part.h delete mode 100644 filter/filter-rule.c delete mode 100644 filter/filter-rule.h delete mode 100644 filter/filter.glade delete mode 100644 filter/filtertypes.xml delete mode 100644 filter/rule-context.c delete mode 100644 filter/rule-context.h delete mode 100644 filter/score-context.c delete mode 100644 filter/score-context.h delete mode 100644 filter/score-editor.c delete mode 100644 filter/score-editor.h delete mode 100644 filter/score-rule.c delete mode 100644 filter/score-rule.h delete mode 100644 filter/vfolder-context.c delete mode 100644 filter/vfolder-context.h delete mode 100644 filter/vfolder-editor.c delete mode 100644 filter/vfolder-editor.h delete mode 100644 filter/vfolder-rule.c delete mode 100644 filter/vfolder-rule.h delete mode 100644 filter/vfoldertypes.xml (limited to 'filter') diff --git a/filter/.cvsignore b/filter/.cvsignore deleted file mode 100644 index 7c13af9a14..0000000000 --- a/filter/.cvsignore +++ /dev/null @@ -1,9 +0,0 @@ -*.la -*.lo -.libs -.deps -.pure -Makefile -Makefile.in -filter-driver -filter-editor diff --git a/filter/ChangeLog b/filter/ChangeLog deleted file mode 100644 index 39ff8bf6f7..0000000000 --- a/filter/ChangeLog +++ /dev/null @@ -1,647 +0,0 @@ -2000-08-14 Ettore Perazzoli - - * vfolder-editor.c (rule_add): Add translation marks and use stock - buttons. - (rule_edit): Likewise. - - * score-editor.c (rule_add): Add translation marks and use stock - buttons. - (rule_edit): Likewise. - - * rule-context.c (rule_context_add_rule_gui): Add translation - marks and use stock buttons. - - * filter-part.c (main): Add translation marks and use - stock buttons. - - * filter-folder.c (button_clicked): Add translation marks and use - stock buttons. - - * filter-editor.c (rule_add): Add translation marks and use stock - buttons. - (rule_edit): Likewise. - - * filter-rule.c (get_widget): Add translation marks. - - * filter-filter.c (get_widget): Add translation marks. Add - padding to make it look like the buttons in `filter-rule.c'. - -2000-08-17 Peter Williams - - Implement filtering on demand. - - * rule-context.h: Add a new callback to rule_context_load - that allows the caller to hook on-demand rules into its UI. - - * rule-context.c (rule_context_load): Changed to pass the - extra parameters to load(). - (load): If the rule is successfully loaded, call the provided - callback so that the UI can be updated. - - * filter-editor.c (rule_add): Set the source of the new filter. - (rule_edit): Use the new rule_context_get_rank_rule_with_source() - so that we don't get a bad index into the GtkList. - (rule_delete): Same as above. - (rule_up): Same as above. - (rule_down): Same as above. - (select_source): New function. When the user changes the - dropdown list to select a new source type, repopulate the - list with rules of the appropriate type. - (filter_editor_construct): Code moved from here into - select_source(). Hook up all the elements of the source optionmenu - to callbacks to select_source(). - - * filter-rule.c (xml_encode): Save the rule's source type. - (xml_decode): Load it. Default to 'incoming' if unspecified. - - * filter-rule.h: New enumeration, _filter_source_t, the - specifies the rule's source. Add it to struct _FilterRule. - - * filter-driver.c (filter_driver_run): Add a new input, - sourcetype, that specifies which rules to run (only ones - with the same source will be run). struct filter_mail_input_t - changed to accomodate. - (do_filter_mail): Skip rules if they're not the specified source. - If source and dest are the same, don't delete the messages or - copy unnecessarily. - - * filter.glade: Make the optionmenu sensitive. Change "Outgoing" - to "On Demand" (outgoing should be added later). - -2000-08-15 Peter Williams - - * vfoldertype.xml, filtertypes.xml: Add entries defining the - date-based message filtering and vfoldering. - - * filter-datespec.{c,h}: New files implementing the UI for - date-based filtering and vfoldering -- specifically, choosing - what to compare the message to. - - * filter-element,c: Hook up to create a datespec filter if - that's what's called for. - - * Makefile.am: Build the new -datespec files. - -2000-08-13 Dan Winship - - * Makefile.am (EXTRA_DIST): remove blank.xpm and check.xpm which - no longer exist. Add filter.glade. - -2000-08-12 Dan Winship - - * filter-driver.c (describe_filter_mail): Use - mail_tool_get_folder_name here too. (Hm... this directory really - shouldn't depend on stuff in mail/, but it already did. We'll have - to sort this out later.) - -2000-08-11 Dan Winship - - * filter-driver.c (do_filter_mail): Remove an '#if 0' that must - have been left in accidentally, so that messages which are copied - to other folders will not also be copied into the Inbox. Also, - #ifdef out the line that printfs the rule, because the rules are - often very large. - -2000-08-11 Not Zed - - * filter-driver.c (do_colour): Use proper accessor function - instead of poking the structure. - -2000-08-10 Christopher James Lahey - - * filter-driver.c, filter-folder.c, rule-context.c, - vfolder-editor.c: Fixed some warnings. - -2000-08-10 Peter Williams - - * filter-driver.c (do_filter_mail): Fix the infinite fetchmail. - -2000-08-10 Not Zed - - * filter-driver.c (filter_driver_run): Save the results of - searches till we're done. So we dont have to go strduping strings - agian and again and again and again ... Remove all the unecessary - strdups. - (do_colour): Implement. - (filter_driver_run): Change for append api change. - (free_key): Removed. - -2000-08-09 Not Zed - - * rule-context.c (rule_context_add_rule_gui): Helper function to - add a rule, but present a gui first, asking for confirmation/allow - editing. - (rule_context_add_rule_gui): Keep track of context so it isn't freed under us. - - * filter-context.c (filter_context_create_action): Implement, - helper to aid filter generation. - -2000-08-08 Peter Williams - - * filter-driver.c (close_folder): Fix an accidental GTK unref - of a CamelObject. - -2000-08-03 Ettore Perazzoli - - * filter-folder.c (button_clicked): Use the base name of the - Evoluton URI for the button's label. - (get_widget): Likewise. - -2000-08-03 Peter Williams - - * filter-driver.c (op_filter_mail): Conform to the new mail-threads - interface. - -2000-08-01 Not Zed - - * vfolder-editor.c (rule_add): Oops, create a vfolder_rule when we - add a new one. - - * rule-context.c (load): If there are no user rules, dont bomb - out. - -2000-07-31 Not Zed - - * filter-input.c (filter_input_set_value): Set value of a simple - type to a new string. - - * filter-option.c (filter_option_set_current): New function to set - the current value of an option. - - * filter-rule.c (filter_rule_find_list): New function to find a - rule in a list, by name. - (filter_rule_set_name): Let you set the name of a rule. - - * rule-context.c (rule_context_find_rule): Find a rule by name. - (rule_context_create_part): Helper to find and clone a part by - name. - - * filter-folder.c (button_clicked): Fix warning. - - * filter.glade: Add new widgets for vfolder rule editor. - - * vfolder-context.c (vfolder_context_init): Changed to use vfolder - rule as the rule type. - - * vfolder-rule.c: New class to encode extra information required - for vfolder rules. - -2000-07-30 Not Zed - - ** Almost a total rewrite of every file, except for filter-driver - which just had minor updates. - - The rule format has changed. - -2000-07-24 Dan Winship - - * filter-driver.c (do_delete, filter_driver_run): Update for - CamelFolder API changes. (delete_message and get_uids don't take - exceptions any more.) - -2000-07-21 Peter Williams - - * filter-driver.c (cleanup_filter_mail): Use the exception - provided to us by the async manager instead of allocating - our own; use mail_tool_camel_lock_{up,down} around camel - operations. - (filter_driver_run): Make it return void. - -2000-07-20 Jeffrey Stedfast - - * filter-driver.c: Update to make "async". - -2000-07-11 Dan Winship - - * filter-driver.c: Update for CamelFolder API changes - -2000-07-11 Jeffrey Stedfast - - * filter-driver.c (filter_driver_run): Updated to reflect changes to - camel_folder_append_message () - -2000-07-09 Dan Winship - - * filter-xml.[ch]: add a "string" type - - * filtertype.xml, vfoldertypes.xml: Use type="string" rather than - "folder" for subject/body matching. - - * filter-arg-types.c: Update some strings for "text" input. Fix - some warnings (including one that pointed out a real bug). - - * filter-arg.c, filter-druid.c, filter-format.c: fix warnings - -2000-07-07 Dan Winship - - * filter-driver.c: Update for camel_folder_search_by_expression - change (GList -> GPtrArray). - - * vfoldertypes.xml: sync this to filtertypes.xml (to/cc thing) - -2000-07-05 Dan Winship - - * remove some non-error case debugging messages. - - * filtertypes.xml: Fix typos and update the "to-address" rule to - match To or Cc. - * vfoldertypes.xml: Fix typos. - - * filter-driver.c (do_delete, do_copy, do_stop, - filter_driver_run): Add uids to the "processed" list only after - succesfully doing something with them. Fixes the problem where - copying a message to a folder that didn't exist would result in it - disapearing. - -2000-07-02 Ettore Perazzoli - - * filter-driver.c (filter_driver_new): Don't free the ruleset nor - the xmlDoc. This will make us leak [I think], but at least - filters work. - -2000-07-02 Dan Winship - - * filter-driver.c (open_folder): freeze the folder to avoid - multiple folder_changed's - (close_folder): and thaw it. - -2000-07-02 Dan Winship - - * filter-driver.c (filter_driver_new): kill - filter_driver_set_session and filter_driver_set_rules and instead - make filter_driver_new take the rules and a callback function it - can use to turn URIs into folders. - (open_folder): Use the callback function rather than calling camel - directly: some URIs need special handling to turn them into stores - and folders correctly, so let the mailer do that. - -2000-07-01 Ettore Perazzoli - - * filter-arg-types.c (arg_folder_edit_value): Only allow type - "mail" when selecting a folder for the filter. - -2000-07-01 Jeffrey Stedfast - - * filter-driver.c: Updated to reflect changes made to - camel-folder. - -2000-06-30 Peter Williams - - * filter-xml.c (filter_load_optionset_file): Check for failure - when loading the filter doc. - - * filter-driver.c (filter_driver_set_rules): Ditto. - - * filter-editor.c (filter_editor_set_rule_files): Ditto. - -2000-06-29 Ettore Perazzoli - - * filter-arg-types.c: Replaced `global_shell_interface' with - `global_shell_client'. - (arg_folder_edit_value): Use - `evolution_shell_client_user_select_folder()'. - (create_listener): Removed. - (impl_FolderSelectionListener_selected): Removed, together with - all the ::Listener stuff. - -2000-06-29 Arik Devens - - * vfoldertypes.xml (ruleset type="match"): Changed Cc to CC to be - the same as the other CC rule. None of this works however, cause - the CC code is not hooked up to camel... oh well ;-( - -2000-06-29 Arik Devens - - * vfoldertypes.xml (ruleset type="match"): Added a Cc rule to - vfolders. Works like To except on the Cc of a message ;-) - -2000-06-28 Jeffrey Stedfast - - * filter-arg-types.c (arg_string_edit_value): Changed "Filter name" - to "Option value" as "Filter name" made no sense in the dialog - (arg_address_edit_value): Same - (arg_folder_edit_value): What do we want to return?? - -2000-06-27 Ettore Perazzoli - - * filter-xml.c (load_desc): Strdup content before assigning the - value. Also, no need to check for NULL when g_strdup()ing as - g_strdup() returns NULL for a NULL arg. - -2000-06-27 Ettore Perazzoli - - * Makefile.am (INCLUDES): `-I$(top_builddir)/shell' so that it - works with builddir != srcdir. [We need to #include - "Evolution.h".] - -2000-06-27 Michael Zucchi - - * Makefile.am (INCLUDES): Add the shell dir for includes (for - corba interfaces). - - * filter-arg-types.c (impl_FolderSelectionListener_selected): - Listener for folder query. Sigh. - (create_listener): Create the listener object for the folder - dialogue query. Uses a global for linkage to the shell object, - via the mail component. - (arg_folder_edit_value): Call the folder selection dialogue to - edit the value, rather than a simple text widget. - -2000-06-26 Jeffrey Stedfast - - * filter-editor.c: Added a #include as this - was needed (since we used the xml parser...) - (druid_dialogue_clicked): Do we want to use struct filter_option - or do we instead want to use struct filter_optionrule as we had before? - Since the function we pass the data to expects filter_option, I suspect - that that is what we want. - - * filter-format.h (filter_description_html_write): Renamed from - description_html_write in order to match function name in - filter-format.c - - * filter-druid.c (option_name_changed): Fixed a memory leak (Free'd - a filter description list). - - * filter-arg-types.c (arg_folder_edit_values): Free'd GList data in - argin->values. - - * filter-driver.c (filter_driver_set_rules): Added code to free an - xmlDoc and some other data. - - * filter-arg.h: Add prototypes for filter_arg_write_html() and - filter_arg_write_text(); - - * filter-arg-types.c: Lets see if we can't get rid of some of these - warnings... (use some casts to make warnings go away) - (arg_address_edit_value): Lets make sure that ad exists before looking - at member data. - -2000-06-16 Dan Winship - - * filter-driver.c (do_delete, filter_driver_run): Update for Camel - flag handling changes. - -2000-06-15 Dan Winship - - * filter-driver.c (open_folder, close_folder): Update for - CamelFolder changes. - -2000-06-09 Jacob Berkman - - * filter-editor.c (add_or_edit): use stock pixmap buttons - - * filter-druid.c (build_druid): remove the border on the notebook, - put the html widget in a scroll frame, and add some padding - -2000-06-06 Dan Winship - - * filter-driver.c (open_folder): Update for folder - existence/creation changes. - -2000-06-02 Christopher James Lahey - - * filter-driver.c: Free the exception and the priv struct. - -2000-06-01 Christopher James Lahey - - * filter-arg-types.c (arg_address_edit_value): Search for ad in - arg->values instead of text since it's a list of - filter_arg_adresses. Also, free the old value in the list. - -2000-05-30 Not Zed - - * filtertypes.xml: And here too. - - * vfoldertypes.xml: Add body-contains and not-body-contains - types. - -2000-05-27 Not Zed - - * vfoldertypes.xml: New file - lists rules appropriate for - vfolders (no actions, etc). - - * Makefile.am (EXTRA_DIST): Add vfoldertypes.xml - - * filter-driver.c (filter_driver_expand_option): Made public from - expand_filter_option. - (filter_driver_rule_count): find out how many user rules are - defined. - (filter_driver_rule_get): Get a user rule by index. - -2000-05-21 Ettore Perazzoli - - * filter-druid.c: Don't pass an empty URL to `gtk_html_begin()' - anymore. - - * filter-arg-types.c: Updated for the new GtkHTML API which uses - `GtkHTMLStream *' instead of `GtkHTMLStreamHandle'. - * filter-arg.c: Likewise. - * filter-arg.h: Likewise. - * filter-druid.c: Likewise. - - * filter-format.c: Likewise. - * filter-format.h: Likewise. - -2000-05-18 Dan Winship - - * filter-driver.c (filter_driver_run): update for - camel_folder_get_uids change - -2000-05-17 NotZed - - * filter-druid.c: Fix some html formatting. - -2000-05-16 NotZed - - * filter-driver.c (filter_driver_run): Delete all processed - messages. This is probably going to slow it down a bit. - (filter_driver_run): Close folders before destroying them *sigh*. - (open_folder): Actually open the folder. Doh. - - * filtertypes.xml: Initial filter rules. - - * filter-xml.c (filter_write_optionset): Save the description - also. - (write_description): Routine to save description - only saves 1 - node of description. - - * filter-arg.c (filter_arg_edit_clicked): Dont free edata here, - let the destroy do it(?) - - * filter-editor.c (main): Simple driver program for testing, so i - can fix all this really broken code *sigh* - -2000-05-15 NotZed - - * filter-editor.c (filter_editor_set_rule_files): filename based - interface. - (filter_editor_save_rules): Interface to save the options to a - filename. - - * filter-xml.[ch]: Bunch of cleanup. - - * filter-xml.c (filter_*_file): New interfaces to read/write files - directly, rather than messing with xmldoc crap. - - * Makefile.am: Removed filter-driver test program, now just part - of libfilter. - - * filter-driver.c: Made an object, with an api and everything, can - apply a filter to a given mailbox. - -2000-05-10 Christopher James Lahey - - * filter-arg.h: Changed tree.h to gnome-xml/tree.h. - - * Makefile.am: Added filter-arg-types.h, filter-arg.h, - filter-xml.h, filter-format.h, filter-druid.h, filter-editor.h. - -2000-05-02 Matt Loper - - * Makefile.am: set G_LOG_DOMAIN. - -2000-05-01 NotZed - - * filter-driver.c (main): Fix for api. - -2000-04-30 Dan Winship - - * filter-driver.c (start): Remove no-longer-necessary call to - camel_provider_register_as_module. - -2000-04-25 Ettore Perazzoli - - * Makefile.am (INCLUDES): Use `$(GTKHTML_CFLAGS)'. - -2000-04-20 NotZed - - * filter-driver.c: Removed a bunch of crappy unrequired headers. - - * Makefile.am (filter_driver_LDADD): Added libibex back again. - -2000-04-18 Dan Winship - - * filter-driver.c: remove unused camel-log.h include - -2000-04-12 Matt Loper - - * filter-arg.c (filter_arg_edit_value): Return a value. - -2000-03-27 NotZed - - * filter-xml.c (tokenise_xmlfreeprop): Free a prop after - tokenising it. - (find_node_attr): Free the prop after using it. - (load_desc): Ditto. I use free() because xmlFree() is nowhere to - be found. - (filter_load_optionset): Ditto. - - * filter-arg-types.c (arg_address_values_add_xml): free() xml - stuff, plugs a leak. - (arg_folder_values_add_xml): Ditto. - -2000-03-22 NotZed - - * filter-driver.c (main): Changed to use async search api. - -2000-03-04 NotZed - - * filter-druid.c (html_write_options): Output 'and' bits between - the rules. - - * filter-driver.c (main): Actually implement filtering, at least, - from Inbox. Copy messages to folder (in the same store only, so - far), delete, and stop processing are implemented, and the logic - to handle default processing. - - * filter-xml.c (load_optionvalue): Fix up a bug where we lost the - name of the arg (ouch). - * filter-xml.c: Wrapped printf's in debug macros. - -2000-03-02 NotZed - - * filter-druid.c (object_destroy): Disconnect the list signal, so - we dont get spurious emits during destroy. - (arg_changed): Callback to update filter arg asynchronously. - (arg_link_clicked): Edit the value non-modally. - - * filter-arg.c (filter_arg_edit_values_1): Changed to use - non-modal interface. - -2000-03-01 Ettore Perazzoli - - * Makefile.am: New file. - - * Makefile: Removed. I wonder why we are using plain Makefiles - instead of automake Makefiles at all. - -2000-02-29 NotZed - - * filter-driver.c (main): Remove gui code, this will be actual - filtering code. - - * Makefile: Added filter-editor to the library. - - * filter-editor.c (main): Comment out, make it a proper library. - -2000-02-28 NotZed - - * filter-druid.c: Removed unused header. - - * Makefile: Removed references to filter-sexp.[ch]. - - * filter-sexp.[ch]: Removed some unecessary includes. Moved to - e-util. Renamed callers. - -2000-02-24 NotZed - - * filter-xml.c (filter_description_free): - (filter_load_ruleset_free): - (filter_load_optionset_free): Functions for memory management. - - * filter-arg.c (filter_arg_copy): Copy the values of one arg into - another. - - * filter-editor.c: New widget, a dialogue which uses filter-druid - to present the various editing views. - (druid_dialogue_clicked): On finish, save the user's new filter - definition where it came from. - - * filter-druid.c: Changed to just being a notebook with no tabs, - rather than a full druid (no next/prev/etc buttons). - (option_name_changed): Update the option's description as the user - enters it in. - -2000-02-22 NotZed - - * filter-xml.c (filter_clone_optionrule): - (filter_clone_optionrule_free): - (filter_optionrule_new_from_rule): New utility functions for - working with the internal rule format. - - * filter-arg.[ch]: Added new callbacks for editing a single value, - and a new editor which shows all items in a list, and allows you - to edit them via the single-edit method. This needs some cleanup - for some unused/unusable virtual methods (edit_values, - write_html?). - - * Makefile: Add the druid for build. - - * filter-druid.c: A 'druid' widget for editing a single filter - rule. - -2000-02-21 Matt Loper - - * .cvsignore: New file. - -2000-02-18 NotZed - - * blank/check.xpm: Added forgotten files. - - * Uh, more changes, lots, its still work in progress. - -2000-02-14 NotZed - - * Initial import. - diff --git a/filter/Makefile.am b/filter/Makefile.am deleted file mode 100644 index 65927b827a..0000000000 --- a/filter/Makefile.am +++ /dev/null @@ -1,72 +0,0 @@ - -gladedir = $(prefix)/share/evolution/glade -glade_DATA = filter.glade - -INCLUDES = \ - -I $(top_srcdir) \ - -I $(top_srcdir)/libibex \ - -I $(top_srcdir)/camel \ - -I $(top_srcdir)/e-util \ - -I $(top_srcdir)/shell \ - -I $(top_srcdir)/camel/providers/mbox \ - -I $(top_builddir)/shell \ - -I $(GNOME_INCLUDEDIR) \ - $(GTKHTML_CFLAGS) \ - $(UNICODE_CFLAGS) \ - $(BONOBO_GNOME_CFLAGS) \ - -DFILTER_GLADEDIR=\"$(gladedir)\" \ - -DG_LOG_DOMAIN=\"filter\" -## - -noinst_LTLIBRARIES = \ - libfilter.la - -libfilter_la_SOURCES = \ - filter-code.c \ - filter-code.h \ - filter-colour.c \ - filter-colour.h \ - filter-context.c \ - filter-context.h \ - filter-datespec.c \ - filter-datespec.h \ - filter-driver.c \ - filter-driver.h \ - filter-editor.c \ - filter-editor.h \ - filter-element.c \ - filter-element.h \ - filter-filter.c \ - filter-filter.h \ - filter-folder.c \ - filter-folder.h \ - filter-input.c \ - filter-input.h \ - filter-option.c \ - filter-option.h \ - filter-part.c \ - filter-part.h \ - filter-rule.c \ - filter-rule.h \ - rule-context.c \ - rule-context.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 - -EXTRA_DIST = filtertypes.xml vfoldertypes.xml \ - filter.glade - -# basic rules. -filterdir = $(prefix)/share/evolution -filter_DATA = filtertypes.xml vfoldertypes.xml - diff --git a/filter/filter-code.c b/filter/filter-code.c deleted file mode 100644 index cbab60359e..0000000000 --- a/filter/filter-code.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include - -#include "filter-code.h" - -static void build_code(FilterElement *fe, GString *out, struct _FilterPart *ff); -static void format_sexp(FilterElement *, GString *); - -static void filter_code_class_init (FilterCodeClass *class); -static void filter_code_init (FilterCode *gspaper); -static void filter_code_finalise (GtkObject *obj); - -static FilterInputClass *parent_class; - -guint -filter_code_get_type (void) -{ - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "FilterCode", - sizeof(FilterCode), - sizeof(FilterCodeClass), - (GtkClassInitFunc)filter_code_class_init, - (GtkObjectInitFunc)filter_code_init, - (GtkArgSetFunc)NULL, - (GtkArgGetFunc)NULL - }; - - type = gtk_type_unique(filter_input_get_type (), &type_info); - } - - return type; -} - -static void -filter_code_class_init (FilterCodeClass *class) -{ - GtkObjectClass *object_class; - FilterElementClass *filter_element = (FilterElementClass *)class; - - object_class = (GtkObjectClass *)class; - parent_class = gtk_type_class(filter_input_get_type ()); - - filter_element->build_code = build_code; - filter_element->format_sexp = format_sexp; - - object_class->finalize = filter_code_finalise; - /* override methods */ - -} - -static void -filter_code_init (FilterCode *o) -{ - ((FilterInput *)o)->type = g_strdup("code"); -} - -static void -filter_code_finalise(GtkObject *obj) -{ - FilterCode *o = (FilterCode *)obj; - - o = o; - - ((GtkObjectClass *)(parent_class))->finalize(obj); -} - -/** - * filter_code_new: - * - * Create a new FilterCode object. - * - * Return value: A new #FilterCode object. - **/ -FilterCode * -filter_code_new(void) -{ - FilterCode *o = (FilterCode *)gtk_type_new(filter_code_get_type ()); - return o; -} - -/* here, the string IS the code */ -static void build_code(FilterElement *fe, GString *out, struct _FilterPart *ff) -{ - GList *l; - FilterInput *fi = (FilterInput *)fe; - - l = fi->values; - while (l) { - g_string_append(out, (char *)l->data); - l = g_list_next(l); - } -} - -/* and we have no value */ -static void format_sexp(FilterElement *fe, GString *out) -{ - return; -} diff --git a/filter/filter-code.h b/filter/filter-code.h deleted file mode 100644 index c4bb04caab..0000000000 --- a/filter/filter-code.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef _FILTER_CODE_H -#define _FILTER_CODE_H - -#include - -#include "filter-input.h" - -#define FILTER_CODE(obj) GTK_CHECK_CAST (obj, filter_code_get_type (), FilterCode) -#define FILTER_CODE_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, filter_code_get_type (), FilterCodeClass) -#define IS_FILTER_CODE(obj) GTK_CHECK_TYPE (obj, filter_code_get_type ()) - -typedef struct _FilterCode FilterCode; -typedef struct _FilterCodeClass FilterCodeClass; - -struct _FilterCode { - FilterInput parent; -}; - -struct _FilterCodeClass { - FilterInputClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - -guint filter_code_get_type (void); -FilterCode *filter_code_new (void); - -/* methods */ - -#endif /* ! _FILTER_CODE_H */ - diff --git a/filter/filter-colour.c b/filter/filter-colour.c deleted file mode 100644 index 202908d016..0000000000 --- a/filter/filter-colour.c +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include - -#include "e-util/e-sexp.h" -#include "filter-colour.h" - -#define d(x) - -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_colour_class_init (FilterColourClass *class); -static void filter_colour_init (FilterColour *gspaper); -static void filter_colour_finalise (GtkObject *obj); - -#define _PRIVATE(x) (((FilterColour *)(x))->priv) - -struct _FilterColourPrivate { -}; - -static FilterElementClass *parent_class; - -enum { - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -guint -filter_colour_get_type (void) -{ - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "FilterColour", - sizeof(FilterColour), - sizeof(FilterColourClass), - (GtkClassInitFunc)filter_colour_class_init, - (GtkObjectInitFunc)filter_colour_init, - (GtkArgSetFunc)NULL, - (GtkArgGetFunc)NULL - }; - - type = gtk_type_unique(filter_element_get_type (), &type_info); - } - - return type; -} - -static void -filter_colour_class_init (FilterColourClass *class) -{ - GtkObjectClass *object_class; - FilterElementClass *filter_element = (FilterElementClass *)class; - - object_class = (GtkObjectClass *)class; - parent_class = gtk_type_class(filter_element_get_type ()); - - object_class->finalize = filter_colour_finalise; - - /* override methods */ - filter_element->xml_create = xml_create; - filter_element->xml_encode = xml_encode; - filter_element->xml_decode = xml_decode; - filter_element->get_widget = get_widget; - filter_element->build_code = build_code; - filter_element->format_sexp = format_sexp; - - /* signals */ - - gtk_object_class_add_signals(object_class, signals, LAST_SIGNAL); -} - -static void -filter_colour_init (FilterColour *o) -{ - o->priv = g_malloc0(sizeof(*o->priv)); -} - -static void -filter_colour_finalise(GtkObject *obj) -{ - FilterColour *o = (FilterColour *)obj; - - o = o; - - ((GtkObjectClass *)(parent_class))->finalize(obj); -} - -/** - * filter_colour_new: - * - * Create a new FilterColour object. - * - * Return value: A new #FilterColour object. - **/ -FilterColour * -filter_colour_new(void) -{ - FilterColour *o = (FilterColour *)gtk_type_new(filter_colour_get_type ()); - return o; -} - -static void xml_create(FilterElement *fe, xmlNodePtr node) -{ - /*FilterColour *fc = (FilterColour *)fe;*/ - - /* parent implementation */ - ((FilterElementClass *)(parent_class))->xml_create(fe, node); -} - -static xmlNodePtr xml_encode(FilterElement *fe) -{ - xmlNodePtr value; - FilterColour *fc = (FilterColour *)fe; - char hex[16]; - - d(printf("Encoding colour as xml\n")); - value = xmlNewNode(NULL, "value"); - xmlSetProp(value, "name", fe->name); - xmlSetProp(value, "type", "colour"); - - sprintf(hex, "%04x", fc->r); - xmlSetProp(value, "red", hex); - sprintf(hex, "%04x", fc->g); - xmlSetProp(value, "green", hex); - sprintf(hex, "%04x", fc->b); - xmlSetProp(value, "blue", hex); - sprintf(hex, "%04x", fc->a); - xmlSetProp(value, "alpha", hex); - - return value; -} - -static guint16 -get_value(xmlNodePtr node, char *name) -{ - unsigned int ret; - char *value; - - value = xmlGetProp(node, name); - sscanf(value, "%04x", &ret); - xmlFree(value); - return ret; -} - - -static int xml_decode(FilterElement *fe, xmlNodePtr node) -{ - FilterColour *fc = (FilterColour *)fe; - - fe->name = xmlGetProp(node, "name"); - fc->r = get_value(node, "red"); - fc->g = get_value(node, "green"); - fc->b = get_value(node, "blue"); - fc->a = get_value(node, "alpha"); - - return 0; -} - -static void set_colour(GnomeColorPicker *cp, guint r, guint g, guint b, guint a, FilterColour *fc) -{ - fc->r = r; - fc->g = g; - fc->b = b; - fc->a = a; -} - -static GtkWidget *get_widget(FilterElement *fe) -{ - FilterColour *fc = (FilterColour *)fe; - GnomeColorPicker *cp; - - cp = (GnomeColorPicker *)gnome_color_picker_new(); - gnome_color_picker_set_i16(cp, fc->r, fc->g, fc->b, fc->a); - gtk_widget_show((GtkWidget *)cp); - gtk_signal_connect((GtkObject *)cp, "color_set", set_colour, fe); - return (GtkWidget *)cp; -} - -static void build_code(FilterElement *fe, GString *out, struct _FilterPart *ff) -{ - return; -} - -static void format_sexp(FilterElement *fe, GString *out) -{ - char *str; - FilterColour *fc = (FilterColour *)fe; - - str =g_strdup_printf("rgb:%04x/%04x/%04x", fc->r, fc->g, fc->b); - e_sexp_encode_string(out, str); - g_free(str); -} diff --git a/filter/filter-colour.h b/filter/filter-colour.h deleted file mode 100644 index 3526dfcfda..0000000000 --- a/filter/filter-colour.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef _FILTER_COLOUR_H -#define _FILTER_COLOUR_H - -#include -#include "filter-element.h" - -#define FILTER_COLOUR(obj) GTK_CHECK_CAST (obj, filter_colour_get_type (), FilterColour) -#define FILTER_COLOUR_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, filter_colour_get_type (), FilterColourClass) -#define IS_FILTER_COLOUR(obj) GTK_CHECK_TYPE (obj, filter_colour_get_type ()) - -typedef struct _FilterColour FilterColour; -typedef struct _FilterColourClass FilterColourClass; - -struct _FilterColour { - FilterElement parent; - struct _FilterColourPrivate *priv; - - guint16 r,g,b,a; -}; - -struct _FilterColourClass { - FilterElementClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - -guint filter_colour_get_type (void); -FilterColour *filter_colour_new (void); - -/* methods */ - -#endif /* ! _FILTER_COLOUR_H */ - diff --git a/filter/filter-context.c b/filter/filter-context.c deleted file mode 100644 index c31eba205a..0000000000 --- a/filter/filter-context.c +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include - -#include "filter-context.h" -#include "filter-filter.h" - -#define d(x) - -static void filter_context_class_init (FilterContextClass *class); -static void filter_context_init (FilterContext *gspaper); -static void filter_context_finalise (GtkObject *obj); - -#define _PRIVATE(x) (((FilterContext *)(x))->priv) - -struct _FilterContextPrivate { -}; - -static RuleContextClass *parent_class; - -enum { - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -guint -filter_context_get_type (void) -{ - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "FilterContext", - sizeof(FilterContext), - sizeof(FilterContextClass), - (GtkClassInitFunc)filter_context_class_init, - (GtkObjectInitFunc)filter_context_init, - (GtkArgSetFunc)NULL, - (GtkArgGetFunc)NULL - }; - - type = gtk_type_unique(rule_context_get_type (), &type_info); - } - - return type; -} - -static void -filter_context_class_init (FilterContextClass *class) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *)class; - parent_class = gtk_type_class(rule_context_get_type ()); - - object_class->finalize = filter_context_finalise; - /* override methods */ - - /* signals */ - - gtk_object_class_add_signals(object_class, signals, LAST_SIGNAL); -} - -static void -filter_context_init (FilterContext *o) -{ - o->priv = g_malloc0(sizeof(*o->priv)); - - rule_context_add_part_set((RuleContext *)o, "partset", filter_part_get_type(), - rule_context_add_part, rule_context_next_part); - rule_context_add_part_set((RuleContext *)o, "actionset", filter_part_get_type(), - (RCPartFunc)filter_context_add_action, - (RCNextPartFunc)filter_context_next_action); - - rule_context_add_rule_set((RuleContext *)o, "ruleset", filter_filter_get_type(), - (RCRuleFunc)rule_context_add_rule, rule_context_next_rule); -} - -static void -filter_context_finalise(GtkObject *obj) -{ - FilterContext *o = (FilterContext *)obj; - - o = o; - - ((GtkObjectClass *)(parent_class))->finalize(obj); -} - -/** - * filter_context_new: - * - * Create a new FilterContext object. - * - * Return value: A new #FilterContext object. - **/ -FilterContext * -filter_context_new(void) -{ - FilterContext *o = (FilterContext *)gtk_type_new(filter_context_get_type ()); - return o; -} - -void filter_context_add_action(FilterContext *f, FilterPart *action) -{ - d(printf("find action : ")); - f->actions = g_list_append(f->actions, action); -} - -FilterPart *filter_context_find_action(FilterContext *f, const char *name) -{ - d(printf("find action : ")); - return filter_part_find_list(f->actions, name); -} - -FilterPart *filter_context_create_action(FilterContext *f, const char *name) -{ - FilterPart *part; - - part = filter_context_find_action(f, name); - if (part) - part = filter_part_clone(part); - return part; -} - -FilterPart *filter_context_next_action(FilterContext *f, FilterPart *last) -{ - return filter_part_next_list(f->actions, last); -} diff --git a/filter/filter-context.h b/filter/filter-context.h deleted file mode 100644 index 1fa0b80af7..0000000000 --- a/filter/filter-context.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef _FILTER_CONTEXT_H -#define _FILTER_CONTEXT_H - -#include -#include "rule-context.h" - -#define FILTER_CONTEXT(obj) GTK_CHECK_CAST (obj, filter_context_get_type (), FilterContext) -#define FILTER_CONTEXT_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, filter_context_get_type (), FilterContextClass) -#define IS_FILTER_CONTEXT(obj) GTK_CHECK_TYPE (obj, filter_context_get_type ()) - -typedef struct _FilterContext FilterContext; -typedef struct _FilterContextClass FilterContextClass; - -struct _FilterContext { - RuleContext parent; - struct _FilterContextPrivate *priv; - - GList *actions; -}; - -struct _FilterContextClass { - RuleContextClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - -guint filter_context_get_type (void); -FilterContext *filter_context_new (void); - -/* methods */ -void filter_context_add_action(FilterContext *f, FilterPart *action); -FilterPart *filter_context_find_action(FilterContext *f, const char *name); -FilterPart *filter_context_create_action(FilterContext *f, const char *name); -FilterPart *filter_context_next_action(FilterContext *f, FilterPart *last); - -#endif /* ! _FILTER_CONTEXT_H */ - diff --git a/filter/filter-datespec.c b/filter/filter-datespec.c deleted file mode 100644 index c087401ee2..0000000000 --- a/filter/filter-datespec.c +++ /dev/null @@ -1,703 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include - -#include "filter-datespec.h" -#include "e-util/e-sexp.h" - -#define d(x) x - -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 *fds); -static void format_sexp(FilterElement *, GString *); -static void filter_datespec_class_init (FilterDatespecClass *class); -static void filter_datespec_init (FilterDatespec *gspaper); -static void filter_datespec_finalise (GtkObject *obj); - -static void make_span_editor (FilterDatespec *fds); -static void adj_value_changed (GtkAdjustment *adj, gpointer user_data); -static gchar *describe_button (FilterDatespec *fds); -static gchar *stringify_agoness (FilterDatespec *fds); -static void set_adjustments (FilterDatespec *fds); - -static void cal_day_selected (GtkCalendar *cal, gpointer user_data); -static void cal_day_selected_double_click (GtkCalendar *cal, gpointer user_data); - -#define PRIV(x) (((FilterDatespec *)(x))->priv) - -typedef struct _timespan -{ - guint32 seconds; - const gchar *singular; - const gchar *plural; - gfloat max; -} timespan; - -static const timespan timespans[] = { - { 31557600, N_("year"), N_("years"), 1000.0 }, - { 2419200, N_("month"), N_("months"), 12.0 }, - { 604800, N_("week"), N_("weeks"), 52.0 }, - { 86400, N_("day"), N_("days"), 31.0 }, - { 3600, N_("hour"), N_("hours"), 23.0 }, - { 60, N_("minute"), N_("minutes"), 59.0 }, - { 1, N_("second"), N_("seconds"), 59.0 } -}; - -#define N_TIMECHUNKS 3 - -static const guint timechunks[N_TIMECHUNKS] = { 2, 2, 3 }; -#define MAX_CHUNK 3 - -#define N_TIMESPANS (sizeof (timespans) / sizeof (timespans[0])) - -struct _FilterDatespecPrivate { - GnomeDialog *gd; - GtkWidget *descriptive_label; - GtkWidget *cur_extra_widget; - FilterDatespec_type selected_type; - - GtkWidget *date_chooser; - GtkWidget *span_chooser; - gboolean double_click; - GtkWidget **spinbuttons; -}; - -static FilterElementClass *parent_class; - -guint -filter_datespec_get_type (void) -{ - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "FilterDatespec", - sizeof(FilterDatespec), - sizeof(FilterDatespecClass), - (GtkClassInitFunc)filter_datespec_class_init, - (GtkObjectInitFunc)filter_datespec_init, - (GtkArgSetFunc)NULL, - (GtkArgGetFunc)NULL - }; - - type = gtk_type_unique(filter_element_get_type (), &type_info); - } - - return type; -} - -static void -filter_datespec_class_init (FilterDatespecClass *class) -{ - GtkObjectClass *object_class; - FilterElementClass *filter_element = (FilterElementClass *)class; - - object_class = (GtkObjectClass *)class; - parent_class = gtk_type_class(filter_element_get_type ()); - - object_class->finalize = filter_datespec_finalise; - - /* override methods */ - filter_element->xml_create = xml_create; - filter_element->xml_encode = xml_encode; - filter_element->xml_decode = xml_decode; - filter_element->get_widget = get_widget; - filter_element->build_code = build_code; - filter_element->format_sexp = format_sexp; -} - -static void -filter_datespec_init (FilterDatespec *o) -{ - o->priv = g_malloc0(sizeof(*o->priv)); - o->type = FDST_UNKNOWN; - PRIV(o)->selected_type = FDST_UNKNOWN; - PRIV(o)->spinbuttons = g_new (GtkWidget *, N_TIMESPANS ); -} - -static void -filter_datespec_finalise(GtkObject *obj) -{ - FilterDatespec *o = (FilterDatespec *)obj; - - if (o->priv) { - g_free (PRIV(o)->spinbuttons); - g_free (o->priv); - } - - ((GtkObjectClass *)(parent_class))->finalize(obj); -} - -/** - * filter_datespec_new: - * - * Create a new FilterDatespec object. - * - * Return value: A new #FilterDatespec object. - **/ -FilterDatespec * -filter_datespec_new(void) -{ - FilterDatespec *o = (FilterDatespec *)gtk_type_new(filter_datespec_get_type ()); - return o; -} - -static void xml_create(FilterElement *fe, xmlNodePtr node) -{ - /* parent implementation */ - ((FilterElementClass *)(parent_class))->xml_create(fe, node); -} - -static xmlNodePtr xml_encode(FilterElement *fe) -{ - xmlNodePtr value, work; - FilterDatespec *fds = (FilterDatespec *)fe; - gchar str[32]; - - d(printf("Encoding datespec as xml\n")); - - value = xmlNewNode(NULL, "value"); - xmlSetProp(value, "name", fe->name); - xmlSetProp(value, "type", "datespec"); - - work = xmlNewChild(value, NULL, "datespec", NULL); - sprintf (str, "%d", fds->type); - xmlSetProp(work, "type", str); - sprintf (str, "%d", (int)fds->value); - xmlSetProp(work, "value", str); - - return value; -} - -static int xml_decode(FilterElement *fe, xmlNodePtr node) -{ - FilterDatespec *fds = (FilterDatespec *)fe; - xmlNodePtr n; - gchar *val; - - d(printf("Decoding datespec from xml %p\n", fe)); - - fe->name = xmlGetProp(node, "name"); - - n = node->childs; - while (n) { - if (!strcmp(n->name, "datespec")) { - val = xmlGetProp(n, "type"); - fds->type = atoi (val); - g_free (val); - val = xmlGetProp(n, "value"); - fds->value = atoi (val); - g_free (val); - break; - } - n = n->next; - } - return 0; -} - -static void activate_now(GtkMenuItem *item, FilterDatespec *fds) -{ - if (PRIV(fds)->cur_extra_widget) { - gtk_container_remove (GTK_CONTAINER (PRIV(fds)->gd->vbox), - PRIV(fds)->cur_extra_widget); - PRIV (fds)->cur_extra_widget = NULL; - } - - - gtk_label_set_text (GTK_LABEL (PRIV(fds)->descriptive_label), - _("The message's date will be compared against\n" - "whatever the time is when the filter is run\n" - "or vfolder is opened.")); - - PRIV(fds)->selected_type = FDST_NOW; -} - -static void activate_specified(GtkMenuItem *item, FilterDatespec *fds) -{ - struct tm *seltime; - - /* Remove other widget if it exists */ - - if (PRIV(fds)->cur_extra_widget) { - gtk_container_remove (GTK_CONTAINER (PRIV(fds)->gd->vbox), - PRIV(fds)->cur_extra_widget); - PRIV (fds)->cur_extra_widget = NULL; - } - - /* Set description */ - - gtk_label_set_text (GTK_LABEL (PRIV(fds)->descriptive_label), - _("The message's date will be compared against\n" - "the time that you specify here.")); - - /* Reset if going from one type to another */ - if (PRIV(fds)->selected_type != FDST_SPECIFIED) - fds->value = 0; - - PRIV(fds)->selected_type = FDST_SPECIFIED; - - /* Set the calendar's time */ - - if (fds->value > 0) { - /* gmtime? */ - seltime = localtime (&(fds->value)); - - gtk_calendar_select_month (GTK_CALENDAR (PRIV(fds)->date_chooser), - seltime->tm_mon, - seltime->tm_year + 1900); - gtk_calendar_select_day (GTK_CALENDAR (PRIV(fds)->date_chooser), - seltime->tm_mday); - /* free seltime?? */ - } - - gtk_box_pack_start (GTK_BOX (PRIV(fds)->gd->vbox), - PRIV(fds)->date_chooser, - TRUE, TRUE, 3); - gtk_widget_show (PRIV(fds)->date_chooser); - PRIV(fds)->cur_extra_widget = PRIV(fds)->date_chooser; -} - -static void activate_x_ago(GtkMenuItem *item, FilterDatespec *fds) -{ - if (PRIV(fds)->cur_extra_widget) { - gtk_container_remove (GTK_CONTAINER (PRIV(fds)->gd->vbox), - PRIV(fds)->cur_extra_widget); - PRIV (fds)->cur_extra_widget = NULL; - } - - gtk_label_set_text (GTK_LABEL (PRIV(fds)->descriptive_label), - _("The message's date will be compared against\n" - "a time relative to when the filter is run;\n" - "\"a week ago\", for example.")); - - /* Reset if going from one type to another */ - if (PRIV(fds)->selected_type != FDST_X_AGO) - fds->value = 0; - - PRIV(fds)->selected_type = FDST_X_AGO; - - if (fds->value > 0) - set_adjustments (fds); - - gtk_box_pack_start (GTK_BOX (PRIV(fds)->gd->vbox), - PRIV(fds)->span_chooser, - TRUE, TRUE, 3); - gtk_widget_show (PRIV(fds)->span_chooser); - PRIV(fds)->cur_extra_widget = PRIV(fds)->span_chooser; - -} - -typedef void (*my_menu_callback) (GtkMenuItem *, FilterDatespec *); - -static void button_clicked(GtkButton *button, FilterDatespec *fds) -{ - GnomeDialog *gd; - GtkWidget *box; - GtkWidget *label; - GtkWidget *menu; - GtkWidget *selectomatic; - GtkWidget *sep; - int i; - gchar *desc; - - /* keep in sync with FilterDatespec_type! */ - const char *items[] = { N_("the current time"), N_("a time you specify"), - N_("a time relative to the current time"), NULL }; - const my_menu_callback callbacks[] - = { activate_now, activate_specified, activate_x_ago }; - - PRIV(fds)->descriptive_label = gtk_label_new(""); - PRIV(fds)->cur_extra_widget = NULL; - PRIV(fds)->double_click = FALSE; - - /* The calendar */ - - PRIV(fds)->date_chooser = gtk_calendar_new (); - gtk_object_ref (GTK_OBJECT (PRIV(fds)->date_chooser)); - gtk_signal_connect (GTK_OBJECT (PRIV(fds)->date_chooser), "day_selected", - cal_day_selected, fds); - gtk_signal_connect (GTK_OBJECT (PRIV(fds)->date_chooser), "day_selected_double_click", - cal_day_selected_double_click, fds); - - /* The span editor thingie */ - - make_span_editor (fds); - gtk_object_ref (GTK_OBJECT (PRIV(fds)->span_chooser)); - - /* The dialog */ - - gd = (GnomeDialog *) gnome_dialog_new ("Select a time to compare against", - GNOME_STOCK_BUTTON_OK, - GNOME_STOCK_BUTTON_CANCEL, - NULL); - PRIV(fds)->gd = gd; - - /* The menu */ - - menu = gtk_menu_new (); - - for (i = 0; items[i]; i++) { - GtkWidget *item; - - item = gtk_menu_item_new_with_label (gettext (items[i])); - gtk_signal_connect (GTK_OBJECT (item), "activate", - callbacks[i], fds); - gtk_menu_append (GTK_MENU (menu), item); - gtk_widget_show (item); - } - - gtk_widget_show (menu); - - /* The selector */ - - selectomatic = gtk_option_menu_new(); - gtk_option_menu_set_menu (GTK_OPTION_MENU (selectomatic), GTK_WIDGET (menu)); - if (fds->type != FDST_UNKNOWN) - /* Keep in sync with FilterDatespec_type! */ - gtk_option_menu_set_history (GTK_OPTION_MENU (selectomatic), fds->type); - - gtk_widget_show ((GtkWidget *)selectomatic); - - /* The label */ - - label = gtk_label_new (_("Compare against")); - gtk_widget_show (label); - - /* The hbox */ - - box = gtk_hbox_new (FALSE, 3); - gtk_box_pack_start (GTK_BOX (box), label, - TRUE, TRUE, 2); - gtk_box_pack_start (GTK_BOX (box), selectomatic, - TRUE, TRUE, 2); - gtk_widget_show (box); - gtk_box_pack_start ((GtkBox *)gd->vbox, (GtkWidget *)box, TRUE, TRUE, 3); - - /* The separator */ - - sep = gtk_hseparator_new (); - gtk_widget_show (sep); - gtk_box_pack_start (GTK_BOX (gd->vbox), sep, TRUE, TRUE, 3); - - /* The descriptive label */ - - gtk_box_pack_start (GTK_BOX (gd->vbox), PRIV(fds)->descriptive_label, TRUE, TRUE, 3); - gtk_misc_set_alignment (GTK_MISC (PRIV(fds)->descriptive_label), 0.5, 0.5); - gtk_widget_show (PRIV(fds)->descriptive_label); - - /* Set up the current view */ - - if (fds->type == FDST_UNKNOWN) - fds->type = FDST_NOW; - - (callbacks[fds->type]) (NULL, fds); - - /* go go gadget gnomedialog! */ - - switch (gnome_dialog_run_and_close(gd)) { - case -1: /*wm close*/ - if (PRIV(fds)->double_click == FALSE) - break; - /* else fall */ - case 0: - fds->type = PRIV(fds)->selected_type; - - PRIV(fds)->descriptive_label = NULL; - - desc = describe_button (fds); - gtk_label_set_text (GTK_LABEL (GTK_BIN (button)->child), desc); - g_free (desc); - /* falllllll */ - case 1: - /* cancel */ - break; - } - - gtk_widget_destroy (PRIV(fds)->date_chooser); - gtk_widget_destroy (PRIV(fds)->span_chooser); -} - -static GtkWidget * -get_widget(FilterElement *fe) -{ - FilterDatespec *fds = (FilterDatespec *)fe; - GtkWidget *button; - GtkWidget *label; - gchar *desc; - - desc = describe_button (fds); - label = gtk_label_new (desc); - gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0.5); - g_free (desc); - - button = gtk_button_new(); - gtk_container_add (GTK_CONTAINER (button), label); - gtk_signal_connect(GTK_OBJECT (button), "clicked", button_clicked, fds); - - gtk_widget_show(button); - gtk_widget_show(label); - return button; -} - -static void -build_code(FilterElement *fe, GString *out, struct _FilterPart *fp) -{ - return; -} - -static void -format_sexp(FilterElement *fe, GString *out) -{ - FilterDatespec *fds = (FilterDatespec *)fe; - - switch (fds->type) { - case FDST_UNKNOWN: - g_warning ("user hasn't selected a datespec yet!"); - /* fall through */ - case FDST_NOW: - g_string_append (out, "(get-current-date)"); - break; - case FDST_SPECIFIED: - g_string_sprintfa (out, "%d", (int) fds->value); - break; - case FDST_X_AGO: - g_string_sprintfa (out, "(- (get-current-date) %d)", (int) fds->value); - break; - } -} - -static gchar * -stringify_agoness (FilterDatespec *fds) -{ - time_t val; - GString *str; - gchar *ret; - - str = g_string_new(""); - val = fds->value; - - if (val == 0) { - g_string_append (str, _("now")); - } else { - int where; - - where = 0; - - while (val) { - int count; - - count = 0; - - while (timespans[where].seconds <= val) { - count++; - val -= timespans[where].seconds; - } - - if (count != 0 ) { - if (count > 1) - g_string_sprintfa (str, "%d %s", (int) count, gettext (timespans[where].plural)); - else - g_string_sprintfa (str, "%d %s", (int) count, gettext (timespans[where].singular)); - - if (val) - g_string_append (str, ", "); - } - - where++; - } - - g_string_append (str, " ago"); - } - - ret = str->str; - g_string_free (str, FALSE); - return ret; -} - -static void -make_span_editor (FilterDatespec *fds) -{ - int i; - int chunk; - int delta; - GtkWidget *table; - - /*PRIV(fds)->span_chooser = gtk_vbox_new (TRUE, 3);*/ - table = gtk_table_new (N_TIMECHUNKS, MAX_CHUNK * 2, FALSE); - - i = 0; - - for (chunk = 0; chunk < N_TIMECHUNKS; chunk++ ) { - /*GtkWidget *hbox;*/ - - /*hbox = gtk_hbox_new (FALSE, 1);*/ - /*gtk_box_pack_start (GTK_BOX (PRIV(fds)->span_chooser), - * hbox, TRUE, TRUE, 1); - */ - /*gtk_table_attach (GTK_TABLE (PRIV(fds)->span_chooser), - * hbox, - * 0, 1, chunk, chunk + 1, - * 0, GTK_EXPAND | GTK_FILL, - * 3, 3); - *gtk_widget_show (hbox); - */ - - for (delta = 0; delta < timechunks[chunk]; delta++, i++ ) { - gchar *text; - GtkObject *adj; - GtkWidget *sb; - GtkWidget *label; - - adj = gtk_adjustment_new (0.0, 0.0, - timespans[i].max, - 1.0, 10.0, 0.0); - - sb = gtk_spin_button_new (GTK_ADJUSTMENT (adj), - 0, 0); - - /*gtk_box_pack_start (GTK_BOX (hbox), sb, FALSE, FALSE, 1);*/ - gtk_table_attach (GTK_TABLE (table), sb, - delta * 2, delta * 2 + 1, - chunk, chunk + 1, - 0, GTK_EXPAND | GTK_FILL, - 2, 4); - PRIV(fds)->spinbuttons[i] = sb; - - gtk_widget_show (GTK_WIDGET (sb)); - - if (delta + 1 < timechunks[chunk]) - text = g_strdup_printf ("%s, ", gettext (timespans[i].plural)); - else - text = g_strdup_printf ("%s ago", gettext (timespans[i].plural)); - - label = gtk_label_new (text); - g_free (text); - - /*gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 3);*/ - gtk_table_attach (GTK_TABLE (table), label, - delta * 2 + 1, (delta + 1) * 2, - chunk, chunk + 1, - 0, GTK_EXPAND | GTK_FILL, - 2, 4); - gtk_widget_show (label); - - gtk_signal_connect (adj, "value_changed", - adj_value_changed, fds); - } - } - - PRIV(fds)->span_chooser = table; -} - -static void -adj_value_changed (GtkAdjustment *adj, gpointer user_data) -{ - FilterDatespec *fds = (FilterDatespec *) user_data; - int i; - - fds->value = 0; - - for (i = 0; i < N_TIMESPANS; i++) - fds->value += timespans[i].seconds * - (gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (PRIV(fds)->spinbuttons[i]))); -} - -static void -set_adjustments (FilterDatespec *fds) -{ - time_t val; - int where; - - val = fds->value; - where = 0; - - while (val) { - int count; - - count = 0; - - while (timespans[where].seconds <= val) { - count++; - val -= timespans[where].seconds; - } - - gtk_spin_button_set_value (GTK_SPIN_BUTTON (PRIV(fds)->spinbuttons[where]), - (gfloat) count); - where++; - } -} - -static gchar * -describe_button (FilterDatespec *fds) -{ - gchar *desc = NULL; - - switch (fds->type) { - case FDST_UNKNOWN: - desc = g_strdup (_("")); - break; - case FDST_NOW: - desc = g_strdup (_("now")); - break; - case FDST_SPECIFIED: - desc = g_strdup (ctime (&(fds->value))); - break; - case FDST_X_AGO: - desc = stringify_agoness (fds); - break; - } - - return desc; -} - -static void -cal_day_selected (GtkCalendar *cal, gpointer user_data) -{ - FilterDatespec *fds = (FilterDatespec *)user_data; - extern int daylight; - struct tm seltime; - - seltime.tm_sec = 0; - seltime.tm_min = 0; - seltime.tm_hour = 0; - seltime.tm_mday = cal->selected_day; - seltime.tm_mon = cal->month; - seltime.tm_year = cal->year - 1900; - seltime.tm_isdst = daylight; - - fds->value = mktime (&seltime); -} - -static void -cal_day_selected_double_click (GtkCalendar *cal, gpointer user_data) -{ - FilterDatespec *fds = (FilterDatespec *)user_data; - - cal_day_selected (cal, user_data); - PRIV(fds)->double_click = TRUE; - gnome_dialog_close (PRIV(fds)->gd); -} diff --git a/filter/filter-datespec.h b/filter/filter-datespec.h deleted file mode 100644 index 1292a94e36..0000000000 --- a/filter/filter-datespec.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef _FILTER_DATESPEC_H -#define _FILTER_DATESPEC_H - -#include -#include "filter-element.h" - -#define FILTER_DATESPEC(obj) GTK_CHECK_CAST (obj, filter_datespec_get_type (), FilterDatespec) -#define FILTER_DATESPEC_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, filter_datespec_get_type (), FilterDatespecClass) -#define IS_FILTER_DATESPEC(obj) GTK_CHECK_TYPE (obj, filter_datespec_get_type ()) - -typedef struct _FilterDatespec FilterDatespec; -typedef struct _FilterDatespecClass FilterDatespecClass; - -typedef enum _FilterDatespec_type { FDST_NOW, FDST_SPECIFIED, FDST_X_AGO, FDST_UNKNOWN } FilterDatespec_type; - -struct _FilterDatespec { - FilterElement parent; - struct _FilterDatespecPrivate *priv; - - FilterDatespec_type type; - - /* either a timespan, an absolute time, or 0 - * depending on type -- the above mapping to - * (X_AGO, SPECIFIED, NOW) - */ - - time_t value; -}; - -struct _FilterDatespecClass { - FilterElementClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - -guint filter_datespec_get_type (void); -FilterDatespec *filter_datespec_new (void); - -/* methods */ - -#endif /* ! _FILTER_DATESPEC_H */ - diff --git a/filter/filter-driver.c b/filter/filter-driver.c deleted file mode 100644 index e3e1c7df5e..0000000000 --- a/filter/filter-driver.c +++ /dev/null @@ -1,636 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Michael Zucchi - * Jeffrey Stedfast - * - * 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 Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include "filter-driver.h" - -#include -#include -#include -#include - -#include -#include - -#include -#include "mail/mail-tools.h" /*mail_tool_camel_lock_up*/ -#include "filter-context.h" -#include "filter-filter.h" -#include "e-util/e-sexp.h" - -#define d(x) - -/* mail-thread filter input data type */ -typedef struct { - FilterDriver *driver; - CamelFolder *source; - CamelFolder *inbox; - enum _filter_source_t sourcetype; - gboolean self_destruct; - gpointer unhook_func; - gpointer unhook_data; -} filter_mail_input_t; - -/* mail-thread filter functions */ -static gchar *describe_filter_mail (gpointer in_data, gboolean gerund); -static void setup_filter_mail (gpointer in_data, gpointer op_data, CamelException *ex); -static void do_filter_mail (gpointer in_data, gpointer op_data, CamelException *ex); -static void cleanup_filter_mail (gpointer in_data, gpointer op_data, CamelException *ex); - - -struct _FilterDriverPrivate { - GHashTable *globals; /* global variables */ - - FilterContext *context; - - /* for callback */ - FilterGetFolderFunc get_folder; - void *data; - - /* run-time data */ - GHashTable *folders; /* currently open folders */ - GPtrArray *matches; /* all messages which match current rule */ - GHashTable *terminated; /* messages for which processing is terminated */ - GHashTable *processed; /* all messages that were processed in some way */ - GHashTable *copies; /* lists of folders to copy messages to */ - - CamelFolder *source; /* temporary input folder */ - - GList *searches; /* search results */ - - CamelException *ex; - - /* evaluator */ - ESExp *eval; -}; - -#define _PRIVATE(o) (((FilterDriver *)(o))->priv) - -static void filter_driver_class_init (FilterDriverClass *klass); -static void filter_driver_init (FilterDriver *obj); -static void filter_driver_finalise (GtkObject *obj); - -static CamelFolder *open_folder (FilterDriver *d, const char *folder_url); -static int close_folders (FilterDriver *d); - -static ESExpResult *do_delete(struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver *); -static ESExpResult *mark_forward(struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver *); -static ESExpResult *mark_copy(struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver *); -static ESExpResult *do_stop(struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver *); -static ESExpResult *do_colour(struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver *); - -static struct { - char *name; - ESExpFunc *func; - int type; /* set to 1 if a function can perform shortcut evaluation, or - doesn't execute everything, 0 otherwise */ -} symbols[] = { - { "delete", (ESExpFunc *)do_delete, 0 }, - { "forward-to", (ESExpFunc *)mark_forward, 0 }, - { "copy-to", (ESExpFunc *)mark_copy, 0 }, - { "stop", (ESExpFunc *)do_stop, 0 }, - { "set-colour", (ESExpFunc *)do_colour, 0 }, -}; - -static GtkObjectClass *filter_driver_parent; - -enum SIGNALS { - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -guint -filter_driver_get_type (void) -{ - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "FilterDriver", - sizeof (FilterDriver), - sizeof (FilterDriverClass), - (GtkClassInitFunc) filter_driver_class_init, - (GtkObjectInitFunc) filter_driver_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - type = gtk_type_unique (gtk_object_get_type (), &type_info); - } - - return type; -} - -static void -filter_driver_class_init (FilterDriverClass *klass) -{ - GtkObjectClass *object_class = (GtkObjectClass *) klass; - - filter_driver_parent = gtk_type_class (gtk_object_get_type ()); - - object_class->finalize = filter_driver_finalise; - - gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); -} - -static void -filter_driver_init (FilterDriver *obj) -{ - struct _FilterDriverPrivate *p; - int i; - - p = _PRIVATE (obj) = g_malloc0 (sizeof (*p)); - - p->eval = e_sexp_new (); - /* Load in builtin symbols */ - for (i = 0; i < sizeof (symbols) / sizeof (symbols[0]); i++) { - if (symbols[i].type == 1) { - e_sexp_add_ifunction (p->eval, 0, symbols[i].name, (ESExpIFunc *)symbols[i].func, obj); - } else { - e_sexp_add_function (p->eval, 0, symbols[i].name, symbols[i].func, obj); - } - } - - p->globals = g_hash_table_new (g_str_hash, g_str_equal); - - /* Will get set in filter_driver_run */ - p->ex = NULL; -} - -static void -free_hash_strings (void *key, void *value, void *data) -{ - g_free (key); - g_free (value); -} - -static void -filter_driver_finalise (GtkObject *obj) -{ - FilterDriver *d = (FilterDriver *) obj; - struct _FilterDriverPrivate *p = _PRIVATE (d); - - g_hash_table_foreach (p->globals, free_hash_strings, d); - g_hash_table_destroy (p->globals); - - gtk_object_unref (GTK_OBJECT (p->eval)); - - /*Was set to the mail_operation_queue exception, - * not our responsibility to free it.*/ - /*camel_exception_free (p->ex);*/ - - g_free (p); - - ((GtkObjectClass *)(filter_driver_parent))->finalize (GTK_OBJECT (obj)); -} - -/** - * filter_driver_new: - * @system: path to system rules - * @user: path to user rules - * @get_folder: function to call to fetch folders - * - * Create a new FilterDriver object. - * - * Return value: A new FilterDriver widget. - **/ -FilterDriver * -filter_driver_new (FilterContext *context, FilterGetFolderFunc get_folder, void *data) -{ - FilterDriver *new; - struct _FilterDriverPrivate *p; - - new = FILTER_DRIVER (gtk_type_new (filter_driver_get_type ())); - p = _PRIVATE(new); - - p->get_folder = get_folder; - p->data = data; - p->context = context; - gtk_object_ref((GtkObject *)context); - - return new; -} - - -#if 0 -void filter_driver_set_global(FilterDriver *d, const char *name, const char *value) -{ - struct _FilterDriverPrivate *p = _PRIVATE (d); - char *oldkey, *oldvalue; - - if (g_hash_table_lookup_extended (p->globals, name, (void *)&oldkey, (void *)&oldvalue)) { - g_free (oldvalue); - g_hash_table_insert (p->globals, oldkey, g_strdup (value)); - } else { - g_hash_table_insert (p->globals, g_strdup (name), g_strdup (value)); - } -} -#endif - -static ESExpResult * -do_delete (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver *driver) -{ - struct _FilterDriverPrivate *p = _PRIVATE (driver); - char *uid; - int i; - - printf ("doing delete\n"); - for (i = 0; i < p->matches->len; i++) { - uid = p->matches->pdata[i]; - printf (" %s\n", uid); - - mail_tool_camel_lock_up (); - camel_folder_delete_message (p->source, uid); - mail_tool_camel_lock_down (); - } - return NULL; -} - -static ESExpResult * -mark_forward (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver *driver) -{ - struct _FilterDriverPrivate *p = _PRIVATE (driver); - int i; - - printf ("marking the following messages for forwarding:\n"); - for (i = 0; i < p->matches->len; i++) { - printf (" %s\n", (char *)p->matches->pdata[i]); - } - return NULL; -} - -static ESExpResult * -mark_copy (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver *driver) -{ - struct _FilterDriverPrivate *p = _PRIVATE (driver); - int i, m; - char *uid; - - printf ("marking for copy\n"); - for (i = 0; i < argc; i++) { - if (argv[i]->type == ESEXP_RES_STRING) { - char *folder = argv[i]->value.string; - CamelFolder *outbox; - - outbox = open_folder (driver, folder); - if (outbox == NULL) - continue; - - for (m = 0; m < p->matches->len; m++) { - gpointer old_key, old_value; - - uid = p->matches->pdata[m]; - printf (" %s\n", uid); - - if (g_hash_table_lookup_extended (p->copies, uid, &old_key, &old_value)) - g_hash_table_insert (p->copies, old_key, g_list_prepend (old_value, outbox)); - else - g_hash_table_insert (p->copies, uid, g_list_append (NULL, outbox)); - } - } - } - - return NULL; -} - -static ESExpResult * -do_stop (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver *driver) -{ - struct _FilterDriverPrivate *p = _PRIVATE (driver); - char *uid; - int i; - - printf ("doing stop on the following messages:\n"); - for (i = 0; i < p->matches->len; i++) { - uid = p->matches->pdata[i]; - printf (" %s\n", uid); - g_hash_table_insert (p->terminated, uid, GINT_TO_POINTER (1)); - } - return NULL; -} - -static ESExpResult * -do_colour(struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver *d) -{ - int i; - char *uid; - struct _FilterDriverPrivate *p = _PRIVATE(d); - - if (argc>0 && argv[0]->type == ESEXP_RES_STRING) { - for (i=0 ; imatches->len; i++) { - uid = p->matches->pdata[i]; - camel_folder_set_message_user_tag(p->source, uid, "colour", argv[0]->value.string); - } - } - - return NULL; -} - -static CamelFolder * -open_folder (FilterDriver *driver, const char *folder_url) -{ - CamelFolder *camelfolder; - struct _FilterDriverPrivate *p = _PRIVATE (driver); - - /* we have a lookup table of currently open folders */ - camelfolder = g_hash_table_lookup (p->folders, folder_url); - if (camelfolder) - return camelfolder; - - camelfolder = p->get_folder(driver, folder_url, p->data); - - if (camelfolder) { - g_hash_table_insert (p->folders, g_strdup (folder_url), camelfolder); - mail_tool_camel_lock_up (); - camel_folder_freeze (camelfolder); - mail_tool_camel_lock_down (); - } - - return camelfolder; -} - -static void -close_folder (void *key, void *value, void *data) -{ - CamelFolder *folder = value; - FilterDriver *driver = data; - struct _FilterDriverPrivate *p = _PRIVATE (driver); - - g_free (key); - mail_tool_camel_lock_up (); - camel_folder_sync (folder, FALSE, p->ex); - camel_folder_thaw (folder); - mail_tool_camel_lock_down (); - camel_object_unref (CAMEL_OBJECT (folder)); -} - -/* flush/close all folders */ -static int -close_folders (FilterDriver *driver) -{ - struct _FilterDriverPrivate *p = _PRIVATE (driver); - - g_hash_table_foreach (p->folders, close_folder, driver); - g_hash_table_destroy (p->folders); - p->folders = g_hash_table_new (g_str_hash, g_str_equal); - - /* FIXME: status from driver */ - return 0; -} - -#if 0 -static void -free_key (gpointer key, gpointer value, gpointer user_data) -{ - g_free (key); -} -#endif - -static const mail_operation_spec op_filter_mail = -{ - describe_filter_mail, - 0, - setup_filter_mail, - do_filter_mail, - cleanup_filter_mail -}; - -void -filter_driver_run (FilterDriver *d, CamelFolder *source, CamelFolder *inbox, - enum _filter_source_t sourcetype, - gboolean self_destruct, gpointer unhook_func, gpointer unhook_data) -{ - filter_mail_input_t *input; - - input = g_new (filter_mail_input_t, 1); - input->driver = d; - input->source = source; - input->inbox = inbox; - input->sourcetype = sourcetype; - input->self_destruct = self_destruct; - input->unhook_func = unhook_func; - input->unhook_data = unhook_data; - - mail_operation_queue (&op_filter_mail, input, TRUE); -} - -static gchar *describe_filter_mail (gpointer in_data, gboolean gerund) -{ - filter_mail_input_t *input = (filter_mail_input_t *) in_data; - - if (gerund) - return g_strdup_printf ("Filtering messages into \"%s\"", - mail_tool_get_folder_name (input->inbox)); - else - return g_strdup_printf ("Filter messages into \"%s\"", - mail_tool_get_folder_name (input->inbox)); -} - -static void -setup_filter_mail (gpointer in_data, gpointer op_data, CamelException *ex) -{ - filter_mail_input_t *input = (filter_mail_input_t *) in_data; - - if (!input->driver) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - "Bad filter driver passed to filter_mail"); - return; - } - - if (!CAMEL_IS_FOLDER (input->source)) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - "Bad source folder passed to filter_mail"); - return; - } - - if (!CAMEL_IS_FOLDER (input->inbox)) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - "Bad Inbox passed to filter_mail"); - return; - } - - camel_object_ref (CAMEL_OBJECT (input->source)); - camel_object_ref (CAMEL_OBJECT (input->inbox)); -} - -static void -do_filter_mail (gpointer in_data, gpointer op_data, CamelException *ex) -{ - filter_mail_input_t *input = (filter_mail_input_t *) in_data; - FilterDriver *d = input->driver; - CamelFolder *source = input->source; - CamelFolder *inbox = input->inbox; - struct _FilterDriverPrivate *p = _PRIVATE (d); - ESExpResult *r; - GString *s, *a; - GPtrArray *all; - char *uid; - int i; - FilterFilter *rule; - GList *l; - - /* FIXME: needs to check all failure cases */ - p->source = source; - - /* setup runtime data */ - p->folders = g_hash_table_new(g_str_hash, g_str_equal); - p->terminated = g_hash_table_new(g_str_hash, g_str_equal); - p->processed = g_hash_table_new(g_str_hash, g_str_equal); - p->copies = g_hash_table_new(g_str_hash, g_str_equal); - - mail_tool_camel_lock_up (); - camel_folder_freeze(inbox); - mail_tool_camel_lock_down (); - - s = g_string_new(""); - a = g_string_new(""); - - rule = NULL; - while ( (rule = (FilterFilter *)rule_context_next_rule((RuleContext *)p->context, (FilterRule *)rule)) ) { - - if (((FilterRule *)rule)->source != input->sourcetype) { - d(printf("skipping rule %s - wrong source type (%d %d)\n", ((FilterRule *)rule)->name, - ((FilterRule *)rule)->source, input->sourcetype)); - continue; - } - - g_string_truncate(s, 0); - g_string_truncate(a, 0); - - filter_rule_build_code((FilterRule *)rule, s); - filter_filter_build_action(rule, a); - - d(printf("applying rule %s\n action %s\n", s->str, a->str)); - - mail_tool_camel_lock_up (); - p->matches = camel_folder_search_by_expression (p->source, s->str, p->ex); - mail_tool_camel_lock_down (); - - /* remove uid's for which processing is complete ... */ - for (i = 0; i < p->matches->len; i++) { - uid = p->matches->pdata[i]; - - /* for all matching id's, so we can work out what to default */ - if (g_hash_table_lookup (p->processed, uid) == NULL) { - g_hash_table_insert (p->processed, uid, GINT_TO_POINTER (1)); - } - - if (g_hash_table_lookup (p->terminated, uid)) { - g_ptr_array_remove_index_fast (p->matches, i); - i--; - } - } - -#ifndef NO_WARNINGS -#warning "Must check expression parsed and executed properly?" -#endif - e_sexp_input_text(p->eval, a->str, strlen(a->str)); - e_sexp_parse(p->eval); - r = e_sexp_eval(p->eval); - e_sexp_result_free(r); - - p->searches = g_list_append(p->searches, p->matches); - } - - g_string_free(s, TRUE); - g_string_free(a, TRUE); - - /* Do any queued copies, and make sure everything is deleted from - * the source. If we have an inbox, anything that didn't get - * processed otherwise goes there. - */ - mail_tool_camel_lock_up (); - all = camel_folder_get_uids (p->source); - mail_tool_camel_lock_down (); - for (i = 0; i < all->len; i++) { - char *uid = all->pdata[i], *procuid; - GList *copies, *tmp; - CamelMimeMessage *mm; - const CamelMessageInfo *info; - - copies = g_hash_table_lookup (p->copies, uid); - procuid = g_hash_table_lookup (p->processed, uid); - - mail_tool_camel_lock_up (); - info = camel_folder_get_message_info (p->source, uid); - - if (copies || !procuid) { - mm = camel_folder_get_message (p->source, uid, p->ex); - - while (copies) { - camel_folder_append_message(copies->data, mm, info, p->ex); - tmp = copies->next; - g_list_free_1 (copies); - copies = tmp; - } - - if (!procuid && inbox != source) { - printf("Applying default rule to message %s\n", uid); - camel_folder_append_message(inbox, mm, info, p->ex); - } - - camel_object_unref (CAMEL_OBJECT (mm)); - } - - if (inbox != source) - camel_folder_delete_message (p->source, uid); - mail_tool_camel_lock_down (); - - } - mail_tool_camel_lock_up (); - camel_folder_free_uids (p->source, all); - if (input->unhook_func) - camel_object_unhook_event (CAMEL_OBJECT (input->inbox), "folder_changed", - input->unhook_func, input->unhook_data); - mail_tool_camel_lock_down (); - - /* now we no longer need our keys */ - l = p->searches; - while (l) { - camel_folder_search_free (p->source, l->data); - l = l->next; - } - g_list_free (p->searches); - - g_hash_table_destroy (p->copies); - g_hash_table_destroy (p->processed); - g_hash_table_destroy (p->terminated); - close_folders (d); - g_hash_table_destroy (p->folders); - mail_tool_camel_lock_up (); - camel_folder_sync (p->source, TRUE, ex); - camel_folder_thaw (inbox); - mail_tool_camel_lock_down (); -} - -static void -cleanup_filter_mail (gpointer in_data, gpointer op_data, CamelException *ex) -{ - filter_mail_input_t *input = (filter_mail_input_t *) in_data; - - camel_object_unref (CAMEL_OBJECT (input->source)); - camel_object_unref (CAMEL_OBJECT (input->inbox)); - - if (input->self_destruct) - gtk_object_unref (GTK_OBJECT (input->driver)); -} diff --git a/filter/filter-driver.h b/filter/filter-driver.h deleted file mode 100644 index 1ef62b7118..0000000000 --- a/filter/filter-driver.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Michael Zucchi - * - * 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 Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#ifndef _FILTER_DRIVER_H -#define _FILTER_DRIVER_H - -#include -#include -#include -#include - -#include "filter-context.h" - -#define FILTER_DRIVER(obj) GTK_CHECK_CAST (obj, filter_driver_get_type (), FilterDriver) -#define FILTER_DRIVER_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, filter_driver_get_type (), FilterDriverClass) -#define IS_FILTER_DRIVER(obj) GTK_CHECK_TYPE (obj, filter_driver_get_type ()) - -typedef struct _FilterDriver FilterDriver; -typedef struct _FilterDriverClass FilterDriverClass; - -struct _FilterDriver { - GtkObject parent; - - struct _FilterDriverPrivate *priv; -}; - -struct _FilterDriverClass { - GtkObjectClass parent_class; -}; - -typedef CamelFolder * (*FilterGetFolderFunc) (FilterDriver *, const char *uri, void *data); - -guint filter_driver_get_type (void); -FilterDriver *filter_driver_new (FilterContext *ctx, FilterGetFolderFunc fetcher, void *data); - -/* - void filter_driver_set_global(FilterDriver *, const char *name, const char *value);*/ - -/* apply rules to a folder, unmatched messages goto inbox, if not NULL */ -void filter_driver_run(FilterDriver *d, CamelFolder *source, CamelFolder *inbox, - enum _filter_source_t sourcetype, - gboolean self_destruct, gpointer unhook_func, gpointer unhook_data); - -#if 0 -/* generate the search query/action string for a filter option */ -void filter_driver_expand_option(FilterDriver *d, GString *s, GString *action, struct filter_option *op); - -/* get info about rules (options) */ -int filter_driver_rule_count(FilterDriver *d); -struct filter_option *filter_driver_rule_get(FilterDriver *d, int n); -#endif - -#endif /* ! _FILTER_DRIVER_H */ diff --git a/filter/filter-editor.c b/filter/filter-editor.c deleted file mode 100644 index 9f4a0e1872..0000000000 --- a/filter/filter-editor.c +++ /dev/null @@ -1,389 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include - -#include "filter-editor.h" -#include "filter-context.h" -#include "filter-filter.h" - -#define d(x) - -#if 0 -static void filter_editor_class_init (FilterEditorClass *class); -static void filter_editor_init (FilterEditor *gspaper); -static void filter_editor_finalise (GtkObject *obj); - -#define _PRIVATE(x) (((FilterEditor *)(x))->priv) - -struct _FilterEditorPrivate { -}; - -static GnomeDialogClass *parent_class; - -enum { - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -guint -filter_editor_get_type (void) -{ - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "FilterEditor", - sizeof(FilterEditor), - sizeof(FilterEditorClass), - (GtkClassInitFunc)filter_editor_class_init, - (GtkObjectInitFunc)filter_editor_init, - (GtkArgSetFunc)NULL, - (GtkArgGetFunc)NULL - }; - - type = gtk_type_unique(gnome_dialog_get_type (), &type_info); - } - - return type; -} - -static void -filter_editor_class_init (FilterEditorClass *class) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *)class; - parent_class = gtk_type_class(gnome_dialog_get_type ()); - - object_class->finalize = filter_editor_finalise; - /* override methods */ - - /* signals */ - - gtk_object_class_add_signals(object_class, signals, LAST_SIGNAL); -} - -static void -filter_editor_init (FilterEditor *o) -{ - o->priv = g_malloc0(sizeof(*o->priv)); -} - -static void -filter_editor_finalise(GtkObject *obj) -{ - FilterEditor *o = (FilterEditor *)obj; - - ((GtkObjectClass *)(parent_class))->finalize(obj); -} - -/** - * filter_editor_new: - * - * Create a new FilterEditor object. - * - * Return value: A new #FilterEditor object. - **/ -FilterEditor * -filter_editor_new(void) -{ - FilterEditor *o = (FilterEditor *)gtk_type_new(filter_editor_get_type ()); - return o; -} - -#endif - - -enum { - BUTTON_ADD, - BUTTON_EDIT, - BUTTON_DELETE, - BUTTON_UP, - BUTTON_DOWN, - BUTTON_LAST -}; - -struct _editor_data { - RuleContext *f; - FilterRule *current; - GtkList *list; - GtkButton *buttons[BUTTON_LAST]; - enum _filter_source_t current_source; -}; - -static void set_sensitive(struct _editor_data *data); - -static void rule_add(GtkWidget *widget, struct _editor_data *data) -{ - FilterFilter *rule; - int result; - GnomeDialog *gd; - GtkWidget *w; - FilterPart *part; - - d(printf("add rule\n")); - /* create a new rule with 1 match and 1 action */ - rule = filter_filter_new(); - ((FilterRule *)rule)->source = data->current_source; - - part = rule_context_next_part(data->f, NULL); - filter_rule_add_part((FilterRule *)rule, filter_part_clone(part)); - part = filter_context_next_action((FilterContext *)data->f, NULL); - filter_filter_add_action(rule, filter_part_clone(part)); - - w = filter_rule_get_widget((FilterRule *)rule, data->f); - gd = (GnomeDialog *)gnome_dialog_new(_("Add Rule"), GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_CANCEL, NULL); - gtk_box_pack_start((GtkBox *)gd->vbox, w, FALSE, TRUE, 0); - gtk_widget_show((GtkWidget *)gd); - result = gnome_dialog_run_and_close(gd); - if (result == 0) { - GtkListItem *item = (GtkListItem *)gtk_list_item_new_with_label(((FilterRule *)rule)->name); - GList *l = NULL; - - gtk_object_set_data((GtkObject *)item, "rule", rule); - gtk_widget_show((GtkWidget *)item); - l = g_list_append(l, item); - gtk_list_append_items(data->list, l); - gtk_list_select_child(data->list, (GtkWidget *)item); - data->current = (FilterRule *)rule; - rule_context_add_rule(data->f, (FilterRule *)rule); - set_sensitive(data); - } else { - gtk_object_unref((GtkObject *)rule); - } -} - -static void rule_edit(GtkWidget *widget, struct _editor_data *data) -{ - GtkWidget *w; - int result; - GnomeDialog *gd; - FilterRule *rule; - int pos; - - d(printf("edit rule\n")); - rule = data->current; - w = filter_rule_get_widget(rule, data->f); - gd = (GnomeDialog *)gnome_dialog_new(_("Edit Rule"), - GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_CANCEL, - NULL); - gtk_box_pack_start((GtkBox *)gd->vbox, w, FALSE, TRUE, 0); - gtk_widget_show((GtkWidget *)gd); - result = gnome_dialog_run_and_close(gd); - - if (result == 0) { - pos = rule_context_get_rank_rule_with_source (data->f, data->current, data->current_source); - if (pos != -1) { - GtkListItem *item = g_list_nth_data(data->list->children, pos); - gtk_label_set_text((GtkLabel *)(((GtkBin *)item)->child), data->current->name); - } - } -} - -static void rule_delete(GtkWidget *widget, struct _editor_data *data) -{ - int pos; - GList *l; - GtkListItem *item; - - d(printf("ddelete rule\n")); - pos = rule_context_get_rank_rule_with_source (data->f, data->current, data->current_source); - if (pos != -1) { - rule_context_remove_rule(data->f, data->current); - - item = g_list_nth_data(data->list->children, pos); - l = g_list_append(NULL, item); - gtk_list_remove_items(data->list, l); - g_list_free(l); - - gtk_object_unref((GtkObject *)data->current); - data->current = NULL; - } - set_sensitive(data); -} - -static void rule_move(struct _editor_data *data, int from, int to) -{ - GList *l; - GtkListItem *item; - - d(printf("moving %d to %d\n", from, to)); - rule_context_rank_rule(data->f, data->current, to); - - item = g_list_nth_data(data->list->children, from); - l = g_list_append(NULL, item); - gtk_list_remove_items_no_unref(data->list, l); - gtk_list_insert_items(data->list, l, to); - gtk_list_select_child(data->list, (GtkWidget *)item); - set_sensitive(data); -} - -static void rule_up(GtkWidget *widget, struct _editor_data *data) -{ - int pos; - - d(printf("up rule\n")); - pos = rule_context_get_rank_rule_with_source(data->f, data->current, data->current_source); - if (pos>0) { - rule_move(data, pos, pos-1); - } -} - -static void rule_down(GtkWidget *widget, struct _editor_data *data) -{ - int pos; - - d(printf("down rule\n")); - pos = rule_context_get_rank_rule_with_source(data->f, data->current, data->current_source); - rule_move(data, pos, pos+1); -} - -static struct { - char *name; - GtkSignalFunc func; -} edit_buttons[] = { - { "rule_add", rule_add }, - { "rule_edit", rule_edit }, - { "rule_delete", rule_delete }, - { "rule_up", rule_up }, - { "rule_down", rule_down }, -}; - -static void -set_sensitive(struct _editor_data *data) -{ - FilterRule *rule = NULL; - int index=-1, count=0; - - while ((rule = rule_context_next_rule(data->f, rule))) { - if (rule == data->current) - index=count; - count++; - } - d(printf("index = %d count=%d\n", index, count)); - count--; - gtk_widget_set_sensitive((GtkWidget *)data->buttons[BUTTON_EDIT], index != -1); - gtk_widget_set_sensitive((GtkWidget *)data->buttons[BUTTON_DELETE], index != -1); - gtk_widget_set_sensitive((GtkWidget *)data->buttons[BUTTON_UP], index > 0); - gtk_widget_set_sensitive((GtkWidget *)data->buttons[BUTTON_DOWN], index >=0 && indexcurrent = gtk_object_get_data((GtkObject *)child, "rule"); - if (data->current) - d(printf("seledct rule: %s\n", data->current->name)); - else - d(printf("bad data?\n")); - set_sensitive(data); -} - -/* FIXME: we need a way to change a rule from one source type - * to a different type. Maybe keep the selected ones? - */ - -static void -select_source (GtkMenuItem *mi, struct _editor_data *data) -{ - FilterRule *rule = NULL; - GList *newitems = NULL; - enum _filter_source_t source; - - source = (enum _filter_source_t) GPOINTER_TO_INT ( - gtk_object_get_data (GTK_OBJECT (mi), "number")); - - gtk_list_clear_items (GTK_LIST (data->list), 0, -1); - - d(printf("Checking for rules that are of type %d\n", source)); - while ((rule = rule_context_next_rule (data->f, rule)) != NULL) { - GtkWidget *item; - - if (rule->source != source) { - d(printf(" skipping %s: %d != %d\n", rule->name, rule->source, source)); - continue; - } - - d(printf(" hit %s (%d)\n", rule->name, source)); - item = gtk_list_item_new_with_label (rule->name); - gtk_object_set_data (GTK_OBJECT (item), "rule", rule); - gtk_widget_show (GTK_WIDGET (item)); - newitems = g_list_append (newitems, item); - } - - gtk_list_append_items (data->list, newitems); - data->current_source = source; - data->current = NULL; - set_sensitive (data); -} - -GtkWidget *filter_editor_construct (struct _FilterContext *f) -{ - GladeXML *gui; - GtkWidget *d, *w, *b, *firstitem = NULL; - GList *l; - struct _editor_data *data; - int i; - - g_assert(IS_FILTER_CONTEXT(f)); - - data = g_malloc0(sizeof(*data)); - data->f = (RuleContext *)f; - - gui = glade_xml_new(FILTER_GLADEDIR "/filter.glade", "edit_filter"); - d = glade_xml_get_widget (gui, "edit_filter"); - gtk_object_set_data_full((GtkObject *)d, "data", data, g_free); - - gtk_window_set_title((GtkWindow *)d, "Edit Filters"); - for (i=0;ibuttons[i] = (GtkButton *)w = glade_xml_get_widget (gui, edit_buttons[i].name); - gtk_signal_connect((GtkObject *)w, "clicked", edit_buttons[i].func, data); - } - - w = glade_xml_get_widget (gui, "filter_source"); - l = GTK_MENU_SHELL(GTK_OPTION_MENU(w)->menu)->children; - i = 0; - while (l) { - b = GTK_WIDGET (l->data); - - if (i == 0) - firstitem = b; - - /* make sure that the glade is in sync with enum _filter_source_t! */ - gtk_object_set_data (GTK_OBJECT (b), "number", GINT_TO_POINTER (i)); - gtk_signal_connect (GTK_OBJECT (b), "activate", select_source, data); - - i++; - l = l->next; - } - - w = glade_xml_get_widget (gui, "rule_list"); - data->list = (GtkList *)w; - gtk_signal_connect((GtkObject *)w, "select_child", select_rule, data); - select_source (GTK_MENU_ITEM (firstitem), data); - - gtk_object_unref((GtkObject *)gui); - - return d; -} diff --git a/filter/filter-editor.h b/filter/filter-editor.h deleted file mode 100644 index 20369a9536..0000000000 --- a/filter/filter-editor.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef _FILTER_EDITOR_H -#define _FILTER_EDITOR_H - -#include -#include - -#if 0 -/* NOTE: object stuff not used (yet?), this is just a holder file for a static factory */ - -#define FILTER_EDITOR(obj) GTK_CHECK_CAST (obj, filter_editor_get_type (), FilterEditor) -#define FILTER_EDITOR_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, filter_editor_get_type (), FilterEditorClass) -#define IS_FILTER_EDITOR(obj) GTK_CHECK_TYPE (obj, filter_editor_get_type ()) - -typedef struct _FilterEditor FilterEditor; -typedef struct _FilterEditorClass FilterEditorClass; - -struct _FilterEditor { - GnomeDialog parent; - struct _FilterEditorPrivate *priv; - -}; - -struct _FilterEditorClass { - GnomeDialogClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - -guint filter_editor_get_type (void); -FilterEditor *filter_editor_new (void); -#endif - -struct _FilterContext; - -/* methods */ -GtkWidget *filter_editor_construct (struct _FilterContext *f); - -#endif /* ! _FILTER_EDITOR_H */ - diff --git a/filter/filter-element.c b/filter/filter-element.c deleted file mode 100644 index e0b896daf2..0000000000 --- a/filter/filter-element.c +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include - -#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-folder.h" - -static void xml_create(FilterElement *fe, xmlNodePtr node); -static FilterElement *clone(FilterElement *fe); - -static void filter_element_class_init (FilterElementClass *class); -static void filter_element_init (FilterElement *gspaper); -static void filter_element_finalise (GtkObject *obj); - -#define _PRIVATE(x) (((FilterElement *)(x))->priv) -struct _FilterElementPrivate { -}; - -static GtkObjectClass *parent_class; - -enum { - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -guint -filter_element_get_type (void) -{ - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "FilterElement", - sizeof(FilterElement), - sizeof(FilterElementClass), - (GtkClassInitFunc)filter_element_class_init, - (GtkObjectInitFunc)filter_element_init, - (GtkArgSetFunc)NULL, - (GtkArgGetFunc)NULL - }; - - type = gtk_type_unique(gtk_object_get_type (), &type_info); - } - - return type; -} - -static void -filter_element_class_init (FilterElementClass *class) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *)class; - parent_class = gtk_type_class(gtk_object_get_type ()); - - object_class->finalize = filter_element_finalise; - - /* override methods */ - class->xml_create = xml_create; - class->clone = clone; - - /* signals */ - - gtk_object_class_add_signals(object_class, signals, LAST_SIGNAL); -} - -static void -filter_element_init (FilterElement *o) -{ - o->priv = g_malloc0(sizeof(*o->priv)); -} - -static void -filter_element_finalise(GtkObject *obj) -{ - FilterElement *o = (FilterElement *)obj; - - o = o; - - ((GtkObjectClass *)(parent_class))->finalize(obj); -} - -/** - * filter_element_new: - * - * Create a new FilterElement object. - * - * Return value: A new #FilterElement object. - **/ -FilterElement * -filter_element_new(void) -{ - FilterElement *o = (FilterElement *)gtk_type_new(filter_element_get_type ()); - return o; -} - -/** - * filter_element_xml_create: - * @fe: - * @node: - * - * Create a new filter element based on an xml definition of - * that element. - **/ -void filter_element_xml_create (FilterElement *fe, xmlNodePtr node) -{ - return ((FilterElementClass *)((GtkObject *)fe)->klass)->xml_create(fe, node); -} - -/** - * filter_element_xml_encode: - * @fe: - * - * Encode the values of a filter element into xml format. - * - * Return value: - **/ -xmlNodePtr filter_element_xml_encode (FilterElement *fe) -{ - return ((FilterElementClass *)((GtkObject *)fe)->klass)->xml_encode(fe); -} - -/** - * filter_element_xml_decode: - * @fe: - * @node: - * - * Decode the values of a fitler element from xml format. - * - * Return value: - **/ -int filter_element_xml_decode (FilterElement *fe, xmlNodePtr node) -{ - return ((FilterElementClass *)((GtkObject *)fe)->klass)->xml_decode(fe, node); -} - -/** - * filter_element_clone: - * @fe: - * - * Clones the FilterElement @fe. - * - * Return value: - **/ -FilterElement *filter_element_clone (FilterElement *fe) -{ - return ((FilterElementClass *)((GtkObject *)fe)->klass)->clone(fe); -} - -/** - * filter_element_get_widget: - * @fe: - * @node: - * - * Create a widget to represent this element. - * - * Return value: - **/ -GtkWidget *filter_element_get_widget (FilterElement *fe) -{ - return ((FilterElementClass *)((GtkObject *)fe)->klass)->get_widget(fe); -} - -/** - * filter_element_build_code: - * @fe: - * @out: - * @ff: - * - * Add the code representing this element to the output string @out. - **/ -void filter_element_build_code (FilterElement *fe, GString *out, struct _FilterPart *ff) -{ - return ((FilterElementClass *)((GtkObject *)fe)->klass)->build_code(fe, out, ff); -} - -/** - * filter_element_format_sexp: - * @fe: - * @out: - * - * Format the value(s) of this element in a method suitable for the context of - * sexp where it is used. Usually as space separated, double-quoted strings. - **/ -void filter_element_format_sexp (FilterElement *fe, GString *out) -{ - return ((FilterElementClass *)((GtkObject *)fe)->klass)->format_sexp(fe, out); -} - -/** - * filter_element_new_type_name: - * @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")) { - return (FilterElement *)filter_option_new(); - } else if (!strcmp(type, "datespec")) { - return (FilterElement *)filter_datespec_new(); - } else { - g_warning("Unknown filter type '%s'", type); - return 0; - } -} - -/* default implementations */ -static void xml_create(FilterElement *fe, xmlNodePtr node) -{ - fe->name = xmlGetProp(node, "name"); -} - -static FilterElement *clone(FilterElement *fe) -{ - xmlNodePtr node; - FilterElement *new; - - new = (FilterElement *)gtk_type_new( ((GtkObject *)fe)->klass->type ); - node = filter_element_xml_encode(fe); - filter_element_xml_decode(new, node); - xmlFreeNodeList(node); - return new; -} - - diff --git a/filter/filter-element.h b/filter/filter-element.h deleted file mode 100644 index 8fe82402ee..0000000000 --- a/filter/filter-element.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef _FILTER_ELEMENT_H -#define _FILTER_ELEMENT_H - -#include -#include - -#define FILTER_ELEMENT(obj) GTK_CHECK_CAST (obj, filter_element_get_type (), FilterElement) -#define FILTER_ELEMENT_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, filter_element_get_type (), FilterElementClass) -#define IS_FILTER_ELEMENT(obj) GTK_CHECK_TYPE (obj, filter_element_get_type ()) - -typedef struct _FilterElement FilterElement; -typedef struct _FilterElementClass FilterElementClass; - -struct _FilterElement { - GtkObject parent; - struct _FilterElementPrivate *priv; - - char *name; -}; - -struct _FilterPart; - -struct _FilterElementClass { - GtkObjectClass parent_class; - - /* virtual methods */ - void (*xml_create)(FilterElement *, xmlNodePtr); - xmlNodePtr (*xml_encode)(FilterElement *); - int (*xml_decode)(FilterElement *, xmlNodePtr); - - FilterElement *(*clone)(FilterElement *fe); - - GtkWidget *(*get_widget)(FilterElement *); - void (*build_code)(FilterElement *, GString *, struct _FilterPart *ff); - void (*format_sexp)(FilterElement *, GString *); - - /* signals */ -}; - -guint filter_element_get_type (void); -FilterElement *filter_element_new (void); - -FilterElement *filter_element_new_type_name (const char *type); - -/* methods */ -void filter_element_xml_create (FilterElement *fe, xmlNodePtr node); - -xmlNodePtr filter_element_xml_encode (FilterElement *fe); -int filter_element_xml_decode (FilterElement *fe, xmlNodePtr node); -FilterElement *filter_element_clone (FilterElement *fe); - -GtkWidget *filter_element_get_widget (FilterElement *fe); -void filter_element_build_code (FilterElement *fe, GString *out, struct _FilterPart *ff); -void filter_element_format_sexp (FilterElement *fe, GString *out); - -#endif /* ! _FILTER_ELEMENT_H */ - diff --git a/filter/filter-filter.c b/filter/filter-filter.c deleted file mode 100644 index b0699ce827..0000000000 --- a/filter/filter-filter.c +++ /dev/null @@ -1,411 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include - -#include "filter-filter.h" -#include "filter-context.h" - -#define d(x) - -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 filter_filter_class_init (FilterFilterClass *class); -static void filter_filter_init (FilterFilter *gspaper); -static void filter_filter_finalise (GtkObject *obj); - -#define _PRIVATE(x) (((FilterFilter *)(x))->priv) - -struct _FilterFilterPrivate { -}; - -static FilterRuleClass *parent_class; - -enum { - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -guint -filter_filter_get_type (void) -{ - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "FilterFilter", - sizeof(FilterFilter), - sizeof(FilterFilterClass), - (GtkClassInitFunc)filter_filter_class_init, - (GtkObjectInitFunc)filter_filter_init, - (GtkArgSetFunc)NULL, - (GtkArgGetFunc)NULL - }; - - type = gtk_type_unique(filter_rule_get_type (), &type_info); - } - - return type; -} - -static void -filter_filter_class_init (FilterFilterClass *class) -{ - GtkObjectClass *object_class; - FilterRuleClass *filter_rule = (FilterRuleClass *)class; - - object_class = (GtkObjectClass *)class; - parent_class = gtk_type_class(filter_rule_get_type ()); - - object_class->finalize = filter_filter_finalise; - - /* override methods */ - filter_rule->xml_encode = xml_encode; - filter_rule->xml_decode = xml_decode; - /*filter_rule->build_code = build_code;*/ - filter_rule->get_widget = get_widget; - - /* signals */ - - gtk_object_class_add_signals(object_class, signals, LAST_SIGNAL); -} - -static void -filter_filter_init (FilterFilter *o) -{ - o->priv = g_malloc0(sizeof(*o->priv)); -} - -static void -unref_list(GList *l) -{ - while (l) { - gtk_object_unref((GtkObject *)l->data); - l = g_list_next(l); - } -} - -static void -filter_filter_finalise(GtkObject *obj) -{ - FilterFilter *o = (FilterFilter *)obj; - - unref_list(o->actions); - - ((GtkObjectClass *)(parent_class))->finalize(obj); -} - -/** - * filter_filter_new: - * - * Create a new FilterFilter object. - * - * Return value: A new #FilterFilter object. - **/ -FilterFilter * -filter_filter_new(void) -{ - FilterFilter *o = (FilterFilter *)gtk_type_new(filter_filter_get_type ()); - return o; -} - -void filter_filter_add_action (FilterFilter *fr, FilterPart *fp) -{ - fr->actions = g_list_append(fr->actions, fp); -} - -void filter_filter_remove_action (FilterFilter *fr, FilterPart *fp) -{ - fr->actions = g_list_remove(fr->actions, fp); -} - -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); - } -} - -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 xmlNodePtr xml_encode(FilterRule *fr) -{ - xmlNodePtr node, set, work; - GList *l; - FilterFilter *ff = (FilterFilter *)fr; - - node = ((FilterRuleClass *)(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 = g_list_next(l); - } - return node; - -} - -static void load_set(xmlNodePtr node, FilterFilter *ff, RuleContext *f) -{ - xmlNodePtr work; - char *rulename; - FilterPart *part; - - work = node->childs; - while (work) { - if (!strcmp(work->name, "part")) { - rulename = xmlGetProp(work, "name"); - part = filter_context_find_action((FilterContext *)f, 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 { - g_warning("Unknwon xml node in part: %s", work->name); - } - work = work->next; - } -} - -static int xml_decode(FilterRule *fr, xmlNodePtr node, struct _RuleContext *f) -{ - xmlNodePtr work; - FilterFilter *ff = (FilterFilter *)fr; - int result; - - result = ((FilterRuleClass *)(parent_class))->xml_decode(fr, node, f); - if (result != 0) - return result; - - work = node->childs; - while (work) { - if (!strcmp(work->name, "actionset")) { - load_set(work, ff, f); - } - work = work->next; - } - return 0; -} - -/*static void build_code(FilterRule *fr, GString *out) -{ - return ((FilterRuleClass *)(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 = gtk_object_get_data((GtkObject *)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((GtkContainer *)data->container, data->partwidget); - newpart = filter_part_clone(part); - filter_filter_replace_action((FilterFilter *)data->fr, data->part, newpart); - gtk_object_unref((GtkObject *)data->part); - data->part = newpart; - data->partwidget = filter_part_get_widget(newpart); - if (data->partwidget) - gtk_box_pack_start((GtkBox *)data->container, data->partwidget, FALSE, FALSE, 0); -} - -static GtkWidget * -get_rule_part_widget(FilterContext *f, FilterPart *newpart, FilterRule *fr) -{ - FilterPart *part = NULL; - GtkMenu *menu; - GtkMenuItem *item; - GtkOptionMenu *omenu; - GtkHBox *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 = (GtkHBox *)gtk_hbox_new(FALSE, 0); - p = filter_part_get_widget(newpart); - - data->partwidget = p; - data->container = (GtkWidget *)hbox; - - menu = (GtkMenu *)gtk_menu_new(); - while ((part=filter_context_next_action(f, part))) { - item = (GtkMenuItem *)gtk_menu_item_new_with_label(part->title); - gtk_object_set_data((GtkObject *)item, "part", part); - gtk_signal_connect((GtkObject *)item, "activate", option_activate, data); - gtk_menu_append(menu, (GtkWidget *)item); - gtk_widget_show((GtkWidget *)item); - if (!strcmp(newpart->title, part->title)) { - current = index; - } - index++; - } - - omenu = (GtkOptionMenu *)gtk_option_menu_new(); - gtk_option_menu_set_menu(omenu, (GtkWidget *)menu); - gtk_option_menu_set_history(omenu, current); - gtk_widget_show((GtkWidget *)omenu); - - gtk_box_pack_start((GtkBox *)hbox, (GtkWidget *)omenu, FALSE, FALSE, 0); - if (p) { - gtk_box_pack_start((GtkBox *)hbox, p, FALSE, FALSE, 0); - } - gtk_widget_show_all((GtkWidget *)hbox); - - return (GtkWidget *)hbox; -} - -struct _rule_data { - FilterRule *fr; - FilterContext *f; - GtkWidget *parts; -}; - -static void -less_parts(GtkWidget *button, struct _rule_data *data) -{ - GList *l; - FilterPart *part; - GtkWidget *w; - - l = ((FilterFilter *)data->fr)->actions; - if (g_list_length(l) < 2) - return; - - /* remove the last one from the list */ - l = g_list_last(l); - part = l->data; - filter_filter_remove_action((FilterFilter *)data->fr, part); - gtk_object_unref((GtkObject *)part); - - /* and from the display */ - l = g_list_last(GTK_BOX(data->parts)->children); - w = ((GtkBoxChild *)l->data)->widget; - gtk_container_remove((GtkContainer *)data->parts, w); -} - -static void -more_parts(GtkWidget *button, struct _rule_data *data) -{ - FilterPart *new; - GtkWidget *w; - - /* create a new rule entry, use the first type of rule */ - new = filter_context_next_action((FilterContext *)data->f, NULL); - if (new) { - new = filter_part_clone(new); - filter_filter_add_action((FilterFilter *)data->fr, new); - w = get_rule_part_widget(data->f, new, data->fr); - gtk_box_pack_start((GtkBox *)data->parts, w, FALSE, FALSE, 0); - } -} - -static GtkWidget *get_widget(FilterRule *fr, struct _RuleContext *f) -{ - GtkWidget *widget; - GtkVBox *parts, *inframe; - GtkHBox *hbox; - GtkWidget *w; - GtkFrame *frame; - GList *l; - FilterPart *part; - struct _rule_data *data; - FilterFilter *ff = (FilterFilter *)fr; - - d(printf("filter filter.get widget\n")); - - widget = ((FilterRuleClass *)(parent_class))->get_widget(fr, f); - - /* and now for the action area */ - frame = (GtkFrame *)gtk_frame_new("Perform actions"); - inframe = (GtkVBox *)gtk_vbox_new(FALSE, 3); - gtk_container_add((GtkContainer *)frame, (GtkWidget *)inframe); - - parts = (GtkVBox *)gtk_vbox_new(FALSE, 3); - data = g_malloc0(sizeof(*data)); - data->f = (FilterContext *)f; - data->fr = fr; - data->parts = (GtkWidget *)parts; - - l = ff->actions; - while (l) { - part = l->data; - d(printf("adding action %s\n", part->title)); - w = get_rule_part_widget((FilterContext *)f, part, fr); - gtk_box_pack_start((GtkBox *)parts, (GtkWidget *)w, FALSE, FALSE, 3); - l = g_list_next(l); - } - gtk_box_pack_start((GtkBox *)inframe, (GtkWidget *)parts, FALSE, FALSE, 3); - - hbox = (GtkHBox *)gtk_hbox_new(FALSE, 3); - w = gtk_button_new_with_label(_("Less")); - gtk_signal_connect((GtkObject *)w, "clicked", less_parts, data); - gtk_box_pack_end((GtkBox *)hbox, (GtkWidget *)w, FALSE, FALSE, 3); - w = gtk_button_new_with_label(_("More")); - gtk_signal_connect((GtkObject *)w, "clicked", more_parts, data); - gtk_box_pack_end((GtkBox *)hbox, (GtkWidget *)w, FALSE, FALSE, 3); - gtk_box_pack_start((GtkBox *)inframe, (GtkWidget *)hbox, FALSE, FALSE, 3); - - gtk_widget_show_all((GtkWidget *)frame); - - gtk_box_pack_start((GtkBox *)widget, (GtkWidget *)frame, FALSE, FALSE, 3); - - return widget; -} - diff --git a/filter/filter-filter.h b/filter/filter-filter.h deleted file mode 100644 index 944aba42ae..0000000000 --- a/filter/filter-filter.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef _FILTER_FILTER_H -#define _FILTER_FILTER_H - -#include -#include "filter-rule.h" - -#define FILTER_FILTER(obj) GTK_CHECK_CAST (obj, filter_filter_get_type (), FilterFilter) -#define FILTER_FILTER_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, filter_filter_get_type (), FilterFilterClass) -#define IS_FILTER_FILTER(obj) GTK_CHECK_TYPE (obj, filter_filter_get_type ()) - -typedef struct _FilterFilter FilterFilter; -typedef struct _FilterFilterClass FilterFilterClass; - -struct _FilterFilter { - FilterRule parent; - struct _FilterFilterPrivate *priv; - - GList *actions; -}; - -struct _FilterFilterClass { - FilterRuleClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - -guint 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 60212086ee..0000000000 --- a/filter/filter-folder.c +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include - -#define SHELL - -#include "filter-folder.h" -#ifdef SHELL -#include "shell/evolution-shell-client.h" -#endif -#include "e-util/e-sexp.h" - -#define d(x) - -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 *); - -#ifdef SHELL -extern EvolutionShellClient *global_shell_client; -#endif - -static void filter_folder_class_init (FilterFolderClass *class); -static void filter_folder_init (FilterFolder *gspaper); -static void filter_folder_finalise (GtkObject *obj); - -#define _PRIVATE(x) (((FilterFolder *)(x))->priv) - -struct _FilterFolderPrivate { -}; - -static FilterElementClass *parent_class; - -guint -filter_folder_get_type (void) -{ - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "FilterFolder", - sizeof(FilterFolder), - sizeof(FilterFolderClass), - (GtkClassInitFunc)filter_folder_class_init, - (GtkObjectInitFunc)filter_folder_init, - (GtkArgSetFunc)NULL, - (GtkArgGetFunc)NULL - }; - - type = gtk_type_unique(filter_element_get_type (), &type_info); - } - - return type; -} - -static void -filter_folder_class_init (FilterFolderClass *class) -{ - GtkObjectClass *object_class; - FilterElementClass *filter_element = (FilterElementClass *)class; - - object_class = (GtkObjectClass *)class; - parent_class = gtk_type_class(filter_element_get_type ()); - - object_class->finalize = filter_folder_finalise; - - /* override methods */ - filter_element->xml_create = xml_create; - filter_element->xml_encode = xml_encode; - filter_element->xml_decode = xml_decode; - filter_element->get_widget = get_widget; - filter_element->build_code = build_code; - filter_element->format_sexp = format_sexp; -} - -static void -filter_folder_init (FilterFolder *o) -{ - o->priv = g_malloc0(sizeof(*o->priv)); -} - -static void -filter_folder_finalise(GtkObject *obj) -{ - FilterFolder *o = (FilterFolder *)obj; - - g_free(o->uri); - g_free(o->name); - - ((GtkObjectClass *)(parent_class))->finalize(obj); -} - -/** - * filter_folder_new: - * - * Create a new FilterFolder object. - * - * Return value: A new #FilterFolder object. - **/ -FilterFolder * -filter_folder_new(void) -{ - FilterFolder *o = (FilterFolder *)gtk_type_new(filter_folder_get_type ()); - return o; -} - -static void xml_create(FilterElement *fe, xmlNodePtr node) -{ - /* parent implementation */ - ((FilterElementClass *)(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, "name", ff->name); - 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)); - - fe->name = xmlGetProp(node, "name"); - - n = node->childs; - while (n) { - if (!strcmp(n->name, "folder")) { - ff->name = xmlGetProp(n, "name"); - ff->uri = xmlGetProp(n, "uri"); - break; - } - n = n->next; - } - return 0; -} - -static void button_clicked(GtkButton *button, FilterFolder *ff) -{ -#ifdef SHELL - const char *allowed_types[] = { "mail", NULL }; - char *def, *physical_uri, *evolution_uri; - - def = ff->uri ? ff->uri : ""; - - evolution_shell_client_user_select_folder (global_shell_client, - _("Select Folder"), - def, allowed_types, - &evolution_uri, - &physical_uri); - - if (physical_uri != NULL && physical_uri[0] != '\0') { - g_free(ff->uri); - ff->uri = physical_uri; - - g_free(ff->name); - ff->name = g_strdup(g_basename (evolution_uri)); - - gtk_label_set_text((GtkLabel *)GTK_BIN(button)->child, ff->name); - } else { - g_free (physical_uri); - } - g_free (evolution_uri); -#else - GnomeDialog *gd; - GtkEntry *entry; - char *uri, *str; - - gd = (GnomeDialog *)gnome_dialog_new(_("Enter folder URI"), - GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_CANCEL, - NULL); - entry = (GtkEntry *)gtk_entry_new(); - if (ff->uri) { - gtk_entry_set_text(entry, ff->uri); - } - gtk_box_pack_start((GtkBox *)gd->vbox, (GtkWidget *)entry, TRUE, TRUE, 3); - gtk_widget_show((GtkWidget *)entry); - switch (gnome_dialog_run(gd)) { - case 0: - g_free(ff->uri); - g_free(ff->name); - uri = gtk_entry_get_text(entry); - ff->uri = g_strdup(uri); - str = strstr(uri, "//"); - if (str) - str = strchr(str+2, '/'); - if (str) - str++; - else - str = uri; - ff->name = g_strdup(str); - gtk_label_set_text((GtkLabel *)GTK_BIN(button)->child, ff->name); - case 1: - gnome_dialog_close(gd); - case -1: - /* nothing */ - } - -#endif -} - -static GtkWidget *get_widget(FilterElement *fe) -{ - FilterFolder *ff = (FilterFolder *)fe; - GtkButton *button; - GtkLabel *label; - - if (ff->name && ff->name[0]) - label = (GtkLabel *)gtk_label_new(g_basename (ff->name)); - else - label = (GtkLabel *)gtk_label_new(_("")); - - button = (GtkButton *)gtk_button_new(); - gtk_container_add((GtkContainer *)button, (GtkWidget *)label); - gtk_widget_show((GtkWidget *)button); - gtk_widget_show((GtkWidget *)label); - gtk_signal_connect((GtkObject *)button, "clicked", button_clicked, ff); - return (GtkWidget *)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 ee52d7037b..0000000000 --- a/filter/filter-folder.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef _FILTER_FOLDER_H -#define _FILTER_FOLDER_H - -#include -#include "filter-element.h" - -#define FILTER_FOLDER(obj) GTK_CHECK_CAST (obj, filter_folder_get_type (), FilterFolder) -#define FILTER_FOLDER_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, filter_folder_get_type (), FilterFolderClass) -#define IS_FILTER_FOLDER(obj) GTK_CHECK_TYPE (obj, filter_folder_get_type ()) - -typedef struct _FilterFolder FilterFolder; -typedef struct _FilterFolderClass FilterFolderClass; - -struct _FilterFolder { - FilterElement parent; - struct _FilterFolderPrivate *priv; - - char *uri; - char *name; /* name of folder for display? */ -}; - -struct _FilterFolderClass { - FilterElementClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - -guint filter_folder_get_type (void); -FilterFolder *filter_folder_new (void); - -/* methods */ - -#endif /* ! _FILTER_FOLDER_H */ - diff --git a/filter/filter-input.c b/filter/filter-input.c deleted file mode 100644 index f422a091b1..0000000000 --- a/filter/filter-input.c +++ /dev/null @@ -1,260 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include - -#include "filter-input.h" -#include "e-util/e-sexp.h" - -#define d(x) - -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_input_class_init (FilterInputClass *class); -static void filter_input_init (FilterInput *gspaper); -static void filter_input_finalise (GtkObject *obj); - -#define _PRIVATE(x) (((FilterInput *)(x))->priv) - -struct _FilterInputPrivate { -}; - -static FilterElementClass *parent_class; - -enum { - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -guint -filter_input_get_type (void) -{ - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "FilterInput", - sizeof(FilterInput), - sizeof(FilterInputClass), - (GtkClassInitFunc)filter_input_class_init, - (GtkObjectInitFunc)filter_input_init, - (GtkArgSetFunc)NULL, - (GtkArgGetFunc)NULL - }; - - type = gtk_type_unique(filter_element_get_type (), &type_info); - } - - return type; -} - -static void -filter_input_class_init (FilterInputClass *class) -{ - GtkObjectClass *object_class; - FilterElementClass *filter_element = (FilterElementClass *)class; - - object_class = (GtkObjectClass *)class; - parent_class = gtk_type_class(filter_element_get_type ()); - - object_class->finalize = filter_input_finalise; - - /* override methods */ - filter_element->xml_create = xml_create; - filter_element->xml_encode = xml_encode; - filter_element->xml_decode = xml_decode; - filter_element->get_widget = get_widget; - filter_element->build_code = build_code; - filter_element->format_sexp = format_sexp; - - /* signals */ - - gtk_object_class_add_signals(object_class, signals, LAST_SIGNAL); -} - -static void -filter_input_init (FilterInput *o) -{ - o->priv = g_malloc0(sizeof(*o->priv)); -} - -static void -filter_input_finalise(GtkObject *obj) -{ - FilterInput *o = (FilterInput *)obj; - - o = o; - - ((GtkObjectClass *)(parent_class))->finalize(obj); -} - -/** - * filter_input_new: - * - * Create a new FilterInput object. - * - * Return value: A new #FilterInput object. - **/ -FilterInput * -filter_input_new(void) -{ - FilterInput *o = (FilterInput *)gtk_type_new(filter_input_get_type ()); - return o; -} - -FilterInput *filter_input_new_type_name (const char *type) -{ - FilterInput *o = filter_input_new(); - o->type = g_strdup(type); - - d(printf("new type %s = %p\n", type, o)); - return o; -} - -void filter_input_set_value(FilterInput *fi, const char *value) -{ - GList *l; - - l = fi->values; - while (l) { - g_free(l->data); - l = g_list_next(l); - } - g_list_free(fi->values); - - fi->values = g_list_append(NULL, g_strdup(value)); -} - -static void xml_create(FilterElement *fe, xmlNodePtr node) -{ - /* parent implementation */ - ((FilterElementClass *)(parent_class))->xml_create(fe, node); - -} - -static xmlNodePtr xml_encode(FilterElement *fe) -{ - xmlNodePtr value; - GList *l; - FilterInput *fi = (FilterInput *)fe; - char *type; - - type = fi->type?fi->type:"string"; - - d(printf("Encoding %s as xml\n", type)); - - value = xmlNewNode(NULL, "value"); - xmlSetProp(value, "name", fe->name); - xmlSetProp(value, "type", type); - l = fi->values; - while (l) { - xmlNodePtr cur; - char *str = l->data; - - cur = xmlNewChild(value, NULL, type, NULL); - xmlNodeSetContent(cur, str); - l = g_list_next(l); - } - return value; -} - -static int xml_decode(FilterElement *fe, xmlNodePtr node) -{ - FilterInput *fi = (FilterInput *)fe; - char *name, *str, *type; - xmlNodePtr n; - - type = fi->type?fi->type:"string"; - - d(printf("Decoding %s from xml %p\n", type, fe)); - - name = xmlGetProp(node, "name"); - d(printf("Name = %s\n", name)); - fe->name = name; - fi->type = xmlGetProp(node, "type"); - n = node->childs; - while (n) { - if (!strcmp(n->name, type)) { - str = xmlNodeGetContent(n); - d(printf(" '%s'\n", str)); - fi->values = g_list_append(fi->values, str); - } else { - g_warning("Unknown node type '%s' encountered decoding a %s\n", n->name, type); - } - n = n->next; - } - return 0; -} - -static void entry_changed(GtkEntry *entry, FilterElement *fe) -{ - char *new; - FilterInput *fi = (FilterInput *)fe; - GList *l; - - new = gtk_entry_get_text(entry); - - /* NOTE: entry only supports a single value ... */ - l = fi->values; - while (l) { - g_free(l->data); - l = g_list_next(l); - } - g_list_free(fi->values); - - fi->values = g_list_append(NULL, g_strdup(new)); -} - -static GtkWidget *get_widget(FilterElement *fe) -{ - GtkEntry *entry; - FilterInput *fi = (FilterInput *)fe; - - entry = (GtkEntry *)gtk_entry_new(); - if (fi->values && fi->values->data) { - gtk_entry_set_text(entry, fi->values->data); - } - gtk_signal_connect((GtkObject *)entry, "changed", entry_changed, fe); - return (GtkWidget *)entry; -} - -static void build_code(FilterElement *fe, GString *out, struct _FilterPart *ff) -{ - return; -} - -static void format_sexp(FilterElement *fe, GString *out) -{ - GList *l; - FilterInput *fi = (FilterInput *)fe; - - l = fi->values; - while (l) { - e_sexp_encode_string(out, l->data); - l = g_list_next(l); - } -} diff --git a/filter/filter-input.h b/filter/filter-input.h deleted file mode 100644 index 0ce43d980d..0000000000 --- a/filter/filter-input.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef _FILTER_INPUT_H -#define _FILTER_INPUT_H - -#include -#include "filter-element.h" - -#define FILTER_INPUT(obj) GTK_CHECK_CAST (obj, filter_input_get_type (), FilterInput) -#define FILTER_INPUT_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, filter_input_get_type (), FilterInputClass) -#define IS_FILTER_INPUT(obj) GTK_CHECK_TYPE (obj, filter_input_get_type ()) - -typedef struct _FilterInput FilterInput; -typedef struct _FilterInputClass FilterInputClass; - -struct _FilterInput { - FilterElement parent; - struct _FilterInputPrivate *priv; - - char *type; /* name of type */ - GList *values; /* strings */ -}; - -struct _FilterInputClass { - FilterElementClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - -guint filter_input_get_type (void); -FilterInput *filter_input_new (void); - -FilterInput *filter_input_new_type_name (const char *type); - -/* methods */ -void filter_input_set_value(FilterInput *fi, const char *value); - -#endif /* ! _FILTER_INPUT_H */ - diff --git a/filter/filter-option.c b/filter/filter-option.c deleted file mode 100644 index bbf1a8ef90..0000000000 --- a/filter/filter-option.c +++ /dev/null @@ -1,311 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include - -#include "filter-option.h" -#include "filter-part.h" -#include "e-util/e-sexp.h" - -#define d(x) - -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_option_class_init (FilterOptionClass *class); -static void filter_option_init (FilterOption *gspaper); -static void filter_option_finalise (GtkObject *obj); - -#define _PRIVATE(x) (((FilterOption *)(x))->priv) - -struct _FilterOptionPrivate { -}; - -static FilterElementClass *parent_class; - -enum { - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -guint -filter_option_get_type (void) -{ - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "FilterOption", - sizeof(FilterOption), - sizeof(FilterOptionClass), - (GtkClassInitFunc)filter_option_class_init, - (GtkObjectInitFunc)filter_option_init, - (GtkArgSetFunc)NULL, - (GtkArgGetFunc)NULL - }; - - type = gtk_type_unique(filter_element_get_type (), &type_info); - } - - return type; -} - -static void -filter_option_class_init (FilterOptionClass *class) -{ - GtkObjectClass *object_class; - FilterElementClass *filter_element = (FilterElementClass *)class; - - object_class = (GtkObjectClass *)class; - parent_class = gtk_type_class(filter_element_get_type ()); - - object_class->finalize = filter_option_finalise; - - /* override methods */ - filter_element->xml_create = xml_create; - filter_element->xml_encode = xml_encode; - filter_element->xml_decode = xml_decode; - filter_element->clone = clone; - filter_element->get_widget = get_widget; - filter_element->build_code = build_code; - filter_element->format_sexp = format_sexp; - - /* signals */ - - gtk_object_class_add_signals(object_class, signals, LAST_SIGNAL); -} - -static void -filter_option_init (FilterOption *o) -{ - o->priv = g_malloc0(sizeof(*o->priv)); -} - -static void -filter_option_finalise(GtkObject *obj) -{ - FilterOption *o = (FilterOption *)obj; - - o = o; - - ((GtkObjectClass *)(parent_class))->finalize(obj); -} - -/** - * filter_option_new: - * - * Create a new FilterOption object. - * - * Return value: A new #FilterOption object. - **/ -FilterOption * -filter_option_new(void) -{ - FilterOption *o = (FilterOption *)gtk_type_new(filter_option_get_type ()); - return o; -} - -static struct _filter_option * -find_option(FilterOption *fo, const char *name) -{ - GList *l = fo->options; - struct _filter_option *op; - - while (l) { - op = l->data; - if (!strcmp(name, op->value)) { - return op; - } - l = g_list_next(l); - } - return NULL; -} - -void filter_option_set_current(FilterOption *option, const char *name) -{ - g_assert(IS_FILTER_OPTION(option)); - - option->current = find_option(option, name); -} - -static void xml_create(FilterElement *fe, xmlNodePtr node) -{ - FilterOption *fo = (FilterOption *)fe; - xmlNodePtr n, work; - struct _filter_option *op; - - /* parent implementation */ - ((FilterElementClass *)(parent_class))->xml_create(fe, node); - - n = node->childs; - while (n) { - if (!strcmp(n->name, "option")) { - op = g_malloc0(sizeof(*op)); - op->value = xmlGetProp(n, "value"); - work = n->childs; - while (work) { - if (!strcmp(work->name, "title")) { - if (!op->title) { - op->title = xmlNodeGetContent(work); - } - } else if (!strcmp(work->name, "code")) { - if (!op->code) { - op->code = xmlNodeGetContent(work); - } - } - work = work->next; - } - d(printf("creating new option:\n title %s\n value %s\n code %s\n", op->title, op->value, op->code)); - fo->options = g_list_append(fo->options, op); - if (fo->current == NULL) - fo->current = op; - } else { - g_warning("Unknown xml node within optionlist: %s\n", n->name); - } - n = n->next; - } -} - -static xmlNodePtr xml_encode(FilterElement *fe) -{ - xmlNodePtr value; - FilterOption *fo = (FilterOption *)fe; - - d(printf("Encoding option as xml\n")); - value = xmlNewNode(NULL, "value"); - xmlSetProp(value, "name", fe->name); - xmlSetProp(value, "type", "option"); - if (fo->current) { - xmlSetProp(value, "value", fo->current->value); - } - return value; -} - -static int xml_decode(FilterElement *fe, xmlNodePtr node) -{ - FilterOption *fo = (FilterOption *)fe; - char *value; - - d(printf("Decoding option from xml\n")); - fe->name = xmlGetProp(node, "name"); - value = xmlGetProp(node, "value"); - if (value) { - fo->current = find_option(fo, value); - xmlFree(value); - } else { - fo->current = NULL; - } - return 0; -} - -static void option_activate(GtkMenuItem *item, FilterOption *fo) -{ - fo->current = gtk_object_get_data((GtkObject *)item, "option"); - d(printf("option changed to %s\n", fo->current->title)); -} - -static GtkWidget *get_widget(FilterElement *fe) -{ - FilterOption *fo = (FilterOption *)fe; - GtkMenu *menu; - GtkOptionMenu *omenu; - GtkMenuItem *item; - GList *l = fo->options; - struct _filter_option *op; - int index = 0, current=0; - - menu = (GtkMenu *)gtk_menu_new(); - while (l) { - op = l->data; - item = (GtkMenuItem *)gtk_menu_item_new_with_label(op->title); - gtk_object_set_data((GtkObject *)item, "option", op); - gtk_signal_connect((GtkObject *)item, "activate", option_activate, fo); - gtk_menu_append(menu, (GtkWidget *)item); - gtk_widget_show((GtkWidget *)item); - if (op == fo->current) { - current = index; - } - l = g_list_next(l); - index++; - } - - omenu = (GtkOptionMenu *)gtk_option_menu_new(); - gtk_option_menu_set_menu(omenu, (GtkWidget *)menu); - gtk_option_menu_set_history(omenu, current); - - return (GtkWidget *)omenu; -} - -static void build_code(FilterElement *fe, GString *out, struct _FilterPart *ff) -{ - FilterOption *fo = (FilterOption *)fe; - - d(printf("building option code %p, current = %p\n", fo, fo->current)); - - if (fo->current) { - filter_part_expand_code(ff, fo->current->code, out); - } -} - -static void format_sexp(FilterElement *fe, GString *out) -{ - FilterOption *fo = (FilterOption *)fe; - - if (fo->current) { - e_sexp_encode_string(out, fo->current->value); - } -} - -static FilterElement *clone(FilterElement *fe) -{ - FilterOption *fo = (FilterOption *)fe, *new; - GList *l; - struct _filter_option *fn, *op; - - d(printf("cloning option\n")); - - new = FILTER_OPTION(((FilterElementClass *)(parent_class))->clone(fe)); - l = fo->options; - while (l) { - op = l->data; - fn = g_malloc(sizeof(*fn)); - d(printf(" option %s\n", op->title)); - fn->title = g_strdup(op->title); - fn->value = g_strdup(op->value); - fn->code = g_strdup(op->code); - new->options = g_list_append(new->options, fn); - l = g_list_next(l); - - if (new->current == NULL) - new->current = fn; - } - - d(printf("cloning option code %p, current = %p\n", new, new->current)); - - return (FilterElement *)new; -} diff --git a/filter/filter-option.h b/filter/filter-option.h deleted file mode 100644 index 1bbec79d84..0000000000 --- a/filter/filter-option.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef _FILTER_OPTION_H -#define _FILTER_OPTION_H - -#include - -#include "filter-element.h" - -#define FILTER_OPTION(obj) GTK_CHECK_CAST (obj, filter_option_get_type (), FilterOption) -#define FILTER_OPTION_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, filter_option_get_type (), FilterOptionClass) -#define IS_FILTER_OPTION(obj) GTK_CHECK_TYPE (obj, filter_option_get_type ()) - -typedef struct _FilterOption FilterOption; -typedef struct _FilterOptionClass FilterOptionClass; - -struct _filter_option { - char *title; /* button title */ - char *value; /* value, if it has one */ - char *code; /* used to string code segments together */ -}; - -struct _FilterOption { - FilterElement parent; - struct _FilterOptionPrivate *priv; - - GList *options; - struct _filter_option *current; -}; - -struct _FilterOptionClass { - FilterElementClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - -guint filter_option_get_type (void); -FilterOption *filter_option_new (void); - -/* methods */ -void filter_option_set_current(FilterOption *option, const char *name); - -#endif /* ! _FILTER_OPTION_H */ - diff --git a/filter/filter-part.c b/filter/filter-part.c deleted file mode 100644 index 31394b63fd..0000000000 --- a/filter/filter-part.c +++ /dev/null @@ -1,432 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include - -#include - -#include "filter-part.h" -#include "filter-element.h" - -#define d(x) - -static void filter_part_class_init (FilterPartClass *class); -static void filter_part_init (FilterPart *gspaper); -static void filter_part_finalise (GtkObject *obj); - -#define _PRIVATE(x) (((FilterPart *)(x))->priv) - -struct _FilterPartPrivate { -}; - -static GtkObjectClass *parent_class; - -enum { - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -guint -filter_part_get_type (void) -{ - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "FilterPart", - sizeof(FilterPart), - sizeof(FilterPartClass), - (GtkClassInitFunc)filter_part_class_init, - (GtkObjectInitFunc)filter_part_init, - (GtkArgSetFunc)NULL, - (GtkArgGetFunc)NULL - }; - - type = gtk_type_unique(gtk_object_get_type (), &type_info); - } - - return type; -} - -static void -filter_part_class_init (FilterPartClass *class) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *)class; - parent_class = gtk_type_class(gtk_object_get_type ()); - - object_class->finalize = filter_part_finalise; - /* override methods */ - - /* signals */ - - gtk_object_class_add_signals(object_class, signals, LAST_SIGNAL); -} - -static void -filter_part_init (FilterPart *o) -{ - o->priv = g_malloc0(sizeof(*o->priv)); -} - -static void -filter_part_finalise(GtkObject *obj) -{ - FilterPart *o = (FilterPart *)obj; - - o = o; - - ((GtkObjectClass *)(parent_class))->finalize(obj); -} - -/** - * filter_part_new: - * - * Create a new FilterPart object. - * - * Return value: A new #FilterPart object. - **/ -FilterPart * -filter_part_new(void) -{ - FilterPart *o = (FilterPart *)gtk_type_new(filter_part_get_type ()); - return o; -} - - - -int filter_part_xml_create (FilterPart *ff, xmlNodePtr node) -{ - xmlNodePtr n; - char *type; - FilterElement *el; - - ff->name = xmlGetProp(node, "name"); - n = node->childs; - while (n) { - if (!strcmp(n->name, "input")) { - 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) { - filter_element_xml_create(el, n); - xmlFree(type); - d(printf("adding element part %p %s\n", el, el->name)); - ff->elements = g_list_append(ff->elements, el); - } else { - g_warning("Invalid xml format, missing/unknown input type"); - } - } else if (!strcmp(n->name, "title")) { - if (!ff->title) - ff->title = xmlNodeGetContent(n); - } else if (!strcmp(n->name, "code")) { - if (!ff->code) - ff->code = xmlNodeGetContent(n); - } else { - g_warning("Unknwon part element in xml: %s\n", n->name); - } - n = n->next; - } - return 0; -} - -xmlNodePtr filter_part_xml_encode (FilterPart *fp) -{ - GList *l; - FilterElement *fe; - xmlNodePtr part, value; - - g_return_val_if_fail(fp != NULL, NULL); - - part = xmlNewNode(NULL, "part"); - xmlSetProp(part, "name", fp->name); - l = fp->elements; - while (l) { - fe = l->data; - value = filter_element_xml_encode(fe); - xmlAddChild(part, value); - l = g_list_next(l); - } - return part; -} - -int filter_part_xml_decode (FilterPart *fp, xmlNodePtr node) -{ - FilterElement *fe; - xmlNodePtr n; - char *name; - - g_return_val_if_fail(fp != NULL, -1); - g_return_val_if_fail(node != NULL, -1); - - n = node->childs; - while (n) { - if (!strcmp(n->name, "value")) { - name = xmlGetProp(n, "name"); - d(printf("finding element part %p %s = %p\n", name, name, fe)); - fe = filter_part_find_element(fp, name); - d(printf("finding element part %p %s = %p\n", name, name, fe)); - xmlFree(name); - if (fe) { - filter_element_xml_decode(fe, n); - } - } - n = n->next; - } - return 0; -} - -FilterPart *filter_part_clone (FilterPart *fp) -{ - FilterPart *new; - GList *l; - FilterElement *fe, *ne; - - new = (FilterPart *)gtk_type_new( ((GtkObject *)fp)->klass->type ); - new->name = g_strdup(fp->name); - new->title = g_strdup(fp->title); - new->code = g_strdup(fp->code); - l = fp->elements; - while (l) { - fe = l->data; - ne = filter_element_clone(fe); - new->elements = g_list_append(new->elements, ne); - l = g_list_next(l); - } - return new; -} - -FilterElement *filter_part_find_element(FilterPart *ff, const char *name) -{ - GList *l = ff->elements; - FilterElement *fe; - - if (name == NULL) - return NULL; - - while (l) { - fe = l->data; - if (fe->name && !strcmp(fe->name, name)) - return fe; - l = g_list_next(l); - } - - return NULL; -} - - -GtkWidget *filter_part_get_widget (FilterPart *ff) -{ - GtkHBox *hbox; - GList *l = ff->elements; - FilterElement *fe; - GtkWidget *w; - - hbox = (GtkHBox *)gtk_hbox_new(FALSE, 3); - - while (l) { - fe = l->data; - w = filter_element_get_widget(fe); - if (w) { - gtk_box_pack_start((GtkBox *)hbox, w, FALSE, FALSE, 3); - } - l = g_list_next(l); - } - gtk_widget_show_all((GtkWidget *)hbox); - return (GtkWidget *)hbox; -} - -/** - * filter_part_build_code: - * @ff: - * @out: - * - * Outputs the code of a part. - **/ -void filter_part_build_code (FilterPart *ff, GString *out) -{ - GList *l = ff->elements; - FilterElement *fe; - - if (ff->code) { - filter_part_expand_code(ff, ff->code, out); - } - while (l) { - fe = l->data; - filter_element_build_code(fe, out, ff); - l = g_list_next(l); - } -} - -/** - * filter_part_build_code_list: - * @l: - * @out: - * - * Construct a list of the filter parts code into - * a single string. - **/ -void -filter_part_build_code_list(GList *l, GString *out) -{ - FilterPart *fp; - - while (l) { - fp = l->data; - filter_part_build_code(fp, out); - g_string_append(out, "\n "); - l = g_list_next(l); - } -} - -/** - * filter_part_find_list: - * @l: - * @name: - * - * Find a filter part stored in a list. - * - * Return value: - **/ -FilterPart *filter_part_find_list (GList *l, const char *name) -{ - FilterPart *part; - d(printf("Find part named %s\n", name)); - - while (l) { - part = l->data; - if (!strcmp(part->name, name)) { - d(printf("Found!\n")); - return part; - } - l = g_list_next(l); - } - return NULL; -} - -/** - * filter_part_next_list: - * @l: - * @last: The last item retrieved, or NULL to start - * from the beginning of the list. - * - * Iterate through a filter part list. - * - * Return value: The next value in the list, or NULL if the - * list is expired. - **/ -FilterPart *filter_part_next_list (GList *l, FilterPart *last) -{ - GList *node = l; - - if (last != NULL) { - node = g_list_find(node, last); - if (node == NULL) - node = l; - else - node = g_list_next(node); - } - if (node) - return node->data; - return NULL; -} - -/** - * filter_part_expand_code: - * @ff: - * @str: - * @out: - * - * Expands the variables in string @str based on the values of the part. - **/ -void filter_part_expand_code (FilterPart *ff, const char *source, GString *out) -{ - const char *newstart, *start, *end; - char *name=alloca(32); - int len, namelen=32; - FilterElement *fe; - - start = source; - while ( (newstart = strstr(start, "${")) - && (end = strstr(newstart+2, "}")) ) { - len = end-newstart-2; - if (len+1>namelen) { - namelen = (len+1)*2; - name = alloca(namelen); - } - memcpy(name, newstart+2, len); - name[len] = 0; - fe = filter_part_find_element(ff, name); - d(printf("expand code: looking up variab le '%s' = %p\n", name, fe)); - if (fe) { - g_string_sprintfa(out, "%.*s", newstart-start, start); - filter_element_format_sexp(fe, out); -#if 0 - } else if ( (val = g_hash_table_lookup(ff->globals, name)) ) { - g_string_sprintfa(out, "%.*s", newstart-start, start); - e_sexp_encode_string(out, val); -#endif - } else { - g_string_sprintfa(out, "%.*s", end-start+1, start); - } - start = end+1; - } - g_string_append(out, start); -} - -#if 0 -int main(int argc, char **argv) -{ - xmlDocPtr system; - FilterPart *ff; - GtkWidget *w; - GnomeDialog *gd; - xmlNodePtr node; - GString *code; - - gnome_init("test", "0.0", argc, argv); - - system = xmlParseFile("form.xml"); - if (system==NULL) { - printf("i/o error\n"); - return 1; - } - - ff = filter_part_new(); - filter_part_xml_create(ff, system->root); - - w = filter_part_get_widget(ff); - - gd = (GnomeDialog *)gnome_dialog_new(_("Test"), GNOME_STOCK_BUTTON_OK, NULL); - gtk_box_pack_start((GtkBox *)gd->vbox, w, FALSE, TRUE, 0); - gtk_widget_show((GtkWidget *)gd); - - gnome_dialog_run_and_close(gd); - - code = g_string_new(""); - filter_part_build_code(ff, code); - printf("code is:\n%s\n", code->str); - - return 0; -} -#endif diff --git a/filter/filter-part.h b/filter/filter-part.h deleted file mode 100644 index 2995046b20..0000000000 --- a/filter/filter-part.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef _FILTER_PART_H -#define _FILTER_PART_H - -#include -#include "filter-input.h" - -#define FILTER_PART(obj) GTK_CHECK_CAST (obj, filter_part_get_type (), FilterPart) -#define FILTER_PART_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, filter_part_get_type (), FilterPartClass) -#define IS_FILTER_PART(obj) GTK_CHECK_TYPE (obj, filter_part_get_type ()) - -typedef struct _FilterPart FilterPart; -typedef struct _FilterPartClass FilterPartClass; - -struct _FilterPart { - GtkObject parent; - struct _FilterPartPrivate *priv; - - char *name; - char *title; - char *code; - GList *elements; -}; - -struct _FilterPartClass { - GtkObjectClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - -guint filter_part_get_type (void); -FilterPart *filter_part_new (void); - -/* methods */ -int filter_part_xml_create (FilterPart *ff, xmlNodePtr node); - -xmlNodePtr filter_part_xml_encode (FilterPart *fe); -int filter_part_xml_decode (FilterPart *fe, xmlNodePtr node); - -FilterPart *filter_part_clone (FilterPart *fp); - -FilterElement *filter_part_find_element(FilterPart *ff, const char *name); - -GtkWidget *filter_part_get_widget (FilterPart *ff); -void filter_part_build_code (FilterPart *ff, GString *out); -void filter_part_expand_code (FilterPart *ff, const char *str, GString *out); - -/* static functions */ -void filter_part_build_code_list (GList *l, GString *out); -FilterPart *filter_part_find_list (GList *l, const char *name); -FilterPart *filter_part_next_list (GList *l, FilterPart *last); - -#endif /* ! _FILTER_PART_H */ - diff --git a/filter/filter-rule.c b/filter/filter-rule.c deleted file mode 100644 index 39012b9e54..0000000000 --- a/filter/filter-rule.c +++ /dev/null @@ -1,574 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include - -#include "filter-rule.h" -#include "filter-context.h" - -#define d(x) - -static xmlNodePtr xml_encode(FilterRule *); -static int xml_decode(FilterRule *, xmlNodePtr, RuleContext *); -static void build_code(FilterRule *, GString *out); -static GtkWidget *get_widget(FilterRule *fr, struct _RuleContext *f); - -static void filter_rule_class_init (FilterRuleClass *class); -static void filter_rule_init (FilterRule *gspaper); -static void filter_rule_finalise (GtkObject *obj); - -#define _PRIVATE(x) (((FilterRule *)(x))->priv) - -struct _FilterRulePrivate { - GtkWidget *parts; /* where the parts are stored */ -}; - -static GtkObjectClass *parent_class; - -enum { - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -guint -filter_rule_get_type (void) -{ - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "FilterRule", - sizeof(FilterRule), - sizeof(FilterRuleClass), - (GtkClassInitFunc)filter_rule_class_init, - (GtkObjectInitFunc)filter_rule_init, - (GtkArgSetFunc)NULL, - (GtkArgGetFunc)NULL - }; - - type = gtk_type_unique(gtk_object_get_type (), &type_info); - } - - return type; -} - -static void -filter_rule_class_init (FilterRuleClass *class) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *)class; - parent_class = gtk_type_class(gtk_object_get_type ()); - - object_class->finalize = filter_rule_finalise; - - /* override methods */ - class->xml_encode = xml_encode; - class->xml_decode = xml_decode; - class->build_code = build_code; - class->get_widget = get_widget; - - /* signals */ - - gtk_object_class_add_signals(object_class, signals, LAST_SIGNAL); -} - -static void -filter_rule_init (FilterRule *o) -{ - o->priv = g_malloc0(sizeof(*o->priv)); -} - -static void -unref_list(GList *l) -{ - while (l) { - gtk_object_unref((GtkObject *)l->data); - l = g_list_next(l); - } -} - -static void -filter_rule_finalise(GtkObject *obj) -{ - FilterRule *o = (FilterRule *)obj; - - g_free(o->name); - unref_list(o->parts); - - ((GtkObjectClass *)(parent_class))->finalize(obj); -} - -/** - * filter_rule_new: - * - * Create a new FilterRule object. - * - * Return value: A new #FilterRule object. - **/ -FilterRule * -filter_rule_new(void) -{ - FilterRule *o = (FilterRule *)gtk_type_new(filter_rule_get_type ()); - return o; -} - -void filter_rule_set_name (FilterRule *fr, const char *name) -{ - g_free(fr->name); - fr->name = g_strdup(name); -} - -xmlNodePtr filter_rule_xml_encode (FilterRule *fr) -{ - return ((FilterRuleClass *)((GtkObject *)fr)->klass)->xml_encode(fr); -} - -static xmlNodePtr xml_encode(FilterRule *fr) -{ - xmlNodePtr node, set, work; - GList *l; - - node = xmlNewNode(NULL, "rule"); - switch (fr->grouping) { - case FILTER_GROUP_ALL: - xmlSetProp(node, "grouping", "all"); - break; - case FILTER_GROUP_ANY: - xmlSetProp(node, "grouping", "any"); - break; - } - - switch (fr->source) { - case FILTER_SOURCE_INCOMING: - xmlSetProp(node, "source", "incoming"); - break; - case FILTER_SOURCE_DEMAND: - xmlSetProp(node, "source", "ondemand"); - break; - case FILTER_SOURCE_OUTGOING: - xmlSetProp(node, "source", "outgoing"); - break; - } - - if (fr->name) { - work = xmlNewNode(NULL, "title"); - xmlNodeSetContent(work, fr->name); - xmlAddChild(node, work); - } - set = xmlNewNode(NULL, "partset"); - xmlAddChild(node, set); - l = fr->parts; - while (l) { - work = filter_part_xml_encode((FilterPart *)l->data); - xmlAddChild(set, work); - l = g_list_next(l); - } - return node; -} - -static void load_set(xmlNodePtr node, FilterRule *fr, RuleContext *f) -{ - xmlNodePtr work; - char *rulename; - FilterPart *part; - - work = node->childs; - while (work) { - if (!strcmp(work->name, "part")) { - rulename = xmlGetProp(work, "name"); - part = rule_context_find_part(f, rulename); - if (part) { - part = filter_part_clone(part); - filter_part_xml_decode(part, work); - filter_rule_add_part(fr, part); - } else { - g_warning("cannot find rule part '%s'\n", rulename); - } - xmlFree(rulename); - } else { - g_warning("Unknwon xml node in part: %s", work->name); - } - work = work->next; - } -} - -int filter_rule_xml_decode (FilterRule *fr, xmlNodePtr node, RuleContext *f) -{ - return ((FilterRuleClass *)((GtkObject *)fr)->klass)->xml_decode(fr, node, f); -} - -static int xml_decode(FilterRule *fr, xmlNodePtr node, RuleContext *f) -{ - xmlNodePtr work; - char *grouping; - char *source; - - if (fr->name) { - g_free(fr->name); - fr->name = NULL; - } - - grouping = xmlGetProp(node, "grouping"); - if (!strcmp(grouping, "any")) - fr->grouping = FILTER_GROUP_ANY; - else - fr->grouping = FILTER_GROUP_ALL; - - /* FIXME: free source and grouping? */ - source = xmlGetProp (node, "source"); - if (!source) /*default to incoming*/ - fr->source = FILTER_SOURCE_INCOMING; - else if (!strcmp (source, "outgoing")) - fr->source = FILTER_SOURCE_OUTGOING; - else if (!strcmp (source, "ondemand")) - fr->source = FILTER_SOURCE_DEMAND; - else if (!strcmp (source, "incoming")) - fr->source = FILTER_SOURCE_INCOMING; - else { - g_warning ("Unknown filter source type \"%s\"", source); - fr->source = FILTER_SOURCE_INCOMING; - } - - work = node->childs; - while (work) { - if (!strcmp(work->name, "partset")) { - load_set(work, fr, f); - } else if (!strcmp(work->name, "title")) { - if (!fr->name) - fr->name = xmlNodeGetContent(work); - } - work = work->next; - } - return 0; -} - -void filter_rule_add_part (FilterRule *fr, FilterPart *fp) -{ - fr->parts = g_list_append(fr->parts, fp); -} - -void filter_rule_remove_part (FilterRule *fr, FilterPart *fp) -{ - fr->parts = g_list_remove(fr->parts, fp); -} - -void filter_rule_replace_part(FilterRule *fr, FilterPart *fp, FilterPart *new) -{ - GList *l; - - l = g_list_find(fr->parts, fp); - if (l) { - l->data = new; - } else { - fr->parts = g_list_append(fr->parts, new); - } -} - -void filter_rule_build_code (FilterRule *fr, GString *out) -{ - return ((FilterRuleClass *)((GtkObject *)fr)->klass)->build_code(fr, out); -} - -static void build_code(FilterRule *fr, GString *out) -{ - switch (fr->grouping) { - case FILTER_GROUP_ALL: - g_string_append(out, " (and\n "); - break; - case FILTER_GROUP_ANY: - g_string_append(out, " (or\n "); - break; - default: - g_warning("Invalid grouping"); - } - - filter_part_build_code_list(fr->parts, out); - g_string_append(out, ")\n"); -} - - -static void -match_all(GtkRadioButton *w, FilterRule *fr) -{ - if (gtk_toggle_button_get_active((GtkToggleButton *)w)) - fr->grouping = FILTER_GROUP_ALL; -} - -static void -match_any(GtkRadioButton *w, FilterRule *fr) -{ - if (gtk_toggle_button_get_active((GtkToggleButton *)w)) - fr->grouping = FILTER_GROUP_ANY; -} - -struct _part_data { - FilterRule *fr; - RuleContext *f; - FilterPart *part; - GtkWidget *partwidget, *container; -}; - -static void option_activate(GtkMenuItem *item, struct _part_data *data) -{ - FilterPart *part = gtk_object_get_data((GtkObject *)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((GtkContainer *)data->container, data->partwidget); - newpart = filter_part_clone(part); - filter_rule_replace_part(data->fr, data->part, newpart); - gtk_object_unref((GtkObject *)data->part); - data->part = newpart; - data->partwidget = filter_part_get_widget(newpart); - if (data->partwidget) - gtk_box_pack_start((GtkBox *)data->container, data->partwidget, FALSE, FALSE, 0); -} - -static GtkWidget * -get_rule_part_widget(RuleContext *f, FilterPart *newpart, FilterRule *fr) -{ - FilterPart *part = NULL; - GtkMenu *menu; - GtkMenuItem *item; - GtkOptionMenu *omenu; - GtkHBox *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 = (GtkHBox *)gtk_hbox_new(FALSE, 0); - /* only set to automatically clean up the memory */ - gtk_object_set_data_full((GtkObject *)hbox, "data", data, g_free); - - p = filter_part_get_widget(newpart); - - data->partwidget = p; - data->container = (GtkWidget *)hbox; - - menu = (GtkMenu *)gtk_menu_new(); - /* sigh, this is a little ugly */ - while ((part=rule_context_next_part(f, part))) { - item = (GtkMenuItem *)gtk_menu_item_new_with_label(part->title); - gtk_object_set_data((GtkObject *)item, "part", part); - gtk_signal_connect((GtkObject *)item, "activate", option_activate, data); - gtk_menu_append(menu, (GtkWidget *)item); - gtk_widget_show((GtkWidget *)item); - if (!strcmp(newpart->title, part->title)) { - current = index; - } - index++; - } - - omenu = (GtkOptionMenu *)gtk_option_menu_new(); - gtk_option_menu_set_menu(omenu, (GtkWidget *)menu); - gtk_option_menu_set_history(omenu, current); - gtk_widget_show((GtkWidget *)omenu); - - gtk_box_pack_start((GtkBox *)hbox, (GtkWidget *)omenu, FALSE, FALSE, 0); - if (p) { - gtk_box_pack_start((GtkBox *)hbox, p, FALSE, FALSE, 0); - } - gtk_widget_show_all((GtkWidget *)hbox); - - return (GtkWidget *)hbox; -} - -struct _rule_data { - FilterRule *fr; - RuleContext *f; - GtkWidget *parts; -}; - -static void -less_parts(GtkWidget *button, struct _rule_data *data) -{ - GList *l; - FilterPart *part; - GtkWidget *w; - - l = data->fr->parts; - if (g_list_length(l) < 2) - return; - - /* remove the last one from the list */ - l = g_list_last(l); - part = l->data; - filter_rule_remove_part(data->fr, part); - gtk_object_unref((GtkObject *)part); - - /* and from the display */ - l = g_list_last(GTK_BOX(data->parts)->children); - w = ((GtkBoxChild *)l->data)->widget; - gtk_container_remove((GtkContainer *)data->parts, w); -} - -static void -more_parts(GtkWidget *button, struct _rule_data *data) -{ - FilterPart *new; - GtkWidget *w; - - /* create a new rule entry, use the first type of rule */ - new = rule_context_next_part(data->f, NULL); - if (new) { - new = filter_part_clone(new); - filter_rule_add_part(data->fr, new); - w = get_rule_part_widget(data->f, new, data->fr); - gtk_box_pack_start((GtkBox *)data->parts, w, FALSE, FALSE, 0); - } -} - -static void -name_changed(GtkEntry *entry, FilterRule *fr) -{ - g_free(fr->name); - fr->name = g_strdup(gtk_entry_get_text(entry)); -} - -GtkWidget *filter_rule_get_widget (FilterRule *fr, struct _RuleContext *f) -{ - return ((FilterRuleClass *)((GtkObject *)fr)->klass)->get_widget(fr, f); -} - -static GtkWidget *get_widget(FilterRule *fr, struct _RuleContext *f) -{ - GtkVBox *vbox, *parts, *inframe; - GtkHBox *hbox; - GtkWidget *w; - GtkRadioButton *g0, *g1; - GtkFrame *frame; - GtkEntry *name; - GtkLabel *label; - GList *l; - FilterPart *part; - struct _rule_data *data; - - /* this stuff should probably be a table, but the - rule parts need to be a vbox */ - vbox = (GtkVBox *)gtk_vbox_new(FALSE, 3); - - label = (GtkLabel *)gtk_label_new("Name"); - name = (GtkEntry *)gtk_entry_new(); - if (fr->name) - gtk_entry_set_text(name, fr->name); - hbox = (GtkHBox *)gtk_hbox_new(FALSE, 3); - gtk_box_pack_start((GtkBox *)hbox, (GtkWidget *)label, FALSE, FALSE, 0); - gtk_box_pack_start((GtkBox *)hbox, (GtkWidget *)name, TRUE, TRUE, 0); - gtk_box_pack_start((GtkBox *)vbox, (GtkWidget *)hbox, FALSE, FALSE, 3); - gtk_signal_connect((GtkObject *)name, "changed", name_changed, fr); - - frame = (GtkFrame *)gtk_frame_new("Messages matching"); - inframe = (GtkVBox *)gtk_vbox_new(FALSE, 3); - gtk_container_add((GtkContainer *)frame, (GtkWidget *)inframe); - - hbox = (GtkHBox *)gtk_hbox_new(FALSE, 3); - g0 = (GtkRadioButton *)gtk_radio_button_new_with_label(NULL, "Match all parts"); - g1 = (GtkRadioButton *)gtk_radio_button_new_with_label(g0->group, "Match any part"); - if (fr->grouping == FILTER_GROUP_ALL) { - gtk_toggle_button_set_active((GtkToggleButton *)g0, TRUE); - } else { - gtk_toggle_button_set_active((GtkToggleButton *)g1, TRUE); - } - gtk_box_pack_start((GtkBox *)hbox, (GtkWidget *)g0, FALSE, FALSE, 0); - gtk_box_pack_start((GtkBox *)hbox, (GtkWidget *)g1, FALSE, FALSE, 0); - gtk_box_pack_start((GtkBox *)inframe, (GtkWidget *)hbox, FALSE, FALSE, 3); - - gtk_signal_connect((GtkObject *)g0, "toggled", match_all, fr); - gtk_signal_connect((GtkObject *)g1, "toggled", match_any, fr); - - /* this is the parts list, it should probably be inside a scrolling list */ - parts = (GtkVBox *)gtk_vbox_new(FALSE, 3); - - /* data for the parts part of the display */ - data = g_malloc0(sizeof(*data)); - data->f = f; - data->fr = fr; - data->parts = (GtkWidget *)parts; - - /* only set to automatically clean up the memory */ - gtk_object_set_data_full((GtkObject *)vbox, "data", data, g_free); - - l = fr->parts; - while (l) { - part = l->data; - w = get_rule_part_widget(f, part, fr); - gtk_box_pack_start((GtkBox *)parts, (GtkWidget *)w, FALSE, FALSE, 3); - l = g_list_next(l); - } - - gtk_box_pack_start((GtkBox *)inframe, (GtkWidget *)parts, FALSE, FALSE, 3); - - hbox = (GtkHBox *)gtk_hbox_new(FALSE, 3); - w = gtk_button_new_with_label(_("Less")); - gtk_signal_connect((GtkObject *)w, "clicked", less_parts, data); - gtk_box_pack_end((GtkBox *)hbox, (GtkWidget *)w, FALSE, FALSE, 3); - w = gtk_button_new_with_label(_("More")); - gtk_signal_connect((GtkObject *)w, "clicked", more_parts, data); - gtk_box_pack_end((GtkBox *)hbox, (GtkWidget *)w, FALSE, FALSE, 3); - gtk_box_pack_start((GtkBox *)inframe, (GtkWidget *)hbox, FALSE, FALSE, 3); - - gtk_box_pack_start((GtkBox *)vbox, (GtkWidget *)frame, FALSE, FALSE, 3); - - gtk_widget_show_all((GtkWidget *)vbox); - return (GtkWidget *)vbox; -} - -FilterRule *filter_rule_next_list (GList *l, FilterRule *last) -{ - GList *node = l; - - if (last != NULL) { - node = g_list_find(node, last); - if (node == NULL) - node = l; - else - node = g_list_next(node); - } - if (node) - return node->data; - return NULL; -} - -FilterRule *filter_rule_find_list (GList *l, const char *name) -{ - while (l) { - FilterRule *rule = l->data; - if (!strcmp(rule->name, name)) - return rule; - l = g_list_next(l); - } - return NULL; -} - diff --git a/filter/filter-rule.h b/filter/filter-rule.h deleted file mode 100644 index 425d0ac350..0000000000 --- a/filter/filter-rule.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef _FILTER_RULE_H -#define _FILTER_RULE_H - -#include - -#include "filter-part.h" - -#define FILTER_RULE(obj) GTK_CHECK_CAST (obj, filter_rule_get_type (), FilterRule) -#define FILTER_RULE_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, filter_rule_get_type (), FilterRuleClass) -#define IS_FILTER_RULE(obj) GTK_CHECK_TYPE (obj, filter_rule_get_type ()) - -typedef struct _FilterRule FilterRule; -typedef struct _FilterRuleClass FilterRuleClass; - -struct _RuleContext; - -enum _filter_grouping_t { - FILTER_GROUP_ALL, /* all rules must match */ - FILTER_GROUP_ANY /* any rule must match */ -}; - -enum _filter_source_t { - FILTER_SOURCE_INCOMING, /* performed on incoming email */ - FILTER_SOURCE_DEMAND, /* performed on the selected folder - * when the user asks for it */ - FILTER_SOURCE_OUTGOING /* performed on outgoing mail */ -}; - -struct _FilterRule { - GtkObject parent; - struct _FilterRulePrivate *priv; - - char *name; - - enum _filter_grouping_t grouping; - enum _filter_source_t source; - GList *parts; -}; - -struct _FilterRuleClass { - GtkObjectClass parent_class; - - /* virtual methods */ - xmlNodePtr (*xml_encode)(FilterRule *); - int (*xml_decode)(FilterRule *, xmlNodePtr, struct _RuleContext *); - - void (*build_code)(FilterRule *, GString *out); - - GtkWidget *(*get_widget)(FilterRule *fr, struct _RuleContext *f); - - /* signals */ -}; - -guint filter_rule_get_type (void); -FilterRule *filter_rule_new (void); - -/* methods */ -void filter_rule_set_name (FilterRule *fr, const char *name); - -xmlNodePtr filter_rule_xml_encode (FilterRule *fr); -int filter_rule_xml_decode (FilterRule *fr, xmlNodePtr node, struct _RuleContext *f); - -void filter_rule_add_part (FilterRule *fr, FilterPart *fp); -void filter_rule_remove_part (FilterRule *fr, FilterPart *fp); -void filter_rule_replace_part(FilterRule *fr, FilterPart *fp, FilterPart *new); - -GtkWidget *filter_rule_get_widget (FilterRule *fr, struct _RuleContext *f); - -void filter_rule_build_code (FilterRule *fr, GString *out); -/* -void filter_rule_build_action(FilterRule *fr, GString *out); -*/ - -/* static functions */ -FilterRule *filter_rule_next_list (GList *l, FilterRule *last); -FilterRule *filter_rule_find_list (GList *l, const char *name); - -#endif /* ! _FILTER_RULE_H */ - diff --git a/filter/filter.glade b/filter/filter.glade deleted file mode 100644 index 5f8a04d64e..0000000000 --- a/filter/filter.glade +++ /dev/null @@ -1,702 +0,0 @@ - - - - - Filter - filter - - src - pixmaps - C - True - True - - - - GnomeDialog - edit_filter - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - False - False - False - False - - - GtkVBox - GnomeDialog:vbox - dialog-vbox1 - False - 8 - - 4 - True - True - - - - GtkHButtonBox - GnomeDialog:action_area - dialog-action_area1 - GTK_BUTTONBOX_END - 8 - 85 - 27 - 7 - 0 - - 0 - False - True - GTK_PACK_END - - - - GtkButton - button1 - True - True - GNOME_STOCK_BUTTON_OK - - - - GtkButton - button3 - True - True - GNOME_STOCK_BUTTON_CANCEL - - - - - GtkOptionMenu - filter_source - True - Incoming -On Demand - - 0 - - 0 - False - False - - - - - GtkFrame - frame1 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - True - True - - - - GtkHBox - hbox1 - False - 0 - - - GtkScrolledWindow - scrolledwindow1 - 256 - GTK_POLICY_ALWAYS - GTK_POLICY_ALWAYS - GTK_UPDATE_CONTINUOUS - GTK_UPDATE_CONTINUOUS - - 0 - True - True - - - - GtkViewport - viewport1 - GTK_SHADOW_IN - - - GtkList - rule_list - GTK_SELECTION_SINGLE - - - - - - GtkVBox - vbox1 - False - 0 - - 0 - False - False - - - - GtkVButtonBox - vbuttonbox1 - GTK_BUTTONBOX_DEFAULT_STYLE - 0 - 85 - 27 - 6 - 0 - - 0 - False - False - - - - GtkButton - rule_add - True - True - - - - - GtkButton - rule_edit - True - True - - - - - GtkButton - rule_delete - True - True - - - - - GtkButton - rule_up - True - True - GNOME_STOCK_BUTTON_UP - - - - GtkButton - rule_down - True - True - GNOME_STOCK_BUTTON_DOWN - - - - - - - - - - GnomeDialog - edit_vfolder - Edit VFolders - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - False - False - False - False - - - GtkVBox - GnomeDialog:vbox - dialog-vbox2 - False - 8 - - 4 - True - True - - - - GtkHButtonBox - GnomeDialog:action_area - dialog-action_area2 - GTK_BUTTONBOX_END - 8 - 85 - 27 - 7 - 0 - - 0 - False - True - GTK_PACK_END - - - - GtkButton - button13 - True - True - GNOME_STOCK_BUTTON_OK - - - - GtkButton - button15 - True - True - GNOME_STOCK_BUTTON_CANCEL - - - - - GtkFrame - frame2 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - True - True - - - - GtkHBox - hbox2 - False - 0 - - - GtkScrolledWindow - scrolledwindow2 - 256 - 167 - GTK_POLICY_ALWAYS - GTK_POLICY_ALWAYS - GTK_UPDATE_CONTINUOUS - GTK_UPDATE_CONTINUOUS - - 0 - True - True - - - - GtkViewport - viewport2 - GTK_SHADOW_IN - - - GtkList - rule_list - GTK_SELECTION_SINGLE - - - - - - GtkVBox - vbox2 - False - 0 - - 0 - False - False - - - - GtkVButtonBox - vbuttonbox2 - GTK_BUTTONBOX_DEFAULT_STYLE - 0 - 85 - 27 - 6 - 0 - - 0 - False - False - - - - GtkButton - rule_add - True - True - - - - - GtkButton - rule_edit - True - True - - - - - GtkButton - rule_delete - True - True - - - - - GtkButton - rule_up - True - True - GNOME_STOCK_BUTTON_UP - - - - GtkButton - rule_down - True - True - GNOME_STOCK_BUTTON_DOWN - - - - - - - - - - GnomeDialog - vfolder_source - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - False - False - False - False - - - GtkVBox - GnomeDialog:vbox - dialog-vbox3 - False - 8 - - 4 - True - True - - - - GtkHButtonBox - GnomeDialog:action_area - dialog-action_area3 - GTK_BUTTONBOX_END - 8 - 85 - 27 - 7 - 0 - - 0 - False - True - GTK_PACK_END - - - - GtkButton - button16 - True - True - GNOME_STOCK_BUTTON_OK - - - - GtkButton - button17 - True - True - GNOME_STOCK_BUTTON_APPLY - - - - GtkButton - button18 - True - True - GNOME_STOCK_BUTTON_CANCEL - - - - - GtkFrame - vfolder_source_frame - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - True - True - - - - GtkHBox - hbox3 - False - 0 - - - GtkScrolledWindow - scrolledwindow3 - 256 - 125 - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_UPDATE_CONTINUOUS - GTK_UPDATE_CONTINUOUS - - 0 - True - True - - - - GtkViewport - viewport3 - GTK_SHADOW_IN - - - GtkList - source_list - GTK_SELECTION_SINGLE - - - - - - GtkVBox - vbox3 - False - 0 - - 0 - False - False - - - - GtkVButtonBox - vbuttonbox3 - GTK_BUTTONBOX_DEFAULT_STYLE - 0 - 85 - 27 - 6 - 0 - - 0 - False - False - - - - GtkButton - source_add - True - True - - - - - GtkButton - source_remove - True - True - - - - - - - - - - - GnomeDialog - vfolder_source - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - False - False - False - False - - - GtkVBox - GnomeDialog:vbox - dialog-vbox3 - False - 8 - - 4 - True - True - - - - GtkHButtonBox - GnomeDialog:action_area - dialog-action_area3 - GTK_BUTTONBOX_END - 8 - 85 - 27 - 7 - 0 - - 0 - False - True - GTK_PACK_END - - - - GtkButton - button16 - True - True - GNOME_STOCK_BUTTON_OK - - - - GtkButton - button17 - True - True - GNOME_STOCK_BUTTON_APPLY - - - - GtkButton - button18 - True - True - GNOME_STOCK_BUTTON_CANCEL - - - - - GtkFrame - vfolder_source_frame - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - True - True - - - - GtkHBox - hbox3 - False - 0 - - - GtkScrolledWindow - scrolledwindow3 - 256 - 125 - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_UPDATE_CONTINUOUS - GTK_UPDATE_CONTINUOUS - - 0 - True - True - - - - GtkViewport - viewport3 - GTK_SHADOW_IN - - - GtkList - source_list - GTK_SELECTION_SINGLE - - - - - - GtkVBox - vbox3 - False - 0 - - 0 - False - False - - - - GtkVButtonBox - vbuttonbox3 - GTK_BUTTONBOX_DEFAULT_STYLE - 0 - 85 - 27 - 6 - 0 - - 0 - False - False - - - - GtkButton - source_add - True - True - - - - - GtkButton - source_remove - True - True - - - - - - - - - - diff --git a/filter/filtertypes.xml b/filter/filtertypes.xml deleted file mode 100644 index 0c38ce575c..0000000000 --- a/filter/filtertypes.xml +++ /dev/null @@ -1,177 +0,0 @@ - - - - - Sender - - - - - - - - Recipients - - - - - - - - Subject - - - - - - - - Message Body - - - - - - - - Expression - - - - - Message was sent - - - - - - - - - - - - Message was received - - - - - - - - - - - - - - - - Copy to Folder - (copy-to ${folder}) - - - - Forward to address - (forward-to ${address}) - - - - Delete - (delete) - - - Stop processing - (stop) - - - Assign Colour - (set-colour ${colour}) - - - - - - - - - diff --git a/filter/rule-context.c b/filter/rule-context.c deleted file mode 100644 index 653627a550..0000000000 --- a/filter/rule-context.c +++ /dev/null @@ -1,427 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include - -#include "rule-context.h" - -#define d(x) x - -static int load(RuleContext *f, const char *system, const char *user, - RCRegisterFunc on_demand_cb, gpointer user_data); -static int save(RuleContext *f, const char *user); - -static void rule_context_class_init (RuleContextClass *class); -static void rule_context_init (RuleContext *gspaper); -static void rule_context_finalise (GtkObject *obj); - -#define _PRIVATE(x) (((RuleContext *)(x))->priv) - -struct _RuleContextPrivate { -}; - -static GtkObjectClass *parent_class; - -enum { - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -guint -rule_context_get_type (void) -{ - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "RuleContext", - sizeof(RuleContext), - sizeof(RuleContextClass), - (GtkClassInitFunc)rule_context_class_init, - (GtkObjectInitFunc)rule_context_init, - (GtkArgSetFunc)NULL, - (GtkArgGetFunc)NULL - }; - - type = gtk_type_unique(gtk_object_get_type (), &type_info); - } - - return type; -} - -static void -rule_context_class_init (RuleContextClass *class) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *)class; - parent_class = gtk_type_class(gtk_object_get_type ()); - - object_class->finalize = rule_context_finalise; - - /* override methods */ - class->load = load; - class->save = save; - - /* signals */ - - gtk_object_class_add_signals(object_class, signals, LAST_SIGNAL); -} - -static void -rule_context_init (RuleContext *o) -{ - o->priv = g_malloc0(sizeof(*o->priv)); - - o->part_set_map = g_hash_table_new(g_str_hash, g_str_equal); - o->rule_set_map = g_hash_table_new(g_str_hash, g_str_equal); -} - -static void -rule_context_finalise(GtkObject *obj) -{ - RuleContext *o = (RuleContext *)obj; - - o = o; - - ((GtkObjectClass *)(parent_class))->finalize(obj); -} - -/** - * rule_context_new: - * - * Create a new RuleContext object. - * - * Return value: A new #RuleContext object. - **/ -RuleContext * -rule_context_new(void) -{ - RuleContext *o = (RuleContext *)gtk_type_new(rule_context_get_type ()); - return o; -} - -void rule_context_add_part_set(RuleContext *f, const char *setname, int part_type, RCPartFunc append, RCNextPartFunc next) -{ - struct _part_set_map *map; - - map = g_malloc0(sizeof(*map)); - map->type = part_type; - map->append = append; - map->next = next; - map->name = g_strdup(setname); - g_hash_table_insert(f->part_set_map, map->name, map); - f->part_set_list = g_list_append(f->part_set_list, map); - d(printf("adding part set '%s'\n", setname)); -} - -void rule_context_add_rule_set(RuleContext *f, const char *setname, int rule_type, RCRuleFunc append, RCNextRuleFunc next) -{ - struct _rule_set_map *map; - - map = g_malloc0(sizeof(*map)); - map->type = rule_type; - map->append = append; - map->next = next; - map->name = g_strdup(setname); - g_hash_table_insert(f->rule_set_map, map->name, map); - f->rule_set_list = g_list_append(f->rule_set_list, map); - d(printf("adding rule set '%s'\n", setname)); -} - -/** - * rule_context_set_error: - * @f: - * @error: - * - * Set the text error for the context, or NULL to clear it. - **/ -static void -rule_context_set_error(RuleContext *f, char *error) -{ - g_free(f->error); - f->error = error; -} - -/** - * rule_context_load: - * @f: - * @system: - * @user: - * @on_demand_cb: An optional callback to allow UI registration of on-demand rules - * @user_data: Extra data for the callback - * - * Load a rule context from a system and user description file. - * - * Return value: - **/ -int rule_context_load(RuleContext *f, const char *system, const char *user, - RCRegisterFunc on_demand_cb, gpointer user_data ) -{ - printf("rule_context: loading %s %s\n", system, user); - - return ((RuleContextClass *)((GtkObject *)f)->klass)->load(f, system, user, - on_demand_cb, - user_data); -} - -static int load(RuleContext *f, const char *system, const char *user, - RCRegisterFunc on_demand_cb, gpointer user_data) -{ - xmlNodePtr set, rule; - struct _part_set_map *part_map; - struct _rule_set_map *rule_map; - - rule_context_set_error(f, NULL); - - d(printf("loading rules %s %s\n", system, user)); - - f->system = xmlParseFile(system); - if (f->system == NULL) { - rule_context_set_error(f, g_strdup_printf("Unable to load system rules '%s': %s", - system, strerror(errno))); - return -1; - } - if (strcmp(f->system->root->name, "filterdescription")) { - rule_context_set_error(f, g_strdup_printf("Unable to load system rules '%s': Invalid format", - system)); - xmlFreeDoc(f->system); - f->system = NULL; - return -1; - } - /* doesn't matter if this doens't exist */ - f->user = xmlParseFile(user); - - /* now parse structure */ - /* get rule parts */ - set = f->system->root->childs; - while (set) { - d(printf("set name = %s\n", set->name)); - part_map = g_hash_table_lookup(f->part_set_map, set->name); - if (part_map) { - d(printf("loading parts ...\n")); - rule = set->childs; - while (rule) { - if (!strcmp(rule->name, "part")) { - FilterPart *part = FILTER_PART(gtk_type_new(part_map->type)); - if (filter_part_xml_create(part, rule) == 0) { - part_map->append(f, part); - } else { - gtk_object_unref((GtkObject *)part); - g_warning("Cannot load filter part"); - } - } - rule = rule->next; - } - } - set = set->next; - } - - /* now load actual rules */ - if (f->user) { - set = f->user->root->childs; - while (set) { - d(printf("set name = %s\n", set->name)); - rule_map = g_hash_table_lookup(f->rule_set_map, set->name); - if (rule_map) { - d(printf("loading rules ...\n")); - rule = set->childs; - while (rule) { - printf("checking node: %s\n", rule->name); - if (!strcmp(rule->name, "rule")) { - FilterRule *part = FILTER_RULE(gtk_type_new(rule_map->type)); - if (filter_rule_xml_decode(part, rule, f) == 0) { - rule_map->append(f, part); - - if (on_demand_cb && part->source == FILTER_SOURCE_DEMAND) - (on_demand_cb) (f, part, user_data); - } else { - gtk_object_unref((GtkObject *)part); - g_warning("Cannot load filter part"); - } - } - rule = rule->next; - } - } - set = set->next; - } - } - return 0; -} - -/** - * rule_context_save: - * @f: - * @user: - * - * Save a rule context to disk. - * - * Return value: - **/ -int rule_context_save(RuleContext *f, const char *user) -{ - return ((RuleContextClass *)((GtkObject *)f)->klass)->save(f, user); -} - -static int save(RuleContext *f, const char *user) -{ - xmlDocPtr doc; - xmlNodePtr root, rules, work; - GList *l; - FilterRule *rule; - struct _rule_set_map *map; - - doc = xmlNewDoc("1.0"); - root = xmlNewDocNode(doc, NULL, "filteroptions", NULL); - xmlDocSetRootElement(doc, root); - l = f->rule_set_list; - while (l) { - map = l->data; - rules = xmlNewDocNode(doc, NULL, map->name, NULL); - xmlAddChild(root, rules); - rule = NULL; - while ( (rule = map->next(f, rule)) ) { - d(printf("processing rule %s\n", rule->name)); - work = filter_rule_xml_encode(rule); - xmlAddChild(rules, work); - } - l = g_list_next(l); - } - xmlSaveFile(user, doc); - xmlFreeDoc(doc); - return 0; -} - -FilterPart *rule_context_find_part(RuleContext *f, const char *name) -{ - d(printf("find part : ")); - return filter_part_find_list(f->parts, name); -} - -FilterPart *rule_context_create_part(RuleContext *f, const char *name) -{ - FilterPart *part; - - part = rule_context_find_part(f, name); - if (part) - part = filter_part_clone(part); - return part; -} - -FilterPart *rule_context_next_part(RuleContext *f, FilterPart *last) -{ - return filter_part_next_list(f->parts, last); -} - -FilterRule *rule_context_next_rule(RuleContext *f, FilterRule *last) -{ - return filter_rule_next_list(f->rules, last); -} - -FilterRule *rule_context_find_rule(RuleContext *f, const char *name) -{ - return filter_rule_find_list(f->rules, name); -} - -void rule_context_add_part(RuleContext *f, FilterPart *part) -{ - f->parts = g_list_append(f->parts, part); -} - -void rule_context_add_rule(RuleContext *f, FilterRule *new) -{ - f->rules = g_list_append(f->rules, new); -} - -static void -new_rule_clicked(GtkWidget *w, int button, RuleContext *context) -{ -#ifndef NO_WARNINGS -#warning "Need a changed signal for this to work best" -#endif - if (button == 0) { - FilterRule *rule = gtk_object_get_data((GtkObject *)w, "rule"); - char *user = gtk_object_get_data((GtkObject *)w, "path"); - - gtk_object_ref((GtkObject *)rule); - rule_context_add_rule(context, rule); - if (user) { - rule_context_save((RuleContext *)context, user); - } - } - if (button != -1) { - gnome_dialog_close((GnomeDialog *)w); - } -} - -/* add a rule, with a gui, asking for confirmation first ... optionally save to path */ -void rule_context_add_rule_gui(RuleContext *f, FilterRule *rule, const char *title, const char *path) -{ - GtkWidget *w; - GnomeDialog *gd; - - w = filter_rule_get_widget(rule, f); - gd = (GnomeDialog *)gnome_dialog_new(title, GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_CANCEL, NULL); - gtk_box_pack_start((GtkBox *)gd->vbox, w, FALSE, TRUE, 0); - gtk_widget_show((GtkWidget *)gd); - gtk_object_set_data_full((GtkObject *)gd, "rule", rule, (GtkDestroyNotify)gtk_object_unref); - if (path) - gtk_object_set_data_full((GtkObject *)gd, "path", g_strdup(path), (GtkDestroyNotify)g_free); - gtk_signal_connect((GtkObject *)gd, "clicked", new_rule_clicked, f); - gtk_object_ref((GtkObject *)f); - gtk_object_set_data_full((GtkObject *)gd, "context", f, (GtkDestroyNotify)gtk_object_unref); - gtk_widget_show((GtkWidget *)gd); -} - -void rule_context_remove_rule(RuleContext *f, FilterRule *rule) -{ - f->rules = g_list_remove(f->rules, rule); -} - -void rule_context_rank_rule(RuleContext *f, FilterRule *rule, int rank) -{ - f->rules = g_list_remove(f->rules, rule); - f->rules = g_list_insert(f->rules, rule, rank); -} - -int rule_context_get_rank_rule(RuleContext *f, FilterRule *rule) -{ - return g_list_index(f->rules, rule); -} - -int -rule_context_get_rank_rule_with_source(RuleContext *f, FilterRule *rule, enum _filter_source_t source) -{ - int i; - GList *iter; - - i = 0; - for (iter = f->rules; iter; iter = iter->next) { - if (iter->data == rule) - return i; - if (((FilterRule *)iter->data)->source == source) - i++; - } - - return -1; -} diff --git a/filter/rule-context.h b/filter/rule-context.h deleted file mode 100644 index 27078adbcf..0000000000 --- a/filter/rule-context.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef _RULE_CONTEXT_H -#define _RULE_CONTEXT_H - -#include -#include - -#include "filter-part.h" -#include "filter-rule.h" - -#define RULE_CONTEXT(obj) GTK_CHECK_CAST (obj, rule_context_get_type (), RuleContext) -#define RULE_CONTEXT_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, rule_context_get_type (), RuleContextClass) -#define IS_RULE_CONTEXT(obj) GTK_CHECK_TYPE (obj, rule_context_get_type ()) - -typedef struct _RuleContext RuleContext; -typedef struct _RuleContextClass RuleContextClass; - -struct _RuleContext { - GtkObject parent; - struct _RuleContextPrivate *priv; - - char *error; /* string version of error */ - - xmlDocPtr system; /* system rules source */ - xmlDocPtr user; /* user defined rules source */ - - GList *parts; - GList *rules; - - GHashTable *part_set_map;/* map set types to part types */ - GList *part_set_list; - GHashTable *rule_set_map;/* map set types to rule types */ - GList *rule_set_list; -}; - -typedef void (*RCRegisterFunc)(RuleContext *f, FilterRule *rule, gpointer data); - -struct _RuleContextClass { - GtkObjectClass parent_class; - - /* virtual methods */ - int (*load)(RuleContext *f, const char *system, const char *user, - RCRegisterFunc on_demand_cb, gpointer user_data); - int (*save)(RuleContext *f, const char *user); - - /* signals */ -}; - -typedef void (*RCPartFunc)(RuleContext *f, FilterPart *part); -typedef void (*RCRuleFunc)(RuleContext *f, FilterRule *part); -typedef FilterPart * (*RCNextPartFunc)(RuleContext *f, FilterPart *part); -typedef FilterRule * (*RCNextRuleFunc)(RuleContext *f, FilterRule *rule); - -struct _part_set_map { - char *name; - int type; - RCPartFunc append; - RCNextPartFunc next; -}; - -struct _rule_set_map { - char *name; - int type; - RCRuleFunc append; - RCNextRuleFunc next; -}; - -guint rule_context_get_type (void); -RuleContext *rule_context_new (void); - -/* methods */ -int rule_context_load(RuleContext *f, const char *system, const char *user, - RCRegisterFunc on_demand_cb, gpointer user_data); -int rule_context_save(RuleContext *f, const char *user); - -void rule_context_add_part(RuleContext *f, FilterPart *new); -FilterPart *rule_context_find_part(RuleContext *f, const char *name); -FilterPart *rule_context_create_part(RuleContext *f, const char *name); -FilterPart *rule_context_next_part(RuleContext *f, FilterPart *last); - -FilterRule *rule_context_next_rule(RuleContext *f, FilterRule *last); -FilterRule *rule_context_find_rule(RuleContext *f, const char *name); -void rule_context_add_rule(RuleContext *f, FilterRule *new); -void rule_context_add_rule_gui(RuleContext *f, FilterRule *rule, const char *title, const char *path); -void rule_context_remove_rule(RuleContext *f, FilterRule *rule); - -/* get/set the rank (position) of a rule */ -void rule_context_rank_rule(RuleContext *f, FilterRule *rule, int rank); -int rule_context_get_rank_rule(RuleContext *f, FilterRule *rule); -int rule_context_get_rank_rule_with_source(RuleContext *f, FilterRule *rule, enum _filter_source_t source); - -void rule_context_delete_rule(RuleContext *f, FilterRule *rule); - -/* setup type for set parts */ -void rule_context_add_part_set(RuleContext *f, const char *setname, int part_type, RCPartFunc append, RCNextPartFunc next); -void rule_context_add_rule_set(RuleContext *f, const char *setname, int rule_type, RCRuleFunc append, RCNextRuleFunc next); - -#endif /* ! _RULE_CONTEXT_H */ - diff --git a/filter/score-context.c b/filter/score-context.c deleted file mode 100644 index a171bd1240..0000000000 --- a/filter/score-context.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include - -#include "score-context.h" -#include "score-rule.h" - -static void score_context_class_init (ScoreContextClass *class); -static void score_context_init (ScoreContext *gspaper); -static void score_context_finalise (GtkObject *obj); - -static RuleContextClass *parent_class; - -guint -score_context_get_type (void) -{ - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "ScoreContext", - sizeof(ScoreContext), - sizeof(ScoreContextClass), - (GtkClassInitFunc)score_context_class_init, - (GtkObjectInitFunc)score_context_init, - (GtkArgSetFunc)NULL, - (GtkArgGetFunc)NULL - }; - - type = gtk_type_unique(rule_context_get_type (), &type_info); - } - - return type; -} - -static void -score_context_class_init (ScoreContextClass *class) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *)class; - parent_class = gtk_type_class(rule_context_get_type ()); - - object_class->finalize = score_context_finalise; - /* override methods */ - -} - -static void -score_context_init (ScoreContext *o) -{ - rule_context_add_part_set((RuleContext *)o, "partset", filter_part_get_type(), - rule_context_add_part, rule_context_next_part); - - rule_context_add_rule_set((RuleContext *)o, "ruleset", score_rule_get_type(), - rule_context_add_rule, rule_context_next_rule); -} - -static void -score_context_finalise(GtkObject *obj) -{ - ScoreContext *o = (ScoreContext *)obj; - - o = o; - - ((GtkObjectClass *)(parent_class))->finalize(obj); -} - -/** - * score_context_new: - * - * Create a new ScoreContext object. - * - * Return value: A new #ScoreContext object. - **/ -ScoreContext * -score_context_new(void) -{ - ScoreContext *o = (ScoreContext *)gtk_type_new(score_context_get_type ()); - return o; -} diff --git a/filter/score-context.h b/filter/score-context.h deleted file mode 100644 index b89f70c1f8..0000000000 --- a/filter/score-context.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef _SCORE_CONTEXT_H -#define _SCORE_CONTEXT_H - -#include - -#include "rule-context.h" - -#define SCORE_CONTEXT(obj) GTK_CHECK_CAST (obj, score_context_get_type (), ScoreContext) -#define SCORE_CONTEXT_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, score_context_get_type (), ScoreContextClass) -#define IS_SCORE_CONTEXT(obj) GTK_CHECK_TYPE (obj, score_context_get_type ()) - -typedef struct _ScoreContext ScoreContext; -typedef struct _ScoreContextClass ScoreContextClass; - -struct _ScoreContext { - RuleContext parent; -}; - -struct _ScoreContextClass { - RuleContextClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - -guint 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 6598cd9e33..0000000000 --- a/filter/score-editor.c +++ /dev/null @@ -1,313 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include - -#include "score-editor.h" -#include "score-context.h" -#include "score-rule.h" - -#define d(x) - -#if 0 -static void score_editor_class_init (ScoreEditorClass *class); -static void score_editor_init (ScoreEditor *gspaper); - -static GnomeDialogClass *parent_class; - -guint -score_editor_get_type (void) -{ - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "ScoreEditor", - sizeof(ScoreEditor), - sizeof(ScoreEditorClass), - (GtkClassInitFunc)score_editor_class_init, - (GtkObjectInitFunc)score_editor_init, - (GtkArgSetFunc)NULL, - (GtkArgGetFunc)NULL - }; - - type = gtk_type_unique(gnome_dialog_get_type (), &type_info); - } - - return type; -} - -static void -score_editor_class_init (ScoreEditorClass *class) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *)class; - parent_class = gtk_type_class(gnome_dialog_get_type ()); - - /* override methods */ - -} - -static void -score_editor_init (ScoreEditor *o) -{ -} - -/** - * score_editor_new: - * - * Create a new ScoreEditor object. - * - * Return value: A new #ScoreEditor object. - **/ -ScoreEditor * -score_editor_new(void) -{ - ScoreEditor *o = (ScoreEditor *)gtk_type_new(score_editor_get_type ()); - return o; -} -#endif - - -enum { - BUTTON_ADD, - BUTTON_EDIT, - BUTTON_DELETE, - BUTTON_UP, - BUTTON_DOWN, - BUTTON_LAST -}; - -struct _editor_data { - RuleContext *f; - FilterRule *current; - GtkList *list; - GtkButton *buttons[BUTTON_LAST]; -}; - -static void set_sensitive(struct _editor_data *data); - -static void rule_add(GtkWidget *widget, struct _editor_data *data) -{ - ScoreRule *rule; - int result; - GnomeDialog *gd; - GtkWidget *w; - FilterPart *part; - - d(printf("add rule\n")); - /* create a new rule with 1 match and 1 action */ - rule = score_rule_new(); - - part = rule_context_next_part(data->f, NULL); - filter_rule_add_part((FilterRule *)rule, filter_part_clone(part)); - - w = filter_rule_get_widget((FilterRule *)rule, data->f); - gd = (GnomeDialog *)gnome_dialog_new(_("Add Rule"), - GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_CANCEL, - NULL); - gtk_box_pack_start((GtkBox *)gd->vbox, w, FALSE, TRUE, 0); - gtk_widget_show((GtkWidget *)gd); - result = gnome_dialog_run_and_close(gd); - if (result == 0) { - GtkListItem *item = (GtkListItem *)gtk_list_item_new_with_label(((FilterRule *)rule)->name); - GList *l = NULL; - - gtk_object_set_data((GtkObject *)item, "rule", rule); - gtk_widget_show((GtkWidget *)item); - l = g_list_append(l, item); - gtk_list_append_items(data->list, l); - gtk_list_select_child(data->list, (GtkWidget *)item); - data->current = (FilterRule *)rule; - rule_context_add_rule(data->f, (FilterRule *)rule); - set_sensitive(data); - } else { - gtk_object_unref((GtkObject *)rule); - } -} - -static void rule_edit(GtkWidget *widget, struct _editor_data *data) -{ - GtkWidget *w; - int result; - GnomeDialog *gd; - FilterRule *rule; - int pos; - - d(printf("edit rule\n")); - rule = data->current; - w = filter_rule_get_widget(rule, data->f); - gd = (GnomeDialog *)gnome_dialog_new(_("Edit Score Rule"), GNOME_STOCK_BUTTON_OK, NULL); - gtk_box_pack_start((GtkBox *)gd->vbox, w, FALSE, TRUE, 0); - gtk_widget_show((GtkWidget *)gd); - result = gnome_dialog_run_and_close(gd); - - if (result == 0) { - pos = rule_context_get_rank_rule(data->f, data->current); - if (pos != -1) { - GtkListItem *item = g_list_nth_data(data->list->children, pos); - gtk_label_set_text((GtkLabel *)(((GtkBin *)item)->child), data->current->name); - } - } -} - -static void rule_delete(GtkWidget *widget, struct _editor_data *data) -{ - int pos; - GList *l; - GtkListItem *item; - - d(printf("ddelete rule\n")); - pos = rule_context_get_rank_rule(data->f, data->current); - if (pos != -1) { - rule_context_remove_rule(data->f, data->current); - - item = g_list_nth_data(data->list->children, pos); - l = g_list_append(NULL, item); - gtk_list_remove_items(data->list, l); - g_list_free(l); - - gtk_object_unref((GtkObject *)data->current); - data->current = NULL; - } - set_sensitive(data); -} - -static void rule_move(struct _editor_data *data, int from, int to) -{ - GList *l; - GtkListItem *item; - - d(printf("moving %d to %d\n", from, to)); - rule_context_rank_rule(data->f, data->current, to); - - item = g_list_nth_data(data->list->children, from); - l = g_list_append(NULL, item); - gtk_list_remove_items_no_unref(data->list, l); - gtk_list_insert_items(data->list, l, to); - gtk_list_select_child(data->list, (GtkWidget *)item); - set_sensitive(data); -} - -static void rule_up(GtkWidget *widget, struct _editor_data *data) -{ - int pos; - - d(printf("up rule\n")); - pos = rule_context_get_rank_rule(data->f, data->current); - if (pos>0) { - rule_move(data, pos, pos-1); - } -} - -static void rule_down(GtkWidget *widget, struct _editor_data *data) -{ - int pos; - - d(printf("down rule\n")); - pos = rule_context_get_rank_rule(data->f, data->current); - rule_move(data, pos, pos+1); -} - -static struct { - char *name; - GtkSignalFunc func; -} edit_buttons[] = { - { "rule_add", rule_add }, - { "rule_edit", rule_edit }, - { "rule_delete", rule_delete }, - { "rule_up", rule_up }, - { "rule_down", rule_down }, -}; - -static void -set_sensitive(struct _editor_data *data) -{ - FilterRule *rule = NULL; - int index=-1, count=0; - - while ((rule = rule_context_next_rule(data->f, rule))) { - if (rule == data->current) - index=count; - count++; - } - d(printf("index = %d count=%d\n", index, count)); - count--; - gtk_widget_set_sensitive((GtkWidget *)data->buttons[BUTTON_EDIT], index != -1); - gtk_widget_set_sensitive((GtkWidget *)data->buttons[BUTTON_DELETE], index != -1); - gtk_widget_set_sensitive((GtkWidget *)data->buttons[BUTTON_UP], index > 0); - gtk_widget_set_sensitive((GtkWidget *)data->buttons[BUTTON_DOWN], index >=0 && indexcurrent = gtk_object_get_data((GtkObject *)child, "rule"); - if (data->current) - d(printf("seledct rule: %s\n", data->current->name)); - else - d(printf("bad data?\n")); - set_sensitive(data); -} - -GtkWidget *score_editor_construct (struct _ScoreContext *f) -{ - GladeXML *gui; - GtkWidget *d, *w; - GList *l; - FilterRule *rule = NULL; - struct _editor_data *data; - int i; - - g_assert(IS_SCORE_CONTEXT(f)); - - data = g_malloc0(sizeof(*data)); - data->f = (RuleContext *)f; - - gui = glade_xml_new(FILTER_GLADEDIR "/filter.glade", "edit_vfolder"); - d = glade_xml_get_widget (gui, "edit_vfolder"); - gtk_object_set_data_full((GtkObject *)d, "data", data, g_free); - - gtk_window_set_title((GtkWindow *)d, "Edit Score List"); - for (i=0;ibuttons[i] = (GtkButton *)w = glade_xml_get_widget (gui, edit_buttons[i].name); - gtk_signal_connect((GtkObject *)w, "clicked", edit_buttons[i].func, data); - } - - w = glade_xml_get_widget (gui, "rule_list"); - data->list = (GtkList *)w; - l = NULL; - while ((rule = rule_context_next_rule((RuleContext *)f, rule))) { - GtkListItem *item = (GtkListItem *)gtk_list_item_new_with_label(rule->name); - gtk_object_set_data((GtkObject *)item, "rule", rule); - gtk_widget_show((GtkWidget *)item); - l = g_list_append(l, item); - } - gtk_list_append_items(data->list, l); - gtk_signal_connect((GtkObject *)w, "select_child", select_rule, data); - - set_sensitive(data); - gtk_object_unref((GtkObject *)gui); - - return d; -} diff --git a/filter/score-editor.h b/filter/score-editor.h deleted file mode 100644 index cb78d465f0..0000000000 --- a/filter/score-editor.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef _SCORE_EDITOR_H -#define _SCORE_EDITOR_H - -#include -#include - -#if 0 -/* NOTE: object stuff not used (yet?), this is just a holder file for a static factory */ - -#define SCORE_EDITOR(obj) GTK_CHECK_CAST (obj, score_editor_get_type (), ScoreEditor) -#define SCORE_EDITOR_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, score_editor_get_type (), ScoreEditorClass) -#define IS_SCORE_EDITOR(obj) GTK_CHECK_TYPE (obj, score_editor_get_type ()) - -typedef struct _ScoreEditor ScoreEditor; -typedef struct _ScoreEditorClass ScoreEditorClass; - -struct _ScoreEditor { - GnomeDialog parent; -}; - -struct _ScoreEditorClass { - GnomeDialogClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - -guint score_editor_get_type (void); -ScoreEditor *score_editor_new (void); -#endif - -struct _ScoreContext; - -/* methods */ -GtkWidget *score_editor_construct (struct _ScoreContext *f); - -#endif /* ! _SCORE_EDITOR_H */ - diff --git a/filter/score-rule.c b/filter/score-rule.c deleted file mode 100644 index 8eb51b6821..0000000000 --- a/filter/score-rule.c +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include - -#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 *class); -static void score_rule_init (ScoreRule *gspaper); -static void score_rule_finalise (GtkObject *obj); - -#define _PRIVATE(x) (((ScoreRule *)(x))->priv) - -struct _ScoreRulePrivate { -}; - -static FilterRuleClass *parent_class; - -enum { - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -guint -score_rule_get_type (void) -{ - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "ScoreRule", - sizeof(ScoreRule), - sizeof(ScoreRuleClass), - (GtkClassInitFunc)score_rule_class_init, - (GtkObjectInitFunc)score_rule_init, - (GtkArgSetFunc)NULL, - (GtkArgGetFunc)NULL - }; - - type = gtk_type_unique(filter_rule_get_type (), &type_info); - } - - return type; -} - -static void -score_rule_class_init (ScoreRuleClass *class) -{ - GtkObjectClass *object_class; - FilterRuleClass *rule_class = (FilterRuleClass *)class; - - object_class = (GtkObjectClass *)class; - parent_class = gtk_type_class(filter_rule_get_type ()); - - 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; - - /* signals */ - - gtk_object_class_add_signals(object_class, signals, LAST_SIGNAL); -} - -static void -score_rule_init (ScoreRule *o) -{ - o->priv = g_malloc0(sizeof(*o->priv)); -} - -static void -score_rule_finalise(GtkObject *obj) -{ - ScoreRule *o = (ScoreRule *)obj; - - o = o; - - ((GtkObjectClass *)(parent_class))->finalize(obj); -} - -/** - * score_rule_new: - * - * Create a new ScoreRule object. - * - * Return value: A new #ScoreRule object. - **/ -ScoreRule * -score_rule_new(void) -{ - ScoreRule *o = (ScoreRule *)gtk_type_new(score_rule_get_type ()); - return o; -} - -static xmlNodePtr xml_encode(FilterRule *fr) -{ - ScoreRule *sr = (ScoreRule *)fr; - xmlNodePtr node, value; - char number[16]; - - node = ((FilterRuleClass *)(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 = ((FilterRuleClass *)(parent_class))->xml_decode(fr, node, f); - if (result != 0) - return result; - value = node->childs; - while (value) { - if (!strcmp(value->name, "score")) { - str = xmlGetProp(value, "value"); - sscanf(str, "%d", &sr->score); - } - 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; - GtkFrame *frame; - GtkLabel *label; - GtkHBox *hbox; - GtkAdjustment *adj; - ScoreRule *sr = (ScoreRule *)fr; - GtkSpinButton *spin; - - widget = ((FilterRuleClass *)(parent_class))->get_widget(fr, f); - frame = (GtkFrame *)gtk_frame_new("Score"); - hbox = (GtkHBox *)gtk_hbox_new(FALSE, 3); - label = (GtkLabel *)gtk_label_new("Score"); - gtk_box_pack_start((GtkBox *)hbox, (GtkWidget *)label, FALSE, FALSE, 3); - adj = (GtkAdjustment *)gtk_adjustment_new((float)sr->score, -100, 100, 1, 10, 10); - gtk_signal_connect((GtkObject *)adj, "value_changed", spin_changed, sr); - spin = (GtkSpinButton *)gtk_spin_button_new(adj, 1.0, 0); - gtk_box_pack_start((GtkBox *)hbox, (GtkWidget *)spin, FALSE, FALSE, 3); - gtk_container_add((GtkContainer *)frame, (GtkWidget *)hbox); - gtk_widget_show_all((GtkWidget *)frame); - - gtk_box_pack_start((GtkBox *)widget, (GtkWidget *)frame, FALSE, FALSE, 3); - return widget; -} diff --git a/filter/score-rule.h b/filter/score-rule.h deleted file mode 100644 index 25607fd7c4..0000000000 --- a/filter/score-rule.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef _SCORE_RULE_H -#define _SCORE_RULE_H - -#include - -#include "filter-rule.h" - -#define SCORE_RULE(obj) GTK_CHECK_CAST (obj, score_rule_get_type (), ScoreRule) -#define SCORE_RULE_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, score_rule_get_type (), ScoreRuleClass) -#define IS_SCORE_RULE(obj) GTK_CHECK_TYPE (obj, score_rule_get_type ()) - -typedef struct _ScoreRule ScoreRule; -typedef struct _ScoreRuleClass ScoreRuleClass; - -struct _ScoreRule { - FilterRule parent; - struct _ScoreRulePrivate *priv; - - int score; -}; - -struct _ScoreRuleClass { - FilterRuleClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - -guint score_rule_get_type (void); -ScoreRule *score_rule_new (void); - -/* methods */ - -#endif /* ! _SCORE_RULE_H */ - diff --git a/filter/vfolder-context.c b/filter/vfolder-context.c deleted file mode 100644 index 41453ea310..0000000000 --- a/filter/vfolder-context.c +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include - -#include "vfolder-context.h" -#include "vfolder-rule.h" - -static void vfolder_context_class_init (VfolderContextClass *class); -static void vfolder_context_init (VfolderContext *gspaper); -static void vfolder_context_finalise (GtkObject *obj); - -#define _PRIVATE(x) (((VfolderContext *)(x))->priv) - -struct _VfolderContextPrivate { -}; - -static RuleContextClass *parent_class; - -enum { - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -guint -vfolder_context_get_type (void) -{ - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "VfolderContext", - sizeof(VfolderContext), - sizeof(VfolderContextClass), - (GtkClassInitFunc)vfolder_context_class_init, - (GtkObjectInitFunc)vfolder_context_init, - (GtkArgSetFunc)NULL, - (GtkArgGetFunc)NULL - }; - - type = gtk_type_unique(rule_context_get_type (), &type_info); - } - - return type; -} - -static void -vfolder_context_class_init (VfolderContextClass *class) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *)class; - parent_class = gtk_type_class(rule_context_get_type ()); - - object_class->finalize = vfolder_context_finalise; - /* override methods */ - - /* signals */ - - gtk_object_class_add_signals(object_class, signals, LAST_SIGNAL); -} - -static void -vfolder_context_init (VfolderContext *o) -{ - o->priv = g_malloc0(sizeof(*o->priv)); - - rule_context_add_part_set((RuleContext *)o, "partset", filter_part_get_type(), - rule_context_add_part, rule_context_next_part); - - rule_context_add_rule_set((RuleContext *)o, "ruleset", vfolder_rule_get_type(), - rule_context_add_rule, rule_context_next_rule); -} - -static void -vfolder_context_finalise(GtkObject *obj) -{ - VfolderContext *o = (VfolderContext *)obj; - - o = o; - - ((GtkObjectClass *)(parent_class))->finalize(obj); -} - -/** - * vfolder_context_new: - * - * Create a new VfolderContext object. - * - * Return value: A new #VfolderContext object. - **/ -VfolderContext * -vfolder_context_new(void) -{ - VfolderContext *o = (VfolderContext *)gtk_type_new(vfolder_context_get_type ()); - return o; -} diff --git a/filter/vfolder-context.h b/filter/vfolder-context.h deleted file mode 100644 index 0bf1b5aaf2..0000000000 --- a/filter/vfolder-context.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef _VFOLDER_CONTEXT_H -#define _VFOLDER_CONTEXT_H - -#include - -#include "rule-context.h" - -#define VFOLDER_CONTEXT(obj) GTK_CHECK_CAST (obj, vfolder_context_get_type (), VfolderContext) -#define VFOLDER_CONTEXT_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, vfolder_context_get_type (), VfolderContextClass) -#define IS_VFOLDER_CONTEXT(obj) GTK_CHECK_TYPE (obj, vfolder_context_get_type ()) - -typedef struct _VfolderContext VfolderContext; -typedef struct _VfolderContextClass VfolderContextClass; - -struct _VfolderContext { - RuleContext parent; - struct _VfolderContextPrivate *priv; - -}; - -struct _VfolderContextClass { - RuleContextClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - -guint 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 c5bf378625..0000000000 --- a/filter/vfolder-editor.c +++ /dev/null @@ -1,339 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include - -#include "vfolder-editor.h" -#include "vfolder-context.h" -#include "vfolder-rule.h" - -#define d(x) - -#if 0 -static void vfolder_editor_class_init (VfolderEditorClass *class); -static void vfolder_editor_init (VfolderEditor *gspaper); -static void vfolder_editor_finalise (GtkObject *obj); - -#define _PRIVATE(x) (((VfolderEditor *)(x))->priv) - -struct _VfolderEditorPrivate { -}; - -static GnomeDialogClass *parent_class; - -enum { - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -guint -vfolder_editor_get_type (void) -{ - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "VfolderEditor", - sizeof(VfolderEditor), - sizeof(VfolderEditorClass), - (GtkClassInitFunc)vfolder_editor_class_init, - (GtkObjectInitFunc)vfolder_editor_init, - (GtkArgSetFunc)NULL, - (GtkArgGetFunc)NULL - }; - - type = gtk_type_unique(gnome_dialog_get_type (), &type_info); - } - - return type; -} - -static void -vfolder_editor_class_init (VfolderEditorClass *class) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *)class; - parent_class = gtk_type_class(gnome_dialog_get_type ()); - - object_class->finalize = vfolder_editor_finalise; - /* override methods */ - - /* signals */ - - gtk_object_class_add_signals(object_class, signals, LAST_SIGNAL); -} - -static void -vfolder_editor_init (VfolderEditor *o) -{ - o->priv = g_malloc0(sizeof(*o->priv)); -} - -static void -vfolder_editor_finalise(GtkObject *obj) -{ - VfolderEditor *o = (VfolderEditor *)obj; - - ((GtkObjectClass *)(parent_class))->finalize(obj); -} - -/** - * vfolder_editor_new: - * - * Create a new VfolderEditor object. - * - * Return value: A new #VfolderEditor object. - **/ -VfolderEditor * -vfolder_editor_new(void) -{ - VfolderEditor *o = (VfolderEditor *)gtk_type_new(vfolder_editor_get_type ()); - return o; -} -#endif - - - -enum { - BUTTON_ADD, - BUTTON_EDIT, - BUTTON_DELETE, - BUTTON_UP, - BUTTON_DOWN, - BUTTON_LAST -}; - -struct _editor_data { - RuleContext *f; - FilterRule *current; - GtkList *list; - GtkButton *buttons[BUTTON_LAST]; -}; - -static void set_sensitive(struct _editor_data *data); - -static void rule_add(GtkWidget *widget, struct _editor_data *data) -{ - FilterRule *rule; - int result; - GnomeDialog *gd; - GtkWidget *w; - FilterPart *part; - - d(printf("add rule\n")); - /* create a new rule with 1 match and 1 action */ - rule = (FilterRule *) vfolder_rule_new(); - - part = rule_context_next_part(data->f, NULL); - filter_rule_add_part(rule, filter_part_clone(part)); - - w = filter_rule_get_widget(rule, data->f); - gd = (GnomeDialog *)gnome_dialog_new(_("Add Rule"), - GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_CANCEL, - NULL); - gtk_box_pack_start((GtkBox *)gd->vbox, w, FALSE, TRUE, 0); - gtk_widget_show((GtkWidget *)gd); - result = gnome_dialog_run_and_close(gd); - if (result == 0) { - GtkListItem *item = (GtkListItem *)gtk_list_item_new_with_label(rule->name); - GList *l = NULL; - - gtk_object_set_data((GtkObject *)item, "rule", rule); - gtk_widget_show((GtkWidget *)item); - l = g_list_append(l, item); - gtk_list_append_items(data->list, l); - gtk_list_select_child(data->list, (GtkWidget *)item); - data->current = rule; - rule_context_add_rule(data->f, rule); - set_sensitive(data); - } else { - gtk_object_unref((GtkObject *)rule); - } -} - -static void rule_edit(GtkWidget *widget, struct _editor_data *data) -{ - GtkWidget *w; - int result; - GnomeDialog *gd; - FilterRule *rule; - int pos; - - d(printf("edit rule\n")); - rule = data->current; - w = filter_rule_get_widget(rule, data->f); - gd = (GnomeDialog *)gnome_dialog_new(_("Edit VFolder Rule"), GNOME_STOCK_BUTTON_OK, NULL); - gtk_box_pack_start((GtkBox *)gd->vbox, w, FALSE, TRUE, 0); - gtk_widget_show((GtkWidget *)gd); - result = gnome_dialog_run_and_close(gd); - - if (result == 0) { - pos = rule_context_get_rank_rule(data->f, data->current); - if (pos != -1) { - GtkListItem *item = g_list_nth_data(data->list->children, pos); - gtk_label_set_text((GtkLabel *)(((GtkBin *)item)->child), data->current->name); - } - } -} - -static void rule_delete(GtkWidget *widget, struct _editor_data *data) -{ - int pos; - GList *l; - GtkListItem *item; - - d(printf("ddelete rule\n")); - pos = rule_context_get_rank_rule(data->f, data->current); - if (pos != -1) { - rule_context_remove_rule(data->f, data->current); - - item = g_list_nth_data(data->list->children, pos); - l = g_list_append(NULL, item); - gtk_list_remove_items(data->list, l); - g_list_free(l); - - gtk_object_unref((GtkObject *)data->current); - data->current = NULL; - } - set_sensitive(data); -} - -static void rule_move(struct _editor_data *data, int from, int to) -{ - GList *l; - GtkListItem *item; - - d(printf("moving %d to %d\n", from, to)); - rule_context_rank_rule(data->f, data->current, to); - - item = g_list_nth_data(data->list->children, from); - l = g_list_append(NULL, item); - gtk_list_remove_items_no_unref(data->list, l); - gtk_list_insert_items(data->list, l, to); - gtk_list_select_child(data->list, (GtkWidget *)item); - set_sensitive(data); -} - -static void rule_up(GtkWidget *widget, struct _editor_data *data) -{ - int pos; - - d(printf("up rule\n")); - pos = rule_context_get_rank_rule(data->f, data->current); - if (pos>0) { - rule_move(data, pos, pos-1); - } -} - -static void rule_down(GtkWidget *widget, struct _editor_data *data) -{ - int pos; - - d(printf("down rule\n")); - pos = rule_context_get_rank_rule(data->f, data->current); - rule_move(data, pos, pos+1); -} - -static struct { - char *name; - GtkSignalFunc func; -} edit_buttons[] = { - { "rule_add", rule_add }, - { "rule_edit", rule_edit }, - { "rule_delete", rule_delete }, - { "rule_up", rule_up }, - { "rule_down", rule_down }, -}; - -static void -set_sensitive(struct _editor_data *data) -{ - FilterRule *rule = NULL; - int index=-1, count=0; - - while ((rule = rule_context_next_rule(data->f, rule))) { - if (rule == data->current) - index=count; - count++; - } - d(printf("index = %d count=%d\n", index, count)); - count--; - gtk_widget_set_sensitive((GtkWidget *)data->buttons[BUTTON_EDIT], index != -1); - gtk_widget_set_sensitive((GtkWidget *)data->buttons[BUTTON_DELETE], index != -1); - gtk_widget_set_sensitive((GtkWidget *)data->buttons[BUTTON_UP], index > 0); - gtk_widget_set_sensitive((GtkWidget *)data->buttons[BUTTON_DOWN], index >=0 && indexcurrent = gtk_object_get_data((GtkObject *)child, "rule"); - if (data->current) - d(printf("seledct rule: %s\n", data->current->name)); - else - d(printf("bad data?\n")); - set_sensitive(data); -} - -GtkWidget *vfolder_editor_construct (struct _VfolderContext *f) -{ - GladeXML *gui; - GtkWidget *d, *w; - GList *l; - FilterRule *rule = NULL; - struct _editor_data *data; - int i; - - g_assert(IS_VFOLDER_CONTEXT(f)); - - data = g_malloc0(sizeof(*data)); - data->f = (RuleContext *)f; - - gui = glade_xml_new(FILTER_GLADEDIR "/filter.glade", "edit_vfolder"); - d = glade_xml_get_widget (gui, "edit_vfolder"); - gtk_object_set_data_full((GtkObject *)d, "data", data, g_free); - - gtk_window_set_title((GtkWindow *)d, "Edit VFolders"); - for (i=0;ibuttons[i] = (GtkButton *)w = glade_xml_get_widget (gui, edit_buttons[i].name); - gtk_signal_connect((GtkObject *)w, "clicked", edit_buttons[i].func, data); - } - - w = glade_xml_get_widget (gui, "rule_list"); - data->list = (GtkList *)w; - l = NULL; - while ((rule = rule_context_next_rule((RuleContext *)f, rule))) { - GtkListItem *item = (GtkListItem *)gtk_list_item_new_with_label(rule->name); - gtk_object_set_data((GtkObject *)item, "rule", rule); - gtk_widget_show((GtkWidget *)item); - l = g_list_append(l, item); - } - gtk_list_append_items(data->list, l); - gtk_signal_connect((GtkObject *)w, "select_child", select_rule, data); - - set_sensitive(data); - gtk_object_unref((GtkObject *)gui); - - return d; -} diff --git a/filter/vfolder-editor.h b/filter/vfolder-editor.h deleted file mode 100644 index 2ff2b261dc..0000000000 --- a/filter/vfolder-editor.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef _VFOLDER_EDITOR_H -#define _VFOLDER_EDITOR_H - -#include -#include - -#if 0 -/* NOTE: object stuff not used (yet?), this is just a holder file for a static factory */ - -#define VFOLDER_EDITOR(obj) GTK_CHECK_CAST (obj, vfolder_editor_get_type (), VfolderEditor) -#define VFOLDER_EDITOR_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, vfolder_editor_get_type (), VfolderEditorClass) -#define IS_VFOLDER_EDITOR(obj) GTK_CHECK_TYPE (obj, vfolder_editor_get_type ()) - -typedef struct _VfolderEditor VfolderEditor; -typedef struct _VfolderEditorClass VfolderEditorClass; - -struct _VfolderEditor { - GnomeDialog parent; - struct _VfolderEditorPrivate *priv; - -}; - -struct _VfolderEditorClass { - GnomeDialogClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - -guint vfolder_editor_get_type (void); -VfolderEditor *vfolder_editor_new (void); -#endif - -struct _VfolderContext; - -/* methods */ -GtkWidget *vfolder_editor_construct (struct _VfolderContext *f); - -#endif /* ! _VFOLDER_EDITOR_H */ - diff --git a/filter/vfolder-rule.c b/filter/vfolder-rule.c deleted file mode 100644 index d6da471b07..0000000000 --- a/filter/vfolder-rule.c +++ /dev/null @@ -1,354 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include - -#include "vfolder-context.h" -#include "vfolder-rule.h" -#include "shell/evolution-shell-client.h" - -#define d(x) x - -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); - -extern EvolutionShellClient *global_shell_client; - -static void vfolder_rule_class_init (VfolderRuleClass *class); -static void vfolder_rule_init (VfolderRule *gspaper); -static void vfolder_rule_finalise (GtkObject *obj); - -#define _PRIVATE(x) (((VfolderRule *)(x))->priv) - -struct _VfolderRulePrivate { -}; - -static FilterRuleClass *parent_class; - -guint -vfolder_rule_get_type (void) -{ - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "VfolderRule", - sizeof(VfolderRule), - sizeof(VfolderRuleClass), - (GtkClassInitFunc)vfolder_rule_class_init, - (GtkObjectInitFunc)vfolder_rule_init, - (GtkArgSetFunc)NULL, - (GtkArgGetFunc)NULL - }; - - type = gtk_type_unique(filter_rule_get_type (), &type_info); - } - - return type; -} - -static void -vfolder_rule_class_init (VfolderRuleClass *class) -{ - GtkObjectClass *object_class; - FilterRuleClass *filter_rule = (FilterRuleClass *)class; - - object_class = (GtkObjectClass *)class; - parent_class = gtk_type_class(filter_rule_get_type ()); - - object_class->finalize = vfolder_rule_finalise; - - /* override methods */ - filter_rule->xml_encode = xml_encode; - filter_rule->xml_decode = xml_decode; - /*filter_rule->build_code = build_code;*/ - filter_rule->get_widget = get_widget; -} - -static void -vfolder_rule_init (VfolderRule *o) -{ - o->priv = g_malloc0(sizeof(*o->priv)); -} - -static void -vfolder_rule_finalise(GtkObject *obj) -{ - VfolderRule *o = (VfolderRule *)obj; - o = o; - ((GtkObjectClass *)(parent_class))->finalize(obj); -} - -/** - * vfolder_rule_new: - * - * Create a new VfolderRule object. - * - * Return value: A new #VfolderRule object. - **/ -VfolderRule * -vfolder_rule_new(void) -{ - VfolderRule *o = (VfolderRule *)gtk_type_new(vfolder_rule_get_type ()); - return o; -} - -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)); -} - -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 = g_list_next(l); - } - 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); - } -} - -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 xmlNodePtr xml_encode(FilterRule *fr) -{ - xmlNodePtr node, set, work; - GList *l; - VfolderRule *vr = (VfolderRule *)fr; - - node = ((FilterRuleClass *)(parent_class))->xml_encode(fr); - g_assert(node != NULL); - set = xmlNewNode(NULL, "sources"); - xmlAddChild(node, set); - l = vr->sources; - while (l) { - work = xmlNewNode(NULL, "folder"); - xmlSetProp(work, "uri", l->data); - xmlAddChild(set, work); - l = g_list_next(l); - } - return node; -} - -static int xml_decode(FilterRule *fr, xmlNodePtr node, struct _RuleContext *f) -{ - xmlNodePtr set, work; - int result; - VfolderRule *vr = (VfolderRule *)fr; - char *uri; - - result = ((FilterRuleClass *)(parent_class))->xml_decode(fr, node, f); - if (result != 0) - return result; - - set = node->childs; - while (set) { - if (!strcmp(set->name, "sources")) { - work = set->childs; - while (work) { - if (!strcmp(work->name, "folder")) { - uri = xmlGetProp(work, "uri"); - if (uri) - vr->sources = g_list_append(vr->sources, uri); - } - work = work->next; - } - } - set = set->next; - } - return 0; -} - -enum { - BUTTON_ADD, - BUTTON_REMOVE, - BUTTON_LAST, -}; - -struct _source_data { - RuleContext *f; - VfolderRule *vr; - const char *current; - GtkList *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", source_add }, - { "source_remove", 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 *w, GtkWidget *child, struct _source_data *data) -{ - data->current = gtk_object_get_data((GtkObject *)child, "source"); - set_sensitive(data); -} - -static void source_add(GtkWidget *widget, struct _source_data *data) -{ - const char *allowed_types[] = { "mail", NULL }; - char *def, *uri; - GtkListItem *item; - GList *l; - - def = ""; - evolution_shell_client_user_select_folder (global_shell_client, - _("Select Folder"), - def, allowed_types, NULL, &uri); - - if (uri != NULL && uri[0] != '\0') { - data->vr->sources = g_list_append(data->vr->sources, uri); - - l = NULL; - item = (GtkListItem *)gtk_list_item_new_with_label(uri); - gtk_object_set_data((GtkObject *)item, "source", uri); - gtk_widget_show((GtkWidget *)item); - l = g_list_append(NULL, item); - gtk_list_append_items(data->list, l); - gtk_list_select_child(data->list, (GtkWidget *)item); - data->current = uri; - } else { - g_free(uri); - } - set_sensitive(data); -} - -static void source_remove(GtkWidget *widget, struct _source_data *data) -{ - const char *source; - int index = 0; - GList *l; - GtkListItem *item; - - source = NULL; - while ((source = vfolder_rule_next_source(data->vr, source))) { - if (data->current == source) { - vfolder_rule_remove_source(data->vr, source); - item = g_list_nth_data(data->list->children, index); - l = g_list_append(NULL, item); - gtk_list_remove_items(data->list, l); - g_list_free(l); - data->current = NULL; - break; - } - index++; - } - set_sensitive(data); -} - -static GtkWidget *get_widget(FilterRule *fr, struct _RuleContext *f) -{ - GtkWidget *widget, *frame, *w; - GladeXML *gui; - const char *source; - VfolderRule *vr = (VfolderRule *)fr; - struct _source_data *data; - int i; - GList *l; - - widget = ((FilterRuleClass *)(parent_class))->get_widget(fr, f); - - data = g_malloc0(sizeof(*data)); - data->f = f; - data->vr = vr; - - gui = glade_xml_new(FILTER_GLADEDIR "/filter.glade", "vfolder_source_frame"); - frame = glade_xml_get_widget (gui, "vfolder_source_frame"); - - gtk_object_set_data_full((GtkObject *)frame, "data", data, g_free); - - for (i=0;ibuttons[i] = (GtkButton *)w = glade_xml_get_widget (gui, edit_buttons[i].name); - gtk_signal_connect((GtkObject *)w, "clicked", edit_buttons[i].func, data); - } - - w = glade_xml_get_widget (gui, "source_list"); - data->list = (GtkList *)w; - l = NULL; - source = NULL; - while ((source = vfolder_rule_next_source(vr, source))) { - GtkListItem *item = (GtkListItem *)gtk_list_item_new_with_label(source); - gtk_object_set_data((GtkObject *)item, "source", (void *)source); - gtk_widget_show((GtkWidget *)item); - l = g_list_append(l, item); - } - gtk_list_append_items(data->list, l); - gtk_signal_connect((GtkObject *)w, "select_child", select_source, data); - set_sensitive(data); - - 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 c3fa130c84..0000000000 --- a/filter/vfolder-rule.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef _VFOLDER_RULE_H -#define _VFOLDER_RULE_H - -#include -#include "filter-rule.h" - -#define VFOLDER_RULE(obj) GTK_CHECK_CAST (obj, vfolder_rule_get_type (), VfolderRule) -#define VFOLDER_RULE_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, vfolder_rule_get_type (), VfolderRuleClass) -#define IS_VFOLDER_RULE(obj) GTK_CHECK_TYPE (obj, vfolder_rule_get_type ()) - -typedef struct _VfolderRule VfolderRule; -typedef struct _VfolderRuleClass VfolderRuleClass; - -struct _VfolderRule { - FilterRule parent; - struct _VfolderRulePrivate *priv; - - GList *sources; /* uri's of the source folders */ -}; - -struct _VfolderRuleClass { - FilterRuleClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - -guint 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 52c2c0e8ca..0000000000 --- a/filter/vfoldertypes.xml +++ /dev/null @@ -1,144 +0,0 @@ - - - - - Sender - - - - - - - - Recipients - - - - - - - - Subject - - - - - - - - Message Body - - - - - - - - Expression - - - - - Message was sent - - - - - - - - - - - - Message was received - - - - - - - - - - - -- cgit v1.2.3