* src/folderview.c
authorColin Leroy <colin@colino.net>
Sat, 9 Nov 2002 17:01:19 +0000 (17:01 +0000)
committerColin Leroy <colin@colino.net>
Sat, 9 Nov 2002 17:01:19 +0000 (17:01 +0000)
                Fix prefs_filtering deletion for MH folders (same
                reason as below)
        * src/prefs_filtering.c
                Fix prefs_filtering renaming and deletion for
                folder-based processing rules.

ChangeLog.claws
configure.in
src/folderview.c
src/prefs_filtering.c

index 34546aa840c541fa26501708948c05472806955a..f659dc1107811b9d86ff14169999257ea52d3f78 100644 (file)
@@ -1,3 +1,12 @@
+2002-11-09 [colin]     0.8.5claws105
+
+       * src/folderview.c
+               Fix prefs_filtering deletion for MH folders (same
+               reason as below)
+       * src/prefs_filtering.c
+               Fix prefs_filtering renaming and deletion for 
+               folder-based processing rules.  
+
 2002-11-09 [christoph] 0.8.5claws104
 
        * src/compose.c
index cb1f9c843dbe8ab1aa9a935255bb21147613adb6..8c665fca4aa0eb0a0662954ed6834a4088e1e372 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=5
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws104
+EXTRA_VERSION=claws105
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index eaa17a829f6774717742fe1bc89a4237b4b08dc9..69fca85201a44113f6bc1d552c418b736603025b 100644 (file)
@@ -2144,10 +2144,8 @@ static void folderview_delete_folder_cb(FolderView *folderview, guint action,
                return;
        }
 
-       if (FOLDER_TYPE(item->folder) == F_MH)
-               prefs_filtering_delete_path(old_path);
-       prefs_filtering_delete_path(old_id);
-       g_free(old_id);
+       /* if (FOLDER_TYPE(item->folder) == F_MH)
+               prefs_filtering_delete_path(old_path); */
 
        if (folderview->opened == folderview->selected ||
            gtk_ctree_is_ancestor(ctree,
@@ -2159,6 +2157,10 @@ static void folderview_delete_folder_cb(FolderView *folderview, guint action,
 
        gtk_ctree_remove_node(ctree, folderview->selected);
        folder_write_list();
+
+       prefs_filtering_delete_path(old_id);
+       g_free(old_id);
+
 }
 
 static void folderview_remove_mailbox_cb(FolderView *folderview, guint action,
index a80000493e5a528d7b0e0aa6d3f86d3909476c44..0728f5b08253962ddc4515581b93b103fddc7c81 100644 (file)
@@ -115,6 +115,8 @@ static void prefs_filtering_action_selection_changed(GtkList *list,
                                                     gpointer user_data);
                                          
 static void prefs_filtering_reset_dialog(void);
+static gboolean prefs_filtering_rename_path_func(GNode *node, gpointer data);
+static gboolean prefs_filtering_delete_path_func(GNode *node, gpointer data);
 
 static FolderItem * cur_item = NULL;
 
@@ -609,8 +611,24 @@ static void prefs_filtering_update_hscrollbar(void)
 }
 
 void prefs_filtering_rename_path(const gchar *old_path, const gchar *new_path)
+{
+       GList * cur;
+       gchar *paths[2] = {NULL, NULL};
+       paths[0] = (gchar*)old_path;
+       paths[1] = (gchar*)new_path;
+       for (cur = folder_get_list() ; cur != NULL ; cur = g_list_next(cur)) {
+               Folder *folder;
+               folder = (Folder *) cur->data;
+               g_node_traverse(folder->node, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
+                               prefs_filtering_rename_path_func, paths);
+       }
+       prefs_filtering_rename_path_func(NULL, paths);
+}
+
+static gboolean prefs_filtering_rename_path_func(GNode *node, gpointer data)
 {
        GSList *cur;
+       gchar *old_path, *new_path;
        gchar *base;
        gchar *prefix;
        gchar *suffix;
@@ -619,14 +637,26 @@ void prefs_filtering_rename_path(const gchar *old_path, const gchar *new_path)
        gint destlen;
        gint prefixlen;
        gint oldpathlen;
-
+       FolderItem *item;
+       
        g_return_if_fail(old_path != NULL);
        g_return_if_fail(new_path != NULL);
 
+       old_path = ((gchar **)data)[0];
+       new_path = ((gchar **)data)[1];
+
        oldpathlen = strlen(old_path);
        old_path_with_sep = g_strconcat(old_path,G_DIR_SEPARATOR_S,NULL);
+       if (node == NULL)
+               cur = global_processing;
+       else {
+               item = node->data;
+               if (!item || !item->prefs) 
+                       return FALSE;
+               cur = item->prefs->processing;
+       }
 
-       for (cur = global_processing; cur != NULL; cur = cur->next) {
+       for (; cur != NULL; cur = cur->next) {
                FilteringProp   *filtering = (FilteringProp *)cur->data;
                FilteringAction *action = filtering->action;
 
@@ -681,23 +711,52 @@ void prefs_filtering_rename_path(const gchar *old_path, const gchar *new_path)
        }
        g_free(old_path_with_sep);
        prefs_matcher_write_config();
+       return FALSE;
 }
 
 void prefs_filtering_delete_path(const gchar *path)
 {
-       GSList *cur;
+       GList * cur;
+       for (cur = folder_get_list() ; cur != NULL ; cur = g_list_next(cur)) {
+               Folder *folder;
+               folder = (Folder *) cur->data;
+               g_node_traverse(folder->node, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
+                               prefs_filtering_delete_path_func, (gchar *)path);
+       }
+       prefs_filtering_delete_path_func(NULL, (gchar *)path);
+}
+
+static gboolean prefs_filtering_delete_path_func(GNode *node, gpointer data)
+{
+       GSList *cur, *orig;
        GSList *next;
+       gchar *path = (gchar *)data;
        gchar *suffix;
        gint destlen;
        gint prefixlen;
        gint pathlen;
-
+       FolderItem *item;
+       
        g_return_if_fail(path != NULL);
 
        pathlen = strlen(path);
-       for (cur = global_processing; cur != NULL; cur = next) {
+       if (node == NULL)
+               cur = global_processing;
+       else {
+               item = node->data;
+               if (!item || !item->prefs)
+                       return FALSE;
+               cur = item->prefs->processing;
+       }
+       orig = cur;
+       
+       for (; cur != NULL; cur = cur->next) {
                FilteringProp *filtering = (FilteringProp *)cur->data;
-               FilteringAction *action = filtering->action;
+               FilteringAction *action;
+               if (!cur->data)
+                       break;
+               
+               action = filtering->action;
                next = cur->next;
 
                if (!action->destination) continue;
@@ -713,6 +772,11 @@ void prefs_filtering_delete_path(const gchar *path)
                                global_processing = 
                                        g_slist_remove(global_processing, filtering);
                        }
+               } else if (strcmp(action->destination, path) == 0) {
+                       filteringprop_free(filtering);
+                       orig = 
+                               g_slist_remove(orig, filtering);
+
                }
        }