2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2001-2006 Hiroyuki Yamamoto and the Sylpheed-Claws team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 * General functions for accessing address book files.
31 #include <glib/gi18n.h>
39 #include "mainwindow.h"
40 #include "summaryview.h"
45 #include "prefs_gtk.h"
47 #include "stock_pixmap.h"
48 #include "manage_window.h"
54 #include "prefs_actions.h"
55 #include "prefs_common.h"
56 #include "prefs_toolbar.h"
57 #include "alertpanel.h"
60 #define TOOLBAR_TAG_INDEX "toolbar"
61 #define TOOLBAR_TAG_ITEM "item"
62 #define TOOLBAR_TAG_SEPARATOR "separator"
64 #define TOOLBAR_ICON_FILE "file"
65 #define TOOLBAR_ICON_TEXT "text"
66 #define TOOLBAR_ICON_ACTION "action"
68 gboolean toolbar_is_duplicate (gint action,
70 static void toolbar_parse_item (XMLFile *file,
73 static gint toolbar_ret_val_from_text (const gchar *text);
74 static gchar *toolbar_ret_text_from_val (gint val);
76 static void toolbar_set_default_main (void);
77 static void toolbar_set_default_compose (void);
78 static void toolbar_set_default_msgview (void);
80 static void toolbar_style (ToolbarType type,
84 static MainWindow *get_mainwin (gpointer data);
85 static void activate_compose_button (Toolbar *toolbar,
87 ComposeButtonType type);
89 /* toolbar callbacks */
90 static void toolbar_reply (gpointer data,
92 static void toolbar_delete_cb (GtkWidget *widget,
94 static void toolbar_trash_cb (GtkWidget *widget,
97 static void toolbar_compose_cb (GtkWidget *widget,
100 static void toolbar_learn_cb (GtkWidget *widget,
103 static void toolbar_reply_cb (GtkWidget *widget,
106 static void toolbar_reply_to_all_cb (GtkWidget *widget,
109 static void toolbar_reply_to_list_cb (GtkWidget *widget,
112 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
115 static void toolbar_forward_cb (GtkWidget *widget,
118 static void toolbar_prev_unread_cb (GtkWidget *widget,
120 static void toolbar_next_unread_cb (GtkWidget *widget,
123 static void toolbar_ignore_thread_cb (GtkWidget *widget,
126 static void toolbar_print_cb (GtkWidget *widget,
129 static void toolbar_actions_execute_cb (GtkWidget *widget,
133 static void toolbar_send_cb (GtkWidget *widget,
135 static void toolbar_send_later_cb (GtkWidget *widget,
137 static void toolbar_draft_cb (GtkWidget *widget,
139 static void toolbar_insert_cb (GtkWidget *widget,
141 static void toolbar_attach_cb (GtkWidget *widget,
143 static void toolbar_sig_cb (GtkWidget *widget,
145 static void toolbar_ext_editor_cb (GtkWidget *widget,
147 static void toolbar_linewrap_current_cb (GtkWidget *widget,
149 static void toolbar_linewrap_all_cb (GtkWidget *widget,
151 static void toolbar_addrbook_cb (GtkWidget *widget,
154 static void toolbar_check_spelling_cb (GtkWidget *widget,
161 } toolbar_text [] = {
162 { "A_RECEIVE_ALL", N_("Receive Mail on all Accounts") },
163 { "A_RECEIVE_CUR", N_("Receive Mail on current Account") },
164 { "A_SEND_QUEUED", N_("Send Queued Messages") },
165 { "A_COMPOSE_EMAIL", N_("Compose Email") },
166 { "A_COMPOSE_NEWS", N_("Compose News") },
167 { "A_REPLY_MESSAGE", N_("Reply to Message") },
168 { "A_REPLY_SENDER", N_("Reply to Sender") },
169 { "A_REPLY_ALL", N_("Reply to All") },
170 { "A_REPLY_ML", N_("Reply to Mailing-list") },
171 { "A_FORWARD", N_("Forward Message") },
172 { "A_TRASH", N_("Trash Message") },
173 { "A_DELETE_REAL", N_("Delete Message") },
174 { "A_EXECUTE", N_("Execute") },
175 { "A_GOTO_PREV", N_("Go to Previous Unread Message") },
176 { "A_GOTO_NEXT", N_("Go to Next Unread Message") },
177 { "A_IGNORE_THREAD", N_("Ignore thread") },
178 { "A_PRINT", N_("Print") },
179 { "A_LEARN_SPAM", N_("Learn Spam or Ham") },
181 { "A_SEND", N_("Send Message") },
182 { "A_SENDL", N_("Put into queue folder and send later") },
183 { "A_DRAFT", N_("Save to draft folder") },
184 { "A_INSERT", N_("Insert file") },
185 { "A_ATTACH", N_("Attach file") },
186 { "A_SIG", N_("Insert signature") },
187 { "A_EXTEDITOR", N_("Edit with external editor") },
188 { "A_LINEWRAP_CURRENT", N_("Wrap long lines of current paragraph") },
189 { "A_LINEWRAP_ALL", N_("Wrap all long lines") },
190 { "A_ADDRBOOK", N_("Address book") },
192 { "A_CHECK_SPELLING", N_("Check spelling") },
194 { "A_SYL_ACTIONS", N_("Sylpheed-Claws Actions Feature") },
195 { "A_SEPARATOR", "Separator" }
198 /* struct holds configuration files and a list of
199 * currently active toolbar items
200 * TOOLBAR_MAIN, TOOLBAR_COMPOSE and TOOLBAR_MSGVIEW
204 const gchar *conf_file;
206 } toolbar_config[3] = {
207 { "toolbar_main.xml", NULL},
208 { "toolbar_compose.xml", NULL},
209 { "toolbar_msgview.xml", NULL}
212 static GtkItemFactoryEntry reply_entries[] =
214 {N_("/Reply with _quote"), NULL, toolbar_reply, COMPOSE_REPLY_WITH_QUOTE, NULL},
215 {N_("/_Reply without quote"), NULL, toolbar_reply, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
217 static GtkItemFactoryEntry replyall_entries[] =
219 {N_("/Reply to all with _quote"), "<shift>A", toolbar_reply, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
220 {N_("/_Reply to all without quote"), "a", toolbar_reply, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
222 static GtkItemFactoryEntry replylist_entries[] =
224 {N_("/Reply to list with _quote"), NULL, toolbar_reply, COMPOSE_REPLY_TO_LIST_WITH_QUOTE, NULL},
225 {N_("/_Reply to list without quote"), NULL, toolbar_reply, COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE, NULL}
227 static GtkItemFactoryEntry replysender_entries[] =
229 {N_("/Reply to sender with _quote"), NULL, toolbar_reply, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
230 {N_("/_Reply to sender without quote"), NULL, toolbar_reply, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
232 static GtkItemFactoryEntry forward_entries[] =
234 {N_("/_Forward"), "f", toolbar_reply, COMPOSE_FORWARD_INLINE, NULL},
235 {N_("/For_ward as attachment"), "<shift>F", toolbar_reply, COMPOSE_FORWARD_AS_ATTACH, NULL},
236 {N_("/Redirec_t"), NULL, toolbar_reply, COMPOSE_REDIRECT, NULL}
240 gint toolbar_ret_val_from_descr(const gchar *descr)
244 for (i = 0; i < N_ACTION_VAL; i++) {
245 if (g_utf8_collate(gettext(toolbar_text[i].descr), descr) == 0)
252 gchar *toolbar_ret_descr_from_val(gint val)
254 g_return_val_if_fail(val >=0 && val < N_ACTION_VAL, NULL);
256 return gettext(toolbar_text[val].descr);
259 static gint toolbar_ret_val_from_text(const gchar *text)
263 for (i = 0; i < N_ACTION_VAL; i++) {
264 if (g_utf8_collate(toolbar_text[i].index_str, text) == 0)
271 static gchar *toolbar_ret_text_from_val(gint val)
273 g_return_val_if_fail(val >=0 && val < N_ACTION_VAL, NULL);
275 return toolbar_text[val].index_str;
278 gboolean toolbar_is_duplicate(gint action, ToolbarType source)
282 if ((action == A_SEPARATOR) || (action == A_SYL_ACTIONS))
285 for (cur = toolbar_config[source].item_list; cur != NULL; cur = cur->next) {
286 ToolbarItem *item = (ToolbarItem*) cur->data;
288 if (item->index == action)
294 /* depending on toolbar type this function
295 returns a list of available toolbar events being
296 displayed by prefs_toolbar
298 GList *toolbar_get_action_items(ToolbarType source)
303 if (source == TOOLBAR_MAIN) {
304 gint main_items[] = { A_RECEIVE_ALL, A_RECEIVE_CUR, A_SEND_QUEUED,
305 A_COMPOSE_EMAIL, A_REPLY_MESSAGE, A_REPLY_SENDER,
306 A_REPLY_ALL, A_REPLY_ML, A_FORWARD,
307 A_TRASH , A_DELETE_REAL, A_EXECUTE, A_GOTO_PREV,
308 A_GOTO_NEXT, A_IGNORE_THREAD, A_PRINT,
309 A_ADDRBOOK, A_LEARN_SPAM, A_SYL_ACTIONS };
311 for (i = 0; i < sizeof main_items / sizeof main_items[0]; i++) {
312 items = g_list_append(items, gettext(toolbar_text[main_items[i]].descr));
315 else if (source == TOOLBAR_COMPOSE) {
316 gint comp_items[] = { A_SEND, A_SENDL, A_DRAFT,
317 A_INSERT, A_ATTACH, A_SIG,
318 A_EXTEDITOR, A_LINEWRAP_CURRENT,
319 A_LINEWRAP_ALL, A_ADDRBOOK,
325 for (i = 0; i < sizeof comp_items / sizeof comp_items[0]; i++)
326 items = g_list_append(items, gettext(toolbar_text[comp_items[i]].descr));
328 else if (source == TOOLBAR_MSGVIEW) {
329 gint msgv_items[] = { A_COMPOSE_EMAIL, A_REPLY_MESSAGE, A_REPLY_SENDER,
330 A_REPLY_ALL, A_REPLY_ML, A_FORWARD,
331 A_TRASH, A_DELETE_REAL, A_GOTO_PREV, A_GOTO_NEXT,
332 A_ADDRBOOK, A_LEARN_SPAM, A_SYL_ACTIONS };
334 for (i = 0; i < sizeof msgv_items / sizeof msgv_items[0]; i++)
335 items = g_list_append(items, gettext(toolbar_text[msgv_items[i]].descr));
341 static void toolbar_parse_item(XMLFile *file, ToolbarType source)
345 ToolbarItem *item = NULL;
346 gboolean rewrite = FALSE;
348 attr = xml_get_current_tag_attr(file);
349 item = g_new0(ToolbarItem, 1);
351 name = ((XMLAttr *)attr->data)->name;
352 value = ((XMLAttr *)attr->data)->value;
354 if (g_utf8_collate(name, TOOLBAR_ICON_FILE) == 0)
355 item->file = g_strdup (value);
356 else if (g_utf8_collate(name, TOOLBAR_ICON_TEXT) == 0)
357 item->text = g_strdup (value);
358 else if (g_utf8_collate(name, TOOLBAR_ICON_ACTION) == 0)
359 item->index = toolbar_ret_val_from_text(value);
360 if (item->index == -1 && !strcmp(value, "A_DELETE")) {
362 item->index = A_TRASH;
364 item->file = g_strdup("trash_btn");
366 item->text = g_strdup(_("Trash"));
369 attr = g_list_next(attr);
371 if (item->index != -1) {
373 if (!toolbar_is_duplicate(item->index, source))
374 toolbar_config[source].item_list = g_slist_append(toolbar_config[source].item_list,
378 toolbar_save_config_file(source);
382 static void toolbar_set_default_main(void)
388 } default_toolbar[] = {
389 { A_RECEIVE_ALL, STOCK_PIXMAP_MAIL_RECEIVE_ALL, _("Get Mail") },
390 { A_SEPARATOR, 0, ("") },
391 { A_SEND_QUEUED, STOCK_PIXMAP_MAIL_SEND_QUEUE, _("Send") },
392 { A_COMPOSE_EMAIL, STOCK_PIXMAP_MAIL_COMPOSE,
393 (gchar*)Q_("Toolbar|Compose") },
394 { A_SEPARATOR, 0, ("") },
395 { A_REPLY_MESSAGE, STOCK_PIXMAP_MAIL_REPLY, _("Reply") },
396 { A_REPLY_ALL, STOCK_PIXMAP_MAIL_REPLY_TO_ALL, _("All") },
397 { A_REPLY_SENDER, STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR, _("Sender") },
398 { A_FORWARD, STOCK_PIXMAP_MAIL_FORWARD, _("Forward") },
399 { A_SEPARATOR, 0, ("") },
400 { A_TRASH, STOCK_PIXMAP_TRASH, _("Trash") },
401 #if (defined(USE_SPAMASSASSIN_PLUGIN) || defined(USE_BOGOFILTER_PLUGIN))
402 { A_LEARN_SPAM, STOCK_PIXMAP_SPAM_BTN, _("Spam") },
404 { A_SEPARATOR, 0, ("") },
405 { A_GOTO_NEXT, STOCK_PIXMAP_DOWN_ARROW, _("Next") }
410 for (i = 0; i < sizeof(default_toolbar) / sizeof(default_toolbar[0]); i++) {
412 ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
414 if (default_toolbar[i].action != A_SEPARATOR) {
416 gchar *file = stock_pixmap_get_name((StockPixmap)default_toolbar[i].icon);
418 toolbar_item->file = g_strdup(file);
419 toolbar_item->index = default_toolbar[i].action;
420 toolbar_item->text = g_strdup(default_toolbar[i].text);
423 toolbar_item->file = g_strdup(TOOLBAR_TAG_SEPARATOR);
424 toolbar_item->index = A_SEPARATOR;
427 if (toolbar_item->index != -1) {
428 if ( !toolbar_is_duplicate(toolbar_item->index, TOOLBAR_MAIN))
429 toolbar_config[TOOLBAR_MAIN].item_list =
430 g_slist_append(toolbar_config[TOOLBAR_MAIN].item_list, toolbar_item);
435 static void toolbar_set_default_compose(void)
441 } default_toolbar[] = {
442 { A_SEND, STOCK_PIXMAP_MAIL_SEND, _("Send") },
443 { A_SENDL, STOCK_PIXMAP_MAIL_SEND_QUEUE, _("Send later") },
444 { A_DRAFT, STOCK_PIXMAP_MAIL, _("Draft") },
445 { A_SEPARATOR, 0, ("") },
446 { A_INSERT, STOCK_PIXMAP_INSERT_FILE, _("Insert") },
447 { A_ATTACH, STOCK_PIXMAP_MAIL_ATTACH, _("Attach") },
448 { A_SEPARATOR, 0, ("") },
449 { A_ADDRBOOK, STOCK_PIXMAP_ADDRESS_BOOK, _("Address") }
454 for (i = 0; i < sizeof(default_toolbar) / sizeof(default_toolbar[0]); i++) {
456 ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
458 if (default_toolbar[i].action != A_SEPARATOR) {
460 gchar *file = stock_pixmap_get_name((StockPixmap)default_toolbar[i].icon);
462 toolbar_item->file = g_strdup(file);
463 toolbar_item->index = default_toolbar[i].action;
464 toolbar_item->text = g_strdup(default_toolbar[i].text);
467 toolbar_item->file = g_strdup(TOOLBAR_TAG_SEPARATOR);
468 toolbar_item->index = A_SEPARATOR;
471 if (toolbar_item->index != -1) {
472 if ( !toolbar_is_duplicate(toolbar_item->index, TOOLBAR_COMPOSE))
473 toolbar_config[TOOLBAR_COMPOSE].item_list =
474 g_slist_append(toolbar_config[TOOLBAR_COMPOSE].item_list, toolbar_item);
479 static void toolbar_set_default_msgview(void)
485 } default_toolbar[] = {
486 { A_REPLY_MESSAGE, STOCK_PIXMAP_MAIL_REPLY, _("Reply") },
487 { A_REPLY_ALL, STOCK_PIXMAP_MAIL_REPLY_TO_ALL, _("All") },
488 { A_REPLY_SENDER, STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR, _("Sender") },
489 { A_FORWARD, STOCK_PIXMAP_MAIL_FORWARD, _("Forward") },
490 { A_SEPARATOR, 0, ("") },
491 { A_TRASH, STOCK_PIXMAP_TRASH, _("Trash") },
492 #if (defined(USE_SPAMASSASSIN_PLUGIN) || defined(USE_BOGOFILTER_PLUGIN))
493 { A_LEARN_SPAM, STOCK_PIXMAP_SPAM_BTN, _("Spam") },
495 { A_GOTO_NEXT, STOCK_PIXMAP_DOWN_ARROW, _("Next") }
500 for (i = 0; i < sizeof(default_toolbar) / sizeof(default_toolbar[0]); i++) {
502 ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
504 if (default_toolbar[i].action != A_SEPARATOR) {
506 gchar *file = stock_pixmap_get_name((StockPixmap)default_toolbar[i].icon);
508 toolbar_item->file = g_strdup(file);
509 toolbar_item->index = default_toolbar[i].action;
510 toolbar_item->text = g_strdup(default_toolbar[i].text);
513 toolbar_item->file = g_strdup(TOOLBAR_TAG_SEPARATOR);
514 toolbar_item->index = A_SEPARATOR;
517 if (toolbar_item->index != -1) {
518 if ( !toolbar_is_duplicate(toolbar_item->index, TOOLBAR_MSGVIEW))
519 toolbar_config[TOOLBAR_MSGVIEW].item_list =
520 g_slist_append(toolbar_config[TOOLBAR_MSGVIEW].item_list, toolbar_item);
525 void toolbar_set_default(ToolbarType source)
527 if (source == TOOLBAR_MAIN)
528 toolbar_set_default_main();
529 else if (source == TOOLBAR_COMPOSE)
530 toolbar_set_default_compose();
531 else if (source == TOOLBAR_MSGVIEW)
532 toolbar_set_default_msgview();
535 void toolbar_save_config_file(ToolbarType source)
540 gchar *fileSpec = NULL;
542 debug_print("save Toolbar Configuration to %s\n", toolbar_config[source].conf_file);
544 fileSpec = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, toolbar_config[source].conf_file, NULL );
545 pfile = prefs_write_open(fileSpec);
549 fprintf(fp, "<?xml version=\"1.0\" encoding=\"%s\" ?>\n", CS_INTERNAL);
551 fprintf(fp, "<%s>\n", TOOLBAR_TAG_INDEX);
553 for (cur = toolbar_config[source].item_list; cur != NULL; cur = cur->next) {
554 ToolbarItem *toolbar_item = (ToolbarItem*) cur->data;
556 if (toolbar_item->index != A_SEPARATOR) {
557 fprintf(fp, "\t<%s %s=\"%s\" %s=\"",
559 TOOLBAR_ICON_FILE, toolbar_item->file,
561 xml_file_put_escape_str(fp, toolbar_item->text);
562 fprintf(fp, "\" %s=\"%s\"/>\n",
564 toolbar_ret_text_from_val(toolbar_item->index));
566 fprintf(fp, "\t<%s/>\n", TOOLBAR_TAG_SEPARATOR);
570 fprintf(fp, "</%s>\n", TOOLBAR_TAG_INDEX);
572 if (prefs_file_close (pfile) < 0 )
573 g_warning("failed to write toolbar configuration to file\n");
575 g_warning("failed to open toolbar configuration file for writing\n");
578 void toolbar_read_config_file(ToolbarType source)
580 XMLFile *file = NULL;
581 gchar *fileSpec = NULL;
586 debug_print("read Toolbar Configuration from %s\n", toolbar_config[source].conf_file);
588 fileSpec = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, toolbar_config[source].conf_file, NULL );
589 file = xml_open_file(fileSpec);
592 toolbar_clear_list(source);
596 || (xml_get_dtd(file))
597 || (xml_parse_next_tag(file))
598 || (!xml_compare_tag(file, TOOLBAR_TAG_INDEX))) {
599 xml_close_file(file);
603 attr = xml_get_current_tag_attr(file);
610 if (xml_parse_next_tag(file))
613 /* Get next tag (icon, icon_text or icon_action) */
614 if (xml_compare_tag(file, TOOLBAR_TAG_ITEM)) {
615 toolbar_parse_item(file, source);
616 } else if (xml_compare_tag(file, TOOLBAR_TAG_SEPARATOR)) {
617 ToolbarItem *item = g_new0(ToolbarItem, 1);
619 item->file = g_strdup(toolbar_ret_descr_from_val(A_SEPARATOR));
620 item->index = A_SEPARATOR;
621 toolbar_config[source].item_list =
622 g_slist_append(toolbar_config[source].item_list, item);
626 xml_close_file(file);
629 if ((!file) || (g_slist_length(toolbar_config[source].item_list) == 0)) {
631 if (source == TOOLBAR_MAIN)
632 toolbar_set_default(TOOLBAR_MAIN);
633 else if (source == TOOLBAR_COMPOSE)
634 toolbar_set_default(TOOLBAR_COMPOSE);
635 else if (source == TOOLBAR_MSGVIEW)
636 toolbar_set_default(TOOLBAR_MSGVIEW);
638 g_warning("failed to write Toolbar Configuration to %s\n", toolbar_config[source].conf_file);
642 toolbar_save_config_file(source);
647 * clears list of toolbar items read from configuration files
649 void toolbar_clear_list(ToolbarType source)
651 while (toolbar_config[source].item_list != NULL) {
652 ToolbarItem *item = (ToolbarItem*) toolbar_config[source].item_list->data;
654 toolbar_config[source].item_list =
655 g_slist_remove(toolbar_config[source].item_list, item);
661 g_slist_free(toolbar_config[source].item_list);
666 * return list of Toolbar items
668 GSList *toolbar_get_list(ToolbarType source)
672 if ((source == TOOLBAR_MAIN) || (source == TOOLBAR_COMPOSE) || (source == TOOLBAR_MSGVIEW))
673 list = toolbar_config[source].item_list;
678 void toolbar_set_list_item(ToolbarItem *t_item, ToolbarType source)
680 ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
682 toolbar_item->file = g_strdup(t_item->file);
683 toolbar_item->text = g_strdup(t_item->text);
684 toolbar_item->index = t_item->index;
686 toolbar_config[source].item_list =
687 g_slist_append(toolbar_config[source].item_list,
691 void toolbar_action_execute(GtkWidget *widget,
697 gchar *action, *action_p;
698 gboolean found = FALSE;
701 for (cur = action_list; cur != NULL; cur = cur->next) {
702 ToolbarSylpheedActions *act = (ToolbarSylpheedActions*)cur->data;
704 if (widget == act->widget) {
706 for (lop = prefs_common.actions_list; lop != NULL; lop = lop->next) {
707 action = g_strdup((gchar*)lop->data);
709 action_p = strstr(action, ": ");
711 if (g_utf8_collate(act->name, action) == 0) {
725 actions_execute(data, i, widget, source);
727 g_warning ("Error: did not find Sylpheed Action to execute");
730 static void activate_compose_button (Toolbar *toolbar,
732 ComposeButtonType type)
734 if ((!toolbar->compose_mail_btn) || (!toolbar->compose_news_btn))
737 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? toolbar->compose_mail_btn
738 : toolbar->compose_news_btn);
739 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? toolbar->compose_news_btn
740 : toolbar->compose_mail_btn);
741 toolbar->compose_btn_type = type;
744 void toolbar_set_compose_button(Toolbar *toolbar,
745 ComposeButtonType compose_btn_type)
747 if (toolbar->compose_btn_type != compose_btn_type)
748 activate_compose_button(toolbar,
749 prefs_common.toolbar_style,
753 static void activate_learn_button (Toolbar *toolbar,
755 LearnButtonType type)
757 if ((!toolbar->learn_spam_btn) || (!toolbar->learn_ham_btn))
760 gtk_widget_hide(type == LEARN_SPAM ? toolbar->learn_ham_btn
761 : toolbar->learn_spam_btn);
762 gtk_widget_show(type == LEARN_SPAM ? toolbar->learn_spam_btn
763 : toolbar->learn_ham_btn);
764 toolbar->learn_btn_type = type;
767 void toolbar_set_learn_button(Toolbar *toolbar,
768 LearnButtonType learn_btn_type)
770 if (toolbar->learn_btn_type != learn_btn_type)
771 activate_learn_button(toolbar,
772 prefs_common.toolbar_style,
776 void toolbar_toggle(guint action, gpointer data)
778 MainWindow *mainwin = (MainWindow*)data;
782 g_return_if_fail(mainwin != NULL);
784 toolbar_style(TOOLBAR_MAIN, action, mainwin);
786 list = compose_get_compose_list();
787 for (cur = list; cur != NULL; cur = cur->next) {
788 toolbar_style(TOOLBAR_COMPOSE, action, cur->data);
790 list = messageview_get_msgview_list();
791 for (cur = list; cur != NULL; cur = cur->next) {
792 toolbar_style(TOOLBAR_MSGVIEW, action, cur->data);
797 void toolbar_set_style(GtkWidget *toolbar_wid, GtkWidget *handlebox_wid, guint action)
799 switch ((ToolbarStyle)action) {
801 gtk_widget_hide(handlebox_wid);
804 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
808 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
812 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
815 case TOOLBAR_BOTH_HORIZ:
816 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
817 GTK_TOOLBAR_BOTH_HORIZ);
823 prefs_common.toolbar_style = (ToolbarStyle)action;
824 gtk_widget_set_size_request(handlebox_wid, 1, -1);
826 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
827 gtk_widget_show(handlebox_wid);
828 gtk_widget_queue_resize(handlebox_wid);
832 * Change the style of toolbar
834 static void toolbar_style(ToolbarType type, guint action, gpointer data)
836 GtkWidget *handlebox_wid;
837 GtkWidget *toolbar_wid;
838 MainWindow *mainwin = (MainWindow*)data;
839 Compose *compose = (Compose*)data;
840 MessageView *msgview = (MessageView*)data;
842 g_return_if_fail(data != NULL);
846 handlebox_wid = mainwin->handlebox;
847 toolbar_wid = mainwin->toolbar->toolbar;
849 case TOOLBAR_COMPOSE:
850 handlebox_wid = compose->handlebox;
851 toolbar_wid = compose->toolbar->toolbar;
853 case TOOLBAR_MSGVIEW:
854 handlebox_wid = msgview->handlebox;
855 toolbar_wid = msgview->toolbar->toolbar;
861 toolbar_set_style(toolbar_wid, handlebox_wid, action);
864 /* Toolbar handling */
865 static void toolbar_inc_cb(GtkWidget *widget,
868 ToolbarItem *toolbar_item = (ToolbarItem*)data;
871 g_return_if_fail(toolbar_item != NULL);
873 switch (toolbar_item->type) {
875 mainwin = (MainWindow*)toolbar_item->parent;
876 inc_mail_cb(mainwin, 0, NULL);
883 static void toolbar_inc_all_cb(GtkWidget *widget,
886 ToolbarItem *toolbar_item = (ToolbarItem*)data;
889 g_return_if_fail(toolbar_item != NULL);
891 switch (toolbar_item->type) {
893 mainwin = (MainWindow*)toolbar_item->parent;
894 inc_all_account_mail_cb(mainwin, 0, NULL);
901 static void toolbar_send_queued_cb(GtkWidget *widget,gpointer data)
903 ToolbarItem *toolbar_item = (ToolbarItem*)data;
906 g_return_if_fail(toolbar_item != NULL);
908 switch (toolbar_item->type) {
910 mainwin = (MainWindow*)toolbar_item->parent;
911 send_queue_cb(mainwin, 0, NULL);
918 static void toolbar_exec_cb(GtkWidget *widget,
921 MainWindow *mainwin = get_mainwin(data);
923 g_return_if_fail(mainwin != NULL);
924 summary_execute(mainwin->summaryview);
928 * Delete current/selected(s) message(s)
930 static void toolbar_trash_cb(GtkWidget *widget, gpointer data)
932 ToolbarItem *toolbar_item = (ToolbarItem*)data;
935 g_return_if_fail(toolbar_item != NULL);
936 g_return_if_fail(toolbar_item->parent);
938 switch (toolbar_item->type) {
939 case TOOLBAR_MSGVIEW:
940 messageview_delete((MessageView *)toolbar_item->parent);
943 mainwin = (MainWindow *)toolbar_item->parent;
944 summary_delete_trash(mainwin->summaryview);
947 debug_print("toolbar event not supported\n");
953 * Delete current/selected(s) message(s)
955 static void toolbar_delete_cb(GtkWidget *widget, gpointer data)
957 ToolbarItem *toolbar_item = (ToolbarItem*)data;
960 g_return_if_fail(toolbar_item != NULL);
961 g_return_if_fail(toolbar_item->parent);
963 switch (toolbar_item->type) {
964 case TOOLBAR_MSGVIEW:
965 messageview_delete((MessageView *)toolbar_item->parent);
968 mainwin = (MainWindow *)toolbar_item->parent;
969 summary_delete(mainwin->summaryview);
972 debug_print("toolbar event not supported\n");
979 * Compose new message
981 static void toolbar_compose_cb(GtkWidget *widget, gpointer data)
983 ToolbarItem *toolbar_item = (ToolbarItem*)data;
985 MessageView *msgview;
987 g_return_if_fail(toolbar_item != NULL);
989 switch (toolbar_item->type) {
991 mainwin = (MainWindow*)toolbar_item->parent;
992 if (mainwin->toolbar->compose_btn_type == COMPOSEBUTTON_NEWS)
993 compose_news_cb(mainwin, 0, NULL);
995 compose_mail_cb(mainwin, 0, NULL);
997 case TOOLBAR_MSGVIEW:
998 msgview = (MessageView*)toolbar_item->parent;
999 compose_new_with_folderitem(NULL,
1000 msgview->msginfo->folder, NULL);
1003 debug_print("toolbar event not supported\n");
1007 static void toolbar_learn_cb(GtkWidget *widget, gpointer data)
1009 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1010 MainWindow *mainwin;
1011 MessageView *msgview;
1013 g_return_if_fail(toolbar_item != NULL);
1015 switch (toolbar_item->type) {
1017 mainwin = (MainWindow*)toolbar_item->parent;
1018 if (mainwin->toolbar->learn_btn_type == LEARN_SPAM)
1019 mainwindow_learn(mainwin, TRUE);
1021 mainwindow_learn(mainwin, FALSE);
1023 case TOOLBAR_MSGVIEW:
1024 msgview = (MessageView*)toolbar_item->parent;
1025 if (msgview->toolbar->learn_btn_type == LEARN_SPAM)
1026 messageview_learn(msgview, TRUE);
1028 messageview_learn(msgview, FALSE);
1031 debug_print("toolbar event not supported\n");
1039 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
1041 toolbar_reply(data, prefs_common.reply_with_quote ?
1042 COMPOSE_REPLY_WITH_QUOTE : COMPOSE_REPLY_WITHOUT_QUOTE);
1047 * Reply message to Sender and All recipients
1049 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
1052 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
1053 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE);
1058 * Reply to Mailing List
1060 static void toolbar_reply_to_list_cb(GtkWidget *widget, gpointer data)
1063 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_LIST_WITH_QUOTE
1064 : COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE);
1069 * Reply to sender of message
1071 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
1074 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
1075 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE);
1081 static void toolbar_addrbook_cb(GtkWidget *widget, gpointer data)
1083 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1086 g_return_if_fail(toolbar_item != NULL);
1088 switch (toolbar_item->type) {
1090 case TOOLBAR_MSGVIEW:
1093 case TOOLBAR_COMPOSE:
1094 compose = (Compose *)toolbar_item->parent;
1099 addressbook_open(compose);
1104 * Forward current/selected(s) message(s)
1106 static void toolbar_forward_cb(GtkWidget *widget, gpointer data)
1108 toolbar_reply(data, COMPOSE_FORWARD);
1112 * Goto Prev Unread Message
1114 static void toolbar_prev_unread_cb(GtkWidget *widget, gpointer data)
1116 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1117 MainWindow *mainwin;
1118 MessageView *msgview;
1120 g_return_if_fail(toolbar_item != NULL);
1122 switch (toolbar_item->type) {
1124 mainwin = (MainWindow*)toolbar_item->parent;
1125 summary_select_prev_unread(mainwin->summaryview);
1128 case TOOLBAR_MSGVIEW:
1129 msgview = (MessageView*)toolbar_item->parent;
1130 msgview->updating = TRUE;
1131 summary_select_prev_unread(msgview->mainwin->summaryview);
1132 msgview->updating = FALSE;
1134 if (msgview->deferred_destroy) {
1135 debug_print("messageview got away!\n");
1136 messageview_destroy(msgview);
1140 /* Now we need to update the messageview window */
1141 if (msgview->mainwin->summaryview->selected) {
1142 MsgInfo * msginfo = summary_get_selected_msg(msgview->mainwin->summaryview);
1145 messageview_show(msgview, msginfo,
1146 msgview->all_headers);
1148 gtk_widget_destroy(msgview->window);
1152 debug_print("toolbar event not supported\n");
1157 * Goto Next Unread Message
1159 static void toolbar_next_unread_cb(GtkWidget *widget, gpointer data)
1161 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1162 MainWindow *mainwin;
1163 MessageView *msgview;
1165 g_return_if_fail(toolbar_item != NULL);
1167 switch (toolbar_item->type) {
1169 mainwin = (MainWindow*)toolbar_item->parent;
1170 summary_select_next_unread(mainwin->summaryview);
1173 case TOOLBAR_MSGVIEW:
1174 msgview = (MessageView*)toolbar_item->parent;
1175 msgview->updating = TRUE;
1176 summary_select_next_unread(msgview->mainwin->summaryview);
1177 msgview->updating = FALSE;
1179 if (msgview->deferred_destroy) {
1180 debug_print("messageview got away!\n");
1181 messageview_destroy(msgview);
1185 /* Now we need to update the messageview window */
1186 if (msgview->mainwin->summaryview->selected) {
1187 MsgInfo * msginfo = summary_get_selected_msg(msgview->mainwin->summaryview);
1190 messageview_show(msgview, msginfo,
1191 msgview->all_headers);
1193 gtk_widget_destroy(msgview->window);
1197 debug_print("toolbar event not supported\n");
1201 static void toolbar_ignore_thread_cb(GtkWidget *widget, gpointer data)
1203 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1204 MainWindow *mainwin;
1206 g_return_if_fail(toolbar_item != NULL);
1208 switch (toolbar_item->type) {
1210 mainwin = (MainWindow *) toolbar_item->parent;
1211 summary_toggle_ignore_thread(mainwin->summaryview);
1213 case TOOLBAR_MSGVIEW:
1214 /* TODO: see toolbar_next_unread_cb() if you need
1215 * this in the message view */
1218 debug_print("toolbar event not supported\n");
1223 static void toolbar_print_cb(GtkWidget *widget, gpointer data)
1225 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1226 MainWindow *mainwin;
1228 g_return_if_fail(toolbar_item != NULL);
1230 switch (toolbar_item->type) {
1232 mainwin = (MainWindow *) toolbar_item->parent;
1233 summary_print(mainwin->summaryview);
1235 case TOOLBAR_MSGVIEW:
1236 /* TODO: see toolbar_next_unread_cb() if you need
1237 * this in the message view */
1240 debug_print("toolbar event not supported\n");
1245 static void toolbar_send_cb(GtkWidget *widget, gpointer data)
1247 compose_toolbar_cb(A_SEND, data);
1250 static void toolbar_send_later_cb(GtkWidget *widget, gpointer data)
1252 compose_toolbar_cb(A_SENDL, data);
1255 static void toolbar_draft_cb(GtkWidget *widget, gpointer data)
1257 compose_toolbar_cb(A_DRAFT, data);
1260 static void toolbar_insert_cb(GtkWidget *widget, gpointer data)
1262 compose_toolbar_cb(A_INSERT, data);
1265 static void toolbar_attach_cb(GtkWidget *widget, gpointer data)
1267 compose_toolbar_cb(A_ATTACH, data);
1270 static void toolbar_sig_cb(GtkWidget *widget, gpointer data)
1272 compose_toolbar_cb(A_SIG, data);
1275 static void toolbar_ext_editor_cb(GtkWidget *widget, gpointer data)
1277 compose_toolbar_cb(A_EXTEDITOR, data);
1280 static void toolbar_linewrap_current_cb(GtkWidget *widget, gpointer data)
1282 compose_toolbar_cb(A_LINEWRAP_CURRENT, data);
1285 static void toolbar_linewrap_all_cb(GtkWidget *widget, gpointer data)
1287 compose_toolbar_cb(A_LINEWRAP_ALL, data);
1291 static void toolbar_check_spelling_cb(GtkWidget *widget, gpointer data)
1293 compose_toolbar_cb(A_CHECK_SPELLING, data);
1297 * Execute actions from toolbar
1299 static void toolbar_actions_execute_cb(GtkWidget *widget, gpointer data)
1301 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1302 GSList *action_list;
1303 MainWindow *mainwin;
1305 MessageView *msgview;
1306 gpointer parent = toolbar_item->parent;
1308 g_return_if_fail(toolbar_item != NULL);
1310 switch (toolbar_item->type) {
1312 mainwin = (MainWindow*)parent;
1313 action_list = mainwin->toolbar->action_list;
1315 case TOOLBAR_COMPOSE:
1316 compose = (Compose*)parent;
1317 action_list = compose->toolbar->action_list;
1319 case TOOLBAR_MSGVIEW:
1320 msgview = (MessageView*)parent;
1321 action_list = msgview->toolbar->action_list;
1324 debug_print("toolbar event not supported\n");
1327 toolbar_action_execute(widget, action_list, parent, toolbar_item->type);
1330 static MainWindow *get_mainwin(gpointer data)
1332 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1333 MainWindow *mainwin = NULL;
1334 MessageView *msgview;
1336 g_return_val_if_fail(toolbar_item != NULL, NULL);
1338 switch(toolbar_item->type) {
1340 mainwin = (MainWindow*)toolbar_item->parent;
1342 case TOOLBAR_MSGVIEW:
1343 msgview = (MessageView*)toolbar_item->parent;
1344 mainwin = (MainWindow*)msgview->mainwin;
1353 static void toolbar_buttons_cb(GtkWidget *widget,
1360 void (*func)(GtkWidget *widget, gpointer data);
1362 { A_RECEIVE_ALL, toolbar_inc_all_cb },
1363 { A_RECEIVE_CUR, toolbar_inc_cb },
1364 { A_SEND_QUEUED, toolbar_send_queued_cb },
1365 { A_COMPOSE_EMAIL, toolbar_compose_cb },
1366 { A_COMPOSE_NEWS, toolbar_compose_cb },
1367 { A_REPLY_MESSAGE, toolbar_reply_cb },
1368 { A_REPLY_SENDER, toolbar_reply_to_sender_cb },
1369 { A_REPLY_ALL, toolbar_reply_to_all_cb },
1370 { A_REPLY_ML, toolbar_reply_to_list_cb },
1371 { A_FORWARD, toolbar_forward_cb },
1372 { A_TRASH, toolbar_trash_cb },
1373 { A_DELETE_REAL, toolbar_delete_cb },
1374 { A_EXECUTE, toolbar_exec_cb },
1375 { A_GOTO_PREV, toolbar_prev_unread_cb },
1376 { A_GOTO_NEXT, toolbar_next_unread_cb },
1377 { A_IGNORE_THREAD, toolbar_ignore_thread_cb },
1378 { A_PRINT, toolbar_print_cb },
1379 { A_LEARN_SPAM, toolbar_learn_cb },
1381 { A_SEND, toolbar_send_cb },
1382 { A_SENDL, toolbar_send_later_cb },
1383 { A_DRAFT, toolbar_draft_cb },
1384 { A_INSERT, toolbar_insert_cb },
1385 { A_ATTACH, toolbar_attach_cb },
1386 { A_SIG, toolbar_sig_cb },
1387 { A_EXTEDITOR, toolbar_ext_editor_cb },
1388 { A_LINEWRAP_CURRENT, toolbar_linewrap_current_cb },
1389 { A_LINEWRAP_ALL, toolbar_linewrap_all_cb },
1390 { A_ADDRBOOK, toolbar_addrbook_cb },
1392 { A_CHECK_SPELLING, toolbar_check_spelling_cb },
1394 { A_SYL_ACTIONS, toolbar_actions_execute_cb }
1397 num_items = sizeof(callbacks)/sizeof(callbacks[0]);
1399 for (i = 0; i < num_items; i++) {
1400 if (callbacks[i].index == item->index) {
1401 callbacks[i].func(widget, item);
1408 * Create a new toolbar with specified type
1409 * if a callback list is passed it will be used before the
1410 * common callback list
1412 Toolbar *toolbar_create(ToolbarType type,
1413 GtkWidget *container,
1416 ToolbarItem *toolbar_item;
1419 GtkWidget *icon_wid = NULL;
1420 GtkWidget *icon_news;
1421 GtkWidget *icon_ham;
1423 GtkWidget *item_news;
1424 GtkWidget *item_ham;
1425 guint n_menu_entries;
1426 ComboButton *getall_combo;
1427 ComboButton *reply_combo;
1428 ComboButton *replyall_combo;
1429 ComboButton *replylist_combo;
1430 ComboButton *replysender_combo;
1431 ComboButton *fwd_combo;
1432 ComboButton *compose_combo;
1434 GtkTooltips *toolbar_tips;
1435 ToolbarSylpheedActions *action_item;
1437 GSList *toolbar_list;
1438 Toolbar *toolbar_data;
1441 toolbar_tips = gtk_tooltips_new();
1443 toolbar_read_config_file(type);
1444 toolbar_list = toolbar_get_list(type);
1446 toolbar_data = g_new0(Toolbar, 1);
1448 toolbar = gtk_toolbar_new();
1449 gtk_container_add(GTK_CONTAINER(container), toolbar);
1450 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1451 gtk_toolbar_set_orientation(GTK_TOOLBAR(toolbar), GTK_ORIENTATION_HORIZONTAL);
1452 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_BOTH);
1454 for (cur = toolbar_list; cur != NULL; cur = cur->next) {
1456 if (g_ascii_strcasecmp(((ToolbarItem*)cur->data)->file, TOOLBAR_TAG_SEPARATOR) == 0) {
1457 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1461 toolbar_item = g_new0(ToolbarItem, 1);
1462 toolbar_item->index = ((ToolbarItem*)cur->data)->index;
1463 toolbar_item->file = g_strdup(((ToolbarItem*)cur->data)->file);
1464 toolbar_item->text = g_strdup(((ToolbarItem*)cur->data)->text);
1465 toolbar_item->parent = data;
1466 toolbar_item->type = type;
1468 /* collect toolbar items in list to keep track */
1469 toolbar_data->item_list =
1470 g_slist_append(toolbar_data->item_list,
1472 icon_wid = stock_pixmap_widget(container, stock_pixmap_get_icon(toolbar_item->file));
1473 item = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1477 icon_wid, G_CALLBACK(toolbar_buttons_cb),
1480 switch (toolbar_item->index) {
1483 toolbar_data->getall_btn = item;
1484 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1485 toolbar_data->getall_btn,
1486 _("Receive Mail on all Accounts"), NULL);
1487 getall_combo = gtkut_combo_button_create(toolbar_data->getall_btn, NULL, 0,
1488 "<GetAll>", (gpointer)toolbar_item);
1489 gtk_button_set_relief(GTK_BUTTON(getall_combo->arrow),
1491 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar),
1492 GTK_WIDGET_PTR(getall_combo),
1493 _("Receive Mail on selected Account"), "Reply");
1494 toolbar_data->getall_combo = getall_combo;
1497 toolbar_data->get_btn = item;
1498 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1499 toolbar_data->get_btn,
1500 _("Receive Mail on current Account"), NULL);
1503 toolbar_data->send_btn = item;
1504 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1505 toolbar_data->send_btn,
1506 _("Send Queued Messages"), NULL);
1508 case A_COMPOSE_EMAIL:
1509 icon_news = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
1510 item_news = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1514 icon_news, G_CALLBACK(toolbar_buttons_cb),
1516 toolbar_data->compose_mail_btn = item;
1517 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1518 toolbar_data->compose_mail_btn,
1519 _("Compose Email"), NULL);
1520 toolbar_data->compose_news_btn = item_news;
1521 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1522 toolbar_data->compose_news_btn,
1523 _("Compose News"), NULL);
1524 compose_combo = gtkut_combo_button_create(toolbar_data->compose_mail_btn, NULL, 0,
1525 "<Compose>", (gpointer)toolbar_item);
1526 gtk_button_set_relief(GTK_BUTTON(compose_combo->arrow),
1528 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar),
1529 GTK_WIDGET_PTR(compose_combo),
1530 _("Compose with selected Account"), "Compose");
1531 toolbar_data->compose_combo = compose_combo;
1534 icon_ham = stock_pixmap_widget(container, STOCK_PIXMAP_HAM_BTN);
1535 item_ham = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1539 icon_ham, G_CALLBACK(toolbar_buttons_cb),
1541 toolbar_data->learn_spam_btn = item;
1542 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1543 toolbar_data->learn_spam_btn,
1544 _("Learn Spam"), NULL);
1545 toolbar_data->learn_ham_btn = item_ham;
1546 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1547 toolbar_data->learn_ham_btn,
1548 _("Learn Ham"), NULL);
1550 case A_REPLY_MESSAGE:
1551 toolbar_data->reply_btn = item;
1552 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1553 toolbar_data->reply_btn,
1554 _("Reply to Message"), NULL);
1555 n_menu_entries = sizeof(reply_entries) /
1556 sizeof(reply_entries[0]);
1557 reply_combo = gtkut_combo_button_create(toolbar_data->reply_btn,
1558 reply_entries, n_menu_entries,
1559 "<Reply>", (gpointer)toolbar_item);
1560 gtk_button_set_relief(GTK_BUTTON(reply_combo->arrow),
1562 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar),
1563 GTK_WIDGET_PTR(reply_combo),
1564 _("Reply to Message"), "Reply");
1565 toolbar_data->reply_combo = reply_combo;
1567 case A_REPLY_SENDER:
1568 toolbar_data->replysender_btn = item;
1569 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1570 toolbar_data->replysender_btn,
1571 _("Reply to Sender"), NULL);
1572 n_menu_entries = sizeof(replysender_entries) /
1573 sizeof(replysender_entries[0]);
1574 replysender_combo = gtkut_combo_button_create(toolbar_data->replysender_btn,
1575 replysender_entries, n_menu_entries,
1576 "<ReplySender>", (gpointer)toolbar_item);
1577 gtk_button_set_relief(GTK_BUTTON(replysender_combo->arrow),
1579 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar),
1580 GTK_WIDGET_PTR(replysender_combo),
1581 _("Reply to Sender"), "ReplySender");
1582 toolbar_data->replysender_combo = replysender_combo;
1585 toolbar_data->replyall_btn = item;
1586 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1587 toolbar_data->replyall_btn,
1588 _("Reply to All"), NULL);
1589 n_menu_entries = sizeof(replyall_entries) /
1590 sizeof(replyall_entries[0]);
1591 replyall_combo = gtkut_combo_button_create(toolbar_data->replyall_btn,
1592 replyall_entries, n_menu_entries,
1593 "<ReplyAll>", (gpointer)toolbar_item);
1594 gtk_button_set_relief(GTK_BUTTON(replyall_combo->arrow),
1596 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar),
1597 GTK_WIDGET_PTR(replyall_combo),
1598 _("Reply to All"), "ReplyAll");
1599 toolbar_data->replyall_combo = replyall_combo;
1602 toolbar_data->replylist_btn = item;
1603 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1604 toolbar_data->replylist_btn,
1605 _("Reply to Mailing-list"), NULL);
1606 n_menu_entries = sizeof(replylist_entries) /
1607 sizeof(replylist_entries[0]);
1608 replylist_combo = gtkut_combo_button_create(toolbar_data->replylist_btn,
1609 replylist_entries, n_menu_entries,
1610 "<ReplyList>", (gpointer)toolbar_item);
1611 gtk_button_set_relief(GTK_BUTTON(replylist_combo->arrow),
1613 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar),
1614 GTK_WIDGET_PTR(replylist_combo),
1615 _("Reply to Mailing-list"), "ReplyList");
1616 toolbar_data->replylist_combo = replylist_combo;
1619 toolbar_data->fwd_btn = item;
1620 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1621 toolbar_data->fwd_btn,
1622 _("Forward Message"), NULL);
1623 n_menu_entries = sizeof(forward_entries) /
1624 sizeof(forward_entries[0]);
1625 fwd_combo = gtkut_combo_button_create(toolbar_data->fwd_btn,
1626 forward_entries, n_menu_entries,
1627 "<Forward>", (gpointer)toolbar_item);
1628 gtk_button_set_relief(GTK_BUTTON(fwd_combo->arrow),
1630 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar),
1631 GTK_WIDGET_PTR(fwd_combo),
1632 _("Forward Message"), "Fwd");
1633 toolbar_data->fwd_combo = fwd_combo;
1636 toolbar_data->trash_btn = item;
1637 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1638 toolbar_data->trash_btn,
1639 _("Trash Message"), NULL);
1642 toolbar_data->delete_btn = item;
1643 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1644 toolbar_data->delete_btn,
1645 _("Delete Message"), NULL);
1648 toolbar_data->exec_btn = item;
1649 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1650 toolbar_data->exec_btn,
1651 _("Execute"), NULL);
1654 toolbar_data->prev_btn = item;
1655 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1656 toolbar_data->prev_btn,
1657 _("Go to Previous Unread Message"),
1661 toolbar_data->next_btn = item;
1662 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1663 toolbar_data->next_btn,
1664 _("Go to Next Unread Message"),
1668 /* Compose Toolbar */
1670 toolbar_data->send_btn = item;
1671 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1672 toolbar_data->send_btn,
1673 _("Send Message"), NULL);
1676 toolbar_data->sendl_btn = item;
1677 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1678 toolbar_data->sendl_btn,
1679 _("Put into queue folder and send later"), NULL);
1682 toolbar_data->draft_btn = item;
1683 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1684 toolbar_data->draft_btn,
1685 _("Save to draft folder"), NULL);
1688 toolbar_data->insert_btn = item;
1689 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1690 toolbar_data->insert_btn,
1691 _("Insert file"), NULL);
1694 toolbar_data->attach_btn = item;
1695 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1696 toolbar_data->attach_btn,
1697 _("Attach file"), NULL);
1700 toolbar_data->sig_btn = item;
1701 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1702 toolbar_data->sig_btn,
1703 _("Insert signature"), NULL);
1706 toolbar_data->exteditor_btn = item;
1707 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1708 toolbar_data->exteditor_btn,
1709 _("Edit with external editor"), NULL);
1711 case A_LINEWRAP_CURRENT:
1712 toolbar_data->linewrap_current_btn = item;
1713 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1714 toolbar_data->linewrap_current_btn,
1715 _("Wrap long lines of current paragraph"), NULL);
1717 case A_LINEWRAP_ALL:
1718 toolbar_data->linewrap_all_btn = item;
1719 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1720 toolbar_data->linewrap_all_btn,
1721 _("Wrap all long lines"), NULL);
1724 toolbar_data->addrbook_btn = item;
1725 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1726 toolbar_data->addrbook_btn,
1727 _("Address book"), NULL);
1730 case A_CHECK_SPELLING:
1731 toolbar_data->spellcheck_btn = item;
1732 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1733 toolbar_data->spellcheck_btn,
1734 _("Check spelling"), NULL);
1739 action_item = g_new0(ToolbarSylpheedActions, 1);
1740 action_item->widget = item;
1741 action_item->name = g_strdup(toolbar_item->text);
1743 toolbar_data->action_list =
1744 g_slist_append(toolbar_data->action_list,
1747 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1749 action_item->name, NULL);
1751 gtk_widget_show(item);
1754 /* find and set the tool tip text */
1755 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1757 toolbar_ret_descr_from_val
1758 (toolbar_item->index),
1764 toolbar_data->toolbar = toolbar;
1765 if (type == TOOLBAR_MAIN)
1766 activate_compose_button(toolbar_data,
1767 prefs_common.toolbar_style,
1768 toolbar_data->compose_btn_type);
1769 if (type != TOOLBAR_COMPOSE)
1770 activate_learn_button(toolbar_data, prefs_common.toolbar_style,
1773 gtk_widget_show_all(toolbar);
1775 return toolbar_data;
1779 * Free toolbar structures
1781 void toolbar_destroy(Toolbar * toolbar) {
1783 TOOLBAR_DESTROY_ITEMS(toolbar->item_list);
1784 TOOLBAR_DESTROY_ACTIONS(toolbar->action_list);
1787 void toolbar_update(ToolbarType type, gpointer data)
1789 Toolbar *toolbar_data;
1790 GtkWidget *handlebox;
1791 MainWindow *mainwin = (MainWindow*)data;
1792 Compose *compose = (Compose*)data;
1793 MessageView *msgview = (MessageView*)data;
1797 toolbar_data = mainwin->toolbar;
1798 handlebox = mainwin->handlebox;
1800 case TOOLBAR_COMPOSE:
1801 toolbar_data = compose->toolbar;
1802 handlebox = compose->handlebox;
1804 case TOOLBAR_MSGVIEW:
1805 toolbar_data = msgview->toolbar;
1806 handlebox = msgview->handlebox;
1812 gtk_container_remove(GTK_CONTAINER(handlebox),
1813 GTK_WIDGET(toolbar_data->toolbar));
1815 toolbar_init(toolbar_data);
1816 toolbar_data = toolbar_create(type, handlebox, data);
1819 mainwin->toolbar = toolbar_data;
1821 case TOOLBAR_COMPOSE:
1822 compose->toolbar = toolbar_data;
1824 case TOOLBAR_MSGVIEW:
1825 msgview->toolbar = toolbar_data;
1829 toolbar_style(type, prefs_common.toolbar_style, data);
1831 if (type == TOOLBAR_MAIN) {
1832 toolbar_main_set_sensitive((MainWindow*)data);
1833 account_set_menu_only_toolbar();
1837 #define GTK_BUTTON_SET_SENSITIVE(widget,sensitive) { \
1838 gboolean in_btn = FALSE; \
1839 if (GTK_IS_BUTTON(widget)) \
1840 in_btn = GTK_BUTTON(widget)->in_button; \
1841 gtk_widget_set_sensitive(widget, sensitive); \
1842 if (GTK_IS_BUTTON(widget)) \
1843 GTK_BUTTON(widget)->in_button = in_btn; \
1846 void toolbar_main_set_sensitive(gpointer data)
1848 SensitiveCond state;
1850 MainWindow *mainwin = (MainWindow*)data;
1851 Toolbar *toolbar = mainwin->toolbar;
1853 GSList *entry_list = NULL;
1855 typedef struct _Entry Entry;
1862 #define SET_WIDGET_COND(w, c) \
1864 Entry *e = g_new0(Entry, 1); \
1867 entry_list = g_slist_append(entry_list, e); \
1871 if (toolbar->get_btn)
1872 SET_WIDGET_COND(toolbar->get_btn,
1873 M_HAVE_ACCOUNT|M_UNLOCKED);
1875 if (toolbar->getall_btn) {
1876 SET_WIDGET_COND(toolbar->getall_btn,
1877 M_HAVE_ACCOUNT|M_UNLOCKED);
1878 SET_WIDGET_COND(GTK_WIDGET_PTR(toolbar->getall_combo),
1879 M_HAVE_ACCOUNT|M_UNLOCKED);
1881 if (toolbar->send_btn) {
1882 SET_WIDGET_COND(toolbar->send_btn,
1883 M_HAVE_QUEUED_MAILS);
1885 if (toolbar->compose_mail_btn) {
1886 SET_WIDGET_COND(GTK_WIDGET_PTR(toolbar->compose_combo),
1888 SET_WIDGET_COND(toolbar->compose_news_btn,
1891 if (toolbar->reply_btn) {
1892 SET_WIDGET_COND(toolbar->reply_btn,
1893 M_HAVE_ACCOUNT|M_TARGET_EXIST);
1894 SET_WIDGET_COND(GTK_WIDGET_PTR(toolbar->reply_combo),
1895 M_HAVE_ACCOUNT|M_TARGET_EXIST);
1897 if (toolbar->replyall_btn) {
1898 SET_WIDGET_COND(toolbar->replyall_btn,
1899 M_HAVE_ACCOUNT|M_TARGET_EXIST);
1900 SET_WIDGET_COND(GTK_WIDGET_PTR(toolbar->replyall_combo),
1901 M_HAVE_ACCOUNT|M_TARGET_EXIST);
1903 if (toolbar->replylist_btn) {
1904 SET_WIDGET_COND(toolbar->replylist_btn,
1905 M_HAVE_ACCOUNT|M_TARGET_EXIST);
1906 SET_WIDGET_COND(GTK_WIDGET_PTR(toolbar->replylist_combo),
1907 M_HAVE_ACCOUNT|M_TARGET_EXIST);
1909 if (toolbar->replysender_btn) {
1910 SET_WIDGET_COND(toolbar->replysender_btn,
1911 M_HAVE_ACCOUNT|M_TARGET_EXIST);
1912 SET_WIDGET_COND(GTK_WIDGET_PTR(toolbar->replysender_combo),
1913 M_HAVE_ACCOUNT|M_TARGET_EXIST);
1915 if (toolbar->fwd_btn) {
1916 SET_WIDGET_COND(toolbar->fwd_btn,
1917 M_HAVE_ACCOUNT|M_TARGET_EXIST);
1918 SET_WIDGET_COND(GTK_WIDGET_PTR(toolbar->fwd_combo),
1919 M_HAVE_ACCOUNT|M_TARGET_EXIST);
1921 if (toolbar->fwd_combo) {
1922 GtkWidget *submenu = gtk_item_factory_get_widget(toolbar->fwd_combo->factory, "/Redirect");
1923 SET_WIDGET_COND(submenu,
1924 M_HAVE_ACCOUNT|M_TARGET_EXIST);
1927 if (prefs_common.next_unread_msg_dialog == NEXTUNREADMSGDIALOG_ASSUME_NO) {
1928 SET_WIDGET_COND(toolbar->next_btn, M_MSG_EXIST);
1930 SET_WIDGET_COND(toolbar->next_btn, 0);
1933 if (toolbar->trash_btn)
1934 SET_WIDGET_COND(toolbar->trash_btn,
1935 M_TARGET_EXIST|M_ALLOW_DELETE);
1937 if (toolbar->delete_btn)
1938 SET_WIDGET_COND(toolbar->delete_btn,
1939 M_TARGET_EXIST|M_ALLOW_DELETE);
1941 if (toolbar->exec_btn)
1942 SET_WIDGET_COND(toolbar->exec_btn,
1945 if (toolbar->learn_ham_btn)
1946 SET_WIDGET_COND(toolbar->learn_ham_btn,
1947 M_TARGET_EXIST|M_CAN_LEARN_SPAM);
1949 if (toolbar->learn_spam_btn)
1950 SET_WIDGET_COND(toolbar->learn_spam_btn,
1951 M_TARGET_EXIST|M_CAN_LEARN_SPAM);
1953 for (cur = toolbar->action_list; cur != NULL; cur = cur->next) {
1954 ToolbarSylpheedActions *act = (ToolbarSylpheedActions*)cur->data;
1956 SET_WIDGET_COND(act->widget, M_TARGET_EXIST|M_UNLOCKED);
1959 #undef SET_WIDGET_COND
1961 state = main_window_get_current_state(mainwin);
1963 for (cur = entry_list; cur != NULL; cur = cur->next) {
1964 Entry *e = (Entry*) cur->data;
1966 if (e->widget != NULL) {
1967 sensitive = ((e->cond & state) == e->cond);
1968 GTK_BUTTON_SET_SENSITIVE(e->widget, sensitive);
1972 while (entry_list != NULL) {
1973 Entry *e = (Entry*) entry_list->data;
1976 entry_list = g_slist_remove(entry_list, e);
1979 g_slist_free(entry_list);
1981 activate_compose_button(toolbar,
1982 prefs_common.toolbar_style,
1983 toolbar->compose_btn_type);
1987 void toolbar_comp_set_sensitive(gpointer data, gboolean sensitive)
1989 Compose *compose = (Compose*)data;
1990 GSList *items = compose->toolbar->action_list;
1992 if (compose->toolbar->send_btn)
1993 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->send_btn, sensitive);
1994 if (compose->toolbar->sendl_btn)
1995 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->sendl_btn, sensitive);
1996 if (compose->toolbar->draft_btn )
1997 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->draft_btn , sensitive);
1998 if (compose->toolbar->insert_btn )
1999 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->insert_btn , sensitive);
2000 if (compose->toolbar->attach_btn)
2001 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->attach_btn, sensitive);
2002 if (compose->toolbar->sig_btn)
2003 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->sig_btn, sensitive);
2004 if (compose->toolbar->exteditor_btn)
2005 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->exteditor_btn, sensitive);
2006 if (compose->toolbar->linewrap_current_btn)
2007 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->linewrap_current_btn, sensitive);
2008 if (compose->toolbar->linewrap_all_btn)
2009 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->linewrap_all_btn, sensitive);
2010 if (compose->toolbar->addrbook_btn)
2011 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->addrbook_btn, sensitive);
2013 if (compose->toolbar->spellcheck_btn)
2014 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->spellcheck_btn, sensitive);
2016 for (; items != NULL; items = g_slist_next(items)) {
2017 ToolbarSylpheedActions *item = (ToolbarSylpheedActions *)items->data;
2018 GTK_BUTTON_SET_SENSITIVE(item->widget, sensitive);
2023 * Initialize toolbar structure
2025 void toolbar_init(Toolbar * toolbar) {
2027 toolbar->toolbar = NULL;
2028 toolbar->get_btn = NULL;
2029 toolbar->getall_btn = NULL;
2030 toolbar->getall_combo = NULL;
2031 toolbar->send_btn = NULL;
2032 toolbar->compose_mail_btn = NULL;
2033 toolbar->compose_news_btn = NULL;
2034 toolbar->compose_combo = NULL;
2035 toolbar->reply_btn = NULL;
2036 toolbar->replysender_btn = NULL;
2037 toolbar->replyall_btn = NULL;
2038 toolbar->replylist_btn = NULL;
2039 toolbar->fwd_btn = NULL;
2040 toolbar->trash_btn = NULL;
2041 toolbar->delete_btn = NULL;
2042 toolbar->prev_btn = NULL;
2043 toolbar->next_btn = NULL;
2044 toolbar->exec_btn = NULL;
2046 /* compose buttons */
2047 toolbar->sendl_btn = NULL;
2048 toolbar->draft_btn = NULL;
2049 toolbar->insert_btn = NULL;
2050 toolbar->attach_btn = NULL;
2051 toolbar->sig_btn = NULL;
2052 toolbar->exteditor_btn = NULL;
2053 toolbar->linewrap_current_btn = NULL;
2054 toolbar->linewrap_all_btn = NULL;
2055 toolbar->addrbook_btn = NULL;
2057 toolbar->spellcheck_btn = NULL;
2060 toolbar_destroy(toolbar);
2065 static void toolbar_reply(gpointer data, guint action)
2067 ToolbarItem *toolbar_item = (ToolbarItem*)data;
2068 MainWindow *mainwin;
2069 MessageView *msgview;
2070 GSList *msginfo_list = NULL;
2072 g_return_if_fail(toolbar_item != NULL);
2074 switch (toolbar_item->type) {
2076 mainwin = (MainWindow*)toolbar_item->parent;
2077 msginfo_list = summary_get_selection(mainwin->summaryview);
2078 msgview = (MessageView*)mainwin->messageview;
2080 case TOOLBAR_MSGVIEW:
2081 msgview = (MessageView*)toolbar_item->parent;
2082 g_return_if_fail(msgview != NULL);
2083 msginfo_list = g_slist_append(msginfo_list, msgview->msginfo);
2089 g_return_if_fail(msgview != NULL);
2090 g_return_if_fail(msginfo_list != NULL);
2091 compose_reply_from_messageview(msgview, msginfo_list, action);
2092 g_slist_free(msginfo_list);
2094 /* TODO: update reply state ion summaryview */
2098 /* exported functions */
2100 void inc_mail_cb(gpointer data, guint action, GtkWidget *widget)
2102 MainWindow *mainwin = (MainWindow*)data;
2104 inc_mail(mainwin, prefs_common.newmail_notify_manu);
2107 void inc_all_account_mail_cb(gpointer data, guint action, GtkWidget *widget)
2109 MainWindow *mainwin = (MainWindow*)data;
2111 inc_all_account_mail(mainwin, FALSE, prefs_common.newmail_notify_manu);
2114 void send_queue_cb(gpointer data, guint action, GtkWidget *widget)
2118 gboolean got_error = FALSE;
2119 gchar *errstr = NULL;
2121 if (prefs_common.work_offline)
2122 if (alertpanel(_("Offline warning"),
2123 _("You're working offline. Override?"),
2124 GTK_STOCK_NO, GTK_STOCK_YES,
2125 NULL) != G_ALERTALTERNATE)
2128 /* ask for confirmation before sending queued messages only
2129 in online mode and if there is at least one message queued
2130 in any of the folder queue
2132 if (prefs_common.confirm_send_queued_messages) {
2134 /* check if there's a queued message */
2135 for (list = folder_get_list(); !found && list != NULL; list = list->next) {
2136 Folder *folder = list->data;
2138 found = !procmsg_queue_is_empty(folder->queue);
2140 /* if necessary, ask for confirmation before sending */
2141 if (found && !prefs_common.work_offline) {
2142 if (alertpanel(_("Send queued messages"),
2143 _("Send all queued messages?"),
2144 GTK_STOCK_CANCEL, _("_Send"),
2145 NULL) != G_ALERTALTERNATE)
2150 for (list = folder_get_list(); list != NULL; list = list->next) {
2151 Folder *folder = list->data;
2153 if (folder->queue) {
2154 if (procmsg_send_queue(folder->queue,
2155 prefs_common.savemsg,
2162 alertpanel_error_log(_("Some errors occurred while "
2163 "sending queued messages."));
2165 gchar *tmp = g_strdup_printf(_("Some errors occurred "
2166 "while sending queued messages:\n%s"), errstr);
2168 alertpanel_error_log(tmp);
2174 void compose_mail_cb(gpointer data, guint action, GtkWidget *widget)
2176 MainWindow *mainwin = (MainWindow*)data;
2177 PrefsAccount *ac = NULL;
2178 FolderItem *item = mainwin->summaryview->folder_item;
2183 ac = account_find_from_item(item);
2184 if (ac && ac->protocol != A_NNTP) {
2185 compose_new_with_folderitem(ac, item, NULL); /* CLAWS */
2191 * CLAWS - use current account
2193 if (cur_account && (cur_account->protocol != A_NNTP)) {
2194 compose_new_with_folderitem(cur_account, item, NULL);
2199 * CLAWS - just get the first one
2201 list = account_get_list();
2202 for (cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2203 ac = (PrefsAccount *) cur->data;
2204 if (ac->protocol != A_NNTP) {
2205 compose_new_with_folderitem(ac, item, NULL);
2211 void compose_news_cb(gpointer data, guint action, GtkWidget *widget)
2213 MainWindow *mainwin = (MainWindow*)data;
2214 PrefsAccount * ac = NULL;
2218 if (mainwin->summaryview->folder_item) {
2219 ac = mainwin->summaryview->folder_item->folder->account;
2220 if (ac && ac->protocol == A_NNTP) {
2221 compose_new_with_folderitem(ac,
2222 mainwin->summaryview->folder_item, NULL);
2227 list = account_get_list();
2228 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2229 ac = (PrefsAccount *) cur->data;
2230 if (ac->protocol == A_NNTP) {
2231 compose_new_with_folderitem(ac,
2232 mainwin->summaryview->folder_item, NULL);