add filter rename/delete on folder rename/delete
authorPaul Mangan <paul@claws-mail.org>
Thu, 14 Mar 2002 12:28:39 +0000 (12:28 +0000)
committerPaul Mangan <paul@claws-mail.org>
Thu, 14 Mar 2002 12:28:39 +0000 (12:28 +0000)
ChangeLog.claws
configure.in
src/folderview.c
src/prefs_filtering.c
src/prefs_filtering.h

index e278b7a..4a1007a 100644 (file)
@@ -1,3 +1,11 @@
+2002-03-14 [paul]      0.7.4claws4
+
+       * src/folderview
+         src/prefs_filtering.[ch]
+               add filter rename on folder rename and filter
+               delete on folder delete. Patch submitted by
+               Neill Miller <neillm@thecodefactory.com> 
+
 2002-03-14 [christoph] 0.7.4claws3
 
        * src/procmsg.c
index 4c49486..ba535e4 100644 (file)
@@ -8,7 +8,7 @@ MINOR_VERSION=7
 MICRO_VERSION=4
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws3
+EXTRA_VERSION=claws4
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 61d4f40..1110304 100644 (file)
@@ -1884,6 +1884,10 @@ static void folderview_rename_folder_cb(FolderView *folderview, guint action,
        g_free(new_folder);
 
        prefs_filter_rename_path(old_path, new_path);
+
+       if (FOLDER_TYPE(item->folder) == F_MH) {
+               prefs_filtering_rename_path(old_path, new_path);
+       }
        g_free(new_path);
 
        gtk_clist_freeze(GTK_CLIST(ctree));
@@ -1993,6 +1997,9 @@ static void folderview_delete_folder_cb(FolderView *folderview, guint action,
 
        prefs_filter_delete_path(old_path);
 
+       if (FOLDER_TYPE(item->folder) == F_MH)
+               prefs_filtering_delete_path(old_path);
+
        if (folderview->opened == folderview->selected ||
            gtk_ctree_is_ancestor(ctree,
                                  folderview->selected,
index f8743ed..1d47db0 100644 (file)
@@ -601,6 +601,97 @@ static void prefs_filtering_update_hscrollbar(void)
        gtk_clist_set_column_width(GTK_CLIST(filtering.cond_clist), 0, optwidth);
 }
 
+void prefs_filtering_rename_path(const gchar *old_path, const gchar *new_path)
+{
+       GSList *cur;
+       gchar *base;
+       gchar *prefix;
+       gchar *suffix;
+       gchar *dest_path;
+       gint destlen;
+       gint prefixlen;
+       gint oldpathlen;
+
+       g_return_if_fail(old_path != NULL);
+       g_return_if_fail(new_path != NULL);
+
+       oldpathlen = strlen(old_path);
+
+       for (cur = global_processing; cur != NULL; cur = cur->next) {
+               FilteringProp   *filtering = (FilteringProp *)cur->data;
+               FilteringAction *action = filtering->action;
+
+               if (!action->destination) continue;
+
+               destlen = strlen(action->destination);
+
+               if (destlen > oldpathlen) {
+                       prefixlen = destlen - oldpathlen;
+                       suffix = action->destination + prefixlen;
+
+                       if (!strncmp(old_path, suffix, oldpathlen)) {
+                               prefix = g_malloc0(prefixlen + 1);
+                               strncpy2(prefix, action->destination, prefixlen);
+
+                               base = suffix + oldpathlen;
+                               while (*base == G_DIR_SEPARATOR) base++;
+                               if (*base == '\0')
+                                       dest_path = g_strconcat(prefix,
+                                                               G_DIR_SEPARATOR_S,
+                                                               new_path, NULL);
+                               else
+                                       dest_path = g_strconcat(prefix,
+                                                               G_DIR_SEPARATOR_S,
+                                                               new_path,
+                                                               G_DIR_SEPARATOR_S,
+                                                               base, NULL);
+
+                               g_free(prefix);
+                               g_free(action->destination);
+                               action->destination = dest_path;
+                       }
+               }
+       }
+
+       prefs_matcher_write_config();
+}
+
+void prefs_filtering_delete_path(const gchar *path)
+{
+       GSList *cur;
+       GSList *next;
+       gchar *suffix;
+       gint destlen;
+       gint prefixlen;
+       gint pathlen;
+
+       g_return_if_fail(path != NULL);
+
+       pathlen = strlen(path);
+       for (cur = global_processing; cur != NULL; cur = next) {
+               FilteringProp *filtering = (FilteringProp *)cur->data;
+               FilteringAction *action = filtering->action;
+               next = cur->next;
+
+               if (!action->destination) continue;
+
+               destlen = strlen(action->destination);
+
+               if (destlen > pathlen) {
+                       prefixlen = destlen - pathlen;
+                       suffix = action->destination + prefixlen;
+
+                       if (suffix && !strncmp(path, suffix, pathlen)) {
+                               filteringprop_free(filtering);
+                               global_processing = 
+                                       g_slist_remove(global_processing, filtering);
+                       }
+               }
+       }
+
+       prefs_matcher_write_config();
+}
+
 static void prefs_filtering_set_dialog(void)
 {
        GtkCList *clist = GTK_CLIST(filtering.cond_clist);
index e32e774..a665b32 100644 (file)
@@ -24,6 +24,9 @@
 void prefs_scoring_read_config (void);
 void prefs_scoring_write_config        (void);
 */
-void prefs_filtering_open(FolderItem * item);
+void prefs_filtering_open              (FolderItem * item);
+void prefs_filtering_rename_path       (const gchar    *old_path,
+                                        const gchar    *new_path);
+void prefs_filtering_delete_path       (const gchar    *path);
 
 #endif /* __PREFS_FILTERING_H__ */