/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2009 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2011 Hiroyuki Yamamoto and the Claws Mail team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
static gint prefs_filtering_deleted (GtkWidget *widget,
GdkEventAny *event,
gpointer data);
+static void prefs_filtering_row_selected(GtkTreeSelection *selection,
+ GtkTreeView *list_view);
static gboolean prefs_filtering_key_pressed(GtkWidget *widget,
GdkEventKey *event,
gpointer data);
cm_return_if_fail(accounts != NULL);
COMBOBOX_ADD(filtering.account_combobox_list, Q_("Filtering Account Menu|All"), 0);
+ COMBOBOX_ADD(filtering.account_combobox_list, NULL, 0);
for (; accounts != NULL; accounts = accounts->next) {
PrefsAccount *ac = (PrefsAccount *)accounts->data;
GtkWidget *bottom_btn;
GtkWidget *table;
static GdkGeometry geometry;
- CLAWS_TIP_DECL();
debug_print("Creating filtering configuration window...\n");
return FALSE;
}
+static void rename_path_prefix(GSList *filters, const gchar *old_prefix,
+ const gchar *new_prefix)
+{
+ GSList *action_cur, *cur;
+ gchar *new_path;
+
+ for (cur = filters; cur != NULL; cur = cur->next) {
+ FilteringProp *filtering = (FilteringProp *)cur->data;
+
+ for(action_cur = filtering->action_list ; action_cur != NULL ;
+ action_cur = action_cur->next) {
+
+ FilteringAction *action = action_cur->data;
+
+ if (action->type == MATCHACTION_SET_TAG ||
+ action->type == MATCHACTION_UNSET_TAG)
+ continue;
+ if (!action->destination)
+ continue;
+ if (!g_str_has_prefix(action->destination, old_prefix))
+ continue;
+
+ new_path = g_strconcat(new_prefix,
+ (action->destination + strlen(old_prefix)), NULL);
+ g_free(action->destination);
+ action->destination = new_path;
+ }
+ }
+}
+
+static gboolean prefs_filtering_rename_path_prefix_func(GNode *node, gpointer data)
+{
+ GSList *filters;
+ const gchar * old_prefix;
+ const gchar * new_prefix;
+ const gchar ** paths;
+ FolderItem *item;
+
+ paths = data;
+ old_prefix = paths[0];
+ new_prefix = paths[1];
+
+ cm_return_val_if_fail(old_prefix != NULL, FALSE);
+ cm_return_val_if_fail(new_prefix != NULL, FALSE);
+ cm_return_val_if_fail(node != NULL, FALSE);
+
+ item = node->data;
+ if (!item || !item->prefs)
+ return FALSE;
+ filters = item->prefs->processing;
+
+ rename_path_prefix(filters, old_prefix, new_prefix);
+
+ return FALSE;
+}
+
+void prefs_filtering_rename_path_prefix(const gchar *old_prefix,
+ const gchar *new_prefix)
+{
+ GList * cur;
+ const gchar *paths[2] = {NULL, NULL};
+ paths[0] = old_prefix;
+ paths[1] = new_prefix;
+ 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_prefix_func, paths);
+ }
+
+ rename_path_prefix(pre_global_processing, old_prefix, new_prefix);
+ rename_path_prefix(post_global_processing, old_prefix, new_prefix);
+ rename_path_prefix(filtering_rules, old_prefix, new_prefix);
+
+ prefs_matcher_write_config();
+}
+
static void rename_tag(GSList * filters,
const gchar * old_tag, const gchar * new_tag)
{
filteringprop_free(prop);
- prefs_filtering_reset_dialog();
+ prefs_filtering_row_selected(gtk_tree_view_get_selection(
+ GTK_TREE_VIEW(filtering.cond_list_view)),
+ GTK_TREE_VIEW(filtering.cond_list_view));
modified = TRUE;
}
static gboolean prefs_filtering_key_pressed(GtkWidget *widget, GdkEventKey *event,
gpointer data)
{
- if (event && event->keyval == GDK_Escape) {
+ if (event && event->keyval == GDK_KEY_Escape) {
prefs_filtering_cancel(NULL, NULL);
return TRUE;
}
#endif
};
+static void prefs_filtering_row_selected(GtkTreeSelection *selection,
+ GtkTreeView *list_view)
+{
+ GtkTreePath *path;
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+
+ if (!gtk_tree_selection_get_selected(selection, &model, &iter))
+ return;
+
+ path = gtk_tree_model_get_path(model, &iter);
+ prefs_filtering_select_row(list_view, path);
+ gtk_tree_path_free(path);
+}
+
static gint prefs_filtering_list_btn_pressed(GtkWidget *widget, GdkEventButton *event,
GtkTreeView *list_view)
{
selector = gtk_tree_view_get_selection(list_view);
gtk_tree_selection_set_mode(selector, GTK_SELECTION_BROWSE);
+ g_signal_connect(G_OBJECT(selector), "changed",
+ G_CALLBACK(prefs_filtering_row_selected), list_view);
/* create the columns */
prefs_filtering_create_list_view_columns(GTK_WIDGET(list_view));