2006-08-03 [wwp] 2.4.0cvs21
authorTristan Chabredier <wwp@claws-mail.org>
Thu, 3 Aug 2006 08:37:30 +0000 (08:37 +0000)
committerTristan Chabredier <wwp@claws-mail.org>
Thu, 3 Aug 2006 08:37:30 +0000 (08:37 +0000)
* src/filtering.c
* src/filtering.h
* src/prefs_common.c
* src/summaryview.c
* src/alertpanel.c
* src/alertpanel.h
* src/messageview.c
ask what to do w/ filtering rules that belong to an account when
applying filtering rules manually from the main window (skip,
apply regardless of the account, use current account). This dialog
can be skipped and the last reply used.

ChangeLog
PATCHSETS
configure.ac
src/alertpanel.c
src/alertpanel.h
src/filtering.c
src/filtering.h
src/messageview.c
src/prefs_common.c
src/summaryview.c

index ece7b55..f3b160f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2006-08-03 [wwp]       2.4.0cvs21
+
+       * src/filtering.c
+       * src/filtering.h
+       * src/prefs_common.c
+       * src/summaryview.c
+       * src/alertpanel.c
+       * src/alertpanel.h
+       * src/messageview.c
+               ask what to do w/ filtering rules that belong to an account when
+               applying filtering rules manually from the main window (skip,
+               apply regardless of the account, use current account). This dialog
+               can be skipped and the last reply used.
+
+
 2006-08-03 [colin]     2.4.0cvs20
 
        * src/textview.c
index 1741eca..7e0ae08 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.94.2.91 -r 1.94.2.92 src/messageview.c;  ) > 2.4.0cvs18.patchset
 ( cvs diff -u -r 1.96.2.130 -r 1.96.2.131 src/textview.c;  ) > 2.4.0cvs19.patchset
 ( cvs diff -u -r 1.96.2.131 -r 1.96.2.132 src/textview.c;  ) > 2.4.0cvs20.patchset
+( cvs diff -u -r 1.60.2.20 -r 1.60.2.21 src/filtering.c;  cvs diff -u -r 1.21.2.8 -r 1.21.2.9 src/filtering.h;  cvs diff -u -r 1.204.2.95 -r 1.204.2.96 src/prefs_common.c;  cvs diff -u -r 1.395.2.226 -r 1.395.2.227 src/summaryview.c;  cvs diff -u -r 1.17.2.23 -r 1.17.2.24 src/alertpanel.c;  cvs diff -u -r 1.5.2.7 -r 1.5.2.8 src/alertpanel.h;  cvs diff -u -r 1.94.2.92 -r 1.94.2.93 src/messageview.c;  ) > 2.4.0cvs21.patchset
index 124a39e..146ae9a 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=4
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=20
+EXTRA_VERSION=21
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 1535f1c..230e9c7 100644 (file)
@@ -73,11 +73,12 @@ AlertValue alertpanel_with_widget(const gchar *title,
                                  const gchar *button1_label,
                                  const gchar *button2_label,
                                  const gchar *button3_label,
+                                 gboolean     can_disable,
                                  GtkWidget *widget)
 {
        return alertpanel_full(title, message, button1_label,
                                    button2_label, button3_label,
-                                   FALSE, widget, ALERT_QUESTION,
+                                   can_disable, widget, ALERT_QUESTION,
                                    G_ALERTDEFAULT);
 }
 
index 89ff73e..4b133e4 100644 (file)
@@ -62,6 +62,7 @@ AlertValue alertpanel_with_widget     (const gchar *title,
                                         const gchar *button1_label,
                                         const gchar *button2_label,
                                         const gchar *button3_label,
+                                        gboolean     can_disable,
                                         GtkWidget *widget);
 
 
index ebc957f..602b179 100644 (file)
@@ -33,6 +33,7 @@
 #include "filtering.h"
 #include "prefs_gtk.h"
 #include "compose.h"
+#include "prefs_common.h"
 
 #define PREFSBUFSIZE           1024
 
