From dcc8171fd4c8df52faff322827876acf30c35a4a Mon Sep 17 00:00:00 2001 From: nobody Date: Fri, 14 Dec 2001 04:59:04 +0000 Subject: This commit was manufactured by cvs2svn to create tag 'EOG_0_109_1'. svn path=/tags/EOG_0_109_1/; revision=15041 --- filter/.cvsignore | 9 - filter/ChangeLog | 2202 ---------------------------------------------- filter/Makefile.am | 85 -- filter/filter-code.c | 122 --- filter/filter-code.h | 51 -- filter/filter-colour.c | 224 ----- filter/filter-colour.h | 54 -- filter/filter-context.c | 237 ----- filter/filter-context.h | 58 -- filter/filter-datespec.c | 763 ---------------- filter/filter-datespec.h | 64 -- filter/filter-editor.c | 187 ---- filter/filter-editor.h | 54 -- filter/filter-element.c | 312 ------- filter/filter-element.h | 86 -- filter/filter-filter.c | 534 ----------- filter/filter-filter.h | 59 -- filter/filter-folder.c | 344 -------- filter/filter-folder.h | 56 -- filter/filter-input.c | 345 -------- filter/filter-input.h | 58 -- filter/filter-int.c | 226 ----- filter/filter-int.h | 58 -- filter/filter-option.c | 361 -------- filter/filter-option.h | 62 -- filter/filter-part.c | 501 ----------- filter/filter-part.h | 77 -- filter/filter-rule.c | 866 ------------------ filter/filter-rule.h | 112 --- filter/filter-score.c | 233 ----- filter/filter-score.h | 56 -- filter/filter-source.c | 362 -------- filter/filter-source.h | 52 -- filter/filter.glade | 738 ---------------- filter/filtertypes.xml | 631 ------------- filter/libfilter-i18n.h | 53 -- filter/rule-context.c | 679 -------------- filter/rule-context.h | 124 --- filter/rule-editor.c | 650 -------------- filter/rule-editor.h | 96 -- filter/score-context.c | 104 --- filter/score-context.h | 51 -- filter/score-editor.c | 149 ---- filter/score-editor.h | 53 -- filter/score-rule.c | 221 ----- filter/score-rule.h | 54 -- filter/vfolder-context.c | 119 --- filter/vfolder-context.h | 53 -- filter/vfolder-editor.c | 149 ---- filter/vfolder-editor.h | 54 -- filter/vfolder-rule.c | 503 ----------- filter/vfolder-rule.h | 60 -- filter/vfoldertypes.xml | 363 -------- 53 files changed, 13774 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-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-int.c delete mode 100644 filter/filter-int.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-score.c delete mode 100644 filter/filter-score.h delete mode 100644 filter/filter-source.c delete mode 100644 filter/filter-source.h delete mode 100644 filter/filter.glade delete mode 100644 filter/filtertypes.xml delete mode 100644 filter/libfilter-i18n.h delete mode 100644 filter/rule-context.c delete mode 100644 filter/rule-context.h delete mode 100644 filter/rule-editor.c delete mode 100644 filter/rule-editor.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 ad60abdf24..0000000000 --- a/filter/ChangeLog +++ /dev/null @@ -1,2202 +0,0 @@ -2001-12-09 Jon Trowbridge - - * vfoldertypes.xml: Add "Needs Reply" option to different status - types. - - * filtertypes.xml: Add "Needs Reply" option to different status - types. - -2001-11-15 Zbigniew Chyla - - * rule-editor.c (set_source): Removed U_. Fixes #15415. - -2001-11-21 Not Zed - - * rule-editor.c (rule_edit): Hook onto destroy event. - (edit_editor_destroyed): IF we get destroyed, fake a -1 click - event to clean up. - (rule_add): hook onto destroy of dialogue. - (add_editor_destroyed): Simulate -1 click event to clean up. Fix - for #15745. - -2001-11-20 Not Zed - - * vfolder-rule.c (source_add): Desensitise button while we're - running, and if we are destroyed, exit and do nothing when we're - done. Fixes crash in #15498. - - * filter-folder.c (button_clicked): Ref 'ff' around dialogue - showing incase we go away before it returns. Also desensitise - button that invoked us while its being processed & remove - 'is_active' hack. Fixes similar problems to those in #15498. - -2001-11-12 Jeffrey Stedfast - - * filter-rule.c (validate): Force the user to name the filter. - - * vfolder-rule.c (validate): Force the user to name the vfolder. - -2001-10-29 - - * rule-editor.c: Some debug printf fixes for printf's that dont - like null %s's. - Fixed previous fix. - (rule_editor_play_undo): Need to ref rule since add doesn't. This - doesn't crash anymore but doesn't seem to do everything right either. - -2001-10-28 - - * filter-context.c (filter_rename_uri): Implement, change any - folder uri's that have been renamed, to the new one. - (filter_delete_uri): Dont actually do any work (yet). - - We could probably put rename_uri on every rule context/filter - part/filter element, and let their methods handle it, but for now - its easy enough just to handle the few cases that we have to - handle manually. - - * rule-context.c (rule_context_delete_uri): Update a filter - context for a deleted uri, e.g. folder removed. - (rule_context_rename_uri): Update a filter context for a renamed - uri, e.g. - - * filter-folder.c (filter_folder_set_value): New function to set - the uri of a folder filter. - - * rule-editor.c (rule_move): Add undo for move. - (rule_editor_add_undo): Add extra rank item. - (rule_editor_play_undo): handle rank case. - (rule_editor_finalise): Clean up any hanging over undo log. - (editor_clicked): Only enable 'undo' if we have - EVOLUTION_RULE_UNDO enabled. Code still a bit flakey. - (rule_editor_construct): Only enable a cancel button if - EVOLUTION_RULE_UNDO is set. - (rule_editor_add_undo): Only add if undo enabled. - (rule_editor_add_undo): Fix enable undo logic. - - * filter-rule.c (filter_rule_set_name): Emit a changed event if it - changes. - (filter_rule_set_source): Same. - -2001-10-26 - - * rule-context.c (rule_context_find_rank_rule): Find a rule at a - specific rank/source. - - * rule-editor.c (add_editor_clicked): Log the added object. - (rule_editor_add_undo): New function to add an undo record to the - rule editor. - (edit_editor_clicked): Log the changed object. - (rule_delete): Add undo object. - (rule_editor_play_undo): Play an undo log back. - -2001-10-26 Jeffrey Stedfast - - * rule-editor.c (rule_add): Desensitize the parent dialog. - (rule_edit): Same. - (add_editor_clicked): Re-sensitize it. - (edit_editor_clicked): Same. - -2001-10-25 Jeffrey Stedfast - - * rule-editor.c: Keep track of the current editor dialog window so - that on exit, we can close it too. - (rule_edit): Don't make the dialog modal and set it's parent - window as well as don't allow more than a single editor window to - be popped up. - (rule_add): Same. - -2001-10-24 - - * rule-context.c (rule_context_class_init): Add a changed signal. - Emits if the order changes or if you add or remove a rule. - (rule_context_rank_rule): Fix rank rule to properly rank based on - source, not merely on list position. - (rule_context_add_rule): Also emit changed signal. - (rule_context_remove_rule): Same. - (rule_context_rank_rule): Emit changed signal. - -2001-10-20 Jon Trowbridge - - * rule-editor.c (set_source): Translate the rule names. (Bug - #13082) - -2001-10-17 Ettore Perazzoli - - * filter-folder.c (button_clicked): Pass the toplevel to - `evolution_shell_client_user_select_folder()'. - * vfolder-rule.c (source_add): Likewise. - -2001-10-15 Jeffrey Stedfast - - * filter-folder.c (button_clicked): Kludge to raise the filter - dialog when the folder-selection window is closed. - -2001-10-15 - - * filter-input.c (xml_decode): If we have no node content, dont - append any value or try to decode it. Gets rid of a bunch of - annoying warnings. - -2001-10-04 Jeffrey Stedfast - - * vfolder-rule.c (validate): And again here. - - * filter-folder.c (validate): Same. - - * filter-datespec.c (validate): Take out the "Oops" part of the - warning. - -2001-10-04 - - * rule-context.c (save): "safe" save code, first save to .#name, - then rename to name if it worked, also create backups to name~. - Means filters/etc wont get reset/lost if disk fills up, although - relies on libxml failing properly. - (new_rule_clicked): Removed warning, we do now have changed - signals! - -2001-09-28 - - * vfolder-rule.c (vfolder_rule_add_source): Emit changed events - when we change it. - (vfolder_rule_remove_source): " - -2001-09-28 Jeffrey Stedfast - - * rule-editor.c (edit_editor_clicked): Set the item label to the - new rule name, not the old rule name. Fixes bug #11168. - -2001-09-27 - - * vfolder-rule.c (xml_decode): Use g_strdup for the uri, not the - xml memory. - - * filter-driver.c, filter-message-search.c: Removed, again, how - did they come back??? - -2001-09-13 - - * filter-filter.c (filter_filter_add_action): - (filter_filter_remove_action): - (filter_filter_replace_action): Emit changed events. - - * filter-rule.c (filter_rule_xml_decode): Emiot a rule changed - event. - (filter_rule_copy): Emit a changed event. - (filter_rule_replace_part): " - (filter_rule_add_part): " - (filter_rule_remove_part): " - (filter_rule_xml_decode): Freeze around decoding, so we only emit - changed when done. - (filter_rule_emit_changed): New function to emit changed events if - not frozen. - -2001-09-13 - - * rule-context.c (rule_context_class_init): Added a 'rule_added' - and 'rule_removed' signal. - (rule_context_load): Set a (private) frozen flag while we're - loading. - (rule_context_add_rule): Emit a rule_added signal if we're not - frozen. - (rule_context_remove_rule): Emit a rule_removed signal if we're - not frozen. - -2001-09-12 Jeffrey Stedfast - - * rule-editor.c (rule_edit): Clone the current rule before editing - it so that changes can be undone. - (edit_editor_clicked): If the user hit OK, replace the original - rule with the new one. - - * vfolder-rule.c (vfolder_rule_finalise): Free the sources list. - (rule_copy): Implemented. - - * filter-filter.c (rule_copy): Implemented. - - * filter-rule.c (filter_rule_copy): New convenience function to - copy one rule "into" another. - (rule_copy): Default implementation. - (filter_rule_clone): Use filter_rule_copy() internally to get rid - of the nastiness/slowness of xml encoding and then decoding. - -2001-09-12 - - * vfoldertypes.xml: Remove the match-all from the not - body-contains, so we can use the new vector not function. - -2001-09-10 - - * filter-score.c (format_sexp): Encode the score as an integer - string, not as a string of integers. #5098. - -2001-09-10 Jeffrey Stedfast - - * filter-datespec.c (button_clicked): Allow the dialog's title to - be translated. - -2001-08-19 Chris Toshok - - * filter-input.c: #include for regex_t on freebsd. - -2001-08-15 Jeffrey Stedfast - - * filter.glade: Added key accelerators. - -2001-08-14 Peter Williams - - * filter-rule.c (xml_decode): Match either "title" or "_title" to - allow for translations of the title (provided in the default - files) - -2001-08-13 Peter Williams - - * filter-datespec.c (make_span_editor): Add a gettext around our static - strings. - (format_time): New function. Convert a time_t to a gchar * (with i18n) - (describe_button): Use format_time instead of ctime. - -2001-08-10 Peter Williams - - * rule-context.c (rule_context_add_rule_gui): Make this compile again. - -2001-08-10 Jeffrey Stedfast - - * rule-context.c (rule_context_add_rule_gui): No need to - gtk_widget_show() the gnome dialog widget twice... - - * vfolder-rule.c (get_widget): Unref the glade_xml gui object - before returning. - -2001-08-08 Radek Doulik - - * filter-folder.c (button_clicked): don't mix g_free and xmlAlloc - (xml_decode): don't mix g_free and xmlAlloc - - * filter-code.c (filter_code_init): use xmlStrdup instead of - g_strdup - - * filter-input.c (filter_input_new_type_name): use xmlStrdup - instead of g_strdup - (filter_input_finalise): don't mix g_free and xmlAlloc - - * filter-option.c (clone): use xmlStrdup instead of g_strdup - (free_option): don't mix g_free and xmlAlloc - - * filter-source.c (clone): use xmlStrdup rather than g_strdup - - * filter-element.c (filter_element_finalise): don't mix g_free and - xmlAlloc - -2001-08-07 Not Zed - - * filter-rule.c (filter_rule_finalise): Properly free the list of - parts, and the private data. - (FilterRulePrivate): Remove unused 'parts' member. - - * filter-option.c (free_option): For freeing options. - (filter_option_finalise): Free options list. - - * filter-element.c (filter_element_finalise): free name. - - * filter-input.c (filter_input_finalise): Free type and values - list. - - * filter-context.c (filter_context_finalise): Free the actions. - - * rule-context.c (rule_context_finalise): Remove the totally weird - arsed *_set_list free code. - (free_part_set): - (free_rule_set): Use this to free stuff using g_list_foreach. - (rule_context_finalise): Free the error string. - (rule_context_finalise): Free the rules and parts. - -2001-08-07 Jeffrey Stedfast - - * filtertypes.xml: Reverted my previous change, I fixed the filter - code to handle this the way danw said to handle it in bug #5886 - now. - -2001-08-07 Jeffrey Stedfast - - * filtertypes.xml: Removed the "is" and "is not" rules from the - xml file for address matching because users are easily confused. - -2001-08-03 Jeffrey Stedfast - - * filter-rule.c (get_widget): Do an evil kludgy hack so that the - Rule Name entry widget gets focused when the filter editor is - shown. - -2001-08-02 Jeffrey Stedfast - - * filter-rule.c: Wrap some debug printf's with d(). - - * rule-context.h: Removed prototype for rule_context_delete_rule() - since the function doesn't exist. - -2001-07-23 Jon Trowbridge - - * vfolder-rule.c (validate): Added a validate function - that checks to make sure that vfolders that have "specific - folders" as their source actually have a non-empty list of - source folders selected. (Bug #4937) - (get_widget): If fr->source is NULL for some reason, bring - it into sync with the default in the option menu. - -2001-07-23 Peter Williams - - * filter-datespec.c (make_span_editor): Change the butt-ugly - UI to a saner (and just as flexible) one. Instead of all those - spinbuttons, just have one and let the user select the time unit. - (omenu_item_activated): New function. When the user changes the - time unit, convert it from the old number. Pretty. - (adj_value_changed): This function is now simpler. - (set_adjustments): Also modified for new UI model. - (button_clicked): Set the selected_type before calling the callback. - (FilterDatespecPrivate): Members change a bit. - (filter_datespec_init): No longer need to allocation spinbuttons - (filter_datespec_finalise): No longer need to free spinbuttons. - -2001-07-20 Jeffrey Stedfast - - * filtertypes.xml: Removed the "Forward To" filter action. - -2001-07-18 Jeffrey Stedfast - - * rule-context.c (rule_context_get_rank_rule): Return -1 if we - don't find it? This is what most of the code expected but not what - we were returning on fail. - -2001-07-12 Zbigniew Chyla - - * filter-datespec.c (stringify_agoness): Marked string for translation. - -2001-07-12 Jeffrey Stedfast - - * filtertypes.xml: Users should not be able to filter on "Status - is Deleted" since we don't allow that in the filter driver code. - -2001-07-11 Jason Leach - - * vfoldertypes.xml: Copied the "Attachments" rule part over from - filtertypes.xml, would be a powerful feature for vfolders (see all - the patches across all folders, or all the attachments you've sent, - without having to duplicate potentially big files, blah blah, bug - #1155). - -2001-07-10 Peter Williams - - * vfoldertypes.xml: Put a match-all around the not-body-contains - to make it work per-message. - - * filtertypes.xml: Same. - -2001-07-05 Jeffrey Stedfast - - * filter-rule.c (get_widget): Set the focus on the title of the - filter rule. - -2001-07-09 Anna Marie Dirks - - * rule-context.c (rule_context_add_rule_gui): Increased the size - of the "Add Filter Rule" dialog to 600 x 400, so that no resizing - is necessary to use the dialog. - -2001-07-09 Jon Trowbridge - - * filter-source.c (filter_source_get_sources): Bonobo-conf-ified. - Removed /home/trow hard-wiring. :) - (xml_encode): Encode things properly. - (xml_decode): Decode things properly. - (get_widget): Ignore accounts w/o source URLs. - (clone): Set the ->name in our copy. - -2001-07-05 Jeffrey Stedfast - - * rule-editor.c (rule_delete): Select the most appropriate filter - rule. - - * filtertypes.xml: Fix bug #4043: s/colour/color - -2001-07-03 Peter Williams - - * filter-source.c (get_widget): Prevent crashing while we work - this out. - - * filter-rule.c (get_widget): Don't try to gtk_widget_grab_default - with a widget that can't be the default. Altough it should be able - to.... - -2001-07-02 Sam Creasey - - * filter-int.c: Added an integer type for filtering values. used - for size. - - * Makefile.am (SOURCES): added filter-int.c, filter-int.h - - * filtertypes.xml: added a part entry for size based filters - -2001-07-02 Anna Marie Dirks - - * filter-rule.c (get_widget): Changed "Add criterion" button to - have normal button relief in response to complaints of it not - appearing clickable. - - * filter-filter.c: Changed "Add action" button to have normal - button relief in response to complaints of it not appearing - clickable. - -2001-06-29 Jeffrey Stedfast - - * rule-editor.c (rule_editor_construct): Set the filter-rule - dialog to be user-resizable. - -2001-06-27 Jeffrey Stedfast - - * filtertypes.xml: Make "Move" the default action. - -2001-05-08 Not Zed - - * filter-rule.c: Deleted Gediminas patch. - -2001-05-08 Gediminas Paulauskas - - * filter-rule.c (xml_decode): allow "_title" in user - rules. translate them and encode to utf8. - (get_rule_part_widget): do not call gettext on part->title. It is - always translated already. - -2001-04-26 Jeffrey Stedfast - - * rule-editor.c (rule_edit): Set the default size of the dialog to - 600x400, which seems to be a nice size that fits all the widgets - into it. - (rule_add): Same. - -2001-04-26 Dan Winship - - * Makefile.am (INCLUDES): Remove UNICODE_CFLAGS - -2001-04-26 Not Zed - - * filter-part.c (filter_part_xml_create): Blah blah fix for xml1 - broken utf8 encoding, and use "g" memory for all allocations. - (filter_part_finalise): Free our data properly. - -2001-04-20 Kjartan Maraas - - * filter-rule.c: Pull up fix for translation of filter - direction drop down menu from the branch. - -2001-04-18 Dan Winship - - * filter-colour.c, filter-datespec.c, filter-folder.c, - filter-input.c, filter-option.c, filter-rule.c, filter-score.c, - filter-source.c, score-rule.c (xml_decode): Plug memory leaks. - - * rule-context.c (rule_context_finalise): Implement. Free stuff. - - * filter-element.h: #include here for xmlFree - - * filter-filter.c, filter-part.c: Remove xmlmemory.h #include - -2001-04-15 Jeffrey Stedfast - - * filtertypes.xml: s/Is/is/ and s/Is Not/is not/ to be more - consistant with the rest. - -2001-04-13 Jon Trowbridge - - * filtertypes.xml: Add XML specs for source account filtering. - - * filter-element.c (filter_element_new_type_name): Recognize - type "source", construct a FilterSource. - - * filter-source.c: Added. A FilterElement for the account e-mail - comes from. - -2001-04-04 Kjartan Maraas - - * filter-editor.c: Fix headers. - * filter-filter.c: Same here. - * filter-option.c: Same here. - * filter-part.c: Same here. - * filter-rule.c: Same here. - * rule-editor.c: Same here. - * score-editor.c: Same here. - * vfolder-editor.c: Same here. - * vfolder-rule.c: Same here. - -2001-04-02 Jeffrey Stedfast - - * filter-filter.c (option_activate): Set the newpart on the - container object. - (less_parts): Remove the rule tht the user wants to remove. - (attach_rule): Attach a new rule and it's remove button to the end - of the table. - (more_parts): Fix to resize the table and such. - (get_widget): Don't have a remove action button, we are putting - this next to the rule part now. - -2001-03-30 Kjartan Maraas - - * *.*: Fix headers. Remove unneccesary ones and replace - with more finegrained ones where needed. - -2001-03-22 Jeffrey Stedfast - - * filter-datespec.c (validate): Oops, an unspecified date is '0', - not -1. - -2001-03-21 Jeffrey Stedfast - - * rule-context.c (new_rule_clicked): Validate the rule before - closing. - -2001-03-20 Jeffrey Stedfast - - * rule-editor.c (rule_edit): Set the editor dialog modal rather - than setting the filter dialog insensitive. Also ref re->edit - since we unref it when the editor closes. This should fix bug - #1905. - (edit_editor_clicked): No need to set the filter dialog sensitive - again. - (rule_add): Set the add-rule dialog modal and don't set the filter - dialog insensitive. - (add_editor_clicked): No need to set the filter dialog sensitive - again. - -2001-03-17 Jeffrey Stedfast - - * filter-option.c (build_code): Since we are now using - filter-option widgets in place of system-flag, we do not need a - "code" part so if there isn't a code part, don't build it. - (clone): Updated to allow NULL code parts. - -2001-03-17 Jeffrey Stedfast - - * filter-element.c (filter_element_new_type_name): If the filter - type is a "system-flag", use the optionlist type as type - system-flag has been removed. This should allow backward - compatability. - - * filter-editor.c (filter_editor_construct): Remove the menu that - is in the glade file because we want to replace it with our menu, - not append items to that menu. - - * filtertypes.xml: Oops, missed the system-flag action-set. - - * vfoldertypes.xml: Update "status" ruleset. - -2001-03-16 Jeffrey Stedfast - - * Makefile.am: Removed filter-url.[c,h] and - filter-system-flag.[c,h] - - * filter-element.c (filter_element_new_type_name): Removed - references to the url-type and system-flag types. - - * filtertypes.xml: Removed "source" type and fixed "status" to use - the optionmenu. - - * filter-url.[c,h]: Removed. - - * filter-system-flag.[c,h]: Removed (just use optionmenu). - -2001-03-15 Not Zed - - * filter.glade: Changed the edit_filter to be a standalone window - rather than a widget, so we can get the rule editor part out - separately. Same for vfolder editor, and new score, and basic rule - editors. - - * score-editor.c (score_editor_new): Turned back on object - stuff, subclass rule-editor, and removed most of the code. - - * filter-editor.c (filter_editor_new): Turned into an object, - subclass rule-editor, removed most of the code. Now we accept the - source list during create, and plug that into the glade. - - * vfolder-editor.c (vfolder_editor_new): Turned back on object - stuff, subclass rule-editor, and removed most of the code. - - * Makefile.am (libfilter_la_SOURCES): Added rule-editor.[ch]. - - * filter-filter.c (validate): inherit the validate function and - also validate the actions part of a filterfilter. - - * filter-rule.c (filter_rule_validate): New method so that filter - rules can validate themselves. - (validate): Default implementation, validates base rules. - - * rule-editor.h: New generic rule editor, to be used for filter - editor/vfolder editor/score editor/saved searches editor. - -2001-03-15 Gediminas Paulauskas - - * filter-system-flag.c: translate status flag title. - -2001-03-12 Jeffrey Stedfast - - * filtertypes.xml: Added an "Attachments" filter option where you - can filter messages that have (or do not have) attachments. This - does not allow you to filter based on the types of the - attachments. - -2001-03-08 Jeffrey Stedfast - - * vfolder-editor.c (double_click): Make sure we have something - selected first ;-) - - * filter-editor.c (double_click): And here too. - -2001-03-03 Not Zed - - * filter.glade: Added option menu to vfolder editor. - -2001-03-02 Not Zed - - * vfolder-rule.c (get_widget): Setup the data on the base source - opiton menu, and make hte option menu reflect the source. - (select_source_with): Set the source type for this - rule. e.g. these folders, "with ..." - - * filter-editor.c: Removed the N_() stuff from the source_names - array, they must not be internationalised!!! - -2001-02-28 Not Zed - - * filter-rule.c (filter_rule_clone): New function to clone rules. - -2001-02-23 Not Zed - - * filtertypes.xml: Added mailing list matching rules. - renamed mailing list options to be more meaningful. - - * vfoldertypes.xml: Added mailing list rules. - renamed mailing list options to be more meaningful. - -2001-02-11 Gediminas Paulauskas - - * filter.glade.h: removed. - * filter.glade: do not donnt output to above one. - * Makefile.am: do not include filter.glade.h in EXTRA_DIST. - -2001-02-06 Dan Winship - - * filter-option.c (get_widget): Translate the option title. - (Noticed by Kjartan). - -2001-02-05 Kjartan Maraas - - * filter-code.c, filter-colour.c, filter-context.c, - filter-element.c, filter-input.c, filter-score.c, - filter-system-flag.c, filter-url.c: Add #include - and mark some strings for translation. - -2001-01-22 Not Zed - - * filter-message-search.[ch]: Removed, now lives in - camel-filter-search.* - - * Makefile.am (libfilter_la_SOURCES): Removed filter-driver.[ch] - and filter-message-search.[ch]. - - * filter-driver.[ch]: Removed. now lives in camel-filter-driver.* - -2001-01-19 Jeffrey Stedfast - - * filter-driver.c (filter_driver_filter_message): Set the delete - bit *before* copying to the default folder. - -2001-01-18 Jeffrey Stedfast - - * filter-filter.c (less_parts): Er, don't set the button - insensitive if there is *1* action, set it insensitive if there - are less than or equal to *1* actions. Doh! - (more_parts): Only set the remove button sensitive if there is - more than 1 action. - (get_widget): Here too. - -2001-01-16 Jason Leach - - * e-search-bar.[ch]: Moved ESearchBar to $(toplevel)/widgets/misc, - a more appropriate home. Bug #1060. - -2001-01-13 Jeffrey Stedfast - - * filter-driver.c (do_copy): Moved p->copied to the inner part of - the loop so that in the case of a folder not existing, it doesn't - think that the message was already copied to some place and thus - not save it to the Inbox. - (do_move): Same. - -2001-01-10 Jeffrey Stedfast - - * filtertypes.xml: Changed Priority to Score. - - * filter-option.c (get_widget): Attach to the "activate" signal - - this should now make it so that a filter-option will "remember" - what a user changed. - - * filter-system-flag.c (get_widget): Don't reset fsf->value to the - first system flag, this should already be defaulted to the - appropriate flag. This should fix the problem of always defaulting - to the first menu option and thus "forgetting" the user's settings. - -2001-01-04 Jeffrey Stedfast - - * filter-system-flag.c: comment out some of the system flags as we - don't want to use them. - (xml_encode): Update the printf - (get_widget): Use strcmp instead of g_strcasecmp. - -2001-01-02 Lauris Kaplinski - - * filter-input.c (xml_encode): Encode utf8 - (xml_decode): Decode utf8 - - * filter-option.c (xml_create): Decode utf8 - - * filter-part.c (filter_part_xml_create): Decode utf8 - - * filter_rule.c (xml_encode): Encode utf8 - (xml_decode): Decode utf8 - -2001-01-02 Jeffrey Stedfast - - * filter-driver.c (do_flag): Set the 'dirty' flag - this should - fix the problem of flags not being set (or, more precisely, - synced). - (filter_driver_filter_message): Here too. - -2000-12-21 Jeffrey Stedfast - - * filter-message-search.c (header_contains): Use - e_utf8_strstrcase() instead of just strstr(). - (header_starts_with): Make sure that the header contents are - longer than the starts-with string. - - * vfoldertypes.xml: Don't send \"Subject\" to body-contains. - Also added matches, starts-with, and ends-with xml stuff. - -2000-12-28 Dan Winship - - * filter-message-search.c (handle_multipart, body_contains, - body_regex): Use CamelContentType rather than GMimeContentField. - -2000-12-24 Not Zed - - * Merge from camel-mt-branch. - -2000-12-21 Not Zed - - * filter-message-search.c (filter_message_search): And here too. - - * filter-driver.c (filter_driver_finalise): Kind of revert an - accidentally commited patch for e_sexp_unref. - -2000-12-20 Jeffrey Stedfast - - * filter-driver.c (filter_driver_filter_message): Oops, slight - logic error. We want to copy the message to the default folder if - the message hasn't been Moved (which is the same as Copied && - Deleted). This fixes bug #1007. - - * filter-rule.c (more_parts): Make sure we have more than 1 part - before we sensitize the "remove" button. - -2000-12-20 Not Zed - - * filter-message-search.c (filter_message_search): Oops, missed a - gtk unref of the now-no-longer gtk e_sexp. - - * filter-driver.c: Remove mail_tool_lock stuff. - (filter_driver_finalise): unref e_sexp properly. - -2000-12-12 Christopher James Lahey - - * e-search-bar.c (esb_pack_menubar): Fixed some warnings. - -2000-12-11 Jeffrey Stedfast - - * filter-folder.c (button_clicked): Added a kludge, 'is_active' - which is a static variable that holds whether or not there is an - active shell folder dialog up or not. - - * vfolder-editor.c (rule_delete): Autoselect the rule that ends up - in the same position (or the one above it if the list is shorter - than the position). - -2000-12-08 Jeffrey Stedfast - - * filter-rule.c (get_widget): Don't highlight the title if it's - "Untitled" because switching widget focus doesn't cause this - selection to go away. - -2000-12-06 Kjartan Maraas - - * filter-editor.c: Mark some strings for translation. - -2000-12-01 Jeffrey Stedfast - - * filter-element.c (filter_element_new_type_name): Added support - for the system-flag type. - - * Makefile.am: Added filter-system-flag.[c,h]. - - * filter-system-flag.[c,h]: New type for system flags. - - * filtertypes.xml: Oops, looks like we were still using integers - as arguments to set-flag. Change over to using strings which are - safer and also change the name to set-system-flag. - - * filter-driver.c (do_flag): Use strings instead of integers. - Instead of set-flag, the callback is now set-system-flag for less - confusion. Sorry Ettore, but you'll have to change your filters. - - * filtertypes.xml: Added system-flags stuff. - - * vfoldertypes.xml: And here too. - - * filter-message-search.c (system_flag): New ESExp callback for - filtering on system flags. - -2000-11-30 Jeffrey Stedfast - - * filter-driver.c (filter_driver_filter_message): Use - camel_message_info_free() instead of freeing everything by hand - - is this a new function? I don't ever recall seeing this - before. Also use my new function, - camel_message_info_new_from_header - ahhh... this code is now so - beatiful. Okay, I'm done. - -2000-11-30 Jeffrey Stedfast - - * filter-driver.c (filter_driver_filter_message): Update to use - EStrv in appropriate places (wrapped with #ifdef DOESTRV for the - moment). - -2000-11-27 Jeffrey Stedfast - - * filtertypes.xml: Moved the regex filter rule around - we've - changed the format a bit. - - * filter-option.c (option_activate): Removed. - (get_widget): Don't connect the activate signal. - - * filter-folder.c (validate): Updated. - - * filter-datespec.c (validate): Updated. - - * filter-part.c (filter_part_validate): Updated. - - * filter-input.c (validate): Check the filter-input type - if it's - of type "regex", then check for regex validity. - - * filter-element.c (filter_element_validate): No longer takes a - gpointer argument. - (filter_element_new_type_name): Allow type "regex" and create a - new filter-input with type "regex". - -2000-11-24 Michael Meeks - - * filter-message-search.c (get_full_header): impl. - (header_full_regex): use it. - -2000-11-23 Michael Meeks - - * filter-message-search.c (header_full_regex): impl. - -2000-11-21 Jeffrey Stedfast - - * filter-message-search.c: took out some no longer needed - printfs. - -2000-11-15 Jeffrey Stedfast - - * filter-driver.c (filter_driver_filter_folder): Sync here - instead. - (filter_driver_filter_mbox): And here too. - (filter_driver_finalise): Don't sync here afterall - it's more - preferable to sync right after processing. - -2000-11-15 Jeffrey Stedfast - - * filter-driver.c (filter_driver_finalise): Sync the - defaultfolder. - (filter_driver_filter_folder): Sync here instead. - (filter_driver_filter_mbox): And here too. - -2000-11-13 Jeffrey Stedfast - - * filter-message-search.c (header_matches): Neglect any leading - whitespace in the header contents. - (header_starts_with): Same. - (header_ends_with): Same. - (header_soundex): Same. - -2000-11-12 Jeffrey Stedfast - - * filter-driver.c (filter_driver_filter_message): If there is a - default folder and the message hasn't been deleted then... should - be: If there is a default folder and the message hasn't been - copied to another folder and the message hasn't been deleted... - (filter_driver_filter_message): Make it so that the FILTER_LOG_END - is only called if filtered were applied to the message so we don't - get huge gaps of whitespace in the log file. - (filter_driver_filter_message): - -2000-11-10 Christopher James Lahey - - * e-search-bar.c: Made the underline show up properly in the main - menu bar. - -2000-11-10 Christopher James Lahey - - * e-search-bar.c: Switched from using gtk_menu_item_new_with_label - for the menu header to using gnome_stock_menu_item. - -2000-11-08 Anna Marie Dirks - * e-search-bar.c: Fixed two spacing problems: first, changed - the spacing around the end of the text-entry widget so that - the text entry is always aligned with the beginning of the scrollbar; - second, trimmed down the space between the widgets in the search bar. - - -2000-11-06 Not Zed - - * filter-driver.c (do_flag): you shouldn't use an integer to - set the flag. You should use a string, and look it up, because - the flag bits might change. - (filter_driver_filter_message): Can som e one PLEASE STOP - INDENTING THE CODE. Even if i have to come over the and - beat it into you. YOU DONT INDENT CODE ONCE ITS BEEN CHECKED IN - TO CVS, otherwise you SCREW UP THE DIFF's. Can't you please - please learn this? - (filter_driver_log): Fixes for api changes to mime_message. - -2000-11-05 Not Zed - - * filter-message-search.c (get_sent_date): Fix for date change - api. No longer need to encode/decode the date, after its been - encoded/ecoded already. - (get_received_date): Likewise. - -2000-11-06 Christopher James Lahey - - * e-search-bar.h: Fixed the argument comment. Removed an old enum - that's not used here. - -2000-11-06 Christopher James Lahey - - * Makefile.am: Added e-search-bar.c and e-search-bar.h. - - * e-search-bar.c, e-search-bar.h: Moved this from - e-addressbook-search. - -2000-11-02 Jeffrey Stedfast - - * filter-driver.c (filter_driver_log): Fix for when 'desc' is - NULL. - (filter_driver_filter_message): Use a more user-friendly filter - name in the log file. - -2000-11-01 Jeffrey Stedfast - - * filter-driver.c (filter_driver_filter_message): Use - filter_driver_log() where appropriate. - (do_copy): Use the service url for the path rather than the - folder->full_name because that'll only get you a "/mbox" which is - entirely useless. Replace occurences of report_status with - filter_driver_log. - (do_move): Same. - (report_status): Don't use this for logging anymore, use only for - reporting the status back to the caller. - (filter_driver_log): Renamed from filter_driver_status_log. Now - ONLY handles file logging and is for INTERNAL USE ONLY. - (do_flag): Replace occurences of report_status with - filter_driver_log. - (do_score): Same. - (do_colour): Same. - (do_stop): Same. - -2000-11-01 Jeffrey Stedfast - - * filter-datespec.c (validate): Check to make sure the user has - entered a valid date. - -2000-10-31 Jeffrey Stedfast - - * filtertypes.xml: Updated to allow the user to select "sounds - like" or "does not sound like" (uses header-soundex). - - * filter-message-search.c (header_matches): Oops. Should be using - !g_strncasecmp. This should fix it so this filter match works - right. - (header_starts_with): Same. - (header_ends_with): Same. - (header_soundex): New filter callback for soundex matching (yes, - it's probably a bloated feature but hey, it was fun to code) - -2000-10-31 Jeffrey Stedfast - - * filter-folder.c (validate): Override the default validate - function to only return TRUE if a folder has been selected. - - * filter-editor.c (rule_add): Validate that all the rule parts and - action parts are correctly filled in. - (rule_edit): Same. - -2000-10-31 Jeffrey Stedfast - - * filtertypes.xml: Updated to add an action to set message flags. - - * filter-driver.c (do_flag): New callback to set message info - flags. - - * filter-element.c (filter_element_set_data): New convenience - function to set the data on a FilterElement. - - * filter-url.c (get_widget): Set the sources list to point to the - FilterElement data. - -2000-10-31 Federico Mena Quintero - - * filter-rule.c (get_widget): Do not pad around the Name hbox; - its parent already has spacing. - Do not pad around the inframe's children; the inframe already has - spacing. - -2000-10-30 Jeffrey Stedfast - - * filter-option.c (option_activate): If a regex option is - selected, change the FilterElement data to TRUE else set to FALSE. - - * filter-rule.c (more_parts): Validate the previously entered - FilterPart before allowing the user to add a new FilterPart. - - * filter-part.c (filter_part_validate): New convenience function - to validate an entire FilterPart expression. - - * filter-input.c (validate): Validate the entry text if it - contains a regular expression. - - * filter-element.[c,h]: New virtual function to validate the - contents of the FilterElement (useful for regex and sexp). - (filter_element_validate): You get the idea... - -2000-10-30 Jeffrey Stedfast - - * filter-input.c: - * filter-option.c: - * filter-part.c: Pure formatting changes, no actual code - changes. Since I know I'm going to get flamed for this, I'm sorry - but I'll probably have to modify code in these files and it's - easier if the code is quickly readable by me. - - * filter-rule.c (get_widget): Set the "remove" button insensitive - for <= 1 instead of == 1. - -2000-10-28 Jeffrey Stedfast - - * filter-driver.c (filter_driver_filter_message): Copy the message - to the default folder if it wasn't marked as deleted. - -2000-10-27 Jeffrey Stedfast - - * filtertypes.xml: Added header-starts-with, header-ends-with, and - header-exists menu items. - - * filter-message-search.c (header_starts_with): New callback to - match the beginnings of headers. - (header_ends_with): New callback to match the ends of headers. - (header_exists): New callback to determine if a header exists - which is useful when filtering out all those pesky bug-buddy - emails! - -2000-10-27 Jeffrey Stedfast - - * filtertypes.xml: Add header-matches expressions ("is" / "is not"). - - * filter-message-search.c (header_matches): New callback to match - headers exactly (aka strcmp rather than strstr). - -2000-10-27 Jacob "Ulysses" Berkman - - * filter-driver.c (filter_driver_filter_mbox): divide before - multiple so that we don't overflow. - -2000-10-27 Christopher James Lahey - - * Makefile.am: Fixed this to include EXTRA_GNOME_CFLAGS. - -2000-10-27 Jeffrey Stedfast - - * filter-driver.c (do_move): Don't mark as deleted here, otherwise - the message will have the DELETED flag set in the folder it's - being moved to. - (do_delete): Don't set the DELETED flag here either...we'll only - set it at the very end of the filtering process. - (filter_driver_filter_message): Set the DELETED flag after all - processing is completed. - -2000-10-26 Jeffrey Stedfast - - * filtertypes.xml: Readded Source url stuff. - - * filter-element.c (filter_element_new_type_name): Added url stuff - back in. - - * filter-url.[c,h]: Back from the dead... - - * Makefile.am: Re-added filter-url.[c,h]. - -2000-10-25 Jeffrey Stedfast - - * filtertypes.xml: Added option menu items to allow searching - based on regular expressions. - - * filter-message-search.c (body_regex): New callback to match text - in the body using regex. - (body_contains): Modified to only match using strstr. - (header_regex): New callback to match headers using regex. - (header_contains): Modified to only match using strstr. - -2000-10-24 Jeffrey Stedfast - - * filtertypes.xml: Take out the reference to "Source". - - * filter-element.c (filter_element_new_type_name): Remove - filter-url code. - - * filter-url.[c,h]: What was I smoking? There's no good reason to - filter on source urls as there are other ways to get the same - effect. Thanks to both Zucchi and Miguel for helping me see this - :-) - -2000-10-24 Jeffrey Stedfast - - * filter-driver.c: Fixed NULL in fprintf. - -2000-10-24 Dan Winship - - * Makefile.am (libfilter-i18n.h): Build a fake header file with - the titles from the xml files, for translation purposes. - - * filter-rule.c (get_rule_part_widget): Call _() on the rule's - title. - - * filter-option.c (get_widget): Call _() on the option's title. - - * filter.glade: Turn on translatable strings. - - * libfilter-i18n.h, filter.glade.h: Translatable string files. - - * add #include to a bunch of C files so that _() - actually does anything. Undo some UTF8 frobs since we're now - dealing in localized strings. - -2000-10-23 Jeffrey Stedfast - - * filter-filter.c (less_parts): Set the remove button insensitive - if there is only 1 action left. - (more_parts): Set the remove button sensitive (since we now have 2 - or more actions). - (get_widget): If there is only 1 action, disable the remove - button. - - * filter-rule.c (xml_encode): If there is a defined source, don't - set it to "incoming", set it to whatever the source is! - (less_parts): Set the remove button insensitive if there is only 1 - criterion left. - (more_parts): Set the remove button sensitive (since we now have 2 - or more criterion). - (get_widget): If there is no name for the filter then set it to - "Untitled", highlight it, and grab the focus. If there is only 1 - criterion, disable the remove button. - - * filter-editor.c, vfolder-editor.c: GUI fixes here and there as - well as some consistancy fixes between them. - - * filter-driver.c (filter_driver_filter_mbox): Updated to send the - source url to filter_driver_filter_message() - (filter_driver_filter_folder): Updated to send the source url of - the folder to filter_driver_filter_message() - (filter_driver_filter_message): Now takes a source_url argument - that represents the url of the folder the message is coming from - (so that we may filter based upon that information). - -2000-10-23 Christopher James Lahey - - * filter.glade: Fixed these widgets to resize properly. - -2000-10-23 Jeffrey Stedfast - - * filter-editor.c: Remove the "demand" source from the list. - - * filter.glade: Remove the "On Demand" option and replace it with - an "Outgoing" option. - -2000-10-23 Christopher James Lahey - - * filter-editor.c, filter-filter.c, filter-folder.c, - filter-part.c, filter-rule.c, rule-context.c, score-editor.c, - vfolder-editor.c: Fixed these widgets to resize properly. - -2000-10-20 Jeffrey Stedfast - - * Makefile.am: Added filter-url.[c,h]. - - * filter-message-search.c (get_source): New callback to get the - source url of the message being filtered. - (filter_message_search): Now takes a source argument. - - * filter-element.c (filter_element_new_type_name): Added code to - handle URL types. - - * filter-url.[c,h]: New filter object to handle URLs (ie in the - case of filtering on source url). FIXME: find a way to populate - the source combo box (including mail-config.h breaks the build in - the addressbook - how does including mail-tools.h not break the - build???) - - * filtertypes.xml: Added the source filter type and added the - move-to action. - - * filter-driver.c (do_move): New callback, a "Copy" action should - just copy the message to another location while a Move should both - copy the message to a new location and delete it from the source - location. - (do_delete): Set the deleted flag on the message info. - (filter_driver_filter_message): Now returns void as we don't care - if it was copied or not in the caller functions. Also check the - CamelMessageInfo being passed in - if the message has been marked - as deleted prior to being filtered, then return immediately as we - don't want to apply filter actions to deleted messages. - -2000-10-19 Jeffrey Stedfast - - * filter-driver.c (filter_driver_filter_folder): Start fetching at - 1, not 0. - -2000-10-11 Not Zed - - * filter-driver.c (filter_driver_filter_mbox): Report the - percentage of file complete for the filter. - -2000-10-10 Not Zed - - * filter-driver.c (filter_driver_run): Why on earth does this code - ref all these objects for? This is not right at all. - (filter_driver_run): Changed source type to a string. - (filter_driver_run): REmove the very weird exception copying - stuff - just ref it instead. - (do_score): - (do_colour): - (do_stop): - (do_copy): - (mark_forward): - (do_delete): Removed bogus 'terminated' testing. This is NOT - NEEDED HERE. It is tested after every rule/action, and - termination only makes sense at that point. - (filter_driver_filter_message): new funciton (renamed), filter - only a message. - (filter_driver_filter_mbox): Filter a whole mbox. - (filter_driver_run): If we aren't given an info, create a simple - one based on the message headers. - (filter_driver_filter_message): Renamed from filter_driver_run(). - (filter_driver_set_status_func): Set the status callback function. - (filter_driver_set_default_folder): Set the default folder for - filtering. - (report_status): Internal function to report the status of a given - event. - (do_copy): Removed a pointless cache lookup - duh, we do it in - open_folder anyway (infact, we do it in camel too!!). - (filter_driver_filter_message): Removed pointless re-refing of - arguments. Why would anyone think this could be any use at all? - (filter_driver_filter_folder): New function to filter a whole - folder. - - * filter-editor.c (rule_add): api fixes. - (rule_edit): - (rule_up): - (rule_down): - (set_sensitive): This didn't take into account the source, now it - does. - (select_source): Fix for api changes. Changed the rather generic - 'number' argument to be 'source', and a string. - (filter_editor_construct): Changed the 'number' to 'source', and - set the string appropriately. Added a warning for one case where - the glade file is out of sync. - - * score-editor.c (score_editor_construct): - (rule_edit): - (rule_delete): - (rule_up): - (rule_down): - (set_sensitive): api fixes. - - * vfolder-editor.c (set_sensitive): Api fixes. - (vfolder_editor_construct): - (rule_edit): - (vfolder_editor_construct): - - * rule-context.h (RCNextRuleFunc): Added a source argument. - - * rule-context.c (rule_context_next_rule): Added source argument. - (rule_context_find_rule): Added source argument. - (rule_context_get_rank_rule): Added source argument. - (rule_context_get_rank_rule_with_source): Removed. - (save): Fixed for changes to RCNextRuleFunc prototype. - - * filter-rule.h: Changed the source to be a string, removed the - filter_source_t type. - - * filter-rule.c (filter_rule_set_source): New function to set the - source of a rule. What idiot ran this code through indent? - (filter_rule_find_list): Added a source argument. - (filter_rule_next_list): Added a source argument. - (get_widget): Fixed the wording. You dont remove search parts, - you can only remove the last one. Why you even need to mention - they are search 'criteria' is beyond me. Whoever added the - scrolled window needs to be shot, its the single most awful GUI - feature ever invented (ranks with the close button next to - maximise). - (xml_encode): Save source as a string (if present). - (xml_decode): Likewise for loading & fixed a small memleak. - (filter_rule_finalise): Free source. - -2000-10-06 Not Zed - - * rule-context.c (load): Remove the stupid on-demand cb shit. - (rule_context_load): And here too. - -2000-09-27 Jeffrey Stedfast - - * filter-driver.c (filter_driver_run): Now takes an argument to - specify the log file (or NULL if logging is not to be performed). - -2000-09-19 Dan Winship - - * Makefile.am (gladedir, filterdir): Use $(datadir), not - $(prefix)/share. - -2000-09-18 Jeffrey Stedfast - - * filtertypes.xml: Modified to use more intuitive naming - - * score-rule.c (xml_decode): Make sure the score is within our - range - (get_widget): Changed range to -3 to +3 - - * filter-score.c (get_widget): Changed range to -3 to +3 - (xml_decode): Make sure the score is within our range - - * filter-rule.c (get_widget): Rearranged widgets. - - * filter-filter.c (get_widget): Rearranged widgets. - - * filter-editor.c (filter_editor_construct): Updated to allow for - double-clicking on a rule to edit it. - -2000-09-18 Christopher James Lahey - - * filter-editor.c, filter-filter.c, filter-folder.c, - filter-input.c, filter-message-search.c, filter-option.c, - filter-rule.c, score-editor.c, vfolder-editor.c, vfolder-rule.c: - Fixed the #include lines to deal properly with gal. - -2000-09-13 Jeffrey Stedfast - - * filter-message-search.c (body_contains): Modified to only match - text MIME parts in the message rather than the entire MIME message - (header_contains): Added regex matching - -2000-09-12 Dan Winship - - * rule-context.c (d): - * filter-datespec.c (d): Turn off debugging output. - -2000-09-11 Jeffrey Stedfast - - * filter-driver.c: We now use a "copied" variable to record - whether a message was marked as copied or not instead of trying to - "guess" by looking at the folders hash table as that won't work at - all anymore. - (do_copy): Renamed as this is more appropriate now that it - actually copies the message rather than marking it for copying - later. Also fixed a logic error which prevented a message from - being dumped into a folder if the fodler had been previously - opened. - -2000-09-11 Jeffrey Stedfast - - * filter-driver.c (filter_driver_run): No longer takes a - self_destruct argument. - -2000-09-11 Jeffrey Stedfast - - * filter-driver.c (filter_driver_run): Don't freeze/thaw the - default inbox here, let the caller freeze/thaw it. Don't destroy - the folders hash table here, it's faster if we wait till the - filter-driver is destroyed. - (filter_driver_finalise): Destroy the folders hash table here - (filter_driver_init): Initialize the folders hash table here - -2000-09-11 Jeffrey Stedfast - - * filtertypes.xml: Changed "Header" to be "Message header" so it's - not quite as confusing (??) - -2000-09-11 Jeffrey Stedfast - - * filtertypes.xml: Updated to allow the user to specify arbitrary - headers. - -2000-09-09 Jeffrey Stedfast - - * filter-driver.c (filter_driver_run): Fixed a logic error. Only - mark filtered as TRUE if it was successfully copied to another - folder, this means don't mark true if the default inbox is NULL. - -2000-09-09 Jeffrey Stedfast - - * filter-driver.c (filter_driver_run): Erm, okay I misunderstood - what camel_folder_[un]hook_event() did - we don't even need this - crap in the filter driver so lets take it completely out and let - the caller handle this junk. - -2000-09-09 Jeffrey Stedfast - - * filter-driver.c (filter_driver_run): Updated to not emit the - folder_changed signal when a message is appended to the default - mailbox - lets leave that up to the caller so we don't queue up a - bunch of these emits if the caller is downloading messages for - example. - -2000-09-08 Jeffrey Stedfast - - * filtertypes.xml: Added scoring xml stuffs - - * Makefile.am: added filter-score.[c,h] - - * filter-score.[c,h]: New functions to handle the "score" filter - type. - - * filter-element.c (filter_element_new_type_name): Added support - for "score" type. - - * filter-driver.c (do_score): New ESExp callback for filter - actions to set the score on a message. - - * filter-message-search.c (get_score): New ESExp callback for - getting the score tag as an integer value. - -2000-09-07 Jeffrey Stedfast - - * filter-driver.c (filter_driver_run): Now takes a - CamelMessageInfo argument in preparation for handling scoring - -2000-09-07 Jeffrey Stedfast - - * filter-driver.c (filter_driver_run): Modified to return a - boolean value specifying whether or not the message was filtered - into a folder other than the default. The default mailbox can now - also be specified as NULL if the message shouldn't be appended to - it in the case that it's not filtered into some other folder. - -2000-09-07 Jeffrey Stedfast - - * filter-driver.c (filter_driver_run): Rewrote - this shouldn't - need to be an async function - - * filter-message-search.c (match_all): Modified to look at the - boolean value being fed to it and just to return that instead of - always returning TRUE - -2000-09-07 Lauris Kaplinski - - * filter-editor.c, filter-filter.c, filter-folder.c, filter-option.c: - * filter-rule.c, score-editor.c, vfolder-editor.c, vfolder-rule.c: - More UTF-8 wrapping - -2000-09-06 Jeffrey Stedfast - - * filter-driver.c (filter_driver_run): Totally rewritten to filter - a single message at a time instead of filtering a folder. - - * filter-message-search.c (filter_message_search): New convenience - function for searching a message. - -2000-08-24 Lauris Kaplinski - - * filter-folder.c: Use e_utf8 wrappers - - * filter-input.c: Use e_utf8 wrappers - - * filter-rule.c: Use e_utf8 wrappers - -2000-08-23 Dan Winship - - * filter-datespec.c (cal_day_selected): Set seltime.tm_isdst to - -1, not daylight, because the current dst value is not relevant to - the selected date. - -2000-08-18 Peter Williams - - * filter-driver.c (do_filter_mail): Unlink a new parameter, path_to_unlink, - if it is empty once the mail is filtered. Fixes a race in - mail_tool_filter_contents_into. - - * filter-driver.h: Update the prototype. - -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 17b150baa9..0000000000 --- a/filter/Makefile.am +++ /dev/null @@ -1,85 +0,0 @@ - -gladedir = $(datadir)/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) \ - $(BONOBO_GNOME_CFLAGS) \ - $(EXTRA_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-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-int.c \ - filter-int.h \ - filter-option.c \ - filter-option.h \ - filter-part.c \ - filter-part.h \ - filter-rule.c \ - filter-rule.h \ - filter-score.c \ - filter-score.h \ - filter-source.h \ - filter-source.c \ - rule-context.c \ - rule-context.h \ - rule-editor.c \ - rule-editor.h \ - score-context.c \ - score-context.h \ - score-editor.c \ - score-editor.h \ - score-rule.c \ - score-rule.h \ - vfolder-context.c \ - vfolder-context.h \ - vfolder-editor.c \ - vfolder-editor.h \ - vfolder-rule.c \ - vfolder-rule.h - -libfilter_la_DEPENDENCIES = libfilter-i18n.h - -EXTRA_DIST = filtertypes.xml vfoldertypes.xml \ - $(glade_DATA) libfilter-i18n.h - -# basic rules. -filterdir = $(datadir)/evolution -filter_DATA = filtertypes.xml vfoldertypes.xml - -libfilter-i18n.h: filtertypes.xml vfoldertypes.xml - echo "/* Automatically generated. Do not edit. */" > $@; \ - cat $(srcdir)/filtertypes.xml $(srcdir)/vfoldertypes.xml | \ - sed -n -e 's:.*\(.*\):char *s = N_("\1");:p' | \ - sort -u >> $@ diff --git a/filter/filter-code.c b/filter/filter-code.c deleted file mode 100644 index eb4de2f374..0000000000 --- a/filter/filter-code.c +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (C) 2000 Ximian Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#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 = xmlStrdup("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 3f640fe909..0000000000 --- a/filter/filter-code.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2000 Ximian Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef _FILTER_CODE_H -#define _FILTER_CODE_H - -#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 0836c30932..0000000000 --- a/filter/filter-colour.c +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright (C) 2000 Ximian Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#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; - - xmlFree (fe->name); - 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 95ca2a4249..0000000000 --- a/filter/filter-colour.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2000 Ximian Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef _FILTER_COLOUR_H -#define _FILTER_COLOUR_H - -#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 aa3b36a5ee..0000000000 --- a/filter/filter-context.c +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright (C) 2000 Ximian Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include -#include - -#include "filter-context.h" -#include "filter-filter.h" - -/* For poking into filter-folder guts */ -#include "filter-folder.h" - -#define d(x) - -static void filter_context_class_init (FilterContextClass *class); -static void filter_context_init (FilterContext *gspaper); -static void filter_context_finalise (GtkObject *obj); - -static int filter_rename_uri(RuleContext *f, const char *olduri, const char *newuri, GCompareFunc cmp); -static int filter_delete_uri(RuleContext *f, const char *uri, GCompareFunc cmp); - -#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; - RuleContextClass *rule_class = (RuleContextClass *)class; - - object_class = (GtkObjectClass *)class; - parent_class = gtk_type_class(rule_context_get_type ()); - - object_class->finalize = filter_context_finalise; - - /* override methods */ - rule_class->rename_uri = filter_rename_uri; - rule_class->delete_uri = filter_delete_uri; - - /* 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; - - g_list_foreach(o->actions, (GFunc)gtk_object_unref, NULL); - g_list_free(o->actions); - - ((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); -} - -/* We search for any folders in our actions list that need updating, update them */ -static int filter_rename_uri(RuleContext *f, const char *olduri, const char *newuri, GCompareFunc cmp) -{ - FilterRule *rule; - GList *l, *el; - FilterPart *action; - FilterElement *element; - const char *name; - int count = 0; - - name = strrchr(newuri, '/'); - if (name) - name++; - else - name = newuri; - - d(printf("uri '%s' renamed to '%s'\n", olduri, newuri)); - - /* For all rules, for all actions, for all elements, rename any folder elements */ - /* Yes we could do this inside each part itself, but not today */ - rule = NULL; - while ( (rule = rule_context_next_rule(f, rule, NULL)) ) { - int rulecount = 0; - - d(printf("checking rule '%s'\n", rule->name)); - - l = FILTER_FILTER(rule)->actions; - while (l) { - action = l->data; - - d(printf("checking action '%s'\n", action->name)); - - el = action->elements; - while (el) { - element = el->data; - - d(printf("checking element '%s'\n", element->name)); - if (IS_FILTER_FOLDER(element)) - d(printf(" is folder, existing uri = '%s'\n", FILTER_FOLDER(element)->uri)); - - if (IS_FILTER_FOLDER(element) - && cmp(((FilterFolder *)element)->uri, olduri)) { - d(printf(" Changed!\n")); - filter_folder_set_value((FilterFolder *)element, newuri, name); - rulecount++; - } - el = el->next; - } - l = l->next; - } - - if (rulecount) - filter_rule_emit_changed(rule); - - count += rulecount; - } - - return count + parent_class->rename_uri(f, olduri, newuri, cmp); -} - -static int filter_delete_uri(RuleContext *f, const char *uri, GCompareFunc cmp) -{ - /* We basically should do similar to above, but when we find it, - Remove the action, and if thats the last action, remove the rule? */ - - /* But i'm not confident the rest of the mailer wont accidentlly delete - something which was just temporarily not available. */ - - return parent_class->delete_uri(f, uri, cmp); -} - diff --git a/filter/filter-context.h b/filter/filter-context.h deleted file mode 100644 index d9d78af2af..0000000000 --- a/filter/filter-context.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2000 Ximian Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef _FILTER_CONTEXT_H -#define _FILTER_CONTEXT_H - -#include "rule-context.h" - -#define FILTER_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 c01ea56f94..0000000000 --- a/filter/filter-datespec.c +++ /dev/null @@ -1,763 +0,0 @@ -/* - * Copyright (C) 2000 Ximian Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "filter-datespec.h" -#include "e-util/e-sexp.h" - -#define d(x) - -static gboolean validate (FilterElement *fe); -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 void omenu_item_activated (GtkMenuItem *item, 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 DAY_INDEX 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; - GtkWidget *omenu, *spinbutton, *recent_item; - gboolean double_click; -}; - -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->validate = validate; - 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; -} - -static void -filter_datespec_finalise(GtkObject *obj) -{ - FilterDatespec *o = (FilterDatespec *)obj; - - if (o->priv) - 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 gboolean -validate (FilterElement *fe) -{ - FilterDatespec *fds = (FilterDatespec *) fe; - gboolean valid = TRUE; - - if (fds->value <= 0) { - GtkWidget *gd; - - valid = FALSE; - - if (fds->type == FDST_UNKNOWN) - gd = gnome_ok_dialog (_("You have forgotten to choose a date.")); - else - gd = gnome_ok_dialog (_("You have chosen an invalid date.")); - - gnome_dialog_run_and_close (GNOME_DIALOG (gd)); - } - - return valid; -} - -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)); - - xmlFree (fe->name); - fe->name = xmlGetProp (node, "name"); - - n = node->childs; - while (n) { - if (!strcmp (n->name, "datespec")) { - val = xmlGetProp (n, "type"); - fds->type = atoi (val); - xmlFree (val); - val = xmlGetProp (n, "value"); - fds->value = atoi (val); - xmlFree (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; - PRIV (fds)->selected_type = fds->type; - - (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; - GtkObject *adj; - GtkWidget *hbox, *menu, *om, *sb, *label; - - /*PRIV (fds)->span_chooser = gtk_vbox_new (TRUE, 3);*/ - - hbox = gtk_hbox_new (TRUE, 3); - - adj = gtk_adjustment_new (0.0, 0.0, - /*timespans[i].max*/100000.0, - 1.0, 10.0, 0.0); - sb = gtk_spin_button_new (GTK_ADJUSTMENT (adj), 0, 0); - gtk_widget_show (GTK_WIDGET (sb)); - gtk_box_pack_start (GTK_BOX (hbox), sb, TRUE, TRUE, 0); - - menu = gtk_menu_new (); - for (i = 0; i < N_TIMESPANS; i++) { - GtkWidget *item; - - item = gtk_menu_item_new_with_label (gettext (timespans[i].plural)); - gtk_object_set_data (GTK_OBJECT (item), "timespan", (gpointer) &(timespans[i])); - gtk_signal_connect (GTK_OBJECT (item), "activate", omenu_item_activated, fds); - gtk_widget_show (item); - gtk_menu_prepend (GTK_MENU (menu), item); - - if (i == DAY_INDEX) - PRIV (fds)->recent_item = item; - } - - om = gtk_option_menu_new (); - gtk_option_menu_set_menu (GTK_OPTION_MENU (om), menu); - gtk_option_menu_set_history (GTK_OPTION_MENU (om), DAY_INDEX); - gtk_widget_show (om); - gtk_box_pack_start (GTK_BOX (hbox), om, FALSE, TRUE, 0); - - label = gtk_label_new (_("ago")); - gtk_widget_show (label); - gtk_misc_set_padding (GTK_MISC (label), 3, 0); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0); - - gtk_widget_show (hbox); - - PRIV (fds)->span_chooser = hbox; - PRIV (fds)->omenu = om; - PRIV (fds)->spinbutton = sb; - - /* if we do this earlier, we get the signal before the private - * members have been set up. */ - gtk_signal_connect (adj, "value_changed", - adj_value_changed, fds); -} - -static void -omenu_item_activated (GtkMenuItem *item, gpointer user_data) -{ - FilterDatespec *fds = (FilterDatespec *) user_data; - GtkOptionMenu *om; - timespan *old_ts, *new_ts; - int cur_val; - gfloat new_val; - - if (!PRIV (fds)->recent_item) { - PRIV (fds)->recent_item = GTK_WIDGET (item); - return; - } - - om = GTK_OPTION_MENU (PRIV (fds)->omenu); - old_ts = gtk_object_get_data (GTK_OBJECT (PRIV (fds)->recent_item), "timespan"); - new_ts = gtk_object_get_data (GTK_OBJECT (item), "timespan"); - - cur_val = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (PRIV (fds)->spinbutton)); - - /*if (old_ts->seconds > new_ts->seconds)*/ - new_val = ceil (cur_val * old_ts->seconds / new_ts->seconds); - - gtk_spin_button_set_value (GTK_SPIN_BUTTON (PRIV (fds)->spinbutton), new_val); - PRIV (fds)->recent_item = GTK_WIDGET (item); -} - -static void -adj_value_changed (GtkAdjustment *adj, gpointer user_data) -{ - FilterDatespec *fds = (FilterDatespec *) user_data; - GtkOptionMenu *om; - timespan *ts; - - om = GTK_OPTION_MENU (PRIV (fds)->omenu); - - if (om->menu_item == NULL) /* this has happened to me... dunno what it means */ - return; - - ts = gtk_object_get_data (GTK_OBJECT (om->menu_item), "timespan"); - fds->value = ts->seconds * - (gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (PRIV (fds)->spinbutton))); -} - -static void -set_adjustments (FilterDatespec *fds) -{ - time_t val; - int i; - - val = fds->value; - - for (i = 0; i < N_TIMESPANS; i++) { - if (val % timespans[i].seconds == 0) { - gtk_spin_button_set_value (GTK_SPIN_BUTTON (PRIV (fds)->spinbutton), - (gfloat) val / timespans[i].seconds); - break; - } - } - - gtk_option_menu_set_history (GTK_OPTION_MENU (PRIV (fds)->omenu), - N_TIMESPANS - (i + 1)); -} - -static gchar * -format_time (time_t time) -{ - struct tm *as_tm; - char buf[128]; - - /* no idea if this format is the 'correct' one */ - - as_tm = localtime (&time); - strftime (buf, 128, _("%b %d %l:%M %p"), as_tm); - return g_strdup (buf); -} - -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 = format_time (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; - 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 = -1; - - 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 a606cc1d2f..0000000000 --- a/filter/filter-datespec.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2000 Ximian Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef _FILTER_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-editor.c b/filter/filter-editor.c deleted file mode 100644 index 4f7183b103..0000000000 --- a/filter/filter-editor.c +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright (C) 2000, 2001 Ximian Inc. - * - * Authors: Not Zed - * Jeffrey Stedfast - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "filter-editor.h" -#include "filter-context.h" -#include "filter-filter.h" - -#define d(x) - -static FilterRule * create_rule(RuleEditor *re); - -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 (rule_editor_get_type (), &type_info); - } - - return type; -} - -static void -filter_editor_class_init (FilterEditorClass *class) -{ - GtkObjectClass *object_class = (GtkObjectClass *)class; - RuleEditorClass *re_class = (RuleEditorClass *)class; - - parent_class = gtk_type_class (gnome_dialog_get_type ()); - - object_class->finalize = filter_editor_finalise; - - /* override methods */ - re_class->create_rule = create_rule; - - /* 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; - - g_free(o->priv); - - ((GtkObjectClass *)(parent_class))->finalize (obj); -} - -/** - * filter_editor_new: - * - * Create a new FilterEditor object. - * - * Return value: A new #FilterEditor object. - **/ -FilterEditor * -filter_editor_new(FilterContext *f, const char **source_names) -{ - FilterEditor *o = (FilterEditor *)gtk_type_new (filter_editor_get_type ()); - GladeXML *gui; - GtkWidget *w; - - gui = glade_xml_new (FILTER_GLADEDIR "/filter.glade", "rule_editor"); - filter_editor_construct (o, f, gui, source_names); - - w = glade_xml_get_widget (gui, "rule_frame"); - gtk_frame_set_label (GTK_FRAME (w), _("Filter Rules")); - - gtk_object_unref (GTK_OBJECT (gui)); - - return o; -} - -static void -select_source (GtkMenuItem *mi, FilterEditor *fe) -{ - char *source; - - source = gtk_object_get_data (GTK_OBJECT (mi), "source"); - g_assert (source); - - rule_editor_set_source ((RuleEditor *)fe, source); -} - -void -filter_editor_construct (FilterEditor *fe, FilterContext *fc, GladeXML *gui, const char **source_names) -{ - GtkWidget *menu, *item, *omenu; - int i; - - omenu = glade_xml_get_widget (gui, "filter_source"); - gtk_option_menu_remove_menu (GTK_OPTION_MENU (omenu)); - menu = gtk_menu_new (); - - for (i = 0; source_names[i]; i++) { - item = gtk_menu_item_new_with_label (_(source_names[i])); - gtk_object_set_data_full (GTK_OBJECT (item), "source", g_strdup (source_names[i]), g_free); - gtk_menu_append (GTK_MENU (menu), item); - gtk_widget_show (item); - gtk_signal_connect (GTK_OBJECT (item), "activate", select_source, fe); - } - gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu); - gtk_widget_show (omenu); - - rule_editor_construct ((RuleEditor *)fe, (RuleContext *)fc, gui, source_names[0]); -} - -static FilterRule * -create_rule (RuleEditor *re) -{ - FilterRule *rule = filter_rule_new (); - FilterPart *part; - - /* create a rule with 1 part & 1 action in it */ - rule = (FilterRule *)filter_filter_new (); - part = rule_context_next_part (re->context, NULL); - filter_rule_add_part (rule, filter_part_clone (part)); - part = filter_context_next_action ((FilterContext *)re->context, NULL); - filter_filter_add_action ((FilterFilter *)rule, filter_part_clone (part)); - - return rule; -} diff --git a/filter/filter-editor.h b/filter/filter-editor.h deleted file mode 100644 index 6a859951a1..0000000000 --- a/filter/filter-editor.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2000, 2001 Ximian Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef _FILTER_EDITOR_H -#define _FILTER_EDITOR_H - -#include "rule-editor.h" - -#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 { - RuleEditor parent; - struct _FilterEditorPrivate *priv; - -}; - -struct _FilterEditorClass { - RuleEditorClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - -struct _FilterContext; - -guint filter_editor_get_type (void); -FilterEditor *filter_editor_new(struct _FilterContext *f, const char **source_names); -void filter_editor_construct(FilterEditor *fe, struct _FilterContext *fc, struct _GladeXML *gui, const char **source_names); - -#endif /* ! _FILTER_EDITOR_H */ - diff --git a/filter/filter-element.c b/filter/filter-element.c deleted file mode 100644 index 4343720e87..0000000000 --- a/filter/filter-element.c +++ /dev/null @@ -1,312 +0,0 @@ -/* - * Copyright (C) 2000 Ximian Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#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-score.h" -#include "filter-int.h" -#include "filter-folder.h" -#include "filter-source.h" - - -static gboolean validate (FilterElement *fe); -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->validate = validate; - 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; - - xmlFree(o->name); - - ((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; -} - -gboolean -filter_element_validate (FilterElement *fe) -{ - return ((FilterElementClass *)((GtkObject *)fe)->klass)->validate (fe); -} - -/** - * filter_element_xml_create: - * @fe: filter element - * @node: xml 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: filter element - * - * 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: filter element - * @node: xml 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: filter element - * - * Clones the FilterElement @fe. - * - * Return value: - **/ -FilterElement * -filter_element_clone (FilterElement *fe) -{ - return ((FilterElementClass *)((GtkObject *)fe)->klass)->clone(fe); -} - -/** - * filter_element_get_widget: - * @fe: filter element - * @node: xml 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: filter element - * @out: output buffer - * @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: filter element - * @out: output buffer - * - * 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: filter element type - * - * Create a new filter element based on its type name. - * - * Return value: - **/ -FilterElement * -filter_element_new_type_name (const char *type) -{ - if (type == NULL) - return NULL; - - if (!strcmp (type, "string")) { - return (FilterElement *)filter_input_new (); - } else if (!strcmp (type, "folder")) { - return (FilterElement *)filter_folder_new (); - } else if (!strcmp (type, "address")) { - /* FIXME: temporary ... need real address type */ - return (FilterElement *)filter_input_new_type_name (type); - } else if (!strcmp (type, "code")) { - return (FilterElement *)filter_code_new (); - } else if (!strcmp (type, "colour")) { - return (FilterElement *)filter_colour_new (); - } else if (!strcmp (type, "optionlist") || !strcmp (type, "system-flag")) { - return (FilterElement *)filter_option_new (); - } else if (!strcmp (type, "datespec")) { - return (FilterElement *)filter_datespec_new (); - } else if (!strcmp (type, "score")) { - return (FilterElement *)filter_score_new (); - } else if (!strcmp (type, "integer")) { - return (FilterElement *)filter_int_new (); - } else if (!strcmp (type, "regex")) { - return (FilterElement *)filter_input_new_type_name (type); - } else if (!strcmp (type, "source")) { - return (FilterElement *)filter_source_new (); - } else { - g_warning("Unknown filter type '%s'", type); - return 0; - } -} - -void -filter_element_set_data (FilterElement *fe, gpointer data) -{ - fe->data = data; -} - -/* default implementations */ -static gboolean -validate (FilterElement *fe) -{ - return TRUE; -} - -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 (GTK_OBJECT (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 3147fb12b4..0000000000 --- a/filter/filter-element.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2000 Ximian Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef _FILTER_ELEMENT_H -#define _FILTER_ELEMENT_H - -#include -#include -#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; - gpointer data; -}; - -struct _FilterPart; - -struct _FilterElementClass { - GtkObjectClass parent_class; - - /* virtual methods */ - gboolean (*validate)(FilterElement *fe); - - 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); - -void filter_element_set_data (FilterElement *fe, gpointer data); - -/* methods */ -gboolean filter_element_validate (FilterElement *fe); - -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 ad3ba7ac6b..0000000000 --- a/filter/filter-filter.c +++ /dev/null @@ -1,534 +0,0 @@ -/* - * Copyright (C) 2000-2001 Ximian Inc. - * - * Authors: Not Zed - * Jeffrey Stedfast - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "filter-filter.h" -#include "filter-context.h" - -#define d(x) - -static int validate(FilterRule *); -static xmlNodePtr xml_encode (FilterRule *); -static int xml_decode (FilterRule *, xmlNodePtr, struct _RuleContext *f); -static void rule_copy (FilterRule *dest, FilterRule *src); -/*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->validate = validate; - filter_rule->xml_encode = xml_encode; - filter_rule->xml_decode = xml_decode; - /*filter_rule->build_code = build_code;*/ - filter_rule->copy = rule_copy; - 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 (GTK_OBJECT (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); - - filter_rule_emit_changed((FilterRule *)fr); -} - -void -filter_filter_remove_action (FilterFilter *fr, FilterPart *fp) -{ - fr->actions = g_list_remove (fr->actions, fp); - - filter_rule_emit_changed((FilterRule *)fr); -} - -void -filter_filter_replace_action (FilterFilter *fr, FilterPart *fp, FilterPart *new) -{ - GList *l; - - l = g_list_find (fr->actions, fp); - if (l) { - l->data = new; - } else { - fr->actions = g_list_append (fr->actions, new); - } - - filter_rule_emit_changed((FilterRule *)fr); -} - -void -filter_filter_build_action (FilterFilter *fr, GString *out) -{ - g_string_append (out, "(begin\n"); - filter_part_build_code_list (fr->actions, out); - g_string_append (out, ")\n"); -} - -static int -validate(FilterRule *fr) -{ - int valid; - GList *parts; - FilterFilter *ff = (FilterFilter *)fr; - - valid = ((FilterRuleClass *)(parent_class))->validate(fr); - - /* validate rule actions */ - parts = ff->actions; - while (parts && valid) { - valid = filter_part_validate((FilterPart *)parts->data); - parts = parts->next; - } - - return valid; -} - -static 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 -rule_copy (FilterRule *dest, FilterRule *src) -{ - FilterFilter *fdest, *fsrc; - GList *node; - - fdest = (FilterFilter *) dest; - fsrc = (FilterFilter *) src; - - if (fdest->actions) { - g_list_foreach (fdest->actions, (GFunc) gtk_object_unref, NULL); - g_list_free (fdest->actions); - fdest->actions = NULL; - } - - node = fsrc->actions; - while (node) { - FilterPart *part = node->data; - - gtk_object_ref (GTK_OBJECT (part)); - fdest->actions = g_list_append (fdest->actions, part); - node = node->next; - } - - ((FilterRuleClass *)(parent_class))->copy (dest, src); -} - -/*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 (GTK_OBJECT (item), "part"); - FilterPart *newpart; - - /* dont update if we haven't changed */ - if (!strcmp (part->title, data->part->title)) - return; - - /* here we do a widget shuffle, throw away the old widget/rulepart, - and create another */ - if (data->partwidget) - gtk_container_remove (GTK_CONTAINER (data->container), data->partwidget); - - newpart = filter_part_clone (part); - filter_filter_replace_action ((FilterFilter *)data->fr, data->part, newpart); - gtk_object_unref (GTK_OBJECT (data->part)); - data->part = newpart; - data->partwidget = filter_part_get_widget (newpart); - if (data->partwidget) - gtk_box_pack_start (GTK_BOX (data->container), data->partwidget, FALSE, FALSE, 0); - - gtk_object_set_data (GTK_OBJECT (data->container), "part", newpart); -} - -static GtkWidget * -get_rule_part_widget (FilterContext *f, FilterPart *newpart, FilterRule *fr) -{ - FilterPart *part = NULL; - GtkWidget *menu; - GtkWidget *item; - GtkWidget *omenu; - GtkWidget *hbox; - GtkWidget *p; - int index = 0, current = 0; - struct _part_data *data; - - data = g_malloc0 (sizeof (*data)); - data->fr = fr; - data->f = f; - data->part = newpart; - - hbox = gtk_hbox_new (FALSE, 0); - p = filter_part_get_widget (newpart); - - data->partwidget = p; - data->container = hbox; - - menu = gtk_menu_new (); - while ((part = filter_context_next_action (f, part))) { - item = gtk_menu_item_new_with_label (_(part->title)); - - gtk_object_set_data (GTK_OBJECT (item), "part", part); - gtk_signal_connect (GTK_OBJECT (item), "activate", option_activate, data); - gtk_menu_append (GTK_MENU (menu), item); - gtk_widget_show (item); - - if (!strcmp (newpart->title, part->title)) { - current = index; - } - index++; - } - - omenu = gtk_option_menu_new (); - gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu); - gtk_option_menu_set_history (GTK_OPTION_MENU (omenu), current); - gtk_widget_show (omenu); - - gtk_box_pack_start (GTK_BOX (hbox), omenu, FALSE, FALSE, 0); - if (p) { - gtk_box_pack_start (GTK_BOX (hbox), p, FALSE, FALSE, 0); - } - gtk_widget_show_all (hbox); - - return hbox; -} - -struct _rule_data { - FilterRule *fr; - FilterContext *f; - GtkWidget *parts; -}; - -static void -less_parts (GtkWidget *button, struct _rule_data *data) -{ - FilterPart *part; - GtkWidget *rule; - GList *l; - - l = ((FilterFilter *)data->fr)->actions; - if (g_list_length (l) < 2) - return; - - rule = gtk_object_get_data (GTK_OBJECT (button), "rule"); - part = gtk_object_get_data (GTK_OBJECT (rule), "part"); - - /* remove the part from the list */ - filter_filter_remove_action ((FilterFilter *)data->fr, part); - gtk_object_unref (GTK_OBJECT (part)); - - /* and from the display */ - gtk_container_remove (GTK_CONTAINER (data->parts), rule); - gtk_container_remove (GTK_CONTAINER (data->parts), button); -} - -static void -attach_rule (GtkWidget *rule, struct _rule_data *data, FilterPart *part, int row) -{ - GtkWidget *remove; - GtkWidget *pixmap; - - gtk_table_attach (GTK_TABLE (data->parts), rule, 0, 1, row, row + 1, - GTK_EXPAND | GTK_FILL, 0, 0, 0); - - pixmap = gnome_stock_new_with_icon (GNOME_STOCK_PIXMAP_REMOVE); - remove = gnome_pixmap_button (pixmap, _("Remove")); - gtk_object_set_data (GTK_OBJECT (remove), "rule", rule); - gtk_object_set_data (GTK_OBJECT (rule), "part", part); - /*gtk_button_set_relief (GTK_BUTTON (remove), GTK_RELIEF_NONE);*/ - gtk_signal_connect (GTK_OBJECT (remove), "clicked", less_parts, data); - gtk_table_attach (GTK_TABLE (data->parts), remove, 1, 2, row, row + 1, - 0, 0, 0, 0); - gtk_widget_show (remove); -} - -static void -more_parts (GtkWidget *button, struct _rule_data *data) -{ - FilterPart *new; - - /* create a new rule entry, use the first type of rule */ - new = filter_context_next_action ((FilterContext *)data->f, NULL); - if (new) { - GtkWidget *w; - guint16 rows; - - new = filter_part_clone (new); - filter_filter_add_action ((FilterFilter *)data->fr, new); - w = get_rule_part_widget (data->f, new, data->fr); - - rows = GTK_TABLE (data->parts)->nrows; - gtk_table_resize (GTK_TABLE (data->parts), rows + 1, 2); - attach_rule (w, data, new, rows); - } -} - -static GtkWidget * -get_widget (FilterRule *fr, struct _RuleContext *f) -{ - GtkWidget *widget; - GtkWidget *parts, *inframe; - GtkWidget *hbox; - GtkWidget *add, *pixmap; - GtkWidget *w; - GtkWidget *frame; - GtkWidget *scrolledwindow; - GtkObject *hadj, *vadj; - GList *l; - FilterPart *part; - struct _rule_data *data; - FilterFilter *ff = (FilterFilter *)fr; - gint rows, i = 0; - - widget = ((FilterRuleClass *)(parent_class))->get_widget (fr, f); - - /* and now for the action area */ - frame = gtk_frame_new (_("Then")); - inframe = gtk_vbox_new (FALSE, 3); - gtk_container_add (GTK_CONTAINER (frame), inframe); - - rows = g_list_length (ff->actions); - parts = gtk_table_new (rows, 2, FALSE); - data = g_malloc0 (sizeof (*data)); - data->f = (FilterContext *)f; - data->fr = fr; - data->parts = parts; - - hbox = gtk_hbox_new (FALSE, 3); - - pixmap = gnome_stock_new_with_icon (GNOME_STOCK_PIXMAP_ADD); - add = gnome_pixmap_button (pixmap, _("Add action")); - /* gtk_button_set_relief (GTK_BUTTON (add), GTK_RELIEF_NONE); */ - gtk_signal_connect (GTK_OBJECT (add), "clicked", more_parts, data); - gtk_box_pack_start (GTK_BOX (hbox), add, FALSE, FALSE, 3); - - gtk_box_pack_start (GTK_BOX (inframe), hbox, FALSE, FALSE, 3); - - l = ff->actions; - while (l) { - part = l->data; - d(printf ("adding action %s\n", part->title)); - w = get_rule_part_widget ((FilterContext *)f, part, fr); - attach_rule (w, data, part, i++); - l = g_list_next (l); - } - - hadj = gtk_adjustment_new (0.0, 0.0, 1.0, 1.0 ,1.0, 1.0); - vadj = gtk_adjustment_new (0.0, 0.0, 1.0, 1.0 ,1.0, 1.0); - scrolledwindow = gtk_scrolled_window_new (GTK_ADJUSTMENT (hadj), GTK_ADJUSTMENT (vadj)); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - - gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolledwindow), parts); - - gtk_box_pack_start (GTK_BOX (inframe), scrolledwindow, TRUE, TRUE, 3); - - /*gtk_box_pack_start (GTK_BOX (inframe), parts, FALSE, FALSE, 3);*/ - - gtk_widget_show_all (frame); - - gtk_box_pack_start (GTK_BOX (widget), frame, TRUE, TRUE, 3); - - return widget; -} diff --git a/filter/filter-filter.h b/filter/filter-filter.h deleted file mode 100644 index 54c4a144f4..0000000000 --- a/filter/filter-filter.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2000 Ximian Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef _FILTER_FILTER_H -#define _FILTER_FILTER_H - -#include "filter-rule.h" - -#define FILTER_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 5b862a986a..0000000000 --- a/filter/filter-folder.c +++ /dev/null @@ -1,344 +0,0 @@ -/* - * Copyright (C) 2000 Ximian Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include - -#define SHELL - -#include -#include -#include -#include -#include -#include - -#include "filter-folder.h" -#ifdef SHELL -#include "shell/evolution-shell-client.h" -#endif -#include "e-util/e-sexp.h" - -#define d(x) - -static gboolean validate (FilterElement *fe); -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->validate = validate; - 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; -} - -void -filter_folder_set_value(FilterFolder *ff, const char *uri, const char *name) -{ - g_free(ff->uri); - ff->uri = g_strdup(uri); - g_free(ff->name); - ff->name = g_strdup(name); -} - -static gboolean -validate (FilterElement *fe) -{ - FilterFolder *ff = (FilterFolder *) fe; - - if (ff->uri && *ff->uri) { - return TRUE; - } else { - GtkWidget *dialog; - - dialog = gnome_ok_dialog (_("You forgot to choose a folder.\n" - "Please go back and specify a valid folder to deliver mail to.")); - - gnome_dialog_run_and_close (GNOME_DIALOG (dialog)); - - return FALSE; - } -} - -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)); - - xmlFree (fe->name); - fe->name = xmlGetProp (node, "name"); - - n = node->childs; - while (n) { - if (!strcmp (n->name, "folder")) { - char *uri, *name; - - name = xmlGetProp (n, "name"); - g_free (ff->name); - ff->name = g_strdup (name); - xmlFree (name); - - uri = xmlGetProp (n, "uri"); - g_free (ff->uri); - ff->uri = g_strdup (uri); - xmlFree (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; - gchar *s; - - def = ff->uri ? ff->uri : ""; - - gtk_widget_set_sensitive((GtkWidget *)button, FALSE); - gtk_object_ref((GtkObject *)ff); - - evolution_shell_client_user_select_folder (global_shell_client, - GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (button))), - _("Select Folder"), - def, allowed_types, - &evolution_uri, - &physical_uri); - - if (GTK_OBJECT_DESTROYED(button)) { - g_free(physical_uri); - g_free(evolution_uri); - gtk_object_unref((GtkObject *)ff); - return; - } - - gtk_widget_set_sensitive((GtkWidget *)button, TRUE); - - 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)); - s = e_utf8_to_gtk_string (GTK_WIDGET (button), ff->name); - gtk_label_set_text (GTK_LABEL (GTK_BIN (button)->child), s); - g_free (s); - } else { - g_free (physical_uri); - } - g_free (evolution_uri); - - gtk_object_unref((GtkObject *)ff); - -#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); - gtk_window_set_policy(GTK_WINDOW(gd), FALSE, TRUE, FALSE); - entry = (GtkEntry *)gtk_entry_new(); - if (ff->uri) { - e_utf8_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 = e_utf8_gtk_entry_get_text(entry); - ff->uri = uri; - str = strstr(uri, "//"); - if (str) - str = strchr(str+2, '/'); - if (str) - str++; - else - str = uri; - ff->name = g_strdup(str); - s = e_utf8_to_gtk_string ((GtkWidget *) button, ff->name); - gtk_label_set_text((GtkLabel *)GTK_BIN(button)->child, s); - g_free (s); - case 1: - gnome_dialog_close(gd); - case -1: - /* nothing */ - } -#endif - - gdk_window_raise (GTK_WIDGET (gtk_widget_get_ancestor (GTK_WIDGET (button), GTK_TYPE_WINDOW))->window); -} - -static GtkWidget * -get_widget (FilterElement *fe) -{ - FilterFolder *ff = (FilterFolder *)fe; - GtkWidget *button; - GtkWidget *label; - - if (ff->name && ff->name[0]) - label = gtk_label_new (g_basename (ff->name)); - else - label = gtk_label_new (_("")); - - button = gtk_button_new (); - gtk_container_add (GTK_CONTAINER (button), label); - gtk_widget_show (button); - gtk_widget_show (label); - gtk_signal_connect (GTK_OBJECT (button), "clicked", button_clicked, ff); - - return button; -} - -static void -build_code (FilterElement *fe, GString *out, struct _FilterPart *ff) -{ - return; -} - -static void -format_sexp (FilterElement *fe, GString *out) -{ - FilterFolder *ff = (FilterFolder *)fe; - - e_sexp_encode_string (out, ff->uri); -} diff --git a/filter/filter-folder.h b/filter/filter-folder.h deleted file mode 100644 index e58444fb14..0000000000 --- a/filter/filter-folder.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2000 Ximian Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef _FILTER_FOLDER_H -#define _FILTER_FOLDER_H - -#include "filter-element.h" - -#define FILTER_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 */ -void filter_folder_set_value(FilterFolder *ff, const char *uri, const char *name); - -#endif /* ! _FILTER_FOLDER_H */ - diff --git a/filter/filter-input.c b/filter/filter-input.c deleted file mode 100644 index 165d16b10c..0000000000 --- a/filter/filter-input.c +++ /dev/null @@ -1,345 +0,0 @@ -/* - * Copyright (C) 2000 Ximian Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "filter-input.h" -#include "e-util/e-sexp.h" - -#define d(x) - -static gboolean validate (FilterElement *fe); -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->validate = validate; - 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; - - xmlFree (o->type); - g_list_foreach(o->values, (GFunc)g_free, NULL); - g_list_free(o->values); - - g_free(o->priv); - - ((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 = xmlStrdup (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 gboolean -validate (FilterElement *fe) -{ - FilterInput *fi = (FilterInput *)fe; - gboolean valid = TRUE; - - if (!strcmp (fi->type, "regex")) { - regex_t regexpat; /* regex patern */ - gint regerr; - char *text; - - text = fi->values->data; - - regerr = regcomp (®expat, text, REG_EXTENDED | REG_NEWLINE | REG_ICASE); - if (regerr) { - GtkWidget *dialog; - gchar *regmsg, *errmsg; - size_t reglen; - - /* regerror gets called twice to get the full error string - length to do proper posix error reporting */ - reglen = regerror (regerr, ®expat, 0, 0); - regmsg = g_malloc0 (reglen + 1); - regerror (regerr, ®expat, regmsg, reglen); - - errmsg = g_strdup_printf (_("Error in regular expression '%s':\n%s"), - text, regmsg); - g_free (regmsg); - - dialog = gnome_ok_dialog (errmsg); - - gnome_dialog_run_and_close (GNOME_DIALOG (dialog)); - - g_free (errmsg); - valid = FALSE; - } - - regfree (®expat); - } - - return valid; -} - -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; - char *encstr; - - cur = xmlNewChild (value, NULL, type, NULL); - encstr = e_utf8_xml1_encode (str); - xmlNodeSetContent (cur, encstr); - g_free (encstr); - 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; - - name = xmlGetProp (node, "name"); - type = xmlGetProp (node, "type"); - - d(printf("Decoding %s from xml %p\n", type, fe)); - d(printf ("Name = %s\n", name)); - xmlFree (fe->name); - fe->name = name; - xmlFree (fi->type); - fi->type = type; - n = node->childs; - while (n) { - if (!strcmp (n->name, type)) { - gchar *decstr; - str = xmlNodeGetContent (n); - if (str) { - decstr = e_utf8_xml1_decode (str); - xmlFree (str); - d(printf (" '%s'\n", decstr)); - fi->values = g_list_append (fi->values, decstr); - } - } 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 = e_utf8_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, new); -} - -static GtkWidget * -get_widget (FilterElement *fe) -{ - GtkWidget *entry; - FilterInput *fi = (FilterInput *)fe; - - entry = gtk_entry_new (); - if (fi->values && fi->values->data) { - e_utf8_gtk_entry_set_text (GTK_ENTRY (entry), fi->values->data); - } - - gtk_signal_connect (GTK_OBJECT (entry), "changed", entry_changed, fe); - - return 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 ab03391116..0000000000 --- a/filter/filter-input.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2000 Ximian Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef _FILTER_INPUT_H -#define _FILTER_INPUT_H - -#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-int.c b/filter/filter-int.c deleted file mode 100644 index 0fb0685aec..0000000000 --- a/filter/filter-int.c +++ /dev/null @@ -1,226 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Ripped off by Sam Creasey from - * filter-score by Jeffrey Stedfast - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include - -#include "e-util/e-sexp.h" -#include "filter-int.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_int_class_init (FilterIntClass *class); -static void filter_int_init (FilterInt *gspaper); -static void filter_int_finalise (GtkObject *obj); - -#define _PRIVATE(x) (((FilterInt *)(x))->priv) - -struct _FilterIntPrivate { -}; - -static FilterElementClass *parent_class; - -enum { - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -guint -filter_int_get_type (void) -{ - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "FilterInt", - sizeof (FilterInt), - sizeof (FilterIntClass), - (GtkClassInitFunc) filter_int_class_init, - (GtkObjectInitFunc) filter_int_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - type = gtk_type_unique (filter_element_get_type (), &type_info); - } - - return type; -} - -static void -filter_int_class_init (FilterIntClass *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_int_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_int_init (FilterInt *o) -{ - o->priv = g_malloc0 (sizeof (*o->priv)); -} - -static void -filter_int_finalise(GtkObject *obj) -{ - FilterInt *o = (FilterInt *)obj; - - o = o; - - ((GtkObjectClass *)(parent_class))->finalize(obj); -} - -/** - * filter_int_new: - * - * Create a new FilterInt object. - * - * Return value: A new #FilterInt object. - **/ -FilterInt * -filter_int_new (void) -{ - FilterInt *o = (FilterInt *)gtk_type_new(filter_int_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; - FilterInt *fs = (FilterInt *)fe; - char *intval; - - d(printf("Encoding integer as xml\n")); - - value = xmlNewNode (NULL, "value"); - xmlSetProp (value, "name", fe->name); - xmlSetProp (value, "type", "integer"); - - intval = g_strdup_printf ("%d", fs->val); - xmlSetProp (value, "integer", intval); - g_free (intval); - - return value; -} - -static int -xml_decode (FilterElement *fe, xmlNodePtr node) -{ - FilterInt *fs = (FilterInt *)fe; - char *name; - char *intval; - - d(printf("Decoding integer from xml %p\n", fe)); - - name = xmlGetProp (node, "name"); - d(printf ("Name = %s\n", name)); - xmlFree (fe->name); - fe->name = name; - intval = xmlGetProp (node, "integer"); - if (intval) { - fs->val = atoi (intval); - xmlFree (intval); - } else - fs->val = 0; - - return 0; -} - -static void -spin_changed (GtkWidget *spin, FilterElement *fe) -{ - FilterInt *fs = (FilterInt *)fe; - - fs->val = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin)); -} - -static GtkWidget * -get_widget (FilterElement *fe) -{ - GtkWidget *spin; - GtkObject *adjustment; - FilterInt *fs = (FilterInt *)fe; - - adjustment = gtk_adjustment_new (0.0, 0.0, (gfloat)G_MAXINT, - 1.0, 1.0, 1.0); - spin = gtk_spin_button_new (GTK_ADJUSTMENT (adjustment), 5.0, 0); - gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spin), TRUE); - - if (fs->val) { - gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), (gfloat) fs->val); - } - - gtk_signal_connect (GTK_OBJECT (spin), "changed", spin_changed, fe); - - return spin; -} - -static void -build_code (FilterElement *fe, GString *out, struct _FilterPart *ff) -{ - return; -} - -static void -format_sexp (FilterElement *fe, GString *out) -{ - FilterInt *fs = (FilterInt *)fe; - - g_string_append(out, g_strdup_printf("%d", fs->val)); -} diff --git a/filter/filter-int.h b/filter/filter-int.h deleted file mode 100644 index 7a451f29ff..0000000000 --- a/filter/filter-int.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Ripped off by Sam Creasey from filter-score by: - * - * Authors: Jeffrey Stedfast - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - -#ifndef _FILTER_INT_H -#define _FILTER_INT_H - -#include "filter-element.h" - -#define FILTER_INT(obj) GTK_CHECK_CAST (obj, filter_int_get_type (), FilterInt) -#define FILTER_INT_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, filter_int_get_type (), FilterIntClass) -#define IS_FILTER_INT(obj) GTK_CHECK_TYPE (obj, filter_int_get_type ()) - -typedef struct _FilterInt FilterInt; -typedef struct _FilterIntClass FilterIntClass; - -struct _FilterInt { - FilterElement parent; - struct _FilterIntPrivate *priv; - - gint32 val; -}; - -struct _FilterIntClass { - FilterElementClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - -guint filter_int_get_type (void); -FilterInt *filter_int_new (void); - -/* methods */ - -#endif /* ! _FILTER_INT_H */ - diff --git a/filter/filter-option.c b/filter/filter-option.c deleted file mode 100644 index b0e1abc3d0..0000000000 --- a/filter/filter-option.c +++ /dev/null @@ -1,361 +0,0 @@ -/* - * Copyright (C) 2000 Ximian Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include - -#include -#include -#include -#include -#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 -free_option(struct _filter_option *o, void *data) -{ - g_free(o->title); - xmlFree (o->value); - g_free(o->code); - g_free(o); -} - -static void -filter_option_finalise (GtkObject *obj) -{ - FilterOption *o = (FilterOption *)obj; - - g_list_foreach(o->options, (GFunc)free_option, NULL); - g_list_free(o->options); - - ((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) { - gchar *str, *decstr; - str = xmlNodeGetContent (work); - decstr = e_utf8_xml1_decode (str); - if (str) xmlFree (str); - op->title = decstr; - } - } else if (!strcmp (work->name, "code")) { - if (!op->code) { - gchar *str, *decstr; - str = xmlNodeGetContent (work); - decstr = e_utf8_xml1_decode (str); - if (str) xmlFree (str); - op->code = decstr; - } - } - work = work->next; - } - d(printf ("creating new option:\n title %s\n value %s\n code %s\n", - op->title, op->value, op->code ? op->code : "none")); - 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")); - xmlFree (fe->name); - 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_changed (GtkWidget *widget, FilterElement *fe) -{ - FilterOption *fo = (FilterOption *)fe; - - fo->current = gtk_object_get_data (GTK_OBJECT (widget), "option"); -} - -static GtkWidget * -get_widget (FilterElement *fe) -{ - FilterOption *fo = (FilterOption *)fe; - GtkWidget *menu; - GtkWidget *omenu; - GtkWidget *item; - GtkWidget *first = NULL; - GList *l = fo->options; - struct _filter_option *op; - int index = 0, current = 0; - - menu = gtk_menu_new (); - while (l) { - op = l->data; - item = gtk_menu_item_new_with_label (_(op->title)); - gtk_object_set_data (GTK_OBJECT (item), "option", op); - gtk_signal_connect (GTK_OBJECT (item), "activate", option_changed, fe); - gtk_menu_append (GTK_MENU (menu), item); - gtk_widget_show (item); - if (op == fo->current) { - current = index; - first = item; - } else if (!first) { - first = item; - } - - l = g_list_next (l); - index++; - } - - omenu = gtk_option_menu_new (); - gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu); - - if (first) - gtk_signal_emit_by_name (GTK_OBJECT (first), "activate", fe); - - gtk_option_menu_set_history (GTK_OPTION_MENU (omenu), current); - - return 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 && fo->current->code) { - 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 = xmlStrdup (op->value); - if (op->code) - fn->code = g_strdup (op->code); - else - fn->code = NULL; - 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 4b33a18697..0000000000 --- a/filter/filter-option.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2000 Ximian Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef _FILTER_OPTION_H -#define _FILTER_OPTION_H - -#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 15e78b77b8..0000000000 --- a/filter/filter-part.c +++ /dev/null @@ -1,501 +0,0 @@ -/* - * Copyright (C) 2000 Ximian Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include - -#include -#include - -#include -#include -#include -#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; - GList *l; - - o = o; - - l = o->elements; - while (l) { - gtk_object_unref((GtkObject *)l->data); - l = g_list_next(l); - } - - g_list_free(o->elements); - g_free(o->name); - g_free(o->title); - g_free(o->code); - - - ((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; -} - -gboolean -filter_part_validate (FilterPart *fp) -{ - gboolean correct = TRUE; - GList *l; - - l = fp->elements; - while (l && correct) { - FilterElement *fe = l->data; - - correct = filter_element_validate (fe); - - l = l->next; - } - - return correct; -} - -int -filter_part_xml_create (FilterPart *ff, xmlNodePtr node) -{ - xmlNodePtr n; - char *type, *str, *decstr; - FilterElement *el; - - str = xmlGetProp(node, "name"); - ff->name = g_strdup(str); - if (str) - xmlFree(str); - 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", ff, 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) { - str = xmlNodeGetContent (n); - ff->title = e_utf8_xml1_decode (str); - if (str) - xmlFree (str); - } - } else if (!strcmp (n->name, "code")) { - if (!ff->code) { - str = xmlNodeGetContent (n); - ff->code = e_utf8_xml1_decode (str); - if (str) - xmlFree (str); - } - } 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 ((GTK_OBJECT (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) -{ - GtkWidget *hbox; - GList *l = ff->elements; - FilterElement *fe; - GtkWidget *w; - - hbox = gtk_hbox_new (FALSE, 3); - - while (l) { - fe = l->data; - w = filter_element_get_widget (fe); - if (w) { - gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 3); - } - l = g_list_next (l); - } - - gtk_widget_show_all (hbox); - - return 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 (start && (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", ff, 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_window_set_policy(GTK_WINDOW(gd), FALSE, TRUE, FALSE); - gtk_box_pack_start((GtkBox *)gd->vbox, w, TRUE, 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 1a29cee981..0000000000 --- a/filter/filter-part.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2000 Ximian Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef _FILTER_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 */ -gboolean filter_part_validate (FilterPart *fp); - -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 2f8fd76047..0000000000 --- a/filter/filter-rule.c +++ /dev/null @@ -1,866 +0,0 @@ -/* - * Copyright (C) 2000 Ximian Inc. - * - * Authors: Not Zed - * Jeffrey Stedfast - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "filter-rule.h" -#include "filter-context.h" - -#define d(x) - -static int validate(FilterRule *); -static xmlNodePtr xml_encode (FilterRule *); -static int xml_decode (FilterRule *, xmlNodePtr, RuleContext *); -static void build_code (FilterRule *, GString * out); -static void rule_copy (FilterRule *dest, FilterRule *src); -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 { - int frozen; -}; - -static GtkObjectClass *parent_class; - -enum { - CHANGED, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -guint -filter_rule_get_type () -{ - 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->validate = validate; - class->xml_encode = xml_encode; - class->xml_decode = xml_decode; - class->build_code = build_code; - class->copy = rule_copy; - class->get_widget = get_widget; - - /* signals */ - signals[CHANGED] = - gtk_signal_new("changed", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (FilterRuleClass, changed), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - 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 -filter_rule_finalise (GtkObject * obj) -{ - FilterRule *o = (FilterRule *) obj; - - g_free (o->name); - g_free (o->source); - g_list_foreach(o->parts, (GFunc)gtk_object_unref, NULL); - g_list_free(o->parts); - - g_free(o->priv); - - ((GtkObjectClass *) (parent_class))->finalize(obj); -} - -/** - * filter_rule_new: - * - * Create a new FilterRule object. - * - * Return value: A new #FilterRule object. - **/ -FilterRule * -filter_rule_new () -{ - FilterRule *o = (FilterRule *) gtk_type_new (filter_rule_get_type()); - - return o; -} - -FilterRule * -filter_rule_clone (FilterRule *base) -{ - FilterRule *rule; - - g_assert (IS_FILTER_RULE (base)); - - rule = gtk_type_new (GTK_OBJECT (base)->klass->type); - filter_rule_copy (rule, base); - - return rule; -} - -void -filter_rule_set_name (FilterRule *fr, const char *name) -{ - g_assert (IS_FILTER_RULE (fr)); - - if ((fr->name && name && strcmp(fr->name, name) == 0) - || (fr->name == NULL && name == NULL)) - return; - - g_free (fr->name); - fr->name = g_strdup (name); - - filter_rule_emit_changed(fr); -} - -void -filter_rule_set_source (FilterRule *fr, const char *source) -{ - g_assert (IS_FILTER_RULE (fr)); - - if ((fr->source && source && strcmp(fr->source, source) == 0) - || (fr->source == NULL && source == NULL)) - return; - - g_free (fr->source); - fr->source = g_strdup (source); - - filter_rule_emit_changed(fr); -} - -int -filter_rule_validate (FilterRule *fr) -{ - g_assert (IS_FILTER_RULE (fr)); - - return ((FilterRuleClass *) ((GtkObject *) fr)->klass)->validate (fr); -} - -static int -validate (FilterRule *fr) -{ - int valid = TRUE; - GList *parts; - - if (!fr->name || !*fr->name) { - GtkWidget *dialog; - - dialog = gnome_ok_dialog (_("You must name this filter.")); - - gnome_dialog_run_and_close (GNOME_DIALOG (dialog)); - - return FALSE; - } - - /* validate rule parts */ - parts = fr->parts; - while (parts && valid) { - valid = filter_part_validate ((FilterPart *)parts->data); - parts = parts->next; - } - - return valid; -} - -xmlNodePtr -filter_rule_xml_encode (FilterRule *fr) -{ - g_assert (IS_FILTER_RULE (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; - } - - if (fr->source) { - xmlSetProp (node, "source", fr->source); - } else { - /* set to the default filter type */ - xmlSetProp (node, "source", "incoming"); - } - - if (fr->name) { - char *encstr; - - work = xmlNewNode (NULL, "title"); - encstr = e_utf8_xml1_encode (fr->name); - xmlNodeSetContent (work, encstr); - g_free (encstr); - 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) -{ - int res; - - g_assert (IS_FILTER_RULE (fr)); - g_assert (IS_RULE_CONTEXT (f)); - g_assert (node != NULL); - - fr->priv->frozen++; - res = ((FilterRuleClass *) ((GtkObject *) fr)->klass)->xml_decode (fr, node, f); - fr->priv->frozen--; - - filter_rule_emit_changed(fr); - - return res; -} - -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; - xmlFree (grouping); - - g_free (fr->source); - source = xmlGetProp (node, "source"); - if (source) { - fr->source = g_strdup (source); - xmlFree (source); - } else { - /* default filter type */ - fr->source = g_strdup ("incoming"); - } - - work = node->childs; - while (work) { - if (!strcmp (work->name, "partset")) { - load_set (work, fr, f); - } else if (!strcmp (work->name, "title") || !strcmp (work->name, "_title")) { - if (!fr->name) { - char *str, *decstr; - - str = xmlNodeGetContent (work); - decstr = e_utf8_xml1_decode (str); - if (str) - xmlFree (str); - fr->name = decstr; - } - } - work = work->next; - } - - return 0; -} - -static void -rule_copy (FilterRule *dest, FilterRule *src) -{ - GList *node; - - g_free (dest->name); - dest->name = g_strdup (src->name); - - g_free (dest->source); - dest->source = g_strdup (src->source); - - dest->grouping = src->grouping; - - if (dest->parts) { - g_list_foreach (dest->parts, (GFunc) gtk_object_unref, NULL); - g_list_free (dest->parts); - dest->parts = NULL; - } - - node = src->parts; - while (node) { - FilterPart *part = node->data; - - gtk_object_ref (GTK_OBJECT (part)); - dest->parts = g_list_append (dest->parts, part); - node = node->next; - } -} - -void -filter_rule_copy (FilterRule *dest, FilterRule *src) -{ - g_assert (IS_FILTER_RULE (dest)); - g_assert (IS_FILTER_RULE (src)); - - ((FilterRuleClass *) ((GtkObject *) dest)->klass)->copy (dest, src); - - filter_rule_emit_changed(dest); -} - -void -filter_rule_add_part (FilterRule *fr, FilterPart *fp) -{ - g_assert (IS_FILTER_RULE (fr)); - g_assert (IS_FILTER_PART (fp)); - - fr->parts = g_list_append (fr->parts, fp); - - filter_rule_emit_changed(fr); -} - -void -filter_rule_remove_part (FilterRule *fr, FilterPart *fp) -{ - g_assert (IS_FILTER_RULE (fr)); - g_assert (IS_FILTER_PART (fp)); - - fr->parts = g_list_remove (fr->parts, fp); - - filter_rule_emit_changed(fr); -} - -void -filter_rule_replace_part (FilterRule *fr, FilterPart *fp, FilterPart *new) -{ - GList *l; - - g_assert (IS_FILTER_RULE (fr)); - g_assert (IS_FILTER_PART (fp)); - g_assert (IS_FILTER_PART (new)); - - l = g_list_find (fr->parts, fp); - if (l) { - l->data = new; - } else { - fr->parts = g_list_append (fr->parts, new); - } - - filter_rule_emit_changed(fr); -} - -void -filter_rule_build_code (FilterRule *fr, GString *out) -{ - g_assert (IS_FILTER_RULE (fr)); - g_assert (out != NULL); - - ((FilterRuleClass *) ((GtkObject *) fr)->klass)->build_code (fr, out); - - d(printf ("build_code: [%s](%d)", out->str, out->len)); -} - -void -filter_rule_emit_changed(FilterRule *fr) -{ - g_assert (IS_FILTER_RULE (fr)); - - if (fr->priv->frozen == 0) - gtk_signal_emit((GtkObject *)fr, signals[CHANGED]); -} - -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 (GtkWidget *widget, FilterRule *fr) -{ - fr->grouping = FILTER_GROUP_ALL; -} - -static void -match_any (GtkWidget *widget, FilterRule *fr) -{ - 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 (GTK_OBJECT (item), "part"); - FilterPart *newpart; - - /* dont update if we haven't changed */ - if (!strcmp (part->title, data->part->title)) - return; - - /* here we do a widget shuffle, throw away the old widget/rulepart, - and create another */ - if (data->partwidget) - gtk_container_remove (GTK_CONTAINER (data->container), data->partwidget); - - newpart = filter_part_clone (part); - filter_rule_replace_part (data->fr, data->part, newpart); - gtk_object_unref (GTK_OBJECT (data->part)); - data->part = newpart; - data->partwidget = filter_part_get_widget (newpart); - if (data->partwidget) - gtk_box_pack_start (GTK_BOX (data->container), data->partwidget, FALSE, FALSE, 0); - - gtk_object_set_data (GTK_OBJECT (data->container), "part", newpart); -} - -static GtkWidget * -get_rule_part_widget (RuleContext *f, FilterPart *newpart, FilterRule *fr) -{ - FilterPart *part = NULL; - GtkWidget *menu; - GtkWidget *item; - GtkWidget *omenu; - GtkWidget *hbox; - GtkWidget *p; - int index = 0, current = 0; - struct _part_data *data; - - data = g_malloc0 (sizeof (*data)); - data->fr = fr; - data->f = f; - data->part = newpart; - - hbox = gtk_hbox_new (FALSE, 0); - /* only set to automatically clean up the memory */ - gtk_object_set_data_full (GTK_OBJECT (hbox), "data", data, g_free); - - p = filter_part_get_widget (newpart); - - data->partwidget = p; - data->container = hbox; - - menu = gtk_menu_new (); - /* sigh, this is a little ugly */ - while ((part = rule_context_next_part (f, part))) { - item = gtk_menu_item_new_with_label (_(part->title)); - gtk_object_set_data (GTK_OBJECT (item), "part", part); - gtk_signal_connect (GTK_OBJECT (item), "activate", option_activate, data); - gtk_menu_append (GTK_MENU (menu), item); - gtk_widget_show (item); - if (!strcmp (newpart->title, part->title)) { - current = index; - } - index++; - } - - omenu = gtk_option_menu_new (); - gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu); - gtk_option_menu_set_history (GTK_OPTION_MENU (omenu), current); - gtk_widget_show (omenu); - - gtk_box_pack_start (GTK_BOX (hbox), omenu, FALSE, FALSE, 0); - if (p) { - gtk_box_pack_start (GTK_BOX (hbox), p, FALSE, FALSE, 0); - } - gtk_widget_show_all (hbox); - - return hbox; -} - -struct _rule_data { - FilterRule *fr; - RuleContext *f; - GtkWidget *parts; -}; - -static void -less_parts (GtkWidget *button, struct _rule_data *data) -{ - FilterPart *part; - GtkWidget *rule; - - if (g_list_length (data->fr->parts) < 2) - return; - - rule = gtk_object_get_data (GTK_OBJECT (button), "rule"); - part = gtk_object_get_data (GTK_OBJECT (rule), "part"); - - /* remove the part from the list */ - filter_rule_remove_part (data->fr, part); - gtk_object_unref (GTK_OBJECT (part)); - - /* and from the display */ - gtk_container_remove (GTK_CONTAINER (data->parts), rule); - gtk_container_remove (GTK_CONTAINER (data->parts), button); -} - -static void -attach_rule (GtkWidget *rule, struct _rule_data *data, FilterPart *part, int row) -{ - GtkWidget *remove; - GtkWidget *pixmap; - - gtk_table_attach (GTK_TABLE (data->parts), rule, 0, 1, row, row + 1, - GTK_EXPAND | GTK_FILL, 0, 0, 0); - - pixmap = gnome_stock_new_with_icon (GNOME_STOCK_PIXMAP_REMOVE); - remove = gnome_pixmap_button (pixmap, _("Remove")); - gtk_object_set_data (GTK_OBJECT (remove), "rule", rule); - gtk_object_set_data (GTK_OBJECT (rule), "part", part); - /*gtk_button_set_relief (GTK_BUTTON (remove), GTK_RELIEF_NONE);*/ - gtk_signal_connect (GTK_OBJECT (remove), "clicked", less_parts, data); - gtk_table_attach (GTK_TABLE (data->parts), remove, 1, 2, row, row + 1, - 0, 0, 0, 0); - gtk_widget_show (remove); -} - -static void -more_parts (GtkWidget *button, struct _rule_data *data) -{ - FilterPart *new; - - /* first make sure that the last part is ok */ - if (data->fr->parts) { - FilterPart *part; - GList *l; - - l = g_list_last (data->fr->parts); - part = l->data; - if (!filter_part_validate (part)) - return; - } - - /* create a new rule entry, use the first type of rule */ - new = rule_context_next_part (data->f, NULL); - if (new) { - GtkWidget *w; - int rows; - - new = filter_part_clone (new); - filter_rule_add_part (data->fr, new); - w = get_rule_part_widget (data->f, new, data->fr); - - rows = GTK_TABLE (data->parts)->nrows; - gtk_table_resize (GTK_TABLE (data->parts), rows + 1, 2); - attach_rule (w, data, new, rows); - } -} - -static void -name_changed (GtkEntry *entry, FilterRule *fr) -{ - g_free (fr->name); - fr->name = e_utf8_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 void -grab_focus (GtkWidget *entry, gpointer data) -{ - gtk_widget_grab_focus (entry); -} - -static GtkWidget * -get_widget (FilterRule *fr, struct _RuleContext *f) -{ - GtkWidget *vbox, *parts, *inframe; - GtkWidget *hbox; - GtkWidget *add, *pixmap; - GtkWidget *w; - GtkWidget *menu, *item, *omenu; - GtkWidget *frame; - GtkWidget *name; - GtkWidget *label; - GtkWidget *scrolledwindow; - GtkObject *hadj, *vadj; - GList *l; - FilterPart *part; - struct _rule_data *data; - gint rows, i = 0; - - /* this stuff should probably be a table, but the - rule parts need to be a vbox */ - vbox = gtk_vbox_new (FALSE, 3); - - label = gtk_label_new (_("Rule name: ")); - name = gtk_entry_new (); - - if (!fr->name) { - fr->name = g_strdup (_("Untitled")); - gtk_entry_set_text (GTK_ENTRY (name), fr->name); - /* FIXME: do we want the following code in the future? */ - /*gtk_editable_select_region (GTK_EDITABLE (name), 0, -1);*/ - } else { - e_utf8_gtk_entry_set_text (GTK_ENTRY (name), fr->name); - } - - /* evil kludgy hack because gtk sucks */ - gtk_signal_connect (GTK_OBJECT (name), "realize", grab_focus, name); - - hbox = gtk_hbox_new (FALSE, 3); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox), name, TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - gtk_signal_connect (GTK_OBJECT (name), "changed", name_changed, fr); - - frame = gtk_frame_new (_("If")); - inframe = gtk_vbox_new (FALSE, 3); - gtk_container_add (GTK_CONTAINER (frame), inframe); - - /* this is the parts table, it should probably be inside a scrolling list */ - rows = g_list_length (fr->parts); - parts = gtk_table_new (rows, 2, FALSE); - - /* data for the parts part of the display */ - data = g_malloc0 (sizeof (*data)); - data->f = f; - data->fr = fr; - data->parts = parts; - - /* only set to automatically clean up the memory */ - gtk_object_set_data_full (GTK_OBJECT (vbox), "data", data, g_free); - - hbox = gtk_hbox_new (FALSE, 3); - label = gtk_label_new (_("Execute actions")); - - menu = gtk_menu_new (); - - item = gtk_menu_item_new_with_label (_("if all criteria are met")); - gtk_signal_connect (GTK_OBJECT (item), "activate", match_all, fr); - gtk_menu_append (GTK_MENU (menu), item); - gtk_widget_show (item); - - item = gtk_menu_item_new_with_label (_("if any criteria are met")); - gtk_signal_connect (GTK_OBJECT (item), "activate", match_any, fr); - gtk_menu_append (GTK_MENU (menu), item); - gtk_widget_show (item); - - omenu = gtk_option_menu_new (); - gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu); - gtk_option_menu_set_history (GTK_OPTION_MENU (omenu), fr->grouping == FILTER_GROUP_ALL ? 0 : 1); - gtk_widget_show (omenu); - - pixmap = gnome_stock_new_with_icon (GNOME_STOCK_PIXMAP_ADD); - add = gnome_pixmap_button (pixmap, _("Add criterion")); - gtk_signal_connect (GTK_OBJECT (add), "clicked", more_parts, data); - gtk_box_pack_start (GTK_BOX (hbox), add, FALSE, FALSE, 3); - - gtk_box_pack_end (GTK_BOX (hbox), omenu, FALSE, FALSE, 0); - gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX (inframe), hbox, FALSE, FALSE, 0); - - l = fr->parts; - while (l) { - part = l->data; - d(printf ("adding rule %s\n", part->title)); - w = get_rule_part_widget (f, part, fr); - attach_rule (w, data, part, i++); - l = g_list_next (l); - } - - hadj = gtk_adjustment_new (0.0, 0.0, 1.0, 1.0, 1.0, 1.0); - vadj = gtk_adjustment_new (0.0, 0.0, 1.0, 1.0, 1.0, 1.0); - scrolledwindow = gtk_scrolled_window_new (GTK_ADJUSTMENT (hadj), GTK_ADJUSTMENT (vadj)); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - - gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolledwindow), parts); - - gtk_box_pack_start (GTK_BOX (inframe), scrolledwindow, TRUE, TRUE, 0); - - /*gtk_box_pack_start (GTK_BOX (inframe), parts, FALSE, FALSE, 3); */ - - gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0); - - gtk_widget_show_all (vbox); - - return vbox; -} - -FilterRule * -filter_rule_next_list (GList * l, FilterRule * last, const char *source) -{ - GList *node = l; - - if (last != NULL) { - node = g_list_find (node, last); - if (node == NULL) - node = l; - else - node = g_list_next (node); - } - - if (source) { - while (node) { - FilterRule *rule = node->data; - - if (rule->source && strcmp (rule->source, source) == 0) - break; - node = g_list_next (node); - } - } - - if (node) - return node->data; - - return NULL; -} - -FilterRule * -filter_rule_find_list (GList * l, const char *name, const char *source) -{ - while (l) { - FilterRule *rule = l->data; - - if (strcmp (rule->name, name) == 0) - if (source == NULL || (rule->source != NULL && strcmp (rule->source, source) == 0)) - return rule; - l = g_list_next (l); - } - - return NULL; -} - -#ifdef FOR_TRANSLATIONS_ONLY - -static char *list[] = { - N_("incoming"), N_("outgoing") -}; -#endif diff --git a/filter/filter-rule.h b/filter/filter-rule.h deleted file mode 100644 index f0558d0f2b..0000000000 --- a/filter/filter-rule.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (C) 2000 Ximian Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef _FILTER_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 */ -}; - - -#define FILTER_SOURCE_INCOMING "incoming" /* performed on incoming email */ -#define FILTER_SOURCE_DEMAND "demand" /* performed on the selected folder - * when the user asks for it */ -#define FILTER_SOURCE_OUTGOING "outgoing"/* performed on outgoing mail */ - -struct _FilterRule { - GtkObject parent; - struct _FilterRulePrivate *priv; - - char *name; - char *source; - - enum _filter_grouping_t grouping; - GList *parts; -}; - -struct _FilterRuleClass { - GtkObjectClass parent_class; - - /* virtual methods */ - int (*validate)(FilterRule *); - - xmlNodePtr (*xml_encode)(FilterRule *); - int (*xml_decode)(FilterRule *, xmlNodePtr, struct _RuleContext *); - - void (*build_code)(FilterRule *, GString *out); - - void (*copy)(FilterRule *dest, FilterRule *src); - - GtkWidget *(*get_widget)(FilterRule *fr, struct _RuleContext *f); - - /* signals */ - void (*changed)(FilterRule *fr); -}; - -guint filter_rule_get_type (void); -FilterRule *filter_rule_new (void); - -FilterRule *filter_rule_clone (FilterRule *base); - -/* methods */ -void filter_rule_set_name (FilterRule *fr, const char *name); -void filter_rule_set_source (FilterRule *fr, const char *source); - -int filter_rule_validate (FilterRule *fr); - -xmlNodePtr filter_rule_xml_encode (FilterRule *fr); -int filter_rule_xml_decode (FilterRule *fr, xmlNodePtr node, struct _RuleContext *f); - -void filter_rule_copy (FilterRule *dest, FilterRule *src); - -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); -*/ - -void filter_rule_emit_changed (FilterRule *fr); - -/* static functions */ -FilterRule *filter_rule_next_list (GList *l, FilterRule *last, const char *source); -FilterRule *filter_rule_find_list (GList *l, const char *name, const char *source); - - -#endif /* ! _FILTER_RULE_H */ - diff --git a/filter/filter-score.c b/filter/filter-score.c deleted file mode 100644 index 170aa288ad..0000000000 --- a/filter/filter-score.c +++ /dev/null @@ -1,233 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Jeffrey Stedfast - * - * Copyright 2000 Ximian, Inc. (www.ximian.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include - -#include "e-util/e-sexp.h" -#include "filter-score.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_score_class_init (FilterScoreClass *class); -static void filter_score_init (FilterScore *gspaper); -static void filter_score_finalise (GtkObject *obj); - -#define _PRIVATE(x) (((FilterScore *)(x))->priv) - -struct _FilterScorePrivate { -}; - -static FilterElementClass *parent_class; - -enum { - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -guint -filter_score_get_type (void) -{ - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "FilterScore", - sizeof (FilterScore), - sizeof (FilterScoreClass), - (GtkClassInitFunc) filter_score_class_init, - (GtkObjectInitFunc) filter_score_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - type = gtk_type_unique (filter_element_get_type (), &type_info); - } - - return type; -} - -static void -filter_score_class_init (FilterScoreClass *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_score_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_score_init (FilterScore *o) -{ - o->priv = g_malloc0 (sizeof (*o->priv)); -} - -static void -filter_score_finalise(GtkObject *obj) -{ - FilterScore *o = (FilterScore *)obj; - - o = o; - - ((GtkObjectClass *)(parent_class))->finalize(obj); -} - -/** - * filter_score_new: - * - * Create a new FilterScore object. - * - * Return value: A new #FilterScore object. - **/ -FilterScore * -filter_score_new (void) -{ - FilterScore *o = (FilterScore *)gtk_type_new(filter_score_get_type ()); - return o; -} - -static void -xml_create (FilterElement *fe, xmlNodePtr node) -{ - /*FilterScore *fs = (FilterScore *)fe;*/ - - /* parent implementation */ - ((FilterElementClass *)(parent_class))->xml_create(fe, node); -} - -static xmlNodePtr -xml_encode (FilterElement *fe) -{ - xmlNodePtr value; - FilterScore *fs = (FilterScore *)fe; - char *score; - - d(printf("Encoding score as xml\n")); - - value = xmlNewNode (NULL, "value"); - xmlSetProp (value, "name", fe->name); - xmlSetProp (value, "type", "score"); - - score = g_strdup_printf ("%d", fs->score); - xmlSetProp (value, "score", score); - g_free (score); - - return value; -} - -static int -xml_decode (FilterElement *fe, xmlNodePtr node) -{ - FilterScore *fs = (FilterScore *)fe; - char *name; - char *score; - - d(printf("Decoding score from xml %p\n", fe)); - - name = xmlGetProp (node, "name"); - d(printf ("Name = %s\n", name)); - xmlFree (fe->name); - fe->name = name; - score = xmlGetProp (node, name); - if (score) { - fs->score = atoi (score); - xmlFree (score); - } else - fs->score = 0; - - if (fs->score > 3) - fs->score = 3; - else if (fs->score < -3) - fs->score = -3; - - return 0; -} - -static void -spin_changed (GtkWidget *spin, FilterElement *fe) -{ - FilterScore *fs = (FilterScore *)fe; - - fs->score = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin)); -} - -static GtkWidget * -get_widget (FilterElement *fe) -{ - GtkWidget *spin; - GtkObject *adjustment; - FilterScore *fs = (FilterScore *)fe; - - adjustment = gtk_adjustment_new (0.0, -3.0, 3.0, 1.0, 1.0, 1.0); - spin = gtk_spin_button_new (GTK_ADJUSTMENT (adjustment), 1.0, 0); - gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spin), TRUE); - - if (fs->score) { - gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), (gfloat) fs->score); - } - - gtk_signal_connect (GTK_OBJECT (spin), "changed", spin_changed, fe); - - return spin; -} - -static void -build_code (FilterElement *fe, GString *out, struct _FilterPart *ff) -{ - return; -} - -static void -format_sexp (FilterElement *fe, GString *out) -{ - FilterScore *fs = (FilterScore *)fe; - - g_string_sprintfa(out, "%d ", fs->score); -} diff --git a/filter/filter-score.h b/filter/filter-score.h deleted file mode 100644 index a7b7acf929..0000000000 --- a/filter/filter-score.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Jeffrey Stedfast - * - * Copyright 2000 Ximian, Inc. (www.ximian.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - */ - -#ifndef _FILTER_SCORE_H -#define _FILTER_SCORE_H - -#include "filter-element.h" - -#define FILTER_SCORE(obj) GTK_CHECK_CAST (obj, filter_score_get_type (), FilterScore) -#define FILTER_SCORE_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, filter_score_get_type (), FilterScoreClass) -#define IS_FILTER_SCORE(obj) GTK_CHECK_TYPE (obj, filter_score_get_type ()) - -typedef struct _FilterScore FilterScore; -typedef struct _FilterScoreClass FilterScoreClass; - -struct _FilterScore { - FilterElement parent; - struct _FilterScorePrivate *priv; - - gint32 score; -}; - -struct _FilterScoreClass { - FilterElementClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - -guint filter_score_get_type (void); -FilterScore *filter_score_new (void); - -/* methods */ - -#endif /* ! _FILTER_SCORE_H */ - diff --git a/filter/filter-source.c b/filter/filter-source.c deleted file mode 100644 index 9574163344..0000000000 --- a/filter/filter-source.c +++ /dev/null @@ -1,362 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * filter-source.c - * - * Copyright (C) 2001 Ximian, Inc. - * - * Authors: Jon Trowbridge - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include -#include "filter-source.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -typedef struct _SourceInfo SourceInfo; -struct _SourceInfo { - gchar *name; - gchar *address; - gchar *url; -}; - -struct _FilterSourcePrivate { - GList *sources; - gchar *current_url; -}; - -static FilterElementClass *parent_class = NULL; -enum { - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -static void filter_source_class_init (FilterSourceClass *); -static void filter_source_init (FilterSource *); -static void filter_source_finalize (GtkObject *); - -static void xml_create(FilterElement *fe, xmlNodePtr node); -static xmlNodePtr xml_encode(FilterElement *fe); -static int xml_decode(FilterElement *fe, xmlNodePtr node); -static FilterElement *clone(FilterElement *fe); -static GtkWidget *get_widget(FilterElement *fe); -static void build_code(FilterElement *fe, GString *out, struct _FilterPart *ff); -static void format_sexp(FilterElement *, GString *); - -static void filter_source_add_source (FilterSource *fs, const gchar *name, const gchar *addr, const gchar *url); -static void filter_source_get_sources (FilterSource *fs); - - -GtkType -filter_source_get_type (void) -{ - static GtkType type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "FilterSource", - sizeof(FilterSource), - sizeof(FilterSourceClass), - (GtkClassInitFunc)filter_source_class_init, - (GtkObjectInitFunc)filter_source_init, - (GtkArgSetFunc)NULL, - (GtkArgGetFunc)NULL - }; - - type = gtk_type_unique (filter_element_get_type (), &type_info); - } - - return type; -} - -static void -filter_source_class_init (FilterSourceClass *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_source_finalize; - - /* 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_source_init (FilterSource *fs) -{ - fs->priv = g_new0 (struct _FilterSourcePrivate, 1); -} - -static void -filter_source_finalize (GtkObject *obj) -{ - FilterSource *fs = FILTER_SOURCE (obj); - GList *i = fs->priv->sources; - - while (i) { - SourceInfo *info = i->data; - g_free (info->name); - g_free (info->address); - g_free (info->url); - g_free (info); - i = g_list_next (i); - } - - g_list_free (fs->priv->sources); - - g_free (fs->priv); - - if (GTK_OBJECT_CLASS (parent_class)->finalize) - GTK_OBJECT_CLASS (parent_class)->finalize (obj); -} - -FilterSource * -filter_source_new (void) -{ - FilterSource *s = (FilterSource *) gtk_type_new (filter_source_get_type ()); - return s; -} - -static void -xml_create (FilterElement *fe, xmlNodePtr node) -{ - /* Call parent implementation */ - ((FilterElementClass *)parent_class)->xml_create (fe, node); -} - -static xmlNodePtr -xml_encode (FilterElement *fe) -{ - xmlNodePtr value; - - FilterSource *fs = (FilterSource *) fe; - - value = xmlNewNode (NULL, "value"); - xmlSetProp (value, "name", fe->name); - xmlSetProp (value, "type", "uri"); - - if (fs->priv->current_url) - xmlNewTextChild (value, NULL, "uri", fs->priv->current_url); - - return value; -} - -static gint -xml_decode (FilterElement *fe, xmlNodePtr node) -{ - FilterSource *fs = (FilterSource *) fe; - gchar *value; - - node = node->childs; - if (node && node->name && !strcmp (node->name, "uri")) { - g_free (fs->priv->current_url); - fs->priv->current_url = xmlNodeGetContent (node); - } - - return 0; -} - -static FilterElement * -clone (FilterElement *fe) -{ - FilterSource *fs = (FilterSource *) fe; - FilterSource *cpy = filter_source_new (); - GList *i; - - ((FilterElement *)cpy)->name = xmlStrdup (fe->name); - - cpy->priv->current_url = g_strdup (fs->priv->current_url); - - for (i = fs->priv->sources; i != NULL; i = g_list_next (i)) { - SourceInfo *info = (SourceInfo *) i->data; - filter_source_add_source (cpy, info->name, info->address, info->url); - } - - return (FilterElement *) cpy; -} - -static void -source_changed (GtkWidget *w, FilterSource *fs) -{ - SourceInfo *info = (SourceInfo *) gtk_object_get_data (GTK_OBJECT (w), "source"); - - g_free (fs->priv->current_url); - fs->priv->current_url = g_strdup (info->url); -} - -static GtkWidget * -get_widget (FilterElement *fe) -{ - FilterSource *fs = (FilterSource *) fe; - GtkWidget *menu; - GtkWidget *omenu; - GtkWidget *item; - GList *i; - SourceInfo *first = NULL; - gint index, current_index; - - if (fs->priv->sources == NULL) - filter_source_get_sources (fs); - - menu = gtk_menu_new (); - - index = 0; - current_index = -1; - - for (i = fs->priv->sources; i != NULL; i = g_list_next (i)) { - SourceInfo *info = (SourceInfo *) i->data; - gchar *label, *native_label; - - if (info->url != NULL) { - - if (first == NULL) - first = info; - - label = g_strdup_printf ("%s <%s>", info->name, info->address); - native_label = e_utf8_to_gtk_string (GTK_WIDGET (menu), label); - item = gtk_menu_item_new_with_label (native_label); - g_free (label); - g_free (native_label); - - gtk_object_set_data (GTK_OBJECT (item), "source", info); - gtk_signal_connect (GTK_OBJECT (item), "activate", GTK_SIGNAL_FUNC (source_changed), fs); - gtk_menu_append (GTK_MENU (menu), item); - gtk_widget_show (item); - - if (fs->priv->current_url && e_url_equal (info->url, fs->priv->current_url)) { - current_index = index; - } - - ++index; - } - } - - omenu = gtk_option_menu_new (); - gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu); - - if (current_index >= 0) { - gtk_option_menu_set_history (GTK_OPTION_MENU (omenu), current_index); - } else { - gtk_option_menu_set_history (GTK_OPTION_MENU (omenu), 0); - g_free (fs->priv->current_url); - - if (first) - fs->priv->current_url = g_strdup (first->url); - else - fs->priv->current_url = NULL; - } - - return omenu; -} - -static void -build_code (FilterElement *fe, GString *out, struct _FilterPart *ff) -{ - /* We are doing nothing on purpose. */ -} - -static void -format_sexp (FilterElement *fe, GString *out) -{ - FilterSource *fs = (FilterSource *) fe; - - e_sexp_encode_string (out, fs->priv->current_url); -} - - -static void -filter_source_add_source (FilterSource *fs, const gchar *name, const gchar *addr, const gchar *url) -{ - SourceInfo *info; - g_return_if_fail (fs && IS_FILTER_SOURCE (fs)); - - info = g_new0 (SourceInfo, 1); - info->name = g_strdup (name); - info->address = g_strdup (addr); - info->url = g_strdup (url); - - fs->priv->sources = g_list_append (fs->priv->sources, info); -} - -static void -filter_source_get_sources (FilterSource *fs) -{ - Bonobo_ConfigDatabase db; - CORBA_Environment ev; - gint i, len; - - CORBA_exception_init (&ev); - db = bonobo_get_object ("wombat:", "Bonobo/ConfigDatabase", &ev); - - if (BONOBO_EX (&ev) || db == CORBA_OBJECT_NIL) { - CORBA_exception_free (&ev); - return; - } - - CORBA_exception_free (&ev); - - len = bonobo_config_get_long_with_default (db, "/Mail/Accounts/num", 0, NULL); - - for (i = 0; i < len; ++i) { - gchar *path; - gchar *name; - gchar *addr; - gchar *url; - - path = g_strdup_printf ("/Mail/Accounts/identity_name_%d", i); - name = bonobo_config_get_string (db, path, NULL); - g_free (path); - - path = g_strdup_printf ("/Mail/Accounts/identity_address_%d", i); - addr = bonobo_config_get_string (db, path, NULL); - g_free (path); - - path = g_strdup_printf ("/Mail/Accounts/source_url_%d", i); - url = bonobo_config_get_string (db, path, NULL); - g_free (path); - - filter_source_add_source (fs, name, addr, url); - - g_free (name); - g_free (addr); - g_free (url); - } -} diff --git a/filter/filter-source.h b/filter/filter-source.h deleted file mode 100644 index da7cadb3dd..0000000000 --- a/filter/filter-source.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * filter-source.h - * - * Copyright (C) 2001 Ximian, Inc. - * - * Authors: Jon Trowbridge - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __FILTER_SOURCE_H__ -#define __FILTER_SOURCE_H__ - -#include "filter-element.h" - -#define FILTER_SOURCE(obj) GTK_CHECK_CAST (obj, filter_source_get_type (), FilterSource) -#define FILTER_SOURCE_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, filter_source_get_type (), FilterSourceClass) -#define IS_FILTER_SOURCE(obj) GTK_CHECK_TYPE (obj, filter_source_get_type ()) - -typedef struct _FilterSource FilterSource; -typedef struct _FilterSourceClass FilterSourceClass; -struct _FilterSourcePrivate; - -struct _FilterSource { - FilterElement parent; - struct _FilterSourcePrivate *priv; -}; - -struct _FilterSourceClass { - FilterElementClass parent_class; -}; - -GtkType filter_source_get_type (void); -FilterSource *filter_source_new (void); - -void filter_source_set_current (FilterSource *src, const gchar *url); - -#endif /* __FILTER_SOURCE_H__ */ - diff --git a/filter/filter.glade b/filter/filter.glade deleted file mode 100644 index 7325381317..0000000000 --- a/filter/filter.glade +++ /dev/null @@ -1,738 +0,0 @@ - - - - - Filter - filter - - src - pixmaps - C - True - True - - - - GnomeDialog - edit_filter_2 - Edit Filters - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - True - 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 -Outgoing - - 0 - - 0 - False - False - - - - - GtkFrame - frame1 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - True - True - - - - GtkHBox - hbox1 - False - 0 - - - GtkScrolledWindow - scrolledwindow1 - 256 - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - 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 - - GTK_RELIEF_NORMAL - - - - GtkButton - rule_edit - True - True - - GTK_RELIEF_NORMAL - - - - GtkButton - rule_delete - True - True - - GTK_RELIEF_NORMAL - - - - GtkButton - rule_up - True - True - GNOME_STOCK_BUTTON_UP - GTK_RELIEF_NORMAL - - - - GtkButton - rule_down - True - True - GNOME_STOCK_BUTTON_DOWN - GTK_RELIEF_NORMAL - - - - - - - - - - GnomeDialog - edit_vfolder_2 - Edit VFolders - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - True - 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_AUTOMATIC - GTK_POLICY_AUTOMATIC - 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 - - GTK_RELIEF_NORMAL - - - - GtkButton - rule_edit - True - True - - GTK_RELIEF_NORMAL - - - - GtkButton - rule_delete - True - True - - GTK_RELIEF_NORMAL - - - - GtkButton - rule_up - True - True - GNOME_STOCK_BUTTON_UP - GTK_RELIEF_NORMAL - - - - GtkButton - rule_down - True - True - GNOME_STOCK_BUTTON_DOWN - GTK_RELIEF_NORMAL - - - - - - - - - - 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 - - - - GtkVBox - vbox3 - False - 0 - - - GtkOptionMenu - source_option - True - specific folders only -with all local folders -with all active remote folders -with all local and active remote folders - - 0 - - 0 - False - False - - - - - GtkHBox - hbox3 - False - 0 - - 0 - True - True - - - - 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 - - GTK_RELIEF_NORMAL - - - - GtkButton - source_remove - True - True - - GTK_RELIEF_NORMAL - - - - - - - - - - - GtkWindow - edit_filter - window1 - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - True - False - - - GtkVBox - rule_editor - False - 0 - - - GtkOptionMenu - filter_source - False - True - Incoming - - 0 - - 0 - False - False - - - - - GtkFrame - rule_frame - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - True - True - - - - GtkHBox - hbox4 - False - 0 - - - GtkScrolledWindow - scrolledwindow4 - 256 - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_UPDATE_CONTINUOUS - GTK_UPDATE_CONTINUOUS - - 0 - True - True - - - - GtkViewport - viewport4 - GTK_SHADOW_IN - - - GtkList - rule_list - GTK_SELECTION_SINGLE - - - - - - GtkVBox - vbox5 - False - 0 - - 0 - False - False - - - - GtkVButtonBox - vbuttonbox4 - GTK_BUTTONBOX_DEFAULT_STYLE - 0 - 85 - 27 - 6 - 0 - - 0 - False - False - - - - GtkButton - rule_add - True - True - - GTK_RELIEF_NORMAL - - - - GtkButton - rule_edit - True - True - - GTK_RELIEF_NORMAL - - - - GtkButton - rule_delete - True - True - - GTK_RELIEF_NORMAL - - - - GtkButton - rule_up - True - True - GNOME_STOCK_BUTTON_UP - GTK_RELIEF_NORMAL - - - - GtkButton - rule_down - True - True - GNOME_STOCK_BUTTON_DOWN - GTK_RELIEF_NORMAL - - - - - - - - - diff --git a/filter/filtertypes.xml b/filter/filtertypes.xml deleted file mode 100644 index 0f651527ee..0000000000 --- a/filter/filtertypes.xml +++ /dev/null @@ -1,631 +0,0 @@ - - - - - Sender - - - - - - - - - - - - - - - - - Recipients - - - - - - - - - - - - - - - - - Subject - - - - - - - - - - - - - - - - - Specific header - - - - - - - - - - - - - - - - - - - - Message Body - - - - - - - - - Expression - - - - - Date sent - - - - - - - - - - - Date received - - - - - - - - - - - Score - - - - - - - - - - - - Size (kB) - - - - - - - - - Status - - - - - - - - - - - - - - - Attachments - - - - - - - - Mailing list - - - - - - - - - - - - - - - Regex Match - - - - - - - - - Source Account - - - - - - - - - - - - - Move to Folder - (move-to ${folder}) - - - - Copy to Folder - (copy-to ${folder}) - - - - Delete - (delete) - - - Stop Processing - (stop) - - - Assign Color - (set-colour ${colour}) - - - - Assign Score - (set-score ${score}) - - - - Set Status - - (set-system-flag ${flag}) - - - - - - - - - - - diff --git a/filter/libfilter-i18n.h b/filter/libfilter-i18n.h deleted file mode 100644 index 175eac2dc6..0000000000 --- a/filter/libfilter-i18n.h +++ /dev/null @@ -1,53 +0,0 @@ -/* Automatically generated. Do not edit. */ -char *s = N_("Assign Color"); -char *s = N_("Assign Score"); -char *s = N_("Attachments"); -char *s = N_("Copy to Folder"); -char *s = N_("Date received"); -char *s = N_("Date sent"); -char *s = N_("Delete"); -char *s = N_("Deleted"); -char *s = N_("Do Not Exist"); -char *s = N_("Draft"); -char *s = N_("Exist"); -char *s = N_("Expression"); -char *s = N_("Important"); -char *s = N_("Mailing list"); -char *s = N_("Message Body"); -char *s = N_("Message Header"); -char *s = N_("Message was received"); -char *s = N_("Message was sent"); -char *s = N_("Move to Folder"); -char *s = N_("Read"); -char *s = N_("Recipients"); -char *s = N_("Regex Match"); -char *s = N_("Replied to"); -char *s = N_("Score"); -char *s = N_("Sender"); -char *s = N_("Set Status"); -char *s = N_("Size (kB)"); -char *s = N_("Source Account"); -char *s = N_("Specific header"); -char *s = N_("Status"); -char *s = N_("Stop Processing"); -char *s = N_("Subject"); -char *s = N_("after"); -char *s = N_("before"); -char *s = N_("contains"); -char *s = N_("does not contain"); -char *s = N_("does not end with"); -char *s = N_("does not exist"); -char *s = N_("does not sound like"); -char *s = N_("does not start with"); -char *s = N_("ends with"); -char *s = N_("exists"); -char *s = N_("is greater than"); -char *s = N_("is less than"); -char *s = N_("is not"); -char *s = N_("is"); -char *s = N_("on or after"); -char *s = N_("on or before"); -char *s = N_("sounds like"); -char *s = N_("starts with"); -char *s = N_("was after"); -char *s = N_("was before"); diff --git a/filter/rule-context.c b/filter/rule-context.c deleted file mode 100644 index d11e4ec722..0000000000 --- a/filter/rule-context.c +++ /dev/null @@ -1,679 +0,0 @@ -/* - * Copyright (C) 2000 Ximian Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#ifdef HAVE_ALLOCA_H -#include -#endif - -#include -#include -#include -#include -#include - -#include "rule-context.h" - -#define d(x) - -static int load(RuleContext * f, const char *system, const char *user); -static int save(RuleContext * f, const char *user); -static int rename_uri(RuleContext *f, const char *olduri, const char *newuri, GCompareFunc cmp); -static int delete_uri(RuleContext *f, const char *uri, GCompareFunc cmp); - -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 { - int frozen; -}; - -static GtkObjectClass *parent_class; - -enum { - RULE_ADDED, - RULE_REMOVED, - CHANGED, - 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; - class->rename_uri = rename_uri; - class->delete_uri = delete_uri; - - /* signals */ - signals[RULE_ADDED] = - gtk_signal_new("rule_added", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (RuleContextClass, rule_added), - gtk_marshal_NONE__POINTER, - GTK_TYPE_NONE, 1, GTK_TYPE_POINTER); - - signals[RULE_REMOVED] = - gtk_signal_new("rule_removed", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (RuleContextClass, rule_removed), - gtk_marshal_NONE__POINTER, - GTK_TYPE_NONE, 1, GTK_TYPE_POINTER); - - signals[CHANGED] = - gtk_signal_new("changed", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (RuleContextClass, changed), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - 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 -free_part_set (struct _part_set_map *map, void *data) -{ - g_free (map->name); - g_free (map); -} - -static void -free_rule_set (struct _rule_set_map *map, void *data) -{ - g_free (map->name); - g_free (map); -} - -static void -rule_context_finalise (GtkObject * obj) -{ - RuleContext *o = (RuleContext *) obj; - - g_list_foreach (o->rule_set_list, (GFunc)free_rule_set, NULL); - g_list_free (o->rule_set_list); - g_hash_table_destroy (o->rule_set_map); - - g_list_foreach (o->part_set_list, (GFunc)free_part_set, NULL); - g_list_free (o->part_set_list); - g_hash_table_destroy (o->part_set_map); - - g_free (o->error); - - g_list_foreach (o->parts, (GFunc)gtk_object_unref, NULL); - g_list_free (o->parts); - g_list_foreach (o->rules, (GFunc)gtk_object_unref, NULL); - g_list_free (o->rules); - - if (o->system) - xmlFreeDoc (o->system); - if (o->user) - xmlFreeDoc (o->user); - - g_free (o->priv); - - ((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; - - g_assert(g_hash_table_lookup(f->part_set_map, setname) == NULL); - - 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; - - g_assert(g_hash_table_lookup (f->rule_set_map, setname) == NULL); - - 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_assert(f); - - g_free (f->error); - f->error = error; -} - -/** - * rule_context_load: - * @f: - * @system: - * @user: - * - * 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) -{ - int res; - - g_assert(f); - - d(printf("rule_context: loading %s %s\n", system, user)); - - f->priv->frozen++; - res= ((RuleContextClass *) ((GtkObject *) f)->klass)->load (f, system, user); - f->priv->frozen--; - - return res; -} - -static int -load (RuleContext *f, const char *system, const char *user) -{ - 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 (GTK_OBJECT (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) { - d(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); - } else { - gtk_object_unref (GTK_OBJECT (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) -{ - g_assert(f); - g_assert(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; - char *usersav, *userbak, *slash; - int ret; - - 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, NULL))) { - d(printf("processing rule %s\n", rule->name)); - work = filter_rule_xml_encode (rule); - xmlAddChild (rules, work); - } - l = g_list_next (l); - } - - usersav = alloca(strlen(user)+5); - userbak = alloca(strlen(user)+5); - slash = strrchr(user, '/'); - if (slash) - sprintf(usersav, "%.*s.#%s", slash-user+1, user, slash+1); - else - sprintf(usersav, ".#%s", user); - sprintf(userbak, "%s~", user); - printf("saving rules to '%s' then backup '%s'\n", usersav, userbak); - ret = xmlSaveFile(usersav, doc); - if (ret != -1) { - rename(user, userbak); - ret = rename(usersav, user); - } - xmlFreeDoc (doc); - return ret; -} - -FilterPart * -rule_context_find_part (RuleContext *f, const char *name) -{ - g_assert(f); - g_assert(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; - - g_assert(f); - g_assert(name); - - 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) -{ - g_assert(f); - - return filter_part_next_list (f->parts, last); -} - -FilterRule * -rule_context_next_rule (RuleContext *f, FilterRule *last, const char *source) -{ - g_assert(f); - - return filter_rule_next_list (f->rules, last, source); -} - -FilterRule * -rule_context_find_rule (RuleContext *f, const char *name, const char *source) -{ - g_assert(name); - g_assert(f); - - return filter_rule_find_list (f->rules, name, source); -} - -void -rule_context_add_part (RuleContext *f, FilterPart *part) -{ - g_assert(f); - g_assert(part); - - f->parts = g_list_append (f->parts, part); -} - -void -rule_context_add_rule (RuleContext *f, FilterRule *new) -{ - g_assert(f); - g_assert(new); - - d(printf("add rule '%s'\n", new->name)); - - f->rules = g_list_append (f->rules, new); - - if (f->priv->frozen == 0) { - gtk_signal_emit((GtkObject *)f, signals[RULE_ADDED], new); - gtk_signal_emit((GtkObject *)f, signals[CHANGED]); - } -} - -static void -new_rule_clicked (GtkWidget *dialog, int button, RuleContext *context) -{ - if (button == 0) { - FilterRule *rule = gtk_object_get_data (GTK_OBJECT (dialog), "rule"); - char *user = gtk_object_get_data (GTK_OBJECT (dialog), "path"); - - if (!filter_rule_validate (rule)) { - /* no need to popup a dialog because the validate code does that. */ - return; - } - - gtk_object_ref (GTK_OBJECT (rule)); - rule_context_add_rule (context, rule); - if (user) { - rule_context_save ((RuleContext *) context, user); - } - } - - if (button != -1) { - gnome_dialog_close (GNOME_DIALOG (dialog)); - } -} - -/* 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 *dialog, *w; - - d(printf("add rule gui '%s'\n", rule->name)); - - g_assert(f); - g_assert(rule); - - w = filter_rule_get_widget (rule, f); - dialog = gnome_dialog_new (title, GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_CANCEL, NULL); - gtk_window_set_policy (GTK_WINDOW (dialog), FALSE, TRUE, FALSE); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), w, TRUE, TRUE, 0); - gtk_window_set_default_size (GTK_WINDOW (dialog), 600, 400); - gtk_widget_show (w); - - gtk_object_set_data_full (GTK_OBJECT (dialog), "rule", rule, (GtkDestroyNotify) gtk_object_unref); - if (path) - gtk_object_set_data_full (GTK_OBJECT (dialog), "path", g_strdup (path), (GtkDestroyNotify) g_free); - gtk_signal_connect (GTK_OBJECT (dialog), "clicked", new_rule_clicked, f); - gtk_object_ref (GTK_OBJECT (f)); - gtk_object_set_data_full (GTK_OBJECT (dialog), "context", f, (GtkDestroyNotify) gtk_object_unref); - gtk_widget_show (dialog); -} - -void -rule_context_remove_rule (RuleContext *f, FilterRule *rule) -{ - g_assert(f); - g_assert(rule); - - d(printf("remove rule '%s'\n", rule->name)); - - f->rules = g_list_remove (f->rules, rule); - - if (f->priv->frozen == 0) { - gtk_signal_emit((GtkObject *)f, signals[RULE_REMOVED], rule); - gtk_signal_emit((GtkObject *)f, signals[CHANGED]); - } -} - -void -rule_context_rank_rule (RuleContext *f, FilterRule *rule, int rank) -{ - GList *node; - int i = 0, index = 0; - - g_assert(f); - g_assert(rule); - - if (rule_context_get_rank_rule(f, rule, rule->source) == rank) - return; - - f->rules = g_list_remove(f->rules, rule); - node = f->rules; - while (node) { - FilterRule *r = node->data; - - if (i == rank) { - f->rules = g_list_insert(f->rules, rule, index); - if (f->priv->frozen == 0) - gtk_signal_emit((GtkObject *)f, signals[CHANGED]); - return; - } - - index++; - if (rule->source == NULL || (r->source && strcmp (r->source, rule->source) == 0)) - i++; - - node = node->next; - } - - f->rules = g_list_append(f->rules, rule); - if (f->priv->frozen == 0) - gtk_signal_emit((GtkObject *)f, signals[CHANGED]); -} - -int -rule_context_get_rank_rule (RuleContext *f, FilterRule *rule, const char *source) -{ - GList *node; - int i = 0; - - g_assert(f); - g_assert(rule); - - d(printf("getting rank of rule '%s'\n", rule->name)); - - node = f->rules; - while (node) { - FilterRule *r = node->data; - - d(printf(" checking against rule '%s' rank '%d'\n", r->name, i)); - - if (r == rule) - return i; - - if (source == NULL || (r->source && strcmp (r->source, source) == 0)) - i++; - - node = node->next; - } - - return -1; -} - -FilterRule * -rule_context_find_rank_rule (RuleContext *f, int rank, const char *source) -{ - GList *node; - int i = 0; - - g_assert(f); - - d(printf("getting rule at rank %d source '%s'\n", rank, source?source:"")); - - node = f->rules; - while (node) { - FilterRule *r = node->data; - - d(printf(" checking against rule '%s' rank '%d'\n", r->name, i)); - - if (source == NULL || (r->source && strcmp(r->source, source) == 0)) { - if (rank == i) - return r; - i++; - } - - node = node->next; - } - - return NULL; -} - -static int -delete_uri(RuleContext *f, const char *uri, GCompareFunc cmp) -{ - return 0; -} - -int -rule_context_delete_uri(RuleContext *f, const char *uri, GCompareFunc cmp) -{ - return ((RuleContextClass *) ((GtkObject *) f)->klass)->delete_uri(f, uri, cmp); -} - -static int -rename_uri(RuleContext *f, const char *olduri, const char *newuri, GCompareFunc cmp) -{ - return 0; -} - -int -rule_context_rename_uri(RuleContext *f, const char *olduri, const char *newuri, GCompareFunc cmp) -{ - return ((RuleContextClass *) ((GtkObject *) f)->klass)->rename_uri (f, olduri, newuri, cmp); -} - - diff --git a/filter/rule-context.h b/filter/rule-context.h deleted file mode 100644 index 982129b216..0000000000 --- a/filter/rule-context.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (C) 2000 Ximian Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef _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); - int (*save)(RuleContext *f, const char *user); - - int (*delete_uri)(RuleContext *f, const char *uri, GCompareFunc cmp); - int (*rename_uri)(RuleContext *f, const char *olduri, const char *newuri, GCompareFunc cmp); - - /* signals */ - void (*rule_added)(RuleContext *f, FilterRule *rule); - void (*rule_removed)(RuleContext *f, FilterRule *rule); - void (*changed)(RuleContext *f); -}; - -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, const char *source); - -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); -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, const char *source); -FilterRule *rule_context_find_rule(RuleContext *f, const char *name, const char *source); -FilterRule *rule_context_find_rank_rule(RuleContext *f, int rank, const char *source); -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, const char *source); - -/* 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); - -/* uri's disappear/renamed externally */ -int rule_context_delete_uri(RuleContext *f, const char *uri, GCompareFunc cmp); -int rule_context_rename_uri(RuleContext *f, const char *olduri, const char *newuri, GCompareFunc cmp); - -#endif /* ! _RULE_CONTEXT_H */ - diff --git a/filter/rule-editor.c b/filter/rule-editor.c deleted file mode 100644 index b6056b3777..0000000000 --- a/filter/rule-editor.c +++ /dev/null @@ -1,650 +0,0 @@ -/* - * Copyright (C) 2000 Ximian Inc. - * - * Authors: Not Zed - * Jeffrey Stedfast - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include "rule-editor.h" -#include "rule-context.h" -#include "filter-rule.h" - -/* for getenv only, remove when getenv need removed */ -#include - -static int enable_undo; - -void rule_editor_add_undo(RuleEditor *re, int type, FilterRule *rule, int rank, int newrank); -void rule_editor_play_undo(RuleEditor *re); - -#define d(x) x - -static void set_source(RuleEditor *re, const char *source); -static void set_sensitive(RuleEditor *re); -static FilterRule *create_rule(RuleEditor *re); - -static void rule_editor_class_init(RuleEditorClass *class); -static void rule_editor_init (RuleEditor *gspaper); -static void rule_editor_finalise (GtkObject *obj); -static void rule_editor_destroy (GtkObject *obj); - -#define _PRIVATE(x)(((RuleEditor *)(x))->priv) - -enum { - BUTTON_ADD, - BUTTON_EDIT, - BUTTON_DELETE, - BUTTON_UP, - BUTTON_DOWN, - BUTTON_LAST -}; - -struct _RuleEditorPrivate { - GtkButton *buttons[BUTTON_LAST]; -}; - -static GnomeDialogClass *parent_class; - -enum { - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -guint -rule_editor_get_type(void) -{ - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "RuleEditor", - sizeof (RuleEditor), - sizeof (RuleEditorClass), - (GtkClassInitFunc) rule_editor_class_init, - (GtkObjectInitFunc) rule_editor_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - /* TODO: Remove when it works (or never will) */ - enable_undo = getenv("EVOLUTION_RULE_UNDO") != NULL; - - type = gtk_type_unique (gnome_dialog_get_type (), &type_info); - } - - return type; -} - -static void -rule_editor_class_init (RuleEditorClass *class) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *)class; - parent_class = gtk_type_class(gnome_dialog_get_type()); - - object_class->finalize = rule_editor_finalise; - object_class->destroy = rule_editor_destroy; - - /* override methods */ - class->set_source = set_source; - class->set_sensitive = set_sensitive; - class->create_rule = create_rule; - - /* signals */ - - gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); -} - -static void -rule_editor_init (RuleEditor *o) -{ - o->priv = g_malloc0 (sizeof (*o->priv)); -} - -static void -rule_editor_finalise (GtkObject *obj) -{ - RuleEditor *re = (RuleEditor *)obj; - RuleEditorUndo *undo, *next; - - gtk_object_unref (GTK_OBJECT (re->context)); - g_free (re->priv); - - undo = re->undo_log; - while (undo) { - next = undo->next; - gtk_object_unref((GtkObject *)undo->rule); - g_free(undo); - undo = next; - } - - ((GtkObjectClass *)(parent_class))->finalize (obj); -} - -static void -rule_editor_destroy (GtkObject *obj) -{ - RuleEditor *re = (RuleEditor *) obj; - - if (re->dialog) - gtk_widget_destroy (GTK_WIDGET (re->dialog)); - - ((GtkObjectClass *)(parent_class))->destroy (obj); -} - -/** - * rule_editor_new: - * - * Create a new RuleEditor object. - * - * Return value: A new #RuleEditor object. - **/ -RuleEditor * -rule_editor_new (RuleContext *f, const char *source) -{ - GladeXML *gui; - RuleEditor *o = (RuleEditor *)gtk_type_new (rule_editor_get_type ()); - GtkWidget *w; - - gui = glade_xml_new (FILTER_GLADEDIR "/filter.glade", "rule_editor"); - rule_editor_construct (o, f, gui, source); - - w = glade_xml_get_widget (gui, "rule_frame"); - gtk_frame_set_label ((GtkFrame *)w, _("Rules")); - - gtk_object_unref (GTK_OBJECT (gui)); - - return o; -} - -/* used internally by implementations if required */ -void -rule_editor_set_sensitive (RuleEditor *re) -{ - return ((RuleEditorClass *)((GtkObject *)re)->klass)->set_sensitive(re); -} - -/* used internally by implementations */ -void -rule_editor_set_source (RuleEditor *re, const char *source) -{ - return ((RuleEditorClass *)((GtkObject *)re)->klass)->set_source(re, source); -} - -/* factory method for "add" button */ -FilterRule * -rule_editor_create_rule (RuleEditor *re) -{ - return ((RuleEditorClass *)((GtkObject *)re)->klass)->create_rule(re); -} - -static FilterRule * -create_rule (RuleEditor *re) -{ - FilterRule *rule = filter_rule_new (); - FilterPart *part; - - /* create a rule with 1 part in it */ - part = rule_context_next_part (re->context, NULL); - filter_rule_add_part (rule, filter_part_clone (part)); - - return rule; -} - -static void -add_editor_clicked (GtkWidget *dialog, int button, RuleEditor *re) -{ - GtkWidget *item; - GList *l = NULL; - char *string; - - switch (button) { - case 0: - if (!filter_rule_validate (re->edit)) { - /* no need to popup a dialog because the validate code does that. */ - return; - } - - gtk_object_ref (GTK_OBJECT (re->edit)); - string = e_utf8_to_gtk_string (GTK_WIDGET (re->list), re->edit->name); - item = gtk_list_item_new_with_label (string); - g_free (string); - - gtk_object_set_data (GTK_OBJECT (item), "rule", re->edit); - gtk_widget_show (item); - - l = g_list_append (l, GTK_LIST_ITEM (item)); - - gtk_list_append_items (re->list, l); - gtk_list_select_child (re->list, item); - - re->current = re->edit; - rule_context_add_rule (re->context, re->current); - - gtk_object_ref((GtkObject *)re->current); - rule_editor_add_undo(re, RULE_EDITOR_LOG_ADD, re->current, rule_context_get_rank_rule (re->context, re->current, re->current->source), 0); - case 1: - default: - gnome_dialog_close (GNOME_DIALOG (dialog)); - case -1: - gtk_object_unref (GTK_OBJECT (re->edit)); - re->edit = NULL; - - re->dialog = NULL; - - gtk_widget_set_sensitive (GTK_WIDGET (re), TRUE); - rule_editor_set_sensitive (re); - } -} - -static void -add_editor_destroyed(GtkWidget *w, RuleEditor *re) -{ - add_editor_clicked(w, -1, re); -} - -static void -rule_add (GtkWidget *widget, RuleEditor *re) -{ - GtkWidget *rules; - - if (re->edit != NULL) - return; - - re->edit = rule_editor_create_rule (re); - filter_rule_set_source (re->edit, re->source); - rules = filter_rule_get_widget (re->edit, re->context); - - re->dialog = gnome_dialog_new (_("Add Rule"), - GNOME_STOCK_BUTTON_OK, - GNOME_STOCK_BUTTON_CANCEL, - NULL); - - gtk_window_set_default_size (GTK_WINDOW (re->dialog), 600, 400); - gtk_window_set_policy (GTK_WINDOW (re->dialog), FALSE, TRUE, FALSE); - gtk_widget_set_parent_window (GTK_WIDGET (re->dialog), GTK_WIDGET (re)->window); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (re->dialog)->vbox), rules, TRUE, TRUE, 0); - gtk_signal_connect (GTK_OBJECT (re->dialog), "clicked", add_editor_clicked, re); - gtk_signal_connect (GTK_OBJECT (re->dialog), "destroy", add_editor_destroyed, re); - gtk_widget_set_sensitive (GTK_WIDGET (re), FALSE); - - gtk_widget_show (re->dialog); -} - -static void -edit_editor_clicked (GtkWidget *dialog, int button, RuleEditor *re) -{ - GtkWidget *item; - char *string; - int pos; - - switch (button) { - case 0: - if (!filter_rule_validate (re->edit)) { - /* no need to popup a dialog because the validate code does that. */ - return; - } - - pos = rule_context_get_rank_rule (re->context, re->current, re->source); - if (pos != -1) { - item = g_list_nth_data (GTK_LIST (re->list)->children, pos); - string = e_utf8_to_gtk_string (GTK_WIDGET (item), re->edit->name); - gtk_label_set_text (GTK_LABEL (GTK_BIN (item)->child), string); - g_free (string); - - rule_editor_add_undo(re, RULE_EDITOR_LOG_EDIT, filter_rule_clone(re->current), pos, 0); - - /* replace the old rule with the new rule */ - filter_rule_copy (re->current, re->edit); - } - case 1: - default: - gnome_dialog_close (GNOME_DIALOG (dialog)); - case -1: - gtk_object_unref (GTK_OBJECT (re->edit)); - re->edit = NULL; - - re->dialog = NULL; - - gtk_widget_set_sensitive (GTK_WIDGET (re), TRUE); - rule_editor_set_sensitive (re); - } -} - -static void -edit_editor_destroyed(GtkWidget *w, RuleEditor *re) -{ - edit_editor_clicked(w, -1, re); -} - -static void -rule_edit (GtkWidget *widget, RuleEditor *re) -{ - GtkWidget *rules; - - if (re->current == NULL || re->edit != NULL) - return; - - re->edit = filter_rule_clone (re->current); - - rules = filter_rule_get_widget (re->edit, re->context); - re->dialog = gnome_dialog_new (_("Edit Rule"), - GNOME_STOCK_BUTTON_OK, - GNOME_STOCK_BUTTON_CANCEL, - NULL); - - gtk_window_set_default_size (GTK_WINDOW (re->dialog), 600, 400); - gtk_window_set_policy (GTK_WINDOW (re->dialog), FALSE, TRUE, FALSE); - gtk_widget_set_parent (re->dialog, GTK_WIDGET (re)); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (re->dialog)->vbox), rules, TRUE, TRUE, 0); - gtk_signal_connect (GTK_OBJECT (re->dialog), "clicked", edit_editor_clicked, re); - gtk_signal_connect (GTK_OBJECT (re->dialog), "destroy", edit_editor_destroyed, re); - - gtk_widget_set_sensitive (GTK_WIDGET (re), FALSE); - - gtk_widget_show (re->dialog); -} - -static void -rule_delete (GtkWidget *widget, RuleEditor *re) -{ - int pos; - GList *l; - GtkListItem *item; - - d(printf ("delete rule\n")); - pos = rule_context_get_rank_rule (re->context, re->current, re->source); - if (pos != -1) { - gint len; - - rule_context_remove_rule (re->context, re->current); - - item = g_list_nth_data (GTK_LIST (re->list)->children, pos); - l = g_list_append (NULL, item); - gtk_list_remove_items (re->list, l); - g_list_free (l); - - rule_editor_add_undo(re, RULE_EDITOR_LOG_REMOVE, re->current, rule_context_get_rank_rule(re->context, re->current, re->current->source), 0); -#if 0 - gtk_object_unref (GTK_OBJECT (re->current)); -#endif - re->current = NULL; - - /* now select the next rule */ - len = g_list_length (GTK_LIST (re->list)->children); - pos = pos >= len ? len - 1 : pos; - gtk_list_select_item (GTK_LIST (re->list), pos); - } - - rule_editor_set_sensitive (re); -} - -static void -rule_move (RuleEditor *re, int from, int to) -{ - GList *l; - GtkListItem *item; - - gtk_object_ref((GtkObject *)re->current); - rule_editor_add_undo(re, RULE_EDITOR_LOG_RANK, re->current, rule_context_get_rank_rule(re->context, re->current, re->current->source), to); - - d(printf ("moving %d to %d\n", from, to)); - rule_context_rank_rule (re->context, re->current, to); - - item = g_list_nth_data (re->list->children, from); - l = g_list_append (NULL, item); - gtk_list_remove_items_no_unref (re->list, l); - gtk_list_insert_items (re->list, l, to); - gtk_list_select_child (re->list, GTK_WIDGET (item)); - - rule_editor_set_sensitive (re); -} - -static void -rule_up (GtkWidget *widget, RuleEditor *re) -{ - int pos; - - d(printf ("up rule\n")); - pos = rule_context_get_rank_rule (re->context, re->current, re->source); - if (pos > 0) - rule_move (re, pos, pos - 1); -} - -static void -rule_down (GtkWidget *widget, RuleEditor *re) -{ - int pos; - - d(printf ("down rule\n")); - pos = rule_context_get_rank_rule (re->context, re->current, re->source); - if (pos >= 0) - rule_move (re, 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 (RuleEditor *re) -{ - FilterRule *rule = NULL; - int index = -1, count = 0; - - while ((rule = rule_context_next_rule(re->context, rule, re->source))) { - if (rule == re->current) - index = count; - count++; - } - - d(printf("index = %d count=%d\n", index, count)); - - count--; - - gtk_widget_set_sensitive (GTK_WIDGET (re->priv->buttons[BUTTON_EDIT]), index != -1); - gtk_widget_set_sensitive (GTK_WIDGET (re->priv->buttons[BUTTON_DELETE]), index != -1); - gtk_widget_set_sensitive (GTK_WIDGET (re->priv->buttons[BUTTON_UP]), index > 0); - gtk_widget_set_sensitive (GTK_WIDGET (re->priv->buttons[BUTTON_DOWN]), index >= 0 && index < count); -} - - -static void -select_rule (GtkWidget *w, GtkWidget *child, RuleEditor *re) -{ - re->current = gtk_object_get_data (GTK_OBJECT (child), "rule"); - - g_assert (re->current); - - rule_editor_set_sensitive (re); -} - -static void -double_click (GtkWidget *widget, GdkEventButton *event, RuleEditor *re) -{ - if (re->current && event->type == GDK_2BUTTON_PRESS) - rule_edit (widget, re); -} - -static void -set_source (RuleEditor *re, const char *source) -{ - FilterRule *rule = NULL; - GList *newitems = NULL; - - gtk_list_clear_items(GTK_LIST(re->list), 0, -1); - - d(printf("Checking for rules that are of type %s\n", source?source:"")); - while ((rule = rule_context_next_rule(re->context, rule, source)) != NULL) { - GtkWidget *item; - char *s; - - d(printf(" hit %s(%s)\n", rule->name, source?source:"")); - s = e_utf8_to_gtk_string (GTK_WIDGET (re->list), rule->name); - item = gtk_list_item_new_with_label (s); - g_free (s); - 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 (re->list, newitems); - g_free (re->source); - re->source = g_strdup (source); - re->current = NULL; - rule_editor_set_sensitive (re); -} - -void -rule_editor_add_undo(RuleEditor *re, int type, FilterRule *rule, int rank, int newrank) -{ - RuleEditorUndo *undo; - - if (!re->undo_active && enable_undo) { - undo = g_malloc0(sizeof(*undo)); - undo->rule = rule; - undo->type = type; - undo->rank = rank; - undo->newrank = newrank; - - undo->next = re->undo_log; - re->undo_log = undo; - } else { - gtk_object_unref((GtkObject *)rule); - } -} - -void -rule_editor_play_undo(RuleEditor *re) -{ - RuleEditorUndo *undo, *next; - FilterRule *rule; - - re->undo_active = TRUE; - undo = re->undo_log; - re->undo_log = NULL; - while (undo) { - next = undo->next; - switch (undo->type) { - case RULE_EDITOR_LOG_EDIT: - printf("Undoing edit on rule '%s'\n", undo->rule->name); - rule = rule_context_find_rank_rule(re->context, undo->rank, undo->rule->source); - if (rule) { - printf(" name was '%s'\n", rule->name); - filter_rule_copy(rule, undo->rule); - printf(" name is '%s'\n", rule->name); - } else { - g_warning("Could not find the right rule to undo against?\n"); - } - break; - case RULE_EDITOR_LOG_ADD: - printf("Undoing add on rule '%s'\n", undo->rule->name); - rule = rule_context_find_rank_rule(re->context, undo->rank, undo->rule->source); - if (rule) - rule_context_remove_rule(re->context, rule); - break; - case RULE_EDITOR_LOG_REMOVE: - printf("Undoing remove on rule '%s'\n", undo->rule->name); - gtk_object_ref((GtkObject *)undo->rule); - rule_context_add_rule(re->context, undo->rule); - rule_context_rank_rule(re->context, undo->rule, undo->rank); - break; - case RULE_EDITOR_LOG_RANK: - rule = rule_context_find_rank_rule(re->context, undo->newrank, undo->rule->source); - if (rule) - rule_context_rank_rule(re->context, rule, undo->rank); - break; - } - gtk_object_unref((GtkObject *)undo->rule); - g_free(undo); - undo = next; - } - re->undo_active = FALSE; -} - -static void -editor_clicked (GtkWidget *dialog, int button, RuleEditor *re) -{ - if (button != 0) { - if (enable_undo) - rule_editor_play_undo(re); - else { - RuleEditorUndo *undo, *next; - - undo = re->undo_log; - re->undo_log = 0; - while (undo) { - next = undo->next; - gtk_object_unref((GtkObject *)undo->rule); - g_free(undo); - undo = next; - } - } - } -} - -void -rule_editor_construct (RuleEditor *re, RuleContext *context, GladeXML *gui, const char *source) -{ - GtkWidget *w; - int i; - - re->context = context; - gtk_object_ref (GTK_OBJECT (context)); - - gtk_window_set_policy (GTK_WINDOW (re), FALSE, TRUE, FALSE); - - w = glade_xml_get_widget (gui, "rule_editor"); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (re)->vbox), w, TRUE, TRUE, 0); - - for (i = 0; i < BUTTON_LAST; i++) { - re->priv->buttons[i] = (GtkButton *)w = glade_xml_get_widget (gui, edit_buttons[i].name); - gtk_signal_connect (GTK_OBJECT (w), "clicked", edit_buttons[i].func, re); - } - - re->list = (GtkList *) w = glade_xml_get_widget(gui, "rule_list"); - gtk_signal_connect (GTK_OBJECT (w), "select_child", select_rule, re); - gtk_signal_connect (GTK_OBJECT (w), "button_press_event", double_click, re); - - gtk_signal_connect (GTK_OBJECT (re), "clicked", editor_clicked, re); - rule_editor_set_source (re, source); - - if (enable_undo) { - gnome_dialog_append_buttons (GNOME_DIALOG (re), GNOME_STOCK_BUTTON_OK, - GNOME_STOCK_BUTTON_CANCEL, NULL); - } else - gnome_dialog_append_buttons (GNOME_DIALOG (re), GNOME_STOCK_BUTTON_OK, NULL); -} diff --git a/filter/rule-editor.h b/filter/rule-editor.h deleted file mode 100644 index f054023c87..0000000000 --- a/filter/rule-editor.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) 2000 Ximian Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef _RULE_EDITOR_H -#define _RULE_EDITOR_H - -#include -#include - -#define RULE_EDITOR(obj) GTK_CHECK_CAST (obj, rule_editor_get_type (), RuleEditor) -#define RULE_EDITOR_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, rule_editor_get_type (), RuleEditorClass) -#define IS_RULE_EDITOR(obj) GTK_CHECK_TYPE (obj, rule_editor_get_type ()) - -typedef struct _RuleEditor RuleEditor; -typedef struct _RuleEditorClass RuleEditorClass; -typedef struct _RuleEditorUndo RuleEditorUndo; - -struct _RuleEditor { - GnomeDialog parent; - - GtkList *list; - struct _RuleContext *context; - struct _FilterRule *current; - struct _FilterRule *edit; /* for editing/adding rules, so we only do 1 at a time */ - - GtkWidget *dialog; - - char *source; - - struct _RuleEditorUndo *undo_log; /* cancel/undo log */ - unsigned int undo_active:1; /* we're performing undo */ - - struct _RuleEditorPrivate *priv; -}; - -struct _RuleEditorClass { - GnomeDialogClass parent_class; - - /* virtual methods */ - void (*set_sensitive)(RuleEditor *); - void (*set_source)(RuleEditor *, const char *source); - - struct _FilterRule *(*create_rule)(RuleEditor *); - - /* signals */ -}; - -enum { - RULE_EDITOR_LOG_EDIT, - RULE_EDITOR_LOG_ADD, - RULE_EDITOR_LOG_REMOVE, - RULE_EDITOR_LOG_RANK, -}; - -struct _RuleEditorUndo { - struct _RuleEditorUndo *next; - - unsigned int type; - struct _FilterRule *rule; - int rank; - int newrank; -}; - -struct _GladeXML; -struct _RuleContext; - -guint rule_editor_get_type (void); -RuleEditor *rule_editor_new (struct _RuleContext *, const char *source); -void rule_editor_construct (RuleEditor *re, struct _RuleContext *context, struct _GladeXML *gui, const char *source); - -/* methods */ -void rule_editor_set_source(RuleEditor *re, const char *source); -/* calculates the sensitivity of the editor */ -void rule_editor_set_sensitive(RuleEditor *re); -/* used internally to create a new rule appropriate for the editor */ -struct _FilterRule *rule_editor_create_rule(RuleEditor *re); - -#endif /* ! _RULE_EDITOR_H */ - diff --git a/filter/score-context.c b/filter/score-context.c deleted file mode 100644 index 4c892bc8d3..0000000000 --- a/filter/score-context.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (C) 2000 Ximian Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#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 3d636797f3..0000000000 --- a/filter/score-context.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2000 Ximian Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef _SCORE_CONTEXT_H -#define _SCORE_CONTEXT_H - -#include "rule-context.h" - -#define SCORE_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 ab24afd499..0000000000 --- a/filter/score-editor.c +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (C) 2001 Ximian Inc. - * - * Authors: Not Zed - * Jeffrey Stedfast - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include - -#include -#include -#include -#include -#include -#include - -#include "score-editor.h" -#include "score-context.h" -#include "score-rule.h" - -#define d(x) - -static FilterRule * create_rule(RuleEditor *re); - -static void score_editor_class_init (ScoreEditorClass *class); -static void score_editor_init (ScoreEditor *gspaper); -static void score_editor_finalise (GtkObject *obj); - -#define _PRIVATE(x) (((ScoreEditor *)(x))->priv) - -struct _ScoreEditorPrivate { -}; - -static RuleEditorClass *parent_class; - -enum { - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -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 (rule_editor_get_type (), &type_info); - } - - return type; -} - -static void -score_editor_class_init (ScoreEditorClass *class) -{ - GtkObjectClass *object_class = (GtkObjectClass *)class; - RuleEditorClass *re_class = (RuleEditorClass *)class; - - parent_class = gtk_type_class (rule_editor_get_type ()); - - object_class->finalize = score_editor_finalise; - - /* override methods */ - re_class->create_rule = create_rule; - - /* signals */ - - gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); -} - -static void -score_editor_init (ScoreEditor *o) -{ - o->priv = g_malloc0 (sizeof (*o->priv)); -} - -static void -score_editor_finalise(GtkObject *obj) -{ - ScoreEditor *o = (ScoreEditor *)obj; - - g_free(o->priv); - - ((GtkObjectClass *)(parent_class))->finalize(obj); -} - -/** - * score_editor_new: - * - * Create a new ScoreEditor object. - * - * Return value: A new #ScoreEditor object. - **/ -ScoreEditor * -score_editor_new(ScoreContext *f) -{ - GladeXML *gui; - ScoreEditor *o = (ScoreEditor *)gtk_type_new (score_editor_get_type ()); - GtkWidget *w; - - gui = glade_xml_new(FILTER_GLADEDIR "/filter.glade", "rule_editor"); - rule_editor_construct((RuleEditor *)o, (RuleContext *)f, gui, NULL); - - w = glade_xml_get_widget(gui, "rule_frame"); - gtk_frame_set_label((GtkFrame *)w, _("Score Rules")); - - gtk_object_unref((GtkObject *)gui); - - return o; -} - -static FilterRule * -create_rule(RuleEditor *re) -{ - FilterRule *rule = filter_rule_new(); - FilterPart *part; - - /* create a rule with 1 part in it */ - rule = (FilterRule *)score_rule_new (); - part = rule_context_next_part(re->context, NULL); - filter_rule_add_part(rule, filter_part_clone(part)); - - return rule; -} diff --git a/filter/score-editor.h b/filter/score-editor.h deleted file mode 100644 index 5c25dd9ecc..0000000000 --- a/filter/score-editor.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2000 Ximian Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef _SCORE_EDITOR_H -#define _SCORE_EDITOR_H - -#include "rule-editor.h" - -#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 { - RuleEditor parent; - - struct _ScoreEditorPrivate *priv; -}; - -struct _ScoreEditorClass { - RuleEditorClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - -struct _ScoreContext; - -guint score_editor_get_type (void); -ScoreEditor *score_editor_new (struct _ScoreContext *f); - -#endif /* ! _SCORE_EDITOR_H */ - diff --git a/filter/score-rule.c b/filter/score-rule.c deleted file mode 100644 index 2975a3854d..0000000000 --- a/filter/score-rule.c +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright (C) 2000 Ximian Inc. - * - * Authors: Not Zed - * Jeffrey Stedfast - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#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); - xmlFree (str); - - /* score range is -3 to +3 */ - if (sr->score > 3) - sr->score = 3; - else if (sr->score < -3) - sr->score = -3; - } - value = value->next; - } - - return 0; -} - -/*static void build_code(FilterRule *fr, GString *out) -{ -}*/ - -static void -spin_changed (GtkAdjustment *adj, ScoreRule *sr) -{ - sr->score = adj->value; -} - -static GtkWidget * -get_widget (FilterRule *fr, struct _RuleContext *f) -{ - GtkWidget *widget; - GtkWidget *frame; - GtkWidget *label; - GtkWidget *hbox; - GtkAdjustment *adj; - ScoreRule *sr = (ScoreRule *)fr; - GtkWidget *spin; - - widget = ((FilterRuleClass *)(parent_class))->get_widget (fr, f); - - frame = gtk_frame_new (_("Score")); - hbox = gtk_hbox_new (FALSE, 3); - label = gtk_label_new (_("Score")); - - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 3); - adj = (GtkAdjustment *)gtk_adjustment_new ((float) sr->score, -3.0, 3.0, 1.0, 1.0, 1.0); - gtk_signal_connect (GTK_OBJECT (adj), "value_changed", spin_changed, sr); - - spin = gtk_spin_button_new (adj, 1.0, 0); - gtk_box_pack_start (GTK_BOX (hbox), spin, FALSE, FALSE, 3); - gtk_container_add (GTK_CONTAINER (frame), hbox); - - gtk_widget_show_all (frame); - - gtk_box_pack_start (GTK_BOX (widget), frame, FALSE, FALSE, 3); - - return widget; -} diff --git a/filter/score-rule.h b/filter/score-rule.h deleted file mode 100644 index bc7be4d043..0000000000 --- a/filter/score-rule.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2000 Ximian Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef _SCORE_RULE_H -#define _SCORE_RULE_H - -#include "filter-rule.h" - -#define SCORE_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 2cb7c6fcae..0000000000 --- a/filter/vfolder-context.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (C) 2000 Ximian Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#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 bf28ac88f7..0000000000 --- a/filter/vfolder-context.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2000 Ximian Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef _VFOLDER_CONTEXT_H -#define _VFOLDER_CONTEXT_H - -#include "rule-context.h" - -#define VFOLDER_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 b331c7ac14..0000000000 --- a/filter/vfolder-editor.c +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (C) 2001 Ximian Inc. - * - * Authors: Not Zed - * Jeffrey Stedfast - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include - -#include -#include -#include -#include -#include -#include - -#include "vfolder-editor.h" -#include "vfolder-context.h" -#include "vfolder-rule.h" - -#define d(x) - -static FilterRule * create_rule(RuleEditor *re); - -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 RuleEditorClass *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 (rule_editor_get_type (), &type_info); - } - - return type; -} - -static void -vfolder_editor_class_init (VfolderEditorClass *class) -{ - GtkObjectClass *object_class = (GtkObjectClass *)class; - RuleEditorClass *re_class = (RuleEditorClass *)class; - - parent_class = gtk_type_class (rule_editor_get_type ()); - - object_class->finalize = vfolder_editor_finalise; - - /* override methods */ - re_class->create_rule = create_rule; - - /* 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; - - g_free(o->priv); - - ((GtkObjectClass *)(parent_class))->finalize(obj); -} - -/** - * vfolder_editor_new: - * - * Create a new VfolderEditor object. - * - * Return value: A new #VfolderEditor object. - **/ -VfolderEditor * -vfolder_editor_new(VfolderContext *f) -{ - GladeXML *gui; - VfolderEditor *o = (VfolderEditor *)gtk_type_new (vfolder_editor_get_type ()); - GtkWidget *w; - - gui = glade_xml_new(FILTER_GLADEDIR "/filter.glade", "rule_editor"); - rule_editor_construct((RuleEditor *)o, (RuleContext *)f, gui, NULL); - - w = glade_xml_get_widget(gui, "rule_frame"); - gtk_frame_set_label((GtkFrame *)w, _("Virtual Folders")); - - gtk_object_unref((GtkObject *)gui); - - return o; -} - -static FilterRule * -create_rule(RuleEditor *re) -{ - FilterRule *rule = filter_rule_new(); - FilterPart *part; - - /* create a rule with 1 part in it */ - rule = (FilterRule *)vfolder_rule_new (); - part = rule_context_next_part(re->context, NULL); - filter_rule_add_part(rule, filter_part_clone(part)); - - return rule; -} diff --git a/filter/vfolder-editor.h b/filter/vfolder-editor.h deleted file mode 100644 index d749a3589d..0000000000 --- a/filter/vfolder-editor.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2000, 2001 Ximian Inc. - * - * Authors: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef _VFOLDER_EDITOR_H -#define _VFOLDER_EDITOR_H - -#include "rule-editor.h" - -#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 { - RuleEditor parent; - - struct _VfolderEditorPrivate *priv; - -}; - -struct _VfolderEditorClass { - RuleEditorClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - -struct _VfolderContext; - -guint vfolder_editor_get_type (void); -VfolderEditor *vfolder_editor_new (struct _VfolderContext *); - -#endif /* ! _VFOLDER_EDITOR_H */ - diff --git a/filter/vfolder-rule.c b/filter/vfolder-rule.c deleted file mode 100644 index 818b303366..0000000000 --- a/filter/vfolder-rule.c +++ /dev/null @@ -1,503 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000 Ximian Inc. - * - * Author: Not Zed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "vfolder-context.h" -#include "vfolder-rule.h" -#include "shell/evolution-shell-client.h" - -#define d(x) x - -static gint validate(FilterRule *); -static xmlNodePtr xml_encode(FilterRule *); -static int xml_decode(FilterRule *, xmlNodePtr, struct _RuleContext *f); -static void rule_copy (FilterRule *dest, FilterRule *src); -/*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->validate = validate; - filter_rule->xml_encode = xml_encode; - filter_rule->xml_decode = xml_decode; - filter_rule->copy = rule_copy; - /*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; - - g_list_foreach (o->sources, (GFunc) g_free, NULL); - g_list_free (o->sources); - - ((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)); - - filter_rule_emit_changed((FilterRule *)vr); -} - -const char * -vfolder_rule_find_source (VfolderRule *vr, const char *uri) -{ - GList *l; - - g_assert(IS_VFOLDER_RULE(vr)); - - /* only does a simple string or address comparison, should - probably do a decoded url comparison */ - l = vr->sources; - while (l) { - if (l->data == uri || !strcmp(l->data, uri)) - return l->data; - l = 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); - filter_rule_emit_changed((FilterRule *)vr); - } -} - -const char * -vfolder_rule_next_source (VfolderRule *vr, const char *last) -{ - GList *node; - - if (last == NULL) { - node = vr->sources; - } else { - node = g_list_find(vr->sources, (char *)last); - if (node == NULL) - node = vr->sources; - else - node = g_list_next(node); - } - if (node) - return (const char *)node->data; - return NULL; -} - -static gint -validate (FilterRule *fr) -{ - GtkWidget *dialog; - - g_return_val_if_fail (fr != NULL, FALSE); - - if (!fr->name || !*fr->name) { - dialog = gnome_ok_dialog (_("You must name this vfolder.")); - gnome_dialog_run_and_close (GNOME_DIALOG (dialog)); - - return 0; - } - - /* We have to have at least one source set in the "specific" case. - Do not translate this string! */ - if (fr->source && !strcmp (fr->source, "specific") && VFOLDER_RULE (fr)->sources == NULL) { - dialog = gnome_ok_dialog (_("You need to to specify at least one folder as a source.")); - gnome_dialog_run_and_close (GNOME_DIALOG (dialog)); - - return 0; - } - - if (FILTER_RULE_CLASS (parent_class)->validate) - return FILTER_RULE_CLASS (parent_class)->validate (fr); - - return 1; -} - -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, g_strdup(uri)); - xmlFree(uri); - } - } - work = work->next; - } - } - set = set->next; - } - return 0; -} - -static void -rule_copy (FilterRule *dest, FilterRule *src) -{ - VfolderRule *vdest, *vsrc; - GList *node; - - vdest = (VfolderRule *) dest; - vsrc = (VfolderRule *) src; - - if (vdest->sources) { - g_list_foreach (vdest->sources, (GFunc) g_free, NULL); - g_list_free (vdest->sources); - vdest->sources = NULL; - } - - node = vsrc->sources; - while (node) { - char *uri = node->data; - - vdest->sources = g_list_append (vdest->sources, g_strdup (uri)); - node = node->next; - } - - ((FilterRuleClass *)(parent_class))->copy (dest, src); -} - - -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 -select_source_with(GtkWidget *w, struct _source_data *data) -{ - char *source = gtk_object_get_data((GtkObject *)w, "source"); - - filter_rule_set_source((FilterRule *)data->vr, source); -} - -static void -source_add(GtkWidget *widget, struct _source_data *data) -{ - const char *allowed_types[] = { "mail", NULL }; - char *def, *uri; - GtkListItem *item; - GList *l; - gchar *s; - - gtk_widget_set_sensitive(widget, FALSE); - def = ""; - evolution_shell_client_user_select_folder (global_shell_client, - GTK_WINDOW (gtk_widget_get_toplevel (widget)), - _("Select Folder"), - def, allowed_types, NULL, &uri); - - if (GTK_OBJECT_DESTROYED(widget)) { - g_free(uri); - return; - } - - gtk_widget_set_sensitive(widget, TRUE); - - if (uri != NULL && uri[0] != '\0') { - data->vr->sources = g_list_append(data->vr->sources, uri); - - l = NULL; - s = e_utf8_to_gtk_string ((GtkWidget *) data->list, uri); - item = (GtkListItem *)gtk_list_item_new_with_label (s); - g_free (s); - 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); -} - -/* DO NOT internationalise these strings */ -const char *source_names[] = { - "specific", - "local", - "remote_active", - "local_remote_active" -}; - -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, row; - 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 (GTK_OBJECT (frame), "data", data, g_free); - - for (i = 0; i < BUTTON_LAST; i++) { - data->buttons[i] = (GtkButton *)w = glade_xml_get_widget (gui, edit_buttons[i].name); - gtk_signal_connect (GTK_OBJECT (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; - - gchar *s = e_utf8_to_gtk_string (GTK_WIDGET (data->list), source); - item = (GtkListItem *)gtk_list_item_new_with_label (s); - g_free (s); - gtk_object_set_data (GTK_OBJECT (item), "source", (void *)source); - gtk_widget_show (GTK_WIDGET (item)); - l = g_list_append (l, item); - } - gtk_list_append_items (data->list, l); - gtk_signal_connect (GTK_OBJECT (w), "select_child", select_source, data); - - w = glade_xml_get_widget (gui, "source_option"); - l = GTK_MENU_SHELL (GTK_OPTION_MENU (w)->menu)->children; - i = 0; - row = 0; - while (l) { - GtkWidget *b = GTK_WIDGET (l->data); - - /* make sure that the glade is in sync with the source list! */ - if (i < sizeof (source_names) / sizeof (source_names[0])) { - gtk_object_set_data (GTK_OBJECT (b), "source", (char *)source_names[i]); - if (fr->source && strcmp (source_names[i], fr->source) == 0) { - row = i; - } - } else { - g_warning ("Glade file " FILTER_GLADEDIR "/filter.glade out of sync with editor code"); - } - gtk_signal_connect (GTK_OBJECT (b), "activate", select_source_with, data); - - i++; - l = l->next; - } - - gtk_option_menu_set_history (GTK_OPTION_MENU (w), row); - if (fr->source == NULL) - filter_rule_set_source (fr, (char *)source_names[row]); - - set_sensitive (data); - - gtk_box_pack_start (GTK_BOX (widget), frame, TRUE, TRUE, 3); - - gtk_object_unref (GTK_OBJECT (gui)); - - return widget; -} diff --git a/filter/vfolder-rule.h b/filter/vfolder-rule.h deleted file mode 100644 index 25073a7a2d..0000000000 --- a/filter/vfolder-rule.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Copyright (C) 2000 Ximian Inc. - * - * Author: NotZed - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef _VFOLDER_RULE_H -#define _VFOLDER_RULE_H - -#include "filter-rule.h" - -#define VFOLDER_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 dfcd85bb94..0000000000 --- a/filter/vfoldertypes.xml +++ /dev/null @@ -1,363 +0,0 @@ - - - - - Sender - - - - - - - - - - - - - - - Recipients - - - - - - - - - - - - - - - Subject - - - - - - - - - - - - - - Message Body - - - - - - - - Expression - - - - - Message was sent - - - - - - - - - - - - Message was received - - - - - - - - - - - - Status - - - - - - - - - - - - - - - - Attachments - - - - - - - - Mailing list - - - - - - - - - - - - - - - -- cgit v1.2.3