From 73d343064ea344cd8bb1d86a894e9c7f976f6ed0 Mon Sep 17 00:00:00 2001 From: Colin Leroy Date: Sat, 9 Nov 2002 17:01:19 +0000 Subject: [PATCH] * 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. --- ChangeLog.claws | 9 +++++ configure.in | 2 +- src/folderview.c | 10 +++--- src/prefs_filtering.c | 76 +++++++++++++++++++++++++++++++++++++++---- 4 files changed, 86 insertions(+), 11 deletions(-) diff --git a/ChangeLog.claws b/ChangeLog.claws index 34546aa84..f659dc110 100644 --- a/ChangeLog.claws +++ b/ChangeLog.claws @@ -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 diff --git a/configure.in b/configure.in index cb1f9c843..8c665fca4 100644 --- a/configure.in +++ b/configure.in @@ -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 diff --git a/src/folderview.c b/src/folderview.c index eaa17a829..69fca8520 100644 --- a/src/folderview.c +++ b/src/folderview.c @@ -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, diff --git a/src/prefs_filtering.c b/src/prefs_filtering.c index a80000493..0728f5b08 100644 --- a/src/prefs_filtering.c +++ b/src/prefs_filtering.c @@ -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); + } } -- 2.25.1