fix a third case of rule rewriting
[claws.git] / src / prefs_filtering.c
index 733ca89b1c281a439925259d5d26205404158db5..a80000493e5a528d7b0e0aa6d3f86d3909476c44 100644 (file)
@@ -316,7 +316,6 @@ static void prefs_filtering_create(void)
        GtkWidget *up_btn;
        GtkWidget *down_btn;
 
-       GtkWidget *dummy;
 
        GList *combo_items;
        gint i;
@@ -326,7 +325,7 @@ static void prefs_filtering_create(void)
 
        gchar *title[1];
 
-       debug_print(_("Creating filtering setting window...\n"));
+       debug_print("Creating filtering setting window...\n");
 
        window = gtk_window_new (GTK_WINDOW_DIALOG);
        gtk_container_set_border_width (GTK_CONTAINER (window), 8);
@@ -616,6 +615,7 @@ void prefs_filtering_rename_path(const gchar *old_path, const gchar *new_path)
        gchar *prefix;
        gchar *suffix;
        gchar *dest_path;
+       gchar *old_path_with_sep;
        gint destlen;
        gint prefixlen;
        gint oldpathlen;
@@ -624,6 +624,7 @@ void prefs_filtering_rename_path(const gchar *old_path, const gchar *new_path)
        g_return_if_fail(new_path != NULL);
 
        oldpathlen = strlen(old_path);
+       old_path_with_sep = g_strconcat(old_path,G_DIR_SEPARATOR_S,NULL);
 
        for (cur = global_processing; cur != NULL; cur = cur->next) {
                FilteringProp   *filtering = (FilteringProp *)cur->data;
@@ -657,10 +658,28 @@ void prefs_filtering_rename_path(const gchar *old_path, const gchar *new_path)
                                g_free(prefix);
                                g_free(action->destination);
                                action->destination = dest_path;
+                       } else { /* for non-leaf folders */
+                               /* compare with trailing slash */
+                               if (!strncmp(old_path_with_sep, action->destination, oldpathlen+1)) {
+                                       
+                                       suffix = action->destination + oldpathlen + 1;
+                                       dest_path = g_strconcat(new_path,
+                                                               G_DIR_SEPARATOR_S,
+                                                               suffix, NULL);
+                                       g_free(action->destination);
+                                       action->destination = dest_path;
+                               }
+                       }
+               } else {
+                       /* folder-moving a leaf */
+                       if (!strcmp(old_path, action->destination)) {           
+                               dest_path = g_strdup(new_path);
+                               g_free(action->destination);
+                               action->destination = dest_path;
                        }
                }
        }
-
+       g_free(old_path_with_sep);
        prefs_matcher_write_config();
 }
 
@@ -759,7 +778,6 @@ static void prefs_filtering_set_list(void)
        FilteringProp *prop;
        GSList * cur;
        gchar * filtering_str;
-       gchar * tmp;
        GSList * prefs_filtering;
 
        if (cur_item == NULL)
@@ -839,9 +857,6 @@ static void prefs_filtering_condition_define(void)
        cond_str = gtk_entry_get_text(GTK_ENTRY(filtering.cond_entry));
 
        if (*cond_str != '\0') {
-               gchar * tmp;
-               
-               /* tmp = cond_str; */
                matchers = matcher_parser_get_cond(cond_str);
                if (matchers == NULL)
                        alertpanel_error(_("Match string is not valid."));
@@ -863,13 +878,12 @@ static FilteringProp * prefs_filtering_dialog_to_filtering(void)
        gchar * cond_str;
        FilteringProp * prop;
        FilteringAction * action;
-       gchar * tmp;
        gint list_id;
        gint action_id;
        gint action_type;
        gint account_id;
        gchar * destination;
-       gint labelcolor;
+       gint labelcolor = 0;
        
        cond_str = gtk_entry_get_text(GTK_ENTRY(filtering.cond_entry));
        if (*cond_str == '\0') {
@@ -1104,7 +1118,6 @@ static void prefs_filtering_select(GtkCList *clist, gint row, gint column,
                                GdkEvent *event)
 {
        FilteringProp * prop;
-       gchar * tmp;
        gchar * filtering_str;
 
        if (row == 0) {