commit 28e718bfcdf36c295858c150dadd9e82cf80b65e
parent 8c1ab26326efaaf610ab6dbbae33a833442d1137
Author: Paweł Pękala <c0rn@gazeta.pl>
Date: Fri, 26 Mar 2010 22:15:29 +0000
2010-03-26 [pawel] 3.7.5cvs40
* src/compose.c
* src/compose.h
* src/textview.c
Fix Bug 1928 Add "reply to this address" pop menu
on Message View
- Set composing account to email one when creating/replying
from NNTP folder by clicking link or choosing option
from popup menu
- Factorize code
Diffstat:
6 files changed, 149 insertions(+), 53 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,3 +1,15 @@
+2010-03-26 [pawel] 3.7.5cvs40
+
+ * src/compose.c
+ * src/compose.h
+ * src/textview.c
+ Fix Bug 1928 Add "reply to this address" pop menu
+ on Message View
+ - Set composing account to email one when creating/replying
+ from NNTP folder by clicking link or choosing option
+ from popup menu
+ - Factorize code
+
2010-03-25 [paul] 3.7.5cvs39
* src/gtk/gtkcmclist.c
diff --git a/PATCHSETS b/PATCHSETS
@@ -3980,3 +3980,4 @@
( cvs diff -u -r 1.274.2.307 -r 1.274.2.308 src/mainwindow.c; cvs diff -u -r 1.83.2.161 -r 1.83.2.162 src/mimeview.c; cvs diff -u -r 1.1.2.14 -r 1.1.2.15 src/gtk/gtkcmctree.c; ) > 3.7.5cvs37.patchset
( cvs diff -u -r 1.27.2.46 -r 1.27.2.47 src/addr_compl.c; cvs diff -u -r 1.382.2.547 -r 1.382.2.548 src/compose.c; cvs diff -u -r 1.207.2.215 -r 1.207.2.216 src/folderview.c; cvs diff -u -r 1.14.2.25 -r 1.14.2.26 src/grouplistdialog.c; cvs diff -u -r 1.8.2.30 -r 1.8.2.31 src/headerview.c; cvs diff -u -r 1.274.2.308 -r 1.274.2.309 src/mainwindow.c; cvs diff -u -r 1.83.2.162 -r 1.83.2.163 src/mimeview.c; cvs diff -u -r 1.105.2.158 -r 1.105.2.159 src/prefs_account.c; cvs diff -u -r 1.1.2.11 -r 1.1.2.12 src/gtk/gtkcmclist.c; cvs diff -u -r 1.1.2.15 -r 1.1.2.16 src/gtk/gtkcmctree.c; cvs diff -u -r 1.1.2.2 -r 1.1.2.3 src/gtk/gtkcmoptionmenu.c; cvs diff -u -r 1.1.4.57 -r 1.1.4.58 src/gtk/gtksctree.c; cvs diff -u -r 1.1.4.11 -r 1.1.4.12 src/gtk/gtkshruler.c; cvs diff -u -r 1.5.2.89 -r 1.5.2.90 src/gtk/gtkutils.c; cvs diff -u -r 1.4.2.48 -r 1.4.2.49 src/gtk/gtkutils.h; cvs diff -u -r 1.5.2.18 -r 1.5.2.19 src/gtk/gtkvscrollbutton.c; cvs diff -u -r 1.2.2.37 -r 1.2.2.38 src/gtk/inputdialog.c; cvs diff -u -r 1.1.2.9 -r 1.1.2.10 src/gtk/spell_entry.c; cvs diff -u -r 1.14.2.70 -r 1.14.2.71 src/plugins/trayicon/trayicon.c; cvs diff -u -r 1.2.2.2 -r 1.2.2.3 src/plugins/trayicon/libeggtrayicon/Makefile.am; cvs diff -u -r 1.1.4.10 -r 1.1.4.11 src/plugins/trayicon/libeggtrayicon/eggtrayicon.c; cvs diff -u -r 1.1.4.4 -r 1.1.4.5 src/plugins/trayicon/libeggtrayicon/gtkplugxembed.c; ) > 3.7.5cvs38.patchset
( cvs diff -u -r 1.1.2.12 -r 1.1.2.13 src/gtk/gtkcmclist.c; ) > 3.7.5cvs39.patchset
+( cvs diff -u -r 1.382.2.548 -r 1.382.2.549 src/compose.c; cvs diff -u -r 1.50.2.59 -r 1.50.2.60 src/compose.h; cvs diff -u -r 1.96.2.222 -r 1.96.2.223 src/textview.c; ) > 3.7.5cvs40.patchset
diff --git a/configure.ac b/configure.ac
@@ -12,7 +12,7 @@ MINOR_VERSION=7
MICRO_VERSION=5
INTERFACE_AGE=0
BINARY_AGE=0
-EXTRA_VERSION=39
+EXTRA_VERSION=40
EXTRA_RELEASE=
EXTRA_GTK2_VERSION=
diff --git a/src/compose.c b/src/compose.c
@@ -533,6 +533,8 @@ static void compose_set_dictionaries_from_folder_prefs(Compose *compose,
FolderItem *folder_item);
#endif
static void compose_attach_update_label(Compose *compose);
+static void compose_set_folder_prefs(Compose *compose, FolderItem *folder,
+ gboolean respect_default_to);
static GtkActionEntry compose_popup_entries[] =
{
@@ -1030,24 +1032,8 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
if (mailto && *mailto != '\0') {
mfield = compose_entries_set(compose, mailto, COMPOSE_TO);
- } else if (item && item->prefs) {
- if (item->prefs->enable_default_bcc) {
- compose_entry_append(compose, item->prefs->default_bcc,
- COMPOSE_BCC, PREF_FOLDER);
- }
- if (item->prefs->enable_default_cc) {
- compose_entry_append(compose, item->prefs->default_cc,
- COMPOSE_CC, PREF_FOLDER);
- }
- if (item->prefs->enable_default_replyto) {
- compose_entry_append(compose, item->prefs->default_replyto,
- COMPOSE_REPLYTO, PREF_FOLDER);
- }
- if (item->prefs->enable_default_to) {
- compose_entry_append(compose, item->prefs->default_to,
- COMPOSE_TO, PREF_FOLDER);
- compose_entry_mark_default_to(compose, item->prefs->default_to);
- }
+ } else {
+ compose_set_folder_prefs(compose, item, TRUE);
}
if (item && item->ret_rcpt) {
cm_toggle_menu_set_active_full(compose->ui_manager, "Menu/Options/RequestRetRcpt", TRUE);
@@ -1311,6 +1297,7 @@ static Compose *compose_reply_mode(ComposeMode mode, GSList *msginfo_list, gchar
switch (mode) {
case COMPOSE_REPLY:
+ case COMPOSE_REPLY_TO_ADDRESS:
compose = compose_reply(msginfo, COMPOSE_QUOTE_CHECK,
FALSE, prefs_common.default_reply_list, FALSE, body);
break;
@@ -1422,6 +1409,9 @@ static Compose *compose_reply_mode(ComposeMode mode, GSList *msginfo_list, gchar
debug_print("reply mode List\n");
cm_toggle_menu_set_active_full(compose->ui_manager, "Menu/Options/ReplyMode/List", TRUE);
break;
+ case COMPOSE_REPLY_TO_ADDRESS:
+ cm_menu_set_sensitive_full(compose->ui_manager, "Menu/Options/ReplyMode", FALSE);
+ break;
default:
break;
}
@@ -1433,7 +1423,7 @@ static Compose *compose_reply(MsgInfo *msginfo,
gboolean to_all,
gboolean to_ml,
gboolean to_sender,
- const gchar *body)
+ const gchar *body)
{
return compose_generic_reply(msginfo, quote_mode, to_all, to_ml,
to_sender, FALSE, body);
@@ -3064,6 +3054,52 @@ static gboolean is_subscription(const gchar *ml_post, const gchar *from)
return result;
}
+static void compose_set_folder_prefs(Compose *compose, FolderItem *folder,
+ gboolean respect_default_to)
+{
+ if (!compose)
+ return;
+ if (!folder || !folder->prefs)
+ return;
+
+ if (respect_default_to && folder->prefs->enable_default_to) {
+ compose_entry_append(compose, folder->prefs->default_to,
+ COMPOSE_TO, PREF_FOLDER);
+ compose_entry_mark_default_to(compose, folder->prefs->default_to);
+ }
+ if (folder->prefs->enable_default_cc)
+ compose_entry_append(compose, folder->prefs->default_cc,
+ COMPOSE_CC, PREF_FOLDER);
+ if (folder->prefs->enable_default_bcc)
+ compose_entry_append(compose, folder->prefs->default_bcc,
+ COMPOSE_BCC, PREF_FOLDER);
+ if (folder->prefs->enable_default_replyto)
+ compose_entry_append(compose, folder->prefs->default_replyto,
+ COMPOSE_REPLYTO, PREF_FOLDER);
+}
+
+static void compose_reply_set_subject(Compose *compose, MsgInfo *msginfo)
+{
+ gchar *buf, *buf2;
+ gchar *p;
+
+ if (!compose || !msginfo)
+ return;
+
+ if (msginfo->subject && *msginfo->subject) {
+ buf = p = g_strdup(msginfo->subject);
+ p += subject_get_prefix_length(p);
+ memmove(buf, p, strlen(p) + 1);
+
+ buf2 = g_strdup_printf("Re: %s", buf);
+ gtk_entry_set_text(GTK_ENTRY(compose->subject_entry), buf2);
+
+ g_free(buf2);
+ g_free(buf);
+ } else
+ gtk_entry_set_text(GTK_ENTRY(compose->subject_entry), "Re: ");
+}
+
static void compose_reply_set_entry(Compose *compose, MsgInfo *msginfo,
gboolean to_all, gboolean to_ml,
gboolean to_sender,
@@ -3087,20 +3123,8 @@ static void compose_reply_set_entry(Compose *compose, MsgInfo *msginfo,
msginfo->folder->prefs->enable_default_reply_to;
if (compose->account->protocol != A_NNTP) {
- if (msginfo && msginfo->folder && msginfo->folder->prefs) {
- if (msginfo->folder->prefs->enable_default_replyto) {
- compose_entry_append(compose, msginfo->folder->prefs->default_replyto,
- COMPOSE_REPLYTO, PREF_FOLDER);
- }
- if (msginfo->folder->prefs->enable_default_bcc) {
- compose_entry_append(compose, msginfo->folder->prefs->default_bcc,
- COMPOSE_BCC, PREF_FOLDER);
- }
- if (msginfo->folder->prefs->enable_default_cc) {
- compose_entry_append(compose, msginfo->folder->prefs->default_cc,
- COMPOSE_CC, PREF_FOLDER);
- }
- }
+ compose_set_folder_prefs(compose, msginfo->folder, FALSE);
+
if (reply_to_ml && !default_reply_to) {
gboolean is_subscr = is_subscription(compose->ml_post,
@@ -3198,22 +3222,7 @@ static void compose_reply_set_entry(Compose *compose, MsgInfo *msginfo,
compose->newsgroups ? compose->newsgroups : "",
COMPOSE_NEWSGROUPS, PREF_NONE);
}
-
- if (msginfo->subject && *msginfo->subject) {
- gchar *buf, *buf2;
- gchar *p;
-
- buf = p = g_strdup(msginfo->subject);
- p += subject_get_prefix_length(p);
- memmove(buf, p, strlen(p) + 1);
-
- buf2 = g_strdup_printf("Re: %s", buf);
- gtk_entry_set_text(GTK_ENTRY(compose->subject_entry), buf2);
-
- g_free(buf2);
- g_free(buf);
- } else
- gtk_entry_set_text(GTK_ENTRY(compose->subject_entry), "Re: ");
+ compose_reply_set_subject(compose, msginfo);
if (to_ml && compose->ml_post) return;
if (!to_all || compose->account->protocol == A_NNTP) return;
@@ -7717,6 +7726,7 @@ static GtkWidget *compose_account_option_menu_create(Compose *compose)
CLAWS_SET_TIP(from_name,
_("Sender address to be used"));
+ compose->account_combo = optmenu;
compose->from_name = from_name;
return hbox;
@@ -11127,6 +11137,51 @@ void compose_reply_from_messageview(MessageView *msgview, GSList *msginfo_list,
}
}
+void compose_check_for_email_account(Compose *compose)
+{
+ PrefsAccount *ac = NULL, *curr = NULL;
+ GList *list;
+
+ if (!compose)
+ return;
+
+ if (compose->account && compose->account->protocol == A_NNTP) {
+ ac = account_get_cur_account();
+ if (ac->protocol == A_NNTP) {
+ list = account_get_list();
+
+ for( ; list != NULL ; list = g_list_next(list)) {
+ curr = (PrefsAccount *) list->data;
+ if (curr->protocol != A_NNTP) {
+ ac = curr;
+ break;
+ }
+ }
+ }
+ combobox_select_by_data(GTK_COMBO_BOX(compose->account_combo),
+ ac->account_id);
+ }
+}
+
+void compose_reply_to_address(MessageView *msgview, MsgInfo *msginfo,
+ const gchar *address)
+{
+ GSList *msginfo_list = NULL;
+ gchar *body = messageview_get_selection(msgview);
+ Compose *compose;
+
+ msginfo_list = g_slist_prepend(msginfo_list, msginfo);
+
+ compose = compose_reply_mode(COMPOSE_REPLY_TO_ADDRESS, msginfo_list, body);
+ compose_check_for_email_account(compose);
+ compose_set_folder_prefs(compose, msginfo->folder, FALSE);
+ compose_entry_append(compose, address, COMPOSE_TO, PREF_NONE);
+ compose_reply_set_subject(compose, msginfo);
+
+ g_free(body);
+ hooks_invoke(COMPOSE_CREATED_HOOKLIST, compose);
+}
+
void compose_set_position(Compose *compose, gint pos)
{
GtkTextView *text = GTK_TEXT_VIEW(compose->text);
diff --git a/src/compose.h b/src/compose.h
@@ -62,6 +62,7 @@ typedef enum
COMPOSE_REPLY_WITH_QUOTE,
COMPOSE_REPLY_WITHOUT_QUOTE,
COMPOSE_REPLY_TO_SENDER,
+ COMPOSE_REPLY_TO_ADDRESS,
COMPOSE_FOLLOWUP_AND_REPLY_TO,
COMPOSE_REPLY_TO_SENDER_WITH_QUOTE,
COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
@@ -114,6 +115,7 @@ struct _Compose
/* Header */
GtkWidget *table_vbox;
GtkWidget *table;
+ GtkWidget *account_combo;
GtkWidget *subject_entry;
GtkWidget *paned;
@@ -313,6 +315,9 @@ void compose_destroy_all (void);
gboolean compose_draft (gpointer data, guint action);
void compose_toolbar_cb (gint action,
gpointer data);
+void compose_reply_to_address (MessageView *msgview,
+ MsgInfo *msginfo,
+ const gchar *address);
void compose_reply_from_messageview (MessageView *msgview,
GSList *msginfo_list,
guint action);
@@ -336,4 +341,5 @@ void compose_close_toolbar (Compose *compose);
void compose_clear_exit_drafts (void);
void compose_reopen_exit_drafts (void);
void compose_attach_from_list (Compose *compose, GList *file_list, gboolean free_data);
+void compose_check_for_email_account(Compose *compose);
#endif /* __COMPOSE_H__ */
diff --git a/src/textview.c b/src/textview.c
@@ -191,6 +191,8 @@ static void copy_uri_cb (GtkAction *action,
TextView *textview);
static void add_uri_to_addrbook_cb (GtkAction *action,
TextView *textview);
+static void reply_to_uri_cb (GtkAction *action,
+ TextView *textview);
static void mail_to_uri_cb (GtkAction *action,
TextView *textview);
static void copy_mail_to_uri_cb (GtkAction *action,
@@ -212,6 +214,7 @@ static GtkActionEntry textview_mail_popup_entries[] =
{
{"TextviewPopupMail", NULL, "TextviewPopupMail" },
{"TextviewPopupMail/Compose", NULL, N_("Compose _new message"), NULL, NULL, G_CALLBACK(mail_to_uri_cb) },
+ {"TextviewPopupMail/ReplyTo", NULL, N_("_Reply to this address"), NULL, NULL, G_CALLBACK(reply_to_uri_cb) },
{"TextviewPopupMail/AddAB", NULL, N_("Add to _Address book"), NULL, NULL, G_CALLBACK(add_uri_to_addrbook_cb) },
{"TextviewPopupMail/Copy", NULL, N_("Copy this add_ress"), NULL, NULL, G_CALLBACK(copy_mail_to_uri_cb) },
};
@@ -343,6 +346,8 @@ TextView *textview_create(void)
MENUITEM_ADDUI_MANAGER(textview->ui_manager,
"/Menus/TextviewPopupMail", "Compose", "TextviewPopupMail/Compose", GTK_UI_MANAGER_MENUITEM)
MENUITEM_ADDUI_MANAGER(textview->ui_manager,
+ "/Menus/TextviewPopupMail", "ReplyTo", "TextviewPopupMail/ReplyTo", GTK_UI_MANAGER_MENUITEM)
+ MENUITEM_ADDUI_MANAGER(textview->ui_manager,
"/Menus/TextviewPopupMail", "AddAB", "TextviewPopupMail/AddAB", GTK_UI_MANAGER_MENUITEM)
MENUITEM_ADDUI_MANAGER(textview->ui_manager,
"/Menus/TextviewPopupMail", "Copy", "TextviewPopupMail/Copy", GTK_UI_MANAGER_MENUITEM)
@@ -2678,6 +2683,8 @@ static gboolean textview_uri_button_pressed(GtkTextTag *tag, GObject *obj,
} else {
PrefsAccount *account = NULL;
FolderItem *folder_item = NULL;
+ Compose *compose;
+
if (textview->messageview && textview->messageview->msginfo &&
textview->messageview->msginfo->folder) {
@@ -2688,7 +2695,9 @@ static gboolean textview_uri_button_pressed(GtkTextTag *tag, GObject *obj,
if (!account)
account = account_find_from_item(folder_item);
}
- compose_new_with_folderitem(account, folder_item, uri->uri + 7);
+ compose = compose_new_with_folderitem(account,
+ folder_item, uri->uri + 7);
+ compose_check_for_email_account(compose);
}
return TRUE;
} else if (g_ascii_strncasecmp(uri->uri, "file:", 5)) {
@@ -3033,9 +3042,21 @@ static void add_uri_to_addrbook_cb (GtkAction *action, TextView *textview)
g_free(fromname);
}
+static void reply_to_uri_cb (GtkAction *action, TextView *textview)
+{
+ ClickableText *uri = g_object_get_data(G_OBJECT(textview->mail_popup_menu),
+ "menu_button");
+ if (!textview->messageview || !uri)
+ return;
+
+ compose_reply_to_address (textview->messageview,
+ textview->messageview->msginfo, uri->uri+7);
+}
+
static void mail_to_uri_cb (GtkAction *action, TextView *textview)
{
PrefsAccount *account = NULL;
+ Compose *compose;
ClickableText *uri = g_object_get_data(G_OBJECT(textview->mail_popup_menu),
"menu_button");
if (uri == NULL)
@@ -3049,10 +3070,11 @@ static void mail_to_uri_cb (GtkAction *action, TextView *textview)
if (folder_item->prefs && folder_item->prefs->enable_default_account)
account = account_find_from_id(folder_item->prefs->default_account);
- compose_new_with_folderitem(account, folder_item, uri->uri+7);
+ compose = compose_new_with_folderitem(account, folder_item, uri->uri+7);
} else {
- compose_new(account, uri->uri + 7, NULL);
+ compose = compose_new(account, uri->uri + 7, NULL);
}
+ compose_check_for_email_account(compose);
}
static void copy_mail_to_uri_cb (GtkAction *action, TextView *textview)