From 0d56f1acfeb7e0ed9a2323feca2353ba51887975 Mon Sep 17 00:00:00 2001 From: Colin Leroy Date: Thu, 27 Jan 2005 10:51:15 +0000 Subject: [PATCH 1/1] 2005-01-27 [colin] 1.0.0cvs16 * src/messageview.c * src/summaryview.c * src/compose.c * src/compose.h * src/toolbar.c * src/mainwindow.c Factorize this reply mess --- ChangeLog.claws | 10 ++++++ PATCHSETS | 1 + configure.ac | 2 +- src/compose.c | 13 +++++++ src/compose.h | 4 +++ src/mainwindow.c | 6 +--- src/messageview.c | 90 +++-------------------------------------------- src/summaryview.c | 7 +--- src/toolbar.c | 8 ++--- 9 files changed, 38 insertions(+), 103 deletions(-) diff --git a/ChangeLog.claws b/ChangeLog.claws index 390e59183..e2fc3b89c 100644 --- a/ChangeLog.claws +++ b/ChangeLog.claws @@ -1,3 +1,13 @@ +2005-01-27 [colin] 1.0.0cvs16 + + * src/messageview.c + * src/summaryview.c + * src/compose.c + * src/compose.h + * src/toolbar.c + * src/mainwindow.c + Factorize this reply mess + 2005-01-26 [paul] 1.0.0cvs15 * ChangeLog diff --git a/PATCHSETS b/PATCHSETS index ee6775047..3e391d0d8 100644 --- a/PATCHSETS +++ b/PATCHSETS @@ -223,3 +223,4 @@ ( cvs diff -u -r 1.456 -r 1.457 src/summaryview.c; ) > 1.0.0cvs13.patchset ( cvs diff -u -r 1.466 -r 1.467 src/compose.c; ) > 1.0.0cvs14.patchset ( cvs diff -u -r 1.456 -r 1.457 ChangeLog; cvs diff -u -r 1.451 -r 1.452 ChangeLog.jp; cvs diff -u -r 1.3 -r 1.4 src/common/template.c; ) > 1.0.0cvs15.patchset +( cvs diff -u -r 1.129 -r 1.130 src/messageview.c; cvs diff -u -r 1.457 -r 1.458 src/summaryview.c; cvs diff -u -r 1.467 -r 1.468 src/compose.c; cvs diff -u -r 1.57 -r 1.58 src/compose.h; cvs diff -u -r 1.56 -r 1.57 src/toolbar.c; cvs diff -u -r 1.316 -r 1.317 src/mainwindow.c; ) > 1.0.0cvs16.patchset diff --git a/configure.ac b/configure.ac index d280ab3a2..82e04117c 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ MINOR_VERSION=0 MICRO_VERSION=0 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=15 +EXTRA_VERSION=16 EXTRA_RELEASE= if test \( $EXTRA_VERSION -eq 0 \) -o \( "x$EXTRA_RELEASE" != "x" \); then diff --git a/src/compose.c b/src/compose.c index 82d7791ed..78c747894 100644 --- a/src/compose.c +++ b/src/compose.c @@ -6923,3 +6923,16 @@ static void compose_add_field_list( Compose *compose, GList *listAddress ) { * End of Source. */ +void compose_reply_from_messageview(MessageView *msgview, GSList *msginfo_list, + guint action) +{ + gchar *body; + + g_return_if_fail(msgview != NULL); + + g_return_if_fail(msginfo_list != NULL); + + body = messageview_get_selection(msgview); + compose_reply_mode((ComposeMode)action, msginfo_list, body); + g_free(body); +} diff --git a/src/compose.h b/src/compose.h index a44258452..80a550af0 100644 --- a/src/compose.h +++ b/src/compose.h @@ -33,6 +33,7 @@ typedef struct _AttachInfo AttachInfo; #include "prefs_account.h" #include "undo.h" #include "toolbar.h" +#include "messageview.h" #ifdef USE_ASPELL #include "gtkaspell.h" @@ -279,5 +280,8 @@ void compose_destroy_all (void); void compose_draft (gpointer data); void compose_toolbar_cb (gint action, gpointer data); +void compose_reply_from_messageview (MessageView *msgview, + GSList *msginfo_list, + guint action); #endif /* __COMPOSE_H__ */ diff --git a/src/mainwindow.c b/src/mainwindow.c index 7b364236a..498f824ed 100644 --- a/src/mainwindow.c +++ b/src/mainwindow.c @@ -2455,16 +2455,12 @@ void main_window_reply_cb(MainWindow *mainwin, guint action, { MessageView *msgview = (MessageView*)mainwin->messageview; GSList *msginfo_list = NULL; - gchar *body; g_return_if_fail(msgview != NULL); msginfo_list = summary_get_selection(mainwin->summaryview); g_return_if_fail(msginfo_list != NULL); - - body = messageview_get_selection(msgview); - compose_reply_mode((ComposeMode)action, msginfo_list, body); - g_free(body); + compose_reply_from_messageview(msgview, msginfo_list, action); g_slist_free(msginfo_list); } diff --git a/src/messageview.c b/src/messageview.c index 5e0dfa968..d4b3cb8d7 100644 --- a/src/messageview.c +++ b/src/messageview.c @@ -1363,94 +1363,14 @@ static void compose_cb(gpointer data, guint action, GtkWidget *widget) static void reply_cb(gpointer data, guint action, GtkWidget *widget) { MessageView *messageview = (MessageView *)data; - GSList *mlist = NULL; + GSList *msginfo_list = NULL; MsgInfo *msginfo; - gchar *text = NULL; - ComposeMode mode = (ComposeMode)action; - TextView *textview; - - msginfo = messageview->msginfo; - mlist = g_slist_append(NULL, msginfo); - textview = messageview_get_current_textview(messageview); - text = gtkut_editable_get_selection - (GTK_EDITABLE(textview->text)); - if (text && *text == '\0') { - g_free(text); - text = NULL; - } + g_return_if_fail(messageview->msginfo); - switch (mode) { - case COMPOSE_REPLY: - compose_reply(msginfo, prefs_common.reply_with_quote, - FALSE, prefs_common.default_reply_list, FALSE, text); - break; - case COMPOSE_REPLY_WITH_QUOTE: - compose_reply(msginfo, TRUE, FALSE, prefs_common.default_reply_list, FALSE, text); - break; - case COMPOSE_REPLY_WITHOUT_QUOTE: - compose_reply(msginfo, FALSE, FALSE, prefs_common.default_reply_list, FALSE, NULL); - break; - case COMPOSE_REPLY_TO_SENDER: - compose_reply(msginfo, prefs_common.reply_with_quote, - FALSE, FALSE, TRUE, text); - break; - case COMPOSE_FOLLOWUP_AND_REPLY_TO: - compose_followup_and_reply_to(msginfo, - prefs_common.reply_with_quote, - FALSE, FALSE, text); - break; - case COMPOSE_REPLY_TO_SENDER_WITH_QUOTE: - compose_reply(msginfo, TRUE, FALSE, FALSE, TRUE, text); - break; - case COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE: - compose_reply(msginfo, FALSE, FALSE, FALSE, TRUE, NULL); - break; - case COMPOSE_REPLY_TO_ALL: - compose_reply(msginfo, prefs_common.reply_with_quote, - TRUE, FALSE, FALSE, text); - break; - case COMPOSE_REPLY_TO_ALL_WITH_QUOTE: - compose_reply(msginfo, TRUE, TRUE, FALSE, FALSE, text); - break; - case COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE: - compose_reply(msginfo, FALSE, TRUE, FALSE, FALSE, NULL); - break; - case COMPOSE_REPLY_TO_LIST: - compose_reply(msginfo, prefs_common.reply_with_quote, - FALSE, TRUE, FALSE, text); - break; - case COMPOSE_REPLY_TO_LIST_WITH_QUOTE: - compose_reply(msginfo, TRUE, FALSE, TRUE, FALSE, text); - break; - case COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE: - compose_reply(msginfo, FALSE, FALSE, TRUE, FALSE, NULL); - break; - case COMPOSE_FORWARD: - if (prefs_common.forward_as_attachment) { - compose_reply_mode(COMPOSE_FORWARD_AS_ATTACH, mlist, text); - return; - } else { - compose_reply_mode(COMPOSE_FORWARD_INLINE, mlist, text); - return; - } - break; - case COMPOSE_FORWARD_INLINE: - compose_forward(NULL, msginfo, FALSE, text, FALSE); - break; - case COMPOSE_FORWARD_AS_ATTACH: - compose_forward_multiple(NULL, mlist); - break; - case COMPOSE_REDIRECT: - compose_redirect(NULL, msginfo); - break; - default: - g_warning("compose_reply(): invalid Compose Mode: %d\n", mode); - } - - /* summary_set_marks_selected(summaryview); */ - g_free(text); - g_slist_free(mlist); + msginfo_list = g_slist_append(msginfo_list, messageview->msginfo); + compose_reply_from_messageview(messageview, msginfo_list, action); + g_list_free(msginfo_list); } static void reedit_cb(gpointer data, guint action, GtkWidget *widget) diff --git a/src/summaryview.c b/src/summaryview.c index fc32c317c..d87da2f7d 100644 --- a/src/summaryview.c +++ b/src/summaryview.c @@ -4621,17 +4621,12 @@ static void summary_reply_cb(SummaryView *summaryview, guint action, { MessageView *msgview = (MessageView*)summaryview->messageview; GSList *msginfo_list; - gchar *body; g_return_if_fail(msgview != NULL); msginfo_list = summary_get_selection(summaryview); g_return_if_fail(msginfo_list != NULL); - - body = messageview_get_selection(msgview); - - compose_reply_mode((ComposeMode)action, msginfo_list, body); - g_free(body); + compose_reply_from_messageview(msgview, msginfo_list, action); g_slist_free(msginfo_list); } diff --git a/src/toolbar.c b/src/toolbar.c index 576d636fc..2b54778bd 100644 --- a/src/toolbar.c +++ b/src/toolbar.c @@ -1811,7 +1811,6 @@ static void toolbar_reply(gpointer data, guint action) MainWindow *mainwin; MessageView *msgview; GSList *msginfo_list = NULL; - gchar *body; g_return_if_fail(toolbar_item != NULL); @@ -1823,6 +1822,7 @@ static void toolbar_reply(gpointer data, guint action) break; case TOOLBAR_MSGVIEW: msgview = (MessageView*)toolbar_item->parent; + g_return_if_fail(msgview != NULL); msginfo_list = g_slist_append(msginfo_list, msgview->msginfo); break; default: @@ -1830,12 +1830,8 @@ static void toolbar_reply(gpointer data, guint action) } 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); + compose_reply_from_messageview(msgview, msginfo_list, action); g_slist_free(msginfo_list); /* TODO: update reply state ion summaryview */ -- 2.25.1