2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2001-2013 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 3 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, see <http://www.gnu.org/licenses/>.
21 * General functions for accessing address book files.
26 #include "claws-features.h"
32 #include <glib/gi18n.h>
41 #include "mainwindow.h"
42 #include "summaryview.h"
47 #include "prefs_gtk.h"
49 #include "stock_pixmap.h"
50 #include "manage_window.h"
56 #include "prefs_actions.h"
57 #include "prefs_common.h"
58 #include "prefs_toolbar.h"
59 #include "alertpanel.h"
62 #include "send_message.h"
63 #ifndef USE_ALT_ADDRBOOK
64 #include "addressbook.h"
66 #include "addressbook-dbus.h"
70 #define TOOLBAR_TAG_INDEX "toolbar"
71 #define TOOLBAR_TAG_ITEM "item"
72 #define TOOLBAR_TAG_SEPARATOR "separator"
74 #define TOOLBAR_ICON_FILE "file"
75 #define TOOLBAR_ICON_TEXT "text"
76 #define TOOLBAR_ICON_ACTION "action"
78 static void toolbar_init(Toolbar * toolbar);
79 static gboolean toolbar_is_duplicate (gint action,
81 static void toolbar_parse_item (XMLFile *file,
84 static gint toolbar_ret_val_from_text (const gchar *text);
85 static gchar *toolbar_ret_text_from_val (gint val);
87 static void toolbar_set_default_main (void);
88 static void toolbar_set_default_compose (void);
89 static void toolbar_set_default_msgview (void);
91 static void toolbar_style (ToolbarType type,
95 static MainWindow *get_mainwin (gpointer data);
96 static void activate_compose_button (Toolbar *toolbar,
98 ComposeButtonType type);
100 /* toolbar callbacks */
101 static void toolbar_reply (gpointer data,
103 static void toolbar_learn (gpointer data,
105 static void toolbar_delete_cb (GtkWidget *widget,
107 static void toolbar_trash_cb (GtkWidget *widget,
110 static void toolbar_compose_cb (GtkWidget *widget,
113 static void toolbar_learn_cb (GtkWidget *widget,
116 static void toolbar_reply_cb (GtkWidget *widget,
119 static void toolbar_reply_to_all_cb (GtkWidget *widget,
122 static void toolbar_reply_to_list_cb (GtkWidget *widget,
125 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
128 static void toolbar_forward_cb (GtkWidget *widget,
131 static void toolbar_prev_unread_cb (GtkWidget *widget,
133 static void toolbar_next_unread_cb (GtkWidget *widget,
136 static void toolbar_ignore_thread_cb (GtkWidget *widget,
139 static void toolbar_watch_thread_cb (GtkWidget *widget,
142 static void toolbar_mark_cb (GtkWidget *widget,
145 static void toolbar_unmark_cb (GtkWidget *widget,
148 static void toolbar_lock_cb (GtkWidget *widget,
151 static void toolbar_ulock_cb (GtkWidget *widget,
154 static void toolbar_all_read_cb (GtkWidget *widget,
157 static void toolbar_all_unread_cb (GtkWidget *widget,
160 static void toolbar_read_cb (GtkWidget *widget,
163 static void toolbar_unread_cb (GtkWidget *widget,
166 static void toolbar_print_cb (GtkWidget *widget,
169 static void toolbar_actions_execute_cb (GtkWidget *widget,
171 static void toolbar_plugins_execute_cb (GtkWidget *widget,
175 static void toolbar_send_cb (GtkWidget *widget,
177 static void toolbar_send_later_cb (GtkWidget *widget,
179 static void toolbar_draft_cb (GtkWidget *widget,
181 static void toolbar_close_cb (GtkWidget *widget,
183 static void toolbar_preferences_cb (GtkWidget *widget,
185 static void toolbar_open_mail_cb (GtkWidget *widget,
187 static void toolbar_insert_cb (GtkWidget *widget,
189 static void toolbar_attach_cb (GtkWidget *widget,
191 static void toolbar_sig_cb (GtkWidget *widget,
193 static void toolbar_ext_editor_cb (GtkWidget *widget,
195 static void toolbar_linewrap_current_cb (GtkWidget *widget,
197 static void toolbar_linewrap_all_cb (GtkWidget *widget,
199 static void toolbar_addrbook_cb (GtkWidget *widget,
202 static void toolbar_check_spelling_cb (GtkWidget *widget,
205 static void toolbar_cancel_inc_cb (GtkWidget *widget,
207 static void toolbar_cancel_send_cb (GtkWidget *widget,
209 static void toolbar_cancel_all_cb (GtkWidget *widget,
215 } toolbar_text [] = {
216 { "A_RECEIVE_ALL", N_("Receive Mail from all Accounts") },
217 { "A_RECEIVE_CUR", N_("Receive Mail from current Account") },
218 { "A_SEND_QUEUED", N_("Send Queued Messages") },
219 { "A_COMPOSE_EMAIL", N_("Compose Email") },
220 { "A_COMPOSE_NEWS", N_("Compose News") },
221 { "A_REPLY_MESSAGE", N_("Reply to Message") },
222 { "A_REPLY_SENDER", N_("Reply to Sender") },
223 { "A_REPLY_ALL", N_("Reply to All") },
224 { "A_REPLY_ML", N_("Reply to Mailing-list") },
225 { "A_OPEN_MAIL", N_("Open email") },
226 { "A_FORWARD", N_("Forward Message") },
227 { "A_TRASH", N_("Trash Message") },
228 { "A_DELETE_REAL", N_("Delete Message") },
229 { "A_EXECUTE", N_("Execute") },
230 { "A_GOTO_PREV", N_("Go to Previous Unread Message") },
231 { "A_GOTO_NEXT", N_("Go to Next Unread Message") },
233 { "A_IGNORE_THREAD", N_("Ignore thread") },
234 { "A_WATCH_THREAD", N_("Watch thread") },
235 { "A_MARK", N_("Mark Message") },
236 { "A_UNMARK", N_("Unmark Message") },
237 { "A_LOCK", N_("Lock Message") },
238 { "A_UNLOCK", N_("Unlock Message") },
239 { "A_ALL_READ", N_("Mark all Messages as read") },
240 { "A_ALL_UNREAD", N_("Mark all Messages as unread") },
241 { "A_READ", N_("Mark Message as read") },
242 { "A_UNREAD", N_("Mark Message as unread") },
244 { "A_PRINT", N_("Print") },
245 { "A_LEARN_SPAM", N_("Learn Spam or Ham") },
246 { "A_GO_FOLDERS", N_("Open folder/Go to folder list") },
247 { "A_PREFERENCES", N_("Preferences") },
249 { "A_SEND", N_("Send Message") },
250 { "A_SEND_LATER", N_("Put into queue folder and send later") },
251 { "A_DRAFT", N_("Save to draft folder") },
252 { "A_INSERT", N_("Insert file") },
253 { "A_ATTACH", N_("Attach file") },
254 { "A_SIG", N_("Insert signature") },
255 { "A_REP_SIG", N_("Replace signature") },
256 { "A_EXTEDITOR", N_("Edit with external editor") },
257 { "A_LINEWRAP_CURRENT", N_("Wrap long lines of current paragraph") },
258 { "A_LINEWRAP_ALL", N_("Wrap all long lines") },
259 { "A_ADDRBOOK", N_("Address book") },
261 { "A_CHECK_SPELLING", N_("Check spelling") },
263 { "A_CLAWS_ACTIONS", N_("Claws Mail Actions Feature") },
264 { "A_CANCEL_INC", N_("Cancel receiving") },
265 { "A_CANCEL_SEND", N_("Cancel sending") },
266 { "A_CANCEL_ALL", N_("Cancel receiving/sending") },
267 { "A_CLOSE", N_("Close window") },
268 { "A_SEPARATOR", N_("Separator") },
269 { "A_CLAWS_PLUGINS", N_("Claws Mail Plugins") },
272 /* struct holds configuration files and a list of
273 * currently active toolbar items
274 * TOOLBAR_MAIN, TOOLBAR_COMPOSE and TOOLBAR_MSGVIEW
278 const gchar *conf_file;
280 } toolbar_config[NUM_TOOLBARS] = {
281 { "toolbar_main.xml", NULL},
282 { "toolbar_compose.xml", NULL},
283 { "toolbar_msgview.xml", NULL}
286 gint toolbar_ret_val_from_descr(const gchar *descr)
290 for (i = 0; i < N_ACTION_VAL; i++) {
291 if (g_utf8_collate(gettext(toolbar_text[i].descr), descr) == 0)
298 gchar *toolbar_ret_descr_from_val(gint val)
300 cm_return_val_if_fail(val >=0 && val < N_ACTION_VAL, NULL);
302 return gettext(toolbar_text[val].descr);
305 static gint toolbar_ret_val_from_text(const gchar *text)
309 for (i = 0; i < N_ACTION_VAL; i++) {
310 if (g_utf8_collate(toolbar_text[i].index_str, text) == 0)
317 static gchar *toolbar_ret_text_from_val(gint val)
319 cm_return_val_if_fail(val >=0 && val < N_ACTION_VAL, NULL);
321 return toolbar_text[val].index_str;
324 static gboolean toolbar_is_duplicate(gint action, ToolbarType source)
328 if ((action == A_SEPARATOR) || (action == A_CLAWS_ACTIONS) || (action == A_CLAWS_PLUGINS))
331 for (cur = toolbar_config[source].item_list; cur != NULL; cur = cur->next) {
332 ToolbarItem *item = (ToolbarItem*) cur->data;
334 if (item->index == action)
340 /* depending on toolbar type this function
341 returns a list of available toolbar events being
342 displayed by prefs_toolbar
344 GList *toolbar_get_action_items(ToolbarType source)
349 if (source == TOOLBAR_MAIN) {
350 gint main_items[] = {
351 A_RECEIVE_ALL, A_RECEIVE_CUR, A_SEND_QUEUED,
352 A_COMPOSE_EMAIL, A_REPLY_MESSAGE, A_REPLY_SENDER,
353 A_REPLY_ALL, A_REPLY_ML, A_OPEN_MAIL, A_FORWARD,
354 A_TRASH, A_DELETE_REAL, A_EXECUTE, A_GOTO_PREV,
355 A_GOTO_NEXT, A_IGNORE_THREAD, A_WATCH_THREAD, A_MARK,
356 A_UNMARK, A_LOCK, A_UNLOCK, A_ALL_READ,
357 A_ALL_UNREAD, A_READ, A_UNREAD, A_PRINT,
358 A_ADDRBOOK, A_LEARN_SPAM, A_GO_FOLDERS,
359 A_CANCEL_INC, A_CANCEL_SEND, A_CANCEL_ALL, A_PREFERENCES };
361 for (i = 0; i < sizeof main_items / sizeof main_items[0]; i++) {
362 items = g_list_append(items, gettext(toolbar_text[main_items[i]].descr));
365 else if (source == TOOLBAR_COMPOSE) {
366 gint comp_items[] = {
367 A_SEND, A_SEND_LATER, A_DRAFT,
368 A_INSERT, A_ATTACH, A_SIG,
369 A_REP_SIG, A_EXTEDITOR, A_LINEWRAP_CURRENT,
370 A_LINEWRAP_ALL, A_ADDRBOOK,
376 for (i = 0; i < sizeof comp_items / sizeof comp_items[0]; i++)
377 items = g_list_append(items, gettext(toolbar_text[comp_items[i]].descr));
379 else if (source == TOOLBAR_MSGVIEW) {
380 gint msgv_items[] = {
381 A_COMPOSE_EMAIL, A_REPLY_MESSAGE, A_REPLY_SENDER,
382 A_REPLY_ALL, A_REPLY_ML, A_FORWARD,
383 A_TRASH, A_DELETE_REAL, A_GOTO_PREV, A_GOTO_NEXT,
384 A_ADDRBOOK, A_LEARN_SPAM, A_CLOSE };
386 for (i = 0; i < sizeof msgv_items / sizeof msgv_items[0]; i++)
387 items = g_list_append(items, gettext(toolbar_text[msgv_items[i]].descr));
393 static void toolbar_parse_item(XMLFile *file, ToolbarType source)
397 ToolbarItem *item = NULL;
398 gboolean rewrite = FALSE;
400 attr = xml_get_current_tag_attr(file);
401 item = g_new0(ToolbarItem, 1);
403 name = ((XMLAttr *)attr->data)->name;
404 value = ((XMLAttr *)attr->data)->value;
406 if (g_utf8_collate(name, TOOLBAR_ICON_FILE) == 0)
407 item->file = g_strdup (value);
408 else if (g_utf8_collate(name, TOOLBAR_ICON_TEXT) == 0)
409 item->text = g_strdup (*value ? gettext(value):"");
410 else if (g_utf8_collate(name, TOOLBAR_ICON_ACTION) == 0)
411 item->index = toolbar_ret_val_from_text(value);
412 if (item->index == -1 && !strcmp(value, "A_DELETE")) {
414 item->index = A_TRASH;
416 item->file = g_strdup("trash_btn");
418 item->text = g_strdup(C_("Toolbar", "Trash"));
421 if (item->index == -1 && !strcmp(value, "A_SYL_ACTIONS")) {
423 item->index = A_CLAWS_ACTIONS;
426 attr = g_list_next(attr);
428 if (item->index != -1) {
430 if (!toolbar_is_duplicate(item->index, source))
431 toolbar_config[source].item_list = g_slist_append(toolbar_config[source].item_list,
435 toolbar_save_config_file(source);
439 const gchar *toolbar_get_short_text(int action) {
441 case A_GO_FOLDERS: return _("Folders");
442 case A_OPEN_MAIL: return _("Open");
443 case A_RECEIVE_ALL: return _("Get Mail");
444 case A_RECEIVE_CUR: return _("Get");
445 case A_SEND_QUEUED: return _("Send");
446 case A_COMPOSE_EMAIL: return C_("Toolbar", "Compose");
447 case A_COMPOSE_NEWS: return C_("Toolbar", "Compose");
448 case A_REPLY_MESSAGE: return _("Reply");
449 case A_REPLY_ALL: return _("All");
450 case A_REPLY_SENDER: return C_("Toolbar", "Sender");
451 case A_REPLY_ML: return _("List");
452 case A_FORWARD: return _("Forward");
453 case A_TRASH: return C_("Toolbar", "Trash");
454 case A_DELETE_REAL: return _("Delete");
455 case A_LEARN_SPAM: return _("Spam");
456 case A_GOTO_PREV: return _("Prev");
457 case A_GOTO_NEXT: return _("Next");
458 case A_IGNORE_THREAD: return _("Ignore thread");
459 case A_WATCH_THREAD: return _("Watch thread");
460 case A_MARK: return _("Mark");
461 case A_UNMARK: return _("Unmark");
462 case A_LOCK: return _("Lock");
463 case A_UNLOCK: return _("Unlock");
464 case A_ALL_READ: return _("All read");
465 case A_ALL_UNREAD: return _("All unread");
466 case A_READ: return _("Read");
467 case A_UNREAD: return _("Unread");
468 case A_PRINT: return _("Print");
469 case A_CLOSE: return _("Close");
470 case A_PREFERENCES: return _("Preferences");
471 case A_SEND: return _("Send");
472 case A_SEND_LATER: return _("Send later");
473 case A_DRAFT: return _("Draft");
474 case A_INSERT: return _("Insert");
475 case A_ATTACH: return _("Attach");
476 case A_SIG: return _("Insert sig.");
477 case A_REP_SIG: return _("Replace sig.");
478 case A_EXTEDITOR: return _("Edit");
479 case A_LINEWRAP_CURRENT:return _("Wrap para.");
480 case A_LINEWRAP_ALL: return _("Wrap all");
481 case A_ADDRBOOK: return _("Address");
482 case A_CANCEL_INC: return _("Stop");
483 case A_CANCEL_SEND: return _("Stop");
484 case A_CANCEL_ALL: return _("Stop all");
485 case A_EXECUTE: return _("Execute");
487 case A_CHECK_SPELLING: return _("Check spelling");
493 gint toolbar_get_icon(int action) {
495 case A_GO_FOLDERS: return STOCK_PIXMAP_GO_FOLDERS;
496 case A_OPEN_MAIL: return STOCK_PIXMAP_OPEN_MAIL;
497 case A_RECEIVE_ALL: return STOCK_PIXMAP_MAIL_RECEIVE_ALL;
498 case A_RECEIVE_CUR: return STOCK_PIXMAP_MAIL_RECEIVE;
499 case A_SEND_QUEUED: return STOCK_PIXMAP_MAIL_SEND_QUEUE;
500 case A_COMPOSE_EMAIL: return STOCK_PIXMAP_MAIL_COMPOSE;
501 case A_COMPOSE_NEWS: return STOCK_PIXMAP_NEWS_COMPOSE;
502 case A_REPLY_MESSAGE: return STOCK_PIXMAP_MAIL_REPLY;
503 case A_REPLY_ALL: return STOCK_PIXMAP_MAIL_REPLY_TO_ALL;
504 case A_REPLY_SENDER: return STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR;
505 case A_REPLY_ML: return STOCK_PIXMAP_MAIL_REPLY_TO_LIST;
506 case A_FORWARD: return STOCK_PIXMAP_MAIL_FORWARD;
507 case A_TRASH: return STOCK_PIXMAP_TRASH;
508 case A_DELETE_REAL: return STOCK_PIXMAP_DELETE;
509 case A_LEARN_SPAM: return STOCK_PIXMAP_SPAM_BTN;
510 case A_GOTO_PREV: return STOCK_PIXMAP_UP_ARROW;
511 case A_GOTO_NEXT: return STOCK_PIXMAP_DOWN_ARROW;
512 case A_IGNORE_THREAD: return STOCK_PIXMAP_MARK_IGNORETHREAD;
513 case A_WATCH_THREAD: return STOCK_PIXMAP_MARK_WATCHTHREAD;
514 case A_MARK: return STOCK_PIXMAP_MARK_MARK;
515 case A_UNMARK: return STOCK_PIXMAP_MARK_UNMARK;
516 case A_LOCK: return STOCK_PIXMAP_MARK_LOCKED;
517 case A_UNLOCK: return STOCK_PIXMAP_MARK_UNLOCKED;
518 case A_ALL_READ: return STOCK_PIXMAP_MARK_ALLREAD;
519 case A_ALL_UNREAD: return STOCK_PIXMAP_MARK_ALLUNREAD;
520 case A_READ: return STOCK_PIXMAP_MARK_READ;
521 case A_UNREAD: return STOCK_PIXMAP_MARK_UNREAD;
522 case A_PRINT: return STOCK_PIXMAP_PRINTER;
523 case A_CLOSE: return STOCK_PIXMAP_CLOSE;
524 case A_PREFERENCES: return STOCK_PIXMAP_PREFERENCES;
525 case A_SEND: return STOCK_PIXMAP_MAIL_SEND;
526 case A_SEND_LATER: return STOCK_PIXMAP_MAIL_SEND_QUEUE;
527 case A_DRAFT: return STOCK_PIXMAP_MAIL;
528 case A_INSERT: return STOCK_PIXMAP_INSERT_FILE;
529 case A_ATTACH: return STOCK_PIXMAP_MAIL_ATTACH;
530 case A_SIG: return STOCK_PIXMAP_MAIL_SIGN;
531 case A_REP_SIG: return STOCK_PIXMAP_MAIL_SIGN;
532 case A_EXTEDITOR: return STOCK_PIXMAP_EDIT_EXTERN;
533 case A_LINEWRAP_CURRENT:return STOCK_PIXMAP_LINEWRAP_CURRENT;
534 case A_LINEWRAP_ALL: return STOCK_PIXMAP_LINEWRAP_ALL;
535 case A_ADDRBOOK: return STOCK_PIXMAP_ADDRESS_BOOK;
536 case A_CANCEL_INC: return STOCK_PIXMAP_CANCEL;
537 case A_CANCEL_SEND: return STOCK_PIXMAP_CANCEL;
538 case A_CANCEL_ALL: return STOCK_PIXMAP_CANCEL;
539 case A_EXECUTE: return STOCK_PIXMAP_EXEC;
541 case A_CHECK_SPELLING: return STOCK_PIXMAP_CHECK_SPELLING;
547 static void toolbar_set_default_main(void)
551 } default_toolbar[] = {
579 for (i = 0; i < sizeof(default_toolbar) / sizeof(default_toolbar[0]); i++) {
581 ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
583 if (default_toolbar[i].action != A_SEPARATOR) {
586 if (toolbar_get_icon(default_toolbar[i].action) > -1) {
587 file = stock_pixmap_get_name((StockPixmap)toolbar_get_icon(default_toolbar[i].action));
590 toolbar_item->file = g_strdup(file);
591 toolbar_item->index = default_toolbar[i].action;
592 toolbar_item->text = g_strdup(toolbar_get_short_text(default_toolbar[i].action));
595 toolbar_item->file = g_strdup(TOOLBAR_TAG_SEPARATOR);
596 toolbar_item->index = A_SEPARATOR;
599 if (toolbar_item->index != -1) {
600 if ( !toolbar_is_duplicate(toolbar_item->index, TOOLBAR_MAIN))
601 toolbar_config[TOOLBAR_MAIN].item_list =
602 g_slist_append(toolbar_config[TOOLBAR_MAIN].item_list, toolbar_item);
607 static void toolbar_set_default_compose(void)
611 } default_toolbar[] = {
630 for (i = 0; i < sizeof(default_toolbar) / sizeof(default_toolbar[0]); i++) {
632 ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
634 if (default_toolbar[i].action != A_SEPARATOR) {
637 if (toolbar_get_icon(default_toolbar[i].action) > -1) {
638 file = stock_pixmap_get_name((StockPixmap)toolbar_get_icon(default_toolbar[i].action));
640 toolbar_item->file = g_strdup(file);
641 toolbar_item->index = default_toolbar[i].action;
642 toolbar_item->text = g_strdup(toolbar_get_short_text(default_toolbar[i].action));
645 toolbar_item->file = g_strdup(TOOLBAR_TAG_SEPARATOR);
646 toolbar_item->index = A_SEPARATOR;
649 if (toolbar_item->index != -1) {
650 if ( !toolbar_is_duplicate(toolbar_item->index, TOOLBAR_COMPOSE))
651 toolbar_config[TOOLBAR_COMPOSE].item_list =
652 g_slist_append(toolbar_config[TOOLBAR_COMPOSE].item_list, toolbar_item);
657 static void toolbar_set_default_msgview(void)
661 } default_toolbar[] = {
680 for (i = 0; i < sizeof(default_toolbar) / sizeof(default_toolbar[0]); i++) {
682 ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
684 if (default_toolbar[i].action != A_SEPARATOR) {
686 if (toolbar_get_icon(default_toolbar[i].action) > -1) {
687 file = stock_pixmap_get_name((StockPixmap)toolbar_get_icon(default_toolbar[i].action));
690 toolbar_item->file = g_strdup(file);
691 toolbar_item->index = default_toolbar[i].action;
692 toolbar_item->text = g_strdup(toolbar_get_short_text(default_toolbar[i].action));
695 toolbar_item->file = g_strdup(TOOLBAR_TAG_SEPARATOR);
696 toolbar_item->index = A_SEPARATOR;
699 if (toolbar_item->index != -1) {
700 if ( !toolbar_is_duplicate(toolbar_item->index, TOOLBAR_MSGVIEW))
701 toolbar_config[TOOLBAR_MSGVIEW].item_list =
702 g_slist_append(toolbar_config[TOOLBAR_MSGVIEW].item_list, toolbar_item);
707 void toolbar_set_default(ToolbarType source)
709 if (source == TOOLBAR_MAIN)
710 toolbar_set_default_main();
711 else if (source == TOOLBAR_COMPOSE)
712 toolbar_set_default_compose();
713 else if (source == TOOLBAR_MSGVIEW)
714 toolbar_set_default_msgview();
717 void toolbar_save_config_file(ToolbarType source)
722 gchar *fileSpec = NULL;
724 debug_print("save Toolbar Configuration to %s\n", toolbar_config[source].conf_file);
726 fileSpec = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, toolbar_config[source].conf_file, NULL );
727 pfile = prefs_write_open(fileSpec);
730 if (fprintf(fp, "<?xml version=\"1.0\" encoding=\"%s\" ?>\n", CS_INTERNAL) < 0)
733 if (fprintf(fp, "<%s>\n", TOOLBAR_TAG_INDEX) < 0)
736 for (cur = toolbar_config[source].item_list; cur != NULL; cur = cur->next) {
737 ToolbarItem *toolbar_item = (ToolbarItem*) cur->data;
739 if (toolbar_item->index != A_SEPARATOR) {
740 if (fprintf(fp, "\t<%s %s=\"%s\" %s=\"",
742 TOOLBAR_ICON_FILE, toolbar_item->file,
743 TOOLBAR_ICON_TEXT) < 0)
745 if (xml_file_put_escape_str(fp, toolbar_item->text) < 0)
747 if (fprintf(fp, "\" %s=\"%s\"/>\n",
749 toolbar_ret_text_from_val(toolbar_item->index)) < 0)
752 if (fprintf(fp, "\t<%s/>\n", TOOLBAR_TAG_SEPARATOR) < 0)
757 if (fprintf(fp, "</%s>\n", TOOLBAR_TAG_INDEX) < 0)
761 if (prefs_file_close (pfile) < 0 )
762 g_warning("failed to write toolbar configuration to file");
766 FILE_OP_ERROR(fileSpec, "fprintf");
768 prefs_file_close_revert (pfile);
770 g_warning("failed to open toolbar configuration file for writing");
773 void toolbar_read_config_file(ToolbarType source)
775 XMLFile *file = NULL;
776 gchar *fileSpec = NULL;
779 debug_print("read Toolbar Configuration from %s\n", toolbar_config[source].conf_file);
781 fileSpec = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, toolbar_config[source].conf_file, NULL );
782 file = xml_open_file(fileSpec);
785 toolbar_clear_list(source);
789 || (xml_get_dtd(file))
790 || (xml_parse_next_tag(file))
791 || (!xml_compare_tag(file, TOOLBAR_TAG_INDEX))) {
792 xml_close_file(file);
800 if (xml_parse_next_tag(file))
803 /* Get next tag (icon, icon_text or icon_action) */
804 if (xml_compare_tag(file, TOOLBAR_TAG_ITEM)) {
805 toolbar_parse_item(file, source);
806 } else if (xml_compare_tag(file, TOOLBAR_TAG_SEPARATOR)) {
807 ToolbarItem *item = g_new0(ToolbarItem, 1);
809 item->file = g_strdup(TOOLBAR_TAG_SEPARATOR);
810 item->index = A_SEPARATOR;
811 toolbar_config[source].item_list =
812 g_slist_append(toolbar_config[source].item_list, item);
816 xml_close_file(file);
819 if ((!file) || (g_slist_length(toolbar_config[source].item_list) == 0)) {
821 if (source == TOOLBAR_MAIN)
822 toolbar_set_default(TOOLBAR_MAIN);
823 else if (source == TOOLBAR_COMPOSE)
824 toolbar_set_default(TOOLBAR_COMPOSE);
825 else if (source == TOOLBAR_MSGVIEW)
826 toolbar_set_default(TOOLBAR_MSGVIEW);
828 g_warning("refusing to write unknown Toolbar Configuration number %d", source);
832 toolbar_save_config_file(source);
837 * clears list of toolbar items read from configuration files
839 void toolbar_clear_list(ToolbarType source)
841 while (toolbar_config[source].item_list != NULL) {
842 ToolbarItem *item = (ToolbarItem*) toolbar_config[source].item_list->data;
844 toolbar_config[source].item_list =
845 g_slist_remove(toolbar_config[source].item_list, item);
851 g_slist_free(toolbar_config[source].item_list);
856 * return list of Toolbar items
858 GSList *toolbar_get_list(ToolbarType source)
862 if ((source == TOOLBAR_MAIN) || (source == TOOLBAR_COMPOSE) || (source == TOOLBAR_MSGVIEW))
863 list = toolbar_config[source].item_list;
868 void toolbar_set_list_item(ToolbarItem *t_item, ToolbarType source)
870 ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
872 toolbar_item->file = g_strdup(t_item->file);
873 toolbar_item->text = g_strdup(t_item->text);
874 toolbar_item->index = t_item->index;
876 toolbar_config[source].item_list =
877 g_slist_append(toolbar_config[source].item_list,
881 static void toolbar_action_execute(GtkWidget *widget,
889 for (cur = action_list; cur != NULL; cur = cur->next) {
890 ToolbarClawsActions *act = (ToolbarClawsActions*)cur->data;
892 if (widget == act->widget) {
893 i = prefs_actions_find_by_name(act->name);
901 actions_execute(data, i, widget, source);
903 g_warning ("Error: did not find Claws Action to execute");
906 gboolean toolbar_check_action_btns(ToolbarType type)
908 GSList *temp, *curr, *list = toolbar_config[type].item_list;
909 gboolean modified = FALSE;
912 while (curr != NULL) {
913 ToolbarItem *toolbar_item = (ToolbarItem *) curr->data;
917 if (toolbar_item->index != A_CLAWS_ACTIONS)
920 if (prefs_actions_find_by_name(toolbar_item->text) == -1) {
921 list = g_slist_delete_link(list, temp);
922 g_free(toolbar_item->file);
923 g_free(toolbar_item->text);
924 g_free(toolbar_item);
932 #define CLAWS_SET_TOOL_ITEM_TIP(widget,tip) { \
933 gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), tip); \
936 #define CLAWS_SET_ARROW_TIP(widget,tip) { \
937 gtk_menu_tool_button_set_arrow_tooltip_text(GTK_MENU_TOOL_BUTTON(widget), tip); \
940 static void activate_compose_button (Toolbar *toolbar,
942 ComposeButtonType type)
944 if ((!toolbar->compose_mail_btn))
947 if (type == COMPOSEBUTTON_NEWS) {
948 gtk_tool_button_set_icon_widget(
949 GTK_TOOL_BUTTON(toolbar->compose_mail_btn),
950 toolbar->compose_news_icon);
952 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(toolbar->compose_mail_btn), _("Compose News message"));
954 gtk_widget_show(toolbar->compose_news_icon);
956 gtk_tool_button_set_icon_widget(
957 GTK_TOOL_BUTTON(toolbar->compose_mail_btn),
958 toolbar->compose_mail_icon);
960 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(toolbar->compose_mail_btn), _("Compose Email"));
962 gtk_widget_show(toolbar->compose_mail_icon);
964 toolbar->compose_btn_type = type;
967 void toolbar_set_compose_button(Toolbar *toolbar,
968 ComposeButtonType compose_btn_type)
970 if (toolbar->compose_btn_type != compose_btn_type)
971 activate_compose_button(toolbar,
972 prefs_common.toolbar_style,
976 static void activate_learn_button (Toolbar *toolbar,
978 LearnButtonType type)
980 if ((!toolbar->learn_spam_btn))
983 if (type == LEARN_SPAM) {
984 gtk_tool_button_set_icon_widget(
985 GTK_TOOL_BUTTON(toolbar->learn_spam_btn),
986 toolbar->learn_spam_icon);
987 gtk_tool_button_set_label(
988 GTK_TOOL_BUTTON(toolbar->learn_spam_btn),
991 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(toolbar->learn_spam_btn), _("Learn spam"));
993 gtk_widget_show(toolbar->learn_spam_icon);
995 gtk_tool_button_set_icon_widget(
996 GTK_TOOL_BUTTON(toolbar->learn_spam_btn),
997 toolbar->learn_ham_icon);
998 gtk_tool_button_set_label(
999 GTK_TOOL_BUTTON(toolbar->learn_spam_btn),
1001 #ifndef GENERIC_UMPC
1002 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(toolbar->learn_spam_btn), _("Learn ham"));
1004 gtk_widget_show(toolbar->learn_ham_icon);
1006 toolbar->learn_btn_type = type;
1009 void toolbar_set_learn_button(Toolbar *toolbar,
1010 LearnButtonType learn_btn_type)
1012 if (toolbar->learn_btn_type != learn_btn_type)
1013 activate_learn_button(toolbar,
1014 prefs_common.toolbar_style,
1018 void toolbar_toggle(guint action, gpointer data)
1020 MainWindow *mainwin = (MainWindow*)data;
1024 cm_return_if_fail(mainwin != NULL);
1026 toolbar_style(TOOLBAR_MAIN, action, mainwin);
1028 list = compose_get_compose_list();
1029 for (cur = list; cur != NULL; cur = cur->next) {
1030 toolbar_style(TOOLBAR_COMPOSE, action, cur->data);
1032 list = messageview_get_msgview_list();
1033 for (cur = list; cur != NULL; cur = cur->next) {
1034 toolbar_style(TOOLBAR_MSGVIEW, action, cur->data);
1039 void toolbar_set_style(GtkWidget *toolbar_wid, GtkWidget *handlebox_wid, guint action)
1041 switch ((ToolbarStyle)action) {
1043 gtk_widget_hide(handlebox_wid);
1046 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
1050 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
1054 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
1057 case TOOLBAR_BOTH_HORIZ:
1058 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
1059 GTK_TOOLBAR_BOTH_HORIZ);
1065 prefs_common.toolbar_style = (ToolbarStyle)action;
1066 gtk_widget_set_size_request(handlebox_wid, 1, -1);
1068 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
1069 gtk_widget_show(handlebox_wid);
1070 gtk_widget_queue_resize(handlebox_wid);
1074 * Change the style of toolbar
1076 static void toolbar_style(ToolbarType type, guint action, gpointer data)
1078 GtkWidget *handlebox_wid;
1079 GtkWidget *toolbar_wid;
1080 MainWindow *mainwin = (MainWindow*)data;
1081 Compose *compose = (Compose*)data;
1082 MessageView *msgview = (MessageView*)data;
1084 cm_return_if_fail(data != NULL);
1088 handlebox_wid = mainwin->handlebox;
1089 toolbar_wid = mainwin->toolbar->toolbar;
1091 case TOOLBAR_COMPOSE:
1092 handlebox_wid = compose->handlebox;
1093 toolbar_wid = compose->toolbar->toolbar;
1095 case TOOLBAR_MSGVIEW:
1096 handlebox_wid = msgview->handlebox;
1097 toolbar_wid = msgview->toolbar->toolbar;
1103 toolbar_set_style(toolbar_wid, handlebox_wid, action);
1106 /* Toolbar handling */
1107 static void toolbar_inc_cb(GtkWidget *widget,
1110 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1111 MainWindow *mainwin;
1113 cm_return_if_fail(toolbar_item != NULL);
1115 switch (toolbar_item->type) {
1117 mainwin = (MainWindow*)toolbar_item->parent;
1118 inc_mail_cb(mainwin, 0, NULL);
1125 static void toolbar_inc_all_cb(GtkWidget *widget,
1128 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1129 MainWindow *mainwin;
1131 cm_return_if_fail(toolbar_item != NULL);
1133 switch (toolbar_item->type) {
1135 mainwin = (MainWindow*)toolbar_item->parent;
1136 inc_all_account_mail_cb(mainwin, 0, NULL);
1143 static void toolbar_send_queued_cb(GtkWidget *widget,gpointer data)
1145 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1146 MainWindow *mainwin;
1148 cm_return_if_fail(toolbar_item != NULL);
1150 switch (toolbar_item->type) {
1152 mainwin = (MainWindow*)toolbar_item->parent;
1153 send_queue_cb(mainwin, 0, NULL);
1160 static void toolbar_exec_cb(GtkWidget *widget,
1163 MainWindow *mainwin = get_mainwin(data);
1165 cm_return_if_fail(mainwin != NULL);
1166 summary_execute(mainwin->summaryview);
1170 * Delete current/selected(s) message(s)
1172 static void toolbar_trash_cb(GtkWidget *widget, gpointer data)
1174 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1175 MainWindow *mainwin;
1177 cm_return_if_fail(toolbar_item != NULL);
1178 cm_return_if_fail(toolbar_item->parent);
1180 switch (toolbar_item->type) {
1181 case TOOLBAR_MSGVIEW:
1182 messageview_delete((MessageView *)toolbar_item->parent);
1185 mainwin = (MainWindow *)toolbar_item->parent;
1186 summary_delete_trash(mainwin->summaryview);
1189 debug_print("toolbar event not supported\n");
1195 * Delete current/selected(s) message(s)
1197 static void toolbar_delete_cb(GtkWidget *widget, gpointer data)
1199 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1200 MainWindow *mainwin;
1202 cm_return_if_fail(toolbar_item != NULL);
1203 cm_return_if_fail(toolbar_item->parent);
1205 switch (toolbar_item->type) {
1206 case TOOLBAR_MSGVIEW:
1207 messageview_delete((MessageView *)toolbar_item->parent);
1210 mainwin = (MainWindow *)toolbar_item->parent;
1211 summary_delete(mainwin->summaryview);
1214 debug_print("toolbar event not supported\n");
1221 * Compose new message
1223 static void toolbar_compose_cb(GtkWidget *widget, gpointer data)
1225 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1226 MainWindow *mainwin;
1227 MessageView *msgview;
1229 cm_return_if_fail(toolbar_item != NULL);
1231 switch (toolbar_item->type) {
1233 mainwin = (MainWindow*)toolbar_item->parent;
1234 if (mainwin->toolbar->compose_btn_type == COMPOSEBUTTON_NEWS)
1235 compose_news_cb(mainwin, 0, NULL);
1237 compose_mail_cb(mainwin, 0, NULL);
1239 case TOOLBAR_MSGVIEW:
1240 msgview = (MessageView*)toolbar_item->parent;
1241 compose_new_with_folderitem(NULL,
1242 msgview->msginfo->folder, NULL);
1245 debug_print("toolbar event not supported\n");
1249 static void toolbar_learn(gpointer data, guint as_spam)
1251 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1252 MainWindow *mainwin;
1253 MessageView *msgview;
1255 cm_return_if_fail(toolbar_item != NULL);
1257 switch (toolbar_item->type) {
1259 mainwin = (MainWindow*)toolbar_item->parent;
1261 mainwindow_learn(mainwin, TRUE);
1263 mainwindow_learn(mainwin, FALSE);
1265 case TOOLBAR_MSGVIEW:
1266 msgview = (MessageView*)toolbar_item->parent;
1268 messageview_learn(msgview, TRUE);
1270 messageview_learn(msgview, FALSE);
1273 debug_print("toolbar event not supported\n");
1277 static void toolbar_learn_cb(GtkWidget *widget, gpointer data)
1279 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1280 MainWindow *mainwin;
1281 MessageView *msgview;
1283 cm_return_if_fail(toolbar_item != NULL);
1285 switch (toolbar_item->type) {
1287 mainwin = (MainWindow*)toolbar_item->parent;
1288 if (mainwin->toolbar->learn_btn_type == LEARN_SPAM)
1289 mainwindow_learn(mainwin, TRUE);
1291 mainwindow_learn(mainwin, FALSE);
1293 case TOOLBAR_MSGVIEW:
1294 msgview = (MessageView*)toolbar_item->parent;
1295 if (msgview->toolbar->learn_btn_type == LEARN_SPAM)
1296 messageview_learn(msgview, TRUE);
1298 messageview_learn(msgview, FALSE);
1301 debug_print("toolbar event not supported\n");
1309 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
1311 toolbar_reply(data, (prefs_common.reply_with_quote ?
1312 COMPOSE_REPLY_WITH_QUOTE : COMPOSE_REPLY_WITHOUT_QUOTE));
1317 * Reply message to Sender and All recipients
1319 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
1322 (prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
1323 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE));
1328 * Reply to Mailing List
1330 static void toolbar_reply_to_list_cb(GtkWidget *widget, gpointer data)
1333 (prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_LIST_WITH_QUOTE
1334 : COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE));
1339 * Reply to sender of message
1341 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
1344 (prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
1345 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE));
1351 static void toolbar_addrbook_cb(GtkWidget *widget, gpointer data)
1353 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1356 cm_return_if_fail(toolbar_item != NULL);
1358 switch (toolbar_item->type) {
1360 case TOOLBAR_MSGVIEW:
1363 case TOOLBAR_COMPOSE:
1364 compose = (Compose *)toolbar_item->parent;
1369 #ifndef USE_ALT_ADDRBOOK
1370 addressbook_open(compose);
1372 GError* error = NULL;
1373 addressbook_connect_signals(compose);
1374 addressbook_dbus_open(TRUE, &error);
1376 g_warning("%s", error->message);
1377 g_error_free(error);
1384 * Forward current/selected(s) message(s)
1386 static void toolbar_forward_cb(GtkWidget *widget, gpointer data)
1388 toolbar_reply(data, (COMPOSE_FORWARD));
1392 * Goto Prev Unread Message
1394 static void toolbar_prev_unread_cb(GtkWidget *widget, gpointer data)
1396 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1397 MainWindow *mainwin;
1398 MessageView *msgview;
1400 cm_return_if_fail(toolbar_item != NULL);
1402 switch (toolbar_item->type) {
1404 mainwin = (MainWindow*)toolbar_item->parent;
1405 summary_select_prev_unread(mainwin->summaryview);
1408 case TOOLBAR_MSGVIEW:
1409 msgview = (MessageView*)toolbar_item->parent;
1410 msgview->updating = TRUE;
1411 summary_select_prev_unread(msgview->mainwin->summaryview);
1412 msgview->updating = FALSE;
1414 if (msgview->deferred_destroy) {
1415 debug_print("messageview got away!\n");
1416 messageview_destroy(msgview);
1420 /* Now we need to update the messageview window */
1421 if (msgview->mainwin->summaryview->selected) {
1422 #ifndef GENERIC_UMPC
1423 MsgInfo * msginfo = summary_get_selected_msg(msgview->mainwin->summaryview);
1426 messageview_show(msgview, msginfo,
1427 msgview->all_headers);
1430 gtk_widget_destroy(msgview->window);
1434 debug_print("toolbar event not supported\n");
1439 * Goto Next Unread Message
1441 static void toolbar_next_unread_cb(GtkWidget *widget, gpointer data)
1443 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1444 MainWindow *mainwin;
1445 MessageView *msgview;
1447 cm_return_if_fail(toolbar_item != NULL);
1449 switch (toolbar_item->type) {
1451 mainwin = (MainWindow*)toolbar_item->parent;
1452 summary_select_next_unread(mainwin->summaryview);
1455 case TOOLBAR_MSGVIEW:
1456 msgview = (MessageView*)toolbar_item->parent;
1457 msgview->updating = TRUE;
1458 summary_select_next_unread(msgview->mainwin->summaryview);
1459 msgview->updating = FALSE;
1461 if (msgview->deferred_destroy) {
1462 debug_print("messageview got away!\n");
1463 messageview_destroy(msgview);
1467 /* Now we need to update the messageview window */
1468 if (msgview->mainwin->summaryview->selected) {
1469 #ifndef GENERIC_UMPC
1470 MsgInfo * msginfo = summary_get_selected_msg(msgview->mainwin->summaryview);
1473 messageview_show(msgview, msginfo,
1474 msgview->all_headers);
1477 gtk_widget_destroy(msgview->window);
1481 debug_print("toolbar event not supported\n");
1485 static void toolbar_ignore_thread_cb(GtkWidget *widget, gpointer data)
1487 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1488 MainWindow *mainwin;
1490 cm_return_if_fail(toolbar_item != NULL);
1492 switch (toolbar_item->type) {
1494 mainwin = (MainWindow *) toolbar_item->parent;
1495 summary_toggle_ignore_thread(mainwin->summaryview);
1497 case TOOLBAR_MSGVIEW:
1498 /* TODO: see toolbar_next_unread_cb() if you need
1499 * this in the message view */
1502 debug_print("toolbar event not supported\n");
1507 static void toolbar_watch_thread_cb(GtkWidget *widget, gpointer data)
1509 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1510 MainWindow *mainwin;
1512 cm_return_if_fail(toolbar_item != NULL);
1514 switch (toolbar_item->type) {
1516 mainwin = (MainWindow *) toolbar_item->parent;
1517 summary_toggle_watch_thread(mainwin->summaryview);
1519 case TOOLBAR_MSGVIEW:
1520 /* TODO: see toolbar_next_unread_cb() if you need
1521 * this in the message view */
1524 debug_print("toolbar event not supported\n");
1529 static void toolbar_mark_cb(GtkWidget *widget, gpointer data)
1531 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1532 MainWindow *mainwin;
1534 cm_return_if_fail(toolbar_item != NULL);
1536 switch (toolbar_item->type) {
1538 mainwin = (MainWindow *) toolbar_item->parent;
1539 summary_mark(mainwin->summaryview);
1541 case TOOLBAR_MSGVIEW:
1542 /* TODO: see toolbar_next_unread_cb() if you need
1543 * this in the message view */
1546 debug_print("toolbar event not supported\n");
1551 static void toolbar_unmark_cb(GtkWidget *widget, gpointer data)
1553 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1554 MainWindow *mainwin;
1556 cm_return_if_fail(toolbar_item != NULL);
1558 switch (toolbar_item->type) {
1560 mainwin = (MainWindow *) toolbar_item->parent;
1561 summary_unmark(mainwin->summaryview);
1563 case TOOLBAR_MSGVIEW:
1564 /* TODO: see toolbar_next_unread_cb() if you need
1565 * this in the message view */
1568 debug_print("toolbar event not supported\n");
1573 static void toolbar_lock_cb(GtkWidget *widget, gpointer data)
1575 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1576 MainWindow *mainwin;
1578 cm_return_if_fail(toolbar_item != NULL);
1580 switch (toolbar_item->type) {
1582 mainwin = (MainWindow *) toolbar_item->parent;
1583 summary_msgs_lock(mainwin->summaryview);
1585 case TOOLBAR_MSGVIEW:
1586 /* TODO: see toolbar_next_unread_cb() if you need
1587 * this in the message view */
1590 debug_print("toolbar event not supported\n");
1595 static void toolbar_unlock_cb(GtkWidget *widget, gpointer data)
1597 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1598 MainWindow *mainwin;
1600 cm_return_if_fail(toolbar_item != NULL);
1602 switch (toolbar_item->type) {
1604 mainwin = (MainWindow *) toolbar_item->parent;
1605 summary_msgs_unlock(mainwin->summaryview);
1607 case TOOLBAR_MSGVIEW:
1608 /* TODO: see toolbar_next_unread_cb() if you need
1609 * this in the message view */
1612 debug_print("toolbar event not supported\n");
1617 static void toolbar_all_read_cb(GtkWidget *widget, gpointer data)
1619 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1620 MainWindow *mainwin;
1622 cm_return_if_fail(toolbar_item != NULL);
1624 switch (toolbar_item->type) {
1626 mainwin = (MainWindow *) toolbar_item->parent;
1627 summary_mark_all_read(mainwin->summaryview, TRUE);
1629 case TOOLBAR_MSGVIEW:
1630 /* TODO: see toolbar_next_unread_cb() if you need
1631 * this in the message view */
1634 debug_print("toolbar event not supported\n");
1639 static void toolbar_all_unread_cb(GtkWidget *widget, gpointer data)
1641 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1642 MainWindow *mainwin;
1644 cm_return_if_fail(toolbar_item != NULL);
1646 switch (toolbar_item->type) {
1648 mainwin = (MainWindow *) toolbar_item->parent;
1649 summary_mark_all_read(mainwin->summaryview, FALSE);
1651 case TOOLBAR_MSGVIEW:
1652 /* TODO: see toolbar_next_unread_cb() if you need
1653 * this in the message view */
1656 debug_print("toolbar event not supported\n");
1661 static void toolbar_read_cb(GtkWidget *widget, gpointer data)
1663 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1664 MainWindow *mainwin;
1666 cm_return_if_fail(toolbar_item != NULL);
1668 switch (toolbar_item->type) {
1670 mainwin = (MainWindow *) toolbar_item->parent;
1671 summary_mark_as_read(mainwin->summaryview, TRUE);
1673 case TOOLBAR_MSGVIEW:
1674 /* TODO: see toolbar_next_unread_cb() if you need
1675 * this in the message view */
1678 debug_print("toolbar event not supported\n");
1683 static void toolbar_unread_cb(GtkWidget *widget, gpointer data)
1685 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1686 MainWindow *mainwin;
1688 cm_return_if_fail(toolbar_item != NULL);
1690 switch (toolbar_item->type) {
1692 mainwin = (MainWindow *) toolbar_item->parent;
1693 summary_mark_as_read(mainwin->summaryview, FALSE);
1695 case TOOLBAR_MSGVIEW:
1696 /* TODO: see toolbar_next_unread_cb() if you need
1697 * this in the message view */
1700 debug_print("toolbar event not supported\n");
1705 static void toolbar_cancel_inc_cb(GtkWidget *widget, gpointer data)
1707 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1709 cm_return_if_fail(toolbar_item != NULL);
1714 static void toolbar_cancel_send_cb(GtkWidget *widget, gpointer data)
1716 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1718 cm_return_if_fail(toolbar_item != NULL);
1722 static void toolbar_cancel_all_cb(GtkWidget *widget, gpointer data)
1724 toolbar_cancel_inc_cb(widget, data);
1725 toolbar_cancel_send_cb(widget, data);
1728 static void toolbar_print_cb(GtkWidget *widget, gpointer data)
1730 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1731 MainWindow *mainwin;
1733 cm_return_if_fail(toolbar_item != NULL);
1735 switch (toolbar_item->type) {
1737 mainwin = (MainWindow *) toolbar_item->parent;
1738 summary_print(mainwin->summaryview);
1740 case TOOLBAR_MSGVIEW:
1741 /* TODO: see toolbar_next_unread_cb() if you need
1742 * this in the message view */
1745 debug_print("toolbar event not supported\n");
1750 static void toolbar_send_cb(GtkWidget *widget, gpointer data)
1752 compose_toolbar_cb(A_SEND, data);
1755 static void toolbar_send_later_cb(GtkWidget *widget, gpointer data)
1757 compose_toolbar_cb(A_SEND_LATER, data);
1760 static void toolbar_draft_cb(GtkWidget *widget, gpointer data)
1762 compose_toolbar_cb(A_DRAFT, data);
1765 static void toolbar_close_cb(GtkWidget *widget, gpointer data)
1767 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1768 MainWindow *mainwin;
1769 MessageView *messageview;
1772 cm_return_if_fail(toolbar_item != NULL);
1774 switch (toolbar_item->type) {
1776 mainwin = (MainWindow *) toolbar_item->parent;
1777 app_will_exit(NULL, mainwin);
1779 case TOOLBAR_MSGVIEW:
1780 messageview = (MessageView *)toolbar_item->parent;
1781 messageview_destroy(messageview);
1783 case TOOLBAR_COMPOSE:
1784 compose = (Compose *)toolbar_item->parent;
1785 compose_close_toolbar(compose);
1790 static void toolbar_preferences_cb(GtkWidget *widget, gpointer data)
1795 static void toolbar_open_mail_cb(GtkWidget *widget, gpointer data)
1797 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1798 MainWindow *mainwin;
1800 cm_return_if_fail(toolbar_item != NULL);
1802 switch (toolbar_item->type) {
1804 mainwin = (MainWindow *) toolbar_item->parent;
1805 summary_open_row(NULL, mainwin->summaryview);
1807 case TOOLBAR_MSGVIEW:
1808 debug_print("toolbar event not supported\n");
1810 case TOOLBAR_COMPOSE:
1811 debug_print("toolbar event not supported\n");
1816 static void toolbar_insert_cb(GtkWidget *widget, gpointer data)
1818 compose_toolbar_cb(A_INSERT, data);
1821 static void toolbar_attach_cb(GtkWidget *widget, gpointer data)
1823 compose_toolbar_cb(A_ATTACH, data);
1826 static void toolbar_sig_cb(GtkWidget *widget, gpointer data)
1828 compose_toolbar_cb(A_SIG, data);
1831 static void toolbar_replace_sig_cb(GtkWidget *widget, gpointer data)
1833 compose_toolbar_cb(A_REP_SIG, data);
1836 static void toolbar_ext_editor_cb(GtkWidget *widget, gpointer data)
1838 compose_toolbar_cb(A_EXTEDITOR, data);
1841 static void toolbar_linewrap_current_cb(GtkWidget *widget, gpointer data)
1843 compose_toolbar_cb(A_LINEWRAP_CURRENT, data);
1846 static void toolbar_linewrap_all_cb(GtkWidget *widget, gpointer data)
1848 compose_toolbar_cb(A_LINEWRAP_ALL, data);
1852 static void toolbar_check_spelling_cb(GtkWidget *widget, gpointer data)
1854 compose_toolbar_cb(A_CHECK_SPELLING, data);
1858 * Execute actions from toolbar
1860 static void toolbar_actions_execute_cb(GtkWidget *widget, gpointer data)
1862 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1863 GSList *action_list;
1864 MainWindow *mainwin;
1866 MessageView *msgview;
1867 gpointer parent = toolbar_item->parent;
1869 cm_return_if_fail(toolbar_item != NULL);
1871 switch (toolbar_item->type) {
1873 mainwin = (MainWindow*)parent;
1874 action_list = mainwin->toolbar->action_list;
1876 case TOOLBAR_COMPOSE:
1877 compose = (Compose*)parent;
1878 action_list = compose->toolbar->action_list;
1880 case TOOLBAR_MSGVIEW:
1881 msgview = (MessageView*)parent;
1882 action_list = msgview->toolbar->action_list;
1885 debug_print("toolbar event not supported\n");
1888 toolbar_action_execute(widget, action_list, parent, toolbar_item->type);
1891 static void toolbar_plugins_execute_cb(GtkWidget *widget, gpointer data)
1893 ToolbarItem *toolbar_item = data;
1894 prefs_toolbar_execute_plugin_item(toolbar_item->parent, toolbar_item->type, toolbar_item->text);
1897 static MainWindow *get_mainwin(gpointer data)
1899 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1900 MainWindow *mainwin = NULL;
1901 MessageView *msgview;
1903 cm_return_val_if_fail(toolbar_item != NULL, NULL);
1905 switch(toolbar_item->type) {
1907 mainwin = (MainWindow*)toolbar_item->parent;
1909 case TOOLBAR_MSGVIEW:
1910 msgview = (MessageView*)toolbar_item->parent;
1911 mainwin = (MainWindow*)msgview->mainwin;
1920 static void toolbar_go_folders_cb(GtkWidget *widget, gpointer data)
1922 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1923 MainWindow *mainwin = NULL;
1924 switch(toolbar_item->type) {
1926 mainwin = (MainWindow*)toolbar_item->parent;
1929 g_warning("wrong toolbar type");
1933 if (!mainwin->in_folder) {
1934 FolderItem *item = folderview_get_selected_item(mainwin->folderview);
1936 folderview_select(mainwin->folderview, item);
1939 folderview_grab_focus(mainwin->folderview);
1940 mainwindow_exit_folder(mainwin);
1944 static void toolbar_buttons_cb(GtkWidget *widget,
1951 void (*func)(GtkWidget *widget, gpointer data);
1953 { A_RECEIVE_ALL, toolbar_inc_all_cb },
1954 { A_RECEIVE_CUR, toolbar_inc_cb },
1955 { A_SEND_QUEUED, toolbar_send_queued_cb },
1956 { A_COMPOSE_EMAIL, toolbar_compose_cb },
1957 { A_COMPOSE_NEWS, toolbar_compose_cb },
1958 { A_REPLY_MESSAGE, toolbar_reply_cb },
1959 { A_REPLY_SENDER, toolbar_reply_to_sender_cb },
1960 { A_REPLY_ALL, toolbar_reply_to_all_cb },
1961 { A_REPLY_ML, toolbar_reply_to_list_cb },
1962 { A_FORWARD, toolbar_forward_cb },
1963 { A_TRASH, toolbar_trash_cb },
1964 { A_DELETE_REAL, toolbar_delete_cb },
1965 { A_EXECUTE, toolbar_exec_cb },
1966 { A_GOTO_PREV, toolbar_prev_unread_cb },
1967 { A_GOTO_NEXT, toolbar_next_unread_cb },
1968 { A_IGNORE_THREAD, toolbar_ignore_thread_cb },
1969 { A_WATCH_THREAD, toolbar_watch_thread_cb },
1970 { A_MARK, toolbar_mark_cb },
1971 { A_UNMARK, toolbar_unmark_cb },
1972 { A_LOCK, toolbar_lock_cb },
1973 { A_UNLOCK, toolbar_unlock_cb },
1974 { A_ALL_READ, toolbar_all_read_cb },
1975 { A_ALL_UNREAD, toolbar_all_unread_cb },
1976 { A_READ, toolbar_read_cb },
1977 { A_UNREAD, toolbar_unread_cb },
1978 { A_PRINT, toolbar_print_cb },
1979 { A_LEARN_SPAM, toolbar_learn_cb },
1980 { A_GO_FOLDERS, toolbar_go_folders_cb },
1982 { A_SEND, toolbar_send_cb },
1983 { A_SEND_LATER, toolbar_send_later_cb },
1984 { A_DRAFT, toolbar_draft_cb },
1985 { A_OPEN_MAIL, toolbar_open_mail_cb },
1986 { A_CLOSE, toolbar_close_cb },
1987 { A_PREFERENCES, toolbar_preferences_cb },
1988 { A_INSERT, toolbar_insert_cb },
1989 { A_ATTACH, toolbar_attach_cb },
1990 { A_SIG, toolbar_sig_cb },
1991 { A_REP_SIG, toolbar_replace_sig_cb },
1992 { A_EXTEDITOR, toolbar_ext_editor_cb },
1993 { A_LINEWRAP_CURRENT, toolbar_linewrap_current_cb },
1994 { A_LINEWRAP_ALL, toolbar_linewrap_all_cb },
1995 { A_ADDRBOOK, toolbar_addrbook_cb },
1997 { A_CHECK_SPELLING, toolbar_check_spelling_cb },
1999 { A_CLAWS_ACTIONS, toolbar_actions_execute_cb },
2000 { A_CANCEL_INC, toolbar_cancel_inc_cb },
2001 { A_CANCEL_SEND, toolbar_cancel_send_cb },
2002 { A_CANCEL_ALL, toolbar_cancel_all_cb },
2003 { A_CLAWS_PLUGINS, toolbar_plugins_execute_cb },
2006 num_items = sizeof(callbacks)/sizeof(callbacks[0]);
2008 for (i = 0; i < num_items; i++) {
2009 if (callbacks[i].index == item->index) {
2010 callbacks[i].func(widget, item);
2015 #ifndef GENERIC_UMPC
2016 #define TOOLBAR_ITEM(item,icon,text,tooltip) { \
2017 item = GTK_WIDGET(gtk_tool_button_new(icon, text)); \
2018 gtkut_widget_set_can_focus(gtk_bin_get_child(GTK_BIN(item)), FALSE); \
2019 gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE); \
2020 gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE); \
2021 g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item); \
2022 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1); \
2023 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(item), \
2027 #define TOOLBAR_MENUITEM(item,icon,text,tooltip,menutip) { \
2028 GtkWidget *child = NULL, *btn = NULL, *arr = NULL; \
2029 GList *gchild = NULL; \
2030 item = GTK_WIDGET(gtk_menu_tool_button_new(icon, text)); \
2031 gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE); \
2032 gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE); \
2033 g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item); \
2034 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1); \
2035 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(item), \
2037 CLAWS_SET_ARROW_TIP(GTK_MENU_TOOL_BUTTON(item), menutip); \
2038 child = gtk_bin_get_child(GTK_BIN(item)); \
2039 gchild = gtk_container_get_children( \
2040 GTK_CONTAINER(child)); \
2041 btn = (GtkWidget *)gchild->data; \
2042 gtkut_widget_set_can_focus(btn, FALSE); \
2043 arr = (GtkWidget *)(gchild->next?gchild->next->data:NULL); \
2044 gtkut_widget_set_can_focus(arr, FALSE); \
2045 g_list_free(gchild); \
2046 gchild = gtk_container_get_children(GTK_CONTAINER(arr)); \
2047 gtk_widget_set_size_request(GTK_WIDGET(gchild->data), 9, -1); \
2048 g_list_free(gchild); \
2051 #define TOOLBAR_ITEM(item,icon,text,tooltip) { \
2052 item = GTK_WIDGET(gtk_tool_button_new(icon, text)); \
2053 gtkut_widget_set_can_focus(gtk_bin_get_child(GTK_BIN(item)), FALSE); \
2054 gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE); \
2055 gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE); \
2056 g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item); \
2057 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1); \
2060 #define TOOLBAR_MENUITEM(item,icon,text,tooltip,menutip) { \
2061 GtkWidget *child = NULL, *btn = NULL, *arr = NULL; \
2062 GList *gchild = NULL; \
2063 item = GTK_WIDGET(gtk_menu_tool_button_new(icon, text)); \
2064 gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE); \
2065 gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE); \
2066 g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item); \
2067 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1); \
2068 child = gtk_bin_get_child(GTK_BIN(item)); \
2069 gchild = gtk_container_get_children( \
2070 GTK_CONTAINER(child)); \
2071 btn = (GtkWidget *)gchild->data; \
2072 gtkut_widget_set_can_focus(btn, FALSE); \
2073 arr = (GtkWidget *)(gchild->next?gchild->next->data:NULL); \
2074 gtkut_widget_set_can_focus(arr, FALSE); \
2075 g_list_free(gchild); \
2076 gchild = gtk_container_get_children(GTK_CONTAINER(arr)); \
2077 gtk_widget_set_size_request(GTK_WIDGET(gchild->data), 9, -1); \
2078 g_list_free(gchild); \
2082 #define ADD_MENU_ITEM(name,cb,data) { \
2083 item = gtk_menu_item_new_with_mnemonic(name); \
2084 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); \
2085 g_signal_connect(G_OBJECT(item), "activate", \
2088 g_object_set_data(G_OBJECT(item), "int-value", GINT_TO_POINTER(data)); \
2089 gtk_widget_show(item); \
2092 static void toolbar_reply_menu_cb(GtkWidget *widget, gpointer data)
2094 gpointer int_value = g_object_get_data(G_OBJECT(widget), "int-value");
2095 ToolbarItem *toolbar_item = (ToolbarItem *)data;
2097 toolbar_reply(toolbar_item, GPOINTER_TO_INT(int_value));
2100 static void toolbar_learn_menu_cb(GtkWidget *widget, gpointer data)
2102 gpointer int_value = g_object_get_data(G_OBJECT(widget), "int-value");
2103 ToolbarItem *toolbar_item = (ToolbarItem *)data;
2105 toolbar_learn(toolbar_item, GPOINTER_TO_INT(int_value));
2109 * Create a new toolbar with specified type
2110 * if a callback list is passed it will be used before the
2111 * common callback list
2113 Toolbar *toolbar_create(ToolbarType type,
2114 GtkWidget *container,
2117 ToolbarItem *toolbar_item;
2120 GtkWidget *icon_wid = NULL;
2121 GtkWidget *icon_news;
2122 GtkWidget *icon_ham;
2124 ToolbarClawsActions *action_item;
2126 GSList *toolbar_list;
2127 Toolbar *toolbar_data;
2129 toolbar_read_config_file(type);
2130 toolbar_list = toolbar_get_list(type);
2132 toolbar_data = g_new0(Toolbar, 1);
2134 toolbar = gtk_toolbar_new();
2136 gtk_orientable_set_orientation(GTK_ORIENTABLE(toolbar), GTK_ORIENTATION_HORIZONTAL);
2138 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_BOTH);
2139 gtk_toolbar_set_show_arrow(GTK_TOOLBAR(toolbar), TRUE);
2141 for (cur = toolbar_list; cur != NULL; cur = cur->next) {
2143 if (g_ascii_strcasecmp(((ToolbarItem*)cur->data)->file, TOOLBAR_TAG_SEPARATOR) == 0) {
2144 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), gtk_separator_tool_item_new(), -1);
2148 toolbar_item = g_new0(ToolbarItem, 1);
2149 toolbar_item->index = ((ToolbarItem*)cur->data)->index;
2150 toolbar_item->file = g_strdup(((ToolbarItem*)cur->data)->file);
2151 toolbar_item->text = g_strdup(((ToolbarItem*)cur->data)->text);
2152 toolbar_item->parent = data;
2153 toolbar_item->type = type;
2155 /* collect toolbar items in list to keep track */
2156 toolbar_data->item_list =
2157 g_slist_append(toolbar_data->item_list,
2159 icon_wid = stock_pixmap_widget(stock_pixmap_get_icon(toolbar_item->file));
2161 switch (toolbar_item->index) {
2164 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Go to folder list"));
2165 toolbar_data->folders_btn = item;
2168 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2169 _("Receive Mail from all Accounts"),
2170 _("Receive Mail from selected Account"));
2171 toolbar_data->getall_btn = item;
2174 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text, _("Receive Mail from current Account"));
2175 toolbar_data->get_btn = item;
2178 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Send Queued Messages"));
2179 toolbar_data->send_btn = item;
2182 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Close window"));
2183 toolbar_data->close_window_btn = item;
2186 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Open preferences"));
2187 toolbar_data->preferences_btn = item;
2190 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Open email"));
2191 toolbar_data->open_mail_btn = item;
2193 case A_COMPOSE_EMAIL:
2194 #ifndef GENERIC_UMPC
2195 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2197 _("Compose with selected Account"));
2198 toolbar_data->compose_mail_btn = item;
2199 toolbar_data->compose_mail_icon = icon_wid;
2200 g_object_ref(toolbar_data->compose_mail_icon);
2202 icon_news = stock_pixmap_widget(STOCK_PIXMAP_NEWS_COMPOSE);
2203 toolbar_data->compose_news_icon = icon_news;
2204 g_object_ref(toolbar_data->compose_news_icon);
2206 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2207 _("Compose Email"));
2208 toolbar_data->compose_mail_btn = item;
2209 toolbar_data->compose_mail_icon = icon_wid;
2211 icon_news = stock_pixmap_widget(STOCK_PIXMAP_NEWS_COMPOSE);
2212 toolbar_data->compose_news_icon = icon_news;
2216 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2219 toolbar_data->learn_spam_btn = item;
2220 toolbar_data->learn_spam_icon = icon_wid;
2221 g_object_ref(toolbar_data->learn_spam_icon);
2223 icon_ham = stock_pixmap_widget(STOCK_PIXMAP_HAM_BTN);
2224 toolbar_data->learn_ham_icon = icon_ham;
2225 g_object_ref(toolbar_data->learn_ham_icon);
2227 menu = gtk_menu_new();
2228 ADD_MENU_ITEM(_("Learn as _Spam"), toolbar_learn_menu_cb, TRUE);
2229 ADD_MENU_ITEM(_("Learn as _Ham"), toolbar_learn_menu_cb, FALSE);
2230 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->learn_spam_btn), menu);
2232 case A_REPLY_MESSAGE:
2233 #ifndef GENERIC_UMPC
2234 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2235 _("Reply to Message"),
2236 _("Reply to Message options"));
2237 toolbar_data->reply_btn = item;
2239 menu = gtk_menu_new();
2240 ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_WITH_QUOTE);
2241 ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_WITHOUT_QUOTE);
2242 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->reply_btn), menu);
2244 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2245 _("Reply to Message"));
2246 toolbar_data->reply_btn = item;
2249 case A_REPLY_SENDER:
2250 #ifndef GENERIC_UMPC
2251 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2252 _("Reply to Sender"),
2253 _("Reply to Sender options"));
2254 toolbar_data->replysender_btn = item;
2256 menu = gtk_menu_new();
2257 ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE);
2258 ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE);
2259 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->replysender_btn), menu);
2261 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2262 _("Reply to Sender"));
2263 toolbar_data->replysender_btn = item;
2267 #ifndef GENERIC_UMPC
2268 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2270 _("Reply to All options"));
2271 toolbar_data->replyall_btn = item;
2273 menu = gtk_menu_new();
2274 ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE);
2275 ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE);
2276 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->replyall_btn), menu);
2278 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2280 toolbar_data->replyall_btn = item;
2284 #ifndef GENERIC_UMPC
2285 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2286 _("Reply to Mailing-list"),
2287 _("Reply to Mailing-list options"));
2288 toolbar_data->replylist_btn = item;
2290 menu = gtk_menu_new();
2291 ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_LIST_WITH_QUOTE);
2292 ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE);
2293 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->replylist_btn), menu);
2295 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2296 _("Reply to Mailing-list"));
2297 toolbar_data->replylist_btn = item;
2301 #ifndef GENERIC_UMPC
2302 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2303 _("Forward Message"),
2304 _("Forward Message options"));
2305 toolbar_data->fwd_btn = item;
2307 menu = gtk_menu_new();
2308 ADD_MENU_ITEM(_("_Forward"), toolbar_reply_menu_cb, COMPOSE_FORWARD_INLINE);
2309 ADD_MENU_ITEM(_("For_ward as attachment"), toolbar_reply_menu_cb, COMPOSE_FORWARD_AS_ATTACH);
2310 ADD_MENU_ITEM(_("Redirec_t"), toolbar_reply_menu_cb, COMPOSE_REDIRECT);
2311 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->fwd_btn), menu);
2313 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2314 _("Forward Message"));
2315 toolbar_data->fwd_btn = item;
2319 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Trash Message"));
2320 toolbar_data->trash_btn = item;
2323 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Delete Message"));
2324 toolbar_data->delete_btn = item;
2327 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Execute"));
2328 toolbar_data->exec_btn = item;
2331 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Go to Previous Unread Message"));
2332 toolbar_data->prev_btn = item;
2335 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Go to Next Unread Message"));
2336 toolbar_data->next_btn = item;
2339 /* Compose Toolbar */
2341 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Send Message"));
2342 toolbar_data->send_btn = item;
2345 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Put into queue folder and send later"));
2346 toolbar_data->sendl_btn = item;
2349 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Save to draft folder"));
2350 toolbar_data->draft_btn = item;
2353 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Insert file"));
2354 toolbar_data->insert_btn = item;
2357 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Attach file"));
2358 toolbar_data->attach_btn = item;
2361 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Insert signature"));
2362 toolbar_data->sig_btn = item;
2365 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Replace signature"));
2366 toolbar_data->repsig_btn = item;
2369 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Edit with external editor"));
2370 toolbar_data->exteditor_btn = item;
2372 case A_LINEWRAP_CURRENT:
2373 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Wrap long lines of current paragraph"));
2374 toolbar_data->linewrap_current_btn = item;
2376 case A_LINEWRAP_ALL:
2377 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Wrap all long lines"));
2378 toolbar_data->linewrap_all_btn = item;
2381 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Address book"));
2382 toolbar_data->addrbook_btn = item;
2385 case A_CHECK_SPELLING:
2386 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Check spelling"));
2387 toolbar_data->spellcheck_btn = item;
2391 case A_CLAWS_ACTIONS:
2392 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,toolbar_item->text);
2393 action_item = g_new0(ToolbarClawsActions, 1);
2394 action_item->widget = item;
2395 action_item->name = g_strdup(toolbar_item->text);
2397 toolbar_data->action_list =
2398 g_slist_append(toolbar_data->action_list,
2402 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Cancel receiving"));
2403 toolbar_data->cancel_inc_btn = item;
2406 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Cancel sending"));
2407 toolbar_data->cancel_send_btn = item;
2410 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Cancel receiving/sending"));
2411 toolbar_data->cancel_all_btn = item;
2413 case A_CLAWS_PLUGINS:
2414 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text, toolbar_item->text);
2417 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2418 toolbar_ret_descr_from_val(toolbar_item->index));
2419 /* find and set the tool tip text */
2424 toolbar_data->toolbar = toolbar;
2426 gtk_widget_show_all(toolbar);
2428 if (type == TOOLBAR_MAIN) {
2430 MainWindow *mainwin = mainwindow_get_mainwindow();
2431 GtkWidget *progressbar = gtk_progress_bar_new();
2432 item = GTK_WIDGET(gtk_tool_item_new());
2433 gtk_container_add (GTK_CONTAINER (item), progressbar);
2434 gtk_widget_show(item);
2435 gtk_widget_set_size_request(progressbar, 84, -1);
2436 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1);
2437 mainwin->progressbar = progressbar;
2439 activate_compose_button(toolbar_data,
2440 prefs_common.toolbar_style,
2441 toolbar_data->compose_btn_type);
2443 if (type != TOOLBAR_COMPOSE)
2444 activate_learn_button(toolbar_data, prefs_common.toolbar_style,
2447 gtk_container_add(GTK_CONTAINER(container), toolbar);
2448 gtk_container_set_border_width(GTK_CONTAINER(container), 0);
2450 return toolbar_data;
2454 * Free toolbar structures
2456 void toolbar_destroy(Toolbar * toolbar) {
2458 TOOLBAR_DESTROY_ITEMS(toolbar->item_list);
2459 TOOLBAR_DESTROY_ACTIONS(toolbar->action_list);
2462 void toolbar_update(ToolbarType type, gpointer data)
2464 Toolbar *toolbar_data;
2465 GtkWidget *handlebox;
2466 MainWindow *mainwin = (MainWindow*)data;
2467 Compose *compose = (Compose*)data;
2468 MessageView *msgview = (MessageView*)data;
2470 #ifndef GENERIC_UMPC
2473 toolbar_data = mainwin->toolbar;
2474 handlebox = mainwin->handlebox;
2476 case TOOLBAR_COMPOSE:
2477 toolbar_data = compose->toolbar;
2478 handlebox = compose->handlebox;
2480 case TOOLBAR_MSGVIEW:
2481 toolbar_data = msgview->toolbar;
2482 handlebox = msgview->handlebox;
2488 gtk_container_remove(GTK_CONTAINER(handlebox),
2489 GTK_WIDGET(toolbar_data->toolbar));
2491 toolbar_init(toolbar_data);
2492 toolbar_data = toolbar_create(type, handlebox, data);
2496 toolbar_data = mainwin->toolbar;
2497 handlebox = mainwin->window;
2499 case TOOLBAR_COMPOSE:
2500 toolbar_data = compose->toolbar;
2501 handlebox = compose->window;
2503 case TOOLBAR_MSGVIEW:
2504 toolbar_data = msgview->toolbar;
2505 handlebox = msgview->window;
2510 toolbar_init(toolbar_data);
2511 toolbar_data = toolbar_create(type, handlebox, data);
2516 mainwin->toolbar = toolbar_data;
2518 case TOOLBAR_COMPOSE:
2519 compose->toolbar = toolbar_data;
2521 case TOOLBAR_MSGVIEW:
2522 msgview->toolbar = toolbar_data;
2526 toolbar_style(type, prefs_common.toolbar_style, data);
2528 if (type == TOOLBAR_MAIN) {
2529 toolbar_main_set_sensitive((MainWindow*)data);
2530 account_set_menu_only_toolbar();
2534 #define GTK_BUTTON_SET_SENSITIVE(widget,sensitive) { \
2535 gtk_widget_set_sensitive(widget, sensitive); \
2538 void toolbar_main_set_sensitive(gpointer data)
2540 SensitiveCondMask state;
2542 MainWindow *mainwin = (MainWindow*)data;
2543 Toolbar *toolbar = mainwin->toolbar;
2545 GSList *entry_list = NULL;
2547 typedef struct _Entry Entry;
2550 SensitiveCondMask cond;
2554 #define SET_WIDGET_COND(w, ...) \
2556 Entry *e = g_new0(Entry, 1); \
2558 e->cond = main_window_get_mask(__VA_ARGS__, -1); \
2559 entry_list = g_slist_append(entry_list, e); \
2562 /* match all bit flags */
2564 if (toolbar->get_btn)
2565 SET_WIDGET_COND(toolbar->get_btn,
2566 M_HAVE_ACCOUNT, M_UNLOCKED, M_HAVE_RETRIEVABLE_ACCOUNT);
2568 if (toolbar->getall_btn) {
2569 SET_WIDGET_COND(toolbar->getall_btn,
2570 M_HAVE_ACCOUNT, M_UNLOCKED, M_HAVE_ANY_RETRIEVABLE_ACCOUNT);
2572 if (toolbar->send_btn) {
2573 SET_WIDGET_COND(toolbar->send_btn,
2574 M_HAVE_QUEUED_MAILS);
2576 if (toolbar->compose_mail_btn) {
2577 SET_WIDGET_COND(toolbar->compose_mail_btn,
2580 if (toolbar->close_window_btn) {
2581 SET_WIDGET_COND(toolbar->close_window_btn,
2584 if (toolbar->open_mail_btn) {
2585 SET_WIDGET_COND(toolbar->open_mail_btn,
2586 M_TARGET_EXIST, M_SUMMARY_ISLIST);
2588 if (toolbar->reply_btn) {
2589 SET_WIDGET_COND(toolbar->reply_btn,
2590 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2592 if (toolbar->replyall_btn) {
2593 SET_WIDGET_COND(toolbar->replyall_btn,
2594 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2596 if (toolbar->replylist_btn) {
2597 SET_WIDGET_COND(toolbar->replylist_btn,
2598 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2600 if (toolbar->replysender_btn) {
2601 SET_WIDGET_COND(toolbar->replysender_btn,
2602 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2604 if (toolbar->fwd_btn) {
2605 SET_WIDGET_COND(toolbar->fwd_btn,
2606 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2609 if (prefs_common.next_unread_msg_dialog == NEXTUNREADMSGDIALOG_ASSUME_NO) {
2610 SET_WIDGET_COND(toolbar->next_btn, M_MSG_EXIST, M_SUMMARY_ISLIST);
2612 SET_WIDGET_COND(toolbar->next_btn, -1);
2615 if (toolbar->trash_btn)
2616 SET_WIDGET_COND(toolbar->trash_btn,
2617 M_TARGET_EXIST, M_ALLOW_DELETE, M_NOT_NEWS);
2619 if (toolbar->delete_btn)
2620 SET_WIDGET_COND(toolbar->delete_btn,
2621 M_TARGET_EXIST, M_ALLOW_DELETE);
2623 if (toolbar->exec_btn)
2624 SET_WIDGET_COND(toolbar->exec_btn,
2627 if (toolbar->learn_spam_btn)
2628 SET_WIDGET_COND(toolbar->learn_spam_btn,
2629 M_TARGET_EXIST, M_CAN_LEARN_SPAM, M_SUMMARY_ISLIST);
2631 if (toolbar->cancel_inc_btn)
2632 SET_WIDGET_COND(toolbar->cancel_inc_btn,
2635 if (toolbar->cancel_send_btn)
2636 SET_WIDGET_COND(toolbar->cancel_send_btn,
2639 for (cur = toolbar->action_list; cur != NULL; cur = cur->next) {
2640 ToolbarClawsActions *act = (ToolbarClawsActions*)cur->data;
2642 SET_WIDGET_COND(act->widget, M_TARGET_EXIST, M_UNLOCKED);
2645 state = main_window_get_current_state(mainwin);
2647 for (cur = entry_list; cur != NULL; cur = cur->next) {
2648 Entry *e = (Entry*) cur->data;
2650 if (e->widget != NULL) {
2651 sensitive = ((e->cond & state) == e->cond);
2652 GTK_BUTTON_SET_SENSITIVE(e->widget, sensitive);
2656 while (entry_list != NULL) {
2657 Entry *e = (Entry*) entry_list->data;
2660 entry_list = g_slist_remove(entry_list, e);
2663 /* match any bit flags */
2665 if (toolbar->cancel_all_btn)
2666 SET_WIDGET_COND(toolbar->cancel_all_btn,
2667 M_INC_ACTIVE, M_SEND_ACTIVE);
2669 for (cur = entry_list; cur != NULL; cur = cur->next) {
2670 Entry *e = (Entry*) cur->data;
2672 if (e->widget != NULL) {
2673 sensitive = ((e->cond & state) != 0);
2674 GTK_BUTTON_SET_SENSITIVE(e->widget, sensitive);
2678 while (entry_list != NULL) {
2679 Entry *e = (Entry*) entry_list->data;
2682 entry_list = g_slist_remove(entry_list, e);
2685 g_slist_free(entry_list);
2687 activate_compose_button(toolbar,
2688 prefs_common.toolbar_style,
2689 toolbar->compose_btn_type);
2691 #undef SET_WIDGET_COND
2694 void toolbar_comp_set_sensitive(gpointer data, gboolean sensitive)
2696 Compose *compose = (Compose*)data;
2697 GSList *items = compose->toolbar->action_list;
2699 if (compose->toolbar->send_btn)
2700 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->send_btn, sensitive);
2701 if (compose->toolbar->sendl_btn)
2702 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->sendl_btn, sensitive);
2703 if (compose->toolbar->draft_btn )
2704 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->draft_btn , sensitive);
2705 if (compose->toolbar->insert_btn )
2706 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->insert_btn , sensitive);
2707 if (compose->toolbar->attach_btn)
2708 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->attach_btn, sensitive);
2709 if (compose->toolbar->sig_btn)
2710 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->sig_btn, sensitive);
2711 if (compose->toolbar->repsig_btn)
2712 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->repsig_btn, sensitive);
2713 if (compose->toolbar->exteditor_btn)
2714 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->exteditor_btn, sensitive);
2715 if (compose->toolbar->linewrap_current_btn)
2716 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->linewrap_current_btn, sensitive);
2717 if (compose->toolbar->linewrap_all_btn)
2718 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->linewrap_all_btn, sensitive);
2719 if (compose->toolbar->addrbook_btn)
2720 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->addrbook_btn, sensitive);
2722 if (compose->toolbar->spellcheck_btn)
2723 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->spellcheck_btn, sensitive);
2725 for (; items != NULL; items = g_slist_next(items)) {
2726 ToolbarClawsActions *item = (ToolbarClawsActions *)items->data;
2727 GTK_BUTTON_SET_SENSITIVE(item->widget, sensitive);
2732 * Initialize toolbar structure
2734 static void toolbar_init(Toolbar * toolbar)
2737 toolbar->toolbar = NULL;
2738 toolbar->folders_btn = NULL;
2739 toolbar->get_btn = NULL;
2740 toolbar->getall_btn = NULL;
2741 toolbar->send_btn = NULL;
2742 toolbar->compose_mail_btn = NULL;
2743 toolbar->compose_mail_icon = NULL;
2744 toolbar->compose_news_icon = NULL;
2745 toolbar->reply_btn = NULL;
2746 toolbar->replysender_btn = NULL;
2747 toolbar->replyall_btn = NULL;
2748 toolbar->replylist_btn = NULL;
2749 toolbar->fwd_btn = NULL;
2750 toolbar->trash_btn = NULL;
2751 toolbar->delete_btn = NULL;
2752 toolbar->prev_btn = NULL;
2753 toolbar->next_btn = NULL;
2754 toolbar->exec_btn = NULL;
2755 toolbar->separator = NULL;
2756 toolbar->learn_spam_btn = NULL;
2757 toolbar->learn_spam_icon = NULL;
2758 toolbar->learn_ham_icon = NULL;
2759 toolbar->cancel_inc_btn = NULL;
2760 toolbar->cancel_send_btn = NULL;
2761 toolbar->cancel_all_btn = NULL;
2763 /* compose buttons */
2764 toolbar->sendl_btn = NULL;
2765 toolbar->draft_btn = NULL;
2766 toolbar->insert_btn = NULL;
2767 toolbar->attach_btn = NULL;
2768 toolbar->sig_btn = NULL;
2769 toolbar->repsig_btn = NULL;
2770 toolbar->exteditor_btn = NULL;
2771 toolbar->linewrap_current_btn = NULL;
2772 toolbar->linewrap_all_btn = NULL;
2773 toolbar->addrbook_btn = NULL;
2775 toolbar->open_mail_btn = NULL;
2776 toolbar->close_window_btn = NULL;
2777 toolbar->preferences_btn = NULL;
2778 toolbar->action_list = NULL;
2779 toolbar->item_list = NULL;
2781 toolbar->spellcheck_btn = NULL;
2784 toolbar_destroy(toolbar);
2789 static void toolbar_reply(gpointer data, guint action)
2791 ToolbarItem *toolbar_item = (ToolbarItem*)data;
2792 MainWindow *mainwin;
2793 MessageView *msgview;
2794 GSList *msginfo_list = NULL;
2796 cm_return_if_fail(toolbar_item != NULL);
2798 switch (toolbar_item->type) {
2800 mainwin = (MainWindow*)toolbar_item->parent;
2801 msginfo_list = summary_get_selection(mainwin->summaryview);
2802 msgview = (MessageView*)mainwin->messageview;
2804 case TOOLBAR_MSGVIEW:
2805 msgview = (MessageView*)toolbar_item->parent;
2806 cm_return_if_fail(msgview != NULL);
2807 msginfo_list = g_slist_append(msginfo_list, msgview->msginfo);
2813 cm_return_if_fail(msgview != NULL);
2814 cm_return_if_fail(msginfo_list != NULL);
2815 compose_reply_from_messageview(msgview, msginfo_list, action);
2816 g_slist_free(msginfo_list);
2818 /* TODO: update reply state ion summaryview */
2822 /* exported functions */
2824 void inc_mail_cb(gpointer data, guint action, GtkWidget *widget)
2826 MainWindow *mainwin = (MainWindow*)data;
2828 inc_mail(mainwin, prefs_common.newmail_notify_manu);
2831 void inc_all_account_mail_cb(gpointer data, guint action, GtkWidget *widget)
2833 MainWindow *mainwin = (MainWindow*)data;
2835 inc_all_account_mail(mainwin, FALSE, prefs_common.newmail_notify_manu);
2838 void send_queue_cb(gpointer data, guint action, GtkWidget *widget)
2842 gboolean got_error = FALSE;
2843 gchar *errstr = NULL;
2845 if (prefs_common.work_offline)
2846 if (alertpanel(_("Offline warning"),
2847 _("You're working offline. Override?"),
2848 GTK_STOCK_NO, GTK_STOCK_YES,
2849 NULL) != G_ALERTALTERNATE)
2852 /* ask for confirmation before sending queued messages only
2853 in online mode and if there is at least one message queued
2854 in any of the folder queue
2856 if (prefs_common.confirm_send_queued_messages) {
2858 /* check if there's a queued message */
2859 for (list = folder_get_list(); !found && list != NULL; list = list->next) {
2860 Folder *folder = list->data;
2862 found = !procmsg_queue_is_empty(folder->queue);
2864 /* if necessary, ask for confirmation before sending */
2865 if (found && !prefs_common.work_offline) {
2866 if (alertpanel(_("Send queued messages"),
2867 _("Send all queued messages?"),
2868 GTK_STOCK_CANCEL, _("_Send"),
2869 NULL) != G_ALERTALTERNATE)
2874 for (list = folder_get_list(); list != NULL; list = list->next) {
2875 Folder *folder = list->data;
2877 if (folder->queue) {
2878 if (procmsg_send_queue(folder->queue,
2879 prefs_common.savemsg,
2886 alertpanel_error_log(_("Some errors occurred while "
2887 "sending queued messages."));
2889 alertpanel_error_log(_("Some errors occurred "
2890 "while sending queued messages:\n%s"), errstr);
2896 void compose_mail_cb(gpointer data, guint action, GtkWidget *widget)
2898 MainWindow *mainwin = (MainWindow*)data;
2899 PrefsAccount *ac = NULL;
2900 FolderItem *item = mainwin->summaryview->folder_item;
2905 ac = account_find_from_item(item);
2906 if (ac && ac->protocol != A_NNTP && ac->protocol != A_IMAP4) {
2907 compose_new_with_folderitem(ac, item, NULL); /* CLAWS */
2913 * CLAWS - use current account
2915 if (cur_account && (cur_account->protocol != A_NNTP)) {
2916 compose_new_with_folderitem(cur_account, item, NULL);
2921 * CLAWS - just get the first one
2923 list = account_get_list();
2924 for (cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2925 ac = (PrefsAccount *) cur->data;
2926 if (ac->protocol != A_NNTP) {
2927 compose_new_with_folderitem(ac, item, NULL);
2933 void compose_news_cb(gpointer data, guint action, GtkWidget *widget)
2935 MainWindow *mainwin = (MainWindow*)data;
2936 PrefsAccount * ac = NULL;
2940 if (mainwin->summaryview->folder_item) {
2941 ac = mainwin->summaryview->folder_item->folder->account;
2942 if (ac && ac->protocol == A_NNTP) {
2943 compose_new_with_folderitem(ac,
2944 mainwin->summaryview->folder_item, NULL);
2949 list = account_get_list();
2950 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2951 ac = (PrefsAccount *) cur->data;
2952 if (ac->protocol == A_NNTP) {
2953 compose_new_with_folderitem(ac,
2954 mainwin->summaryview->folder_item, NULL);