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);
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 GtkCTree *ctree = GTK_CTREE(msgview->mainwin->summaryview->ctree);
1144 MsgInfo * msginfo = gtk_ctree_node_get_row_data(ctree,
1145 msgview->mainwin->summaryview->selected);
1147 messageview_show(msgview, msginfo,
1148 msgview->all_headers);
1150 gtk_widget_destroy(msgview->window);
1154 debug_print("toolbar event not supported\n");
1159 * Goto Next Unread Message
1161 static void toolbar_next_unread_cb(GtkWidget *widget, gpointer data)
1163 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1164 MainWindow *mainwin;
1165 MessageView *msgview;
1167 g_return_if_fail(toolbar_item != NULL);
1169 switch (toolbar_item->type) {
1171 mainwin = (MainWindow*)toolbar_item->parent;
1172 summary_select_next_unread(mainwin->summaryview);
1175 case TOOLBAR_MSGVIEW:
1176 msgview = (MessageView*)toolbar_item->parent;
1177 msgview->updating = TRUE;
1178 summary_select_next_unread(msgview->mainwin->summaryview);
1179 msgview->updating = FALSE;
1181 if (msgview->deferred_destroy) {
1182 debug_print("messageview got away!\n");
1183 messageview_destroy(msgview);
1187 /* Now we need to update the messageview window */
1188 if (msgview->mainwin->summaryview->selected) {
1189 GtkCTree *ctree = GTK_CTREE(msgview->mainwin->summaryview->ctree);
1191 MsgInfo * msginfo = gtk_ctree_node_get_row_data(ctree,
1192 msgview->mainwin->summaryview->selected);
1194 messageview_show(msgview, msginfo,
1195 msgview->all_headers);
1197 gtk_widget_destroy(msgview->window);
1201 debug_print("toolbar event not supported\n");
1205 static void toolbar_ignore_thread_cb(GtkWidget *widget, gpointer data)
1207 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1208 MainWindow *mainwin;
1210 g_return_if_fail(toolbar_item != NULL);
1212 switch (toolbar_item->type) {
1214 mainwin = (MainWindow *) toolbar_item->parent;
1215 summary_toggle_ignore_thread(mainwin->summaryview);
1217 case TOOLBAR_MSGVIEW:
1218 /* TODO: see toolbar_next_unread_cb() if you need
1219 * this in the message view */
1222 debug_print("toolbar event not supported\n");
1227 static void toolbar_print_cb(GtkWidget *widget, gpointer data)
1229 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1230 MainWindow *mainwin;
1232 g_return_if_fail(toolbar_item != NULL);
1234 switch (toolbar_item->type) {
1236 mainwin = (MainWindow *) toolbar_item->parent;
1237 summary_print(mainwin->summaryview);
1239 case TOOLBAR_MSGVIEW:
1240 /* TODO: see toolbar_next_unread_cb() if you need
1241 * this in the message view */
1244 debug_print("toolbar event not supported\n");
1249 static void toolbar_send_cb(GtkWidget *widget, gpointer data)
1251 compose_toolbar_cb(A_SEND, data);
1254 static void toolbar_send_later_cb(GtkWidget *widget, gpointer data)
1256 compose_toolbar_cb(A_SENDL, data);
1259 static void toolbar_draft_cb(GtkWidget *widget, gpointer data)
1261 compose_toolbar_cb(A_DRAFT, data);
1264 static void toolbar_insert_cb(GtkWidget *widget, gpointer data)
1266 compose_toolbar_cb(A_INSERT, data);
1269 static void toolbar_attach_cb(GtkWidget *widget, gpointer data)
1271 compose_toolbar_cb(A_ATTACH, data);
1274 static void toolbar_sig_cb(GtkWidget *widget, gpointer data)
1276 compose_toolbar_cb(A_SIG, data);
1279 static void toolbar_ext_editor_cb(GtkWidget *widget, gpointer data)
1281 compose_toolbar_cb(A_EXTEDITOR, data);
1284 static void toolbar_linewrap_current_cb(GtkWidget *widget, gpointer data)
1286 compose_toolbar_cb(A_LINEWRAP_CURRENT, data);
1289 static void toolbar_linewrap_all_cb(GtkWidget *widget, gpointer data)
1291 compose_toolbar_cb(A_LINEWRAP_ALL, data);
1295 static void toolbar_check_spelling_cb(GtkWidget *widget, gpointer data)
1297 compose_toolbar_cb(A_CHECK_SPELLING, data);
1301 * Execute actions from toolbar
1303 static void toolbar_actions_execute_cb(GtkWidget *widget, gpointer data)
1305 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1306 GSList *action_list;
1307 MainWindow *mainwin;
1309 MessageView *msgview;
1310 gpointer parent = toolbar_item->parent;
1312 g_return_if_fail(toolbar_item != NULL);
1314 switch (toolbar_item->type) {
1316 mainwin = (MainWindow*)parent;
1317 action_list = mainwin->toolbar->action_list;
1319 case TOOLBAR_COMPOSE:
1320 compose = (Compose*)parent;
1321 action_list = compose->toolbar->action_list;
1323 case TOOLBAR_MSGVIEW:
1324 msgview = (MessageView*)parent;
1325 action_list = msgview->toolbar->action_list;
1328 debug_print("toolbar event not supported\n");
1331 toolbar_action_execute(widget, action_list, parent, toolbar_item->type);
1334 static MainWindow *get_mainwin(gpointer data)
1336 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1337 MainWindow *mainwin = NULL;
1338 MessageView *msgview;
1340 g_return_val_if_fail(toolbar_item != NULL, NULL);
1342 switch(toolbar_item->type) {
1344 mainwin = (MainWindow*)toolbar_item->parent;
1346 case TOOLBAR_MSGVIEW:
1347 msgview = (MessageView*)toolbar_item->parent;
1348 mainwin = (MainWindow*)msgview->mainwin;
1357 static void toolbar_buttons_cb(GtkWidget *widget,
1364 void (*func)(GtkWidget *widget, gpointer data);
1366 { A_RECEIVE_ALL, toolbar_inc_all_cb },
1367 { A_RECEIVE_CUR, toolbar_inc_cb },
1368 { A_SEND_QUEUED, toolbar_send_queued_cb },
1369 { A_COMPOSE_EMAIL, toolbar_compose_cb },
1370 { A_COMPOSE_NEWS, toolbar_compose_cb },
1371 { A_REPLY_MESSAGE, toolbar_reply_cb },
1372 { A_REPLY_SENDER, toolbar_reply_to_sender_cb },
1373 { A_REPLY_ALL, toolbar_reply_to_all_cb },
1374 { A_REPLY_ML, toolbar_reply_to_list_cb },
1375 { A_FORWARD, toolbar_forward_cb },
1376 { A_TRASH, toolbar_trash_cb },
1377 { A_DELETE_REAL, toolbar_delete_cb },
1378 { A_EXECUTE, toolbar_exec_cb },
1379 { A_GOTO_PREV, toolbar_prev_unread_cb },
1380 { A_GOTO_NEXT, toolbar_next_unread_cb },
1381 { A_IGNORE_THREAD, toolbar_ignore_thread_cb },
1382 { A_PRINT, toolbar_print_cb },
1383 { A_LEARN_SPAM, toolbar_learn_cb },
1385 { A_SEND, toolbar_send_cb },
1386 { A_SENDL, toolbar_send_later_cb },
1387 { A_DRAFT, toolbar_draft_cb },
1388 { A_INSERT, toolbar_insert_cb },
1389 { A_ATTACH, toolbar_attach_cb },
1390 { A_SIG, toolbar_sig_cb },
1391 { A_EXTEDITOR, toolbar_ext_editor_cb },
1392 { A_LINEWRAP_CURRENT, toolbar_linewrap_current_cb },
1393 { A_LINEWRAP_ALL, toolbar_linewrap_all_cb },
1394 { A_ADDRBOOK, toolbar_addrbook_cb },
1396 { A_CHECK_SPELLING, toolbar_check_spelling_cb },
1398 { A_SYL_ACTIONS, toolbar_actions_execute_cb }
1401 num_items = sizeof(callbacks)/sizeof(callbacks[0]);
1403 for (i = 0; i < num_items; i++) {
1404 if (callbacks[i].index == item->index) {
1405 callbacks[i].func(widget, item);
1412 * Create a new toolbar with specified type
1413 * if a callback list is passed it will be used before the
1414 * common callback list
1416 Toolbar *toolbar_create(ToolbarType type,
1417 GtkWidget *container,
1420 ToolbarItem *toolbar_item;
1423 GtkWidget *icon_wid = NULL;
1424 GtkWidget *icon_news;
1425 GtkWidget *icon_ham;
1427 GtkWidget *item_news;
1428 GtkWidget *item_ham;
1429 guint n_menu_entries;
1430 ComboButton *getall_combo;
1431 ComboButton *reply_combo;
1432 ComboButton *replyall_combo;
1433 ComboButton *replylist_combo;
1434 ComboButton *replysender_combo;
1435 ComboButton *fwd_combo;
1436 ComboButton *compose_combo;
1438 GtkTooltips *toolbar_tips;
1439 ToolbarSylpheedActions *action_item;
1441 GSList *toolbar_list;
1442 Toolbar *toolbar_data;
1445 toolbar_tips = gtk_tooltips_new();
1447 toolbar_read_config_file(type);
1448 toolbar_list = toolbar_get_list(type);
1450 toolbar_data = g_new0(Toolbar, 1);
1452 toolbar = gtk_toolbar_new();
1453 gtk_container_add(GTK_CONTAINER(container), toolbar);
1454 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1455 gtk_toolbar_set_orientation(GTK_TOOLBAR(toolbar), GTK_ORIENTATION_HORIZONTAL);
1456 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_BOTH);
1458 for (cur = toolbar_list; cur != NULL; cur = cur->next) {
1460 if (g_ascii_strcasecmp(((ToolbarItem*)cur->data)->file, TOOLBAR_TAG_SEPARATOR) == 0) {
1461 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1465 toolbar_item = g_new0(ToolbarItem, 1);
1466 toolbar_item->index = ((ToolbarItem*)cur->data)->index;
1467 toolbar_item->file = g_strdup(((ToolbarItem*)cur->data)->file);
1468 toolbar_item->text = g_strdup(((ToolbarItem*)cur->data)->text);
1469 toolbar_item->parent = data;
1470 toolbar_item->type = type;
1472 /* collect toolbar items in list to keep track */
1473 toolbar_data->item_list =
1474 g_slist_append(toolbar_data->item_list,
1476 icon_wid = stock_pixmap_widget(container, stock_pixmap_get_icon(toolbar_item->file));
1477 item = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1481 icon_wid, G_CALLBACK(toolbar_buttons_cb),
1484 switch (toolbar_item->index) {
1487 toolbar_data->getall_btn = item;
1488 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1489 toolbar_data->getall_btn,
1490 _("Receive Mail on all Accounts"), NULL);
1491 getall_combo = gtkut_combo_button_create(toolbar_data->getall_btn, NULL, 0,
1492 "<GetAll>", (gpointer)toolbar_item);
1493 gtk_button_set_relief(GTK_BUTTON(getall_combo->arrow),
1495 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar),
1496 GTK_WIDGET_PTR(getall_combo),
1497 _("Receive Mail on selected Account"), "Reply");
1498 toolbar_data->getall_combo = getall_combo;
1501 toolbar_data->get_btn = item;
1502 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1503 toolbar_data->get_btn,
1504 _("Receive Mail on current Account"), NULL);
1507 toolbar_data->send_btn = item;
1508 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1509 toolbar_data->send_btn,
1510 _("Send Queued Messages"), NULL);
1512 case A_COMPOSE_EMAIL:
1513 icon_news = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
1514 item_news = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1518 icon_news, G_CALLBACK(toolbar_buttons_cb),
1520 toolbar_data->compose_mail_btn = item;
1521 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1522 toolbar_data->compose_mail_btn,
1523 _("Compose Email"), NULL);
1524 toolbar_data->compose_news_btn = item_news;
1525 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1526 toolbar_data->compose_news_btn,
1527 _("Compose News"), NULL);
1528 compose_combo = gtkut_combo_button_create(toolbar_data->compose_mail_btn, NULL, 0,
1529 "<Compose>", (gpointer)toolbar_item);
1530 gtk_button_set_relief(GTK_BUTTON(compose_combo->arrow),
1532 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar),
1533 GTK_WIDGET_PTR(compose_combo),
1534 _("Compose with selected Account"), "Compose");
1535 toolbar_data->compose_combo = compose_combo;
1538 icon_ham = stock_pixmap_widget(container, STOCK_PIXMAP_HAM_BTN);
1539 item_ham = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1543 icon_ham, G_CALLBACK(toolbar_buttons_cb),
1545 toolbar_data->learn_spam_btn = item;
1546 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1547 toolbar_data->learn_spam_btn,
1548 _("Learn Spam"), NULL);
1549 toolbar_data->learn_ham_btn = item_ham;
1550 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1551 toolbar_data->learn_ham_btn,
1552 _("Learn Ham"), NULL);
1554 case A_REPLY_MESSAGE:
1555 toolbar_data->reply_btn = item;
1556 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1557 toolbar_data->reply_btn,
1558 _("Reply to Message"), NULL);
1559 n_menu_entries = sizeof(reply_entries) /
1560 sizeof(reply_entries[0]);
1561 reply_combo = gtkut_combo_button_create(toolbar_data->reply_btn,
1562 reply_entries, n_menu_entries,
1563 "<Reply>", (gpointer)toolbar_item);
1564 gtk_button_set_relief(GTK_BUTTON(reply_combo->arrow),
1566 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar),
1567 GTK_WIDGET_PTR(reply_combo),
1568 _("Reply to Message"), "Reply");
1569 toolbar_data->reply_combo = reply_combo;
1571 case A_REPLY_SENDER:
1572 toolbar_data->replysender_btn = item;
1573 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1574 toolbar_data->replysender_btn,
1575 _("Reply to Sender"), NULL);
1576 n_menu_entries = sizeof(replysender_entries) /
1577 sizeof(replysender_entries[0]);
1578 replysender_combo = gtkut_combo_button_create(toolbar_data->replysender_btn,
1579 replysender_entries, n_menu_entries,
1580 "<ReplySender>", (gpointer)toolbar_item);
1581 gtk_button_set_relief(GTK_BUTTON(replysender_combo->arrow),
1583 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar),
1584 GTK_WIDGET_PTR(replysender_combo),
1585 _("Reply to Sender"), "ReplySender");
1586 toolbar_data->replysender_combo = replysender_combo;
1589 toolbar_data->replyall_btn = item;
1590 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1591 toolbar_data->replyall_btn,
1592 _("Reply to All"), NULL);
1593 n_menu_entries = sizeof(replyall_entries) /
1594 sizeof(replyall_entries[0]);
1595 replyall_combo = gtkut_combo_button_create(toolbar_data->replyall_btn,
1596 replyall_entries, n_menu_entries,
1597 "<ReplyAll>", (gpointer)toolbar_item);
1598 gtk_button_set_relief(GTK_BUTTON(replyall_combo->arrow),
1600 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar),
1601 GTK_WIDGET_PTR(replyall_combo),
1602 _("Reply to All"), "ReplyAll");
1603 toolbar_data->replyall_combo = replyall_combo;
1606 toolbar_data->replylist_btn = item;
1607 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1608 toolbar_data->replylist_btn,
1609 _("Reply to Mailing-list"), NULL);
1610 n_menu_entries = sizeof(replylist_entries) /
1611 sizeof(replylist_entries[0]);
1612 replylist_combo = gtkut_combo_button_create(toolbar_data->replylist_btn,
1613 replylist_entries, n_menu_entries,
1614 "<ReplyList>", (gpointer)toolbar_item);
1615 gtk_button_set_relief(GTK_BUTTON(replylist_combo->arrow),
1617 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar),
1618 GTK_WIDGET_PTR(replylist_combo),
1619 _("Reply to Mailing-list"), "ReplyList");
1620 toolbar_data->replylist_combo = replylist_combo;
1623 toolbar_data->fwd_btn = item;
1624 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1625 toolbar_data->fwd_btn,
1626 _("Forward Message"), NULL);
1627 n_menu_entries = sizeof(forward_entries) /
1628 sizeof(forward_entries[0]);
1629 fwd_combo = gtkut_combo_button_create(toolbar_data->fwd_btn,
1630 forward_entries, n_menu_entries,
1631 "<Forward>", (gpointer)toolbar_item);
1632 gtk_button_set_relief(GTK_BUTTON(fwd_combo->arrow),
1634 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar),
1635 GTK_WIDGET_PTR(fwd_combo),
1636 _("Forward Message"), "Fwd");
1637 toolbar_data->fwd_combo = fwd_combo;
1640 toolbar_data->trash_btn = item;
1641 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1642 toolbar_data->trash_btn,
1643 _("Trash Message"), NULL);
1646 toolbar_data->delete_btn = item;
1647 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1648 toolbar_data->delete_btn,
1649 _("Delete Message"), NULL);
1652 toolbar_data->exec_btn = item;
1653 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1654 toolbar_data->exec_btn,
1655 _("Execute"), NULL);
1658 toolbar_data->prev_btn = item;
1659 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1660 toolbar_data->prev_btn,
1661 _("Go to Previous Unread Message"),
1665 toolbar_data->next_btn = item;
1666 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1667 toolbar_data->next_btn,
1668 _("Go to Next Unread Message"),
1672 /* Compose Toolbar */
1674 toolbar_data->send_btn = item;
1675 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1676 toolbar_data->send_btn,
1677 _("Send Message"), NULL);
1680 toolbar_data->sendl_btn = item;
1681 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1682 toolbar_data->sendl_btn,
1683 _("Put into queue folder and send later"), NULL);
1686 toolbar_data->draft_btn = item;
1687 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1688 toolbar_data->draft_btn,
1689 _("Save to draft folder"), NULL);
1692 toolbar_data->insert_btn = item;
1693 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1694 toolbar_data->insert_btn,
1695 _("Insert file"), NULL);
1698 toolbar_data->attach_btn = item;
1699 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1700 toolbar_data->attach_btn,
1701 _("Attach file"), NULL);
1704 toolbar_data->sig_btn = item;
1705 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1706 toolbar_data->sig_btn,
1707 _("Insert signature"), NULL);
1710 toolbar_data->exteditor_btn = item;
1711 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1712 toolbar_data->exteditor_btn,
1713 _("Edit with external editor"), NULL);
1715 case A_LINEWRAP_CURRENT:
1716 toolbar_data->linewrap_current_btn = item;
1717 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1718 toolbar_data->linewrap_current_btn,
1719 _("Wrap long lines of current paragraph"), NULL);
1721 case A_LINEWRAP_ALL:
1722 toolbar_data->linewrap_all_btn = item;
1723 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1724 toolbar_data->linewrap_all_btn,
1725 _("Wrap all long lines"), NULL);
1728 toolbar_data->addrbook_btn = item;
1729 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1730 toolbar_data->addrbook_btn,
1731 _("Address book"), NULL);
1734 case A_CHECK_SPELLING:
1735 toolbar_data->spellcheck_btn = item;
1736 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1737 toolbar_data->spellcheck_btn,
1738 _("Check spelling"), NULL);
1743 action_item = g_new0(ToolbarSylpheedActions, 1);
1744 action_item->widget = item;
1745 action_item->name = g_strdup(toolbar_item->text);
1747 toolbar_data->action_list =
1748 g_slist_append(toolbar_data->action_list,
1751 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1753 action_item->name, NULL);
1755 gtk_widget_show(item);
1758 /* find and set the tool tip text */
1759 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1761 toolbar_ret_descr_from_val
1762 (toolbar_item->index),
1768 toolbar_data->toolbar = toolbar;
1769 if (type == TOOLBAR_MAIN)
1770 activate_compose_button(toolbar_data,
1771 prefs_common.toolbar_style,
1772 toolbar_data->compose_btn_type);
1773 if (type != TOOLBAR_COMPOSE)
1774 activate_learn_button(toolbar_data, prefs_common.toolbar_style,
1777 gtk_widget_show_all(toolbar);
1779 return toolbar_data;
1783 * Free toolbar structures
1785 void toolbar_destroy(Toolbar * toolbar) {
1787 TOOLBAR_DESTROY_ITEMS(toolbar->item_list);
1788 TOOLBAR_DESTROY_ACTIONS(toolbar->action_list);
1791 void toolbar_update(ToolbarType type, gpointer data)
1793 Toolbar *toolbar_data;
1794 GtkWidget *handlebox;
1795 MainWindow *mainwin = (MainWindow*)data;
1796 Compose *compose = (Compose*)data;
1797 MessageView *msgview = (MessageView*)data;
1801 toolbar_data = mainwin->toolbar;
1802 handlebox = mainwin->handlebox;
1804 case TOOLBAR_COMPOSE:
1805 toolbar_data = compose->toolbar;
1806 handlebox = compose->handlebox;
1808 case TOOLBAR_MSGVIEW:
1809 toolbar_data = msgview->toolbar;
1810 handlebox = msgview->handlebox;
1816 gtk_container_remove(GTK_CONTAINER(handlebox),
1817 GTK_WIDGET(toolbar_data->toolbar));
1819 toolbar_init(toolbar_data);
1820 toolbar_data = toolbar_create(type, handlebox, data);
1823 mainwin->toolbar = toolbar_data;
1825 case TOOLBAR_COMPOSE:
1826 compose->toolbar = toolbar_data;
1828 case TOOLBAR_MSGVIEW:
1829 msgview->toolbar = toolbar_data;
1833 toolbar_style(type, prefs_common.toolbar_style, data);
1835 if (type == TOOLBAR_MAIN) {
1836 toolbar_main_set_sensitive((MainWindow*)data);
1837 account_set_menu_only_toolbar();
1841 #define GTK_BUTTON_SET_SENSITIVE(widget,sensitive) { \
1842 gboolean in_btn = FALSE; \
1843 if (GTK_IS_BUTTON(widget)) \
1844 in_btn = GTK_BUTTON(widget)->in_button; \
1845 gtk_widget_set_sensitive(widget, sensitive); \
1846 if (GTK_IS_BUTTON(widget)) \
1847 GTK_BUTTON(widget)->in_button = in_btn; \
1850 void toolbar_main_set_sensitive(gpointer data)
1852 SensitiveCond state;
1854 MainWindow *mainwin = (MainWindow*)data;
1855 Toolbar *toolbar = mainwin->toolbar;
1857 GSList *entry_list = NULL;
1859 typedef struct _Entry Entry;
1866 #define SET_WIDGET_COND(w, c) \
1868 Entry *e = g_new0(Entry, 1); \
1871 entry_list = g_slist_append(entry_list, e); \
1875 if (toolbar->get_btn)
1876 SET_WIDGET_COND(toolbar->get_btn,
1877 M_HAVE_ACCOUNT|M_UNLOCKED);
1879 if (toolbar->getall_btn) {
1880 SET_WIDGET_COND(toolbar->getall_btn,
1881 M_HAVE_ACCOUNT|M_UNLOCKED);
1882 SET_WIDGET_COND(GTK_WIDGET_PTR(toolbar->getall_combo),
1883 M_HAVE_ACCOUNT|M_UNLOCKED);
1885 if (toolbar->send_btn) {
1886 SET_WIDGET_COND(toolbar->send_btn,
1887 M_HAVE_QUEUED_MAILS);
1889 if (toolbar->compose_mail_btn) {
1890 SET_WIDGET_COND(GTK_WIDGET_PTR(toolbar->compose_combo),
1892 SET_WIDGET_COND(toolbar->compose_news_btn,
1895 if (toolbar->reply_btn) {
1896 SET_WIDGET_COND(toolbar->reply_btn,
1897 M_HAVE_ACCOUNT|M_TARGET_EXIST);
1898 SET_WIDGET_COND(GTK_WIDGET_PTR(toolbar->reply_combo),
1899 M_HAVE_ACCOUNT|M_TARGET_EXIST);
1901 if (toolbar->replyall_btn) {
1902 SET_WIDGET_COND(toolbar->replyall_btn,
1903 M_HAVE_ACCOUNT|M_TARGET_EXIST);
1904 SET_WIDGET_COND(GTK_WIDGET_PTR(toolbar->replyall_combo),
1905 M_HAVE_ACCOUNT|M_TARGET_EXIST);
1907 if (toolbar->replylist_btn) {
1908 SET_WIDGET_COND(toolbar->replylist_btn,
1909 M_HAVE_ACCOUNT|M_TARGET_EXIST);
1910 SET_WIDGET_COND(GTK_WIDGET_PTR(toolbar->replylist_combo),
1911 M_HAVE_ACCOUNT|M_TARGET_EXIST);
1913 if (toolbar->replysender_btn) {
1914 SET_WIDGET_COND(toolbar->replysender_btn,
1915 M_HAVE_ACCOUNT|M_TARGET_EXIST);
1916 SET_WIDGET_COND(GTK_WIDGET_PTR(toolbar->replysender_combo),
1917 M_HAVE_ACCOUNT|M_TARGET_EXIST);
1919 if (toolbar->fwd_btn) {
1920 SET_WIDGET_COND(toolbar->fwd_btn,
1921 M_HAVE_ACCOUNT|M_TARGET_EXIST);
1922 SET_WIDGET_COND(GTK_WIDGET_PTR(toolbar->fwd_combo),
1923 M_HAVE_ACCOUNT|M_TARGET_EXIST);
1925 if (toolbar->fwd_combo) {
1926 GtkWidget *submenu = gtk_item_factory_get_widget(toolbar->fwd_combo->factory, "/Redirect");
1927 SET_WIDGET_COND(submenu,
1928 M_HAVE_ACCOUNT|M_TARGET_EXIST);
1931 if (prefs_common.next_unread_msg_dialog == NEXTUNREADMSGDIALOG_ASSUME_NO) {
1932 SET_WIDGET_COND(toolbar->next_btn, M_MSG_EXIST);
1934 SET_WIDGET_COND(toolbar->next_btn, 0);
1937 if (toolbar->trash_btn)
1938 SET_WIDGET_COND(toolbar->trash_btn,
1939 M_TARGET_EXIST|M_ALLOW_DELETE);
1941 if (toolbar->delete_btn)
1942 SET_WIDGET_COND(toolbar->delete_btn,
1943 M_TARGET_EXIST|M_ALLOW_DELETE);
1945 if (toolbar->exec_btn)
1946 SET_WIDGET_COND(toolbar->exec_btn,
1949 if (toolbar->learn_ham_btn)
1950 SET_WIDGET_COND(toolbar->learn_ham_btn,
1951 M_TARGET_EXIST|M_CAN_LEARN_SPAM);
1953 if (toolbar->learn_spam_btn)
1954 SET_WIDGET_COND(toolbar->learn_spam_btn,
1955 M_TARGET_EXIST|M_CAN_LEARN_SPAM);
1957 for (cur = toolbar->action_list; cur != NULL; cur = cur->next) {
1958 ToolbarSylpheedActions *act = (ToolbarSylpheedActions*)cur->data;
1960 SET_WIDGET_COND(act->widget, M_TARGET_EXIST|M_UNLOCKED);
1963 #undef SET_WIDGET_COND
1965 state = main_window_get_current_state(mainwin);
1967 for (cur = entry_list; cur != NULL; cur = cur->next) {
1968 Entry *e = (Entry*) cur->data;
1970 if (e->widget != NULL) {
1971 sensitive = ((e->cond & state) == e->cond);
1972 GTK_BUTTON_SET_SENSITIVE(e->widget, sensitive);
1976 while (entry_list != NULL) {
1977 Entry *e = (Entry*) entry_list->data;
1980 entry_list = g_slist_remove(entry_list, e);
1983 g_slist_free(entry_list);
1985 activate_compose_button(toolbar,
1986 prefs_common.toolbar_style,
1987 toolbar->compose_btn_type);
1991 void toolbar_comp_set_sensitive(gpointer data, gboolean sensitive)
1993 Compose *compose = (Compose*)data;
1994 GSList *items = compose->toolbar->action_list;
1996 if (compose->toolbar->send_btn)
1997 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->send_btn, sensitive);
1998 if (compose->toolbar->sendl_btn)
1999 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->sendl_btn, sensitive);
2000 if (compose->toolbar->draft_btn )
2001 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->draft_btn , sensitive);
2002 if (compose->toolbar->insert_btn )
2003 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->insert_btn , sensitive);
2004 if (compose->toolbar->attach_btn)
2005 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->attach_btn, sensitive);
2006 if (compose->toolbar->sig_btn)
2007 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->sig_btn, sensitive);
2008 if (compose->toolbar->exteditor_btn)
2009 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->exteditor_btn, sensitive);
2010 if (compose->toolbar->linewrap_current_btn)
2011 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->linewrap_current_btn, sensitive);
2012 if (compose->toolbar->linewrap_all_btn)
2013 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->linewrap_all_btn, sensitive);
2014 if (compose->toolbar->addrbook_btn)
2015 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->addrbook_btn, sensitive);
2017 if (compose->toolbar->spellcheck_btn)
2018 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->spellcheck_btn, sensitive);
2020 for (; items != NULL; items = g_slist_next(items)) {
2021 ToolbarSylpheedActions *item = (ToolbarSylpheedActions *)items->data;
2022 GTK_BUTTON_SET_SENSITIVE(item->widget, sensitive);
2027 * Initialize toolbar structure
2029 void toolbar_init(Toolbar * toolbar) {
2031 toolbar->toolbar = NULL;
2032 toolbar->get_btn = NULL;
2033 toolbar->getall_btn = NULL;
2034 toolbar->getall_combo = NULL;
2035 toolbar->send_btn = NULL;
2036 toolbar->compose_mail_btn = NULL;
2037 toolbar->compose_news_btn = NULL;
2038 toolbar->compose_combo = NULL;
2039 toolbar->reply_btn = NULL;
2040 toolbar->replysender_btn = NULL;
2041 toolbar->replyall_btn = NULL;
2042 toolbar->replylist_btn = NULL;
2043 toolbar->fwd_btn = NULL;
2044 toolbar->trash_btn = NULL;
2045 toolbar->delete_btn = NULL;
2046 toolbar->prev_btn = NULL;
2047 toolbar->next_btn = NULL;
2048 toolbar->exec_btn = NULL;
2050 /* compose buttons */
2051 toolbar->sendl_btn = NULL;
2052 toolbar->draft_btn = NULL;
2053 toolbar->insert_btn = NULL;
2054 toolbar->attach_btn = NULL;
2055 toolbar->sig_btn = NULL;
2056 toolbar->exteditor_btn = NULL;
2057 toolbar->linewrap_current_btn = NULL;
2058 toolbar->linewrap_all_btn = NULL;
2059 toolbar->addrbook_btn = NULL;
2061 toolbar->spellcheck_btn = NULL;
2064 toolbar_destroy(toolbar);
2069 static void toolbar_reply(gpointer data, guint action)
2071 ToolbarItem *toolbar_item = (ToolbarItem*)data;
2072 MainWindow *mainwin;
2073 MessageView *msgview;
2074 GSList *msginfo_list = NULL;
2076 g_return_if_fail(toolbar_item != NULL);
2078 switch (toolbar_item->type) {
2080 mainwin = (MainWindow*)toolbar_item->parent;
2081 msginfo_list = summary_get_selection(mainwin->summaryview);
2082 msgview = (MessageView*)mainwin->messageview;
2084 case TOOLBAR_MSGVIEW:
2085 msgview = (MessageView*)toolbar_item->parent;
2086 g_return_if_fail(msgview != NULL);
2087 msginfo_list = g_slist_append(msginfo_list, msgview->msginfo);
2093 g_return_if_fail(msgview != NULL);
2094 g_return_if_fail(msginfo_list != NULL);
2095 compose_reply_from_messageview(msgview, msginfo_list, action);
2096 g_slist_free(msginfo_list);
2098 /* TODO: update reply state ion summaryview */
2102 /* exported functions */
2104 void inc_mail_cb(gpointer data, guint action, GtkWidget *widget)
2106 MainWindow *mainwin = (MainWindow*)data;
2108 inc_mail(mainwin, prefs_common.newmail_notify_manu);
2111 void inc_all_account_mail_cb(gpointer data, guint action, GtkWidget *widget)
2113 MainWindow *mainwin = (MainWindow*)data;
2115 inc_all_account_mail(mainwin, FALSE, prefs_common.newmail_notify_manu);
2118 void send_queue_cb(gpointer data, guint action, GtkWidget *widget)
2122 gboolean got_error = FALSE;
2123 gchar *errstr = NULL;
2125 if (prefs_common.work_offline)
2126 if (alertpanel(_("Offline warning"),
2127 _("You're working offline. Override?"),
2128 GTK_STOCK_NO, GTK_STOCK_YES,
2129 NULL) != G_ALERTALTERNATE)
2132 /* ask for confirmation before sending queued messages only
2133 in online mode and if there is at least one message queued
2134 in any of the folder queue
2136 if (prefs_common.confirm_send_queued_messages) {
2138 /* check if there's a queued message */
2139 for (list = folder_get_list(); !found && list != NULL; list = list->next) {
2140 Folder *folder = list->data;
2142 found = !procmsg_queue_is_empty(folder->queue);
2144 /* if necessary, ask for confirmation before sending */
2145 if (found && !prefs_common.work_offline) {
2146 if (alertpanel(_("Send queued messages"),
2147 _("Send all queued messages?"),
2148 GTK_STOCK_CANCEL, _("_Send"),
2149 NULL) != G_ALERTALTERNATE)
2154 for (list = folder_get_list(); list != NULL; list = list->next) {
2155 Folder *folder = list->data;
2157 if (folder->queue) {
2158 if (procmsg_send_queue(folder->queue,
2159 prefs_common.savemsg,
2166 alertpanel_error_log(_("Some errors occurred while "
2167 "sending queued messages."));
2169 gchar *tmp = g_strdup_printf(_("Some errors occurred "
2170 "while sending queued messages:\n%s"), errstr);
2172 alertpanel_error_log(tmp);
2178 void compose_mail_cb(gpointer data, guint action, GtkWidget *widget)
2180 MainWindow *mainwin = (MainWindow*)data;
2181 PrefsAccount *ac = NULL;
2182 FolderItem *item = mainwin->summaryview->folder_item;
2187 ac = account_find_from_item(item);
2188 if (ac && ac->protocol != A_NNTP) {
2189 compose_new_with_folderitem(ac, item); /* CLAWS */
2195 * CLAWS - use current account
2197 if (cur_account && (cur_account->protocol != A_NNTP)) {
2198 compose_new_with_folderitem(cur_account, item);
2203 * CLAWS - just get the first one
2205 list = account_get_list();
2206 for (cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2207 ac = (PrefsAccount *) cur->data;
2208 if (ac->protocol != A_NNTP) {
2209 compose_new_with_folderitem(ac, item);
2215 void compose_news_cb(gpointer data, guint action, GtkWidget *widget)
2217 MainWindow *mainwin = (MainWindow*)data;
2218 PrefsAccount * ac = NULL;
2222 if (mainwin->summaryview->folder_item) {
2223 ac = mainwin->summaryview->folder_item->folder->account;
2224 if (ac && ac->protocol == A_NNTP) {
2225 compose_new_with_folderitem(ac,
2226 mainwin->summaryview->folder_item);
2231 list = account_get_list();
2232 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2233 ac = (PrefsAccount *) cur->data;
2234 if (ac->protocol == A_NNTP) {
2235 compose_new_with_folderitem(ac,
2236 mainwin->summaryview->folder_item);