/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 2001 Hiroyuki Yamamoto
+ * Copyright (C) 2001-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
#include "intl.h"
#include "mainwindow.h"
+#include "summaryview.h"
#include "compose.h"
#include "utils.h"
#include "xml.h"
ComposeButtonType type);
/* toolbar callbacks */
+static void toolbar_reply (gpointer data,
+ guint action);
static void toolbar_delete_cb (GtkWidget *widget,
gpointer data);
{ "A_ADDRBOOK", N_("Address book") },
{ "A_SYL_ACTIONS", N_("Sylpheed Actions Feature") },
- { "A_SEPARATOR", N_("Separator") }
+ { "A_SEPARATOR", "Separator" }
};
/* struct holds configuration files and a list of
switch (toolbar_item->type) {
case TOOLBAR_MSGVIEW:
msgview = (MessageView*)toolbar_item->parent;
- /* make sure the selected msg in summaryview is
- the one we are asked to delete */
- delete_msgview_cb(msgview, 0, widget);
+ messageview_delete(msgview);
break;
case TOOLBAR_MAIN:
mainwin = (MainWindow*)toolbar_item->parent;
static void toolbar_popup_cb(gpointer data, guint action, GtkWidget *widget)
{
- MainWindow *mainwin = get_mainwin(data);
-
- g_return_if_fail(mainwin != NULL);
- reply_cb(mainwin, action, widget);
+ toolbar_reply(data, action);
}
*/
static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
{
- ToolbarItem *toolbar_item = (ToolbarItem*)data;
- MainWindow *mainwin;
- MessageView *msgview;
-
- g_return_if_fail(toolbar_item != NULL);
-
- switch (toolbar_item->type) {
- case TOOLBAR_MAIN:
- mainwin = (MainWindow*)toolbar_item->parent;
- if (prefs_common.default_reply_list)
- reply_cb(mainwin,
- prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_LIST_WITH_QUOTE
- : COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE,
- NULL);
- else
- reply_cb(mainwin,
- prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
- : COMPOSE_REPLY_WITHOUT_QUOTE,
- NULL);
- break;
- case TOOLBAR_MSGVIEW:
- msgview = (MessageView*)toolbar_item->parent;
- compose_reply(msgview->msginfo,
- prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
- : COMPOSE_REPLY_WITHOUT_QUOTE,
- FALSE, FALSE, FALSE, NULL);
- break;
- default:
- debug_print("toolbar event not supported\n");
- }
+ toolbar_reply(data, prefs_common.reply_with_quote ?
+ COMPOSE_REPLY_WITH_QUOTE : COMPOSE_REPLY_WITHOUT_QUOTE);
}
*/
static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
{
- ToolbarItem *toolbar_item = (ToolbarItem*)data;
- MainWindow *mainwin;
- MessageView *msgview;
-
- g_return_if_fail(toolbar_item != NULL);
-
- switch (toolbar_item->type) {
- case TOOLBAR_MAIN:
- mainwin = (MainWindow*)toolbar_item->parent;
- reply_cb(mainwin,
- prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
- : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
- NULL);
- break;
- case TOOLBAR_MSGVIEW:
- msgview = (MessageView*)toolbar_item->parent;
- compose_reply(msgview->msginfo,
- prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
- : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
- TRUE, FALSE, FALSE, NULL);
- break;
- default:
- debug_print("toolbar event not supported\n");
- }
+ toolbar_reply(data,
+ prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
+ : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE);
}
*/
static void toolbar_reply_to_list_cb(GtkWidget *widget, gpointer data)
{
- ToolbarItem *toolbar_item = (ToolbarItem*)data;
- MainWindow *mainwin;
- MessageView *msgview;
-
- g_return_if_fail(toolbar_item != NULL);
-
- switch (toolbar_item->type) {
- case TOOLBAR_MAIN:
- mainwin = (MainWindow*)toolbar_item->parent;
- reply_cb(mainwin,
- prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_LIST_WITH_QUOTE
- : COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE,
- NULL);
- break;
- case TOOLBAR_MSGVIEW:
- msgview = (MessageView*)toolbar_item->parent;
- compose_reply(msgview->msginfo,
- prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_LIST_WITH_QUOTE
- : COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE,
- FALSE, TRUE, FALSE, NULL);
- break;
- default:
- debug_print("toolbar event not supported\n");
- }
+ toolbar_reply(data,
+ prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_LIST_WITH_QUOTE
+ : COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE);
}
*/
static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
{
- ToolbarItem *toolbar_item = (ToolbarItem*)data;
- MainWindow *mainwin;
- MessageView *msgview;
-
- g_return_if_fail(toolbar_item != NULL);
-
- switch (toolbar_item->type) {
- case TOOLBAR_MAIN:
- mainwin = (MainWindow*)toolbar_item->parent;
- reply_cb(mainwin,
- prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
- : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
- NULL);
- break;
- case TOOLBAR_MSGVIEW:
- msgview = (MessageView*)toolbar_item->parent;
- compose_reply(msgview->msginfo,
- prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
- : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
- FALSE, FALSE, FALSE, NULL);
- break;
- default:
- debug_print("toolbar event not supported\n\n");
- }
+ toolbar_reply(data,
+ prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
+ : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE);
}
/*
*/
static void toolbar_forward_cb(GtkWidget *widget, gpointer data)
{
- ToolbarItem *toolbar_item = (ToolbarItem*)data;
- MainWindow *mainwin;
-
- g_return_if_fail(toolbar_item != NULL);
-
- switch (toolbar_item->type) {
- case TOOLBAR_MAIN:
- mainwin = (MainWindow*)toolbar_item->parent;
- if (prefs_common.forward_as_attachment)
- reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
- else
- reply_cb(mainwin, COMPOSE_FORWARD, NULL);
- break;
-
- default:
- debug_print("toolbar event not supported\n");
- }
+ toolbar_reply(data, COMPOSE_FORWARD);
}
}
static void toolbar_buttons_cb(GtkWidget *widget,
- ToolbarItem *item)
+ ToolbarItem *item)
{
gint num_items;
gint i;
toolbar_destroy(toolbar);
}
-/* exported functions */
-
-void delete_msgview_cb(gpointer data, guint action, GtkWidget *widget)
+/*
+ */
+static void toolbar_reply(gpointer data, guint action)
{
- MessageView *msgview = (MessageView*)data;
+ ToolbarItem *toolbar_item = (ToolbarItem*)data;
+ MainWindow *mainwin;
+ MessageView *msgview;
+ GSList *msginfo_list = NULL;
+ gchar *body;
- if (msgview->mainwin->summaryview->selected) {
- SummaryView *summaryview = msgview->mainwin->summaryview;
- GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
- MsgInfo *msginfo = gtk_ctree_node_get_row_data(ctree,
- summaryview->selected);
- if (msginfo->msgnum != msgview->msginfo->msgnum) {
- alertpanel_error(_("Message already removed from folder."));
- return;
- }
+ g_return_if_fail(toolbar_item != NULL);
+
+ switch (toolbar_item->type) {
+ case TOOLBAR_MAIN:
+ mainwin = (MainWindow*)toolbar_item->parent;
+ msginfo_list = summary_get_selection(mainwin->summaryview);
+ msgview = (MessageView*)mainwin->messageview;
+ break;
+ case TOOLBAR_MSGVIEW:
+ msgview = (MessageView*)toolbar_item->parent;
+ msginfo_list = g_slist_append(msginfo_list, msgview->msginfo);
+ break;
+ default:
+ return;
}
-
- summary_delete(msgview->mainwin->summaryview);
-
- if (msgview->mainwin->summaryview->selected) {
- SummaryView *summaryview = msgview->mainwin->summaryview;
- GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
- MsgInfo *msginfo = gtk_ctree_node_get_row_data(ctree,
- summaryview->selected);
- messageview_show(msgview, msginfo,
- msgview->all_headers);
- } else {
- toolbar_clear_list(TOOLBAR_MSGVIEW);
- toolbar_destroy(msgview->toolbar);
- gtk_widget_destroy(msgview->window);
- }
-}
-
-void reply_cb(gpointer data, guint action, GtkWidget *widget)
-{
- MainWindow *mainwin = (MainWindow*)data;
- g_return_if_fail(mainwin != NULL);
+ g_return_if_fail(msgview != NULL);
+ body = messageview_get_selection(msgview);
+
+ g_return_if_fail(msginfo_list != NULL);
+ compose_reply_mode((ComposeMode)action, msginfo_list, body);
+
+ g_free(body);
+ g_slist_free(msginfo_list);
- summary_reply(mainwin->summaryview, (ComposeMode)action);
+ /* TODO: update reply state ion summaryview */
}
+
+/* exported functions */
+
void inc_mail_cb(gpointer data, guint action, GtkWidget *widget)
{
MainWindow *mainwin = (MainWindow*)data;