/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2001 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2003 Hiroyuki Yamamoto and the Sylpheed-Claws 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
GtkWidget *dest_entry;
GtkWidget *dest_btn;
GtkWidget *dest_label;
+ GtkWidget *recip_label;
GtkWidget *exec_label;
GtkWidget *exec_btn;
static void prefs_filtering_set_list (void);
/* callback functions */
-/* static void prefs_filtering_select_dest_cb (void); */
static void prefs_filtering_register_cb (void);
static void prefs_filtering_substitute_cb (void);
static void prefs_filtering_delete_cb (void);
static void prefs_filtering_up (void);
-static void prefs_filtering_down (void);
-static void prefs_filtering_select (GtkCList *clist,
+static void prefs_filtering_down (void);
+static void prefs_filtering_select (GtkCList *clist,
gint row,
gint column,
GdkEvent *event);
static void prefs_filtering_key_pressed (GtkWidget *widget,
GdkEventKey *event,
gpointer data);
-static void prefs_filtering_cancel (void);
+static void prefs_filtering_cancel (void);
static void prefs_filtering_ok (void);
static void prefs_filtering_condition_define (void);
-static gint prefs_filtering_clist_set_row(gint row, FilteringProp * prop);
-static void prefs_filtering_select_dest(void);
-static void prefs_filtering_action_select(GtkList *list,
- GtkWidget *widget,
- gpointer user_data);
+static gint prefs_filtering_clist_set_row (gint row, FilteringProp * prop);
+static void prefs_filtering_select_dest (void);
+static void prefs_filtering_action_select (GtkList *list,
+ GtkWidget *widget,
+ gpointer user_data);
+
static void prefs_filtering_action_selection_changed(GtkList *list,
gpointer user_data);
-static void prefs_filtering_reset_dialog(void);
+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;
-
-enum {
- ACTION_MOVE = 0,
- ACTION_COPY = 1,
- ACTION_DELETE = 2,
- ACTION_MARK = 3,
- ACTION_UNMARK = 4,
- ACTION_MARK_AS_READ = 5,
- ACTION_MARK_AS_UNREAD = 6,
- ACTION_FORWARD = 7,
- ACTION_FORWARD_AS_ATTACHMENT = 8,
- ACTION_REDIRECT = 9,
- ACTION_EXECUTE = 10,
- ACTION_COLOR = 11,
- ACTION_DELETE_ON_SERVER = 12,
+static FolderItem * cur_item = NULL; /* folder (if dialog opened for processing) */
+
+typedef enum Action_ {
+ ACTION_MOVE,
+ ACTION_COPY,
+ ACTION_DELETE,
+ ACTION_MARK,
+ ACTION_UNMARK,
+ ACTION_LOCK,
+ ACTION_UNLOCK,
+ ACTION_MARK_AS_READ,
+ ACTION_MARK_AS_UNREAD,
+ ACTION_FORWARD,
+ ACTION_FORWARD_AS_ATTACHMENT,
+ ACTION_REDIRECT,
+ ACTION_EXECUTE,
+ ACTION_COLOR,
+ /* add other action constants */
+} Action;
+
+static struct {
+ gchar *text;
+ Action action;
+} action_text [] = {
+ { N_("Move"), ACTION_MOVE },
+ { N_("Copy"), ACTION_COPY },
+ { N_("Delete"), ACTION_DELETE },
+ { N_("Mark"), ACTION_MARK },
+ { N_("Unmark"), ACTION_UNMARK },
+ { N_("Lock"), ACTION_LOCK },
+ { N_("Unlock"), ACTION_UNLOCK },
+ { N_("Mark as read"), ACTION_MARK_AS_READ },
+ { N_("Mark as unread"), ACTION_MARK_AS_UNREAD },
+ { N_("Forward"), ACTION_FORWARD },
+ { N_("Forward as attachment"), ACTION_FORWARD_AS_ATTACHMENT },
+ { N_("Redirect"), ACTION_REDIRECT },
+ { N_("Execute"), ACTION_EXECUTE },
+ { N_("Color"), ACTION_COLOR }
};
+static const gchar *get_action_text(Action action)
+{
+ int n;
+ for (n = 0; n < sizeof action_text / sizeof action_text[0]; n++)
+ if (action_text[n].action == action)
+ return action_text[n].text;
+ return "";
+}
+
static gint get_sel_from_list(GtkList * list)
{
gint row = 0;
return 0;
}
-static gint prefs_filtering_get_matching_from_action(gint action_id)
+static gint prefs_filtering_get_matching_from_action(Action action_id)
{
- switch(action_id) {
+ switch (action_id) {
case ACTION_MOVE:
return MATCHACTION_MOVE;
case ACTION_COPY:
return MATCHACTION_MARK;
case ACTION_UNMARK:
return MATCHACTION_UNMARK;
+ case ACTION_LOCK:
+ return MATCHACTION_LOCK;
+ case ACTION_UNLOCK:
+ return MATCHACTION_UNLOCK;
case ACTION_MARK_AS_READ:
return MATCHACTION_MARK_AS_READ;
case ACTION_MARK_AS_UNREAD:
return MATCHACTION_EXECUTE;
case ACTION_COLOR:
return MATCHACTION_COLOR;
- case ACTION_DELETE_ON_SERVER:
- return MATCHACTION_DELETE_ON_SERVER;
default:
return -1;
}
}
-static gchar * action_text [] = {
- N_("Move"),
- N_("Copy"),
- N_("Delete"),
- N_("Mark"),
- N_("Unmark"),
- N_("Mark as read"),
- N_("Mark as unread"),
- N_("Forward"),
- N_("Forward as attachment"),
- N_("Redirect"),
- N_("Execute"),
- N_("Color"),
- N_("Delete on Server")
-};
-
void prefs_filtering_open(FolderItem * item,
const gchar *header,
const gchar *key)
GtkWidget *account_list;
GtkWidget *account_combo;
GtkWidget *dest_label;
+ GtkWidget *recip_label;
GtkWidget *exec_label;
GtkWidget *dest_entry;
GtkWidget *dest_btn;
gtk_box_pack_start (GTK_BOX (vbox1), cond_label, FALSE, FALSE, 0);
hbox1 = gtk_hbox_new (FALSE, VSPACING);
- gtk_widget_show (vbox1);
+ gtk_widget_show (hbox1);
gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (vbox1), 2);
NULL);
hbox1 = gtk_hbox_new (FALSE, VSPACING);
- gtk_widget_show (vbox1);
+ gtk_widget_show (hbox1);
gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (vbox1), 2);
FALSE);
combo_items = NULL;
-
- for(i = 0 ; i < (gint) (sizeof(action_text) / sizeof(gchar *)) ;
- i++) {
- combo_items = g_list_append(combo_items,
- (gpointer) _(action_text[i]));
- }
+ for (i = 0; i < sizeof action_text / sizeof action_text[0]; i++)
+ combo_items = g_list_append
+ (combo_items, (gpointer) _(action_text[i].text));
gtk_combo_set_popdown_strings(GTK_COMBO(action_combo), combo_items);
g_list_free(combo_items);
/* accounts */
hbox1 = gtk_hbox_new (FALSE, VSPACING);
- gtk_widget_show (vbox1);
+ gtk_widget_show (hbox1);
gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (vbox1), 2);
/* destination */
hbox1 = gtk_hbox_new (FALSE, VSPACING);
- gtk_widget_show (vbox1);
+ gtk_widget_show (hbox1);
gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (vbox1), 2);
gtk_misc_set_alignment (GTK_MISC (dest_label), 0, 0.5);
gtk_box_pack_start (GTK_BOX (hbox1), dest_label, FALSE, FALSE, 0);
+ recip_label = gtk_label_new (_("Recipient"));
+ gtk_widget_show (recip_label);
+ gtk_misc_set_alignment (GTK_MISC (recip_label), 0, 0.5);
+ gtk_box_pack_start (GTK_BOX (hbox1), recip_label, FALSE, FALSE, 0);
+
exec_label = gtk_label_new (_("Execute"));
gtk_widget_show (exec_label);
gtk_misc_set_alignment (GTK_MISC (exec_label), 0, 0.5);
filtering.dest_entry = dest_entry;
filtering.dest_btn = dest_btn;
filtering.dest_label = dest_label;
+ filtering.recip_label = recip_label;
filtering.exec_label = exec_label;
filtering.exec_btn = exec_btn;
FilteringProp * prop;
FilteringAction * action;
gint list_id;
- gint action_id;
+ Action action_id;
gint action_type;
gint account_id;
gchar * destination;
switch (action_id) {
case ACTION_MOVE:
case ACTION_COPY:
+ case ACTION_EXECUTE:
+ destination = gtk_entry_get_text(GTK_ENTRY(filtering.dest_entry));
+ if (*destination == '\0') {
+ if(alert == TRUE) alertpanel_error(_("Destination is not set."));
+ return NULL;
+ }
+ break;
case ACTION_FORWARD:
case ACTION_FORWARD_AS_ATTACHMENT:
case ACTION_REDIRECT:
- case ACTION_EXECUTE:
destination = gtk_entry_get_text(GTK_ENTRY(filtering.dest_entry));
if (*destination == '\0') {
- if(alert == TRUE) alertpanel_error(_("Destination is not set."));
+ if(alert == TRUE) alertpanel_error(_("Recipient is not set."));
return NULL;
}
break;
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;
gtk_clist_remove(clist, row);
+ prefs_filtering_reset_dialog();
+
prefs_filtering_update_hscrollbar();
}
}
}
-static void prefs_filtering_select_set(FilteringProp * prop)
+static void prefs_filtering_select_set(FilteringProp *prop)
{
- FilteringAction * action;
- gchar * matcher_str;
+ FilteringAction *action;
+ gchar *matcher_str;
gint list_id;
prefs_filtering_reset_dialog();
gtk_list_select_item(GTK_LIST(filtering.action_list),
ACTION_UNMARK);
break;
+ case MATCHACTION_LOCK:
+ gtk_list_select_item(GTK_LIST(filtering.action_list),
+ ACTION_LOCK);
+ break;
+ case MATCHACTION_UNLOCK:
+ gtk_list_select_item(GTK_LIST(filtering.action_list),
+ ACTION_UNLOCK);
+ break;
case MATCHACTION_MARK_AS_READ:
gtk_list_select_item(GTK_LIST(filtering.action_list),
ACTION_MARK_AS_READ);
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);
if (filtering.current_action != value) {
if (filtering.current_action == ACTION_FORWARD
- || filtering.current_action == ACTION_FORWARD_AS_ATTACHMENT) {
+ || filtering.current_action == ACTION_FORWARD_AS_ATTACHMENT
+ || filtering.current_action == ACTION_REDIRECT) {
debug_print("unregistering address completion entry\n");
address_completion_unregister_entry(GTK_ENTRY(filtering.dest_entry));
}
- if (value == ACTION_FORWARD || value == ACTION_FORWARD_AS_ATTACHMENT) {
+ if (value == ACTION_FORWARD || value == ACTION_FORWARD_AS_ATTACHMENT
+ || value == ACTION_REDIRECT) {
debug_print("registering address completion entry\n");
address_completion_register_entry(GTK_ENTRY(filtering.dest_entry));
}
GtkWidget *widget,
gpointer user_data)
{
- gint value;
+ Action value;
- value = get_sel_from_list(GTK_LIST(filtering.action_list));
+ value = (Action) get_sel_from_list(GTK_LIST(filtering.action_list));
switch (value) {
case ACTION_MOVE:
gtk_widget_set_sensitive(filtering.dest_btn, TRUE);
gtk_widget_show(filtering.dest_label);
gtk_widget_set_sensitive(filtering.dest_label, TRUE);
+ gtk_widget_hide(filtering.recip_label);
gtk_widget_hide(filtering.exec_label);
gtk_widget_hide(filtering.exec_btn);
gtk_widget_hide(filtering.color_optmenu);
gtk_widget_set_sensitive(filtering.dest_btn, TRUE);
gtk_widget_show(filtering.dest_label);
gtk_widget_set_sensitive(filtering.dest_label, TRUE);
+ gtk_widget_hide(filtering.recip_label);
gtk_widget_hide(filtering.exec_label);
gtk_widget_hide(filtering.exec_btn);
gtk_widget_hide(filtering.color_optmenu);
gtk_widget_set_sensitive(filtering.dest_btn, FALSE);
gtk_widget_show(filtering.dest_label);
gtk_widget_set_sensitive(filtering.dest_label, FALSE);
+ gtk_widget_hide(filtering.recip_label);
gtk_widget_hide(filtering.exec_label);
gtk_widget_hide(filtering.exec_btn);
gtk_widget_hide(filtering.color_optmenu);
gtk_widget_hide(filtering.color_label);
break;
case ACTION_MARK:
- gtk_widget_show(filtering.account_label);
- gtk_widget_set_sensitive(filtering.account_label, FALSE);
- gtk_widget_set_sensitive(filtering.account_combo, FALSE);
- gtk_widget_show(filtering.dest_entry);
- gtk_widget_set_sensitive(filtering.dest_entry, FALSE);
- gtk_widget_show(filtering.dest_btn);
- gtk_widget_set_sensitive(filtering.dest_btn, FALSE);
- gtk_widget_show(filtering.dest_label);
- gtk_widget_set_sensitive(filtering.dest_label, FALSE);
- gtk_widget_hide(filtering.exec_label);
- gtk_widget_hide(filtering.exec_btn);
- gtk_widget_hide(filtering.color_optmenu);
- gtk_widget_hide(filtering.color_label);
- break;
case ACTION_UNMARK:
- gtk_widget_show(filtering.account_label);
- gtk_widget_set_sensitive(filtering.account_label, FALSE);
- gtk_widget_set_sensitive(filtering.account_combo, FALSE);
- gtk_widget_show(filtering.dest_entry);
- gtk_widget_set_sensitive(filtering.dest_entry, FALSE);
- gtk_widget_show(filtering.dest_btn);
- gtk_widget_set_sensitive(filtering.dest_btn, FALSE);
- gtk_widget_show(filtering.dest_label);
- gtk_widget_set_sensitive(filtering.dest_label, FALSE);
- gtk_widget_hide(filtering.exec_label);
- gtk_widget_hide(filtering.exec_btn);
- gtk_widget_hide(filtering.color_optmenu);
- gtk_widget_hide(filtering.color_label);
- break;
+ case ACTION_LOCK:
+ case ACTION_UNLOCK:
case ACTION_MARK_AS_READ:
- gtk_widget_show(filtering.account_label);
- gtk_widget_set_sensitive(filtering.account_label, FALSE);
- gtk_widget_set_sensitive(filtering.account_combo, FALSE);
- gtk_widget_show(filtering.dest_entry);
- gtk_widget_set_sensitive(filtering.dest_entry, FALSE);
- gtk_widget_show(filtering.dest_btn);
- gtk_widget_set_sensitive(filtering.dest_btn, FALSE);
- gtk_widget_show(filtering.dest_label);
- gtk_widget_set_sensitive(filtering.dest_label, FALSE);
- gtk_widget_hide(filtering.exec_label);
- gtk_widget_hide(filtering.exec_btn);
- gtk_widget_hide(filtering.color_optmenu);
- gtk_widget_hide(filtering.color_label);
- break;
case ACTION_MARK_AS_UNREAD:
gtk_widget_show(filtering.account_label);
gtk_widget_set_sensitive(filtering.account_label, FALSE);
gtk_widget_set_sensitive(filtering.dest_btn, FALSE);
gtk_widget_show(filtering.dest_label);
gtk_widget_set_sensitive(filtering.dest_label, FALSE);
+ gtk_widget_hide(filtering.recip_label);
gtk_widget_hide(filtering.exec_label);
gtk_widget_hide(filtering.exec_btn);
gtk_widget_hide(filtering.color_optmenu);
gtk_widget_set_sensitive(filtering.dest_entry, TRUE);
gtk_widget_show(filtering.dest_btn);
gtk_widget_set_sensitive(filtering.dest_btn, FALSE);
- gtk_widget_show(filtering.dest_label);
- gtk_widget_set_sensitive(filtering.dest_label, TRUE);
+ gtk_widget_hide(filtering.dest_label);
+ gtk_widget_show(filtering.recip_label);
+ gtk_widget_set_sensitive(filtering.recip_label, TRUE);
gtk_widget_hide(filtering.exec_label);
gtk_widget_hide(filtering.exec_btn);
gtk_widget_hide(filtering.color_optmenu);
gtk_widget_set_sensitive(filtering.dest_entry, TRUE);
gtk_widget_show(filtering.dest_btn);
gtk_widget_set_sensitive(filtering.dest_btn, FALSE);
- gtk_widget_show(filtering.dest_label);
- gtk_widget_set_sensitive(filtering.dest_label, TRUE);
+ gtk_widget_hide(filtering.dest_label);
+ gtk_widget_show(filtering.recip_label);
+ gtk_widget_set_sensitive(filtering.recip_label, TRUE);
gtk_widget_hide(filtering.exec_label);
gtk_widget_hide(filtering.exec_btn);
gtk_widget_hide(filtering.color_optmenu);
gtk_widget_set_sensitive(filtering.dest_entry, TRUE);
gtk_widget_show(filtering.dest_btn);
gtk_widget_set_sensitive(filtering.dest_btn, FALSE);
- gtk_widget_show(filtering.dest_label);
- gtk_widget_set_sensitive(filtering.dest_label, TRUE);
+ gtk_widget_hide(filtering.dest_label);
+ gtk_widget_show(filtering.recip_label);
+ gtk_widget_set_sensitive(filtering.recip_label, TRUE);
gtk_widget_hide(filtering.exec_label);
gtk_widget_hide(filtering.exec_btn);
gtk_widget_hide(filtering.color_optmenu);
gtk_widget_set_sensitive(filtering.dest_entry, TRUE);
gtk_widget_hide(filtering.dest_btn);
gtk_widget_hide(filtering.dest_label);
+ gtk_widget_hide(filtering.recip_label);
gtk_widget_show(filtering.exec_label);
gtk_widget_set_sensitive(filtering.exec_btn, TRUE);
gtk_widget_show(filtering.exec_btn);
gtk_widget_hide(filtering.dest_entry);
gtk_widget_hide(filtering.dest_btn);
gtk_widget_hide(filtering.dest_label);
+ gtk_widget_hide(filtering.recip_label);
gtk_widget_hide(filtering.exec_label);
gtk_widget_show(filtering.exec_btn);
gtk_widget_set_sensitive(filtering.exec_btn, FALSE);
gtk_widget_show(filtering.color_optmenu);
gtk_widget_show(filtering.color_label);
break;
- case ACTION_DELETE_ON_SERVER:
- gtk_widget_show(filtering.account_label);
- gtk_widget_set_sensitive(filtering.account_label, FALSE);
- gtk_widget_set_sensitive(filtering.account_combo, FALSE);
- gtk_widget_show(filtering.dest_entry);
- gtk_widget_set_sensitive(filtering.dest_entry, FALSE);
- gtk_widget_show(filtering.dest_btn);
- gtk_widget_set_sensitive(filtering.dest_btn, FALSE);
- gtk_widget_show(filtering.dest_label);
- gtk_widget_set_sensitive(filtering.dest_label, FALSE);
- 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;
}
}
prop = prefs_filtering_dialog_to_filtering(FALSE);
if (prop != NULL) {
str = filteringprop_to_string(prop);
+
while (gtk_clist_get_text(GTK_CLIST(filtering.cond_clist),
row, 0, &filtering_str)) {
if (strcmp(filtering_str, str) == 0) break;
row++;
}
if (strcmp(filtering_str, str) != 0) {
- val = alertpanel(_("Entry not saved"),
- _("The entry was not saved\nHave you really finished?"),
- _("Yes"), _("No"), NULL);
- if (G_ALERTDEFAULT != val) {
+ val = alertpanel(_("Entry not saved"),
+ _("The entry was not saved. Close anyway?"),
+ _("Yes"), _("No"), NULL);
+ if (G_ALERTDEFAULT != val) {
g_free(str);
return;
- }
+ }
}
g_free(str);
}