@@ -412,11 +413,25 @@ static gboolean filtering_match_condition(FilteringProp *filtering, MsgInfo *inf
 {
        gboolean matches = FALSE;
 
-       if (ac_prefs != NULL)
+       if (ac_prefs != NULL) {
                matches = ((filtering->account_id == 0)
                                        || (filtering->account_id == ac_prefs->account_id));
-       else
-               matches = TRUE;
+       } else {
+               switch (prefs_common.apply_per_account_filtering_rules) {
+               case FILTERING_ACCOUNT_RULES_FORCE:
+                       /* apply filtering rules regardless to the account info */
+                       matches = TRUE;
+                       break;
+               case FILTERING_ACCOUNT_RULES_SKIP:
+                       /* don't apply filtering rules that belong to an account */
+                       matches = (filtering->account_id == 0);
+                       break;
+               case FILTERING_ACCOUNT_RULES_USE_CURRENT:
+                       matches = ((filtering->account_id == 0)
+                                       || (filtering->account_id == cur_account->account_id));
+                       break;
+               }
+       }
 
        return matches && matcherlist_match(filtering->matchers, info);
 }
@@ -685,3 +700,18 @@ void prefs_filtering_clear_folder(Folder *folder)
        /* FIXME: Note folder settings were changed, where the updates? */
 }
 
+gboolean filtering_peek_per_account_rules(GSList *filtering_list)
+/* return TRUE if there's at least one per-account filtering rule */
+{
+       GSList *l;
+
+       for (l = filtering_list; l != NULL; l = g_slist_next(l)) {
+               FilteringProp * filtering = (FilteringProp *) l->data;
+
+               if (filtering->enabled && (filtering->account_id != 0)) {
+                       return TRUE;
+               }               
+       }
+
+       return FALSE;
+}
index edc1cb9..be2a57b 100644 (file)
@@ -45,6 +45,12 @@ struct _FilteringProp {
 
 typedef struct _FilteringProp FilteringProp;
 
+enum {
+       FILTERING_ACCOUNT_RULES_SKIP = 0,
+       FILTERING_ACCOUNT_RULES_FORCE = 1,
+       FILTERING_ACCOUNT_RULES_USE_CURRENT = 2
+};
+
 /* extern GSList * prefs_filtering; */
 
 
@@ -84,4 +90,6 @@ extern GSList * filtering_rules;
 extern GSList * pre_global_processing;
 extern GSList * post_global_processing;
 
+gboolean filtering_peek_per_account_rules(GSList *filtering_list);
+
 #endif
index eb3295f..c3b5b93 100644 (file)
@@ -1352,7 +1352,7 @@ static PrefsAccount *select_account_from_list(GList *ac_list)
                                  "Please choose which account do you want to "
                                  "use for sending the receipt notification:"),
                                _("_Send Notification"), _("+_Cancel"), NULL,
-                               optmenu) != G_ALERTDEFAULT)
+                               FALSE, optmenu) != G_ALERTDEFAULT)
                return NULL;
        return account_find_from_id(account_id);
 }
index 150bf9c..4359fd8 100644 (file)
@@ -624,6 +624,11 @@ static PrefParam param[] = {
        {"ask_mark_all_read", "TRUE", &prefs_common.ask_mark_all_read, P_BOOL,
         NULL, NULL, NULL},
 
+       {"ask_apply_per_account_filtering_rules", "TRUE", &prefs_common.ask_apply_per_account_filtering_rules, P_BOOL,
+        NULL, NULL, NULL},
+       {"apply_per_account_filtering_rules", "0", &prefs_common.apply_per_account_filtering_rules, P_ENUM,
+        NULL, NULL, NULL},
+
        /* Other */
        {"uri_open_command", DEFAULT_BROWSER_CMD,
         &SPECIFIC_PREFS.uri_cmd, P_STRING, NULL, NULL, NULL},
index f387f08..36af8a3 100644 (file)
@@ -4469,11 +4469,91 @@ void summary_collapse_threads(SummaryView *summaryview)
        gtk_ctree_node_moveto(ctree, summaryview->selected, 0, 0.5, 0);
 }
 
