guint action,
GtkWidget *widget);
+static void folderview_send_queue_cb (FolderView *folderview,
+ guint action,
+ GtkWidget *widget);
+
static void folderview_search_cb (FolderView *folderview,
guint action,
GtkWidget *widget);
};
static GtkItemFactoryEntry folder_view_trash_popup_entries[] = {
- {N_("/------"), NULL, NULL, 0, "<Separator>"},
+ {N_("/------trashsep"), NULL, NULL, 0, "<Separator>"},
{N_("/Empty _trash..."), NULL, folderview_empty_trash_cb, 0, NULL},
};
+static GtkItemFactoryEntry folder_view_queue_popup_entries[] = {
+ {N_("/------queuesep"), NULL, NULL, 0, "<Separator>"},
+ {N_("/Send _queue..."), NULL, folderview_send_queue_cb, 0, NULL},
+};
+
GtkTargetEntry folderview_drag_types[] =
{
if (item == NULL)
return;
- if (prefs_common.ask_mark_all_read) {
+ if (folderview->summaryview->folder_item != item
+ && prefs_common.ask_mark_all_read) {
val = alertpanel_full(_("Mark all as read"),
_("Do you really want to mark all mails in this "
"folder as read ?"), GTK_STOCK_NO, GTK_STOCK_YES, NULL,
- TRUE, NULL, ALERT_QUESTION, G_ALERTALTERNATE);
+ TRUE, NULL, ALERT_QUESTION, G_ALERTDEFAULT);
- if (val == G_ALERTDEFAULT ||
- val == (G_ALERTDEFAULT|G_ALERTDISABLE))
+ if ((val & ~G_ALERTDISABLE) != G_ALERTALTERNATE)
return;
- else if (val == (G_ALERTALTERNATE|G_ALERTDISABLE))
+ else if (val & G_ALERTDISABLE)
prefs_common.ask_mark_all_read = FALSE;
}
-
+
summary_lock(folderview->summaryview);
folder_item_update_freeze();
if (folderview->summaryview->folder_item == item)
folderview->selected = folderview->opened = NULL;
}
+static GtkCTreeNode *folderview_find_next_marked(GtkCTree *ctree,
+ GtkCTreeNode *node)
+{
+ FolderItem *item;
+
+ if (node)
+ node = gtkut_ctree_node_next(ctree, node);
+ else
+ node = GTK_CTREE_NODE(GTK_CLIST(ctree)->row_list);
+
+ for (; node != NULL; node = gtkut_ctree_node_next(ctree, node)) {
+ item = gtk_ctree_node_get_row_data(ctree, node);
+ if (item && item->marked_msgs > 0 && item->stype != F_TRASH)
+ return node;
+ }
+
+ return NULL;
+}
+
+void folderview_select_next_marked(FolderView *folderview)
+{
+ GtkCTree *ctree = GTK_CTREE(folderview->ctree);
+ GtkCTreeNode *node = NULL;
+ SelectOnEntry last_sel = prefs_common.select_on_entry;
+ gboolean last_open = prefs_common.always_show_msg;
+
+ prefs_common.select_on_entry = SELECTONENTRY_MNU;
+ prefs_common.always_show_msg = TRUE;
+
+ if ((node = folderview_find_next_marked(ctree, folderview->opened))
+ != NULL) {
+ folderview_select_node(folderview, node);
+ goto out;
+ }
+
+ if (!folderview->opened ||
+ folderview->opened == GTK_CTREE_NODE(GTK_CLIST(ctree)->row_list)) {
+ goto out;
+ }
+ /* search again from the first node */
+ if ((node = folderview_find_next_marked(ctree, NULL)) != NULL)
+ folderview_select_node(folderview, node);
+
+out:
+ prefs_common.select_on_entry = last_sel;
+ prefs_common.always_show_msg = last_open;
+}
+
static GtkCTreeNode *folderview_find_next_unread(GtkCTree *ctree,
GtkCTreeNode *node)
{
{
GtkCTree *ctree = GTK_CTREE(folderview->ctree);
GtkCTreeNode *node = NULL;
+ SelectOnEntry last_sel = prefs_common.select_on_entry;
+ gboolean last_open = prefs_common.always_show_msg;
+
+ prefs_common.select_on_entry = SELECTONENTRY_UNM;
+ prefs_common.always_show_msg = TRUE;
if ((node = folderview_find_next_unread(ctree, folderview->opened))
!= NULL) {
folderview_select_node(folderview, node);
- return;
+ goto out;
}
if (!folderview->opened ||
- folderview->opened == GTK_CTREE_NODE(GTK_CLIST(ctree)->row_list))
- return;
+ folderview->opened == GTK_CTREE_NODE(GTK_CLIST(ctree)->row_list)) {
+ goto out;
+ }
/* search again from the first node */
if ((node = folderview_find_next_unread(ctree, NULL)) != NULL)
folderview_select_node(folderview, node);
+
+out:
+ prefs_common.select_on_entry = last_sel;
+ prefs_common.always_show_msg = last_open;
}
static GtkCTreeNode *folderview_find_next_new(GtkCTree *ctree,
{
GtkCTree *ctree = GTK_CTREE(folderview->ctree);
GtkCTreeNode *node = NULL;
+ SelectOnEntry last_sel = prefs_common.select_on_entry;
+ gboolean last_open = prefs_common.always_show_msg;
+
+ prefs_common.select_on_entry = SELECTONENTRY_NUM;
+ prefs_common.always_show_msg = TRUE;
if ((node = folderview_find_next_new(ctree, folderview->opened))
!= NULL) {
folderview_select_node(folderview, node);
- return;
+ goto out;
}
if (!folderview->opened ||
- folderview->opened == GTK_CTREE_NODE(GTK_CLIST(ctree)->row_list))
- return;
+ folderview->opened == GTK_CTREE_NODE(GTK_CLIST(ctree)->row_list)) {
+ goto out;
+ }
/* search again from the first node */
if ((node = folderview_find_next_new(ctree, NULL)) != NULL)
folderview_select_node(folderview, node);
+
+out:
+ prefs_common.select_on_entry = last_sel;
+ prefs_common.always_show_msg = last_open;
}
FolderItem *folderview_get_selected_item(FolderView *folderview)
str = get_scan_str(item);
STATUSBAR_PUSH(folderview->mainwin, str);
-
+ GTK_EVENTS_FLUSH();
g_free(str);
folderview_scan_tree_func(item->folder, item, NULL);
color_style->fg[GTK_STATE_NORMAL] = gdk_color;
style = color_style;
} else if (use_color) {
- gtkut_convert_int_to_gdk_color(prefs_common.color_new, &gdk_color);
- bold_color_style = gtk_style_copy(bold_style);
- bold_color_style->fg[GTK_STATE_NORMAL] = gdk_color;
style = bold_color_style;
} else
style = bold_style;
style = bold_tgtfold_style;
}
} else if (use_color) {
- GdkColor gdk_color;
-
- gtkut_convert_int_to_gdk_color(prefs_common.color_new, &gdk_color);
- style = gtk_style_copy(normal_color_style);
- style->fg[GTK_STATE_NORMAL] = gdk_color;
+ style = normal_color_style;
gtk_ctree_node_set_foreground(ctree, node,
&folderview->color_new);
} else if (item->op_count > 0) {
FolderViewPopup *fpopup;
GtkItemFactory *fpopup_factory;
GtkWidget *popup;
- FolderItem *special_trash = NULL;
+ FolderItem *special_trash = NULL, *special_queue = NULL;
PrefsAccount *ac;
if (!event) return FALSE;
if (fpopup->set_sensitivity != NULL)
fpopup->set_sensitivity(fpopup_factory, item);
- if (NULL != (ac = account_find_from_item(item)))
+ if (NULL != (ac = account_find_from_item(item))) {
special_trash = account_get_special_folder(ac, F_TRASH);
-
+ special_queue = account_get_special_folder(ac, F_QUEUE);
+ }
+
if ((item == folder->trash || item == special_trash
|| folder_has_parent_of_type(item, F_TRASH)) &&
gtk_item_factory_get_item(fpopup_factory, "/Empty trash...") == NULL) {
gtk_item_factory_delete_entry(fpopup_factory, &folder_view_trash_popup_entries[1]);
}
+ if ((item == folder->queue || item == special_queue
+ || folder_has_parent_of_type(item, F_QUEUE)) &&
+ gtk_item_factory_get_item(fpopup_factory, "/Send queue...") == NULL) {
+ gtk_item_factory_create_item(fpopup_factory, &folder_view_queue_popup_entries[0], folderview, 1);
+ gtk_item_factory_create_item(fpopup_factory, &folder_view_queue_popup_entries[1], folderview, 1);
+ } else if (item != folder->queue && (special_queue == NULL || item != special_queue)
+ && !folder_has_parent_of_type(item, F_QUEUE)) {
+ gtk_item_factory_delete_entry(fpopup_factory, &folder_view_queue_popup_entries[0]);
+ gtk_item_factory_delete_entry(fpopup_factory, &folder_view_queue_popup_entries[1]);
+ }
+
#define SET_SENS(name, sens) \
menu_set_sensitive(fpopup_factory, name, sens)
SET_SENS("/Mark all read", item->unread_msgs >= 1);
SET_SENS("/Search folder...", item->total_msgs >= 1 &&
folderview->selected == folderview->opened);
- SET_SENS("/Properties...", item->node->parent != NULL);
+ SET_SENS("/Properties...", TRUE);
SET_SENS("/Processing...", item->node->parent != NULL);
if (item == folder->trash || item == special_trash
|| folder_has_parent_of_type(item, F_TRASH)) {
SET_SENS("/Empty trash...", msglist != NULL);
procmsg_msg_list_free(msglist);
}
+ if (item == folder->queue || item == special_queue
+ || folder_has_parent_of_type(item, F_QUEUE)) {
+ GSList *msglist = folder_item_get_msg_list(item);
+ SET_SENS("/Send queue...", msglist != NULL);
+ procmsg_msg_list_free(msglist);
+ }
#undef SET_SENS
popup = gtk_item_factory_get_widget(fpopup_factory, fpopup->path);
folder_item_remove_all_msg(item);
}
+static void folderview_send_queue_cb(FolderView *folderview, guint action,
+ GtkWidget *widget)
+{
+ GtkCTree *ctree = GTK_CTREE(folderview->ctree);
+ FolderItem *item;
+ FolderItem *special_queue = NULL;
+ PrefsAccount *ac;
+ gchar *errstr = NULL;
+
+ if (!folderview->selected) return;
+ item = gtk_ctree_node_get_row_data(ctree, folderview->selected);
+ g_return_if_fail(item != NULL);
+ g_return_if_fail(item->folder != NULL);
+
+ if (NULL != (ac = account_find_from_item(item)))
+ special_queue = account_get_special_folder(ac, F_QUEUE);
+
+ if (item != item->folder->queue && item != special_queue
+ && !folder_has_parent_of_type(item, F_QUEUE)) return;
+
+ if (procmsg_queue_is_empty(item))
+ return;
+
+ if (prefs_common.work_offline)
+ if (alertpanel(_("Offline warning"),
+ _("You're working offline. Override?"),
+ GTK_STOCK_NO, GTK_STOCK_YES,
+ NULL) != G_ALERTALTERNATE)
+ return;
+
+ /* ask for confirmation before sending queued messages only
+ in online mode and if there is at least one message queued
+ in any of the folder queue
+ */
+ if (prefs_common.confirm_send_queued_messages) {
+ if (!prefs_common.work_offline) {
+ if (alertpanel(_("Send queued messages"),
+ _("Send all queued messages?"),
+ GTK_STOCK_CANCEL, _("_Send"),
+ NULL) != G_ALERTALTERNATE)
+ return;
+ }
+ }
+
+ if (procmsg_send_queue(item, prefs_common.savemsg, &errstr) < 0) {
+ if (!errstr)
+ alertpanel_error_log(_("Some errors occurred while "
+ "sending queued messages."));
+ else {
+ gchar *tmp = g_strdup_printf(_("Some errors occurred "
+ "while sending queued messages:\n%s"), errstr);
+ g_free(errstr);
+ alertpanel_error_log(tmp);
+ g_free(tmp);
+ }
+ }
+}
+
static void folderview_search_cb(FolderView *folderview, guint action,
GtkWidget *widget)
{
g_return_if_fail(item != NULL);
g_return_if_fail(item->folder != NULL);
- if (folder_item_parent(item) == NULL)
- return;
-
prefs_folder_item_open(item);
}
NULL, ALERT_QUESTION, G_ALERTDEFAULT);
g_free(buf);
- if (status != G_ALERTALTERNATE
- && status != (G_ALERTALTERNATE | G_ALERTDISABLE))
+ if ((status & ~G_ALERTDISABLE) != G_ALERTALTERNATE)
return;
- if (status & G_ALERTDISABLE)
+ else if (status & G_ALERTDISABLE)
prefs_common.warn_dnd = FALSE;
}