/* widget creating functions */
static void prefs_filtering_create (void);
-static void prefs_filtering_set_dialog (void);
+static void prefs_filtering_set_dialog (const gchar *header,
+ const gchar *key);
static void prefs_filtering_set_list (void);
/* callback functions */
ACTION_BOUNCE = 9,
ACTION_EXECUTE = 10,
ACTION_COLOR = 11,
+ ACTION_DELETE_ON_SERVER = 12,
};
static gint get_sel_from_list(GtkList * list)
return MATCHACTION_FORWARD;
case ACTION_FORWARD_AS_ATTACHMENT:
return MATCHACTION_FORWARD_AS_ATTACHMENT;
+ case ACTION_BOUNCE:
+ return MATCHACTION_BOUNCE;
case ACTION_EXECUTE:
return MATCHACTION_EXECUTE;
case ACTION_COLOR:
return MATCHACTION_COLOR;
+ case ACTION_DELETE_ON_SERVER:
+ return MATCHACTION_DELETE_ON_SERVER;
default:
return -1;
}
N_("Forward as attachment"),
N_("Bounce"),
N_("Execute"),
- N_("Color")
+ N_("Color"),
+ N_("Delete on Server")
};
-void prefs_filtering_open(FolderItem * item)
+void prefs_filtering_open(FolderItem * item,
+ const gchar *header,
+ const gchar *key)
{
if (prefs_rc_is_readonly(FILTERING_RC))
return;
- inc_autocheck_timer_remove();
+ inc_lock();
if (!filtering.window) {
prefs_filtering_create();
cur_item = item;
- prefs_filtering_set_dialog();
+ prefs_filtering_set_dialog(header, key);
gtk_widget_show(filtering.window);
end_address_completion();
gtk_widget_hide(filtering.window);
+ inc_unlock();
}
static void prefs_filtering_create(void)
GList *accounts;
GList * cur;
- gchar *title[] = {_("Registered rules")};
+ gchar *title[1];
debug_print(_("Creating filtering setting window...\n"));
GTK_SIGNAL_FUNC(prefs_filtering_deleted), NULL);
gtk_signal_connect (GTK_OBJECT(window), "key_press_event",
GTK_SIGNAL_FUNC(prefs_filtering_key_pressed), NULL);
- gtk_signal_connect (GTK_OBJECT(window), "focus_in_event",
- GTK_SIGNAL_FUNC(manage_window_focus_in), NULL);
- gtk_signal_connect (GTK_OBJECT(window), "focus_out_event",
- GTK_SIGNAL_FUNC(manage_window_focus_out), NULL);
+ MANAGE_WINDOW_SIGNALS_CONNECT (window);
gtk_signal_connect (GTK_OBJECT(ok_btn), "clicked",
GTK_SIGNAL_FUNC(prefs_filtering_ok), NULL);
gtk_signal_connect (GTK_OBJECT(cancel_btn), "clicked",
cond_entry = gtk_entry_new ();
gtk_widget_show (cond_entry);
-// gtk_widget_set_usize (cond_entry, 200, -1);
gtk_box_pack_start (GTK_BOX (hbox1), cond_entry, TRUE, TRUE, 0);
cond_btn = gtk_button_new_with_label (_("Define ..."));
action_combo = gtk_combo_new ();
gtk_widget_show (action_combo);
-// gtk_widget_set_usize (action_combo, 200, -1);
gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(action_combo)->entry),
FALSE);
dest_entry = gtk_entry_new ();
gtk_widget_show (dest_entry);
-// gtk_widget_set_usize (dest_entry, 200, -1);
gtk_box_pack_start (GTK_BOX (hbox1), dest_entry, TRUE, TRUE, 0);
color_optmenu = gtk_option_menu_new();
gtk_option_menu_set_menu(GTK_OPTION_MENU(color_optmenu),
colorlabel_create_color_menu());
-// gtk_widget_set_usize(color_optmenu, -1, -1);
gtk_box_pack_start(GTK_BOX(hbox1), color_optmenu, TRUE, TRUE, 0);
dest_btn = gtk_button_new_with_label (_("Select ..."));
GTK_SIGNAL_FUNC (prefs_matcher_exec_info),
NULL);
-// dummy = gtk_label_new("");
-// gtk_widget_show (dummy);
-// gtk_box_pack_start(GTK_BOX (hbox1), dummy, FALSE, FALSE, 0);
-
-
/* register / substitute / delete */
reg_hbox = gtk_hbox_new (FALSE, 4);
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
+ title[0] = _("Registered rules");
cond_clist = gtk_clist_new_with_titles(1, title);
gtk_widget_show (cond_clist);
gtk_container_add (GTK_CONTAINER (cond_scrolledwin), cond_clist);
gtk_clist_set_column_width(GTK_CLIST(filtering.cond_clist), 0, optwidth);
}
-static void prefs_filtering_set_dialog(void)
+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(const gchar *header, const gchar *key)
{
GtkCList *clist = GTK_CLIST(filtering.cond_clist);
GSList *cur;
GSList * prefs_filtering;
+ gchar *cond_str[1];
+ gint row;
gtk_clist_freeze(clist);
gtk_clist_clear(clist);
- prefs_filtering_clist_set_row(-1, NULL);
+ cond_str[0] = _("(New)");
+ row = gtk_clist_append(clist, cond_str);
+ gtk_clist_set_row_data(clist, row, NULL);
if (cur_item == NULL)
prefs_filtering = global_processing;
for(cur = prefs_filtering ; cur != NULL ; cur = g_slist_next(cur)) {
FilteringProp * prop = (FilteringProp *) cur->data;
- prefs_filtering_clist_set_row(-1, prop);
+ cond_str[0] = filteringprop_to_string(prop);
+ subst_char(cond_str[0], '\t', ':');
+ row = gtk_clist_append(clist, cond_str);
+ gtk_clist_set_row_data(clist, row, prop);
+
+ g_free(cond_str[0]);
}
prefs_filtering_update_hscrollbar();
gtk_clist_thaw(clist);
prefs_filtering_reset_dialog();
+
+ if (header && key) {
+ gchar *match_str = g_strconcat(header, " ",
+ get_matchparser_tab_str(MATCHTYPE_MATCHCASE),
+ " \"", key, "\"", NULL);
+ gtk_entry_set_text(GTK_ENTRY(filtering.cond_entry), match_str);
+ g_free(match_str);
+ }
}
static void prefs_filtering_reset_dialog(void)
gtk_option_menu_get_menu(GTK_OPTION_MENU(filtering.color_optmenu)));
destination = NULL;
break;
+ case ACTION_DELETE_ON_SERVER:
+ destination = NULL;
+ break;
default:
destination = NULL;
break;
ACTION_MARK_AS_UNREAD);
break;
case MATCHACTION_FORWARD:
+ list_id = get_list_id_from_account_id(action->account_id);
gtk_list_select_item(GTK_LIST(filtering.action_list),
ACTION_FORWARD);
- list_id = get_list_id_from_account_id(action->account_id);
gtk_list_select_item(GTK_LIST(filtering.account_list),
list_id);
break;
list_id);
break;
case MATCHACTION_BOUNCE:
+ list_id = get_list_id_from_account_id(action->account_id);
gtk_list_select_item(GTK_LIST(filtering.action_list),
ACTION_BOUNCE);
- list_id = get_list_id_from_account_id(action->account_id);
gtk_list_select_item(GTK_LIST(filtering.account_list),
list_id);
break;
ACTION_COLOR);
gtk_option_menu_set_history(GTK_OPTION_MENU(filtering.color_optmenu), action->labelcolor);
break;
+ case MATCHACTION_DELETE_ON_SERVER:
+ gtk_list_select_item(GTK_LIST(filtering.action_list),
+ ACTION_DELETE_ON_SERVER);
+ break;
}
g_free(matcher_str);
FolderItem *dest;
gchar * path;
- dest = foldersel_folder_sel(NULL, NULL);
+ dest = foldersel_folder_sel(NULL, FOLDER_SEL_COPY, NULL);
if (!dest) return;
path = folder_item_get_identifier(dest);
gtk_widget_hide(filtering.dest_btn);
gtk_widget_hide(filtering.dest_label);
gtk_widget_show(filtering.exec_label);
- gtk_widget_set_sensitive(filtering.exec_btn, FALSE);
+ gtk_widget_set_sensitive(filtering.exec_btn, TRUE);
gtk_widget_show(filtering.exec_btn);
gtk_widget_hide(filtering.color_optmenu);
gtk_widget_hide(filtering.color_label);
gtk_widget_show(filtering.color_optmenu);
gtk_widget_show(filtering.color_label);
break;
+ case ACTION_DELETE_ON_SERVER:
+ gtk_widget_set_sensitive(filtering.account_combo, FALSE);
+ gtk_widget_hide(filtering.dest_entry);
+ gtk_widget_hide(filtering.dest_btn);
+ gtk_widget_hide(filtering.dest_label);
+ gtk_widget_hide(filtering.exec_label);
+ gtk_widget_show(filtering.exec_btn);
+ gtk_widget_hide(filtering.exec_btn);
+ gtk_widget_hide(filtering.color_optmenu);
+ gtk_widget_hide(filtering.color_label);
+ break;
}
}