+void account_rules_radio_button_toggled_cb(GtkToggleButton *btn, gpointer data)
+{
+       prefs_common.apply_per_account_filtering_rules = GPOINTER_TO_INT(data);
+}
+
+gboolean summary_filter_get_mode(void)
+/* ask what to do w/ them: skip them, apply them regardless to the account,
+   use the current account */
+{
+       /* TODO: eventually also propose to use the current folder's default account,
+          if it is set */
+       /* TODO: eventually allow to select the account to use from a optmenu */
+
+       GtkWidget *vbox;
+       GtkWidget *account_rules_skip;
+       GtkWidget *account_rules_force;
+       GtkWidget *account_rules_user_current;
+       GSList *group;
+       AlertValue val;
+
+       vbox = gtk_vbox_new (FALSE, 0);
+
+       account_rules_skip = gtk_radio_button_new_with_label
+                                                       (NULL, _("Skip these rules"));
+       account_rules_force = gtk_radio_button_new_with_label_from_widget
+                                                       (GTK_RADIO_BUTTON(account_rules_skip),
+                                                       _("Apply these rules regardless of the account they belong to"));
+       account_rules_user_current = gtk_radio_button_new_with_label_from_widget
+                                                       (GTK_RADIO_BUTTON(account_rules_skip),
+                                                       _("Use current account for these rules"));
+       gtk_box_pack_start (GTK_BOX (vbox), account_rules_skip, FALSE, FALSE, 0);
+       gtk_box_pack_start (GTK_BOX (vbox), account_rules_force, FALSE, FALSE, 0);
+       gtk_box_pack_start (GTK_BOX (vbox), account_rules_user_current, FALSE, FALSE, 0);
+       g_signal_connect(G_OBJECT(account_rules_skip), "toggled",
+                       G_CALLBACK(account_rules_radio_button_toggled_cb),
+                       GINT_TO_POINTER(FILTERING_ACCOUNT_RULES_SKIP));
+       g_signal_connect(G_OBJECT(account_rules_force), "toggled",
+                       G_CALLBACK(account_rules_radio_button_toggled_cb),
+                       GINT_TO_POINTER(FILTERING_ACCOUNT_RULES_FORCE));
+       g_signal_connect(G_OBJECT(account_rules_user_current), "toggled",
+                       G_CALLBACK(account_rules_radio_button_toggled_cb),
+                       GINT_TO_POINTER(FILTERING_ACCOUNT_RULES_USE_CURRENT));
+       switch (prefs_common.apply_per_account_filtering_rules) {
+       case FILTERING_ACCOUNT_RULES_SKIP:
+               gtk_toggle_button_set_active(
+                               GTK_TOGGLE_BUTTON(account_rules_skip), TRUE);
+               break;
+       case FILTERING_ACCOUNT_RULES_FORCE:
+               gtk_toggle_button_set_active(
+                               GTK_TOGGLE_BUTTON(account_rules_force), TRUE);
+               break;
+       case FILTERING_ACCOUNT_RULES_USE_CURRENT:
+               gtk_toggle_button_set_active(
+                               GTK_TOGGLE_BUTTON(account_rules_user_current), TRUE);
+               break;
+       }
+
+       val = alertpanel_with_widget(
+                       _("Filtering"),
+                       _("There are some filtering rules that belong to an account.\n"
+                         "Please choose what to do with these rules:"),
+                       _("_Filter"), _("_Cancel"), NULL, TRUE, vbox);
+       if ((val & ~G_ALERTDISABLE) != G_ALERTDEFAULT) {
+               return FALSE;
+       } else if (val & G_ALERTDISABLE)
+               prefs_common.ask_apply_per_account_filtering_rules = FALSE;
+
+       return TRUE;
+}
+
 void summary_filter(SummaryView *summaryview, gboolean selected_only)
 {
        GSList *mlist = NULL, *cur_list;
        summary_lock(summaryview);
 
+       /* are there any per-account filtering rules? */
+       if (prefs_common.ask_apply_per_account_filtering_rules == TRUE &&
+               filtering_peek_per_account_rules(filtering_rules)) {
+
+               if (summary_filter_get_mode() == FALSE) {
+                       summary_unlock(summaryview);
+                       return;
+               }
+       }
+
        folder_item_update_freeze();
        
        debug_print("filtering...");