2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2001-2007 Hiroyuki Yamamoto and the Claws Mail 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_learn (gpointer data,
94 static void toolbar_delete_cb (GtkWidget *widget,
96 static void toolbar_trash_cb (GtkWidget *widget,
99 static void toolbar_compose_cb (GtkWidget *widget,
102 static void toolbar_learn_cb (GtkWidget *widget,
105 static void toolbar_reply_cb (GtkWidget *widget,
108 static void toolbar_reply_to_all_cb (GtkWidget *widget,
111 static void toolbar_reply_to_list_cb (GtkWidget *widget,
114 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
117 static void toolbar_forward_cb (GtkWidget *widget,
120 static void toolbar_prev_unread_cb (GtkWidget *widget,
122 static void toolbar_next_unread_cb (GtkWidget *widget,
125 static void toolbar_ignore_thread_cb (GtkWidget *widget,
128 static void toolbar_print_cb (GtkWidget *widget,
131 static void toolbar_actions_execute_cb (GtkWidget *widget,
135 static void toolbar_send_cb (GtkWidget *widget,
137 static void toolbar_send_later_cb (GtkWidget *widget,
139 static void toolbar_draft_cb (GtkWidget *widget,
141 static void toolbar_insert_cb (GtkWidget *widget,
143 static void toolbar_attach_cb (GtkWidget *widget,
145 static void toolbar_sig_cb (GtkWidget *widget,
147 static void toolbar_ext_editor_cb (GtkWidget *widget,
149 static void toolbar_linewrap_current_cb (GtkWidget *widget,
151 static void toolbar_linewrap_all_cb (GtkWidget *widget,
153 static void toolbar_addrbook_cb (GtkWidget *widget,
156 static void toolbar_check_spelling_cb (GtkWidget *widget,
159 static void toolbar_cancel_inc_cb (GtkWidget *widget,
165 } toolbar_text [] = {
166 { "A_RECEIVE_ALL", N_("Receive Mail on all Accounts") },
167 { "A_RECEIVE_CUR", N_("Receive Mail on current Account") },
168 { "A_SEND_QUEUED", N_("Send Queued Messages") },
169 { "A_COMPOSE_EMAIL", N_("Compose Email") },
170 { "A_COMPOSE_NEWS", N_("Compose News") },
171 { "A_REPLY_MESSAGE", N_("Reply to Message") },
172 { "A_REPLY_SENDER", N_("Reply to Sender") },
173 { "A_REPLY_ALL", N_("Reply to All") },
174 { "A_REPLY_ML", N_("Reply to Mailing-list") },
175 { "A_FORWARD", N_("Forward Message") },
176 { "A_TRASH", N_("Trash Message") },
177 { "A_DELETE_REAL", N_("Delete Message") },
178 { "A_EXECUTE", N_("Execute") },
179 { "A_GOTO_PREV", N_("Go to Previous Unread Message") },
180 { "A_GOTO_NEXT", N_("Go to Next Unread Message") },
181 { "A_IGNORE_THREAD", N_("Ignore thread") },
182 { "A_PRINT", N_("Print") },
183 { "A_LEARN_SPAM", N_("Learn Spam or Ham") },
185 { "A_SEND", N_("Send Message") },
186 { "A_SENDL", N_("Put into queue folder and send later") },
187 { "A_DRAFT", N_("Save to draft folder") },
188 { "A_INSERT", N_("Insert file") },
189 { "A_ATTACH", N_("Attach file") },
190 { "A_SIG", N_("Insert signature") },
191 { "A_EXTEDITOR", N_("Edit with external editor") },
192 { "A_LINEWRAP_CURRENT", N_("Wrap long lines of current paragraph") },
193 { "A_LINEWRAP_ALL", N_("Wrap all long lines") },
194 { "A_ADDRBOOK", N_("Address book") },
196 { "A_CHECK_SPELLING", N_("Check spelling") },
198 { "A_SYL_ACTIONS", N_("Claws Mail Actions Feature") },
199 { "A_CANCEL_INC", N_("Cancel receiving") },
200 { "A_SEPARATOR", "Separator" }
203 /* struct holds configuration files and a list of
204 * currently active toolbar items
205 * TOOLBAR_MAIN, TOOLBAR_COMPOSE and TOOLBAR_MSGVIEW
209 const gchar *conf_file;
211 } toolbar_config[3] = {
212 { "toolbar_main.xml", NULL},
213 { "toolbar_compose.xml", NULL},
214 { "toolbar_msgview.xml", NULL}
217 static GtkItemFactoryEntry reply_entries[] =
219 {N_("/Reply with _quote"), NULL, toolbar_reply, COMPOSE_REPLY_WITH_QUOTE, NULL},
220 {N_("/_Reply without quote"), NULL, toolbar_reply, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
222 static GtkItemFactoryEntry replyall_entries[] =
224 {N_("/Reply to all with _quote"), "<shift>A", toolbar_reply, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
225 {N_("/_Reply to all without quote"), "a", toolbar_reply, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
227 static GtkItemFactoryEntry replylist_entries[] =
229 {N_("/Reply to list with _quote"), NULL, toolbar_reply, COMPOSE_REPLY_TO_LIST_WITH_QUOTE, NULL},
230 {N_("/_Reply to list without quote"), NULL, toolbar_reply, COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE, NULL}
232 static GtkItemFactoryEntry replysender_entries[] =
234 {N_("/Reply to sender with _quote"), NULL, toolbar_reply, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
235 {N_("/_Reply to sender without quote"), NULL, toolbar_reply, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
237 static GtkItemFactoryEntry forward_entries[] =
239 {N_("/_Forward"), "f", toolbar_reply, COMPOSE_FORWARD_INLINE, NULL},
240 {N_("/For_ward as attachment"), "<shift>F", toolbar_reply, COMPOSE_FORWARD_AS_ATTACH, NULL},
241 {N_("/Redirec_t"), NULL, toolbar_reply, COMPOSE_REDIRECT, NULL}
243 static GtkItemFactoryEntry learn_entries[] =
245 {N_("/Learn as _Spam"), NULL, toolbar_learn, TRUE, NULL},
246 {N_("/Learn as _Ham"), NULL, toolbar_learn, FALSE, NULL}
250 gint toolbar_ret_val_from_descr(const gchar *descr)
254 for (i = 0; i < N_ACTION_VAL; i++) {
255 if (g_utf8_collate(gettext(toolbar_text[i].descr), descr) == 0)
262 gchar *toolbar_ret_descr_from_val(gint val)
264 g_return_val_if_fail(val >=0 && val < N_ACTION_VAL, NULL);
266 return gettext(toolbar_text[val].descr);
269 static gint toolbar_ret_val_from_text(const gchar *text)
273 for (i = 0; i < N_ACTION_VAL; i++) {
274 if (g_utf8_collate(toolbar_text[i].index_str, text) == 0)
281 static gchar *toolbar_ret_text_from_val(gint val)
283 g_return_val_if_fail(val >=0 && val < N_ACTION_VAL, NULL);
285 return toolbar_text[val].index_str;
288 gboolean toolbar_is_duplicate(gint action, ToolbarType source)
292 if ((action == A_SEPARATOR) || (action == A_SYL_ACTIONS))
295 for (cur = toolbar_config[source].item_list; cur != NULL; cur = cur->next) {
296 ToolbarItem *item = (ToolbarItem*) cur->data;
298 if (item->index == action)
304 /* depending on toolbar type this function
305 returns a list of available toolbar events being
306 displayed by prefs_toolbar
308 GList *toolbar_get_action_items(ToolbarType source)
313 if (source == TOOLBAR_MAIN) {
314 gint main_items[] = { A_RECEIVE_ALL, A_RECEIVE_CUR, A_SEND_QUEUED,
315 A_COMPOSE_EMAIL, A_REPLY_MESSAGE, A_REPLY_SENDER,
316 A_REPLY_ALL, A_REPLY_ML, A_FORWARD,
317 A_TRASH , A_DELETE_REAL, A_EXECUTE, A_GOTO_PREV,
318 A_GOTO_NEXT, A_IGNORE_THREAD, A_PRINT,
319 A_ADDRBOOK, A_LEARN_SPAM, A_SYL_ACTIONS, A_CANCEL_INC };
321 for (i = 0; i < sizeof main_items / sizeof main_items[0]; i++) {
322 items = g_list_append(items, gettext(toolbar_text[main_items[i]].descr));
325 else if (source == TOOLBAR_COMPOSE) {
326 gint comp_items[] = { A_SEND, A_SENDL, A_DRAFT,
327 A_INSERT, A_ATTACH, A_SIG,
328 A_EXTEDITOR, A_LINEWRAP_CURRENT,
329 A_LINEWRAP_ALL, A_ADDRBOOK,
335 for (i = 0; i < sizeof comp_items / sizeof comp_items[0]; i++)
336 items = g_list_append(items, gettext(toolbar_text[comp_items[i]].descr));
338 else if (source == TOOLBAR_MSGVIEW) {
339 gint msgv_items[] = { A_COMPOSE_EMAIL, A_REPLY_MESSAGE, A_REPLY_SENDER,
340 A_REPLY_ALL, A_REPLY_ML, A_FORWARD,
341 A_TRASH, A_DELETE_REAL, A_GOTO_PREV, A_GOTO_NEXT,
342 A_ADDRBOOK, A_LEARN_SPAM, A_SYL_ACTIONS };
344 for (i = 0; i < sizeof msgv_items / sizeof msgv_items[0]; i++)
345 items = g_list_append(items, gettext(toolbar_text[msgv_items[i]].descr));
351 static void toolbar_parse_item(XMLFile *file, ToolbarType source)
355 ToolbarItem *item = NULL;
356 gboolean rewrite = FALSE;
358 attr = xml_get_current_tag_attr(file);
359 item = g_new0(ToolbarItem, 1);
361 name = ((XMLAttr *)attr->data)->name;
362 value = ((XMLAttr *)attr->data)->value;
364 if (g_utf8_collate(name, TOOLBAR_ICON_FILE) == 0)
365 item->file = g_strdup (value);
366 else if (g_utf8_collate(name, TOOLBAR_ICON_TEXT) == 0)
367 item->text = g_strdup (value);
368 else if (g_utf8_collate(name, TOOLBAR_ICON_ACTION) == 0)
369 item->index = toolbar_ret_val_from_text(value);
370 if (item->index == -1 && !strcmp(value, "A_DELETE")) {
372 item->index = A_TRASH;
374 item->file = g_strdup("trash_btn");
376 item->text = g_strdup(_("Trash"));
379 attr = g_list_next(attr);
381 if (item->index != -1) {
383 if (!toolbar_is_duplicate(item->index, source))
384 toolbar_config[source].item_list = g_slist_append(toolbar_config[source].item_list,
388 toolbar_save_config_file(source);
392 static void toolbar_set_default_main(void)
398 } default_toolbar[] = {
399 { A_RECEIVE_ALL, STOCK_PIXMAP_MAIL_RECEIVE_ALL, _("Get Mail") },
400 { A_SEPARATOR, 0, ("") },
401 { A_SEND_QUEUED, STOCK_PIXMAP_MAIL_SEND_QUEUE, _("Send") },
402 { A_COMPOSE_EMAIL, STOCK_PIXMAP_MAIL_COMPOSE,
403 (gchar*)Q_("Toolbar|Compose") },
404 { A_SEPARATOR, 0, ("") },
405 { A_REPLY_MESSAGE, STOCK_PIXMAP_MAIL_REPLY, _("Reply") },
406 { A_REPLY_ALL, STOCK_PIXMAP_MAIL_REPLY_TO_ALL, _("All") },
407 { A_REPLY_SENDER, STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR, _("Sender") },
408 { A_FORWARD, STOCK_PIXMAP_MAIL_FORWARD, _("Forward") },
409 { A_SEPARATOR, 0, ("") },
410 { A_TRASH, STOCK_PIXMAP_TRASH, _("Trash") },
411 #if (defined(USE_SPAMASSASSIN_PLUGIN) || defined(USE_BOGOFILTER_PLUGIN))
412 { A_LEARN_SPAM, STOCK_PIXMAP_SPAM_BTN, _("Spam") },
414 { A_SEPARATOR, 0, ("") },
415 { A_GOTO_NEXT, STOCK_PIXMAP_DOWN_ARROW, _("Next") }
420 for (i = 0; i < sizeof(default_toolbar) / sizeof(default_toolbar[0]); i++) {
422 ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
424 if (default_toolbar[i].action != A_SEPARATOR) {
426 gchar *file = stock_pixmap_get_name((StockPixmap)default_toolbar[i].icon);
428 toolbar_item->file = g_strdup(file);
429 toolbar_item->index = default_toolbar[i].action;
430 toolbar_item->text = g_strdup(default_toolbar[i].text);
433 toolbar_item->file = g_strdup(TOOLBAR_TAG_SEPARATOR);
434 toolbar_item->index = A_SEPARATOR;
437 if (toolbar_item->index != -1) {
438 if ( !toolbar_is_duplicate(toolbar_item->index, TOOLBAR_MAIN))
439 toolbar_config[TOOLBAR_MAIN].item_list =
440 g_slist_append(toolbar_config[TOOLBAR_MAIN].item_list, toolbar_item);
445 static void toolbar_set_default_compose(void)
451 } default_toolbar[] = {
452 { A_SEND, STOCK_PIXMAP_MAIL_SEND, _("Send") },
453 { A_SENDL, STOCK_PIXMAP_MAIL_SEND_QUEUE, _("Send later") },
454 { A_DRAFT, STOCK_PIXMAP_MAIL, _("Draft") },
455 { A_SEPARATOR, 0, ("") },
456 { A_INSERT, STOCK_PIXMAP_INSERT_FILE, _("Insert") },
457 { A_ATTACH, STOCK_PIXMAP_MAIL_ATTACH, _("Attach") },
458 { A_SEPARATOR, 0, ("") },
459 { A_ADDRBOOK, STOCK_PIXMAP_ADDRESS_BOOK, _("Address") }
464 for (i = 0; i < sizeof(default_toolbar) / sizeof(default_toolbar[0]); i++) {
466 ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
468 if (default_toolbar[i].action != A_SEPARATOR) {
470 gchar *file = stock_pixmap_get_name((StockPixmap)default_toolbar[i].icon);
472 toolbar_item->file = g_strdup(file);
473 toolbar_item->index = default_toolbar[i].action;
474 toolbar_item->text = g_strdup(default_toolbar[i].text);
477 toolbar_item->file = g_strdup(TOOLBAR_TAG_SEPARATOR);
478 toolbar_item->index = A_SEPARATOR;
481 if (toolbar_item->index != -1) {
482 if ( !toolbar_is_duplicate(toolbar_item->index, TOOLBAR_COMPOSE))
483 toolbar_config[TOOLBAR_COMPOSE].item_list =
484 g_slist_append(toolbar_config[TOOLBAR_COMPOSE].item_list, toolbar_item);
489 static void toolbar_set_default_msgview(void)
495 } default_toolbar[] = {
496 { A_REPLY_MESSAGE, STOCK_PIXMAP_MAIL_REPLY, _("Reply") },
497 { A_REPLY_ALL, STOCK_PIXMAP_MAIL_REPLY_TO_ALL, _("All") },
498 { A_REPLY_SENDER, STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR, _("Sender") },
499 { A_FORWARD, STOCK_PIXMAP_MAIL_FORWARD, _("Forward") },
500 { A_SEPARATOR, 0, ("") },
501 { A_TRASH, STOCK_PIXMAP_TRASH, _("Trash") },
502 #if (defined(USE_SPAMASSASSIN_PLUGIN) || defined(USE_BOGOFILTER_PLUGIN))
503 { A_LEARN_SPAM, STOCK_PIXMAP_SPAM_BTN, _("Spam") },
505 { A_GOTO_NEXT, STOCK_PIXMAP_DOWN_ARROW, _("Next") }
510 for (i = 0; i < sizeof(default_toolbar) / sizeof(default_toolbar[0]); i++) {
512 ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
514 if (default_toolbar[i].action != A_SEPARATOR) {
516 gchar *file = stock_pixmap_get_name((StockPixmap)default_toolbar[i].icon);
518 toolbar_item->file = g_strdup(file);
519 toolbar_item->index = default_toolbar[i].action;
520 toolbar_item->text = g_strdup(default_toolbar[i].text);
523 toolbar_item->file = g_strdup(TOOLBAR_TAG_SEPARATOR);
524 toolbar_item->index = A_SEPARATOR;
527 if (toolbar_item->index != -1) {
528 if ( !toolbar_is_duplicate(toolbar_item->index, TOOLBAR_MSGVIEW))
529 toolbar_config[TOOLBAR_MSGVIEW].item_list =
530 g_slist_append(toolbar_config[TOOLBAR_MSGVIEW].item_list, toolbar_item);
535 void toolbar_set_default(ToolbarType source)
537 if (source == TOOLBAR_MAIN)
538 toolbar_set_default_main();
539 else if (source == TOOLBAR_COMPOSE)
540 toolbar_set_default_compose();
541 else if (source == TOOLBAR_MSGVIEW)
542 toolbar_set_default_msgview();
545 void toolbar_save_config_file(ToolbarType source)
550 gchar *fileSpec = NULL;
552 debug_print("save Toolbar Configuration to %s\n", toolbar_config[source].conf_file);
554 fileSpec = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, toolbar_config[source].conf_file, NULL );
555 pfile = prefs_write_open(fileSpec);
559 fprintf(fp, "<?xml version=\"1.0\" encoding=\"%s\" ?>\n", CS_INTERNAL);
561 fprintf(fp, "<%s>\n", TOOLBAR_TAG_INDEX);
563 for (cur = toolbar_config[source].item_list; cur != NULL; cur = cur->next) {
564 ToolbarItem *toolbar_item = (ToolbarItem*) cur->data;
566 if (toolbar_item->index != A_SEPARATOR) {
567 fprintf(fp, "\t<%s %s=\"%s\" %s=\"",
569 TOOLBAR_ICON_FILE, toolbar_item->file,
571 xml_file_put_escape_str(fp, toolbar_item->text);
572 fprintf(fp, "\" %s=\"%s\"/>\n",
574 toolbar_ret_text_from_val(toolbar_item->index));
576 fprintf(fp, "\t<%s/>\n", TOOLBAR_TAG_SEPARATOR);
580 fprintf(fp, "</%s>\n", TOOLBAR_TAG_INDEX);
582 if (prefs_file_close (pfile) < 0 )
583 g_warning("failed to write toolbar configuration to file\n");
585 g_warning("failed to open toolbar configuration file for writing\n");
588 void toolbar_read_config_file(ToolbarType source)
590 XMLFile *file = NULL;
591 gchar *fileSpec = NULL;
596 debug_print("read Toolbar Configuration from %s\n", toolbar_config[source].conf_file);
598 fileSpec = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, toolbar_config[source].conf_file, NULL );
599 file = xml_open_file(fileSpec);
602 toolbar_clear_list(source);
606 || (xml_get_dtd(file))
607 || (xml_parse_next_tag(file))
608 || (!xml_compare_tag(file, TOOLBAR_TAG_INDEX))) {
609 xml_close_file(file);
613 attr = xml_get_current_tag_attr(file);
620 if (xml_parse_next_tag(file))
623 /* Get next tag (icon, icon_text or icon_action) */
624 if (xml_compare_tag(file, TOOLBAR_TAG_ITEM)) {
625 toolbar_parse_item(file, source);
626 } else if (xml_compare_tag(file, TOOLBAR_TAG_SEPARATOR)) {
627 ToolbarItem *item = g_new0(ToolbarItem, 1);
629 item->file = g_strdup(toolbar_ret_descr_from_val(A_SEPARATOR));
630 item->index = A_SEPARATOR;
631 toolbar_config[source].item_list =
632 g_slist_append(toolbar_config[source].item_list, item);
636 xml_close_file(file);
639 if ((!file) || (g_slist_length(toolbar_config[source].item_list) == 0)) {
641 if (source == TOOLBAR_MAIN)
642 toolbar_set_default(TOOLBAR_MAIN);
643 else if (source == TOOLBAR_COMPOSE)
644 toolbar_set_default(TOOLBAR_COMPOSE);
645 else if (source == TOOLBAR_MSGVIEW)
646 toolbar_set_default(TOOLBAR_MSGVIEW);
648 g_warning("failed to write Toolbar Configuration to %s\n", toolbar_config[source].conf_file);
652 toolbar_save_config_file(source);
657 * clears list of toolbar items read from configuration files
659 void toolbar_clear_list(ToolbarType source)
661 while (toolbar_config[source].item_list != NULL) {
662 ToolbarItem *item = (ToolbarItem*) toolbar_config[source].item_list->data;
664 toolbar_config[source].item_list =
665 g_slist_remove(toolbar_config[source].item_list, item);
671 g_slist_free(toolbar_config[source].item_list);
676 * return list of Toolbar items
678 GSList *toolbar_get_list(ToolbarType source)
682 if ((source == TOOLBAR_MAIN) || (source == TOOLBAR_COMPOSE) || (source == TOOLBAR_MSGVIEW))
683 list = toolbar_config[source].item_list;
688 void toolbar_set_list_item(ToolbarItem *t_item, ToolbarType source)
690 ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
692 toolbar_item->file = g_strdup(t_item->file);
693 toolbar_item->text = g_strdup(t_item->text);
694 toolbar_item->index = t_item->index;
696 toolbar_config[source].item_list =
697 g_slist_append(toolbar_config[source].item_list,
701 void toolbar_action_execute(GtkWidget *widget,
707 gchar *action, *action_p;
708 gboolean found = FALSE;
711 for (cur = action_list; cur != NULL; cur = cur->next) {
712 ToolbarSylpheedActions *act = (ToolbarSylpheedActions*)cur->data;
714 if (widget == act->widget) {
716 for (lop = prefs_common.actions_list; lop != NULL; lop = lop->next) {
717 action = g_strdup((gchar*)lop->data);
719 action_p = strstr(action, ": ");
721 if (g_utf8_collate(act->name, action) == 0) {
735 actions_execute(data, i, widget, source);
737 g_warning ("Error: did not find Claws Action to execute");
740 static void activate_compose_button (Toolbar *toolbar,
742 ComposeButtonType type)
744 if ((!toolbar->compose_mail_btn) || (!toolbar->compose_news_btn))
747 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? toolbar->compose_mail_btn
748 : toolbar->compose_news_btn);
749 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? toolbar->compose_news_btn
750 : toolbar->compose_mail_btn);
751 toolbar->compose_btn_type = type;
754 void toolbar_set_compose_button(Toolbar *toolbar,
755 ComposeButtonType compose_btn_type)
757 if (toolbar->compose_btn_type != compose_btn_type)
758 activate_compose_button(toolbar,
759 prefs_common.toolbar_style,
763 static void activate_learn_button (Toolbar *toolbar,
765 LearnButtonType type)
767 if ((!toolbar->learn_spam_btn) || (!toolbar->learn_ham_btn))
770 gtk_widget_hide(type == LEARN_SPAM ? toolbar->learn_ham_btn
771 : toolbar->learn_spam_btn);
772 gtk_widget_show(type == LEARN_SPAM ? toolbar->learn_spam_btn
773 : toolbar->learn_ham_btn);
774 toolbar->learn_btn_type = type;
777 void toolbar_set_learn_button(Toolbar *toolbar,
778 LearnButtonType learn_btn_type)
780 if (toolbar->learn_btn_type != learn_btn_type)
781 activate_learn_button(toolbar,
782 prefs_common.toolbar_style,
786 void toolbar_toggle(guint action, gpointer data)
788 MainWindow *mainwin = (MainWindow*)data;
792 g_return_if_fail(mainwin != NULL);
794 toolbar_style(TOOLBAR_MAIN, action, mainwin);
796 list = compose_get_compose_list();
797 for (cur = list; cur != NULL; cur = cur->next) {
798 toolbar_style(TOOLBAR_COMPOSE, action, cur->data);
800 list = messageview_get_msgview_list();
801 for (cur = list; cur != NULL; cur = cur->next) {
802 toolbar_style(TOOLBAR_MSGVIEW, action, cur->data);
807 void toolbar_set_style(GtkWidget *toolbar_wid, GtkWidget *handlebox_wid, guint action)
809 switch ((ToolbarStyle)action) {
811 gtk_widget_hide(handlebox_wid);
814 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
818 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
822 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
825 case TOOLBAR_BOTH_HORIZ:
826 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
827 GTK_TOOLBAR_BOTH_HORIZ);
833 prefs_common.toolbar_style = (ToolbarStyle)action;
834 gtk_widget_set_size_request(handlebox_wid, 1, -1);
836 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
837 gtk_widget_show(handlebox_wid);
838 gtk_widget_queue_resize(handlebox_wid);
842 * Change the style of toolbar
844 static void toolbar_style(ToolbarType type, guint action, gpointer data)
846 GtkWidget *handlebox_wid;
847 GtkWidget *toolbar_wid;
848 MainWindow *mainwin = (MainWindow*)data;
849 Compose *compose = (Compose*)data;
850 MessageView *msgview = (MessageView*)data;
852 g_return_if_fail(data != NULL);
856 handlebox_wid = mainwin->handlebox;
857 toolbar_wid = mainwin->toolbar->toolbar;
859 case TOOLBAR_COMPOSE:
860 handlebox_wid = compose->handlebox;
861 toolbar_wid = compose->toolbar->toolbar;
863 case TOOLBAR_MSGVIEW:
864 handlebox_wid = msgview->handlebox;
865 toolbar_wid = msgview->toolbar->toolbar;
871 toolbar_set_style(toolbar_wid, handlebox_wid, action);
874 /* Toolbar handling */
875 static void toolbar_inc_cb(GtkWidget *widget,
878 ToolbarItem *toolbar_item = (ToolbarItem*)data;
881 g_return_if_fail(toolbar_item != NULL);
883 switch (toolbar_item->type) {
885 mainwin = (MainWindow*)toolbar_item->parent;
886 inc_mail_cb(mainwin, 0, NULL);
893 static void toolbar_inc_all_cb(GtkWidget *widget,
896 ToolbarItem *toolbar_item = (ToolbarItem*)data;
899 g_return_if_fail(toolbar_item != NULL);
901 switch (toolbar_item->type) {
903 mainwin = (MainWindow*)toolbar_item->parent;
904 inc_all_account_mail_cb(mainwin, 0, NULL);
911 static void toolbar_send_queued_cb(GtkWidget *widget,gpointer data)
913 ToolbarItem *toolbar_item = (ToolbarItem*)data;
916 g_return_if_fail(toolbar_item != NULL);
918 switch (toolbar_item->type) {
920 mainwin = (MainWindow*)toolbar_item->parent;
921 send_queue_cb(mainwin, 0, NULL);
928 static void toolbar_exec_cb(GtkWidget *widget,
931 MainWindow *mainwin = get_mainwin(data);
933 g_return_if_fail(mainwin != NULL);
934 summary_execute(mainwin->summaryview);
938 * Delete current/selected(s) message(s)
940 static void toolbar_trash_cb(GtkWidget *widget, gpointer data)
942 ToolbarItem *toolbar_item = (ToolbarItem*)data;
945 g_return_if_fail(toolbar_item != NULL);
946 g_return_if_fail(toolbar_item->parent);
948 switch (toolbar_item->type) {
949 case TOOLBAR_MSGVIEW:
950 messageview_delete((MessageView *)toolbar_item->parent);
953 mainwin = (MainWindow *)toolbar_item->parent;
954 summary_delete_trash(mainwin->summaryview);
957 debug_print("toolbar event not supported\n");
963 * Delete current/selected(s) message(s)
965 static void toolbar_delete_cb(GtkWidget *widget, gpointer data)
967 ToolbarItem *toolbar_item = (ToolbarItem*)data;
970 g_return_if_fail(toolbar_item != NULL);
971 g_return_if_fail(toolbar_item->parent);
973 switch (toolbar_item->type) {
974 case TOOLBAR_MSGVIEW:
975 messageview_delete((MessageView *)toolbar_item->parent);
978 mainwin = (MainWindow *)toolbar_item->parent;
979 summary_delete(mainwin->summaryview);
982 debug_print("toolbar event not supported\n");
989 * Compose new message
991 static void toolbar_compose_cb(GtkWidget *widget, gpointer data)
993 ToolbarItem *toolbar_item = (ToolbarItem*)data;
995 MessageView *msgview;
997 g_return_if_fail(toolbar_item != NULL);
999 switch (toolbar_item->type) {
1001 mainwin = (MainWindow*)toolbar_item->parent;
1002 if (mainwin->toolbar->compose_btn_type == COMPOSEBUTTON_NEWS)
1003 compose_news_cb(mainwin, 0, NULL);
1005 compose_mail_cb(mainwin, 0, NULL);
1007 case TOOLBAR_MSGVIEW:
1008 msgview = (MessageView*)toolbar_item->parent;
1009 compose_new_with_folderitem(NULL,
1010 msgview->msginfo->folder, NULL);
1013 debug_print("toolbar event not supported\n");
1017 static void toolbar_learn(gpointer data, guint as_spam)
1019 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1020 MainWindow *mainwin;
1021 MessageView *msgview;
1023 g_return_if_fail(toolbar_item != NULL);
1025 switch (toolbar_item->type) {
1027 mainwin = (MainWindow*)toolbar_item->parent;
1029 mainwindow_learn(mainwin, TRUE);
1031 mainwindow_learn(mainwin, FALSE);
1033 case TOOLBAR_MSGVIEW:
1034 msgview = (MessageView*)toolbar_item->parent;
1036 messageview_learn(msgview, TRUE);
1038 messageview_learn(msgview, FALSE);
1041 debug_print("toolbar event not supported\n");
1045 static void toolbar_learn_cb(GtkWidget *widget, gpointer data)
1047 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1048 MainWindow *mainwin;
1049 MessageView *msgview;
1051 g_return_if_fail(toolbar_item != NULL);
1053 switch (toolbar_item->type) {
1055 mainwin = (MainWindow*)toolbar_item->parent;
1056 if (mainwin->toolbar->learn_btn_type == LEARN_SPAM)
1057 mainwindow_learn(mainwin, TRUE);
1059 mainwindow_learn(mainwin, FALSE);
1061 case TOOLBAR_MSGVIEW:
1062 msgview = (MessageView*)toolbar_item->parent;
1063 if (msgview->toolbar->learn_btn_type == LEARN_SPAM)
1064 messageview_learn(msgview, TRUE);
1066 messageview_learn(msgview, FALSE);
1069 debug_print("toolbar event not supported\n");
1077 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
1079 toolbar_reply(data, prefs_common.reply_with_quote ?
1080 COMPOSE_REPLY_WITH_QUOTE : COMPOSE_REPLY_WITHOUT_QUOTE);
1085 * Reply message to Sender and All recipients
1087 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
1090 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
1091 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE);
1096 * Reply to Mailing List
1098 static void toolbar_reply_to_list_cb(GtkWidget *widget, gpointer data)
1101 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_LIST_WITH_QUOTE
1102 : COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE);
1107 * Reply to sender of message
1109 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
1112 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
1113 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE);
1119 static void toolbar_addrbook_cb(GtkWidget *widget, gpointer data)
1121 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1124 g_return_if_fail(toolbar_item != NULL);
1126 switch (toolbar_item->type) {
1128 case TOOLBAR_MSGVIEW:
1131 case TOOLBAR_COMPOSE:
1132 compose = (Compose *)toolbar_item->parent;
1137 addressbook_open(compose);
1142 * Forward current/selected(s) message(s)
1144 static void toolbar_forward_cb(GtkWidget *widget, gpointer data)
1146 toolbar_reply(data, COMPOSE_FORWARD);
1150 * Goto Prev Unread Message
1152 static void toolbar_prev_unread_cb(GtkWidget *widget, gpointer data)
1154 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1155 MainWindow *mainwin;
1156 MessageView *msgview;
1158 g_return_if_fail(toolbar_item != NULL);
1160 switch (toolbar_item->type) {
1162 mainwin = (MainWindow*)toolbar_item->parent;
1163 summary_select_prev_unread(mainwin->summaryview);
1166 case TOOLBAR_MSGVIEW:
1167 msgview = (MessageView*)toolbar_item->parent;
1168 msgview->updating = TRUE;
1169 summary_select_prev_unread(msgview->mainwin->summaryview);
1170 msgview->updating = FALSE;
1172 if (msgview->deferred_destroy) {
1173 debug_print("messageview got away!\n");
1174 messageview_destroy(msgview);
1178 /* Now we need to update the messageview window */
1179 if (msgview->mainwin->summaryview->selected) {
1180 MsgInfo * msginfo = summary_get_selected_msg(msgview->mainwin->summaryview);
1183 messageview_show(msgview, msginfo,
1184 msgview->all_headers);
1186 gtk_widget_destroy(msgview->window);
1190 debug_print("toolbar event not supported\n");
1195 * Goto Next Unread Message
1197 static void toolbar_next_unread_cb(GtkWidget *widget, gpointer data)
1199 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1200 MainWindow *mainwin;
1201 MessageView *msgview;
1203 g_return_if_fail(toolbar_item != NULL);
1205 switch (toolbar_item->type) {
1207 mainwin = (MainWindow*)toolbar_item->parent;
1208 summary_select_next_unread(mainwin->summaryview);
1211 case TOOLBAR_MSGVIEW:
1212 msgview = (MessageView*)toolbar_item->parent;
1213 msgview->updating = TRUE;
1214 summary_select_next_unread(msgview->mainwin->summaryview);
1215 msgview->updating = FALSE;
1217 if (msgview->deferred_destroy) {
1218 debug_print("messageview got away!\n");
1219 messageview_destroy(msgview);
1223 /* Now we need to update the messageview window */
1224 if (msgview->mainwin->summaryview->selected) {
1225 MsgInfo * msginfo = summary_get_selected_msg(msgview->mainwin->summaryview);
1228 messageview_show(msgview, msginfo,
1229 msgview->all_headers);
1231 gtk_widget_destroy(msgview->window);
1235 debug_print("toolbar event not supported\n");
1239 static void toolbar_ignore_thread_cb(GtkWidget *widget, gpointer data)
1241 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1242 MainWindow *mainwin;
1244 g_return_if_fail(toolbar_item != NULL);
1246 switch (toolbar_item->type) {
1248 mainwin = (MainWindow *) toolbar_item->parent;
1249 summary_toggle_ignore_thread(mainwin->summaryview);
1251 case TOOLBAR_MSGVIEW:
1252 /* TODO: see toolbar_next_unread_cb() if you need
1253 * this in the message view */
1256 debug_print("toolbar event not supported\n");
1261 static void toolbar_cancel_inc_cb(GtkWidget *widget, gpointer data)
1263 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1265 g_return_if_fail(toolbar_item != NULL);
1270 static void toolbar_print_cb(GtkWidget *widget, gpointer data)
1272 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1273 MainWindow *mainwin;
1275 g_return_if_fail(toolbar_item != NULL);
1277 switch (toolbar_item->type) {
1279 mainwin = (MainWindow *) toolbar_item->parent;
1280 summary_print(mainwin->summaryview);
1282 case TOOLBAR_MSGVIEW:
1283 /* TODO: see toolbar_next_unread_cb() if you need
1284 * this in the message view */
1287 debug_print("toolbar event not supported\n");
1292 static void toolbar_send_cb(GtkWidget *widget, gpointer data)
1294 compose_toolbar_cb(A_SEND, data);
1297 static void toolbar_send_later_cb(GtkWidget *widget, gpointer data)
1299 compose_toolbar_cb(A_SENDL, data);
1302 static void toolbar_draft_cb(GtkWidget *widget, gpointer data)
1304 compose_toolbar_cb(A_DRAFT, data);
1307 static void toolbar_insert_cb(GtkWidget *widget, gpointer data)
1309 compose_toolbar_cb(A_INSERT, data);
1312 static void toolbar_attach_cb(GtkWidget *widget, gpointer data)
1314 compose_toolbar_cb(A_ATTACH, data);
1317 static void toolbar_sig_cb(GtkWidget *widget, gpointer data)
1319 compose_toolbar_cb(A_SIG, data);
1322 static void toolbar_ext_editor_cb(GtkWidget *widget, gpointer data)
1324 compose_toolbar_cb(A_EXTEDITOR, data);
1327 static void toolbar_linewrap_current_cb(GtkWidget *widget, gpointer data)
1329 compose_toolbar_cb(A_LINEWRAP_CURRENT, data);
1332 static void toolbar_linewrap_all_cb(GtkWidget *widget, gpointer data)
1334 compose_toolbar_cb(A_LINEWRAP_ALL, data);
1338 static void toolbar_check_spelling_cb(GtkWidget *widget, gpointer data)
1340 compose_toolbar_cb(A_CHECK_SPELLING, data);
1344 * Execute actions from toolbar
1346 static void toolbar_actions_execute_cb(GtkWidget *widget, gpointer data)
1348 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1349 GSList *action_list;
1350 MainWindow *mainwin;
1352 MessageView *msgview;
1353 gpointer parent = toolbar_item->parent;
1355 g_return_if_fail(toolbar_item != NULL);
1357 switch (toolbar_item->type) {
1359 mainwin = (MainWindow*)parent;
1360 action_list = mainwin->toolbar->action_list;
1362 case TOOLBAR_COMPOSE:
1363 compose = (Compose*)parent;
1364 action_list = compose->toolbar->action_list;
1366 case TOOLBAR_MSGVIEW:
1367 msgview = (MessageView*)parent;
1368 action_list = msgview->toolbar->action_list;
1371 debug_print("toolbar event not supported\n");
1374 toolbar_action_execute(widget, action_list, parent, toolbar_item->type);
1377 static MainWindow *get_mainwin(gpointer data)
1379 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1380 MainWindow *mainwin = NULL;
1381 MessageView *msgview;
1383 g_return_val_if_fail(toolbar_item != NULL, NULL);
1385 switch(toolbar_item->type) {
1387 mainwin = (MainWindow*)toolbar_item->parent;
1389 case TOOLBAR_MSGVIEW:
1390 msgview = (MessageView*)toolbar_item->parent;
1391 mainwin = (MainWindow*)msgview->mainwin;
1400 static void toolbar_buttons_cb(GtkWidget *widget,
1407 void (*func)(GtkWidget *widget, gpointer data);
1409 { A_RECEIVE_ALL, toolbar_inc_all_cb },
1410 { A_RECEIVE_CUR, toolbar_inc_cb },
1411 { A_SEND_QUEUED, toolbar_send_queued_cb },
1412 { A_COMPOSE_EMAIL, toolbar_compose_cb },
1413 { A_COMPOSE_NEWS, toolbar_compose_cb },
1414 { A_REPLY_MESSAGE, toolbar_reply_cb },
1415 { A_REPLY_SENDER, toolbar_reply_to_sender_cb },
1416 { A_REPLY_ALL, toolbar_reply_to_all_cb },
1417 { A_REPLY_ML, toolbar_reply_to_list_cb },
1418 { A_FORWARD, toolbar_forward_cb },
1419 { A_TRASH, toolbar_trash_cb },
1420 { A_DELETE_REAL, toolbar_delete_cb },
1421 { A_EXECUTE, toolbar_exec_cb },
1422 { A_GOTO_PREV, toolbar_prev_unread_cb },
1423 { A_GOTO_NEXT, toolbar_next_unread_cb },
1424 { A_IGNORE_THREAD, toolbar_ignore_thread_cb },
1425 { A_PRINT, toolbar_print_cb },
1426 { A_LEARN_SPAM, toolbar_learn_cb },
1428 { A_SEND, toolbar_send_cb },
1429 { A_SENDL, toolbar_send_later_cb },
1430 { A_DRAFT, toolbar_draft_cb },
1431 { A_INSERT, toolbar_insert_cb },
1432 { A_ATTACH, toolbar_attach_cb },
1433 { A_SIG, toolbar_sig_cb },
1434 { A_EXTEDITOR, toolbar_ext_editor_cb },
1435 { A_LINEWRAP_CURRENT, toolbar_linewrap_current_cb },
1436 { A_LINEWRAP_ALL, toolbar_linewrap_all_cb },
1437 { A_ADDRBOOK, toolbar_addrbook_cb },
1439 { A_CHECK_SPELLING, toolbar_check_spelling_cb },
1441 { A_SYL_ACTIONS, toolbar_actions_execute_cb },
1442 { A_CANCEL_INC, toolbar_cancel_inc_cb }
1445 num_items = sizeof(callbacks)/sizeof(callbacks[0]);
1447 for (i = 0; i < num_items; i++) {
1448 if (callbacks[i].index == item->index) {
1449 callbacks[i].func(widget, item);
1456 * Create a new toolbar with specified type
1457 * if a callback list is passed it will be used before the
1458 * common callback list
1460 Toolbar *toolbar_create(ToolbarType type,
1461 GtkWidget *container,
1464 ToolbarItem *toolbar_item;
1467 GtkWidget *icon_wid = NULL;
1468 GtkWidget *icon_news;
1469 GtkWidget *icon_ham;
1471 GtkWidget *item_news;
1472 GtkWidget *item_ham;
1473 guint n_menu_entries;
1474 ComboButton *getall_combo;
1475 ComboButton *reply_combo;
1476 ComboButton *replyall_combo;
1477 ComboButton *replylist_combo;
1478 ComboButton *replysender_combo;
1479 ComboButton *fwd_combo;
1480 ComboButton *compose_combo;
1481 ComboButton *ham_combo;
1483 GtkTooltips *toolbar_tips;
1484 ToolbarSylpheedActions *action_item;
1486 GSList *toolbar_list;
1487 Toolbar *toolbar_data;
1490 toolbar_tips = gtk_tooltips_new();
1492 toolbar_read_config_file(type);
1493 toolbar_list = toolbar_get_list(type);
1495 toolbar_data = g_new0(Toolbar, 1);
1497 toolbar = gtk_toolbar_new();
1498 gtk_container_add(GTK_CONTAINER(container), toolbar);
1499 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1500 gtk_toolbar_set_orientation(GTK_TOOLBAR(toolbar), GTK_ORIENTATION_HORIZONTAL);
1501 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_BOTH);
1503 for (cur = toolbar_list; cur != NULL; cur = cur->next) {
1505 if (g_ascii_strcasecmp(((ToolbarItem*)cur->data)->file, TOOLBAR_TAG_SEPARATOR) == 0) {
1506 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1510 toolbar_item = g_new0(ToolbarItem, 1);
1511 toolbar_item->index = ((ToolbarItem*)cur->data)->index;
1512 toolbar_item->file = g_strdup(((ToolbarItem*)cur->data)->file);
1513 toolbar_item->text = g_strdup(((ToolbarItem*)cur->data)->text);
1514 toolbar_item->parent = data;
1515 toolbar_item->type = type;
1517 /* collect toolbar items in list to keep track */
1518 toolbar_data->item_list =
1519 g_slist_append(toolbar_data->item_list,
1521 icon_wid = stock_pixmap_widget(container, stock_pixmap_get_icon(toolbar_item->file));
1522 item = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1526 icon_wid, G_CALLBACK(toolbar_buttons_cb),
1529 switch (toolbar_item->index) {
1532 toolbar_data->getall_btn = item;
1533 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1534 toolbar_data->getall_btn,
1535 _("Receive Mail on all Accounts"), NULL);
1536 getall_combo = gtkut_combo_button_create(toolbar_data->getall_btn, NULL, 0,
1537 "<GetAll>", (gpointer)toolbar_item);
1538 gtk_button_set_relief(GTK_BUTTON(getall_combo->arrow),
1540 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar),
1541 GTK_WIDGET_PTR(getall_combo),
1542 _("Receive Mail on selected Account"), "Reply");
1543 toolbar_data->getall_combo = getall_combo;
1546 toolbar_data->get_btn = item;
1547 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1548 toolbar_data->get_btn,
1549 _("Receive Mail on current Account"), NULL);
1552 toolbar_data->send_btn = item;
1553 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1554 toolbar_data->send_btn,
1555 _("Send Queued Messages"), NULL);
1557 case A_COMPOSE_EMAIL:
1558 icon_news = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
1559 item_news = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1563 icon_news, G_CALLBACK(toolbar_buttons_cb),
1565 toolbar_data->compose_mail_btn = item;
1566 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1567 toolbar_data->compose_mail_btn,
1568 _("Compose Email"), NULL);
1569 toolbar_data->compose_news_btn = item_news;
1570 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1571 toolbar_data->compose_news_btn,
1572 _("Compose News"), NULL);
1573 compose_combo = gtkut_combo_button_create(toolbar_data->compose_mail_btn, NULL, 0,
1574 "<Compose>", (gpointer)toolbar_item);
1575 gtk_button_set_relief(GTK_BUTTON(compose_combo->arrow),
1577 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar),
1578 GTK_WIDGET_PTR(compose_combo),
1579 _("Compose with selected Account"), "Compose");
1580 toolbar_data->compose_combo = compose_combo;
1583 icon_ham = stock_pixmap_widget(container, STOCK_PIXMAP_HAM_BTN);
1584 item_ham = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1588 icon_ham, G_CALLBACK(toolbar_buttons_cb),
1590 toolbar_data->learn_spam_btn = item;
1591 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1592 toolbar_data->learn_spam_btn,
1593 _("Learn Spam"), NULL);
1594 toolbar_data->learn_ham_btn = item_ham;
1595 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1596 toolbar_data->learn_ham_btn,
1597 _("Learn Ham"), NULL);
1598 n_menu_entries = sizeof(learn_entries) /
1599 sizeof(learn_entries[0]);
1600 ham_combo = gtkut_combo_button_create(toolbar_data->learn_spam_btn,
1601 learn_entries, n_menu_entries,
1602 "<LearnSpam>", (gpointer)toolbar_item);
1603 gtk_button_set_relief(GTK_BUTTON(ham_combo->arrow),
1605 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar),
1606 GTK_WIDGET_PTR(ham_combo),
1607 _("Learn as..."), "Learn");
1608 toolbar_data->ham_combo = ham_combo;
1610 case A_REPLY_MESSAGE:
1611 toolbar_data->reply_btn = item;
1612 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1613 toolbar_data->reply_btn,
1614 _("Reply to Message"), NULL);
1615 n_menu_entries = sizeof(reply_entries) /
1616 sizeof(reply_entries[0]);
1617 reply_combo = gtkut_combo_button_create(toolbar_data->reply_btn,
1618 reply_entries, n_menu_entries,
1619 "<Reply>", (gpointer)toolbar_item);
1620 gtk_button_set_relief(GTK_BUTTON(reply_combo->arrow),
1622 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar),
1623 GTK_WIDGET_PTR(reply_combo),
1624 _("Reply to Message"), "Reply");
1625 toolbar_data->reply_combo = reply_combo;
1627 case A_REPLY_SENDER:
1628 toolbar_data->replysender_btn = item;
1629 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1630 toolbar_data->replysender_btn,
1631 _("Reply to Sender"), NULL);
1632 n_menu_entries = sizeof(replysender_entries) /
1633 sizeof(replysender_entries[0]);
1634 replysender_combo = gtkut_combo_button_create(toolbar_data->replysender_btn,
1635 replysender_entries, n_menu_entries,
1636 "<ReplySender>", (gpointer)toolbar_item);
1637 gtk_button_set_relief(GTK_BUTTON(replysender_combo->arrow),
1639 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar),
1640 GTK_WIDGET_PTR(replysender_combo),
1641 _("Reply to Sender"), "ReplySender");
1642 toolbar_data->replysender_combo = replysender_combo;
1645 toolbar_data->replyall_btn = item;
1646 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1647 toolbar_data->replyall_btn,
1648 _("Reply to All"), NULL);
1649 n_menu_entries = sizeof(replyall_entries) /
1650 sizeof(replyall_entries[0]);
1651 replyall_combo = gtkut_combo_button_create(toolbar_data->replyall_btn,
1652 replyall_entries, n_menu_entries,
1653 "<ReplyAll>", (gpointer)toolbar_item);
1654 gtk_button_set_relief(GTK_BUTTON(replyall_combo->arrow),
1656 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar),
1657 GTK_WIDGET_PTR(replyall_combo),
1658 _("Reply to All"), "ReplyAll");
1659 toolbar_data->replyall_combo = replyall_combo;
1662 toolbar_data->replylist_btn = item;
1663 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1664 toolbar_data->replylist_btn,
1665 _("Reply to Mailing-list"), NULL);
1666 n_menu_entries = sizeof(replylist_entries) /
1667 sizeof(replylist_entries[0]);
1668 replylist_combo = gtkut_combo_button_create(toolbar_data->replylist_btn,
1669 replylist_entries, n_menu_entries,
1670 "<ReplyList>", (gpointer)toolbar_item);
1671 gtk_button_set_relief(GTK_BUTTON(replylist_combo->arrow),
1673 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar),
1674 GTK_WIDGET_PTR(replylist_combo),
1675 _("Reply to Mailing-list"), "ReplyList");
1676 toolbar_data->replylist_combo = replylist_combo;
1679 toolbar_data->fwd_btn = item;
1680 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1681 toolbar_data->fwd_btn,
1682 _("Forward Message"), NULL);
1683 n_menu_entries = sizeof(forward_entries) /
1684 sizeof(forward_entries[0]);
1685 fwd_combo = gtkut_combo_button_create(toolbar_data->fwd_btn,
1686 forward_entries, n_menu_entries,
1687 "<Forward>", (gpointer)toolbar_item);
1688 gtk_button_set_relief(GTK_BUTTON(fwd_combo->arrow),
1690 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar),
1691 GTK_WIDGET_PTR(fwd_combo),
1692 _("Forward Message"), "Fwd");
1693 toolbar_data->fwd_combo = fwd_combo;
1696 toolbar_data->trash_btn = item;
1697 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1698 toolbar_data->trash_btn,
1699 _("Trash Message"), NULL);
1702 toolbar_data->delete_btn = item;
1703 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1704 toolbar_data->delete_btn,
1705 _("Delete Message"), NULL);
1708 toolbar_data->exec_btn = item;
1709 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1710 toolbar_data->exec_btn,
1711 _("Execute"), NULL);
1714 toolbar_data->prev_btn = item;
1715 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1716 toolbar_data->prev_btn,
1717 _("Go to Previous Unread Message"),
1721 toolbar_data->next_btn = item;
1722 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1723 toolbar_data->next_btn,
1724 _("Go to Next Unread Message"),
1728 /* Compose Toolbar */
1730 toolbar_data->send_btn = item;
1731 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1732 toolbar_data->send_btn,
1733 _("Send Message"), NULL);
1736 toolbar_data->sendl_btn = item;
1737 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1738 toolbar_data->sendl_btn,
1739 _("Put into queue folder and send later"), NULL);
1742 toolbar_data->draft_btn = item;
1743 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1744 toolbar_data->draft_btn,
1745 _("Save to draft folder"), NULL);
1748 toolbar_data->insert_btn = item;
1749 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1750 toolbar_data->insert_btn,
1751 _("Insert file"), NULL);
1754 toolbar_data->attach_btn = item;
1755 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1756 toolbar_data->attach_btn,
1757 _("Attach file"), NULL);
1760 toolbar_data->sig_btn = item;
1761 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1762 toolbar_data->sig_btn,
1763 _("Insert signature"), NULL);
1766 toolbar_data->exteditor_btn = item;
1767 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1768 toolbar_data->exteditor_btn,
1769 _("Edit with external editor"), NULL);
1771 case A_LINEWRAP_CURRENT:
1772 toolbar_data->linewrap_current_btn = item;
1773 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1774 toolbar_data->linewrap_current_btn,
1775 _("Wrap long lines of current paragraph"), NULL);
1777 case A_LINEWRAP_ALL:
1778 toolbar_data->linewrap_all_btn = item;
1779 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1780 toolbar_data->linewrap_all_btn,
1781 _("Wrap all long lines"), NULL);
1784 toolbar_data->addrbook_btn = item;
1785 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1786 toolbar_data->addrbook_btn,
1787 _("Address book"), NULL);
1790 case A_CHECK_SPELLING:
1791 toolbar_data->spellcheck_btn = item;
1792 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1793 toolbar_data->spellcheck_btn,
1794 _("Check spelling"), NULL);
1799 action_item = g_new0(ToolbarSylpheedActions, 1);
1800 action_item->widget = item;
1801 action_item->name = g_strdup(toolbar_item->text);
1803 toolbar_data->action_list =
1804 g_slist_append(toolbar_data->action_list,
1807 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1809 action_item->name, NULL);
1811 gtk_widget_show(item);
1814 toolbar_data->cancel_inc_btn = item;
1815 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1816 toolbar_data->cancel_inc_btn,
1817 _("Cancel receiving"), NULL);
1820 /* find and set the tool tip text */
1821 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
1823 toolbar_ret_descr_from_val
1824 (toolbar_item->index),
1830 toolbar_data->toolbar = toolbar;
1831 if (type == TOOLBAR_MAIN)
1832 activate_compose_button(toolbar_data,
1833 prefs_common.toolbar_style,
1834 toolbar_data->compose_btn_type);
1835 if (type != TOOLBAR_COMPOSE)
1836 activate_learn_button(toolbar_data, prefs_common.toolbar_style,
1839 gtk_widget_show_all(toolbar);
1841 return toolbar_data;
1845 * Free toolbar structures
1847 void toolbar_destroy(Toolbar * toolbar) {
1849 TOOLBAR_DESTROY_ITEMS(toolbar->item_list);
1850 TOOLBAR_DESTROY_ACTIONS(toolbar->action_list);
1853 void toolbar_update(ToolbarType type, gpointer data)
1855 Toolbar *toolbar_data;
1856 GtkWidget *handlebox;
1857 MainWindow *mainwin = (MainWindow*)data;
1858 Compose *compose = (Compose*)data;
1859 MessageView *msgview = (MessageView*)data;
1863 toolbar_data = mainwin->toolbar;
1864 handlebox = mainwin->handlebox;
1866 case TOOLBAR_COMPOSE:
1867 toolbar_data = compose->toolbar;
1868 handlebox = compose->handlebox;
1870 case TOOLBAR_MSGVIEW:
1871 toolbar_data = msgview->toolbar;
1872 handlebox = msgview->handlebox;
1878 gtk_container_remove(GTK_CONTAINER(handlebox),
1879 GTK_WIDGET(toolbar_data->toolbar));
1881 toolbar_init(toolbar_data);
1882 toolbar_data = toolbar_create(type, handlebox, data);
1885 mainwin->toolbar = toolbar_data;
1887 case TOOLBAR_COMPOSE:
1888 compose->toolbar = toolbar_data;
1890 case TOOLBAR_MSGVIEW:
1891 msgview->toolbar = toolbar_data;
1895 toolbar_style(type, prefs_common.toolbar_style, data);
1897 if (type == TOOLBAR_MAIN) {
1898 toolbar_main_set_sensitive((MainWindow*)data);
1899 account_set_menu_only_toolbar();
1903 #define GTK_BUTTON_SET_SENSITIVE(widget,sensitive) { \
1904 gboolean in_btn = FALSE; \
1905 if (GTK_IS_BUTTON(widget)) \
1906 in_btn = GTK_BUTTON(widget)->in_button; \
1907 gtk_widget_set_sensitive(widget, sensitive); \
1908 if (GTK_IS_BUTTON(widget)) \
1909 GTK_BUTTON(widget)->in_button = in_btn; \
1912 void toolbar_main_set_sensitive(gpointer data)
1914 SensitiveCond state;
1916 MainWindow *mainwin = (MainWindow*)data;
1917 Toolbar *toolbar = mainwin->toolbar;
1919 GSList *entry_list = NULL;
1921 typedef struct _Entry Entry;
1928 #define SET_WIDGET_COND(w, c) \
1930 Entry *e = g_new0(Entry, 1); \
1933 entry_list = g_slist_append(entry_list, e); \
1937 if (toolbar->get_btn)
1938 SET_WIDGET_COND(toolbar->get_btn,
1939 M_HAVE_ACCOUNT|M_UNLOCKED);
1941 if (toolbar->getall_btn) {
1942 SET_WIDGET_COND(toolbar->getall_btn,
1943 M_HAVE_ACCOUNT|M_UNLOCKED);
1944 SET_WIDGET_COND(GTK_WIDGET_PTR(toolbar->getall_combo),
1945 M_HAVE_ACCOUNT|M_UNLOCKED);
1947 if (toolbar->send_btn) {
1948 SET_WIDGET_COND(toolbar->send_btn,
1949 M_HAVE_QUEUED_MAILS);
1951 if (toolbar->compose_mail_btn) {
1952 SET_WIDGET_COND(GTK_WIDGET_PTR(toolbar->compose_combo),
1954 SET_WIDGET_COND(toolbar->compose_news_btn,
1957 if (toolbar->reply_btn) {
1958 SET_WIDGET_COND(toolbar->reply_btn,
1959 M_HAVE_ACCOUNT|M_TARGET_EXIST);
1960 SET_WIDGET_COND(GTK_WIDGET_PTR(toolbar->reply_combo),
1961 M_HAVE_ACCOUNT|M_TARGET_EXIST);
1963 if (toolbar->replyall_btn) {
1964 SET_WIDGET_COND(toolbar->replyall_btn,
1965 M_HAVE_ACCOUNT|M_TARGET_EXIST);
1966 SET_WIDGET_COND(GTK_WIDGET_PTR(toolbar->replyall_combo),
1967 M_HAVE_ACCOUNT|M_TARGET_EXIST);
1969 if (toolbar->replylist_btn) {
1970 SET_WIDGET_COND(toolbar->replylist_btn,
1971 M_HAVE_ACCOUNT|M_TARGET_EXIST);
1972 SET_WIDGET_COND(GTK_WIDGET_PTR(toolbar->replylist_combo),
1973 M_HAVE_ACCOUNT|M_TARGET_EXIST);
1975 if (toolbar->replysender_btn) {
1976 SET_WIDGET_COND(toolbar->replysender_btn,
1977 M_HAVE_ACCOUNT|M_TARGET_EXIST);
1978 SET_WIDGET_COND(GTK_WIDGET_PTR(toolbar->replysender_combo),
1979 M_HAVE_ACCOUNT|M_TARGET_EXIST);
1981 if (toolbar->fwd_btn) {
1982 SET_WIDGET_COND(toolbar->fwd_btn,
1983 M_HAVE_ACCOUNT|M_TARGET_EXIST);
1984 SET_WIDGET_COND(GTK_WIDGET_PTR(toolbar->fwd_combo),
1985 M_HAVE_ACCOUNT|M_TARGET_EXIST);
1987 if (toolbar->fwd_combo) {
1988 GtkWidget *submenu = gtk_item_factory_get_widget(toolbar->fwd_combo->factory, "/Redirect");
1989 SET_WIDGET_COND(submenu,
1990 M_HAVE_ACCOUNT|M_TARGET_EXIST);
1993 if (prefs_common.next_unread_msg_dialog == NEXTUNREADMSGDIALOG_ASSUME_NO) {
1994 SET_WIDGET_COND(toolbar->next_btn, M_MSG_EXIST);
1996 SET_WIDGET_COND(toolbar->next_btn, 0);
1999 if (toolbar->trash_btn)
2000 SET_WIDGET_COND(toolbar->trash_btn,
2001 M_TARGET_EXIST|M_ALLOW_DELETE);
2003 if (toolbar->delete_btn)
2004 SET_WIDGET_COND(toolbar->delete_btn,
2005 M_TARGET_EXIST|M_ALLOW_DELETE);
2007 if (toolbar->exec_btn)
2008 SET_WIDGET_COND(toolbar->exec_btn,
2011 if (toolbar->learn_ham_btn)
2012 SET_WIDGET_COND(toolbar->learn_ham_btn,
2013 M_TARGET_EXIST|M_CAN_LEARN_SPAM);
2015 if (toolbar->learn_spam_btn)
2016 SET_WIDGET_COND(toolbar->learn_spam_btn,
2017 M_TARGET_EXIST|M_CAN_LEARN_SPAM);
2019 if (toolbar->ham_combo)
2020 SET_WIDGET_COND(GTK_WIDGET_PTR(toolbar->ham_combo),
2021 M_TARGET_EXIST|M_CAN_LEARN_SPAM);
2023 if (toolbar->cancel_inc_btn)
2024 SET_WIDGET_COND(toolbar->cancel_inc_btn,
2027 for (cur = toolbar->action_list; cur != NULL; cur = cur->next) {
2028 ToolbarSylpheedActions *act = (ToolbarSylpheedActions*)cur->data;
2030 SET_WIDGET_COND(act->widget, M_TARGET_EXIST|M_UNLOCKED);
2033 #undef SET_WIDGET_COND
2035 state = main_window_get_current_state(mainwin);
2037 for (cur = entry_list; cur != NULL; cur = cur->next) {
2038 Entry *e = (Entry*) cur->data;
2040 if (e->widget != NULL) {
2041 sensitive = ((e->cond & state) == e->cond);
2042 GTK_BUTTON_SET_SENSITIVE(e->widget, sensitive);
2046 while (entry_list != NULL) {
2047 Entry *e = (Entry*) entry_list->data;
2050 entry_list = g_slist_remove(entry_list, e);
2053 g_slist_free(entry_list);
2055 activate_compose_button(toolbar,
2056 prefs_common.toolbar_style,
2057 toolbar->compose_btn_type);
2061 void toolbar_comp_set_sensitive(gpointer data, gboolean sensitive)
2063 Compose *compose = (Compose*)data;
2064 GSList *items = compose->toolbar->action_list;
2066 if (compose->toolbar->send_btn)
2067 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->send_btn, sensitive);
2068 if (compose->toolbar->sendl_btn)
2069 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->sendl_btn, sensitive);
2070 if (compose->toolbar->draft_btn )
2071 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->draft_btn , sensitive);
2072 if (compose->toolbar->insert_btn )
2073 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->insert_btn , sensitive);
2074 if (compose->toolbar->attach_btn)
2075 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->attach_btn, sensitive);
2076 if (compose->toolbar->sig_btn)
2077 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->sig_btn, sensitive);
2078 if (compose->toolbar->exteditor_btn)
2079 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->exteditor_btn, sensitive);
2080 if (compose->toolbar->linewrap_current_btn)
2081 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->linewrap_current_btn, sensitive);
2082 if (compose->toolbar->linewrap_all_btn)
2083 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->linewrap_all_btn, sensitive);
2084 if (compose->toolbar->addrbook_btn)
2085 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->addrbook_btn, sensitive);
2087 if (compose->toolbar->spellcheck_btn)
2088 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->spellcheck_btn, sensitive);
2090 for (; items != NULL; items = g_slist_next(items)) {
2091 ToolbarSylpheedActions *item = (ToolbarSylpheedActions *)items->data;
2092 GTK_BUTTON_SET_SENSITIVE(item->widget, sensitive);
2097 * Initialize toolbar structure
2099 void toolbar_init(Toolbar * toolbar) {
2101 toolbar->toolbar = NULL;
2102 toolbar->get_btn = NULL;
2103 toolbar->getall_btn = NULL;
2104 toolbar->getall_combo = NULL;
2105 toolbar->send_btn = NULL;
2106 toolbar->compose_mail_btn = NULL;
2107 toolbar->compose_news_btn = NULL;
2108 toolbar->compose_combo = NULL;
2109 toolbar->reply_btn = NULL;
2110 toolbar->replysender_btn = NULL;
2111 toolbar->replyall_btn = NULL;
2112 toolbar->replylist_btn = NULL;
2113 toolbar->fwd_btn = NULL;
2114 toolbar->trash_btn = NULL;
2115 toolbar->delete_btn = NULL;
2116 toolbar->prev_btn = NULL;
2117 toolbar->next_btn = NULL;
2118 toolbar->exec_btn = NULL;
2120 /* compose buttons */
2121 toolbar->sendl_btn = NULL;
2122 toolbar->draft_btn = NULL;
2123 toolbar->insert_btn = NULL;
2124 toolbar->attach_btn = NULL;
2125 toolbar->sig_btn = NULL;
2126 toolbar->exteditor_btn = NULL;
2127 toolbar->linewrap_current_btn = NULL;
2128 toolbar->linewrap_all_btn = NULL;
2129 toolbar->addrbook_btn = NULL;
2131 toolbar->spellcheck_btn = NULL;
2134 toolbar_destroy(toolbar);
2139 static void toolbar_reply(gpointer data, guint action)
2141 ToolbarItem *toolbar_item = (ToolbarItem*)data;
2142 MainWindow *mainwin;
2143 MessageView *msgview;
2144 GSList *msginfo_list = NULL;
2146 g_return_if_fail(toolbar_item != NULL);
2148 switch (toolbar_item->type) {
2150 mainwin = (MainWindow*)toolbar_item->parent;
2151 msginfo_list = summary_get_selection(mainwin->summaryview);
2152 msgview = (MessageView*)mainwin->messageview;
2154 case TOOLBAR_MSGVIEW:
2155 msgview = (MessageView*)toolbar_item->parent;
2156 g_return_if_fail(msgview != NULL);
2157 msginfo_list = g_slist_append(msginfo_list, msgview->msginfo);
2163 g_return_if_fail(msgview != NULL);
2164 g_return_if_fail(msginfo_list != NULL);
2165 compose_reply_from_messageview(msgview, msginfo_list, action);
2166 g_slist_free(msginfo_list);
2168 /* TODO: update reply state ion summaryview */
2172 /* exported functions */
2174 void inc_mail_cb(gpointer data, guint action, GtkWidget *widget)
2176 MainWindow *mainwin = (MainWindow*)data;
2178 inc_mail(mainwin, prefs_common.newmail_notify_manu);
2181 void inc_all_account_mail_cb(gpointer data, guint action, GtkWidget *widget)
2183 MainWindow *mainwin = (MainWindow*)data;
2185 inc_all_account_mail(mainwin, FALSE, prefs_common.newmail_notify_manu);
2188 void send_queue_cb(gpointer data, guint action, GtkWidget *widget)
2192 gboolean got_error = FALSE;
2193 gchar *errstr = NULL;
2195 if (prefs_common.work_offline)
2196 if (alertpanel(_("Offline warning"),
2197 _("You're working offline. Override?"),
2198 GTK_STOCK_NO, GTK_STOCK_YES,
2199 NULL) != G_ALERTALTERNATE)
2202 /* ask for confirmation before sending queued messages only
2203 in online mode and if there is at least one message queued
2204 in any of the folder queue
2206 if (prefs_common.confirm_send_queued_messages) {
2208 /* check if there's a queued message */
2209 for (list = folder_get_list(); !found && list != NULL; list = list->next) {
2210 Folder *folder = list->data;
2212 found = !procmsg_queue_is_empty(folder->queue);
2214 /* if necessary, ask for confirmation before sending */
2215 if (found && !prefs_common.work_offline) {
2216 if (alertpanel(_("Send queued messages"),
2217 _("Send all queued messages?"),
2218 GTK_STOCK_CANCEL, _("_Send"),
2219 NULL) != G_ALERTALTERNATE)
2224 for (list = folder_get_list(); list != NULL; list = list->next) {
2225 Folder *folder = list->data;
2227 if (folder->queue) {
2228 if (procmsg_send_queue(folder->queue,
2229 prefs_common.savemsg,
2236 alertpanel_error_log(_("Some errors occurred while "
2237 "sending queued messages."));
2239 gchar *tmp = g_strdup_printf(_("Some errors occurred "
2240 "while sending queued messages:\n%s"), errstr);
2242 alertpanel_error_log(tmp);
2248 void compose_mail_cb(gpointer data, guint action, GtkWidget *widget)
2250 MainWindow *mainwin = (MainWindow*)data;
2251 PrefsAccount *ac = NULL;
2252 FolderItem *item = mainwin->summaryview->folder_item;
2257 ac = account_find_from_item(item);
2258 if (ac && ac->protocol != A_NNTP) {
2259 compose_new_with_folderitem(ac, item, NULL); /* CLAWS */
2265 * CLAWS - use current account
2267 if (cur_account && (cur_account->protocol != A_NNTP)) {
2268 compose_new_with_folderitem(cur_account, item, NULL);
2273 * CLAWS - just get the first one
2275 list = account_get_list();
2276 for (cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2277 ac = (PrefsAccount *) cur->data;
2278 if (ac->protocol != A_NNTP) {
2279 compose_new_with_folderitem(ac, item, NULL);
2285 void compose_news_cb(gpointer data, guint action, GtkWidget *widget)
2287 MainWindow *mainwin = (MainWindow*)data;
2288 PrefsAccount * ac = NULL;
2292 if (mainwin->summaryview->folder_item) {
2293 ac = mainwin->summaryview->folder_item->folder->account;
2294 if (ac && ac->protocol == A_NNTP) {
2295 compose_new_with_folderitem(ac,
2296 mainwin->summaryview->folder_item, NULL);
2301 list = account_get_list();
2302 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2303 ac = (PrefsAccount *) cur->data;
2304 if (ac->protocol == A_NNTP) {
2305 compose_new_with_folderitem(ac,
2306 mainwin->summaryview->folder_item, NULL);