From 6205e8cad4ef2c93093b06e579ad26bd6b6505bd Mon Sep 17 00:00:00 2001 From: nobody Date: Sat, 28 Jun 2003 16:20:00 +0000 Subject: This commit was manufactured by cvs2svn to create tag 'GDM2_2_4_4_0'. svn path=/tags/GDM2_2_4_4_0/; revision=21592 --- filter/.cvsignore | 10 - filter/ChangeLog | 23 - filter/ChangeLog.pre-1-4 | 2967 -------------------------------------------- filter/Makefile.am | 101 -- filter/filter-code.c | 125 -- filter/filter-code.h | 56 - filter/filter-colour.c | 229 ---- filter/filter-colour.h | 58 - filter/filter-context.c | 279 ----- filter/filter-context.h | 62 - filter/filter-datespec.c | 480 ------- filter/filter-datespec.h | 74 -- filter/filter-editor.c | 169 --- filter/filter-editor.h | 58 - filter/filter-element.c | 385 ------ filter/filter-element.h | 93 -- filter/filter-file.c | 323 ----- filter/filter-file.h | 73 -- filter/filter-filter.c | 538 -------- filter/filter-filter.h | 63 - filter/filter-folder.c | 265 ---- filter/filter-folder.h | 59 - filter/filter-input.c | 353 ------ filter/filter-input.h | 62 - filter/filter-int.c | 254 ---- filter/filter-int.h | 63 - filter/filter-label.c | 182 --- filter/filter-label.h | 70 -- filter/filter-marshal.list | 2 - filter/filter-option.c | 367 ------ filter/filter-option.h | 69 -- filter/filter-part.c | 544 -------- filter/filter-part.h | 85 -- filter/filter-rule.c | 897 -------------- filter/filter-rule.h | 121 -- filter/filter-source.c | 377 ------ filter/filter-source.h | 56 - filter/filter.glade | 1344 -------------------- filter/filtertypes.xml | 719 ----------- filter/libfilter-i18n.h | 61 - filter/rule-context.c | 869 ------------- filter/rule-context.h | 136 -- filter/rule-editor.c | 750 ----------- filter/rule-editor.h | 103 -- filter/score-context.c | 101 -- filter/score-context.h | 58 - filter/score-editor.c | 133 -- filter/score-editor.h | 58 - filter/score-rule.c | 201 --- filter/score-rule.h | 60 - filter/vfolder-context.c | 100 -- filter/vfolder-context.h | 59 - filter/vfolder-editor.c | 133 -- filter/vfolder-editor.h | 58 - filter/vfolder-rule.c | 635 ---------- filter/vfolder-rule.h | 62 - filter/vfoldertypes.xml | 421 ------- 57 files changed, 16053 deletions(-) delete mode 100644 filter/.cvsignore delete mode 100644 filter/ChangeLog delete mode 100644 filter/ChangeLog.pre-1-4 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-file.c delete mode 100644 filter/filter-file.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-label.c delete mode 100644 filter/filter-label.h delete mode 100644 filter/filter-marshal.list 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-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 40ccce097c..0000000000 --- a/filter/.cvsignore +++ /dev/null @@ -1,10 +0,0 @@ -*.la -*.lo -.libs -.deps -.pure -Makefile -Makefile.in -libfilter-i18n.h -filter-marshal.c -filter-marshal.h diff --git a/filter/ChangeLog b/filter/ChangeLog deleted file mode 100644 index 277bea383e..0000000000 --- a/filter/ChangeLog +++ /dev/null @@ -1,23 +0,0 @@ -2003-06-13 Larry Ewing - - * filter-source.c (filter_source_finalize): free current_url. - -2003-06-11 Mike Kestner - - * rule-context.c (load): stat the user file before parsing. - -2003-06-06 Jeffrey Stedfast - - Fixes some leaks from bug #43883. - - * filter-file.c (xml_decode): Free file->path and set it to - NULL before entering the loop to decode it. This way if the value - is already set we don't leak it. Set file->path = g_strdup (str ? - str : ""); and then xmlFree the str. - -2003-05-21 Jeffrey Stedfast - - * filter-source.c (filter_source_get_sources): Same as below. - - * filter-label.c (xml_create): Unref the gconf client when we're - finished with it. diff --git a/filter/ChangeLog.pre-1-4 b/filter/ChangeLog.pre-1-4 deleted file mode 100644 index ece5ee7998..0000000000 --- a/filter/ChangeLog.pre-1-4 +++ /dev/null @@ -1,2967 +0,0 @@ -2003-05-05 Jeffrey Stedfast - - * filter-colour.c (format_sexp): Format the colour string in a way - that gdk_color_parse() will handle. Apparently it no longer - handles rgb://? Fixes bug #42345. - -2003-04-24 Jeffrey Stedfast - - Fix for bug #41578. - - * rule-editor.c (rule_move): Pass re->source instead of - re->current->source to rule_context_get_rank_rule(). Also updated - to pass re->source to rule_context_rank_rule(). - (rule_editor_play_undo): Updated to pass re->source to - rule_context_rank_rule(). - - * rule-context.c (rule_context_rank_rule): Now takes a 'source' - argument rather than using rule->source (vfolder editor lists - rules of all sources, not just same-source rules). - (revert): Pass frule->source/part->source to - rule_context_rank_rule() - might not be right but should preserve - the prior behaviour at least. - -2003-04-18 Not Zed - - * rule-editor.c (d): removed debug spew. - - * addresses #41398 - - * vfolder-rule.c (format_source): helper function to decode a url - into a more user-friendly format. - (source_add, get_widget): add the formatted data as another - column to the table. - (vfolder_editor_sourcelist_new): add another column to the table, - a formatted uri as well as the raw one. - (d): turned off debug vomit while i'm here. - -2003-04-11 Jeffrey Stedfast - - Fixes for bugs: #41149, #41150, #41151, #41152, #41153, #41155, - #41156, #41205, and #41208. - - * filter-filter.c (get_widget): Same as with filter-rule. - - * filter-rule.c (get_widget): Changed border widths of frame - vboxes and other padding to comply with the HIG. - - * rule-editor.c (rule_add): Change window border and padding - around the 'rules' widget to comply with the HIG. - (rule_edit): Same. - (rule_editor_construct): Same here as well. - - * filter.glade: Many HIG compliance fixes. - -2003-03-28 Not Zed - - * filter-datespec.c (button_clicked): cast warning. - -2003-03-26 Jeffrey Stedfast - - * filter-file.c (xml_decode): Loop over child nodes here too in - order to not be affected by libxml2 crack. - - * filter-source.c (xml_decode): Fixed to disreguard libxml2 crack. - (get_widget): Use strcmp instead of e_url_equal(). - -2003-03-20 Dan Winship - - * filter-datespec.c (timespans, set_button): Change the strings in - the timespans array from "second" / "seconds" to "1 second ago" / - "%d seconds ago", etc, and update the code in set_button that uses - them. Fixes #36245, translation clash between the "second" here - and the one in the calendar (where it's used as "2nd"). - (button_clicked): Fix this so we don't get stuck inside - gtk_dialog_run's main loop forever. - -2003-03-20 Jeffrey Stedfast - - * rule-editor.c (rule_editor_set_sensitive): Don't return here - - this is a void function. - (rule_editor_set_source): Same. - -2003-03-18 Not Zed - - * rule-context.c (new_rule_response): use the same code as in - filter-rule to enforce unique names for all rules/vfolders. - -2003-03-17 Jeffrey Stedfast - - * rule-editor.c (rule_editor_construct): Set the default window - size to something reasonable (350x400?). Fixes bug #39808. - - * vfolder-rule.c (source_remove): Fixed to work properly. Fixes - bug #39654. - - * rule-editor.c (rule_editor_construct): Always add a Cancel - button here, but if !enable_undo - make the response id - GTK_RESPONSE_CANCEL rather than GTK_RESPONSE_REJECT (which does - undo). This mimics the behaviour that was done in the mail/ code - previously. Fixes bug #39809. - -2003-03-11 Not Zed - - * rule-context.c (revert): go to the proper level of child node - before looking for rule sets, fix for #39165 to make 'cancel' work. - -2003-03-06 Jeffrey Stedfast - - Fixes for bug #39170 - - * filter-element.c (filter_element_xml_create): Remove return - keyword. - (filter_element_build_code): Same. - (filter_element_format_sexp): Here too. - -2003-02-20 Not Zed - - * filter-source.c (filter_source_get_sources): Change to use - EAccountList, etc. - -2003-02-12 Jeffrey Stedfast - - * vfolder-rule.c (source_add): Get rid of the need for the - GTK_WIDGET_DESTROYED() check. - -2003-02-07 Jeffrey Stedfast - - * filter-editor.c (filter_editor_new): Use g_object_new() - instead of gtk_type_new(). - - * vfolder-editor.c (vfolder_editor_new): Use g_object_new() - instead of gtk_type_new(). - - * score-editor.c (score_editor_new): Use g_object_new() instead of - gtk_type_new(). - - * rule-editor.c (rule_editor_new): Use g_object_new() instead of - gtk_type_new(). - (rule_add): Use gtk_window_set_resizable() instead of the - deprecated gtk_window_set_policy(). - (rule_edit): Same here. - (rule_editor_construct): Here too. - - * rule-context.c (rule_context_add_rule_gui): Use - gtk_window_set_resizable() instead of the deprecated - gtk_window_set_policy(). - -2003-02-05 Dan Winship - - * Makefile.am (gladedir): Defined in configure.in now - (filterdir): Define using privdatadir - -2003-01-22 Ettore Perazzoli - - * Makefile.am (gladedir): Version using $(BASE_VERSION). - (filterdir): Likewise. - -2003-01-15 Not Zed - - * vfolder-rule.c (get_widget): dont re-use 'widget', its the - return value! - -2003-01-15 Jeffrey Stedfast - - * rule-context.c (save): Back to using e_xml_save_file(). - -2003-01-14 Ettore Perazzoli - - * rule-editor.c (rule_add): Change dialog from OK/Cancel to - Cancel/OK to match HIG. - (rule_edit): Likewise. - (rule_editor_construct): Likewise. - - * rule-context.c (rule_context_add_rule_gui): Change dialog from - OK/Cancel to Cancel/OK to match HIG. - - * filter-datespec.c (button_clicked): Change dialog from OK/Cancel - to Cancel/OK to match HIG. - -2003-01-03 Jeffrey Stedfast - - * rule-editor.c (add_editor_response): Scroll to the newly added - row. Fixes bug #3725. - (rule_delete): Scroll to the selected row. - (rule_move): After moving the row, re-select it and then scroll to - make sure that it is still visible. Fixes bug #7800. - -2003-01-02 Jeffrey Stedfast - - Fixed to build with -DG_DISABLE_DEPRECATED and - -DGTK_DISABLE_DEPRECATED - -2002-12-12 Jeffrey Stedfast - - * rule-editor.c (cursor_changed): Use an easier method for getting - the iter. - -2002-12-12 Jeffrey Stedfast - - * vfolder-rule.c (vfolder_editor_sourcelist_new): New custom - function for creating the source_list widget. - (get_widget): Removed the source_list creation code. - - * rule-editor.c (rule_editor_construct): Listen to row-activated - for double-click events. Also, removed the model creation code out - of here. - (rule_editor_treeview_new): Moved the treeview and model creation - code into here instead, and made the glade widgets into custom - widgets. - -2002-11-26 Not Zed - - * vfolder-rule.c (get_widget): Add a textcellrenderer to display - the folders. - (get_widget): Remove FIXME which was wrong. - - * filter-rule.c (filter_rule_validate): FILTER_RULE_CLASS -> - _GET_CLASS - - * rule-context.c (rule_context_save): RULE_CONTEXT_CLASS -> - RULE_CONTEXT_GET_CLASS - (rule_context_revert): " - - * *.[ch]: Ran fix.sh over all files. - - * rule-editor.c (rule_add): widget:set_parent -> - window:set_transient_for - (editor_response): renamed from editor_clicked, handle gtk dialog - response codes. - (rule_edit): connect to response rather than clicked. - (rule_editor_construct): Setup a text column in the tree view. - Not sure if this can be handled via glade. - -2002-11-20 Jeffrey Stedfast - - * filter-label.c (xml_create): gconfify. - -2002-11-18 Jeffrey Stedfast - - * rule-editor.c: Updated to use GtkTreeView. - - * vfolder-rule.c: Same. - -2002-11-13 Not Zed - - * rule-context.c (load): Get the root node properly. - - * rule-editor.c (rule_add): cast g_object_weak_ref - (rule_edit): " - - * all: xml2 node change - childs->children. Also, ignore 'text' - nodes while scanning tree. - - * rule-context.h: gnome-xml->libxml. - - * filter-element.h: gnome-xml->libxml - - * vfolder-rule.c (source_add): comment out gtk_destroyed check. - - * filter-label.c: Added back some of the guts. Might not work but - some of the code uses it :-/. Gives u a fixed set of non-editable - labels. - -2002-11-08 Jeffrey Stedfast - - * rule-editor.c (rule_edit): Use weak_ref instead of connecting to - "destroy". - (rule_add): Same. - -2002-11-07 Jeffrey Stedfast - - * vfolder-rule.c (validate): Use a GtkDialog instead of a - GnomeDialog for reporting errors. - - * rule-editor.c (rule_add): Use a GtkDialog instead of - GnomeDialog. - (rule_edit): Same. - (add_editor_response): Use a GtkMessageDialog for the error - reporting instead of a GnomeDialog. - (edit_editor_response): Same. - - * rule-context.c (rule_context_add_rule_gui): Use a GtkDialog - instead of a GnomeDialog. - - * filter-rule.c (validate): Use GtkDialog instead of GnomeDialog - here. - - * filter-input.c (validate): Use GtkDialog instead of GnomeDialog - here. - - * filter-folder.c (validate): Use GtkDialog instead of GnomeDialog - here. - - * filter-file.c (validate): Use GtkDialog instead of GnomeDialog - here. - - * rule-editor.c: Subclass GtkDialog instead of GnomeDialog. - - * filter-datespec.c (validate): Use GtkDialog instead of - GnomeDialog. - (button_clicked): Same. - -2002-11-06 Jeffrey Stedfast - - * filter-label.c (xml_create): Deleted most of the internals until - we devise a gconf schema and redesign how we want to do this. It - didn't work correctly for 1.2 anyway. - - * filter.glade: Converted to the glade-2 format. - -2002-11-05 Jeffrey Stedfast - - * filter-filter.c: Ported. - - * filter-source.c (get_widget): Don't use e_utf8_to_gtk_string. - - * filter-option.c (xml_create): Don't use e_utf8_xml1_decode. - - * filter-input.c (xml_encode): Don't use e_utf8_xml1_encode. - (xml_decode): Don't use e_utf8_xml1_decode. - (entry_changed): Don't use e_utf8_gtk_entry_get_text. - (get_widget): Don't use e_utf8_gtk_entry_set_text. - - * filter-file.c (xml_encode): Don't use e_utf8_xml1_encode shit. - (xml_decode): Don't use e_utf8_xml1_decode. - (entry_changed): Don't use e_utf8_gtk_entry_get_text. - (get_widget): Don't use e_utf8_gtk_entry_set_text. - -2002-11-05 Jeffrey Stedfast - - * vfolder-rule.c: Ported. - - * vfolder-editor.c: Ported. - - * vfolder-context.c: Ported. - -2002-11-05 Jeffrey Stedfast - - * filter-rule.c: Ported. - - * score-rule.c: Ported. - - * score-editor.c: Ported. Again, thise code seems to be unused. - - * score-context.c: Ported. Although it seems this code isn't - really used anywhere? - -2002-11-04 Jeffrey Stedfast - - * filter-part.c: Ported. - - * filter-editor.c: Also ported. - - * rule-editor.c: Ported to gtk2 and removed unnecessary e_utf8 snot. - -2002-11-02 Jeffrey Stedfast - - * filter-context.c: Ported this too. - - * rule-context.c: Ported to glib2/GObject. - -2002-11-01 Jeffrey Stedfast - - * filter-element.c: Ported to GObject. - - * filter-input.c: Same. - - * filter-code.c: This too. - - * filter-colour.c: And this. - - * filter-datespec.c: You guessed it. - - * filter-file.c: And again... - - * filter-folder.c: Wheee! This is fun... - - * filter-int.c: Gee, I wonder... - - * filter-label.c: Also ported. - - * filter-option.c: Yep, this too. - - * filter-source.c: And finally this one. - -2002-10-30 Dan Winship - - * rule-editor.c (rule_add): Adjust default rule editor size to - accomodate the menu widening caused by "Pipe Message to Shell - Command". - -2002-10-10 Jeffrey Stedfast - - * filtertypes.xml: Removed the Run Once filter action. - -2002-09-30 Aaron Weber - - * filter-folder.c (validate): adjust string on 149 to "You must - specify a folder. - - * filter-datespec.c (get_best_span): adjust string on 174 from - "You have forgotten to choose a date" to "You must choose a date." - -2002-09-25 Dan Winship - - * filter-folder.c (get_widget): Use "mail/*" as the allowed folder - type. - - * vfolder-rule.c (source_add): Likewise - -2002-09-22 Dan Winship - - * filter-context.c (filter_delete_uri): add empty statement after - label to make it ANSI. - -2002-09-19 Not Zed - - * filtertypes.xml: Changed source account, use header-source - rather than (= (get-source) ...) - -2002-09-13 Jeffrey Stedfast - - * filtertypes.xml: Add a Run Once action to run a command only - once rather than for each message that has that action applied. - -2002-08-08 Not Zed - - * rule-editor.c (add_editor_clicked): Dont allow duplicate names. - (edit_editor_clicked): Same here. For #24803. - -2002-08-06 Jeffrey Stedfast - - * rule-context.c (save): Don't need to save temp/backup files - anymore, e_xml_save_file() now handles this for us (well, at least - the saving of temp files). I'm not sure we need a backup file - anymore now that we can depend on e_xml_save_file() to "Just Work" - -2002-08-06 Jeffrey Stedfast - - * rule-context.c (save): Use e_xml_save_file(). - (xml_doc_save): Removed this code and added it to gal so that - e-table and all other parts of evolution and so forth could use - it. - -2002-08-05 Jeffrey Stedfast - - * rule-context.c (xml_doc_save): New internal function to replace - xmlSaveFile. Does proper error checking and so forth to ensure - that the resulting file does not ever get truncated. - (save): Cal xml_doc_save rather than xmlSaveFile. Fixes bug - #25980. - -2002-08-02 Not Zed - - * filter.glade: Added a datespec editor window. - - * filter-datespec.c (button_clicked): Rewritten to use glade. - Simplified all the code around it as a result, etc, and fixed bug - #21798. - -2002-08-01 Peter Williams - - * filter-datespec.c (activate_specified): If the value was unset, - initialize it to now. - -2002-07-31 Ettore Perazzoli - - * filter-option.c (xml_create): Remove unused variable. - -2002-07-30 Peter Williams - - * filter-rule.c (get_widget): Translate the rule name when filling - in the name entry. - -2002-07-29 Jeffrey Stedfast - - * filtertypes.xml: Add xml to unset system flags. - -2002-07-26 Jeffrey Stedfast - - * filter-int.c (xml_decode): Use fs->type in xmlGetProp since we - already free'd 'type'. Fixes bug #28113. - - * filter-element.c: Removed the empty private struct. - - * filter-int.c: Removed the empty private struct. - -2002-07-25 Jeffrey Stedfast - - * filter-int.[c,h]: Use GtkType (I only changed this one because I - turned on debugging for a bit). - - * filter-file.c (validate): Fix the strcmp logic a bit, I had it - the exact opposite of what I really wanted. Oops :-) - -2002-07-25 Jeffrey Stedfast - - * filter-file.c (validate): Do some minimalistic validation of - command-lines (ie, make sure it isn't an empty string). - - * filtertypes.xml: s/shell-exec/shell/ (for the action) and pass - "/bin/sh" "-c" as the first 2 arguments. For the shell-exec - *rule*, change the name to "pipe-message" and add the "/bin/sh" - "-c" arguments too. - -2002-07-17 Jeffrey Stedfast - - * filter-label.c (xml_create): Use the U_() macro to get the UTF-8 - translation. - -2002-07-15 Not Zed - - * filter-score.[ch]: cvs remove. - - * filter-element.c: Remove reference to filter-score.h - - * vfoldertypes.xml: Fix label vfolder rule as below, also add - score and size rules from filtertypes.xml. - - * filtertypes.xml (score): Use (cast-int (user-tag "score")) to - get the value directly, rather than (get-score). - (label): Use (user-tag "label") to get the value directly, rather - than (get-label). The label is now a string too. - - * filter-label.c (filter_label_get_type): Make filter-label - inherit from filter-option. Which makes more sense doesn't it - ... surely. - (validate): Removed, optionlists are self-validating. - (xml_create): Initialise the list of options from our - configuration database. If it isn't working, ignore it and set it - up anyway. - (filter_label_init): Override the xml type. - (filter_label_count): - (filter_label_label): - (filter_label_index): Some helper functions for external - interfaces. All of the mail config/etc should use this. - - * filter-option.c (free_option): - (xml_create): - (clone): Made the "value" type in glib memory rather than xml - memory space. - (filter_option_add): Utility function to add a new option to the - list. - (clone): Use above function to simplify code. - (xml_create): Same here. - (xml_encode): Allow subclasses to override the type. - -2002-07-10 Not Zed - - ** fixes for #10781 - - * filter-int.c (xml_encode): - (xml_decode): Handle encoding/decoding with a type name, in a - manner compatible with the score/label elemtns. - (filter_int_new_type): New constructor to create a generic 'int' - type. - - * filter-score.c: Removed. Now relies on using a filter-int with - appropriate settings. - - * filter-label.[ch]: Now inherits from filter-int. - - * rule-context.c (rule_context_revert): New method to revert a - filter context back to a user-file's definition. - (revert): implementation. - - * filter-rule.h: Added new virtual method _eq and wrapper, and - fixed all subclasses to implement it. - - * filter-element.h: Added new virtual method _eq and wrapper. - Fixed all subclasses to implement it. - -2002-07-08 Jeffrey Stedfast - - * filtertypes.xml: Make the sound type for (play-sound ) a "file" - type rather than "string" since users will want to use a filesel - to select it most likely. Fixes bug #26921. - - * filter-file.c (validate): If the type is "file" check that it is - a valid file, otheriwse if it is a command-line just ignore it for - now. - - * filter-element.c (filter_element_new_type_name): A filter type - of "file" should also use the filter-file object. - -2002-05-24 Ettore Perazzoli - - * filter-rule.c (get_widget): Fix English grammar. - -2002-05-16 Jeffrey Stedfast - - * vfoldertypes.xml: Added a label definition. - - * filtertypes.xml: Added a label definition. - - * filter-label.c: New filter widget for labels. - - * filter-element.c (filter_element_new_type_name): Add support for - the new label widget. - - * filter-int.c (format_sexp): Fixed a memory leak. - -2002-05-09 Jeffrey Stedfast - - * filter-file.c (get_widget): Set the path in the entry widget. - - * Makefile.am: Add filter-file.[c,h] to the build. - - * filtertypes.xml: Add a "Command" filter rule. - - * filter-element.c (filter_element_new_type_name): Add support for - type "command" which uses the new FilterFile widget. - - * filter-file.[c,h]: New filter widgets for choosing files and/or - command-line's (?). Not yet hooked up or anything, just for future - use. - -2002-05-08 Not Zed - - * rule-context.c (rule_context_delete_uri): Changed to return a - GList *, a list of the names of the rules affected by the delete, - fixed all implementors. - (rule_context_rename_uri): Similarly for delete_uri, for - api consistency. - (rule_context_free_uri_list): Util function to free the return - from above. - - * filter-context.c (filter_delete_uri): Actually implement it, fix - for #18826, and some related bugs. - -2002-04-26 Jeffrey Stedfast - - * Makefile.am: Get rid of ibex stuff, we no longer use it. - -2002-04-18 Jeffrey Stedfast - - * filtertypes.xml: The score "is" rule should have a value of "is" - and not "less-than". - -2002-04-12 Jeffrey Stedfast - - * filter-rule.c (get_widget): Fixed a grammer mistake, or so - according to bug #23376. Whatever. - -2002-04-11 Russell Steinthal - - * filtertypes.xml: Fix "Follow Up" searches by generating a - boolean, rather than a string result (Fixes #23334) - - * vfoldertypes.xml: Ditto - -2002-04-09 Jeffrey Stedfast - - * rule-editor.c (double_click): This needs to return a gboolean - (TRUE). - (rule_edit): Using gnome_dialog_set_parent instead of - gtk_widget_set_parent_window seems to fix bug #23226. - -2002-04-10 Not Zed - - * filter-input.c (validate): Check that there is a value to - setup. Fixes #15470. - - * filtertypes.xml: Added closing ) for "not starts with" subject - rule. - Added closing ) for all the other broken rules too ... - -2002-04-04 Dan Winship - - * filter-folder.c: Remove the #ifndef SHELL part. Use an - EvolutionFolderSelectorButton. Remove FilterFolder->name since - it's no longer needed. - - * filter-context.c (filter_rename_uri): Update for removal of - FilterFolder->name. - - * filter-element.c (filter_element_copy_value): Likewise. - - * vfolder-rule.c (source_add): Update for - evolution_shell_client_user_select_folder API change. - -2002-04-01 Jeffrey Stedfast - - * rule-editor.c (rule_edit): Set 're' as the parent window rather - than as the parent widget. - (add_editor_clicked): Only unref the editor if it is non-NULL. - -2002-03-18 Jeffrey Stedfast - - * filter-source.c (filter_source_get_sources): Free account_name - so we don't leak. Also after getting the source uri, use camel-url - to hide unwanted stuff. - (xml_decode): Use xmlFree on the buffer returned from - xmlNodeGetContent rather than g_free, as I think they are - incompatable. Also use camel-url here to hide any params in the - decoded url (to make things compatable with what older versions - may have saved). - -2002-03-06 Jeffrey Stedfast - - * filtertypes.xml: Added beep and play-sound actions. - -2002-02-26 Not Zed - - * filter-filter.c (option_activate): Copy values across to new - part. - - * filter-rule.c (option_activate): copy values across to new part, - if they are compatible. - - * filter-element.c (filter_element_copy_value): New function to - copy values (where they can be) from one filter element to another. - - * filter-part.c (filter_part_copy_values): New function to copy - values of a filter part. #1359. - -2002-02-12 Jeffrey Stedfast - - * vfoldertypes.xml: - * filtertypes.xml: Re-added contains and - not-contains. Also added filter/vfolder rules for - Flag-for-Followup. - -2002-02-04 Jeffrey Stedfast - - * vfoldertypes.xml: Same here. - - * filtertypes.xml: For mlist matching, we only want "is" and "is - not" because that is all we really support anyway. - -2002-01-27 Ettore Perazzoli - - * Makefile.am: Use LIBFILTER_CFLAGS. - -2002-01-26 Mikael Hallendal - - * rule-editor.c (add_editor_clicked): check if re->edit != NULL - before trying to unref it. Fixes a segfault when closing the - rule editor. - -2002-01-15 Not Zed - - * filter-input.c (xml_decode): If we write "" to an xml file, we - read back NULL. So if we read back NULL, convert it to "". - Sigh. This makes a fix for #7801, although new gui may also be - required. - -2002-01-03 Jeffrey Stedfast - - * filter-source.c (filter_source_get_sources): Get the account - name because that is the string we'd like to use for display. - (get_widget): Generate the account label the same as we do for the - composer's From optionmenu. - (filter_source_finalize): Free the account_name. - (clone): Pass along the account_name member to filter_add_source - -2002-01-02 Jeffrey Stedfast - - * vfoldertypes.xml: Make the date comparisons read the same as the - ones in filtertypes.xml - -2001-12-17 Jeffrey Stedfast - - * filtertypes.xml: Add new action to execute a shell command. - -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 2b4b1038d5..0000000000 --- a/filter/Makefile.am +++ /dev/null @@ -1,101 +0,0 @@ - -glade_DATA = filter.glade - -INCLUDES = \ - -I $(top_srcdir) \ - -I $(top_srcdir)/camel \ - -I $(top_srcdir)/e-util \ - -I $(top_srcdir)/shell \ - -DFILTER_GLADEDIR=\"$(gladedir)\" \ - -DG_LOG_DOMAIN=\"filter\" \ - -DG_DISABLE_DEPRECATED \ - -DGTK_DISABLE_DEPRECATED \ - $(LIBFILTER_CFLAGS) - -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-file.c \ - filter-file.h \ - filter-filter.c \ - filter-filter.h \ - filter-folder.c \ - filter-folder.h \ - filter-input.c \ - filter-input.h \ - filter-int.c \ - filter-int.h \ - filter-label.c \ - filter-label.h \ - filter-marshal.c \ - filter-marshal.h \ - filter-option.c \ - filter-option.h \ - filter-part.c \ - filter-part.h \ - filter-rule.c \ - filter-rule.h \ - filter-source.h \ - filter-source.c \ - rule-context.c \ - rule-context.h \ - rule-editor.c \ - rule-editor.h \ - score-context.c \ - score-context.h \ - score-editor.c \ - score-editor.h \ - score-rule.c \ - score-rule.h \ - vfolder-context.c \ - vfolder-context.h \ - vfolder-editor.c \ - vfolder-editor.h \ - vfolder-rule.c \ - vfolder-rule.h - -libfilter_la_DEPENDENCIES = libfilter-i18n.h - -EXTRA_DIST = \ - $(glade_DATA) \ - ChangeLog.pre-1-4 \ - filter-marshal.list \ - filtertypes.xml \ - libfilter-i18n.h \ - vfoldertypes.xml - -# basic rules. -filterdir = $(privdatadir) -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 >> $@ - -filter-marshal.h: filter-marshal.list - ( @GLIB_GENMARSHAL@ --prefix=filter_marshal filter-marshal.list --header > filter-marshal.tmp \ - && mv filter-marshal.tmp filter-marshal.h ) \ - || ( rm -f filter-marshal.tmp && exit 1 ) - -filter-marshal.c: filter-marshal.h - ( @GLIB_GENMARSHAL@ --prefix=filter_marshal filter-marshal.list --body > filter-marshal.tmp \ - && mv filter-marshal.tmp filter-marshal.c ) \ - || ( rm -f filter-marshal.tmp && exit 1 ) - -MARSHAL_GENERATED = filter-marshal.c filter-marshal.h - diff --git a/filter/filter-code.c b/filter/filter-code.c deleted file mode 100644 index 11739a318d..0000000000 --- a/filter/filter-code.c +++ /dev/null @@ -1,125 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 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. - */ - - -#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 *fc); -static void filter_code_finalise (GObject *obj); - - -static FilterInputClass *parent_class; - - -GType -filter_code_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (FilterCodeClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) filter_code_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (FilterCode), - 0, /* n_preallocs */ - (GInstanceInitFunc) filter_code_init, - }; - - type = g_type_register_static (FILTER_TYPE_INPUT, "FilterCode", &info, 0); - } - - return type; -} - -static void -filter_code_class_init (FilterCodeClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - FilterElementClass *fe_class = FILTER_ELEMENT_CLASS (klass); - - parent_class = g_type_class_ref (FILTER_TYPE_INPUT); - - object_class->finalize = filter_code_finalise; - - /* override methods */ - fe_class->build_code = build_code; - fe_class->format_sexp = format_sexp; -} - -static void -filter_code_init (FilterCode *fc) -{ - ((FilterInput *) fc)->type = xmlStrdup ("code"); -} - -static void -filter_code_finalise (GObject *obj) -{ - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - - -/** - * filter_code_new: - * - * Create a new FilterCode object. - * - * Return value: A new #FilterCode object. - **/ -FilterCode * -filter_code_new (void) -{ - return (FilterCode *) g_object_new (FILTER_TYPE_CODE, NULL, NULL); -} - -/* 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) -{ - ; -} diff --git a/filter/filter-code.h b/filter/filter-code.h deleted file mode 100644 index 2d590279ee..0000000000 --- a/filter/filter-code.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 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. - */ - - -#ifndef _FILTER_CODE_H -#define _FILTER_CODE_H - -#include "filter-input.h" - -#define FILTER_TYPE_CODE (filter_code_get_type ()) -#define FILTER_CODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FILTER_TYPE_CODE, FilterCode)) -#define FILTER_CODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FILTER_TYPE_CODE, FilterCodeClass)) -#define IS_FILTER_CODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FILTER_TYPE_CODE)) -#define IS_FILTER_CODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FILTER_TYPE_CODE)) -#define FILTER_CODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FILTER_TYPE_CODE, FilterCodeClass)) - -typedef struct _FilterCode FilterCode; -typedef struct _FilterCodeClass FilterCodeClass; - -struct _FilterCode { - FilterInput parent_object; -}; - -struct _FilterCodeClass { - FilterInputClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - -GType 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 4819b24524..0000000000 --- a/filter/filter-colour.c +++ /dev/null @@ -1,229 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 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. - */ - - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include - -#include "e-util/e-sexp.h" -#include "filter-colour.h" - -#define d(x) - -static int colour_eq (FilterElement *fe, FilterElement *cm); -static void xml_create (FilterElement *fe, xmlNodePtr node); -static xmlNodePtr xml_encode (FilterElement *fe); -static int xml_decode (FilterElement *fe, xmlNodePtr node); -static GtkWidget *get_widget (FilterElement *fe); -static void build_code (FilterElement *fe, GString *out, struct _FilterPart *ff); -static void format_sexp (FilterElement *, GString *); - -static void filter_colour_class_init (FilterColourClass *klass); -static void filter_colour_init (FilterColour *fc); -static void filter_colour_finalise (GObject *obj); - - -static FilterElementClass *parent_class; - -GType -filter_colour_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (FilterColourClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) filter_colour_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (FilterColour), - 0, /* n_preallocs */ - (GInstanceInitFunc) filter_colour_init, - }; - - type = g_type_register_static (FILTER_TYPE_ELEMENT, "FilterColour", &info, 0); - } - - return type; -} - -static void -filter_colour_class_init (FilterColourClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - FilterElementClass *fe_class = FILTER_ELEMENT_CLASS (klass); - - parent_class = g_type_class_ref (FILTER_TYPE_ELEMENT); - - object_class->finalize = filter_colour_finalise; - - /* override methods */ - fe_class->eq = colour_eq; - fe_class->xml_create = xml_create; - fe_class->xml_encode = xml_encode; - fe_class->xml_decode = xml_decode; - fe_class->get_widget = get_widget; - fe_class->build_code = build_code; - fe_class->format_sexp = format_sexp; -} - -static void -filter_colour_init (FilterColour *fc) -{ - ; -} - -static void -filter_colour_finalise (GObject *obj) -{ - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -/** - * filter_colour_new: - * - * Create a new FilterColour object. - * - * Return value: A new #FilterColour object. - **/ -FilterColour * -filter_colour_new (void) -{ - return (FilterColour *) g_object_new (FILTER_TYPE_COLOUR, NULL, NULL); -} - -static int -colour_eq (FilterElement *fe, FilterElement *cm) -{ - FilterColour *fc = (FilterColour *)fe, *cc = (FilterColour *)cm; - - return FILTER_ELEMENT_CLASS (parent_class)->eq (fe, cm) - && fc->r == cc->r - && fc->g == cc->g - && fc->b == cc->b - && fc->a == cc->a; -} - -static void -xml_create (FilterElement *fe, xmlNodePtr node) -{ - /* parent implementation */ - FILTER_ELEMENT_CLASS (parent_class)->xml_create (fe, node); -} - -static xmlNodePtr -xml_encode (FilterElement *fe) -{ - xmlNodePtr value; - 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); - g_signal_connect (cp, "color_set", G_CALLBACK (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) -{ - FilterColour *fc = (FilterColour *)fe; - char *str; - - str = g_strdup_printf ("#%02x%02x%02x", (fc->r >> 8) & 0xff, (fc->g >> 8) & 0xff, (fc->b >> 8) & 0xff); - 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 9e22a2021f..0000000000 --- a/filter/filter-colour.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 Ximian Inc. - * - * Authors: Not Zed - * 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. - */ - - -#ifndef _FILTER_COLOUR_H -#define _FILTER_COLOUR_H - -#include "filter-element.h" - -#define FILTER_TYPE_COLOUR (filter_colour_get_type ()) -#define FILTER_COLOUR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FILTER_TYPE_COLOUR, FilterColour)) -#define FILTER_COLOUR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FILTER_TYPE_COLOUR, FilterColourClass)) -#define IS_FILTER_COLOUR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FILTER_TYPE_COLOUR)) -#define IS_FILTER_COLOUR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FILTER_TYPE_COLOUR)) -#define FILTER_COLOUR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FILTER_TYPE_COLOUR, FilterColourClass)) - -typedef struct _FilterColour FilterColour; -typedef struct _FilterColourClass FilterColourClass; - -struct _FilterColour { - FilterElement parent_object; - - guint16 r, g, b, a; -}; - -struct _FilterColourClass { - FilterElementClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - -GType 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 3e82bc4c39..0000000000 --- a/filter/filter-context.c +++ /dev/null @@ -1,279 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 Ximian Inc. - * - * Authors: Not Zed - * 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 "filter-context.h" -#include "filter-filter.h" - -/* For poking into filter-folder guts */ -#include "filter-folder.h" - -#define d(x) - -static void filter_context_class_init (FilterContextClass *klass); -static void filter_context_init (FilterContext *fc); -static void filter_context_finalise (GObject *obj); - -static GList *filter_rename_uri (RuleContext *rc, const char *olduri, const char *newuri, GCompareFunc cmp); -static GList *filter_delete_uri (RuleContext *rc, const char *uri, GCompareFunc cmp); - - -static RuleContextClass *parent_class = NULL; - - -GType -filter_context_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (FilterContextClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) filter_context_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (FilterContext), - 0, /* n_preallocs */ - (GInstanceInitFunc) filter_context_init, - }; - - type = g_type_register_static (RULE_TYPE_CONTEXT, "FilterContext", &info, 0); - } - - return type; -} - -static void -filter_context_class_init (FilterContextClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - RuleContextClass *rc_class = RULE_CONTEXT_CLASS (klass); - - parent_class = g_type_class_ref (RULE_TYPE_CONTEXT); - - object_class->finalize = filter_context_finalise; - - /* override methods */ - rc_class->rename_uri = filter_rename_uri; - rc_class->delete_uri = filter_delete_uri; -} - -static void -filter_context_init (FilterContext *fc) -{ - rule_context_add_part_set ((RuleContext *) fc, "partset", filter_part_get_type (), - rule_context_add_part, rule_context_next_part); - rule_context_add_part_set ((RuleContext *) fc, "actionset", filter_part_get_type (), - (RCPartFunc) filter_context_add_action, - (RCNextPartFunc) filter_context_next_action); - - rule_context_add_rule_set ((RuleContext *) fc, "ruleset", filter_filter_get_type (), - (RCRuleFunc) rule_context_add_rule, rule_context_next_rule); -} - -static void -filter_context_finalise (GObject *obj) -{ - FilterContext *fc = (FilterContext *)obj; - - g_list_foreach (fc->actions, (GFunc)g_object_unref, NULL); - g_list_free (fc->actions); - - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -/** - * filter_context_new: - * - * Create a new FilterContext object. - * - * Return value: A new #FilterContext object. - **/ -FilterContext * -filter_context_new (void) -{ - return (FilterContext *) g_object_new (FILTER_TYPE_CONTEXT, NULL, NULL); -} - -void -filter_context_add_action (FilterContext *fc, FilterPart *action) -{ - d(printf("find action : ")); - fc->actions = g_list_append (fc->actions, action); -} - -FilterPart * -filter_context_find_action (FilterContext *fc, const char *name) -{ - d(printf("find action : ")); - return filter_part_find_list (fc->actions, name); -} - -FilterPart * -filter_context_create_action (FilterContext *fc, const char *name) -{ - FilterPart *part; - - if ((part = filter_context_find_action (fc, name))) - return filter_part_clone (part); - - return NULL; -} - -FilterPart * -filter_context_next_action (FilterContext *fc, FilterPart *last) -{ - return filter_part_next_list (fc->actions, last); -} - -/* We search for any folders in our actions list that need updating, update them */ -static GList * -filter_rename_uri (RuleContext *rc, const char *olduri, const char *newuri, GCompareFunc cmp) -{ - FilterRule *rule; - GList *l, *el; - FilterPart *action; - FilterElement *element; - int count = 0; - GList *changed = NULL; - - d(printf("uri '%s' renamed to '%s'\n", olduri, newuri)); - - /* For all rules, for all actions, for all elements, rename any folder elements */ - /* Yes we could do this inside each part itself, but not today */ - rule = NULL; - while ((rule = rule_context_next_rule (rc, rule, NULL))) { - int rulecount = 0; - - d(printf("checking rule '%s'\n", rule->name)); - - l = FILTER_FILTER (rule)->actions; - while (l) { - action = l->data; - - d(printf("checking action '%s'\n", action->name)); - - el = action->elements; - while (el) { - element = el->data; - - d(printf("checking element '%s'\n", element->name)); - if (IS_FILTER_FOLDER (element)) { - d(printf(" is folder, existing uri = '%s'\n", - FILTER_FOLDER (element)->uri)); - } - - if (IS_FILTER_FOLDER (element) - && cmp(((FilterFolder *)element)->uri, olduri)) { - d(printf(" Changed!\n")); - filter_folder_set_value((FilterFolder *)element, newuri); - rulecount++; - } - el = el->next; - } - l = l->next; - } - - if (rulecount) { - changed = g_list_append (changed, g_strdup (rule->name)); - filter_rule_emit_changed (rule); - } - - count += rulecount; - } - - /* might need to call parent class, if it did anything ... parent_class->rename_uri(f, olduri, newuri, cmp); */ - - return changed; -} - -static GList * -filter_delete_uri (RuleContext *rc, const char *uri, GCompareFunc cmp) -{ - /* We basically do similar to above, but when we find it, - Remove the action, and if thats the last action, this might create an empty rule? remove the rule? */ - - FilterRule *rule; - GList *l, *el; - FilterPart *action; - FilterElement *element; - int count = 0; - GList *deleted = NULL; - - d(printf("uri '%s' deleted\n", uri)); - - /* For all rules, for all actions, for all elements, check deleted folder elements */ - /* Yes we could do this inside each part itself, but not today */ - rule = NULL; - while ((rule = rule_context_next_rule (rc, rule, NULL))) { - int recorded = 0; - - d(printf("checking rule '%s'\n", rule->name)); - - l = FILTER_FILTER (rule)->actions; - while (l) { - action = l->data; - - d(printf("checking action '%s'\n", action->name)); - - el = action->elements; - while (el) { - element = el->data; - - d(printf("checking element '%s'\n", element->name)); - if (IS_FILTER_FOLDER (element)) { - d(printf(" is folder, existing uri = '%s'\n", - FILTER_FOLDER (element)->uri)); - } - - if (IS_FILTER_FOLDER (element) - && cmp(((FilterFolder *)element)->uri, uri)) { - d(printf(" Deleted!\n")); - /* check if last action, if so, remove rule instead? */ - l = l->next; - filter_filter_remove_action ((FilterFilter *)rule, action); - g_object_unref (action); - count++; - if (!recorded) - deleted = g_list_append (deleted, g_strdup (rule->name)); - goto next_action; - } - el = el->next; - } - l = l->next; - next_action: - ; - } - } - - /* TODO: could call parent and merge lists */ - - return deleted; -} diff --git a/filter/filter-context.h b/filter/filter-context.h deleted file mode 100644 index 157ee6f1de..0000000000 --- a/filter/filter-context.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 Ximian Inc. - * - * Authors: Not Zed - * 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. - */ - - -#ifndef _FILTER_CONTEXT_H -#define _FILTER_CONTEXT_H - -#include "rule-context.h" - -#define FILTER_TYPE_CONTEXT (filter_context_get_type ()) -#define FILTER_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FILTER_TYPE_CONTEXT, FilterContext)) -#define FILTER_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FILTER_TYPE_CONTEXT, FilterContextClass)) -#define IS_FILTER_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FILTER_TYPE_CONTEXT)) -#define IS_FILTER_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FILTER_TYPE_CONTEXT)) -#define FILTER_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FILTER_TYPE_CONTEXT, FilterContextClass)) - -typedef struct _FilterContext FilterContext; -typedef struct _FilterContextClass FilterContextClass; - -struct _FilterContext { - RuleContext parent_object; - - GList *actions; -}; - -struct _FilterContextClass { - RuleContextClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - -GType filter_context_get_type (void); -FilterContext *filter_context_new (void); - -/* methods */ -void filter_context_add_action (FilterContext *fc, FilterPart *action); -FilterPart *filter_context_find_action (FilterContext *fc, const char *name); -FilterPart *filter_context_create_action (FilterContext *fc, const char *name); -FilterPart *filter_context_next_action (FilterContext *fc, FilterPart *last); - -#endif /* ! _FILTER_CONTEXT_H */ diff --git a/filter/filter-datespec.c b/filter/filter-datespec.c deleted file mode 100644 index bbb6df77d5..0000000000 --- a/filter/filter-datespec.c +++ /dev/null @@ -1,480 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 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. - */ - - -#ifdef HAVE_CONFIG_H -#include -#endif - -#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 int date_eq (FilterElement *fe, FilterElement *cm); -static void xml_create (FilterElement *fe, xmlNodePtr node); -static xmlNodePtr xml_encode (FilterElement *fe); -static int xml_decode (FilterElement *fe, xmlNodePtr node); -static GtkWidget *get_widget (FilterElement *fe); -static void build_code (FilterElement *fe, GString *out, struct _FilterPart *fds); -static void format_sexp (FilterElement *, GString *); - -static void filter_datespec_class_init (FilterDatespecClass *klass); -static void filter_datespec_init (FilterDatespec *fd); -static void filter_datespec_finalise (GObject *obj); - -#define PRIV(x) (((FilterDatespec *)(x))->priv) - -typedef struct _timespan { - guint32 seconds; - const char *singular; - const char *plural; - float max; -} timespan; - -static const timespan timespans[] = { - { 1, N_("1 second ago"), N_("%d seconds ago"), 59.0 }, - { 60, N_("1 minute ago"), N_("%d minutes ago"), 59.0 }, - { 3600, N_("1 hour ago"), N_("%d hours ago"), 23.0 }, - { 86400, N_("1 day ago"), N_("%d days ago"), 31.0 }, - { 604800, N_("1 week ago"), N_("%d weeks ago"), 52.0 }, - { 2419200, N_("1 month ago"), N_("%d months ago"), 12.0 }, - { 31557600, N_("1 year ago"), N_("%d years ago"), 1000.0 }, -}; - -#define DAY_INDEX 3 -#define N_TIMESPANS (sizeof (timespans) / sizeof (timespans[0])) - -struct _FilterDatespecPrivate { - GtkWidget *label_button; - GtkWidget *notebook_type, *option_type, *calendar_specify, *spin_relative, *option_relative; - FilterDatespec_type type; - int span; -}; - -static FilterElementClass *parent_class; - -GType -filter_datespec_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (FilterDatespecClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) filter_datespec_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (FilterDatespec), - 0, /* n_preallocs */ - (GInstanceInitFunc) filter_datespec_init, - }; - - type = g_type_register_static (FILTER_TYPE_ELEMENT, "FilterDatespec", &info, 0); - } - - return type; -} - -static void -filter_datespec_class_init (FilterDatespecClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - FilterElementClass *fe_class = FILTER_ELEMENT_CLASS (klass); - - parent_class = g_type_class_ref (FILTER_TYPE_ELEMENT); - - object_class->finalize = filter_datespec_finalise; - - /* override methods */ - fe_class->validate = validate; - fe_class->eq = date_eq; - fe_class->xml_create = xml_create; - fe_class->xml_encode = xml_encode; - fe_class->xml_decode = xml_decode; - fe_class->get_widget = get_widget; - fe_class->build_code = build_code; - fe_class->format_sexp = format_sexp; -} - -static void -filter_datespec_init (FilterDatespec *fd) -{ - fd->priv = g_malloc0 (sizeof (*fd->priv)); - fd->type = FDST_UNKNOWN; -} - -static void -filter_datespec_finalise (GObject *obj) -{ - FilterDatespec *fd = (FilterDatespec *) obj; - - g_free (fd->priv); - - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -/** - * filter_datespec_new: - * - * Create a new FilterDatespec object. - * - * Return value: A new #FilterDatespec object. - **/ -FilterDatespec * -filter_datespec_new (void) -{ - return (FilterDatespec *) g_object_new (FILTER_TYPE_DATESPEC, NULL, NULL); -} - -static gboolean -validate (FilterElement *fe) -{ - FilterDatespec *fds = (FilterDatespec *) fe; - GtkWidget *dialog; - gboolean valid; - - valid = fds->type != FDST_UNKNOWN; - if (!valid) { - /* FIXME: FilterElement should probably have a - GtkWidget member pointing to the value gotten with - ::get_widget() so that we can get the parent window - here. */ - dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, - "%s", _("You must choose a date.")); - - gtk_dialog_run ((GtkDialog *) dialog); - gtk_widget_destroy (dialog); - } - - return valid; -} - -static int -date_eq (FilterElement *fe, FilterElement *cm) -{ - FilterDatespec *fd = (FilterDatespec *)fe, *cd = (FilterDatespec *)cm; - - return FILTER_ELEMENT_CLASS (parent_class)->eq(fe, cm) - && (fd->type == cd->type) - && (fd->value == cd->value); -} - -static void -xml_create (FilterElement *fe, xmlNodePtr node) -{ - /* parent implementation */ - FILTER_ELEMENT_CLASS (parent_class)->xml_create (fe, node); -} - -static xmlNodePtr -xml_encode (FilterElement *fe) -{ - xmlNodePtr value, work; - FilterDatespec *fds = (FilterDatespec *)fe; - char 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; - char *val; - - d(printf ("Decoding datespec from xml %p\n", fe)); - - xmlFree (fe->name); - fe->name = xmlGetProp (node, "name"); - - n = node->children; - 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 int -get_best_span (time_t val) -{ - int i; - - for (i=N_TIMESPANS-1;i>=0;i--) { - if (val % timespans[i].seconds == 0) - return i; - } - - return 0; -} - -/* sets button label */ -static void -set_button (FilterDatespec *fds) -{ - char buf[128]; - char *label = buf; - - switch (fds->type) { - case FDST_UNKNOWN: - label = _(""); - break; - case FDST_NOW: - label = _("now"); - break; - case FDST_SPECIFIED: { - struct tm tm; - - localtime_r(&fds->value, &tm); - /* strftime for date filter display, only needs to show a day date (i.e. no time) */ - strftime(buf, sizeof(buf), _("%d-%b-%Y"), &tm); - break; } - case FDST_X_AGO: - if (fds->value == 0) - label = _("now"); - else { - int span, count; - - span = get_best_span(fds->value); - count = fds->value / timespans[span].seconds; - - if (count == 1) - /* 1 (minute|day|...) ago (singular time ago) */ - strcpy(buf, _(timespans[span].singular)); - else - /* N (minutes|days|...) ago (plural time ago) */ - sprintf(buf, _(timespans[span].plural), count); - } - break; - } - - gtk_label_set_text((GtkLabel *)fds->priv->label_button, label); -} - -static void -get_values (FilterDatespec *fds) -{ - struct _FilterDatespecPrivate *p = PRIV(fds); - - switch(fds->priv->type) { - case FDST_SPECIFIED: { - guint year, month, day; - struct tm tm; - - gtk_calendar_get_date((GtkCalendar *)p->calendar_specify, &year, &month, &day); - memset(&tm, 0, sizeof(tm)); - tm.tm_mday = day; - tm.tm_year = year - 1900; - tm.tm_mon = month; - fds->value = mktime(&tm); - /* what about timezone? */ - break; } - case FDST_X_AGO: { - int val; - - val = gtk_spin_button_get_value_as_int((GtkSpinButton *)p->spin_relative); - fds->value = timespans[p->span].seconds * val; - break; } - case FDST_NOW: - default: - break; - } - - fds->type = p->type; -} - -static void -set_values (FilterDatespec *fds) -{ - struct _FilterDatespecPrivate *p = PRIV(fds); - - p->type = fds->type==FDST_UNKNOWN ? FDST_NOW : fds->type; - - switch (p->type) { - case FDST_NOW: - case FDST_UNKNOWN: - /* noop */ - break; - case FDST_SPECIFIED: - { - struct tm tm; - - localtime_r(&fds->value, &tm); - gtk_calendar_select_month((GtkCalendar*)p->calendar_specify, tm.tm_mon, tm.tm_year + 1900); - gtk_calendar_select_day((GtkCalendar*)p->calendar_specify, tm.tm_mday); - break; - } - case FDST_X_AGO: - p->span = get_best_span(fds->value); - gtk_spin_button_set_value((GtkSpinButton*)p->spin_relative, fds->value/timespans[p->span].seconds); - gtk_option_menu_set_history((GtkOptionMenu*)p->option_relative, p->span); - break; - } - - gtk_notebook_set_current_page ((GtkNotebook*) p->notebook_type, p->type); - gtk_option_menu_set_history ((GtkOptionMenu*) p->option_type, p->type); -} - - -static void -set_option_type (GtkMenu *menu, FilterDatespec *fds) -{ - GtkWidget *w; - - /* ugh, no other way to 'get_history' */ - w = gtk_menu_get_active (menu); - fds->priv->type = g_list_index (GTK_MENU_SHELL (menu)->children, w); - gtk_notebook_set_current_page ((GtkNotebook*) fds->priv->notebook_type, fds->priv->type); -} - -static void -set_option_relative (GtkMenu *menu, FilterDatespec *fds) -{ - GtkWidget *w; - - w = gtk_menu_get_active (menu); - fds->priv->span = g_list_index (GTK_MENU_SHELL (menu)->children, w); -} - -static void -button_clicked (GtkButton *button, FilterDatespec *fds) -{ - struct _FilterDatespecPrivate *p = PRIV(fds); - GtkWidget *toplevel; - GtkDialog *dialog; - GladeXML *gui; - - gui = glade_xml_new (FILTER_GLADEDIR "/filter.glade", "filter_datespec", NULL); - toplevel = glade_xml_get_widget (gui, "filter_datespec"); - - dialog = (GtkDialog *) gtk_dialog_new (); - gtk_window_set_title ((GtkWindow *) dialog, _("Select a time to compare against")); - gtk_dialog_add_buttons (dialog, - GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, - GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, - NULL); - - p->notebook_type = glade_xml_get_widget (gui, "notebook_type"); - p->option_type = glade_xml_get_widget (gui, "option_type"); - p->calendar_specify = glade_xml_get_widget (gui, "calendar_specify"); - p->spin_relative = glade_xml_get_widget (gui, "spin_relative"); - p->option_relative = glade_xml_get_widget (gui, "option_relative"); - - set_values (fds); - - g_signal_connect (GTK_OPTION_MENU (p->option_type)->menu, "deactivate", - G_CALLBACK (set_option_type), fds); - g_signal_connect (GTK_OPTION_MENU (p->option_relative)->menu, "deactivate", - G_CALLBACK (set_option_relative), fds); - - gtk_box_pack_start ((GtkBox *) dialog->vbox, toplevel, TRUE, TRUE, 3); - - if (gtk_dialog_run (dialog) == GTK_RESPONSE_ACCEPT) { - get_values (fds); - set_button (fds); - } - - gtk_widget_destroy ((GtkWidget *)dialog); -} - -static GtkWidget * -get_widget (FilterElement *fe) -{ - FilterDatespec *fds = (FilterDatespec *)fe; - GtkWidget *button; - - fds->priv->label_button = gtk_label_new (""); - gtk_misc_set_alignment (GTK_MISC (fds->priv->label_button), 0.5, 0.5); - set_button(fds); - - button = gtk_button_new(); - gtk_container_add (GTK_CONTAINER (button), fds->priv->label_button); - g_signal_connect (button, "clicked", G_CALLBACK (button_clicked), fds); - - gtk_widget_show (button); - gtk_widget_show (fds->priv->label_button); - - 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_append_printf (out, "%d", (int) fds->value); - break; - case FDST_X_AGO: - g_string_append_printf (out, "(- (get-current-date) %d)", (int) fds->value); - break; - } -} diff --git a/filter/filter-datespec.h b/filter/filter-datespec.h deleted file mode 100644 index 6290ab34b5..0000000000 --- a/filter/filter-datespec.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 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. - */ - - -#ifndef _FILTER_DATESPEC_H -#define _FILTER_DATESPEC_H - -#include -#include "filter-element.h" - -#define FILTER_TYPE_DATESPEC (filter_datespec_get_type ()) -#define FILTER_DATESPEC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FILTER_TYPE_DATESPEC, FilterDatespec)) -#define FILTER_DATESPEC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FILTER_TYPE_DATESPEC, FilterDatespecClass)) -#define IS_FILTER_DATESPEC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FILTER_TYPE_DATESPEC)) -#define IS_FILTER_DATESPEC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FILTER_TYPE_DATESPEC)) -#define FILTER_DATESPEC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FILTER_TYPE_DATESPEC, FilterDatespecClass)) - -typedef struct _FilterDatespec FilterDatespec; -typedef struct _FilterDatespecClass FilterDatespecClass; - -typedef enum _FilterDatespec_type { - FDST_UNKNOWN = -1, - FDST_NOW, - FDST_SPECIFIED, - FDST_X_AGO, -} 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 */ -}; - -GType 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 f6dc5700ec..0000000000 --- a/filter/filter-editor.c +++ /dev/null @@ -1,169 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 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. - */ - - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include - -#include "filter-editor.h" -#include "filter-filter.h" - -#define d(x) - -static FilterRule *create_rule (RuleEditor *re); - -static void filter_editor_class_init (FilterEditorClass *klass); -static void filter_editor_init (FilterEditor *fe); -static void filter_editor_finalise (GObject *obj); - - -static RuleEditorClass *parent_class = NULL; - - -GtkType -filter_editor_get_type (void) -{ - static GtkType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (FilterEditorClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) filter_editor_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (FilterEditor), - 0, /* n_preallocs */ - (GInstanceInitFunc) filter_editor_init, - }; - - type = g_type_register_static (RULE_TYPE_EDITOR, "FilterEditor", &info, 0); - } - - return type; -} - -static void -filter_editor_class_init (FilterEditorClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - RuleEditorClass *re_class = (RuleEditorClass *) klass; - - parent_class = g_type_class_ref (rule_editor_get_type ()); - - gobject_class->finalize = filter_editor_finalise; - - /* override methods */ - re_class->create_rule = create_rule; -} - -static void -filter_editor_init (FilterEditor *fe) -{ - ; -} - -static void -filter_editor_finalise (GObject *obj) -{ - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -/** - * filter_editor_new: - * - * Create a new FilterEditor object. - * - * Return value: A new #FilterEditor object. - **/ -FilterEditor * -filter_editor_new (FilterContext *fc, const char **source_names) -{ - FilterEditor *fe = (FilterEditor *) g_object_new (FILTER_TYPE_EDITOR, NULL); - GladeXML *gui; - GtkWidget *w; - - gui = glade_xml_new (FILTER_GLADEDIR "/filter.glade", "rule_editor", NULL); - filter_editor_construct (fe, fc, gui, source_names); - - w = glade_xml_get_widget (gui, "rule_frame"); - gtk_frame_set_label (GTK_FRAME (w), _("Filter Rules")); - - g_object_unref (gui); - - return fe; -} - -static void -select_source (GtkMenuItem *mi, FilterEditor *fe) -{ - char *source; - - source = g_object_get_data(G_OBJECT(mi), "source"); - g_assert (source); - - rule_editor_set_source ((RuleEditor *)fe, source); -} - -void -filter_editor_construct (FilterEditor *fe, FilterContext *fc, GladeXML *gui, const char **source_names) -{ - GtkWidget *menu, *item, *omenu; - int i; - - omenu = glade_xml_get_widget (gui, "filter_source"); - gtk_option_menu_remove_menu (GTK_OPTION_MENU (omenu)); - menu = gtk_menu_new (); - - for (i = 0; source_names[i]; i++) { - item = gtk_menu_item_new_with_label (_(source_names[i])); - g_object_set_data_full (G_OBJECT (item), "source", g_strdup (source_names[i]), g_free); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); - gtk_widget_show (item); - g_signal_connect (item, "activate", G_CALLBACK (select_source), fe); - } - gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu); - gtk_widget_show (omenu); - - rule_editor_construct ((RuleEditor *) fe, (RuleContext *) fc, gui, source_names[0]); -} - -static FilterRule * -create_rule (RuleEditor *re) -{ - FilterRule *rule = filter_rule_new (); - FilterPart *part; - - /* create a rule with 1 part & 1 action in it */ - rule = (FilterRule *)filter_filter_new (); - part = rule_context_next_part (re->context, NULL); - filter_rule_add_part (rule, filter_part_clone (part)); - part = filter_context_next_action ((FilterContext *)re->context, NULL); - filter_filter_add_action ((FilterFilter *)rule, filter_part_clone (part)); - - return rule; -} diff --git a/filter/filter-editor.h b/filter/filter-editor.h deleted file mode 100644 index 4b01e3b877..0000000000 --- a/filter/filter-editor.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 Ximian Inc. - * - * Authors: Not Zed - * 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. - */ - - -#ifndef _FILTER_EDITOR_H -#define _FILTER_EDITOR_H - -#include "rule-editor.h" -#include "filter-context.h" - -#define FILTER_TYPE_EDITOR (filter_editor_get_type ()) -#define FILTER_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FILTER_TYPE_EDITOR, FilterEditor)) -#define FILTER_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FILTER_TYPE_EDITOR, FilterEditorClass)) -#define IS_FILTER_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FILTER_TYPE_EDITOR)) -#define IS_FILTER_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FILTER_TYPE_EDITOR)) -#define FILTER_EDITOR_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), FILTER_TYPE_EDITOR, FilterEditorClass)) - -typedef struct _FilterEditor FilterEditor; -typedef struct _FilterEditorClass FilterEditorClass; - -struct _FilterEditor { - RuleEditor parent_object; - -}; - -struct _FilterEditorClass { - RuleEditorClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - -GtkType filter_editor_get_type (void); - -FilterEditor *filter_editor_new (FilterContext *f, const char **source_names); -void filter_editor_construct (FilterEditor *fe, FilterContext *fc, GladeXML *gui, const char **source_names); - -#endif /* ! _FILTER_EDITOR_H */ diff --git a/filter/filter-element.c b/filter/filter-element.c deleted file mode 100644 index 5f68f78804..0000000000 --- a/filter/filter-element.c +++ /dev/null @@ -1,385 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 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. - */ - - -#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-int.h" -#include "filter-folder.h" -#include "filter-source.h" -#include "filter-file.h" -#include "filter-label.h" - - -static gboolean validate (FilterElement *fe); -static int element_eq(FilterElement *fe, FilterElement *cm); -static void xml_create(FilterElement *fe, xmlNodePtr node); -static FilterElement *clone(FilterElement *fe); - -static void filter_element_class_init (FilterElementClass *klass); -static void filter_element_init (FilterElement *fe); -static void filter_element_finalise (GObject *obj); - - -static GObjectClass *parent_class = NULL; - - -GType -filter_element_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (FilterElementClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) filter_element_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (FilterElement), - 0, /* n_preallocs */ - (GInstanceInitFunc) filter_element_init, - }; - - type = g_type_register_static (G_TYPE_OBJECT, "FilterElement", &info, 0); - } - - return type; -} - -static void -filter_element_class_init (FilterElementClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_ref (G_TYPE_OBJECT); - - object_class->finalize = filter_element_finalise; - - /* override methods */ - klass->validate = validate; - klass->eq = element_eq; - klass->xml_create = xml_create; - klass->clone = clone; -} - -static void -filter_element_init (FilterElement *fe) -{ - ; -} - -static void -filter_element_finalise (GObject *obj) -{ - FilterElement *o = (FilterElement *)obj; - - xmlFree (o->name); - - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -/** - * filter_element_new: - * - * Create a new FilterElement object. - * - * Return value: A new #FilterElement object. - **/ -FilterElement * -filter_element_new (void) -{ - return (FilterElement *) g_object_new (FILTER_TYPE_ELEMENT, NULL, NULL); -} - -gboolean -filter_element_validate (FilterElement *fe) -{ - return FILTER_ELEMENT_GET_CLASS (fe)->validate (fe); -} - -int -filter_element_eq (FilterElement *fe, FilterElement *cm) -{ - FilterElementClass *klass; - - klass = FILTER_ELEMENT_GET_CLASS (fe); - return (klass == FILTER_ELEMENT_GET_CLASS (cm)) && klass->eq (fe, cm); -} - -/** - * 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) -{ - FILTER_ELEMENT_GET_CLASS (fe)->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 FILTER_ELEMENT_GET_CLASS (fe)->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 FILTER_ELEMENT_GET_CLASS (fe)->xml_decode (fe, node); -} - -/** - * filter_element_clone: - * @fe: filter element - * - * Clones the FilterElement @fe. - * - * Return value: - **/ -FilterElement * -filter_element_clone (FilterElement *fe) -{ - return FILTER_ELEMENT_GET_CLASS (fe)->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 FILTER_ELEMENT_GET_CLASS (fe)->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) -{ - FILTER_ELEMENT_GET_CLASS (fe)->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) -{ - FILTER_ELEMENT_GET_CLASS (fe)->format_sexp (fe, out); -} - -/** - * filter_element_new_type_name: - * @type: filter element type - * - * Create a new filter element based on its type name. - * - * Return value: - **/ -FilterElement * -filter_element_new_type_name (const char *type) -{ - if (type == NULL) - return NULL; - - if (!strcmp (type, "string")) { - return (FilterElement *) filter_input_new (); - } else if (!strcmp (type, "folder")) { - return (FilterElement *) filter_folder_new (); - } else if (!strcmp (type, "address")) { - /* FIXME: temporary ... need real address type */ - return (FilterElement *) filter_input_new_type_name (type); - } else if (!strcmp (type, "code")) { - return (FilterElement *) filter_code_new (); - } else if (!strcmp (type, "colour")) { - return (FilterElement *) filter_colour_new (); - } else if (!strcmp (type, "optionlist") || !strcmp (type, "system-flag")) { - return (FilterElement *) filter_option_new (); - } else if (!strcmp (type, "datespec")) { - return (FilterElement *) filter_datespec_new (); - } else if (!strcmp (type, "score")) { - return (FilterElement *) filter_int_new_type("score", -3, 3); - } else if (!strcmp (type, "integer")) { - return (FilterElement *) filter_int_new (); - } else if (!strcmp (type, "regex")) { - return (FilterElement *) filter_input_new_type_name (type); - } else if (!strcmp (type, "source")) { - return (FilterElement *) filter_source_new (); - } else if (!strcmp (type, "command")) { - return (FilterElement *) filter_file_new_type_name (type); - } else if (!strcmp (type, "file")) { - return (FilterElement *) filter_file_new_type_name (type); - } else if (!strcmp (type, "label")) { - return (FilterElement *) filter_label_new (); - } else { - g_warning("Unknown filter type '%s'", type); - return NULL; - } -} - -void -filter_element_set_data (FilterElement *fe, gpointer data) -{ - fe->data = data; -} - -/* default implementations */ -static gboolean -validate (FilterElement *fe) -{ - return TRUE; -} - -static int -element_eq (FilterElement *fe, FilterElement *cm) -{ - return ((fe->name && cm->name && strcmp (fe->name, cm->name) == 0) - || (fe->name == NULL && cm->name == NULL)); -} - -static void -xml_create (FilterElement *fe, xmlNodePtr node) -{ - fe->name = xmlGetProp (node, "name"); -} - -static FilterElement * -clone (FilterElement *fe) -{ - xmlNodePtr node; - FilterElement *new; - - new = (FilterElement *) g_object_new (G_OBJECT_TYPE (fe), NULL, NULL); - node = filter_element_xml_encode (fe); - filter_element_xml_decode (new, node); - xmlFreeNodeList (node); - - return new; -} - -/* only copies the value, not the name/type */ -void -filter_element_copy_value (FilterElement *de, FilterElement *se) -{ - /* bit of a hack, but saves having to do the same in each type ? */ - - if (IS_FILTER_INPUT(se)) { - if (IS_FILTER_INPUT(de)) { - if (((FilterInput *)se)->values) - filter_input_set_value((FilterInput*)de, ((FilterInput *)se)->values->data); - } else if (IS_FILTER_INT(de)) { - ((FilterInt *)de)->val = atoi((char *) ((FilterInput *)se)->values->data); - } - } else if (IS_FILTER_FOLDER(se)) { - if (IS_FILTER_FOLDER(de)) { - filter_folder_set_value((FilterFolder *)de, ((FilterFolder *)se)->uri); - } - } else if (IS_FILTER_COLOUR(se)) { - if (IS_FILTER_COLOUR(de)) { - FilterColour *s = (FilterColour *)se, *d = (FilterColour *)de; - - d->r = s->r; - d->g = s->g; - d->b = s->b; - d->a = s->a; - } - } else if (IS_FILTER_DATESPEC(se)) { - if (IS_FILTER_DATESPEC(de)) { - FilterDatespec *s = (FilterDatespec *)se, *d = (FilterDatespec *)de; - - d->type = s->type; - d->value = s->value; - } - } else if (IS_FILTER_INT(se)) { - if (IS_FILTER_INT(de)) { - FilterInt *s = (FilterInt *)se, *d = (FilterInt *)de; - - d->val = s->val; - } else if (IS_FILTER_INPUT(de)) { - FilterInt *s = (FilterInt *)se; - FilterInput *d = (FilterInput *)de; - char *v; - - v = g_strdup_printf("%d", s->val); - filter_input_set_value(d, v); - g_free(v); - } - } else if (IS_FILTER_OPTION(se)) { - if (IS_FILTER_OPTION(de)) { - FilterOption *s = (FilterOption *)se, *d = (FilterOption *)de; - - if (s->current) - filter_option_set_current(d, s->current->value); - } - } -} diff --git a/filter/filter-element.h b/filter/filter-element.h deleted file mode 100644 index 75627686ae..0000000000 --- a/filter/filter-element.h +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 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. - */ - -#ifndef _FILTER_ELEMENT_H -#define _FILTER_ELEMENT_H - -#include -#include -#include -#include -#include - -#define FILTER_TYPE_ELEMENT (filter_element_get_type ()) -#define FILTER_ELEMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FILTER_TYPE_ELEMENT, FilterElement)) -#define FILTER_ELEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FILTER_TYPE_ELEMENT, FilterElementClass)) -#define IS_FILTER_ELEMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FILTER_TYPE_ELEMENT)) -#define IS_FILTER_ELEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FILTER_TYPE_ELEMENT)) -#define FILTER_ELEMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FILTER_TYPE_ELEMENT, FilterElementClass)) - -typedef struct _FilterElement FilterElement; -typedef struct _FilterElementClass FilterElementClass; - -struct _FilterElement { - GObject parent_object; - - char *name; - gpointer data; -}; - -struct _FilterPart; - -struct _FilterElementClass { - GObjectClass parent_class; - - /* virtual methods */ - gboolean (*validate) (FilterElement *fe); - int (*eq) (FilterElement *fe, FilterElement *cm); - - 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 */ -}; - -GType filter_element_get_type (void); -FilterElement *filter_element_new (void); - -FilterElement *filter_element_new_type_name (const char *type); - -void filter_element_set_data (FilterElement *fe, gpointer data); - -/* methods */ -gboolean filter_element_validate (FilterElement *fe); -int filter_element_eq (FilterElement *fe, FilterElement *cm); - -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); -void filter_element_copy_value (FilterElement *de, FilterElement *se); - -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-file.c b/filter/filter-file.c deleted file mode 100644 index 41c6b69c58..0000000000 --- a/filter/filter-file.c +++ /dev/null @@ -1,323 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Jeffrey Stedfast - * - * Copyright 2002 Ximian, Inc. (www.ximian.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include - -#include -#include -#include - -#include "filter-file.h" -#include "e-util/e-sexp.h" - -#define d(x) - -static gboolean validate (FilterElement *fe); -static int file_eq (FilterElement *fe, FilterElement *cm); -static void xml_create (FilterElement *fe, xmlNodePtr node); -static xmlNodePtr xml_encode (FilterElement *fe); -static int xml_decode (FilterElement *fe, xmlNodePtr node); -static GtkWidget *get_widget (FilterElement *fe); -static void build_code (FilterElement *fe, GString *out, struct _FilterPart *ff); -static void format_sexp (FilterElement *, GString *); - -static void filter_file_class_init (FilterFileClass *klass); -static void filter_file_init (FilterFile *ff); -static void filter_file_finalise (GObject *obj); - - -static FilterElementClass *parent_class = NULL; - - -GType -filter_file_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (FilterFileClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) filter_file_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (FilterFile), - 0, /* n_preallocs */ - (GInstanceInitFunc) filter_file_init, - }; - - type = g_type_register_static (FILTER_TYPE_ELEMENT, "FilterFile", &info, 0); - } - - return type; -} - -static void -filter_file_class_init (FilterFileClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - FilterElementClass *fe_class = FILTER_ELEMENT_CLASS (klass); - - parent_class = g_type_class_ref (FILTER_TYPE_ELEMENT); - - object_class->finalize = filter_file_finalise; - - /* override methods */ - fe_class->validate = validate; - fe_class->eq = file_eq; - fe_class->xml_create = xml_create; - fe_class->xml_encode = xml_encode; - fe_class->xml_decode = xml_decode; - fe_class->get_widget = get_widget; - fe_class->build_code = build_code; - fe_class->format_sexp = format_sexp; -} - -static void -filter_file_init (FilterFile *ff) -{ - ; -} - -static void -filter_file_finalise (GObject *obj) -{ - FilterFile *ff = (FilterFile *) obj; - - xmlFree (ff->type); - g_free (ff->path); - - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -/** - * filter_file_new: - * - * Create a new FilterFile object. - * - * Return value: A new #FilterFile object. - **/ -FilterFile * -filter_file_new (void) -{ - return (FilterFile *) g_object_new (FILTER_TYPE_FILE, NULL, NULL); -} - - -FilterFile * -filter_file_new_type_name (const char *type) -{ - FilterFile *file; - - file = filter_file_new (); - file->type = xmlStrdup (type); - - return file; -} - -void -filter_file_set_path (FilterFile *file, const char *path) -{ - g_free (file->path); - file->path = g_strdup (path); -} - -static gboolean -validate (FilterElement *fe) -{ - FilterFile *file = (FilterFile *) fe; - GtkWidget *dialog; - struct stat st; - - if (!file->path) { - /* FIXME: FilterElement should probably have a - GtkWidget member pointing to the value gotten with - ::get_widget() so that we can get the parent window - here. */ - dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, - "%s", _("You must specify a file name.")); - - gtk_dialog_run ((GtkDialog *) dialog); - gtk_widget_destroy (dialog); - - return FALSE; - } - - /* FIXME: do more to validate command-lines? */ - - if (strcmp (file->type, "file") == 0) { - if (stat (file->path, &st) == -1 || !S_ISREG (st.st_mode)) { - /* FIXME: FilterElement should probably have a - GtkWidget member pointing to the value gotten with - ::get_widget() so that we can get the parent window - here. */ - dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, - _("File '%s' does not exist or is not a regular file."), - file->path); - - gtk_dialog_run ((GtkDialog *) dialog); - gtk_widget_destroy (dialog); - - return FALSE; - } - } else if (strcmp (file->type, "command") == 0) { - /* only requirements so far is that the command can't - be an empty string */ - return file->path[0] != '\0'; - } - - return TRUE; -} - -static int -file_eq (FilterElement *fe, FilterElement *cm) -{ - FilterFile *ff = (FilterFile *)fe, *cf = (FilterFile *)cm; - - return FILTER_ELEMENT_CLASS (parent_class)->eq (fe, cm) - && ((ff->path && cf->path && strcmp (ff->path, cf->path) == 0) - || (ff->path == NULL && cf->path == NULL)) - && ((ff->type && cf->type && strcmp (ff->type, cf->type) == 0) - || (ff->type == NULL && cf->type == NULL)); -} - -static void -xml_create (FilterElement *fe, xmlNodePtr node) -{ - /* parent implementation */ - FILTER_ELEMENT_CLASS (parent_class)->xml_create (fe, node); -} - -static xmlNodePtr -xml_encode (FilterElement *fe) -{ - FilterFile *file = (FilterFile *) fe; - xmlNodePtr cur, value; - char *type; - - type = file->type ? file->type : "file"; - - d(printf ("Encoding %s as xml\n", type)); - - value = xmlNewNode (NULL, "value"); - xmlSetProp (value, "name", fe->name); - xmlSetProp (value, "type", type); - - cur = xmlNewChild (value, NULL, type, NULL); - xmlNodeSetContent (cur, file->path); - - return value; -} - -static int -xml_decode (FilterElement *fe, xmlNodePtr node) -{ - FilterFile *file = (FilterFile *)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 (file->type); - file->type = type; - - g_free (file->path); - file->path = NULL; - - n = node->children; - while (n != NULL) { - if (!strcmp (n->name, type)) { - str = xmlNodeGetContent (n); - file->path = g_strdup (str ? str : ""); - xmlFree (str); - - d(printf (" '%s'\n", file->path)); - break; - } else if (n->type == XML_ELEMENT_NODE) { - 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) -{ - FilterFile *file = (FilterFile *) fe; - const char *new; - - new = gtk_entry_get_text (entry); - - g_free (file->path); - file->path = g_strdup (new); -} - -static GtkWidget * -get_widget (FilterElement *fe) -{ - FilterFile *file = (FilterFile *) fe; - GtkWidget *fileentry, *entry; - - fileentry = gnome_file_entry_new (NULL, _("Choose a file")); - gnome_file_entry_set_default_path (GNOME_FILE_ENTRY (fileentry), file->path); - gnome_file_entry_set_modal (GNOME_FILE_ENTRY (fileentry), TRUE); - - entry = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (fileentry)); - gtk_entry_set_text (GTK_ENTRY (entry), file->path); - - g_signal_connect (entry, "changed", G_CALLBACK (entry_changed), fe); - - return fileentry; -} - -static void -build_code (FilterElement *fe, GString *out, struct _FilterPart *ff) -{ - return; -} - -static void -format_sexp (FilterElement *fe, GString *out) -{ - FilterFile *file = (FilterFile *) fe; - - e_sexp_encode_string (out, file->path); -} diff --git a/filter/filter-file.h b/filter/filter-file.h deleted file mode 100644 index a3e28d0b5c..0000000000 --- a/filter/filter-file.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Jeffrey Stedfast - * - * Copyright 2002 Ximian, Inc. (www.ximian.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - - -#ifndef __FILTER_FILE_H__ -#define __FILTER_FILE_H__ - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#include "filter-element.h" - -#define FILTER_TYPE_FILE (filter_file_get_type ()) -#define FILTER_FILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FILTER_TYPE_FILE, FilterFile)) -#define FILTER_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FILTER_TYPE_FILE, FilterFileClass)) -#define IS_FILTER_FILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FILTER_TYPE_FILE)) -#define IS_FILTER_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FILTER_TYPE_FILE)) -#define FILTER_FILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FILTER_TYPE_FILE, FilterFileClass)) - -typedef struct _FilterFile FilterFile; -typedef struct _FilterFileClass FilterFileClass; - -struct _FilterFile { - FilterElement parent_object; - - char *type; - char *path; -}; - -struct _FilterFileClass { - FilterElementClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - - -GType filter_file_get_type (void); - -FilterFile *filter_file_new (void); - -FilterFile *filter_file_new_type_name (const char *type); - -/* methods */ -void filter_file_set_path (FilterFile *file, const char *path); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* ! __FILTER_FILE_H__ */ diff --git a/filter/filter-filter.c b/filter/filter-filter.c deleted file mode 100644 index 6719cb9ad4..0000000000 --- a/filter/filter-filter.c +++ /dev/null @@ -1,538 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 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. - */ - - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include -#include - -#include "filter-filter.h" -#include "filter-context.h" - -#define d(x) - -static int validate(FilterRule *fr); -static int filter_eq(FilterRule *fr, FilterRule *cm); -static xmlNodePtr xml_encode (FilterRule *fr); -static int xml_decode (FilterRule *fr, xmlNodePtr, RuleContext *rc); -static void rule_copy (FilterRule *dest, FilterRule *src); -/*static void build_code(FilterRule *, GString *out);*/ -static GtkWidget *get_widget (FilterRule *fr, RuleContext *rc); - -static void filter_filter_class_init (FilterFilterClass *klass); -static void filter_filter_init (FilterFilter *ff); -static void filter_filter_finalise (GObject *obj); - - -static FilterRuleClass *parent_class = NULL; - - -GType -filter_filter_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (FilterFilterClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) filter_filter_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (FilterFilter), - 0, /* n_preallocs */ - (GInstanceInitFunc) filter_filter_init, - }; - - type = g_type_register_static (FILTER_TYPE_RULE, "FilterFilter", &info, 0); - } - - return type; -} - -static void -filter_filter_class_init (FilterFilterClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - FilterRuleClass *fr_class = (FilterRuleClass *) klass; - - parent_class = g_type_class_ref (FILTER_TYPE_RULE); - - object_class->finalize = filter_filter_finalise; - - /* override methods */ - fr_class->validate = validate; - fr_class->eq = filter_eq; - fr_class->xml_encode = xml_encode; - fr_class->xml_decode = xml_decode; - /*fr_class->build_code = build_code;*/ - fr_class->copy = rule_copy; - fr_class->get_widget = get_widget; -} - -static void -filter_filter_init (FilterFilter *ff) -{ - ; -} - -static void -unref_list (GList *l) -{ - while (l) { - g_object_unref (l->data); - l = l->next; - } -} - -static void -filter_filter_finalise (GObject *obj) -{ - FilterFilter *ff = (FilterFilter *) obj; - - unref_list (ff->actions); - g_list_free (ff->actions); - - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -/** - * filter_filter_new: - * - * Create a new FilterFilter object. - * - * Return value: A new #FilterFilter object. - **/ -FilterFilter * -filter_filter_new (void) -{ - return (FilterFilter *) g_object_new (FILTER_TYPE_FILTER, NULL, NULL); -} - -void -filter_filter_add_action (FilterFilter *fr, FilterPart *fp) -{ - fr->actions = g_list_append (fr->actions, fp); - - filter_rule_emit_changed ((FilterRule *) fr); -} - -void -filter_filter_remove_action (FilterFilter *fr, FilterPart *fp) -{ - fr->actions = g_list_remove (fr->actions, fp); - - filter_rule_emit_changed ((FilterRule *) fr); -} - -void -filter_filter_replace_action (FilterFilter *fr, FilterPart *fp, FilterPart *new) -{ - GList *l; - - l = g_list_find (fr->actions, fp); - if (l) { - l->data = new; - } else { - fr->actions = g_list_append (fr->actions, new); - } - - filter_rule_emit_changed ((FilterRule *) fr); -} - -void -filter_filter_build_action (FilterFilter *fr, GString *out) -{ - g_string_append (out, "(begin\n"); - filter_part_build_code_list (fr->actions, out); - g_string_append (out, ")\n"); -} - -static int -validate (FilterRule *fr) -{ - FilterFilter *ff = (FilterFilter *) fr; - GList *parts; - int valid; - - valid = FILTER_RULE_CLASS (parent_class)->validate (fr); - - /* validate rule actions */ - parts = ff->actions; - while (parts && valid) { - valid = filter_part_validate ((FilterPart *) parts->data); - parts = parts->next; - } - - return valid; -} - -static int -list_eq (GList *al, GList *bl) -{ - int truth = TRUE; - - while (truth && al && bl) { - FilterPart *a = al->data, *b = bl->data; - - truth = filter_part_eq (a, b); - al = al->next; - bl = bl->next; - } - - return truth && al == NULL && bl == NULL; -} - -static int -filter_eq (FilterRule *fr, FilterRule *cm) -{ - return FILTER_RULE_CLASS (parent_class)->eq (fr, cm) - && list_eq (((FilterFilter *) fr)->actions, ((FilterFilter *) cm)->actions); -} - -static xmlNodePtr -xml_encode (FilterRule *fr) -{ - FilterFilter *ff = (FilterFilter *) fr; - xmlNodePtr node, set, work; - GList *l; - - node = FILTER_RULE_CLASS (parent_class)->xml_encode (fr); - g_assert (node != NULL); - set = xmlNewNode (NULL, "actionset"); - xmlAddChild (node, set); - l = ff->actions; - while (l) { - work = filter_part_xml_encode ((FilterPart *) l->data); - xmlAddChild (set, work); - l = l->next; - } - - return node; - -} - -static void -load_set (xmlNodePtr node, FilterFilter *ff, RuleContext *rc) -{ - xmlNodePtr work; - char *rulename; - FilterPart *part; - - work = node->children; - while (work) { - if (!strcmp (work->name, "part")) { - rulename = xmlGetProp (work, "name"); - part = filter_context_find_action ((FilterContext *) rc, rulename); - if (part) { - part = filter_part_clone (part); - filter_part_xml_decode (part, work); - filter_filter_add_action (ff, part); - } else { - g_warning ("cannot find rule part '%s'\n", rulename); - } - xmlFree (rulename); - } else if (work->type == XML_ELEMENT_NODE) { - g_warning ("Unknown xml node in part: %s", work->name); - } - work = work->next; - } -} - -static int -xml_decode (FilterRule *fr, xmlNodePtr node, RuleContext *rc) -{ - FilterFilter *ff = (FilterFilter *) fr; - xmlNodePtr work; - int result; - - result = FILTER_RULE_CLASS (parent_class)->xml_decode (fr, node, rc); - if (result != 0) - return result; - - work = node->children; - while (work) { - if (!strcmp (work->name, "actionset")) { - load_set (work, ff, rc); - } - work = work->next; - } - - return 0; -} - -static void -rule_copy (FilterRule *dest, FilterRule *src) -{ - FilterFilter *fdest, *fsrc; - GList *node; - - fdest = (FilterFilter *) dest; - fsrc = (FilterFilter *) src; - - if (fdest->actions) { - g_list_foreach (fdest->actions, (GFunc) g_object_unref, NULL); - g_list_free (fdest->actions); - fdest->actions = NULL; - } - - node = fsrc->actions; - while (node) { - FilterPart *part = node->data; - - g_object_ref (part); - fdest->actions = g_list_append (fdest->actions, part); - node = node->next; - } - - FILTER_RULE_CLASS (parent_class)->copy (dest, src); -} - -/*static void build_code(FilterRule *fr, GString *out) -{ - return FILTER_RULE_CLASS (parent_class)->build_code (fr, out); -}*/ - -struct _part_data { - FilterRule *fr; - FilterContext *f; - FilterPart *part; - GtkWidget *partwidget, *container; -}; - -static void -option_activate (GtkMenuItem *item, struct _part_data *data) -{ - FilterPart *part = g_object_get_data ((GObject *) item, "part"); - FilterPart *newpart; - - /* dont update if we haven't changed */ - if (!strcmp (part->title, data->part->title)) - return; - - /* here we do a widget shuffle, throw away the old widget/rulepart, - and create another */ - if (data->partwidget) - gtk_container_remove (GTK_CONTAINER (data->container), data->partwidget); - - newpart = filter_part_clone (part); - filter_part_copy_values (newpart, data->part); - filter_filter_replace_action ((FilterFilter *) data->fr, data->part, newpart); - g_object_unref (data->part); - data->part = newpart; - data->partwidget = filter_part_get_widget (newpart); - if (data->partwidget) - gtk_box_pack_start (GTK_BOX (data->container), data->partwidget, FALSE, FALSE, 0); - - g_object_set_data ((GObject *) data->container, "part", newpart); -} - -static GtkWidget * -get_rule_part_widget (FilterContext *f, FilterPart *newpart, FilterRule *fr) -{ - FilterPart *part = NULL; - GtkWidget *menu; - GtkWidget *item; - GtkWidget *omenu; - GtkWidget *hbox; - GtkWidget *p; - int index = 0, current = 0; - struct _part_data *data; - - data = g_malloc0 (sizeof (*data)); - data->fr = fr; - data->f = f; - data->part = newpart; - - hbox = gtk_hbox_new (FALSE, 0); - p = filter_part_get_widget (newpart); - - data->partwidget = p; - data->container = hbox; - - menu = gtk_menu_new (); - while ((part = filter_context_next_action (f, part))) { - item = gtk_menu_item_new_with_label (_(part->title)); - - g_object_set_data ((GObject *) item, "part", part); - g_signal_connect (item, "activate", G_CALLBACK (option_activate), data); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); - gtk_widget_show (item); - - if (!strcmp (newpart->title, part->title)) - current = index; - - index++; - } - - omenu = gtk_option_menu_new (); - gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu); - gtk_option_menu_set_history (GTK_OPTION_MENU (omenu), current); - gtk_widget_show (omenu); - - gtk_box_pack_start (GTK_BOX (hbox), omenu, FALSE, FALSE, 0); - if (p) - gtk_box_pack_start (GTK_BOX (hbox), p, FALSE, FALSE, 0); - - gtk_widget_show_all (hbox); - - return hbox; -} - -struct _rule_data { - FilterRule *fr; - FilterContext *f; - GtkWidget *parts; -}; - -static void -less_parts (GtkWidget *button, struct _rule_data *data) -{ - FilterPart *part; - GtkWidget *rule; - GList *l; - - l = ((FilterFilter *) data->fr)->actions; - if (g_list_length (l) < 2) - return; - - rule = g_object_get_data ((GObject *) button, "rule"); - part = g_object_get_data ((GObject *) rule, "part"); - - /* remove the part from the list */ - filter_filter_remove_action ((FilterFilter *) data->fr, part); - g_object_unref (part); - - /* and from the display */ - gtk_container_remove (GTK_CONTAINER (data->parts), rule); - gtk_container_remove (GTK_CONTAINER (data->parts), button); -} - -static void -attach_rule (GtkWidget *rule, struct _rule_data *data, FilterPart *part, int row) -{ - GtkWidget *remove; - - gtk_table_attach (GTK_TABLE (data->parts), rule, 0, 1, row, row + 1, - GTK_EXPAND | GTK_FILL, 0, 0, 0); - - remove = gtk_button_new_from_stock (GTK_STOCK_REMOVE); - g_object_set_data ((GObject *) remove, "rule", rule); - g_object_set_data ((GObject *) rule, "part", part); - /*gtk_button_set_relief (GTK_BUTTON (remove), GTK_RELIEF_NONE);*/ - g_signal_connect (remove, "clicked", G_CALLBACK (less_parts), data); - gtk_table_attach (GTK_TABLE (data->parts), remove, 1, 2, row, row + 1, - 0, 0, 0, 0); - gtk_widget_show (remove); -} - -static void -more_parts (GtkWidget *button, struct _rule_data *data) -{ - FilterPart *new; - - /* create a new rule entry, use the first type of rule */ - new = filter_context_next_action ((FilterContext *) data->f, NULL); - if (new) { - GtkWidget *w; - guint16 rows; - - new = filter_part_clone (new); - filter_filter_add_action ((FilterFilter *) data->fr, new); - w = get_rule_part_widget (data->f, new, data->fr); - - rows = GTK_TABLE (data->parts)->nrows; - gtk_table_resize (GTK_TABLE (data->parts), rows + 1, 2); - attach_rule (w, data, new, rows); - } -} - -static GtkWidget * -get_widget (FilterRule *fr, RuleContext *rc) -{ - GtkWidget *widget, *hbox, *add, *frame; - GtkWidget *parts, *inframe, *w; - GtkWidget *scrolledwindow; - GtkObject *hadj, *vadj; - GList *l; - FilterPart *part; - struct _rule_data *data; - FilterFilter *ff = (FilterFilter *)fr; - int rows, i = 0; - - widget = FILTER_RULE_CLASS (parent_class)->get_widget (fr, rc); - - /* and now for the action area */ - frame = gtk_frame_new (_("Then")); - inframe = gtk_vbox_new (FALSE, 3); - gtk_container_add (GTK_CONTAINER (frame), inframe); - gtk_container_set_border_width (GTK_CONTAINER (inframe), 6); - - rows = g_list_length (ff->actions); - parts = gtk_table_new (rows, 2, FALSE); - data = g_malloc0 (sizeof (*data)); - data->f = (FilterContext *) rc; - data->fr = fr; - data->parts = parts; - - hbox = gtk_hbox_new (FALSE, 3); - - add = gtk_button_new_from_stock (GTK_STOCK_ADD); - /* gtk_button_set_relief (GTK_BUTTON (add), GTK_RELIEF_NONE); */ - g_signal_connect (add, "clicked", G_CALLBACK (more_parts), data); - gtk_box_pack_start (GTK_BOX (hbox), add, FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX (inframe), hbox, FALSE, FALSE, 3); - - l = ff->actions; - while (l) { - part = l->data; - d(printf ("adding action %s\n", part->title)); - w = get_rule_part_widget ((FilterContext *) rc, part, fr); - attach_rule (w, data, part, i++); - l = l->next; - } - - hadj = gtk_adjustment_new (0.0, 0.0, 1.0, 1.0 ,1.0, 1.0); - vadj = gtk_adjustment_new (0.0, 0.0, 1.0, 1.0 ,1.0, 1.0); - scrolledwindow = gtk_scrolled_window_new (GTK_ADJUSTMENT (hadj), GTK_ADJUSTMENT (vadj)); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - - gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolledwindow), parts); - - gtk_box_pack_start (GTK_BOX (inframe), scrolledwindow, TRUE, TRUE, 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 1fcff3fa3a..0000000000 --- a/filter/filter-filter.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 Ximian Inc. - * - * Authors: Not Zed - * 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. - */ - - -#ifndef _FILTER_FILTER_H -#define _FILTER_FILTER_H - -#include "filter-rule.h" - -#define FILTER_TYPE_FILTER (filter_filter_get_type ()) -#define FILTER_FILTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FILTER_TYPE_FILTER, FilterFilter)) -#define FILTER_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FILTER_TYPE_FILTER, FilterFilterClass)) -#define IS_FILTER_FILTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FILTER_TYPE_FILTER)) -#define IS_FILTER_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FILTER_TYPE_FILTER)) -#define FILTER_FILTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FILTER_TYPE_FILTER, FilterFilterClass)) - -typedef struct _FilterFilter FilterFilter; -typedef struct _FilterFilterClass FilterFilterClass; - -struct _FilterFilter { - FilterRule parent_object; - - GList *actions; -}; - -struct _FilterFilterClass { - FilterRuleClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - -GType filter_filter_get_type (void); -FilterFilter *filter_filter_new (void); - -/* methods */ -void filter_filter_add_action (FilterFilter *fr, FilterPart *fp); -void filter_filter_remove_action (FilterFilter *fr, FilterPart *fp); -void filter_filter_replace_action (FilterFilter *fr, FilterPart *fp, FilterPart *new); - -void filter_filter_build_action (FilterFilter *fr, GString *out); - -#endif /* ! _FILTER_FILTER_H */ diff --git a/filter/filter-folder.c b/filter/filter-folder.c deleted file mode 100644 index e074c31f6c..0000000000 --- a/filter/filter-folder.c +++ /dev/null @@ -1,265 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 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. - */ - - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include -#include - -#include "filter-folder.h" -#include "shell/evolution-folder-selector-button.h" -#include "e-util/e-sexp.h" - -#define d(x) - -static gboolean validate (FilterElement *fe); -static int folder_eq (FilterElement *fe, FilterElement *cm); -static void xml_create (FilterElement *fe, xmlNodePtr node); -static xmlNodePtr xml_encode (FilterElement *fe); -static int xml_decode (FilterElement *fe, xmlNodePtr node); -static GtkWidget *get_widget (FilterElement *fe); -static void build_code (FilterElement *fe, GString *out, struct _FilterPart *ff); -static void format_sexp (FilterElement *, GString *); - -static void filter_folder_class_init (FilterFolderClass *class); -static void filter_folder_init (FilterFolder *ff); -static void filter_folder_finalise (GObject *obj); - - -static FilterElementClass *parent_class = NULL; - - -extern EvolutionShellClient *global_shell_client; - - -GType -filter_folder_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (FilterFolderClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) filter_folder_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (FilterFolder), - 0, /* n_preallocs */ - (GInstanceInitFunc) filter_folder_init, - }; - - type = g_type_register_static (FILTER_TYPE_ELEMENT, "FilterFolder", &info, 0); - } - - return type; -} - -static void -filter_folder_class_init (FilterFolderClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - FilterElementClass *fe_class = FILTER_ELEMENT_CLASS (klass); - - parent_class = g_type_class_ref (FILTER_TYPE_ELEMENT); - - object_class->finalize = filter_folder_finalise; - - /* override methods */ - fe_class->validate = validate; - fe_class->eq = folder_eq; - fe_class->xml_create = xml_create; - fe_class->xml_encode = xml_encode; - fe_class->xml_decode = xml_decode; - fe_class->get_widget = get_widget; - fe_class->build_code = build_code; - fe_class->format_sexp = format_sexp; -} - -static void -filter_folder_init (FilterFolder *ff) -{ - ; -} - -static void -filter_folder_finalise (GObject *obj) -{ - FilterFolder *ff = (FilterFolder *) obj; - - g_free (ff->uri); - - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -/** - * filter_folder_new: - * - * Create a new FilterFolder object. - * - * Return value: A new #FilterFolder object. - **/ -FilterFolder * -filter_folder_new (void) -{ - return (FilterFolder *) g_object_new (FILTER_TYPE_FOLDER, NULL, NULL); -} - -void -filter_folder_set_value (FilterFolder *ff, const char *uri) -{ - g_free (ff->uri); - ff->uri = g_strdup (uri); -} - -static gboolean -validate (FilterElement *fe) -{ - FilterFolder *ff = (FilterFolder *) fe; - GtkWidget *dialog; - - if (ff->uri && *ff->uri) { - return TRUE; - } else { - /* FIXME: FilterElement should probably have a - GtkWidget member pointing to the value gotten with - ::get_widget() so that we can get the parent window - here. */ - dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, - "%s", _("You must specify a folder.")); - - gtk_dialog_run ((GtkDialog *) dialog); - gtk_widget_destroy (dialog); - - return FALSE; - } -} - -static int -folder_eq (FilterElement *fe, FilterElement *cm) -{ - return FILTER_ELEMENT_CLASS (parent_class)->eq (fe, cm) - && strcmp(((FilterFolder *)fe)->uri, ((FilterFolder *)cm)->uri) == 0; -} - -static void -xml_create (FilterElement *fe, xmlNodePtr node) -{ - /* parent implementation */ - FILTER_ELEMENT_CLASS (parent_class)->xml_create (fe, node); -} - -static xmlNodePtr -xml_encode (FilterElement *fe) -{ - xmlNodePtr value, work; - FilterFolder *ff = (FilterFolder *)fe; - - d(printf ("Encoding folder as xml\n")); - - value = xmlNewNode (NULL, "value"); - xmlSetProp (value, "name", fe->name); - xmlSetProp (value, "type", "folder"); - - work = xmlNewChild (value, NULL, "folder", NULL); - xmlSetProp (work, "uri", ff->uri); - - return value; -} - -static int -xml_decode (FilterElement *fe, xmlNodePtr node) -{ - FilterFolder *ff = (FilterFolder *)fe; - xmlNodePtr n; - - d(printf ("Decoding folder from xml %p\n", fe)); - - xmlFree (fe->name); - fe->name = xmlGetProp (node, "name"); - - n = node->children; - while (n) { - if (!strcmp (n->name, "folder")) { - char *uri; - - uri = xmlGetProp (n, "uri"); - g_free (ff->uri); - ff->uri = g_strdup (uri); - xmlFree (uri); - break; - } - n = n->next; - } - - return 0; -} - -static void -folder_selected (EvolutionFolderSelectorButton *button, - GNOME_Evolution_Folder *folder, - FilterFolder *ff) -{ - g_free (ff->uri); - ff->uri = g_strdup (folder->physicalUri); - - gdk_window_raise (GTK_WIDGET (gtk_widget_get_ancestor (GTK_WIDGET (button), GTK_TYPE_WINDOW))->window); -} - -static GtkWidget * -get_widget (FilterElement *fe) -{ - static const char *allowed_types[] = { "mail/*", NULL }; - FilterFolder *ff = (FilterFolder *)fe; - GtkWidget *button; - - button = evolution_folder_selector_button_new (global_shell_client, - _("Select Folder"), - ff->uri, - allowed_types); - - gtk_widget_show (button); - g_signal_connect (button, "selected", G_CALLBACK (folder_selected), ff); - - return button; -} - -static void -build_code (FilterElement *fe, GString *out, struct _FilterPart *ff) -{ - return; -} - -static void -format_sexp (FilterElement *fe, GString *out) -{ - FilterFolder *ff = (FilterFolder *)fe; - - e_sexp_encode_string (out, ff->uri); -} diff --git a/filter/filter-folder.h b/filter/filter-folder.h deleted file mode 100644 index 0e541a580b..0000000000 --- a/filter/filter-folder.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 Ximian Inc. - * - * Authors: Not Zed - * 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. - */ - - -#ifndef _FILTER_FOLDER_H -#define _FILTER_FOLDER_H - -#include "filter-element.h" - -#define FILTER_TYPE_FOLDER (filter_folder_get_type ()) -#define FILTER_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FILTER_TYPE_FOLDER, FilterFolder)) -#define FILTER_FOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FILTER_TYPE_FOLDER, FilterFolderClass)) -#define IS_FILTER_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FILTER_TYPE_FOLDER)) -#define IS_FILTER_FOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FILTER_TYPE_FOLDER)) -#define FILTER_FOLDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FILTER_TYPE_FOLDER, FilterFolderClass)) - -typedef struct _FilterFolder FilterFolder; -typedef struct _FilterFolderClass FilterFolderClass; - -struct _FilterFolder { - FilterElement parent_object; - - char *uri; -}; - -struct _FilterFolderClass { - FilterElementClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - -GType filter_folder_get_type (void); -FilterFolder *filter_folder_new (void); - -/* methods */ -void filter_folder_set_value (FilterFolder *ff, const char *uri); - -#endif /* ! _FILTER_FOLDER_H */ diff --git a/filter/filter-input.c b/filter/filter-input.c deleted file mode 100644 index a43156b802..0000000000 --- a/filter/filter-input.c +++ /dev/null @@ -1,353 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 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. - */ - - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include - -#include -#include - -#include "filter-input.h" -#include "e-util/e-sexp.h" - -#define d(x) - -static gboolean validate (FilterElement *fe); -static int input_eq (FilterElement *fe, FilterElement *cm); -static void xml_create (FilterElement *fe, xmlNodePtr node); -static xmlNodePtr xml_encode (FilterElement *fe); -static int xml_decode (FilterElement *fe, xmlNodePtr node); -static GtkWidget *get_widget (FilterElement *fe); -static void build_code (FilterElement *fe, GString *out, struct _FilterPart *ff); -static void format_sexp (FilterElement *, GString *); - -static void filter_input_class_init (FilterInputClass *klass); -static void filter_input_init (FilterInput *fi); -static void filter_input_finalise (GObject *obj); - - -static FilterElementClass *parent_class = NULL; - - -GType -filter_input_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (FilterInputClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) filter_input_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (FilterInput), - 0, /* n_preallocs */ - (GInstanceInitFunc) filter_input_init, - }; - - type = g_type_register_static (FILTER_TYPE_ELEMENT, "FilterInput", &info, 0); - } - - return type; -} - -static void -filter_input_class_init (FilterInputClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - FilterElementClass *fe_class = FILTER_ELEMENT_CLASS (klass); - - parent_class = g_type_class_ref (FILTER_TYPE_ELEMENT); - - object_class->finalize = filter_input_finalise; - - /* override methods */ - fe_class->validate = validate; - fe_class->eq = input_eq; - fe_class->xml_create = xml_create; - fe_class->xml_encode = xml_encode; - fe_class->xml_decode = xml_decode; - fe_class->get_widget = get_widget; - fe_class->build_code = build_code; - fe_class->format_sexp = format_sexp; -} - -static void -filter_input_init (FilterInput *fi) -{ - ; -} - -static void -filter_input_finalise (GObject *obj) -{ - FilterInput *fi = (FilterInput *) obj; - - xmlFree (fi->type); - g_list_foreach (fi->values, (GFunc)g_free, NULL); - g_list_free (fi->values); - - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -/** - * filter_input_new: - * - * Create a new FilterInput object. - * - * Return value: A new #FilterInput object. - **/ -FilterInput * -filter_input_new (void) -{ - return (FilterInput *) g_object_new (FILTER_TYPE_INPUT, NULL, NULL); -} - -FilterInput * -filter_input_new_type_name (const char *type) -{ - FilterInput *fi; - - fi = filter_input_new (); - fi->type = xmlStrdup (type); - - d(printf("new type %s = %p\n", type, fi)); - - return fi; -} - -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; - GtkWidget *dialog; - - if (fi->values && !strcmp (fi->type, "regex")) { - const char *pattern; - regex_t regexpat; - int regerr; - - pattern = fi->values->data; - - if ((regerr = regcomp (®expat, pattern, REG_EXTENDED | REG_NEWLINE | REG_ICASE))) { - size_t reglen; - char *regmsg; - - /* 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); - - /* FIXME: FilterElement should probably have a - GtkWidget member pointing to the value gotten with - ::get_widget() so that we can get the parent window - here. */ - dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, - _("Error in regular expression '%s':\n%s"), - pattern, regmsg); - - gtk_dialog_run ((GtkDialog *) dialog); - gtk_widget_destroy (dialog); - g_free (regmsg); - - valid = FALSE; - } - - regfree (®expat); - } - - return valid; -} - -static int -list_eq (GList *al, GList *bl) -{ - int truth = TRUE; - - while (truth && al && bl) { - truth = strcmp ((char *) al->data, (char *) bl->data) == 0; - al = al->next; - bl = bl->next; - } - - return truth && al == NULL && bl == NULL; -} - -static int -input_eq (FilterElement *fe, FilterElement *cm) -{ - FilterInput *fi = (FilterInput *)fe, *ci = (FilterInput *)cm; - - return FILTER_ELEMENT_CLASS (parent_class)->eq (fe, cm) - && strcmp (fi->type, ci->type) == 0 - && list_eq (fi->values, ci->values); -} - -static void -xml_create (FilterElement *fe, xmlNodePtr node) -{ - /* parent implementation */ - FILTER_ELEMENT_CLASS (parent_class)->xml_create (fe, node); -} - -static xmlNodePtr -xml_encode (FilterElement *fe) -{ - xmlNodePtr value; - GList *l; - FilterInput *fi = (FilterInput *)fe; - char *type; - - type = fi->type ? fi->type : "string"; - - d(printf ("Encoding %s as xml\n", type)); - - value = xmlNewNode (NULL, "value"); - xmlSetProp (value, "name", fe->name); - xmlSetProp (value, "type", type); - l = fi->values; - while (l) { - xmlNodePtr cur; - char *str = l->data; - - cur = xmlNewChild (value, NULL, type, NULL); - xmlNodeSetContent (cur, str); - l = l->next; - } - - 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->children; - while (n) { - if (!strcmp (n->name, type)) { - if (!(str = xmlNodeGetContent (n))) - str = xmlStrdup (""); - - d(printf (" '%s'\n", str)); - fi->values = g_list_append (fi->values, g_strdup (str)); - xmlFree (str); - } else if (n->type == XML_ELEMENT_NODE) { - 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) -{ - FilterInput *fi = (FilterInput *) fe; - const char *new; - GList *l; - - new = gtk_entry_get_text (entry); - - /* NOTE: entry only supports a single value ... */ - l = fi->values; - while (l) { - g_free (l->data); - l = l->next; - } - - g_list_free (fi->values); - - fi->values = g_list_append (NULL, g_strdup (new)); -} - -static GtkWidget * -get_widget (FilterElement *fe) -{ - GtkWidget *entry; - FilterInput *fi = (FilterInput *)fe; - - entry = gtk_entry_new (); - if (fi->values && fi->values->data) - gtk_entry_set_text (GTK_ENTRY (entry), (const char *) fi->values->data); - - g_signal_connect (entry, "changed", G_CALLBACK (entry_changed), fe); - - return entry; -} - -static void -build_code (FilterElement *fe, GString *out, struct _FilterPart *ff) -{ - ; -} - -static void -format_sexp (FilterElement *fe, GString *out) -{ - FilterInput *fi = (FilterInput *) fe; - GList *l; - - l = fi->values; - while (l) { - e_sexp_encode_string (out, l->data); - l = l->next; - } -} diff --git a/filter/filter-input.h b/filter/filter-input.h deleted file mode 100644 index 7a7b4761de..0000000000 --- a/filter/filter-input.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 Ximian Inc. - * - * Authors: Not Zed - * 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. - */ - - -#ifndef _FILTER_INPUT_H -#define _FILTER_INPUT_H - -#include "filter-element.h" - -#define FILTER_TYPE_INPUT (filter_input_get_type ()) -#define FILTER_INPUT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FILTER_TYPE_INPUT, FilterInput)) -#define FILTER_INPUT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FILTER_TYPE_INPUT, FilterInputClass)) -#define IS_FILTER_INPUT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FILTER_TYPE_INPUT)) -#define IS_FILTER_INPUT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FILTER_TYPE_INPUT)) -#define FILTER_INPUT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FILTER_TYPE_INPUT, FilterInputClass)) - -typedef struct _FilterInput FilterInput; -typedef struct _FilterInputClass FilterInputClass; - -struct _FilterInput { - FilterElement parent_object; - - char *type; /* name of type */ - GList *values; /* strings */ -}; - -struct _FilterInputClass { - FilterElementClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - -GType 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 17f568c766..0000000000 --- a/filter/filter-int.c +++ /dev/null @@ -1,254 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Jeffrey Stedfast - * - * Copyright 2002 Ximian, Inc. (www.ximian.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include - -#include "e-util/e-sexp.h" -#include "filter-int.h" - -#define d(x) - -static int int_eq (FilterElement *fe, FilterElement *cm); -static void xml_create (FilterElement *fe, xmlNodePtr node); -static xmlNodePtr xml_encode (FilterElement *fe); -static int xml_decode (FilterElement *fe, xmlNodePtr node); -static GtkWidget *get_widget (FilterElement *fe); -static void build_code (FilterElement *fe, GString *out, struct _FilterPart *ff); -static void format_sexp (FilterElement *fe, GString *out); - -static void filter_int_class_init (FilterIntClass *klass); -static void filter_int_init (FilterInt *fi); -static void filter_int_finalise (GObject *obj); - - -static FilterElementClass *parent_class; - - -GType -filter_int_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (FilterIntClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) filter_int_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (FilterInt), - 0, /* n_preallocs */ - (GInstanceInitFunc) filter_int_init, - }; - - type = g_type_register_static (FILTER_TYPE_ELEMENT, "FilterInt", &info, 0); - } - - return type; -} - -static void -filter_int_class_init (FilterIntClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - FilterElementClass *fe_class = FILTER_ELEMENT_CLASS (klass); - - parent_class = g_type_class_ref (FILTER_TYPE_ELEMENT); - - object_class->finalize = filter_int_finalise; - - /* override methods */ - fe_class->eq = int_eq; - fe_class->xml_create = xml_create; - fe_class->xml_encode = xml_encode; - fe_class->xml_decode = xml_decode; - fe_class->get_widget = get_widget; - fe_class->build_code = build_code; - fe_class->format_sexp = format_sexp; -} - -static void -filter_int_init (FilterInt *fi) -{ - fi->min = 0; - fi->max = G_MAXINT; -} - -static void -filter_int_finalise (GObject *obj) -{ - FilterInt *fi = (FilterInt *) obj; - - g_free (fi->type); - - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -/** - * filter_int_new: - * - * Create a new FilterInt object. - * - * Return value: A new #FilterInt object. - **/ -FilterInt * -filter_int_new (void) -{ - return (FilterInt *) g_object_new (FILTER_TYPE_INT, NULL, NULL); -} - -FilterInt * -filter_int_new_type (const char *type, int min, int max) -{ - FilterInt *fi; - - fi = filter_int_new (); - - fi->type = g_strdup (type); - fi->min = min; - fi->max = max; - - return fi; -} - -void -filter_int_set_value (FilterInt *fi, int val) -{ - fi->val = val; -} - -static int -int_eq (FilterElement *fe, FilterElement *cm) -{ - return FILTER_ELEMENT_CLASS (parent_class)->eq (fe, cm) - && ((FilterInt *)fe)->val == ((FilterInt *)cm)->val; -} - -static void -xml_create (FilterElement *fe, xmlNodePtr node) -{ - /* parent implementation */ - FILTER_ELEMENT_CLASS (parent_class)->xml_create (fe, node); -} - -static xmlNodePtr -xml_encode (FilterElement *fe) -{ - xmlNodePtr value; - FilterInt *fs = (FilterInt *)fe; - char intval[32]; - const char *type; - - type = fs->type?fs->type:"integer"; - - d(printf("Encoding %s as xml\n", type)); - - value = xmlNewNode (NULL, "value"); - xmlSetProp (value, "name", fe->name); - xmlSetProp (value, "type", type); - - sprintf(intval, "%d", fs->val); - xmlSetProp (value, type, intval); - - return value; -} - -static int -xml_decode (FilterElement *fe, xmlNodePtr node) -{ - FilterInt *fs = (FilterInt *)fe; - char *name, *type; - 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; - - type = xmlGetProp(node, "type"); - d(printf ("Type = %s\n", type)); - g_free(fs->type); - fs->type = g_strdup(type); - xmlFree(type); - - intval = xmlGetProp (node, fs->type ? fs->type : "integer"); - if (intval) { - d(printf ("Value = %s\n", intval)); - fs->val = atoi (intval); - xmlFree (intval); - } else { - d(printf ("Value = ?unknown?\n")); - 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, (gfloat)fs->min, (gfloat)fs->max, 1.0, 1.0, 1.0); - spin = gtk_spin_button_new (GTK_ADJUSTMENT (adjustment), fs->max>fs->min+1000?5.0:1.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); - - g_signal_connect (spin, "changed", G_CALLBACK (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_printf (out, "%d", fs->val); -} diff --git a/filter/filter-int.h b/filter/filter-int.h deleted file mode 100644 index caba992958..0000000000 --- a/filter/filter-int.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Jeffrey Stedfast - * - * Copyright 2002 Ximian, Inc. (www.ximian.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - - -#ifndef _FILTER_INT_H -#define _FILTER_INT_H - -#include "filter-element.h" - -#define FILTER_TYPE_INT (filter_int_get_type ()) -#define FILTER_INT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FILTER_TYPE_INT, FilterInt)) -#define FILTER_INT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FILTER_TYPE_INT, FilterIntClass)) -#define IS_FILTER_INT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FILTER_TYPE_INT)) -#define IS_FILTER_INT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FILTER_TYPE_INT)) -#define FILTER_INT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FILTER_TYPE_INT, FilterIntClass)) - -typedef struct _FilterInt FilterInt; -typedef struct _FilterIntClass FilterIntClass; - -struct _FilterInt { - FilterElement parent_object; - - char *type; - int val; - int min; - int max; -}; - -struct _FilterIntClass { - FilterElementClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - -GType filter_int_get_type (void); -FilterInt *filter_int_new (void); -FilterInt *filter_int_new_type (const char *type, int min, int max); -void filter_int_set_value (FilterInt *fi, int val); - -/* methods */ - -#endif /* ! _FILTER_INT_H */ diff --git a/filter/filter-label.c b/filter/filter-label.c deleted file mode 100644 index 2e8e8d787c..0000000000 --- a/filter/filter-label.c +++ /dev/null @@ -1,182 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Jeffrey Stedfast - * Michael Zucchi - * - * Copyright 2002 Ximian, Inc. (www.ximian.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "filter-label.h" -#include "e-util/e-sexp.h" - -#define d(x) - -static void xml_create (FilterElement *fe, xmlNodePtr node); - -static void filter_label_class_init (FilterLabelClass *klass); -static void filter_label_init (FilterLabel *label); -static void filter_label_finalise (GObject *obj); - - -static FilterElementClass *parent_class; - - -GType -filter_label_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (FilterLabelClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) filter_label_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (FilterLabel), - 0, /* n_preallocs */ - (GInstanceInitFunc) filter_label_init, - }; - - type = g_type_register_static (FILTER_TYPE_OPTION, "FilterLabel", &info, 0); - } - - return type; -} - -static void -filter_label_class_init (FilterLabelClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - FilterElementClass *fe_class = FILTER_ELEMENT_CLASS (klass); - - parent_class = g_type_class_ref (FILTER_TYPE_OPTION); - - object_class->finalize = filter_label_finalise; - - /* override methods */ - fe_class->xml_create = xml_create; -} - -static void -filter_label_init (FilterLabel *fl) -{ - ((FilterOption *) fl)->type = "label"; -} - -static void -filter_label_finalise (GObject *obj) -{ - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -/** - * filter_label_new: - * - * Create a new FilterLabel object. - * - * Return value: A new #FilterLabel object. - **/ -FilterLabel * -filter_label_new (void) -{ - return (FilterLabel *) g_object_new (FILTER_TYPE_LABEL, NULL, NULL); -} - -static struct { - char *title; - char *value; -} labels[] = { - { N_("Important"), "important" }, - { N_("Work"), "work" }, - { N_("Personal"), "personal" }, - { N_("To Do"), "todo" }, - { N_("Later"), "later" }, -}; - -int filter_label_count (void) -{ - return sizeof (labels) / sizeof (labels[0]); -} - -const char * -filter_label_label (int i) -{ - if (i < 0 || i >= sizeof (labels) / sizeof (labels[0])) - return NULL; - else - return labels[i].value; -} - -int -filter_label_index (const char *label) -{ - int i; - - for (i = 0; i < sizeof (labels) / sizeof (labels[0]); i++) { - if (strcmp (labels[i].value, label) == 0) - return i; - } - - return -1; -} - -static void -xml_create (FilterElement *fe, xmlNodePtr node) -{ - FilterOption *fo = (FilterOption *) fe; - GConfClient *gconf; - GSList *list, *l; - char *title, *p; - int i = 0; - - FILTER_ELEMENT_CLASS (parent_class)->xml_create (fe, node); - - gconf = gconf_client_get_default (); - - l = list = gconf_client_get_list (gconf, "/apps/evolution/mail/labels", GCONF_VALUE_STRING, NULL); - while (l != NULL) { - title = (char *) l->data; - if ((p = strrchr (title, ':'))) - *p++ = '\0'; - - filter_option_add (fo, i < 5 ? labels[i++].value : (p ? p : "#ffffff"), title, NULL); - g_free (title); - - l = l->next; - } - g_slist_free (list); - - g_object_unref (gconf); -} diff --git a/filter/filter-label.h b/filter/filter-label.h deleted file mode 100644 index 395ce07d48..0000000000 --- a/filter/filter-label.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Jeffrey Stedfast - * - * Copyright 2002 Ximian, Inc. (www.ximian.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - - -#ifndef __FILTER_LABEL__ -#define __FILTER_LABEL__ - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#include "filter-option.h" - -#define FILTER_TYPE_LABEL (filter_label_get_type ()) -#define FILTER_LABEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FILTER_TYPE_LABEL, FilterLabel)) -#define FILTER_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FILTER_TYPE_LABEL, FilterLabelClass)) -#define IS_FILTER_LABEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FILTER_TYPE_LABEL)) -#define IS_FILTER_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FILTER_TYPE_LABEL)) -#define FILTER_LABEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FILTER_TYPE_LABEL, FilterLabelClass)) - -typedef struct _FilterLabel FilterLabel; -typedef struct _FilterLabelClass FilterLabelClass; - -struct _FilterLabel { - FilterOption parent_object; - -}; - -struct _FilterLabelClass { - FilterOptionClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - -GType filter_label_get_type (void); - -FilterLabel *filter_label_new (void); - -/* Sigh, this is a mess, but its cleaner than the original mess */ -int filter_label_count(void); -const char *filter_label_label(int i); -int filter_label_index(const char *label); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __FILTER_LABEL__ */ diff --git a/filter/filter-marshal.list b/filter/filter-marshal.list deleted file mode 100644 index 9d6744db44..0000000000 --- a/filter/filter-marshal.list +++ /dev/null @@ -1,2 +0,0 @@ -NONE:NONE -NONE:POINTER diff --git a/filter/filter-option.c b/filter/filter-option.c deleted file mode 100644 index 249e79c98b..0000000000 --- a/filter/filter-option.c +++ /dev/null @@ -1,367 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 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. - */ - - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include -#include - -#include "filter-option.h" -#include "filter-part.h" -#include "e-util/e-sexp.h" - -#define d(x) - -static int option_eq (FilterElement *fe, FilterElement *cm); -static void xml_create (FilterElement *fe, xmlNodePtr node); -static xmlNodePtr xml_encode (FilterElement *fe); -static int xml_decode (FilterElement *fe, xmlNodePtr node); -static FilterElement *clone (FilterElement *fe); -static GtkWidget *get_widget (FilterElement *fe); -static void build_code (FilterElement *fe, GString *out, struct _FilterPart *ff); -static void format_sexp (FilterElement *, GString *); - -static void filter_option_class_init (FilterOptionClass *klass); -static void filter_option_init (FilterOption *fo); -static void filter_option_finalise (GObject *obj); - - -static FilterElementClass *parent_class; - - -GType -filter_option_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (FilterOptionClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) filter_option_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (FilterOption), - 0, /* n_preallocs */ - (GInstanceInitFunc) filter_option_init, - }; - - type = g_type_register_static (FILTER_TYPE_ELEMENT, "FilterOption", &info, 0); - } - - return type; -} - -static void -filter_option_class_init (FilterOptionClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - FilterElementClass *fe_class = FILTER_ELEMENT_CLASS (klass); - - parent_class = g_type_class_ref (FILTER_TYPE_ELEMENT); - - object_class->finalize = filter_option_finalise; - - /* override methods */ - fe_class->eq = option_eq; - fe_class->xml_create = xml_create; - fe_class->xml_encode = xml_encode; - fe_class->xml_decode = xml_decode; - fe_class->clone = clone; - fe_class->get_widget = get_widget; - fe_class->build_code = build_code; - fe_class->format_sexp = format_sexp; -} - -static void -filter_option_init (FilterOption *fo) -{ - fo->type = "option"; -} - -static void -free_option (struct _filter_option *o, void *data) -{ - g_free (o->title); - g_free (o->value); - g_free (o->code); - g_free (o); -} - -static void -filter_option_finalise (GObject *obj) -{ - FilterOption *fo = (FilterOption *) obj; - - g_list_foreach (fo->options, (GFunc)free_option, NULL); - g_list_free (fo->options); - - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -/** - * filter_option_new: - * - * Create a new FilterOption object. - * - * Return value: A new #FilterOption object. - **/ -FilterOption * -filter_option_new (void) -{ - return (FilterOption *) g_object_new (FILTER_TYPE_OPTION, NULL, NULL); -} - -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); -} - -/* used by implementers to add additional options */ -void -filter_option_add(FilterOption *fo, const char *value, const char *title, const char *code) -{ - struct _filter_option *op; - - g_assert(IS_FILTER_OPTION(fo)); - g_return_if_fail(find_option(fo, value) == NULL); - - op = g_malloc(sizeof(*op)); - op->title = g_strdup(title); - op->value = g_strdup(value); - op->code = g_strdup(code); - - fo->options = g_list_append(fo->options, op); - if (fo->current == NULL) - fo->current = op; -} - -static int -option_eq(FilterElement *fe, FilterElement *cm) -{ - FilterOption *fo = (FilterOption *)fe, *co = (FilterOption *)cm; - - return FILTER_ELEMENT_CLASS (parent_class)->eq (fe, cm) - && ((fo->current && co->current && strcmp(fo->current->value, co->current->value) == 0) - || (fo->current == NULL && co->current == NULL)); -} - -static void -xml_create (FilterElement *fe, xmlNodePtr node) -{ - FilterOption *fo = (FilterOption *)fe; - xmlNodePtr n, work; - - /* parent implementation */ - FILTER_ELEMENT_CLASS (parent_class)->xml_create (fe, node); - - n = node->children; - while (n) { - if (!strcmp (n->name, "option")) { - char *tmp, *value, *title = NULL, *code = NULL; - - value = xmlGetProp (n, "value"); - work = n->children; - while (work) { - if (!strcmp (work->name, "title")) { - if (!title) { - if (!(tmp = xmlNodeGetContent (work))) - tmp = xmlStrdup (""); - - title = g_strdup (tmp); - xmlFree (tmp); - } - } else if (!strcmp (work->name, "code")) { - if (!code) { - if (!(tmp = xmlNodeGetContent (work))) - tmp = xmlStrdup (""); - - code = g_strdup (tmp); - xmlFree (tmp); - } - } - work = work->next; - } - - filter_option_add (fo, value, title, code); - xmlFree (value); - g_free (title); - g_free (code); - } else if (n->type == XML_ELEMENT_NODE) { - 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", fo->type); - 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 = g_object_get_data ((GObject *) 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)); - g_object_set_data ((GObject *) item, "option", op); - g_signal_connect (item, "activate", G_CALLBACK (option_changed), fe); - gtk_menu_shell_append(GTK_MENU_SHELL(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) - g_signal_emit_by_name (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 *op; - - d(printf ("cloning option\n")); - - new = FILTER_OPTION (FILTER_ELEMENT_CLASS (parent_class)->clone (fe)); - l = fo->options; - while (l) { - op = l->data; - filter_option_add (new, op->value, op->title, op->code); - l = l->next; - } - - 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 39418868ab..0000000000 --- a/filter/filter-option.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 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. - */ - - -#ifndef _FILTER_OPTION_H -#define _FILTER_OPTION_H - -#include "filter-element.h" - -#define FILTER_TYPE_OPTION (filter_option_get_type ()) -#define FILTER_OPTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FILTER_TYPE_OPTION, FilterOption)) -#define FILTER_OPTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FILTER_TYPE_OPTION, FilterOptionClass)) -#define IS_FILTER_OPTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FILTER_TYPE_OPTION)) -#define IS_FILTER_OPTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FILTER_TYPE_OPTION)) -#define FILTER_OPTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FILTER_TYPE_OPTION, FilterOptionClass)) - -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_object; - - const char *type; /* static memory, type name written to xml */ - - GList *options; - struct _filter_option *current; -}; - -struct _FilterOptionClass { - FilterElementClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - -GType filter_option_get_type (void); -FilterOption *filter_option_new (void); - -/* methods */ -void filter_option_set_current (FilterOption *option, const char *name); -void filter_option_add (FilterOption *fo, const char *name, const char *title, const char *code); - -#endif /* ! _FILTER_OPTION_H */ diff --git a/filter/filter-part.c b/filter/filter-part.c deleted file mode 100644 index 5f8a53304a..0000000000 --- a/filter/filter-part.c +++ /dev/null @@ -1,544 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 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. - */ - - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include - -#include -#include -#include - -#include "filter-part.h" - - -#define d(x) - -static void filter_part_class_init (FilterPartClass *klass); -static void filter_part_init (FilterPart *fp); -static void filter_part_finalise (GObject *obj); - - -static GObjectClass *parent_class = NULL; - - -GType -filter_part_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (FilterPartClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) filter_part_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (FilterPart), - 0, /* n_preallocs */ - (GInstanceInitFunc) filter_part_init, - }; - - type = g_type_register_static (G_TYPE_OBJECT, "FilterPart", &info, 0); - } - - return type; -} - -static void -filter_part_class_init (FilterPartClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_ref (G_TYPE_OBJECT); - - object_class->finalize = filter_part_finalise; -} - -static void -filter_part_init (FilterPart *fp) -{ - ; -} - -static void -filter_part_finalise (GObject *obj) -{ - FilterPart *fp = (FilterPart *) obj; - GList *l; - - l = fp->elements; - while (l) { - g_object_unref (l->data); - l = l->next; - } - - g_list_free (fp->elements); - g_free (fp->name); - g_free (fp->title); - g_free (fp->code); - - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -/** - * filter_part_new: - * - * Create a new FilterPart object. - * - * Return value: A new #FilterPart object. - **/ -FilterPart * -filter_part_new (void) -{ - return (FilterPart *) g_object_new (FILTER_TYPE_PART, NULL, NULL); -} - -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_eq (FilterPart *fp, FilterPart *fc) -{ - int truth; - GList *al, *bl; - - truth = ((fp->name && fc->name && strcmp(fp->name, fc->name) == 0) - || (fp->name == NULL && fc->name == NULL)) - && ((fp->title && fc->title && strcmp(fp->title, fc->title) == 0) - || (fp->title == NULL && fc->title == NULL)) - && ((fp->code && fc->code && strcmp(fp->code, fc->code) == 0) - || (fp->code == NULL && fc->code == NULL)); - - al = fp->elements; - bl = fc->elements; - while (truth && al && bl) { - FilterElement *a = al->data, *b = bl->data; - - truth = filter_element_eq(a, b); - - al = al->next; - bl = bl->next; - } - - return truth && al == NULL && bl == NULL; -} - -int -filter_part_xml_create (FilterPart *ff, xmlNodePtr node) -{ - xmlNodePtr n; - char *type, *str; - FilterElement *el; - - str = xmlGetProp (node, "name"); - ff->name = g_strdup (str); - if (str) - xmlFree (str); - - n = node->children; - 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 = g_strdup (str); - if (str) - xmlFree (str); - } - } else if (!strcmp (n->name, "code")) { - if (!ff->code) { - str = xmlNodeGetContent (n); - ff->code = g_strdup (str); - if (str) - xmlFree (str); - } - } else if (n->type == XML_ELEMENT_NODE) { - g_warning ("Unknown 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->children; - 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 *) g_object_new (G_OBJECT_TYPE (fp), NULL, NULL); - 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; -} - -/* only copies values of matching parts in the right order */ -void -filter_part_copy_values (FilterPart *dst, FilterPart *src) -{ - GList *dstl, *srcl, *dstt; - FilterElement *de, *se; - - /* NOTE: we go backwards, it just works better that way */ - - /* for each source type, search the dest type for - a matching type in the same order */ - srcl = g_list_last (src->elements); - dstl = g_list_last (dst->elements); - while (srcl && dstl) { - se = srcl->data; - dstt = dstl; - while (dstt) { - de = dstt->data; - if (FILTER_PART_GET_CLASS (de) == FILTER_PART_GET_CLASS (se)) { - filter_element_copy_value (de, se); - dstl = dstt->prev; - break; - } - dstt = dstt->prev; - } - - srcl = srcl->prev; - } -} - -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 = l->next; - } -} - -/** - * 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 = l->next; - } -} - -/** - * 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 = l->next; - } - - 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 = node->next; - } - - 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 = g_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_append_printf (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_append_printf (out, "%.*s", newstart-start, start); - e_sexp_encode_string (out, val); -#endif - } else { - g_string_append_printf (out, "%.*s", end-start+1, start); - } - start = end + 1; - } - g_string_append (out, start); -} - -#if 0 -int main(int argc, char **argv) -{ - GtkWidget *dialog, *w; - xmlDocPtr system; - xmlNodePtr node; - FilterPart *ff; - 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); - - dialog = gtk_dialog_new (); - gtk_dialog_add_buttons ((GtkDialog *) dialog, GTK_BUTTONS_OK, NULL); - gtk_window_set_title ((GtkWindow *) dialog, _("Test")); - gtk_window_set_policy ((GtkWindow *) dialog, FALSE, TRUE, FALSE); - gtk_box_pack_start ((GtkBox *) dialog->vbox, w, TRUE, TRUE, 0); - - gtk_dialog_run ((GtkDialog *) dialog); - gtk_widget_destroy (dialog); - - 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 b1281522ea..0000000000 --- a/filter/filter-part.h +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 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. - */ - -#ifndef _FILTER_PART_H -#define _FILTER_PART_H - -#include -#include - -#include "filter-input.h" - -#define FILTER_TYPE_PART (filter_part_get_type ()) -#define FILTER_PART(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FILTER_TYPE_PART, FilterPart)) -#define FILTER_PART_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FILTER_TYPE_PART, FilterPartClass)) -#define IS_FILTER_PART(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FILTER_TYPE_PART)) -#define IS_FILTER_PART_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FILTER_TYPE_PART)) -#define FILTER_PART_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FILTER_TYPE_PART, FilterElementClass)) - -typedef struct _FilterPart FilterPart; -typedef struct _FilterPartClass FilterPartClass; - -struct _FilterPart { - GObject parent_object; - struct _FilterPartPrivate *priv; - - char *name; - char *title; - char *code; - GList *elements; -}; - -struct _FilterPartClass { - GObjectClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - -GType filter_part_get_type (void); -FilterPart *filter_part_new (void); - -/* methods */ -gboolean filter_part_validate (FilterPart *fp); -int filter_part_eq (FilterPart *fp, FilterPart *fc); - -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); -void filter_part_copy_values (FilterPart *dfp, FilterPart *sfp); - -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 87e6433167..0000000000 --- a/filter/filter-rule.c +++ /dev/null @@ -1,897 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 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. - */ - - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include -#include - -#include "filter-rule.h" -#include "filter-context.h" -#include "filter-marshal.h" - -#define d(x) - -static int validate(FilterRule *); -static int rule_eq(FilterRule *fr, FilterRule *cm); -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 *klass); -static void filter_rule_init (FilterRule *fr); -static void filter_rule_finalise (GObject *obj); - -#define _PRIVATE(x) (((FilterRule *)(x))->priv) - -struct _FilterRulePrivate { - int frozen; -}; - -static GObjectClass *parent_class = NULL; - -enum { - CHANGED, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -GType -filter_rule_get_type () -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (FilterRuleClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) filter_rule_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (FilterRule), - 0, /* n_preallocs */ - (GInstanceInitFunc) filter_rule_init, - }; - - type = g_type_register_static (G_TYPE_OBJECT, "FilterRule", &info, 0); - } - - return type; -} - -static void -filter_rule_class_init (FilterRuleClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_ref (G_TYPE_OBJECT); - - object_class->finalize = filter_rule_finalise; - - /* override methods */ - klass->validate = validate; - klass->eq = rule_eq; - klass->xml_encode = xml_encode; - klass->xml_decode = xml_decode; - klass->build_code = build_code; - klass->copy = rule_copy; - klass->get_widget = get_widget; - - /* signals */ - signals[CHANGED] = - g_signal_new ("changed", - FILTER_TYPE_RULE, - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (FilterRuleClass, changed), - NULL, - NULL, - filter_marshal_NONE__NONE, - G_TYPE_NONE, 0); -} - -static void -filter_rule_init (FilterRule *fr) -{ - fr->priv = g_malloc0 (sizeof (*fr->priv)); -} - -static void -filter_rule_finalise (GObject *obj) -{ - FilterRule *fr = (FilterRule *) obj; - - g_free (fr->name); - g_free (fr->source); - g_list_foreach (fr->parts, (GFunc)g_object_unref, NULL); - g_list_free (fr->parts); - - g_free (fr->priv); - - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -/** - * filter_rule_new: - * - * Create a new FilterRule object. - * - * Return value: A new #FilterRule object. - **/ -FilterRule * -filter_rule_new () -{ - return (FilterRule *) g_object_new (FILTER_TYPE_RULE, NULL, NULL); -} - -FilterRule * -filter_rule_clone (FilterRule *base) -{ - FilterRule *rule; - - g_assert (IS_FILTER_RULE (base)); - - rule = g_object_new (G_OBJECT_TYPE (base), NULL, NULL); - 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 FILTER_RULE_GET_CLASS (fr)->validate (fr); -} - -static int -validate (FilterRule *fr) -{ - GtkWidget *dialog; - int valid = TRUE; - GList *parts; - - if (!fr->name || !*fr->name) { - /* FIXME: FilterElement should probably have a - GtkWidget member pointing to the value gotten with - ::get_widget() so that we can get the parent window - here. */ - dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, - "%s", _("You must name this filter.")); - - gtk_dialog_run ((GtkDialog *) dialog); - gtk_widget_destroy (dialog); - - return FALSE; - } - - /* validate rule parts */ - parts = fr->parts; - while (parts && valid) { - valid = filter_part_validate ((FilterPart *) parts->data); - parts = parts->next; - } - - return valid; -} - -int -filter_rule_eq (FilterRule *fr, FilterRule *cm) -{ - g_assert (IS_FILTER_RULE (fr)); - g_assert (IS_FILTER_RULE (cm)); - - return (FILTER_RULE_GET_CLASS (fr) == FILTER_RULE_GET_CLASS (cm)) - && FILTER_RULE_GET_CLASS (fr)->eq (fr, cm); -} - -static int -list_eq(GList *al, GList *bl) -{ - int truth = TRUE; - - while (truth && al && bl) { - FilterPart *a = al->data, *b = bl->data; - - truth = filter_part_eq (a, b); - al = al->next; - bl = bl->next; - } - - return truth && al == NULL && bl == NULL; -} - -static int -rule_eq (FilterRule *fr, FilterRule *cm) -{ - return fr->grouping == cm->grouping - && ((fr->name && cm->name && strcmp (fr->name, cm->name) == 0) - || (fr->name == NULL && cm->name == NULL)) - && ((fr->source && cm->source && strcmp (fr->source, cm->source) == 0) - || (fr->source == NULL && cm->source == NULL) ) - && list_eq (fr->parts, cm->parts); -} - -xmlNodePtr -filter_rule_xml_encode (FilterRule *fr) -{ - g_assert (IS_FILTER_RULE (fr)); - - return FILTER_RULE_GET_CLASS (fr)->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) { - work = xmlNewNode (NULL, "title"); - xmlNodeSetContent (work, fr->name); - xmlAddChild (node, work); - } - - set = xmlNewNode (NULL, "partset"); - xmlAddChild (node, set); - l = fr->parts; - while (l) { - work = filter_part_xml_encode ((FilterPart *) l->data); - xmlAddChild (set, work); - l = l->next; - } - - return node; -} - -static void -load_set (xmlNodePtr node, FilterRule *fr, RuleContext *f) -{ - xmlNodePtr work; - char *rulename; - FilterPart *part; - - work = node->children; - 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 if (work->type == XML_ELEMENT_NODE) { - g_warning ("Unknown 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 = FILTER_RULE_GET_CLASS (fr)->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->children; - 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 = g_strdup (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) g_object_unref, NULL); - g_list_free (dest->parts); - dest->parts = NULL; - } - - node = src->parts; - while (node) { - FilterPart *part = node->data; - - g_object_ref (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)); - - FILTER_RULE_GET_CLASS (dest)->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); - - FILTER_RULE_GET_CLASS (fr)->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) - g_signal_emit (fr, signals[CHANGED], 0); -} - -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 = g_object_get_data ((GObject *) item, "part"); - FilterPart *newpart; - - /* dont update if we haven't changed */ - if (!strcmp (part->title, data->part->title)) - return; - - /* here we do a widget shuffle, throw away the old widget/rulepart, - and create another */ - if (data->partwidget) - gtk_container_remove (GTK_CONTAINER (data->container), data->partwidget); - - newpart = filter_part_clone (part); - filter_part_copy_values (newpart, data->part); - filter_rule_replace_part (data->fr, data->part, newpart); - g_object_unref (data->part); - data->part = newpart; - data->partwidget = filter_part_get_widget (newpart); - if (data->partwidget) - gtk_box_pack_start (GTK_BOX (data->container), data->partwidget, FALSE, FALSE, 0); - - g_object_set_data ((GObject *) data->container, "part", newpart); -} - -static GtkWidget * -get_rule_part_widget (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 */ - g_object_set_data_full ((GObject *) 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)); - g_object_set_data ((GObject *) item, "part", part); - g_signal_connect (item, "activate", G_CALLBACK (option_activate), data); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); - gtk_widget_show (item); - if (!strcmp (newpart->title, part->title)) - current = index; - - index++; - } - - omenu = gtk_option_menu_new (); - gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu); - gtk_option_menu_set_history (GTK_OPTION_MENU (omenu), current); - gtk_widget_show (omenu); - - gtk_box_pack_start (GTK_BOX (hbox), omenu, FALSE, FALSE, 0); - if (p) - gtk_box_pack_start (GTK_BOX (hbox), p, FALSE, FALSE, 0); - - gtk_widget_show_all (hbox); - - return hbox; -} - -struct _rule_data { - FilterRule *fr; - 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 = g_object_get_data ((GObject *) button, "rule"); - part = g_object_get_data ((GObject *) rule, "part"); - - /* remove the part from the list */ - filter_rule_remove_part (data->fr, part); - g_object_unref (part); - - /* and from the display */ - gtk_container_remove (GTK_CONTAINER (data->parts), rule); - gtk_container_remove (GTK_CONTAINER (data->parts), button); -} - -static void -attach_rule (GtkWidget *rule, struct _rule_data *data, FilterPart *part, int row) -{ - GtkWidget *remove; - - gtk_table_attach (GTK_TABLE (data->parts), rule, 0, 1, row, row + 1, - GTK_EXPAND | GTK_FILL, 0, 0, 0); - - remove = gtk_button_new_from_stock (GTK_STOCK_REMOVE); - g_object_set_data ((GObject *) remove, "rule", rule); - g_object_set_data ((GObject *) rule, "part", part); - /*gtk_button_set_relief (GTK_BUTTON (remove), GTK_RELIEF_NONE);*/ - g_signal_connect (remove, "clicked", G_CALLBACK (less_parts), data); - gtk_table_attach (GTK_TABLE (data->parts), remove, 1, 2, row, row + 1, - 0, 0, 0, 0); - - gtk_widget_show (remove); -} - -static void -more_parts (GtkWidget *button, struct _rule_data *data) -{ - FilterPart *new; - - /* 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 = g_strdup (gtk_entry_get_text (entry)); -} - -GtkWidget * -filter_rule_get_widget (FilterRule *fr, RuleContext *rc) -{ - return FILTER_RULE_GET_CLASS (fr)->get_widget (fr, rc); -} - -static void -grab_focus (GtkWidget *entry, gpointer data) -{ - gtk_widget_grab_focus (entry); -} - -static GtkWidget * -get_widget (FilterRule *fr, struct _RuleContext *f) -{ - GtkWidget *hbox, *vbox, *parts, *inframe; - GtkWidget *add, *frame, *label, *name, *w; - GtkWidget *omenu, *menu, *item; - GtkWidget *scrolledwindow; - GtkObject *hadj, *vadj; - GList *l; - FilterPart *part; - struct _rule_data *data; - int 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 { - gtk_entry_set_text (GTK_ENTRY (name), fr->name); - } - - /* evil kludgy hack because gtk sucks */ - g_signal_connect (name, "realize", G_CALLBACK (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); - g_signal_connect (name, "changed", G_CALLBACK (name_changed), fr); - - frame = gtk_frame_new (_("If")); - inframe = gtk_vbox_new (FALSE, 3); - gtk_container_add (GTK_CONTAINER (frame), inframe); - gtk_container_set_border_width (GTK_CONTAINER (inframe), 6); - - /* 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 */ - g_object_set_data_full ((GObject *) 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")); - g_signal_connect (item, "activate", G_CALLBACK (match_all), fr); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - gtk_widget_show (item); - - item = gtk_menu_item_new_with_label (_("if any criteria are met")); - g_signal_connect (item, "activate", G_CALLBACK (match_any), fr); - gtk_menu_shell_append (GTK_MENU_SHELL (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); - - add = gtk_button_new_from_stock (GTK_STOCK_ADD); - g_signal_connect (add, "clicked", G_CALLBACK (more_parts), data); - gtk_box_pack_start (GTK_BOX (hbox), add, FALSE, FALSE, 0); - - 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, 3); - - 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, 3); - - /*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 = node->next; - } - - if (source) { - while (node) { - FilterRule *rule = node->data; - - if (rule->source && strcmp (rule->source, source) == 0) - break; - node = node->next; - } - } - - 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 = l->next; - } - - 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 b75213d274..0000000000 --- a/filter/filter-rule.h +++ /dev/null @@ -1,121 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 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. - */ - -#ifndef _FILTER_RULE_H -#define _FILTER_RULE_H - -#include -#include - -#include "filter-part.h" - -#define FILTER_TYPE_RULE (filter_rule_get_type ()) -#define FILTER_RULE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FILTER_TYPE_RULE, FilterRule)) -#define FILTER_RULE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FILTER_TYPE_RULE, FilterRuleClass)) -#define IS_FILTER_RULE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FILTER_TYPE_RULE)) -#define IS_FILTER_RULE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FILTER_TYPE_RULE)) -#define FILTER_RULE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FILTER_TYPE_RULE, FilterRuleClass)) - -struct _RuleContext; - -typedef struct _FilterRule FilterRule; -typedef struct _FilterRuleClass FilterRuleClass; - -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 { - GObject parent_object; - struct _FilterRulePrivate *priv; - - char *name; - char *source; - - enum _filter_grouping_t grouping; - GList *parts; -}; - -struct _FilterRuleClass { - GObjectClass parent_class; - - /* virtual methods */ - int (*validate) (FilterRule *); - int (*eq) (FilterRule *fr, FilterRule *cm); - - 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); -}; - - -GType 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); -int filter_rule_eq (FilterRule *fr, FilterRule *cm); - -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-source.c b/filter/filter-source.c deleted file mode 100644 index c5955eb733..0000000000 --- a/filter/filter-source.c +++ /dev/null @@ -1,377 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Jon Trowbridge - * Jeffrey Stedfast - * - * Copyright 2001-2002 Ximian, Inc. (www.ximian.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include "filter-source.h" - -#include -#include -#include -#include -#include - - -static void filter_source_class_init (FilterSourceClass *klass); -static void filter_source_init (FilterSource *fs); -static void filter_source_finalize (GObject *obj); - -static int source_eq (FilterElement *fe, FilterElement *cm); -static void xml_create (FilterElement *fe, xmlNodePtr node); -static xmlNodePtr xml_encode (FilterElement *fe); -static int xml_decode (FilterElement *fe, xmlNodePtr node); -static FilterElement *clone (FilterElement *fe); -static GtkWidget *get_widget (FilterElement *fe); -static void build_code (FilterElement *fe, GString *out, struct _FilterPart *ff); -static void format_sexp (FilterElement *, GString *); - -static void filter_source_add_source (FilterSource *fs, const char *account_name, const char *name, - const char *addr, const char *url); -static void filter_source_get_sources (FilterSource *fs); - -typedef struct _SourceInfo { - char *account_name; - char *name; - char *address; - char *url; -} SourceInfo; - -struct _FilterSourcePrivate { - GList *sources; - char *current_url; -}; - - -static FilterElementClass *parent_class = NULL; - - -GType -filter_source_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (FilterSourceClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) filter_source_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (FilterSource), - 0, /* n_preallocs */ - (GInstanceInitFunc) filter_source_init, - }; - - type = g_type_register_static (FILTER_TYPE_ELEMENT, "FilterSource", &info, 0); - } - - return type; -} - -static void -filter_source_class_init (FilterSourceClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - FilterElementClass *fe_class = FILTER_ELEMENT_CLASS (klass); - - parent_class = g_type_class_ref (FILTER_TYPE_ELEMENT); - - object_class->finalize = filter_source_finalize; - - /* override methods */ - fe_class->eq = source_eq; - fe_class->xml_create = xml_create; - fe_class->xml_encode = xml_encode; - fe_class->xml_decode = xml_decode; - fe_class->clone = clone; - fe_class->get_widget = get_widget; - fe_class->build_code = build_code; - fe_class->format_sexp = format_sexp; -} - -static void -filter_source_init (FilterSource *fs) -{ - fs->priv = g_new (struct _FilterSourcePrivate, 1); - fs->priv->sources = NULL; - fs->priv->current_url = NULL; -} - -static void -filter_source_finalize (GObject *obj) -{ - FilterSource *fs = FILTER_SOURCE (obj); - GList *i = fs->priv->sources; - - while (i) { - SourceInfo *info = i->data; - g_free (info->account_name); - g_free (info->name); - g_free (info->address); - g_free (info->url); - g_free (info); - i = g_list_next (i); - } - - g_list_free (fs->priv->sources); - g_free (fs->priv->current_url); - - g_free (fs->priv); - - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -FilterSource * -filter_source_new (void) -{ - return (FilterSource *) g_object_new (FILTER_TYPE_SOURCE, NULL, NULL); -} - -static int -source_eq (FilterElement *fe, FilterElement *cm) -{ - FilterSource *fs = (FilterSource *)fe, *cs = (FilterSource *)cm; - - return FILTER_ELEMENT_CLASS (parent_class)->eq (fe, cm) - && ((fs->priv->current_url && cs->priv->current_url - && strcmp (fs->priv->current_url, cs->priv->current_url) == 0) - || (fs->priv->current_url == NULL && cs->priv->current_url == NULL)); -} - -static void -xml_create (FilterElement *fe, xmlNodePtr node) -{ - /* Call parent implementation */ - FILTER_ELEMENT_CLASS (parent_class)->xml_create (fe, node); -} - -static xmlNodePtr -xml_encode (FilterElement *fe) -{ - xmlNodePtr value; - - FilterSource *fs = (FilterSource *) fe; - - value = xmlNewNode (NULL, "value"); - xmlSetProp (value, "name", fe->name); - xmlSetProp (value, "type", "uri"); - - if (fs->priv->current_url) - xmlNewTextChild (value, NULL, "uri", fs->priv->current_url); - - return value; -} - -static gint -xml_decode (FilterElement *fe, xmlNodePtr node) -{ - FilterSource *fs = (FilterSource *) fe; - CamelURL *url; - char *uri; - - node = node->children; - while (node != NULL) { - if (!strcmp (node->name, "uri")) { - uri = xmlNodeGetContent (node); - url = camel_url_new (uri, NULL); - xmlFree (uri); - - g_free (fs->priv->current_url); - fs->priv->current_url = camel_url_to_string (url, CAMEL_URL_HIDE_ALL); - camel_url_free (url); - break; - } - - node = node->next; - } - - return 0; -} - -static FilterElement * -clone (FilterElement *fe) -{ - FilterSource *fs = (FilterSource *) fe; - FilterSource *cpy = filter_source_new (); - GList *i; - - ((FilterElement *) cpy)->name = xmlStrdup (fe->name); - - cpy->priv->current_url = g_strdup (fs->priv->current_url); - - for (i = fs->priv->sources; i != NULL; i = g_list_next (i)) { - SourceInfo *info = (SourceInfo *) i->data; - filter_source_add_source (cpy, info->account_name, info->name, info->address, info->url); - } - - return (FilterElement *) cpy; -} - -static void -source_changed (GtkWidget *item, FilterSource *fs) -{ - SourceInfo *info = (SourceInfo *) g_object_get_data ((GObject *) item, "source"); - - g_free (fs->priv->current_url); - fs->priv->current_url = g_strdup (info->url); -} - -static GtkWidget * -get_widget (FilterElement *fe) -{ - FilterSource *fs = (FilterSource *) fe; - GtkWidget *menu; - GtkWidget *omenu; - GtkWidget *item; - GList *i; - SourceInfo *first = NULL; - int index, current_index; - - if (fs->priv->sources == NULL) - filter_source_get_sources (fs); - - menu = gtk_menu_new (); - - index = 0; - current_index = -1; - - for (i = fs->priv->sources; i != NULL; i = g_list_next (i)) { - SourceInfo *info = (SourceInfo *) i->data; - char *label; - - if (info->url != NULL) { - if (first == NULL) - first = info; - - if (info->account_name && strcmp (info->account_name, info->address)) - label = g_strdup_printf ("%s <%s> (%s)", info->name, - info->address, info->account_name); - else - label = g_strdup_printf ("%s <%s>", info->name, info->address); - - item = gtk_menu_item_new_with_label (label); - g_free (label); - - g_object_set_data ((GObject *) item, "source", info); - g_signal_connect (item, "activate", G_CALLBACK (source_changed), fs); - - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - gtk_widget_show (item); - - if (fs->priv->current_url && !strcmp (info->url, fs->priv->current_url)) - current_index = index; - - index++; - } - } - - omenu = gtk_option_menu_new (); - gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu); - - if (current_index >= 0) { - gtk_option_menu_set_history (GTK_OPTION_MENU (omenu), current_index); - } else { - gtk_option_menu_set_history (GTK_OPTION_MENU (omenu), 0); - g_free (fs->priv->current_url); - - if (first) - fs->priv->current_url = g_strdup (first->url); - else - fs->priv->current_url = NULL; - } - - return omenu; -} - -static void -build_code (FilterElement *fe, GString *out, struct _FilterPart *ff) -{ - /* We are doing nothing on purpose. */ -} - -static void -format_sexp (FilterElement *fe, GString *out) -{ - FilterSource *fs = (FilterSource *) fe; - - e_sexp_encode_string (out, fs->priv->current_url); -} - - -static void -filter_source_add_source (FilterSource *fs, const char *account_name, const char *name, - const char *addr, const char *url) -{ - SourceInfo *info; - - g_return_if_fail (IS_FILTER_SOURCE (fs)); - - info = g_new0 (SourceInfo, 1); - info->account_name = g_strdup (account_name); - info->name = g_strdup (name); - info->address = g_strdup (addr); - info->url = g_strdup (url); - - fs->priv->sources = g_list_append (fs->priv->sources, info); -} - -static void -filter_source_get_sources (FilterSource *fs) -{ - EAccountList *accounts; - const EAccount *account; - GConfClient *gconf; - EIterator *it; - char *uri; - CamelURL *url; - - /* should this get the global object from mail? */ - gconf = gconf_client_get_default (); - accounts = e_account_list_new (gconf); - g_object_unref (gconf); - - for (it = e_list_get_iterator((EList *)accounts); - e_iterator_is_valid(it); - e_iterator_next(it)) { - account = (const EAccount *)e_iterator_get(it); - - if (account->source == NULL || account->source->url == NULL) - continue; - - /* hide secret stuff */ - url = camel_url_new (account->source->url, NULL); - uri = camel_url_to_string (url, CAMEL_URL_HIDE_ALL); - camel_url_free (url); - - filter_source_add_source (fs, account->name, account->id->name, account->id->address, uri); - g_free(uri); - } - g_object_unref(it); - g_object_unref(accounts); -} diff --git a/filter/filter-source.h b/filter/filter-source.h deleted file mode 100644 index 73bd63f503..0000000000 --- a/filter/filter-source.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Jon Trowbridge - * Jeffrey Stedfast - * - * Copyright 2001-2002 Ximian, Inc. (www.ximian.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - - -#ifndef __FILTER_SOURCE_H__ -#define __FILTER_SOURCE_H__ - -#include "filter-element.h" - -#define FILTER_TYPE_SOURCE (filter_source_get_type ()) -#define FILTER_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FILTER_TYPE_SOURCE, FilterSource)) -#define FILTER_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FILTER_TYPE_SOURCE, FilterSourceClass)) -#define IS_FILTER_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FILTER_TYPE_SOURCE)) -#define IS_FILTER_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FILTER_TYPE_SOURCE)) -#define FILTER_SOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FILTER_TYPE_SOURCE, FilterSourceClass)) - -typedef struct _FilterSource FilterSource; -typedef struct _FilterSourceClass FilterSourceClass; - -struct _FilterSource { - FilterElement parent_object; - struct _FilterSourcePrivate *priv; -}; - -struct _FilterSourceClass { - FilterElementClass parent_class; - -}; - - -GType filter_source_get_type (void); -FilterSource *filter_source_new (void); - -void filter_source_set_current (FilterSource *src, const char *url); - -#endif /* __FILTER_SOURCE_H__ */ diff --git a/filter/filter.glade b/filter/filter.glade deleted file mode 100644 index 973c7ea33c..0000000000 --- a/filter/filter.glade +++ /dev/null @@ -1,1344 +0,0 @@ - - - - - - - 6 - True - Edit Filters - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - True - False - True - - - - True - False - 6 - - - - True - GTK_BUTTONBOX_END - - - - True - True - True - gtk-cancel - True - GTK_RELIEF_NORMAL - -6 - - - - - - True - True - True - gtk-ok - True - GTK_RELIEF_NORMAL - -5 - - - - - 0 - False - True - GTK_PACK_END - - - - - - True - True - 0 - - - - True - - - - True - Incoming - True - - - - - - True - Outgoing - True - - - - - - - 0 - False - False - - - - - - True - 0 - 0.5 - GTK_SHADOW_ETCHED_IN - - - - 6 - True - False - 6 - - - - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_NONE - GTK_CORNER_TOP_LEFT - - - - True - GTK_SHADOW_IN - - - - True - rule_editor_treeview_new - 0 - 0 - Thu, 12 Dec 2002 23:41:46 GMT - - - - - - - 0 - True - True - - - - - - True - False - 0 - - - - True - GTK_BUTTONBOX_DEFAULT_STYLE - 6 - - - - True - True - True - gtk-add - True - GTK_RELIEF_NORMAL - - - - - - True - True - True - _Edit - True - GTK_RELIEF_NORMAL - - - - - - True - True - True - gtk-remove - True - GTK_RELIEF_NORMAL - - - - - - True - True - True - gtk-go-up - True - GTK_RELIEF_NORMAL - - - - - - True - True - True - gtk-go-down - True - GTK_RELIEF_NORMAL - - - - - 0 - False - False - - - - - 0 - False - False - - - - - - - - True - Filter Rules - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - label_item - - - - - 0 - True - True - - - - - - - - 6 - True - Edit VFolders - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - True - False - True - - - - True - False - 8 - - - - True - GTK_BUTTONBOX_END - - - - True - True - True - gtk-cancel - True - GTK_RELIEF_NORMAL - -6 - - - - - - True - True - True - gtk-ok - True - GTK_RELIEF_NORMAL - -5 - - - - - 0 - False - True - GTK_PACK_END - - - - - - True - 0 - 0.5 - GTK_SHADOW_ETCHED_IN - - - - 6 - True - False - 6 - - - - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_NONE - GTK_CORNER_TOP_LEFT - - - - True - GTK_SHADOW_IN - - - - True - rule_editor_treeview_new - 0 - 0 - Fri, 13 Dec 2002 00:15:04 GMT - - - - - - - 0 - True - True - - - - - - True - False - 0 - - - - True - GTK_BUTTONBOX_DEFAULT_STYLE - 6 - - - - True - True - True - gtk-add - True - GTK_RELIEF_NORMAL - - - - - - True - True - True - _Edit - True - GTK_RELIEF_NORMAL - - - - - - True - True - True - gtk-remove - True - GTK_RELIEF_NORMAL - - - - - - True - True - True - gtk-go-up - True - GTK_RELIEF_NORMAL - - - - - - True - True - True - gtk-go-down - True - GTK_RELIEF_NORMAL - - - - - 0 - False - False - - - - - 0 - False - False - - - - - - - - True - Virtual Folders - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - label_item - - - - - 0 - True - True - - - - - - - - 6 - True - - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - True - False - True - - - - True - False - 8 - - - - True - GTK_BUTTONBOX_END - - - - True - True - True - gtk-cancel - True - GTK_RELIEF_NORMAL - -6 - - - - - - True - True - True - gtk-apply - True - GTK_RELIEF_NORMAL - 0 - - - - - - True - True - True - gtk-ok - True - GTK_RELIEF_NORMAL - -5 - - - - - 0 - False - True - GTK_PACK_END - - - - - - True - 0 - 0.5 - GTK_SHADOW_ETCHED_IN - - - - 6 - True - False - 6 - - - - True - True - 0 - - - - True - - - - True - specific folders only - True - - - - - - True - with all local folders - True - - - - - - True - with all active remote folders - True - - - - - - True - with all local and active remote folders - True - - - - - - - 0 - False - False - - - - - - True - False - 6 - - - - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_NONE - GTK_CORNER_TOP_LEFT - - - - True - GTK_SHADOW_IN - - - - True - vfolder_editor_sourcelist_new - 0 - 0 - Fri, 13 Dec 2002 00:22:39 GMT - - - - - - - 0 - True - True - - - - - - True - False - 1 - - - - True - GTK_BUTTONBOX_DEFAULT_STYLE - 6 - - - - True - True - True - gtk-add - True - GTK_RELIEF_NORMAL - - - - - - True - True - True - gtk-remove - True - GTK_RELIEF_NORMAL - - - - - 0 - False - False - - - - - 0 - False - False - - - - - 0 - True - True - - - - - - - - True - vFolder Sources - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - label_item - - - - - 0 - True - True - - - - - - - - 6 - True - window1 - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - True - False - - - - True - False - 6 - - - - True - 0 - - - - True - - - - True - Incoming - True - - - - - - - 0 - False - False - - - - - - True - 0 - 0.5 - GTK_SHADOW_ETCHED_IN - - - - 6 - True - False - 6 - - - - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_NONE - GTK_CORNER_TOP_LEFT - - - - True - GTK_SHADOW_IN - - - - True - rule_editor_treeview_new - 0 - 0 - Thu, 12 Dec 2002 23:50:05 GMT - - - - - - - 0 - True - True - - - - - - True - False - 0 - - - - True - GTK_BUTTONBOX_DEFAULT_STYLE - 6 - - - - True - True - True - gtk-add - True - GTK_RELIEF_NORMAL - - - - - - True - True - True - _Edit - True - GTK_RELIEF_NORMAL - - - - - - True - True - True - gtk-remove - True - GTK_RELIEF_NORMAL - - - - - - True - True - True - gtk-go-up - True - GTK_RELIEF_NORMAL - - - - - - True - True - True - gtk-go-down - True - GTK_RELIEF_NORMAL - - - - - 0 - False - False - - - - - 0 - False - False - - - - - - - - True - Filter Rules - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - label_item - - - - - 0 - True - True - - - - - - - - 6 - True - window1 - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - True - False - - - - True - False - 6 - - - - 4 - True - False - 6 - - - - True - Compare against - False - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - True - 0 - - - - True - - - - True - the current time - True - - - - - - True - the time you specify - True - - - - - - True - a time relative to the current time - True - - - - - - - 0 - False - False - - - - - 0 - False - False - - - - - - True - - - 1 - False - True - - - - - - True - False - False - GTK_POS_TOP - False - False - - - - True - False - 0 - - - - True - The message's date will be compared against -the current time when filtering occurs. - False - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - False - False - - - - - - True - label1 - False - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - - - - - - True - False - 0 - - - - True - The message's date will be compared against -12:00am of the date specified. - False - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - True - GTK_CALENDAR_SHOW_HEADING|GTK_CALENDAR_SHOW_DAY_NAMES - - - 0 - True - True - - - - - False - True - - - - - - True - label2 - False - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - - - - - - True - False - 0 - - - - True - The message's date will be compared against -a time relative to when filtering occurs. - False - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - True - 0 - - - - True - True - 1 - 0 - False - GTK_UPDATE_ALWAYS - False - False - 1 0 1000 1 10 10 - - - 0 - True - True - - - - - - True - True - 0 - - - - True - - - - True - seconds - True - - - - - - True - minutes - True - - - - - - True - hours - True - - - - - - True - days - True - - - - - - True - weeks - True - - - - - - True - months - True - - - - - - True - years - True - - - - - - - 0 - False - False - - - - - - True - ago - False - False - GTK_JUSTIFY_CENTER - False - False - 7.45058e-09 - 0.5 - 0 - 0 - - - 0 - False - True - - - - - 2 - False - True - - - - - False - True - - - - - - True - label3 - False - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - - - - - 0 - True - True - - - - - - - diff --git a/filter/filtertypes.xml b/filter/filtertypes.xml deleted file mode 100644 index 012ba62274..0000000000 --- a/filter/filtertypes.xml +++ /dev/null @@ -1,719 +0,0 @@ - - - - - Sender - - - - - - - - - - - - - - - - - Recipients - - - - - - - - - - - - - - - - - Subject - - - - - - - - - - - - - - - - - Specific header - - - - - - - - - - - - - - - - - - - - Message Body - - - - - - - - - Expression - - - - - Date sent - - - - - - - - - - - Date received - - - - - - - - - - - Label - - - - - - - - - Score - - - - - - - - - - - Size (kB) - - - - - - - - - Status - - - - - - - - - - - - - - Follow Up - - - - - - - - Attachments - - - - - - - - Mailing list - - - - - - - - - - - Regex Match - - - - - - - - - Source Account - - - - - - - - - Pipe Message to Shell Command - - - - - - - - - - - - - - - - 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}) - - - - Adjust Score - (adjust-score ${score}) - - - - Set Status - - (set-system-flag ${flag}) - - - - - - - - - - - Unset Status - - (unset-system-flag ${flag}) - - - - - - - - - - - Beep - (beep) - - - Play Sound - (play-sound ${sound}) - - - - Shell Command - (shell "/bin/sh" "-c" ${command}) - - - - Pipe Message to Shell Command - (pipe-message "/bin/sh" "-c" ${command}) - - - - diff --git a/filter/libfilter-i18n.h b/filter/libfilter-i18n.h deleted file mode 100644 index d965e03184..0000000000 --- a/filter/libfilter-i18n.h +++ /dev/null @@ -1,61 +0,0 @@ -/* Automatically generated. Do not edit. */ -char *s = N_("Adjust Score"); -char *s = N_("Assign Color"); -char *s = N_("Assign Score"); -char *s = N_("Attachments"); -char *s = N_("Beep"); -char *s = N_("contains"); -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_("does not contain"); -char *s = N_("does not end with"); -char *s = N_("does not exist"); -char *s = N_("does not return"); -char *s = N_("does not sound like"); -char *s = N_("does not start with"); -char *s = N_("Do Not Exist"); -char *s = N_("Draft"); -char *s = N_("ends with"); -char *s = N_("Exist"); -char *s = N_("exists"); -char *s = N_("Expression"); -char *s = N_("Follow Up"); -char *s = N_("Important"); -char *s = N_("is"); -char *s = N_("is after"); -char *s = N_("is before"); -char *s = N_("is Flagged"); -char *s = N_("is greater than"); -char *s = N_("is less than"); -char *s = N_("is not"); -char *s = N_("is not Flagged"); -char *s = N_("Label"); -char *s = N_("Mailing list"); -char *s = N_("Message Body"); -char *s = N_("Message Header"); -char *s = N_("Move to Folder"); -char *s = N_("Pipe Message to Shell Command"); -char *s = N_("Play Sound"); -char *s = N_("Read"); -char *s = N_("Recipients"); -char *s = N_("Regex Match"); -char *s = N_("Replied to"); -char *s = N_("returns"); -char *s = N_("returns greater than"); -char *s = N_("returns less than"); -char *s = N_("Score"); -char *s = N_("Sender"); -char *s = N_("Set Status"); -char *s = N_("Shell Command"); -char *s = N_("Size (kB)"); -char *s = N_("sounds like"); -char *s = N_("Source Account"); -char *s = N_("Specific header"); -char *s = N_("starts with"); -char *s = N_("Status"); -char *s = N_("Stop Processing"); -char *s = N_("Subject"); -char *s = N_("Unset Status"); diff --git a/filter/rule-context.c b/filter/rule-context.c deleted file mode 100644 index f76d9fae89..0000000000 --- a/filter/rule-context.c +++ /dev/null @@ -1,869 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 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. - */ - - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "rule-context.h" -#include "filter-rule.h" -#include "filter-marshal.h" - -#define d(x) - -static int load(RuleContext *rc, const char *system, const char *user); -static int save(RuleContext *rc, const char *user); -static int revert(RuleContext *rc, const char *user); -static GList *rename_uri(RuleContext *rc, const char *olduri, const char *newuri, GCompareFunc cmp); -static GList *delete_uri(RuleContext *rc, const char *uri, GCompareFunc cmp); - -static void rule_context_class_init(RuleContextClass *klass); -static void rule_context_init(RuleContext *rc); -static void rule_context_finalise(GObject *obj); - -#define _PRIVATE(x)(((RuleContext *)(x))->priv) - -struct _RuleContextPrivate { - int frozen; -}; - -static GObjectClass *parent_class = NULL; - -enum { - RULE_ADDED, - RULE_REMOVED, - CHANGED, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - - -GType -rule_context_get_type(void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof(RuleContextClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) rule_context_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof(RuleContext), - 0, /* n_preallocs */ - (GInstanceInitFunc) rule_context_init, - }; - - type = g_type_register_static(G_TYPE_OBJECT, "RuleContext", &info, 0); - } - - return type; -} - -static void -rule_context_class_init(RuleContextClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS(klass); - - parent_class = g_type_class_ref(G_TYPE_OBJECT); - - object_class->finalize = rule_context_finalise; - - /* override methods */ - klass->load = load; - klass->save = save; - klass->revert = revert; - klass->rename_uri = rename_uri; - klass->delete_uri = delete_uri; - - /* signals */ - signals[RULE_ADDED] = - g_signal_new("rule_added", - RULE_TYPE_CONTEXT, - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET(RuleContextClass, rule_added), - NULL, - NULL, - filter_marshal_NONE__POINTER, - G_TYPE_NONE, 1, G_TYPE_POINTER); - - signals[RULE_REMOVED] = - g_signal_new("rule_removed", - RULE_TYPE_CONTEXT, - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET(RuleContextClass, rule_removed), - NULL, - NULL, - filter_marshal_NONE__POINTER, - G_TYPE_NONE, 1, G_TYPE_POINTER); - - signals[CHANGED] = - g_signal_new("changed", - RULE_TYPE_CONTEXT, - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET(RuleContextClass, changed), - NULL, - NULL, - filter_marshal_NONE__NONE, - G_TYPE_NONE, 0); -} - -static void -rule_context_init(RuleContext *rc) -{ - rc->priv = g_malloc0(sizeof(*rc->priv)); - - rc->part_set_map = g_hash_table_new(g_str_hash, g_str_equal); - rc->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(GObject *obj) -{ - RuleContext *rc =(RuleContext *) obj; - - g_list_foreach(rc->rule_set_list, (GFunc)free_rule_set, NULL); - g_list_free(rc->rule_set_list); - g_hash_table_destroy(rc->rule_set_map); - - g_list_foreach(rc->part_set_list, (GFunc)free_part_set, NULL); - g_list_free(rc->part_set_list); - g_hash_table_destroy(rc->part_set_map); - - g_free(rc->error); - - g_list_foreach(rc->parts, (GFunc)g_object_unref, NULL); - g_list_free(rc->parts); - g_list_foreach(rc->rules, (GFunc)g_object_unref, NULL); - g_list_free(rc->rules); - - if (rc->system) - xmlFreeDoc(rc->system); - if (rc->user) - xmlFreeDoc(rc->user); - - g_free(rc->priv); - - G_OBJECT_CLASS(parent_class)->finalize(obj); -} - -/** - * rule_context_new: - * - * Create a new RuleContext object. - * - * Return value: A new #RuleContext object. - **/ -RuleContext * -rule_context_new(void) -{ - return(RuleContext *) g_object_new(RULE_TYPE_CONTEXT, NULL, NULL); -} - -void -rule_context_add_part_set(RuleContext *rc, const char *setname, int part_type, RCPartFunc append, RCNextPartFunc next) -{ - struct _part_set_map *map; - - g_assert(g_hash_table_lookup(rc->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(rc->part_set_map, map->name, map); - rc->part_set_list = g_list_append(rc->part_set_list, map); - d(printf("adding part set '%s'\n", setname)); -} - -void -rule_context_add_rule_set(RuleContext *rc, const char *setname, int rule_type, RCRuleFunc append, RCNextRuleFunc next) -{ - struct _rule_set_map *map; - - g_assert(g_hash_table_lookup(rc->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(rc->rule_set_map, map->name, map); - rc->rule_set_list = g_list_append(rc->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 *rc, char *error) -{ - g_assert(rc); - - g_free(rc->error); - rc->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 *rc, const char *system, const char *user) -{ - int res; - - g_assert(rc); - - d(printf("rule_context: loading %s %s\n", system, user)); - - rc->priv->frozen++; - res = RULE_CONTEXT_GET_CLASS(rc)->load(rc, system, user); - rc->priv->frozen--; - - return res; -} - -static int -load(RuleContext *rc, const char *system, const char *user) -{ - xmlNodePtr set, rule, root; - struct _part_set_map *part_map; - struct _rule_set_map *rule_map; - struct stat st; - - rule_context_set_error(rc, NULL); - - d(printf("loading rules %s %s\n", system, user)); - - rc->system = xmlParseFile(system); - if (rc->system == NULL) { - rule_context_set_error(rc, g_strdup_printf("Unable to load system rules '%s': %s", - system, g_strerror(errno))); - return -1; - } - - root = xmlDocGetRootElement(rc->system); - if (root == NULL || strcmp(root->name, "filterdescription")) { - rule_context_set_error(rc, g_strdup_printf("Unable to load system rules '%s': Invalid format", system)); - xmlFreeDoc(rc->system); - rc->system = NULL; - return -1; - } - /* doesn't matter if this doens't exist */ - rc->user = NULL; - if (stat (user, &st) != -1 && S_ISREG (st.st_mode)) - rc->user = xmlParseFile(user); - - /* now parse structure */ - /* get rule parts */ - set = root->children; - while (set) { - d(printf("set name = %s\n", set->name)); - part_map = g_hash_table_lookup(rc->part_set_map, set->name); - if (part_map) { - d(printf("loading parts ...\n")); - rule = set->children; - while (rule) { - if (!strcmp(rule->name, "part")) { - FilterPart *part = FILTER_PART(g_object_new(part_map->type, NULL, NULL)); - - if (filter_part_xml_create(part, rule) == 0) { - part_map->append(rc, part); - } else { - g_object_unref(part); - g_warning("Cannot load filter part"); - } - } - rule = rule->next; - } - } - set = set->next; - } - - /* now load actual rules */ - if (rc->user) { - root = xmlDocGetRootElement(rc->user); - set = root?root->children:NULL; - while (set) { - d(printf("set name = %s\n", set->name)); - rule_map = g_hash_table_lookup(rc->rule_set_map, set->name); - if (rule_map) { - d(printf("loading rules ...\n")); - rule = set->children; - while (rule) { - d(printf("checking node: %s\n", rule->name)); - if (!strcmp(rule->name, "rule")) { - FilterRule *part = FILTER_RULE(g_object_new(rule_map->type, NULL, NULL)); - - if (filter_rule_xml_decode(part, rule, rc) == 0) { - rule_map->append(rc, part); - } else { - g_object_unref(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 *rc, const char *user) -{ - g_assert(rc); - g_assert(user); - - return RULE_CONTEXT_GET_CLASS(rc)->save(rc, user); -} - -static int -save(RuleContext *rc, const char *user) -{ - xmlDocPtr doc; - xmlNodePtr root, rules, work; - GList *l; - FilterRule *rule; - struct _rule_set_map *map; - int ret; - - doc = xmlNewDoc("1.0"); - /* FIXME: set character encoding to UTF-8? */ - root = xmlNewDocNode(doc, NULL, "filteroptions", NULL); - xmlDocSetRootElement(doc, root); - l = rc->rule_set_list; - while (l) { - map = l->data; - rules = xmlNewDocNode(doc, NULL, map->name, NULL); - xmlAddChild(root, rules); - rule = NULL; - while ((rule = map->next(rc, rule, NULL))) { - d(printf("processing rule %s\n", rule->name)); - work = filter_rule_xml_encode(rule); - xmlAddChild(rules, work); - } - l = g_list_next(l); - } - - ret = e_xml_save_file(user, doc); - - xmlFreeDoc(doc); - - return ret; -} - -/** - * rule_context_revert: - * @f: - * @user: - * - * Reverts a rule context from a user description file. Assumes the - * system description file is unchanged from when it was loaded. - * - * Return value: - **/ -int -rule_context_revert(RuleContext *rc, const char *user) -{ - g_assert(rc); - - d(printf("rule_context: restoring %s %s\n", user)); - - return RULE_CONTEXT_GET_CLASS(rc)->revert(rc, user); -} - -struct _revert_data { - GHashTable *rules; - int rank; -}; - -static void -revert_rule_remove(void *key, FilterRule *frule, RuleContext *rc) -{ - rule_context_remove_rule(rc, frule); - g_object_unref(frule); -} - -static void -revert_source_remove(void *key, struct _revert_data *rest_data, RuleContext *rc) -{ - g_hash_table_foreach(rest_data->rules, (GHFunc)revert_rule_remove, rc); - g_hash_table_destroy(rest_data->rules); - g_free(rest_data); -} - -static guint -source_hashf(const char *a) -{ - if (a) - return g_str_hash(a); - return 0; -} - -static int -source_eqf(const char *a, const char *b) -{ - return((a && b && strcmp(a, b) == 0)) - || (a == NULL && b == NULL); -} - -static int -revert(RuleContext *rc, const char *user) -{ - xmlNodePtr set, rule; - /*struct _part_set_map *part_map;*/ - struct _rule_set_map *rule_map; - struct _revert_data *rest_data; - GHashTable *source_hash; - xmlDocPtr userdoc; - FilterRule *frule; - - rule_context_set_error(rc, NULL); - - d(printf("restoring rules %s %s\n", user)); - - userdoc = xmlParseFile(user); - if (userdoc == NULL) - /* clear out anythign we have? */ - return 0; - - source_hash = g_hash_table_new((GHashFunc)source_hashf, (GCompareFunc)source_eqf); - - /* setup stuff we have now */ - /* Note that we assume there is only 1 set of rules in a given rule context, - although other parts of the code dont assume this */ - frule = NULL; - while ((frule = rule_context_next_rule(rc, frule, NULL))) { - rest_data = g_hash_table_lookup(source_hash, frule->source); - if (rest_data == NULL) { - rest_data = g_malloc0(sizeof(*rest_data)); - rest_data->rules = g_hash_table_new(g_str_hash, g_str_equal); - g_hash_table_insert(source_hash, frule->source, rest_data); - } - g_hash_table_insert(rest_data->rules, frule->name, frule); - } - - /* make what we have, match what we load */ - set = xmlDocGetRootElement(rc->user); - set = set?set->children:NULL; - while (set) { - d(printf("set name = %s\n", set->name)); - rule_map = g_hash_table_lookup(rc->rule_set_map, set->name); - if (rule_map) { - d(printf("loading rules ...\n")); - rule = set->children; - while (rule) { - d(printf("checking node: %s\n", rule->name)); - if (!strcmp(rule->name, "rule")) { - FilterRule *part = FILTER_RULE(g_object_new(rule_map->type, NULL, NULL)); - - if (filter_rule_xml_decode(part, rule, rc) == 0) { - /* use the revert data to keep track of the right rank of this rule part */ - rest_data = g_hash_table_lookup(source_hash, part->source); - if (rest_data == NULL) { - rest_data = g_malloc0(sizeof(*rest_data)); - rest_data->rules = g_hash_table_new(g_str_hash, g_str_equal); - g_hash_table_insert(source_hash, part->source, rest_data); - } - frule = g_hash_table_lookup(rest_data->rules, part->name); - if (frule) { - if (rc->priv->frozen == 0 && !filter_rule_eq(frule, part)) - filter_rule_copy(frule, part); - - g_object_unref(part); - rule_context_rank_rule(rc, frule, frule->source, rest_data->rank); - g_hash_table_remove(rest_data->rules, frule->name); - } else { - rule_context_add_rule(rc, part); - rule_context_rank_rule(rc, part, part->source, rest_data->rank); - } - rest_data->rank++; - } else { - g_object_unref(part); - g_warning("Cannot load filter part"); - } - } - rule = rule->next; - } - } - set = set->next; - } - - xmlFreeDoc(userdoc); - - /* remove any we still have that weren't in the file */ - g_hash_table_foreach(source_hash, (GHFunc)revert_source_remove, rc); - g_hash_table_destroy(source_hash); - - return 0; -} - -FilterPart * -rule_context_find_part(RuleContext *rc, const char *name) -{ - g_assert(rc); - g_assert(name); - - d(printf("find part : ")); - return filter_part_find_list(rc->parts, name); -} - -FilterPart * -rule_context_create_part(RuleContext *rc, const char *name) -{ - FilterPart *part; - - g_assert(rc); - g_assert(name); - - if ((part = rule_context_find_part(rc, name))) - return filter_part_clone(part); - - return NULL; -} - -FilterPart * -rule_context_next_part(RuleContext *rc, FilterPart *last) -{ - g_assert(rc); - - return filter_part_next_list(rc->parts, last); -} - -FilterRule * -rule_context_next_rule(RuleContext *rc, FilterRule *last, const char *source) -{ - g_assert(rc); - - return filter_rule_next_list(rc->rules, last, source); -} - -FilterRule * -rule_context_find_rule(RuleContext *rc, const char *name, const char *source) -{ - g_assert(name); - g_assert(rc); - - return filter_rule_find_list(rc->rules, name, source); -} - -void -rule_context_add_part(RuleContext *rc, FilterPart *part) -{ - g_assert(rc); - g_assert(part); - - rc->parts = g_list_append(rc->parts, part); -} - -void -rule_context_add_rule(RuleContext *rc, FilterRule *new) -{ - g_assert(rc); - g_assert(new); - - d(printf("add rule '%s'\n", new->name)); - - rc->rules = g_list_append(rc->rules, new); - - if (rc->priv->frozen == 0) { - g_signal_emit(rc, signals[RULE_ADDED], 0, new); - g_signal_emit(rc, signals[CHANGED], 0); - } -} - -static void -new_rule_response(GtkWidget *dialog, int button, RuleContext *context) -{ - if (button == GTK_RESPONSE_ACCEPT) { - FilterRule *rule = g_object_get_data((GObject *) dialog, "rule"); - char *user = g_object_get_data((GObject *) dialog, "path"); - - if (!filter_rule_validate(rule)) { - /* no need to popup a dialog because the validate code does that. */ - return; - } - - if (rule_context_find_rule (context, rule->name, rule->source)) { - dialog = gtk_message_dialog_new ((GtkWindow *) dialog, GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, - _("Rule name '%s' is not unique, choose another."), - rule->name); - - gtk_dialog_run ((GtkDialog *) dialog); - gtk_widget_destroy (dialog); - - return; - } - - g_object_ref(rule); - rule_context_add_rule(context, rule); - if (user) - rule_context_save(context, user); - } - - gtk_widget_destroy(dialog); -} - -/* add a rule, with a gui, asking for confirmation first ... optionally save to path */ -void -rule_context_add_rule_gui(RuleContext *rc, FilterRule *rule, const char *title, const char *path) -{ - GtkDialog *dialog; - GtkWidget *widget; - - d(printf("add rule gui '%s'\n", rule->name)); - - g_assert(rc); - g_assert(rule); - - widget = filter_rule_get_widget(rule, rc); - gtk_widget_show(widget); - - dialog =(GtkDialog *) gtk_dialog_new(); - gtk_dialog_add_buttons(dialog, - GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, - GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, - NULL); - - gtk_window_set_title((GtkWindow *) dialog, title); - gtk_window_set_default_size((GtkWindow *) dialog, 600, 400); - gtk_window_set_resizable((GtkWindow *) dialog, TRUE); - - gtk_box_pack_start((GtkBox *) dialog->vbox, widget, TRUE, TRUE, 0); - - g_object_set_data_full((GObject *) dialog, "rule", rule, g_object_unref); - if (path) - g_object_set_data_full((GObject *) dialog, "path", g_strdup(path), g_free); - - g_signal_connect(dialog, "response", G_CALLBACK(new_rule_response), rc); - - g_object_ref(rc); - - g_object_set_data_full((GObject *) dialog, "context", rc, g_object_unref); - - gtk_widget_show((GtkWidget *) dialog); -} - -void -rule_context_remove_rule(RuleContext *rc, FilterRule *rule) -{ - g_assert(rc); - g_assert(rule); - - d(printf("remove rule '%s'\n", rule->name)); - - rc->rules = g_list_remove(rc->rules, rule); - - if (rc->priv->frozen == 0) { - g_signal_emit(rc, signals[RULE_REMOVED], 0, rule); - g_signal_emit(rc, signals[CHANGED], 0); - } -} - -void -rule_context_rank_rule(RuleContext *rc, FilterRule *rule, const char *source, int rank) -{ - GList *node; - int i = 0, index = 0; - - g_assert(rc); - g_assert(rule); - - if (rule_context_get_rank_rule (rc, rule, source) == rank) - return; - - rc->rules = g_list_remove(rc->rules, rule); - node = rc->rules; - while (node) { - FilterRule *r = node->data; - - if (i == rank) { - rc->rules = g_list_insert(rc->rules, rule, index); - if (rc->priv->frozen == 0) - g_signal_emit(rc, signals[CHANGED], 0); - - return; - } - - index++; - if (source == NULL || (r->source && strcmp(r->source, source) == 0)) - i++; - - node = node->next; - } - - rc->rules = g_list_append(rc->rules, rule); - if (rc->priv->frozen == 0) - g_signal_emit(rc, signals[CHANGED], 0); -} - -int -rule_context_get_rank_rule(RuleContext *rc, FilterRule *rule, const char *source) -{ - GList *node; - int i = 0; - - g_assert(rc); - g_assert(rule); - - d(printf("getting rank of rule '%s'\n", rule->name)); - - node = rc->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 *rc, int rank, const char *source) -{ - GList *node; - int i = 0; - - g_assert(rc); - - d(printf("getting rule at rank %d source '%s'\n", rank, source?source:"")); - - node = rc->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 GList * -delete_uri(RuleContext *rc, const char *uri, GCompareFunc cmp) -{ - return NULL; -} - -GList * -rule_context_delete_uri(RuleContext *rc, const char *uri, GCompareFunc cmp) -{ - return RULE_CONTEXT_GET_CLASS(rc)->delete_uri(rc, uri, cmp); -} - -static GList * -rename_uri(RuleContext *rc, const char *olduri, const char *newuri, GCompareFunc cmp) -{ - return NULL; -} - -GList * -rule_context_rename_uri(RuleContext *rc, const char *olduri, const char *newuri, GCompareFunc cmp) -{ - return RULE_CONTEXT_GET_CLASS(rc)->rename_uri(rc, olduri, newuri, cmp); -} - -void -rule_context_free_uri_list(RuleContext *rc, GList *uris) -{ - GList *l = uris, *n; - - /* TODO: should be virtual */ - - while (l) { - n = l->next; - g_free(l->data); - g_list_free_1(l); - l = n; - } -} diff --git a/filter/rule-context.h b/filter/rule-context.h deleted file mode 100644 index 6e7a7f9443..0000000000 --- a/filter/rule-context.h +++ /dev/null @@ -1,136 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 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. - */ - - -#ifndef _RULE_CONTEXT_H -#define _RULE_CONTEXT_H - -#include -#include -#include - -#include "filter-part.h" -#include "filter-rule.h" - -#define RULE_TYPE_CONTEXT (rule_context_get_type ()) -#define RULE_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RULE_TYPE_CONTEXT, RuleContext)) -#define RULE_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RULE_TYPE_CONTEXT, RuleContextClass)) -#define IS_RULE_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RULE_TYPE_CONTEXT)) -#define IS_RULE_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RULE_TYPE_CONTEXT)) -#define RULE_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RULE_TYPE_CONTEXT, RuleContextClass)) - -typedef struct _RuleContext RuleContext; -typedef struct _RuleContextClass RuleContextClass; - -struct _RuleContext { - GObject parent_object; - 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 *rc, FilterRule *rule, gpointer user_data); - -struct _RuleContextClass { - GObjectClass parent_class; - - /* virtual methods */ - int (*load) (RuleContext *rc, const char *system, const char *user); - int (*save) (RuleContext *rc, const char *user); - int (*revert) (RuleContext *rc, const char *user); - - GList *(*delete_uri) (RuleContext *rc, const char *uri, GCompareFunc cmp); - GList *(*rename_uri) (RuleContext *rc, const char *olduri, const char *newuri, GCompareFunc cmp); - - /* signals */ - void (*rule_added) (RuleContext *rc, FilterRule *rule); - void (*rule_removed) (RuleContext *rc, FilterRule *rule); - void (*changed) (RuleContext *rc); -}; - -typedef void (*RCPartFunc) (RuleContext *rc, FilterPart *part); -typedef void (*RCRuleFunc) (RuleContext *rc, FilterRule *part); -typedef FilterPart * (*RCNextPartFunc) (RuleContext *rc, FilterPart *part); -typedef FilterRule * (*RCNextRuleFunc) (RuleContext *rc, 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; -}; - -GType rule_context_get_type (void); -RuleContext *rule_context_new (void); - -/* methods */ -int rule_context_load (RuleContext *rc, const char *system, const char *user); -int rule_context_save (RuleContext *rc, const char *user); -int rule_context_revert (RuleContext *rc, const char *user); - -void rule_context_add_part (RuleContext *rc, FilterPart *new); -FilterPart *rule_context_find_part (RuleContext *rc, const char *name); -FilterPart *rule_context_create_part (RuleContext *rc, const char *name); -FilterPart *rule_context_next_part (RuleContext *rc, FilterPart *last); - -FilterRule *rule_context_next_rule (RuleContext *rc, FilterRule *last, const char *source); -FilterRule *rule_context_find_rule (RuleContext *rc, const char *name, const char *source); -FilterRule *rule_context_find_rank_rule (RuleContext *rc, int rank, const char *source); -void rule_context_add_rule (RuleContext *rc, FilterRule *new); -void rule_context_add_rule_gui (RuleContext *rc, FilterRule *rule, const char *title, const char *path); -void rule_context_remove_rule (RuleContext *rc, FilterRule *rule); - -/* get/set the rank (position) of a rule */ -void rule_context_rank_rule (RuleContext *rc, FilterRule *rule, const char *source, int rank); -int rule_context_get_rank_rule (RuleContext *rc, FilterRule *rule, const char *source); - -/* setup type for set parts */ -void rule_context_add_part_set (RuleContext *rc, const char *setname, int part_type, - RCPartFunc append, RCNextPartFunc next); -void rule_context_add_rule_set (RuleContext *rc, const char *setname, int rule_type, - RCRuleFunc append, RCNextRuleFunc next); - -/* uri's disappear/renamed externally */ -GList *rule_context_delete_uri (RuleContext *rc, const char *uri, GCompareFunc cmp); -GList *rule_context_rename_uri (RuleContext *rc, const char *olduri, const char *newuri, GCompareFunc cmp); - -void rule_context_free_uri_list (RuleContext *rc, GList *uris); - -#endif /* ! _RULE_CONTEXT_H */ diff --git a/filter/rule-editor.c b/filter/rule-editor.c deleted file mode 100644 index 32f368a06b..0000000000 --- a/filter/rule-editor.c +++ /dev/null @@ -1,750 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 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. - */ - - -#ifdef HAVE_CONFIG_H -#include -#endif - -/* for getenv only, remove when getenv need removed */ -#include - -#include - -#include "rule-editor.h" - -static int enable_undo = 0; - -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) - -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 *klass); -static void rule_editor_init (RuleEditor *re); -static void rule_editor_finalise (GObject *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 GtkDialogClass *parent_class = NULL; - - -GtkType -rule_editor_get_type (void) -{ - static GtkType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (RuleEditorClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) rule_editor_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (RuleEditor), - 0, /* n_preallocs */ - (GInstanceInitFunc) rule_editor_init, - }; - - /* TODO: Remove when it works (or never will) */ - enable_undo = getenv ("EVOLUTION_RULE_UNDO") != NULL; - - type = g_type_register_static (gtk_dialog_get_type (), "RuleEditor", &info, 0); - } - - return type; -} - -static void -rule_editor_class_init (RuleEditorClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - GtkObjectClass *object_class = (GtkObjectClass *) klass; - - parent_class = g_type_class_ref(gtk_dialog_get_type ()); - - gobject_class->finalize = rule_editor_finalise; - object_class->destroy = rule_editor_destroy; - - /* override methods */ - klass->set_source = set_source; - klass->set_sensitive = set_sensitive; - klass->create_rule = create_rule; -} - -static void -rule_editor_init (RuleEditor *re) -{ - re->priv = g_malloc0 (sizeof (*re->priv)); -} - -static void -rule_editor_finalise (GObject *obj) -{ - RuleEditor *re = (RuleEditor *)obj; - RuleEditorUndo *undo, *next; - - g_object_unref (re->context); - g_free (re->priv); - - undo = re->undo_log; - while (undo) { - next = undo->next; - g_object_unref (undo->rule); - g_free (undo); - undo = next; - } - - G_OBJECT_CLASS (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)); - re->dialog = NULL; - } - - ((GtkObjectClass *)(parent_class))->destroy (obj); -} - -/** - * rule_editor_new: - * - * Create a new RuleEditor object. - * - * Return value: A new #RuleEditor object. - **/ -RuleEditor * -rule_editor_new (RuleContext *rc, const char *source) -{ - RuleEditor *re = (RuleEditor *) g_object_new (RULE_TYPE_EDITOR, NULL); - GladeXML *gui; - GtkWidget *w; - - gui = glade_xml_new (FILTER_GLADEDIR "/filter.glade", "rule_editor", NULL); - rule_editor_construct (re, rc, gui, source); - - w = glade_xml_get_widget (gui, "rule_frame"); - gtk_frame_set_label ((GtkFrame *) w, _("Rules")); - - g_object_unref (gui); - - return re; -} - -/* used internally by implementations if required */ -void -rule_editor_set_sensitive (RuleEditor *re) -{ - RULE_EDITOR_GET_CLASS (re)->set_sensitive (re); -} - -/* used internally by implementations */ -void -rule_editor_set_source (RuleEditor *re, const char *source) -{ - RULE_EDITOR_GET_CLASS (re)->set_source (re, source); -} - -/* factory method for "add" button */ -FilterRule * -rule_editor_create_rule (RuleEditor *re) -{ - return RULE_EDITOR_GET_CLASS (re)->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 -editor_destroy (RuleEditor *re, GObject *deadbeef) -{ - if (re->edit) { - g_object_unref (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_response (GtkWidget *dialog, int button, RuleEditor *re) -{ - GtkTreeSelection *selection; - GtkTreePath *path; - GtkTreeIter iter; - - if (button == GTK_RESPONSE_ACCEPT) { - if (!filter_rule_validate (re->edit)) { - /* no need to popup a dialog because the validate code does that. */ - return; - } - - if (rule_context_find_rule (re->context, re->edit->name, re->edit->source)) { - dialog = gtk_message_dialog_new ((GtkWindow *) dialog, GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, - _("Rule name '%s' is not unique, choose another."), - re->edit->name); - - gtk_dialog_run ((GtkDialog *) dialog); - gtk_widget_destroy (dialog); - - return; - } - - g_object_ref (re->edit); - - gtk_list_store_append (re->model, &iter); - gtk_list_store_set (re->model, &iter, 0, re->edit->name, 1, re->edit, -1); - selection = gtk_tree_view_get_selection (re->list); - gtk_tree_selection_select_iter (selection, &iter); - - /* scroll to the newly added row */ - path = gtk_tree_model_get_path ((GtkTreeModel *) re->model, &iter); - gtk_tree_view_scroll_to_cell (re->list, path, NULL, TRUE, 1.0, 0.0); - gtk_tree_path_free (path); - - re->current = re->edit; - rule_context_add_rule (re->context, re->current); - - g_object_ref (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); - } - - gtk_widget_destroy (dialog); -} - -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 = gtk_dialog_new (); - gtk_dialog_add_buttons ((GtkDialog *) re->dialog, - GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, - GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, - NULL); - - gtk_window_set_title ((GtkWindow *) re->dialog, _("Add Rule")); - gtk_window_set_default_size (GTK_WINDOW (re->dialog), 650, 400); - gtk_window_set_resizable (GTK_WINDOW (re->dialog), TRUE); - gtk_window_set_transient_for ((GtkWindow *) re->dialog, (GtkWindow *) re); - gtk_container_set_border_width ((GtkContainer *) re->dialog, 6); - - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (re->dialog)->vbox), rules, TRUE, TRUE, 3); - - g_signal_connect (re->dialog, "response", G_CALLBACK (add_editor_response), re); - g_object_weak_ref ((GObject *) re->dialog, (GWeakNotify) editor_destroy, re); - - gtk_widget_set_sensitive (GTK_WIDGET (re), FALSE); - - gtk_widget_show (re->dialog); -} - -static void -edit_editor_response (GtkWidget *dialog, int button, RuleEditor *re) -{ - FilterRule *rule; - GtkTreePath *path; - GtkTreeIter iter; - int pos; - - if (button == GTK_RESPONSE_ACCEPT) { - if (!filter_rule_validate (re->edit)) { - /* no need to popup a dialog because the validate code does that. */ - return; - } - - rule = rule_context_find_rule (re->context, re->edit->name, re->edit->source); - if (rule != NULL && rule != re->current) { - dialog = gtk_message_dialog_new ((GtkWindow *) dialog, - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, - _("Rule name '%s' is not unique, choose another."), - re->edit->name); - - gtk_dialog_run ((GtkDialog *) dialog); - gtk_widget_destroy (dialog); - - return; - } - - pos = rule_context_get_rank_rule (re->context, re->current, re->source); - if (pos != -1) { - path = gtk_tree_path_new (); - gtk_tree_path_append_index (path, pos); - gtk_tree_model_get_iter (GTK_TREE_MODEL (re->model), &iter, path); - gtk_tree_path_free (path); - - gtk_list_store_set (re->model, &iter, 0, re->edit->name, -1); - - 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); - } - } - - gtk_widget_destroy (dialog); -} - -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 = gtk_dialog_new (); - gtk_dialog_add_buttons ((GtkDialog *) re->dialog, - GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, - GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, - NULL); - - gtk_window_set_title ((GtkWindow *) re->dialog, _("Edit Rule")); - gtk_window_set_default_size (GTK_WINDOW (re->dialog), 650, 400); - gtk_window_set_resizable (GTK_WINDOW (re->dialog), TRUE); - gtk_widget_set_parent_window (GTK_WIDGET (re->dialog), GTK_WIDGET (re)->window); - gtk_container_set_border_width ((GtkContainer *) re->dialog, 6); - - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (re->dialog)->vbox), rules, TRUE, TRUE, 3); - - g_signal_connect (re->dialog, "response", G_CALLBACK (edit_editor_response), re); - g_object_weak_ref ((GObject *) re->dialog, (GWeakNotify) editor_destroy, re); - - gtk_widget_set_sensitive (GTK_WIDGET (re), FALSE); - - gtk_widget_show (re->dialog); -} - -static void -rule_delete (GtkWidget *widget, RuleEditor *re) -{ - GtkTreeSelection *selection; - GtkTreePath *path; - GtkTreeIter iter; - int pos, len; - - d(printf ("delete rule\n")); - pos = rule_context_get_rank_rule (re->context, re->current, re->source); - if (pos != -1) { - rule_context_remove_rule (re->context, re->current); - - path = gtk_tree_path_new (); - gtk_tree_path_append_index (path, pos); - gtk_tree_model_get_iter (GTK_TREE_MODEL (re->model), &iter, path); - gtk_list_store_remove (re->model, &iter); - gtk_tree_path_free (path); - - 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 - g_object_unref (re->current); -#endif - re->current = NULL; - - /* now select the next rule */ - len = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (re->model), NULL); - pos = pos >= len ? len - 1 : pos; - - if (pos >= 0) { - path = gtk_tree_path_new (); - gtk_tree_path_append_index (path, pos); - gtk_tree_model_get_iter (GTK_TREE_MODEL (re->model), &iter, path); - gtk_tree_path_free (path); - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (re->list)); - gtk_tree_selection_select_iter (selection, &iter); - - /* scroll to the selected row */ - path = gtk_tree_model_get_path ((GtkTreeModel *) re->model, &iter); - gtk_tree_view_scroll_to_cell (re->list, path, NULL, FALSE, 0.0, 0.0); - gtk_tree_path_free (path); - } - } - - rule_editor_set_sensitive (re); -} - -static void -rule_move (RuleEditor *re, int from, int to) -{ - GtkTreeSelection *selection; - GtkTreePath *path; - GtkTreeIter iter; - FilterRule *rule; - - g_object_ref (re->current); - rule_editor_add_undo (re, RULE_EDITOR_LOG_RANK, re->current, - rule_context_get_rank_rule (re->context, re->current, re->source), to); - - d(printf ("moving %d to %d\n", from, to)); - rule_context_rank_rule (re->context, re->current, re->source, to); - - path = gtk_tree_path_new (); - gtk_tree_path_append_index (path, from); - gtk_tree_model_get_iter (GTK_TREE_MODEL (re->model), &iter, path); - gtk_tree_path_free (path); - - gtk_tree_model_get (GTK_TREE_MODEL (re->model), &iter, 1, &rule, -1); - g_assert (rule != NULL); - - /* remove and then re-insert the row at the new location */ - gtk_list_store_remove (re->model, &iter); - gtk_list_store_insert (re->model, &iter, to); - - /* set the data on the row */ - gtk_list_store_set (re->model, &iter, 0, rule->name, 1, rule, -1); - - /* select the row */ - selection = gtk_tree_view_get_selection (re->list); - gtk_tree_selection_select_iter (selection, &iter); - - /* scroll to the selected row */ - path = gtk_tree_model_get_path ((GtkTreeModel *) re->model, &iter); - gtk_tree_view_scroll_to_cell (re->list, path, NULL, FALSE, 0.0, 0.0); - gtk_tree_path_free (path); - - 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", G_CALLBACK (rule_add) }, - { "rule_edit", G_CALLBACK (rule_edit) }, - { "rule_delete", G_CALLBACK (rule_delete) }, - { "rule_up", G_CALLBACK (rule_up) }, - { "rule_down", G_CALLBACK (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 -cursor_changed (GtkTreeView *treeview, RuleEditor *re) -{ - GtkTreeSelection *selection; - GtkTreeModel *model; - GtkTreeIter iter; - - selection = gtk_tree_view_get_selection (re->list); - if (gtk_tree_selection_get_selected (selection, &model, &iter)) { - gtk_tree_model_get (GTK_TREE_MODEL (re->model), &iter, 1, &re->current, -1); - - g_assert (re->current); - - rule_editor_set_sensitive (re); - } -} - -static void -double_click (GtkTreeView *treeview, GtkTreePath *path, GtkTreeViewColumn *column, RuleEditor *re) -{ - if (re->current) - rule_edit ((GtkWidget *) treeview, re); -} - -static void -set_source (RuleEditor *re, const char *source) -{ - FilterRule *rule = NULL; - GtkTreeIter iter; - - gtk_list_store_clear (re->model); - - d(printf("Checking for rules that are of type %s\n", source ? source : "")); - while ((rule = rule_context_next_rule (re->context, rule, source)) != NULL) { - d(printf("Adding row '%s'\n", rule->name)); - gtk_list_store_append (re->model, &iter); - gtk_list_store_set (re->model, &iter, 0, rule->name, 1, rule, -1); - } - - 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 { - g_object_unref (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: - d(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) { - d(printf (" name was '%s'\n", rule->name)); - filter_rule_copy (rule, undo->rule); - d(printf (" name is '%s'\n", rule->name)); - } else { - g_warning ("Could not find the right rule to undo against?"); - } - break; - case RULE_EDITOR_LOG_ADD: - d(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: - d(printf ("Undoing remove on rule '%s'\n", undo->rule->name)); - g_object_ref (undo->rule); - rule_context_add_rule (re->context, undo->rule); - rule_context_rank_rule (re->context, undo->rule, re->source, 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, re->source, undo->rank); - break; - } - - g_object_unref (undo->rule); - g_free (undo); - undo = next; - } - re->undo_active = FALSE; -} - -static void -editor_response (GtkWidget *dialog, int button, RuleEditor *re) -{ - if (button == GTK_RESPONSE_REJECT) { - 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; - g_object_unref (undo->rule); - g_free (undo); - undo = next; - } - } - } -} - -GtkWidget *rule_editor_treeview_new (char *widget_name, char *string1, char *string2, - int int1, int int2); - -GtkWidget * -rule_editor_treeview_new (char *widget_name, char *string1, char *string2, int int1, int int2) -{ - GtkWidget *table, *scrolled; - GtkTreeSelection *selection; - GtkCellRenderer *renderer; - GtkListStore *model; - - scrolled = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - - model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER); - table = gtk_tree_view_new_with_model ((GtkTreeModel *) model); - gtk_tree_view_set_headers_visible ((GtkTreeView *) table, FALSE); - - renderer = gtk_cell_renderer_text_new (); - gtk_tree_view_insert_column_with_attributes ((GtkTreeView *) table, -1, - _("Rule name"), renderer, - "text", 0, NULL); - - selection = gtk_tree_view_get_selection ((GtkTreeView *) table); - gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); - - gtk_container_add (GTK_CONTAINER (scrolled), table); - - g_object_set_data ((GObject *) scrolled, "table", table); - g_object_set_data ((GObject *) scrolled, "model", model); - - gtk_widget_show (scrolled); - gtk_widget_show (table); - - return scrolled; -} - -void -rule_editor_construct (RuleEditor *re, RuleContext *context, GladeXML *gui, const char *source) -{ - GtkWidget *w; - int i; - - re->context = context; - g_object_ref (context); - - gtk_window_set_resizable ((GtkWindow *) re, TRUE); - gtk_window_set_default_size ((GtkWindow *) re, 350, 400); - gtk_container_set_border_width ((GtkContainer *) re, 6); - - w = glade_xml_get_widget (gui, "rule_editor"); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (re)->vbox), w, TRUE, TRUE, 3); - - for (i = 0; i < BUTTON_LAST; i++) { - re->priv->buttons[i] = (GtkButton *) w = glade_xml_get_widget (gui, edit_buttons[i].name); - g_signal_connect (w, "clicked", edit_buttons[i].func, re); - } - - w = glade_xml_get_widget (gui, "rule_list"); - re->list = (GtkTreeView *) g_object_get_data ((GObject *) w, "table"); - re->model = (GtkListStore *) g_object_get_data ((GObject *) w, "model"); - - g_signal_connect (re->list, "cursor-changed", G_CALLBACK (cursor_changed), re); - g_signal_connect (re->list, "row-activated", G_CALLBACK (double_click), re); - - g_signal_connect (re, "response", G_CALLBACK (editor_response), re); - rule_editor_set_source (re, source); - - if (enable_undo) { - gtk_dialog_add_buttons ((GtkDialog *) re, - GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, - GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, - NULL); - } else { - gtk_dialog_add_buttons ((GtkDialog *) re, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, - NULL); - } -} diff --git a/filter/rule-editor.h b/filter/rule-editor.h deleted file mode 100644 index d2e9797e46..0000000000 --- a/filter/rule-editor.h +++ /dev/null @@ -1,103 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 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. - */ - - -#ifndef _RULE_EDITOR_H -#define _RULE_EDITOR_H - -#include -#include - -#include "rule-context.h" -#include "filter-rule.h" - -#define RULE_TYPE_EDITOR (rule_editor_get_type ()) -#define RULE_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RULE_TYPE_EDITOR, RuleEditor)) -#define RULE_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RULE_TYPE_EDITOR, RuleEditorClass)) -#define IS_RULE_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RULE_TYPE_EDITOR)) -#define IS_RULE_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RULE_TYPE_EDITOR)) -#define RULE_EDITOR_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), RULE_TYPE_EDITOR, RuleEditorClass)) - -typedef struct _RuleEditor RuleEditor; -typedef struct _RuleEditorClass RuleEditorClass; -typedef struct _RuleEditorUndo RuleEditorUndo; - -struct _RuleEditor { - GtkDialog parent_object; - - GtkListStore *model; - GtkTreeView *list; - - RuleContext *context; - FilterRule *current; - 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 { - GtkDialogClass parent_class; - - /* virtual methods */ - void (*set_sensitive) (RuleEditor *); - void (*set_source) (RuleEditor *, const char *source); - - 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; - FilterRule *rule; - int rank; - int newrank; -}; - -GtkType rule_editor_get_type (void); -RuleEditor *rule_editor_new (struct _RuleContext *, const char *source); -void rule_editor_construct (RuleEditor *re, RuleContext *context, 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 dd3663ffab..0000000000 --- a/filter/score-context.c +++ /dev/null @@ -1,101 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 Ximian Inc. - * - * Authors: Not Zed - * 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 "score-context.h" -#include "score-rule.h" - - -static void score_context_class_init (ScoreContextClass *klass); -static void score_context_init (ScoreContext *sc); -static void score_context_finalise (GObject *obj); - - -static RuleContextClass *parent_class = NULL; - - -GType -score_context_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (ScoreContextClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) score_context_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (ScoreContext), - 0, /* n_preallocs */ - (GInstanceInitFunc) score_context_init, - }; - - type = g_type_register_static (RULE_TYPE_CONTEXT, "ScoreContext", &info, 0); - } - - return type; -} - -static void -score_context_class_init (ScoreContextClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_ref (rule_context_get_type ()); - - object_class->finalize = score_context_finalise; -} - -static void -score_context_init (ScoreContext *sc) -{ - rule_context_add_part_set ((RuleContext *) sc, "partset", filter_part_get_type (), - rule_context_add_part, rule_context_next_part); - - rule_context_add_rule_set ((RuleContext *) sc, "ruleset", score_rule_get_type (), - rule_context_add_rule, rule_context_next_rule); -} - -static void -score_context_finalise (GObject *obj) -{ - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -/** - * score_context_new: - * - * Create a new ScoreContext object. - * - * Return value: A new #ScoreContext object. - **/ -ScoreContext * -score_context_new (void) -{ - return (ScoreContext *) g_object_new (SCORE_TYPE_CONTEXT, NULL, NULL); -} diff --git a/filter/score-context.h b/filter/score-context.h deleted file mode 100644 index 7a76ac8d32..0000000000 --- a/filter/score-context.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 Ximian Inc. - * - * Authors: Not Zed - * 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. - */ - -#ifndef _SCORE_CONTEXT_H -#define _SCORE_CONTEXT_H - -#include "rule-context.h" - -#define SCORE_TYPE_CONTEXT (score_context_get_type ()) -#define SCORE_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SCORE_TYPE_CONTEXT, ScoreContext)) -#define SCORE_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SCORE_TYPE_CONTEXT, ScoreContextClass)) -#define IS_SCORE_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SCORE_TYPE_CONTEXT)) -#define IS_SCORE_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SCORE_TYPE_CONTEXT)) -#define SCORE_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SCORE_TYPE_CONTEXT, ScoreContextClass)) - -typedef struct _ScoreContext ScoreContext; -typedef struct _ScoreContextClass ScoreContextClass; - -struct _ScoreContext { - RuleContext parent_object; - -}; - -struct _ScoreContextClass { - RuleContextClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - - -GType score_context_get_type (void); - -ScoreContext *score_context_new (void); - -/* methods */ - -#endif /* ! _SCORE_CONTEXT_H */ diff --git a/filter/score-editor.c b/filter/score-editor.c deleted file mode 100644 index 9a8c0a626c..0000000000 --- a/filter/score-editor.c +++ /dev/null @@ -1,133 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2001-2002 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. - */ - - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include - -#include "score-editor.h" -#include "score-rule.h" - -#define d(x) - -static FilterRule * create_rule(RuleEditor *re); - -static void score_editor_class_init (ScoreEditorClass *klass); -static void score_editor_init (ScoreEditor *se); -static void score_editor_finalise (GObject *obj); - - -static RuleEditorClass *parent_class = NULL; - - -GtkType -score_editor_get_type (void) -{ - static GtkType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (ScoreEditorClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) score_editor_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (ScoreEditor), - 0, /* n_preallocs */ - (GInstanceInitFunc) score_editor_init, - }; - - type = g_type_register_static (RULE_TYPE_EDITOR, "ScoreEditor", &info, 0); - } - - return type; -} - -static void -score_editor_class_init (ScoreEditorClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - RuleEditorClass *re_class = (RuleEditorClass *) klass; - - parent_class = g_type_class_ref(rule_editor_get_type ()); - - gobject_class->finalize = score_editor_finalise; - - /* override methods */ - re_class->create_rule = create_rule; -} - -static void -score_editor_init (ScoreEditor *se) -{ - ; -} - -static void -score_editor_finalise (GObject *obj) -{ - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -/** - * score_editor_new: - * - * Create a new ScoreEditor object. - * - * Return value: A new #ScoreEditor object. - **/ -ScoreEditor * -score_editor_new (ScoreContext *sc) -{ - ScoreEditor *se = (ScoreEditor *) g_object_new (SCORE_TYPE_EDITOR, NULL); - GladeXML *gui; - GtkWidget *w; - - gui = glade_xml_new (FILTER_GLADEDIR "/filter.glade", "rule_editor", NULL); - rule_editor_construct ((RuleEditor *) se, (RuleContext *) sc, gui, NULL); - - w = glade_xml_get_widget (gui, "rule_frame"); - gtk_frame_set_label ((GtkFrame *) w, _("Score Rules")); - - g_object_unref (gui); - - return se; -} - -static FilterRule * -create_rule (RuleEditor *re) -{ - FilterRule *rule = filter_rule_new (); - FilterPart *part; - - /* create a rule with 1 part in it */ - rule = (FilterRule *) score_rule_new (); - part = rule_context_next_part (re->context, NULL); - filter_rule_add_part (rule, filter_part_clone (part)); - - return rule; -} diff --git a/filter/score-editor.h b/filter/score-editor.h deleted file mode 100644 index 85bff02140..0000000000 --- a/filter/score-editor.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 Ximian Inc. - * - * Authors: Not Zed - * 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. - */ - - -#ifndef _SCORE_EDITOR_H -#define _SCORE_EDITOR_H - -#include "rule-editor.h" -#include "score-context.h" - -#define SCORE_TYPE_EDITOR (score_editor_get_type ()) -#define SCORE_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SCORE_TYPE_EDITOR, ScoreEditor)) -#define SCORE_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SCORE_TYPE_EDITOR, ScoreEditorClass)) -#define IS_SCORE_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SCORE_TYPE_EDITOR)) -#define IS_SCORE_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SCORE_TYPE_EDITOR)) -#define SCORE_EDITOR_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), SCORE_TYPE_EDITOR, ScoreEditorClass)) - -typedef struct _ScoreEditor ScoreEditor; -typedef struct _ScoreEditorClass ScoreEditorClass; - -struct _ScoreEditor { - RuleEditor parent_object; - -}; - -struct _ScoreEditorClass { - RuleEditorClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - - -GType score_editor_get_type (void); - -ScoreEditor *score_editor_new (ScoreContext *sc); - -#endif /* ! _SCORE_EDITOR_H */ diff --git a/filter/score-rule.c b/filter/score-rule.c deleted file mode 100644 index 9865b320cf..0000000000 --- a/filter/score-rule.c +++ /dev/null @@ -1,201 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 Ximian Inc. - * - * Authors: Not Zed - * 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 "score-rule.h" - -static xmlNodePtr xml_encode(FilterRule *); -static int xml_decode(FilterRule *, xmlNodePtr, struct _RuleContext *f); -/*static void build_code(FilterRule *, GString *out);*/ -static GtkWidget *get_widget(FilterRule *fr, struct _RuleContext *f); - -static void score_rule_class_init (ScoreRuleClass *klass); -static void score_rule_init (ScoreRule *sr); -static void score_rule_finalise (GObject *obj); - - -static FilterRuleClass *parent_class = NULL; - - -GType -score_rule_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (ScoreRuleClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) score_rule_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (ScoreRule), - 0, /* n_preallocs */ - (GInstanceInitFunc) score_rule_init, - }; - - type = g_type_register_static (FILTER_TYPE_RULE, "ScoreRule", &info, 0); - } - - return type; -} - -static void -score_rule_class_init (ScoreRuleClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - FilterRuleClass *rule_class = (FilterRuleClass *) klass; - - parent_class = g_type_class_ref (FILTER_TYPE_RULE); - - object_class->finalize = score_rule_finalise; - - /* override methods */ - rule_class->xml_encode = xml_encode; - rule_class->xml_decode = xml_decode; -/* rule_class->build_code = build_code;*/ - rule_class->get_widget = get_widget; -} - -static void -score_rule_init (ScoreRule *sr) -{ - ; -} - -static void -score_rule_finalise (GObject *obj) -{ - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -/** - * score_rule_new: - * - * Create a new ScoreRule object. - * - * Return value: A new #ScoreRule object. - **/ -ScoreRule * -score_rule_new (void) -{ - return (ScoreRule *) g_object_new (SCORE_TYPE_RULE, NULL, NULL); -} - -static xmlNodePtr -xml_encode (FilterRule *fr) -{ - ScoreRule *sr = (ScoreRule *)fr; - xmlNodePtr node, value; - char number[16]; - - node = FILTER_RULE_CLASS (parent_class)->xml_encode (fr); - sprintf (number, "%d", sr->score); - value = xmlNewNode (NULL, "score"); - xmlSetProp (value, "value", number); - xmlAddChild (node, value); - - return node; -} - -static int -xml_decode (FilterRule *fr, xmlNodePtr node, struct _RuleContext *f) -{ - ScoreRule *sr = (ScoreRule *) fr; - xmlNodePtr value; - int result; - char *str; - - result = FILTER_RULE_CLASS (parent_class)->xml_decode (fr, node, f); - if (result != 0) - return result; - - value = node->children; - while (value) { - if (!strcmp (value->name, "score")) { - str = xmlGetProp (value, "value"); - sscanf (str, "%d", &sr->score); - xmlFree (str); - - /* score range is -3 to +3 */ - if (sr->score > 3) - sr->score = 3; - else if (sr->score < -3) - sr->score = -3; - } - value = value->next; - } - - return 0; -} - -/*static void build_code(FilterRule *fr, GString *out) -{ -}*/ - -static void -spin_changed (GtkAdjustment *adj, ScoreRule *sr) -{ - sr->score = adj->value; -} - -static GtkWidget * -get_widget (FilterRule *fr, struct _RuleContext *f) -{ - GtkWidget *widget; - GtkWidget *frame; - GtkWidget *label; - GtkWidget *hbox; - GtkAdjustment *adj; - ScoreRule *sr = (ScoreRule *)fr; - GtkWidget *spin; - - widget = FILTER_RULE_CLASS (parent_class)->get_widget (fr, f); - - frame = gtk_frame_new (_("Score")); - hbox = gtk_hbox_new (FALSE, 3); - label = gtk_label_new (_("Score")); - - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 3); - adj = (GtkAdjustment *) gtk_adjustment_new ((float) sr->score, -3.0, 3.0, 1.0, 1.0, 1.0); - g_signal_connect (adj, "value_changed", G_CALLBACK (spin_changed), sr); - - spin = gtk_spin_button_new (adj, 1.0, 0); - gtk_box_pack_start (GTK_BOX (hbox), spin, FALSE, FALSE, 3); - gtk_container_add (GTK_CONTAINER (frame), hbox); - - gtk_widget_show_all (frame); - - gtk_box_pack_start (GTK_BOX (widget), frame, FALSE, FALSE, 3); - - return widget; -} diff --git a/filter/score-rule.h b/filter/score-rule.h deleted file mode 100644 index fbd8f649de..0000000000 --- a/filter/score-rule.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 Ximian Inc. - * - * Authors: Not Zed - * 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. - */ - - -#ifndef _SCORE_RULE_H -#define _SCORE_RULE_H - -#include "filter-rule.h" - -#define SCORE_TYPE_RULE (score_rule_get_type ()) -#define SCORE_RULE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SCORE_TYPE_RULE, ScoreRule)) -#define SCORE_RULE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SCORE_TYPE_RULE, ScoreRuleClass)) -#define IS_SCORE_RULE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SCORE_TYPE_RULE)) -#define IS_SCORE_RULE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SCORE_TYPE_RULE)) -#define SCORE_RULE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SCORE_TYPE_RULE, ScoreRuleClass)) - -typedef struct _ScoreRule ScoreRule; -typedef struct _ScoreRuleClass ScoreRuleClass; - -struct _ScoreRule { - FilterRule parent_object; - - int score; -}; - -struct _ScoreRuleClass { - FilterRuleClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - - -GType score_rule_get_type (void); - -ScoreRule *score_rule_new (void); - -/* methods */ - -#endif /* ! _SCORE_RULE_H */ diff --git a/filter/vfolder-context.c b/filter/vfolder-context.c deleted file mode 100644 index 9c2eee4278..0000000000 --- a/filter/vfolder-context.c +++ /dev/null @@ -1,100 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 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. - */ - - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "vfolder-context.h" -#include "vfolder-rule.h" - -static void vfolder_context_class_init (VfolderContextClass *klass); -static void vfolder_context_init (VfolderContext *vc); -static void vfolder_context_finalise (GObject *obj); - - -static RuleContextClass *parent_class = NULL; - - -GType -vfolder_context_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (VfolderContextClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) vfolder_context_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (VfolderContext), - 0, /* n_preallocs */ - (GInstanceInitFunc) vfolder_context_init, - }; - - type = g_type_register_static (RULE_TYPE_CONTEXT, "VfolderContext", &info, 0); - } - - return type; -} - -static void -vfolder_context_class_init (VfolderContextClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_ref (RULE_TYPE_CONTEXT); - - object_class->finalize = vfolder_context_finalise; -} - -static void -vfolder_context_init (VfolderContext *vc) -{ - rule_context_add_part_set ((RuleContext *) vc, "partset", filter_part_get_type (), - rule_context_add_part, rule_context_next_part); - - rule_context_add_rule_set ((RuleContext *) vc, "ruleset", vfolder_rule_get_type (), - rule_context_add_rule, rule_context_next_rule); -} - -static void -vfolder_context_finalise (GObject *obj) -{ - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -/** - * vfolder_context_new: - * - * Create a new VfolderContext object. - * - * Return value: A new #VfolderContext object. - **/ -VfolderContext * -vfolder_context_new (void) -{ - return (VfolderContext *) g_object_new (VFOLDER_TYPE_CONTEXT, NULL, NULL); -} diff --git a/filter/vfolder-context.h b/filter/vfolder-context.h deleted file mode 100644 index bed020127d..0000000000 --- a/filter/vfolder-context.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 Ximian Inc. - * - * Authors: Not Zed - * 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. - */ - - -#ifndef _VFOLDER_CONTEXT_H -#define _VFOLDER_CONTEXT_H - -#include "rule-context.h" - -#define VFOLDER_TYPE_CONTEXT (vfolder_context_get_type ()) -#define VFOLDER_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VFOLDER_TYPE_CONTEXT, VfolderContext)) -#define VFOLDER_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VFOLDER_TYPE_CONTEXT, VfolderContextClass)) -#define IS_VFOLDER_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VFOLDER_TYPE_CONTEXT)) -#define IS_VFOLDER_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VFOLDER_TYPE_CONTEXT)) -#define VFOLDER_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VFOLDER_TYPE_CONTEXT, VfolderContextClass)) - -typedef struct _VfolderContext VfolderContext; -typedef struct _VfolderContextClass VfolderContextClass; - -struct _VfolderContext { - RuleContext parent_object; - -}; - -struct _VfolderContextClass { - RuleContextClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - - -GType vfolder_context_get_type (void); - -VfolderContext *vfolder_context_new (void); - -/* methods */ - -#endif /* ! _VFOLDER_CONTEXT_H */ diff --git a/filter/vfolder-editor.c b/filter/vfolder-editor.c deleted file mode 100644 index 3addc14bed..0000000000 --- a/filter/vfolder-editor.c +++ /dev/null @@ -1,133 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2001-2002 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. - */ - - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include - -#include "vfolder-editor.h" -#include "vfolder-rule.h" - -#define d(x) - -static FilterRule *create_rule (RuleEditor *re); - -static void vfolder_editor_class_init (VfolderEditorClass *klass); -static void vfolder_editor_init (VfolderEditor *ve); -static void vfolder_editor_finalise (GObject *obj); - - -static RuleEditorClass *parent_class = NULL; - - -GtkType -vfolder_editor_get_type (void) -{ - static GtkType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (VfolderEditorClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) vfolder_editor_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (VfolderEditor), - 0, /* n_preallocs */ - (GInstanceInitFunc) vfolder_editor_init, - }; - - type = g_type_register_static (RULE_TYPE_EDITOR, "VfolderEditor", &info, 0); - } - - return type; -} - -static void -vfolder_editor_class_init (VfolderEditorClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - RuleEditorClass *re_class = (RuleEditorClass *) klass; - - parent_class = g_type_class_ref (rule_editor_get_type ()); - - gobject_class->finalize = vfolder_editor_finalise; - - /* override methods */ - re_class->create_rule = create_rule; -} - -static void -vfolder_editor_init (VfolderEditor *ve) -{ - ; -} - -static void -vfolder_editor_finalise (GObject *obj) -{ - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -/** - * vfolder_editor_new: - * - * Create a new VfolderEditor object. - * - * Return value: A new #VfolderEditor object. - **/ -VfolderEditor * -vfolder_editor_new (VfolderContext *vc) -{ - VfolderEditor *ve = (VfolderEditor *) g_object_new (VFOLDER_TYPE_EDITOR, NULL); - GladeXML *gui; - GtkWidget *w; - - gui = glade_xml_new (FILTER_GLADEDIR "/filter.glade", "rule_editor", NULL); - rule_editor_construct ((RuleEditor *) ve, (RuleContext *) vc, gui, NULL); - - w = glade_xml_get_widget (gui, "rule_frame"); - gtk_frame_set_label ((GtkFrame *) w, _("Virtual Folders")); - - g_object_unref (gui); - - return ve; -} - -static FilterRule * -create_rule (RuleEditor *re) -{ - FilterRule *rule = filter_rule_new (); - FilterPart *part; - - /* create a rule with 1 part in it */ - rule = (FilterRule *) vfolder_rule_new (); - part = rule_context_next_part (re->context, NULL); - filter_rule_add_part (rule, filter_part_clone (part)); - - return rule; -} diff --git a/filter/vfolder-editor.h b/filter/vfolder-editor.h deleted file mode 100644 index c33f896eb3..0000000000 --- a/filter/vfolder-editor.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 Ximian Inc. - * - * Authors: Not Zed - * 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. - */ - - -#ifndef _VFOLDER_EDITOR_H -#define _VFOLDER_EDITOR_H - -#include "rule-editor.h" -#include "vfolder-context.h" - -#define VFOLDER_TYPE_EDITOR (vfolder_editor_get_type ()) -#define VFOLDER_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VFOLDER_TYPE_EDITOR, VfolderEditor)) -#define VFOLDER_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VFOLDER_TYPE_EDITOR, VfolderEditorClass)) -#define IS_VFOLDER_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VFOLDER_TYPE_EDITOR)) -#define IS_VFOLDER_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VFOLDER_TYPE_EDITOR)) -#define VFOLDER_EDITOR_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), VFOLDER_TYPE_EDITOR, VfolderEditorClass)) - -typedef struct _VfolderEditor VfolderEditor; -typedef struct _VfolderEditorClass VfolderEditorClass; - -struct _VfolderEditor { - RuleEditor parent_object; - -}; - -struct _VfolderEditorClass { - RuleEditorClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - - -GtkType vfolder_editor_get_type (void); - -VfolderEditor *vfolder_editor_new (VfolderContext *vc); - -#endif /* ! _VFOLDER_EDITOR_H */ diff --git a/filter/vfolder-rule.c b/filter/vfolder-rule.c deleted file mode 100644 index 26d024c525..0000000000 --- a/filter/vfolder-rule.c +++ /dev/null @@ -1,635 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 Ximian Inc. - * - * Author: 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. - */ - - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include -#include -#include - -#include "camel/camel-url.h" -#include "vfolder-context.h" -#include "vfolder-rule.h" -#include "shell/evolution-shell-client.h" - -#define d(x) - -static int validate(FilterRule *); -static int vfolder_eq(FilterRule *fr, FilterRule *cm); -static xmlNodePtr xml_encode(FilterRule *); -static int xml_decode(FilterRule *, xmlNodePtr, RuleContext *f); -static void rule_copy (FilterRule *dest, FilterRule *src); -/*static void build_code(FilterRule *, GString *out);*/ -static GtkWidget *get_widget(FilterRule *fr, RuleContext *f); - -extern EvolutionShellClient *global_shell_client; - -static void vfolder_rule_class_init (VfolderRuleClass *klass); -static void vfolder_rule_init (VfolderRule *vr); -static void vfolder_rule_finalise (GObject *obj); - - -static FilterRuleClass *parent_class = NULL; - - -GType -vfolder_rule_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (VfolderRuleClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) vfolder_rule_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (VfolderRule), - 0, /* n_preallocs */ - (GInstanceInitFunc) vfolder_rule_init, - }; - - type = g_type_register_static (FILTER_TYPE_RULE, "VfolderRule", &info, 0); - } - - return type; -} - -static void -vfolder_rule_class_init (VfolderRuleClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - FilterRuleClass *fr_class = (FilterRuleClass *) klass; - - parent_class = g_type_class_ref (FILTER_TYPE_RULE); - - object_class->finalize = vfolder_rule_finalise; - - /* override methods */ - fr_class->validate = validate; - fr_class->eq = vfolder_eq; - fr_class->xml_encode = xml_encode; - fr_class->xml_decode = xml_decode; - fr_class->copy = rule_copy; - /*fr_class->build_code = build_code;*/ - fr_class->get_widget = get_widget; -} - -static void -vfolder_rule_init (VfolderRule *vr) -{ - ; -} - -static void -vfolder_rule_finalise (GObject *obj) -{ - VfolderRule *vr = (VfolderRule *) obj; - - g_list_foreach (vr->sources, (GFunc) g_free, NULL); - g_list_free (vr->sources); - - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -/** - * vfolder_rule_new: - * - * Create a new VfolderRule object. - * - * Return value: A new #VfolderRule object. - **/ -VfolderRule * -vfolder_rule_new (void) -{ - return (VfolderRule *) g_object_new (VFOLDER_TYPE_RULE, NULL, NULL); -} - -void -vfolder_rule_add_source (VfolderRule *vr, const char *uri) -{ - g_assert (IS_VFOLDER_RULE (vr)); - - vr->sources = g_list_append (vr->sources, g_strdup (uri)); - - filter_rule_emit_changed ((FilterRule *) vr); -} - -const char * -vfolder_rule_find_source (VfolderRule *vr, const char *uri) -{ - GList *l; - - g_assert (IS_VFOLDER_RULE (vr)); - - /* only does a simple string or address comparison, should - probably do a decoded url comparison */ - l = vr->sources; - while (l) { - if (l->data == uri || !strcmp (l->data, uri)) - return l->data; - l = l->next; - } - - return NULL; -} - -void -vfolder_rule_remove_source (VfolderRule *vr, const char *uri) -{ - char *found; - - g_assert (IS_VFOLDER_RULE (vr)); - - found = (char *) vfolder_rule_find_source (vr, uri); - if (found) { - vr->sources = g_list_remove (vr->sources, found); - g_free (found); - filter_rule_emit_changed ((FilterRule *) vr); - } -} - -const char * -vfolder_rule_next_source (VfolderRule *vr, const char *last) -{ - GList *node; - - if (last == NULL) { - node = vr->sources; - } else { - node = g_list_find (vr->sources, (char *) last); - if (node == NULL) - node = vr->sources; - else - node = g_list_next (node); - } - - if (node) - return (const char *) node->data; - - return NULL; -} - -static int -validate (FilterRule *fr) -{ - GtkWidget *dialog; - - g_return_val_if_fail (fr != NULL, FALSE); - - if (!fr->name || !*fr->name) { - /* FIXME: set a aprent window? */ - dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, - "%s", _("You must name this vfolder.")); - - gtk_dialog_run ((GtkDialog *) dialog); - gtk_widget_destroy (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) { - /* FIXME: set a parent window? */ - dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, - "%s", _("You need to to specify at least one folder as a source.")); - - gtk_dialog_run ((GtkDialog *) dialog); - gtk_widget_destroy (dialog); - - return 0; - } - - return FILTER_RULE_CLASS (parent_class)->validate (fr); -} - -static int -list_eq (GList *al, GList *bl) -{ - int truth = TRUE; - - while (truth && al && bl) { - char *a = al->data, *b = bl->data; - - truth = strcmp (a, b) == 0; - al = al->next; - bl = bl->next; - } - - return truth && al == NULL && bl == NULL; -} - -static int -vfolder_eq (FilterRule *fr, FilterRule *cm) -{ - return FILTER_RULE_CLASS (parent_class)->eq (fr, cm) - && list_eq (((VfolderRule *) fr)->sources, ((VfolderRule *) cm)->sources); -} - -static xmlNodePtr -xml_encode (FilterRule *fr) -{ - VfolderRule *vr = (VfolderRule *) fr; - xmlNodePtr node, set, work; - GList *l; - - node = FILTER_RULE_CLASS (parent_class)->xml_encode (fr); - g_assert(node != NULL); - 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 = l->next; - } - - 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 = FILTER_RULE_CLASS (parent_class)->xml_decode (fr, node, f); - if (result != 0) - return result; - - set = node->children; - while (set) { - if (!strcmp (set->name, "sources")) { - work = set->children; - 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; - } - - FILTER_RULE_CLASS (parent_class)->copy (dest, src); -} - - -enum { - BUTTON_ADD, - BUTTON_REMOVE, - BUTTON_LAST, -}; - -struct _source_data { - RuleContext *rc; - VfolderRule *vr; - const char *current; - GtkListStore *model; - GtkTreeView *list; - GtkButton *buttons[BUTTON_LAST]; -}; - -static void source_add(GtkWidget *widget, struct _source_data *data); -static void source_remove(GtkWidget *widget, struct _source_data *data); - -static struct { - char *name; - GtkSignalFunc func; -} edit_buttons[] = { - { "source_add", G_CALLBACK (source_add) }, - { "source_remove", G_CALLBACK (source_remove) }, -}; - -static void -set_sensitive (struct _source_data *data) -{ - gtk_widget_set_sensitive ((GtkWidget *) data->buttons[BUTTON_ADD], TRUE); - gtk_widget_set_sensitive ((GtkWidget *) data->buttons[BUTTON_REMOVE], data->current != NULL); -} - -static void -select_source (GtkWidget *list, struct _source_data *data) -{ - GtkTreeViewColumn *column; - GtkTreePath *path; - GtkTreeIter iter; - - gtk_tree_view_get_cursor (data->list, &path, &column); - gtk_tree_model_get_iter (GTK_TREE_MODEL (data->model), &iter, path); - gtk_tree_path_free (path); - - gtk_tree_model_get (GTK_TREE_MODEL (data->model), &iter, 0, &data->current, -1); - - set_sensitive (data); -} - -static void -select_source_with (GtkWidget *widget, struct _source_data *data) -{ - char *source = g_object_get_data ((GObject *) widget, "source"); - - filter_rule_set_source ((FilterRule *) data->vr, source); -} - -/* attempt to make a 'nice' folder name out of the raw uri */ -static char *format_source(const char *uri) -{ - CamelURL *url = camel_url_new(uri, NULL); - GString *out; - char *res; - - /* bad uri */ - if (url == NULL) - return g_strdup(uri); - - out = g_string_new(url->protocol); - g_string_append_c(out, ':'); - if (url->user && url->host) { - g_string_append_printf(out, "%s@%s", url->user, url->host); - if (url->port) - g_string_append_printf(out, ":%d", url->port); - } - if (url->fragment) - g_string_append(out, url->fragment); - else if (url->path) - g_string_append(out, url->path); - - res = out->str; - g_string_free(out, FALSE); - - return res; -} - -static void -source_add (GtkWidget *widget, struct _source_data *data) -{ - static const char *allowed_types[] = { "mail/*", NULL }; - GNOME_Evolution_Folder *folder; - GtkTreeSelection *selection; - GtkWidget *window; - GtkTreeIter iter; - char *uri, *urinice; - - window = gtk_widget_get_toplevel (widget); - gtk_widget_set_sensitive (window, FALSE); - - evolution_shell_client_user_select_folder (global_shell_client, GTK_WINDOW (window), - _("Select Folder"), "", allowed_types, &folder); - - gtk_widget_set_sensitive (window, TRUE); - - if (folder) { - uri = g_strdup (folder->physicalUri); - data->vr->sources = g_list_append (data->vr->sources, uri); - - gtk_list_store_append (data->model, &iter); - urinice = format_source(uri); - gtk_list_store_set (data->model, &iter, 0, urinice, 1, uri, -1); - g_free(urinice); - selection = gtk_tree_view_get_selection (data->list); - gtk_tree_selection_select_iter (selection, &iter); - data->current = uri; - } - - CORBA_free (folder); - set_sensitive (data); -} - -static void -source_remove (GtkWidget *widget, struct _source_data *data) -{ - GtkTreeSelection *selection; - const char *source; - GtkTreePath *path; - GtkTreeIter iter; - int index = 0; - int n; - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (data->list)); - - source = NULL; - while ((source = vfolder_rule_next_source (data->vr, source))) { - path = gtk_tree_path_new (); - gtk_tree_path_append_index (path, index); - - if (gtk_tree_selection_path_is_selected (selection, path)) { - gtk_tree_model_get_iter (GTK_TREE_MODEL (data->model), &iter, path); - - vfolder_rule_remove_source (data->vr, source); - gtk_list_store_remove (data->model, &iter); - gtk_tree_path_free (path); - - /* now select the next rule */ - n = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (data->model), NULL); - index = index >= n ? n - 1 : index; - - if (index >= 0) { - path = gtk_tree_path_new (); - gtk_tree_path_append_index (path, index); - gtk_tree_model_get_iter (GTK_TREE_MODEL (data->model), &iter, path); - gtk_tree_path_free (path); - - gtk_tree_selection_select_iter (selection, &iter); - gtk_tree_model_get (GTK_TREE_MODEL (data->model), &iter, 0, &data->current, -1); - } else { - data->current = NULL; - } - - break; - } - - index++; - gtk_tree_path_free (path); - } - - set_sensitive (data); -} - - -GtkWidget *vfolder_editor_sourcelist_new (char *widget_name, char *string1, char *string2, - int int1, int int2); - -GtkWidget * -vfolder_editor_sourcelist_new (char *widget_name, char *string1, char *string2, int int1, int int2) -{ - GtkWidget *table, *scrolled; - GtkTreeSelection *selection; - GtkCellRenderer *renderer; - GtkListStore *model; - - scrolled = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - - model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER); - table = gtk_tree_view_new_with_model ((GtkTreeModel *) model); - gtk_tree_view_set_headers_visible ((GtkTreeView *) table, FALSE); - - renderer = gtk_cell_renderer_text_new (); - gtk_tree_view_insert_column_with_attributes ((GtkTreeView *) table, -1, - _("VFolder source"), renderer, - "text", 0, NULL); - - selection = gtk_tree_view_get_selection ((GtkTreeView *) table); - gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); - - gtk_container_add (GTK_CONTAINER (scrolled), table); - - g_object_set_data ((GObject *) scrolled, "table", table); - g_object_set_data ((GObject *) scrolled, "model", model); - - gtk_widget_show (scrolled); - gtk_widget_show (table); - - return scrolled; -} - - -/* DO NOT internationalise these strings */ -const char *source_names[] = { - "specific", - "local", - "remote_active", - "local_remote_active" -}; - -static GtkWidget * -get_widget (FilterRule *fr, RuleContext *rc) -{ - VfolderRule *vr = (VfolderRule *) fr; - GtkWidget *widget, *frame, *list; - struct _source_data *data; - GtkOptionMenu *omenu; - const char *source; - GtkTreeIter iter; - GladeXML *gui; - int i, row; - GList *l; - - widget = FILTER_RULE_CLASS (parent_class)->get_widget (fr, rc); - - data = g_malloc0 (sizeof (*data)); - data->rc = rc; - data->vr = vr; - - gui = glade_xml_new (FILTER_GLADEDIR "/filter.glade", "vfolder_source_frame", NULL); - frame = glade_xml_get_widget (gui, "vfolder_source_frame"); - - g_object_set_data_full ((GObject *) frame, "data", data, g_free); - - for (i = 0; i < BUTTON_LAST; i++) { - data->buttons[i] = (GtkButton *) glade_xml_get_widget (gui, edit_buttons[i].name); - g_signal_connect (data->buttons[i], "clicked", edit_buttons[i].func, data); - } - - list = glade_xml_get_widget (gui, "source_list"); - data->list = (GtkTreeView *) g_object_get_data ((GObject *) list, "table"); - data->model = (GtkListStore *) g_object_get_data ((GObject *) list, "model"); - - source = NULL; - while ((source = vfolder_rule_next_source (vr, source))) { - char *nice = format_source(source); - - gtk_list_store_append (data->model, &iter); - gtk_list_store_set (data->model, &iter, 0, nice, 1, source, -1); - g_free(nice); - } - - g_signal_connect (data->list, "cursor-changed", G_CALLBACK (select_source), data); - - omenu = (GtkOptionMenu *) glade_xml_get_widget (gui, "source_option"); - l = GTK_MENU_SHELL (omenu->menu)->children; - i = 0; - row = 0; - while (l) { - GtkWidget *item = 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])) { - g_object_set_data ((GObject *) item, "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"); - } - - g_signal_connect (item, "activate", G_CALLBACK (select_source_with), data); - - i++; - l = l->next; - } - - gtk_option_menu_set_history (omenu, row); - if (fr->source == NULL) - filter_rule_set_source (fr, (char *) source_names[row]); - - set_sensitive (data); - - g_object_unref (gui); - - gtk_box_pack_start (GTK_BOX (widget), frame, TRUE, TRUE, 3); - - return widget; -} diff --git a/filter/vfolder-rule.h b/filter/vfolder-rule.h deleted file mode 100644 index 165e547688..0000000000 --- a/filter/vfolder-rule.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000-2002 Ximian Inc. - * - * Author: NotZed - * 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. - */ - - -#ifndef _VFOLDER_RULE_H -#define _VFOLDER_RULE_H - -#include "filter-rule.h" - -#define VFOLDER_TYPE_RULE (vfolder_rule_get_type ()) -#define VFOLDER_RULE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VFOLDER_TYPE_RULE, VfolderRule)) -#define VFOLDER_RULE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VFOLDER_TYPE_RULE, VfolderRuleClass)) -#define IS_VFOLDER_RULE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VFOLDER_TYPE_RULE)) -#define IS_VFOLDER_RULE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VFOLDER_TYPE_RULE)) -#define VFOLDER_RULE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VFOLDER_TYPE_RULE, VfolderRuleClass)) - -typedef struct _VfolderRule VfolderRule; -typedef struct _VfolderRuleClass VfolderRuleClass; - -struct _VfolderRule { - FilterRule parent_object; - - GList *sources; /* uri's of the source folders */ -}; - -struct _VfolderRuleClass { - FilterRuleClass parent_class; - - /* virtual methods */ - - /* signals */ -}; - -GType vfolder_rule_get_type (void); -VfolderRule *vfolder_rule_new (void); - -/* methods */ -void vfolder_rule_add_source (VfolderRule *vr, const char *uri); -void vfolder_rule_remove_source (VfolderRule *vr, const char *uri); -const char *vfolder_rule_find_source (VfolderRule *vr, const char *uri); -const char *vfolder_rule_next_source (VfolderRule *vr, const char *last); - -#endif /* ! _VFOLDER_RULE_H */ diff --git a/filter/vfoldertypes.xml b/filter/vfoldertypes.xml deleted file mode 100644 index daa873d184..0000000000 --- a/filter/vfoldertypes.xml +++ /dev/null @@ -1,421 +0,0 @@ - - - - - Sender - - - - - - - - - - - - - - - Recipients - - - - - - - - - - - - - - - Subject - - - - - - - - - - - - - - Message Body - - - - - - - - Expression - - - - - Date sent - - - - - - - - - - - Date received - - - - - - - - - - - Label - - - - - - - - - Score - - - - - - - - - - - Size (kB) - - - - - - - - - Status - - - - - - - - - - - - - - - Follow Up - - - - - - - - Attachments - - - - - - - - Mailing list - - - - - - - - - - - -- cgit v1.2.3