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,
82 ToolbarType source, gboolean *rewrite);
84 static gint toolbar_ret_val_from_text (const gchar *text);
85 static gchar *toolbar_ret_text_from_val (gint val);
87 typedef struct _DefaultToolbar DefaultToolbar;
88 struct _DefaultToolbar {
91 static void toolbar_set_default_generic(ToolbarType toolbar_type,
92 DefaultToolbar *default_toolbar);
94 static void toolbar_style (ToolbarType type,
98 static MainWindow *get_mainwin (gpointer data);
99 static void activate_compose_button (Toolbar *toolbar,
101 ComposeButtonType type);
103 /* toolbar callbacks */
104 static void toolbar_reply (gpointer data,
107 static void toolbar_learn (gpointer data,
110 static void toolbar_trash_cb (GtkWidget *widget,
113 static void toolbar_delete_cb (GtkWidget *widget,
116 static void toolbar_delete_dup_cb (GtkWidget *widget,
120 static void toolbar_compose_cb (GtkWidget *widget,
123 static void toolbar_learn_cb (GtkWidget *widget,
126 static void toolbar_reply_cb (GtkWidget *widget,
129 static void toolbar_reply_to_all_cb (GtkWidget *widget,
132 static void toolbar_reply_to_list_cb (GtkWidget *widget,
135 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
138 static void toolbar_forward_cb (GtkWidget *widget,
141 static void toolbar_prev_unread_cb (GtkWidget *widget,
143 static void toolbar_next_unread_cb (GtkWidget *widget,
146 static void toolbar_ignore_thread_cb (GtkWidget *widget,
149 static void toolbar_watch_thread_cb (GtkWidget *widget,
152 static void toolbar_mark_cb (GtkWidget *widget,
155 static void toolbar_unmark_cb (GtkWidget *widget,
158 static void toolbar_lock_cb (GtkWidget *widget,
161 static void toolbar_ulock_cb (GtkWidget *widget,
164 static void toolbar_all_read_cb (GtkWidget *widget,
167 static void toolbar_all_unread_cb (GtkWidget *widget,
170 static void toolbar_read_cb (GtkWidget *widget,
173 static void toolbar_unread_cb (GtkWidget *widget,
176 static void toolbar_print_cb (GtkWidget *widget,
179 static void toolbar_actions_execute_cb (GtkWidget *widget,
181 static void toolbar_plugins_execute_cb (GtkWidget *widget,
185 static void toolbar_send_cb (GtkWidget *widget,
187 static void toolbar_send_later_cb (GtkWidget *widget,
189 static void toolbar_draft_cb (GtkWidget *widget,
191 static void toolbar_close_cb (GtkWidget *widget,
193 static void toolbar_preferences_cb (GtkWidget *widget,
195 static void toolbar_open_mail_cb (GtkWidget *widget,
197 static void toolbar_insert_cb (GtkWidget *widget,
199 static void toolbar_attach_cb (GtkWidget *widget,
201 static void toolbar_sig_cb (GtkWidget *widget,
203 static void toolbar_ext_editor_cb (GtkWidget *widget,
205 static void toolbar_linewrap_current_cb (GtkWidget *widget,
207 static void toolbar_linewrap_all_cb (GtkWidget *widget,
209 static void toolbar_addrbook_cb (GtkWidget *widget,
212 static void toolbar_check_spelling_cb (GtkWidget *widget,
215 static void toolbar_cancel_inc_cb (GtkWidget *widget,
217 static void toolbar_cancel_send_cb (GtkWidget *widget,
219 static void toolbar_cancel_all_cb (GtkWidget *widget,
225 } toolbar_text [] = {
226 { "A_RECEIVE_ALL", N_("Receive Mail from all Accounts") },
227 { "A_RECEIVE_CUR", N_("Receive Mail from current Account") },
228 { "A_SEND_QUEUED", N_("Send Queued Messages") },
229 { "A_COMPOSE_EMAIL", N_("Compose Email") },
230 { "A_COMPOSE_NEWS", N_("Compose News") },
231 { "A_REPLY_MESSAGE", N_("Reply to Message") },
232 { "A_REPLY_SENDER", N_("Reply to Sender") },
233 { "A_REPLY_ALL", N_("Reply to All") },
234 { "A_REPLY_ML", N_("Reply to Mailing-list") },
235 { "A_OPEN_MAIL", N_("Open email") },
236 { "A_FORWARD", N_("Forward Message") },
237 { "A_TRASH", N_("Trash Message") },
238 { "A_DELETE_REAL", N_("Delete Message") },
239 { "A_DELETE_DUP", N_("Delete duplicate messages in current folder") },
240 { "A_EXECUTE", N_("Execute") },
241 { "A_GOTO_PREV", N_("Go to Previous Unread Message") },
242 { "A_GOTO_NEXT", N_("Go to Next Unread Message") },
244 { "A_IGNORE_THREAD", N_("Ignore thread") },
245 { "A_WATCH_THREAD", N_("Watch thread") },
246 { "A_MARK", N_("Mark Message") },
247 { "A_UNMARK", N_("Unmark Message") },
248 { "A_LOCK", N_("Lock Message") },
249 { "A_UNLOCK", N_("Unlock Message") },
250 { "A_ALL_READ", N_("Mark all Messages as read") },
251 { "A_ALL_UNREAD", N_("Mark all Messages as unread") },
252 { "A_READ", N_("Mark Message as read") },
253 { "A_UNREAD", N_("Mark Message as unread") },
255 { "A_PRINT", N_("Print") },
256 { "A_LEARN_SPAM", N_("Learn Spam or Ham") },
257 { "A_GO_FOLDERS", N_("Open folder/Go to folder list") },
258 { "A_PREFERENCES", N_("Preferences") },
260 { "A_SEND", N_("Send Message") },
261 { "A_SEND_LATER", N_("Put into queue folder and send later") },
262 { "A_DRAFT", N_("Save to draft folder") },
263 { "A_INSERT", N_("Insert file") },
264 { "A_ATTACH", N_("Attach file") },
265 { "A_SIG", N_("Insert signature") },
266 { "A_REP_SIG", N_("Replace signature") },
267 { "A_EXTEDITOR", N_("Edit with external editor") },
268 { "A_LINEWRAP_CURRENT", N_("Wrap long lines of current paragraph") },
269 { "A_LINEWRAP_ALL", N_("Wrap all long lines") },
270 { "A_ADDRBOOK", N_("Address book") },
272 { "A_CHECK_SPELLING", N_("Check spelling") },
274 { "A_CLAWS_ACTIONS", N_("Claws Mail Actions Feature") },
275 { "A_CANCEL_INC", N_("Cancel receiving") },
276 { "A_CANCEL_SEND", N_("Cancel sending") },
277 { "A_CANCEL_ALL", N_("Cancel receiving/sending") },
278 { "A_CLOSE", N_("Close window") },
279 { "A_SEPARATOR", N_("Separator") },
280 { "A_CLAWS_PLUGINS", N_("Claws Mail Plugins") }
283 /* migration table: support reading toolbar configuration files with
284 old action names and converting them to current action names,
285 see toolbar_parse_item(), which makes uses of this alias table.
288 const gchar *old_name;
289 const gchar *current_name;
290 } toolbar_migration [] = {
291 { "A_SYL_ACTIONS", "A_CLAWS_ACTIONS" },
292 { "A_SENDL", "A_SEND_LATER" },
296 /* struct holds configuration files and a list of
297 * currently active toolbar items
298 * TOOLBAR_MAIN, TOOLBAR_COMPOSE and TOOLBAR_MSGVIEW
302 const gchar *conf_file;
304 } toolbar_config[NUM_TOOLBARS] = {
305 { "toolbar_main.xml", NULL},
306 { "toolbar_compose.xml", NULL},
307 { "toolbar_msgview.xml", NULL}
310 gint toolbar_ret_val_from_descr(const gchar *descr)
314 for (i = 0; i < N_ACTION_VAL; i++) {
315 if (g_utf8_collate(gettext(toolbar_text[i].descr), descr) == 0)
322 gchar *toolbar_ret_descr_from_val(gint val)
324 cm_return_val_if_fail(val >=0 && val < N_ACTION_VAL, NULL);
326 return gettext(toolbar_text[val].descr);
329 static gint toolbar_ret_val_from_text(const gchar *text)
333 for (i = 0; i < N_ACTION_VAL; i++) {
334 if (g_utf8_collate(toolbar_text[i].index_str, text) == 0)
341 static gchar *toolbar_ret_text_from_val(gint val)
343 cm_return_val_if_fail(val >=0 && val < N_ACTION_VAL, NULL);
345 return toolbar_text[val].index_str;
348 static gboolean toolbar_is_duplicate(gint action, ToolbarType source)
352 if ((action == A_SEPARATOR) || (action == A_CLAWS_ACTIONS) || (action == A_CLAWS_PLUGINS))
355 for (cur = toolbar_config[source].item_list; cur != NULL; cur = cur->next) {
356 ToolbarItem *item = (ToolbarItem*) cur->data;
358 if (item->index == action)
364 /* depending on toolbar type this function
365 returns a list of available toolbar events being
366 displayed by prefs_toolbar
368 GList *toolbar_get_action_items(ToolbarType source)
373 if (source == TOOLBAR_MAIN) {
374 gint main_items[] = {
375 A_RECEIVE_ALL, A_RECEIVE_CUR, A_SEND_QUEUED,
376 A_COMPOSE_EMAIL, A_REPLY_MESSAGE, A_REPLY_SENDER,
377 A_REPLY_ALL, A_REPLY_ML, A_OPEN_MAIL, A_FORWARD,
378 A_TRASH, A_DELETE_REAL, A_DELETE_DUP, A_EXECUTE,
379 A_GOTO_PREV, A_GOTO_NEXT, A_IGNORE_THREAD, A_WATCH_THREAD,
380 A_MARK, A_UNMARK, A_LOCK, A_UNLOCK,
381 A_ALL_READ, A_ALL_UNREAD, A_READ, A_UNREAD,
382 A_PRINT, A_ADDRBOOK, A_LEARN_SPAM, A_GO_FOLDERS,
383 A_CANCEL_INC, A_CANCEL_SEND, A_CANCEL_ALL, A_PREFERENCES };
385 for (i = 0; i < sizeof main_items / sizeof main_items[0]; i++) {
386 items = g_list_append(items, gettext(toolbar_text[main_items[i]].descr));
389 else if (source == TOOLBAR_COMPOSE) {
390 gint comp_items[] = {
391 A_SEND, A_SEND_LATER, A_DRAFT,
392 A_INSERT, A_ATTACH, A_SIG,
393 A_REP_SIG, A_EXTEDITOR, A_LINEWRAP_CURRENT,
394 A_LINEWRAP_ALL, A_ADDRBOOK,
400 for (i = 0; i < sizeof comp_items / sizeof comp_items[0]; i++)
401 items = g_list_append(items, gettext(toolbar_text[comp_items[i]].descr));
403 else if (source == TOOLBAR_MSGVIEW) {
404 gint msgv_items[] = {
405 A_COMPOSE_EMAIL, A_REPLY_MESSAGE, A_REPLY_SENDER,
406 A_REPLY_ALL, A_REPLY_ML, A_FORWARD,
407 A_TRASH, A_DELETE_REAL, A_GOTO_PREV, A_GOTO_NEXT,
408 A_ADDRBOOK, A_LEARN_SPAM, A_CLOSE };
410 for (i = 0; i < sizeof msgv_items / sizeof msgv_items[0]; i++)
411 items = g_list_append(items, gettext(toolbar_text[msgv_items[i]].descr));
417 static void toolbar_parse_item(XMLFile *file, ToolbarType source, gboolean *rewrite)
421 ToolbarItem *item = NULL;
423 g_return_if_fail(rewrite != NULL);
425 attr = xml_get_current_tag_attr(file);
426 item = g_new0(ToolbarItem, 1);
428 name = ((XMLAttr *)attr->data)->name;
429 value = ((XMLAttr *)attr->data)->value;
431 if (g_utf8_collate(name, TOOLBAR_ICON_FILE) == 0)
432 item->file = g_strdup (value);
433 else if (g_utf8_collate(name, TOOLBAR_ICON_TEXT) == 0)
434 item->text = g_strdup (*value ? gettext(value):"");
435 else if (g_utf8_collate(name, TOOLBAR_ICON_ACTION) == 0)
436 item->index = toolbar_ret_val_from_text(value);
438 if ((item->index == -1) && !strcmp(value, "A_DELETE")) {
440 item->index = A_TRASH;
442 item->file = g_strdup("trash_btn");
444 item->text = g_strdup(C_("Toolbar", "Trash"));
447 if (item->index == -1) {
448 /* item not found in table: try migrating old action names to current ones */
451 /* replace action name */
452 for (i = 0; toolbar_migration[i].old_name != NULL; i++) {
453 if (g_utf8_collate(value, toolbar_migration[i].old_name) == 0) {
454 item->index = toolbar_ret_val_from_text(toolbar_migration[i].current_name);
455 if (item->index != -1) {
457 debug_print("toolbar_parse_item: migrating action label from '%s' to '%s'\n",
458 value, toolbar_migration[i].current_name);
464 if ((item->index == -1) && !rewrite)
465 g_warning("toolbar_parse_item: unrecognized action name '%s'\n", value);
467 attr = g_list_next(attr);
469 if (item->index != -1) {
470 if (!toolbar_is_duplicate(item->index, source))
471 toolbar_config[source].item_list = g_slist_append(toolbar_config[source].item_list,
476 const gchar *toolbar_get_short_text(int action) {
478 case A_RECEIVE_ALL: return _("Get Mail");
479 case A_RECEIVE_CUR: return _("Get");
480 case A_SEND_QUEUED: return _("Send");
481 case A_COMPOSE_EMAIL: return C_("Toolbar", "Compose");
482 case A_COMPOSE_NEWS: return C_("Toolbar", "Compose");
483 case A_REPLY_MESSAGE: return _("Reply");
484 case A_REPLY_SENDER: return C_("Toolbar", "Sender");
485 case A_REPLY_ALL: return _("All");
486 case A_REPLY_ML: return _("List");
487 case A_OPEN_MAIL: return _("Open");
488 case A_FORWARD: return _("Forward");
489 case A_TRASH: return C_("Toolbar", "Trash");
490 case A_DELETE_REAL: return _("Delete");
491 case A_DELETE_DUP: return _("Delete duplicates");
492 case A_EXECUTE: return _("Execute");
493 case A_GOTO_PREV: return _("Prev");
494 case A_GOTO_NEXT: return _("Next");
496 case A_IGNORE_THREAD: return _("Ignore thread");
497 case A_WATCH_THREAD: return _("Watch thread");
498 case A_MARK: return _("Mark");
499 case A_UNMARK: return _("Unmark");
500 case A_LOCK: return _("Lock");
501 case A_UNLOCK: return _("Unlock");
502 case A_ALL_READ: return _("All read");
503 case A_ALL_UNREAD: return _("All unread");
504 case A_READ: return _("Read");
505 case A_UNREAD: return _("Unread");
507 case A_PRINT: return _("Print");
508 case A_LEARN_SPAM: return _("Spam");
509 case A_GO_FOLDERS: return _("Folders");
510 case A_PREFERENCES: return _("Preferences");
512 case A_SEND: return _("Send");
513 case A_SEND_LATER: return _("Send later");
514 case A_DRAFT: return _("Draft");
515 case A_INSERT: return _("Insert");
516 case A_ATTACH: return _("Attach");
517 case A_SIG: return _("Insert sig.");
518 case A_REP_SIG: return _("Replace sig.");
519 case A_EXTEDITOR: return _("Edit");
520 case A_LINEWRAP_CURRENT:return _("Wrap para.");
521 case A_LINEWRAP_ALL: return _("Wrap all");
522 case A_ADDRBOOK: return _("Address");
524 case A_CHECK_SPELLING: return _("Check spelling");
527 case A_CANCEL_INC: return _("Stop");
528 case A_CANCEL_SEND: return _("Stop");
529 case A_CANCEL_ALL: return _("Stop all");
530 case A_CLOSE: return _("Close");
535 gint toolbar_get_icon(int action) {
537 case A_RECEIVE_ALL: return STOCK_PIXMAP_MAIL_RECEIVE_ALL;
538 case A_RECEIVE_CUR: return STOCK_PIXMAP_MAIL_RECEIVE;
539 case A_SEND_QUEUED: return STOCK_PIXMAP_MAIL_SEND_QUEUE;
540 case A_COMPOSE_EMAIL: return STOCK_PIXMAP_MAIL_COMPOSE;
541 case A_COMPOSE_NEWS: return STOCK_PIXMAP_NEWS_COMPOSE;
542 case A_REPLY_MESSAGE: return STOCK_PIXMAP_MAIL_REPLY;
543 case A_REPLY_SENDER: return STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR;
544 case A_REPLY_ALL: return STOCK_PIXMAP_MAIL_REPLY_TO_ALL;
545 case A_REPLY_ML: return STOCK_PIXMAP_MAIL_REPLY_TO_LIST;
546 case A_OPEN_MAIL: return STOCK_PIXMAP_OPEN_MAIL;
547 case A_FORWARD: return STOCK_PIXMAP_MAIL_FORWARD;
548 case A_TRASH: return STOCK_PIXMAP_TRASH;
549 case A_DELETE_REAL: return STOCK_PIXMAP_DELETE;
550 case A_DELETE_DUP: return STOCK_PIXMAP_DELETE_DUP;
551 case A_EXECUTE: return STOCK_PIXMAP_EXEC;
552 case A_GOTO_PREV: return STOCK_PIXMAP_UP_ARROW;
553 case A_GOTO_NEXT: return STOCK_PIXMAP_DOWN_ARROW;
555 case A_IGNORE_THREAD: return STOCK_PIXMAP_MARK_IGNORETHREAD;
556 case A_WATCH_THREAD: return STOCK_PIXMAP_MARK_WATCHTHREAD;
557 case A_MARK: return STOCK_PIXMAP_MARK_MARK;
558 case A_UNMARK: return STOCK_PIXMAP_MARK_UNMARK;
559 case A_LOCK: return STOCK_PIXMAP_MARK_LOCKED;
560 case A_UNLOCK: return STOCK_PIXMAP_MARK_UNLOCKED;
561 case A_ALL_READ: return STOCK_PIXMAP_MARK_ALLREAD;
562 case A_ALL_UNREAD: return STOCK_PIXMAP_MARK_ALLUNREAD;
563 case A_READ: return STOCK_PIXMAP_MARK_READ;
564 case A_UNREAD: return STOCK_PIXMAP_MARK_UNREAD;
566 case A_PRINT: return STOCK_PIXMAP_PRINTER;
567 case A_LEARN_SPAM: return STOCK_PIXMAP_SPAM_BTN;
568 case A_GO_FOLDERS: return STOCK_PIXMAP_GO_FOLDERS;
569 case A_PREFERENCES: return STOCK_PIXMAP_PREFERENCES;
571 case A_SEND: return STOCK_PIXMAP_MAIL_SEND;
572 case A_SEND_LATER: return STOCK_PIXMAP_MAIL_SEND_QUEUE;
573 case A_DRAFT: return STOCK_PIXMAP_MAIL;
574 case A_INSERT: return STOCK_PIXMAP_INSERT_FILE;
575 case A_ATTACH: return STOCK_PIXMAP_MAIL_ATTACH;
576 case A_SIG: return STOCK_PIXMAP_MAIL_SIGN;
577 case A_REP_SIG: return STOCK_PIXMAP_MAIL_SIGN;
578 case A_EXTEDITOR: return STOCK_PIXMAP_EDIT_EXTERN;
579 case A_LINEWRAP_CURRENT:return STOCK_PIXMAP_LINEWRAP_CURRENT;
580 case A_LINEWRAP_ALL: return STOCK_PIXMAP_LINEWRAP_ALL;
581 case A_ADDRBOOK: return STOCK_PIXMAP_ADDRESS_BOOK;
583 case A_CHECK_SPELLING: return STOCK_PIXMAP_CHECK_SPELLING;
586 case A_CANCEL_INC: return STOCK_PIXMAP_CANCEL;
587 case A_CANCEL_SEND: return STOCK_PIXMAP_CANCEL;
588 case A_CANCEL_ALL: return STOCK_PIXMAP_CANCEL;
589 case A_CLOSE: return STOCK_PIXMAP_CLOSE;
594 static void toolbar_set_default_generic(ToolbarType toolbar_type, DefaultToolbar *default_toolbar)
598 g_return_if_fail(default_toolbar != NULL);
600 for (i = 0; default_toolbar[i].action != N_ACTION_VAL; i++) {
602 ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
604 if (default_toolbar[i].action != A_SEPARATOR) {
608 icon = toolbar_get_icon(default_toolbar[i].action);
610 file = stock_pixmap_get_name((StockPixmap)icon);
612 toolbar_item->file = g_strdup(file);
613 toolbar_item->index = default_toolbar[i].action;
614 toolbar_item->text = g_strdup(toolbar_get_short_text(default_toolbar[i].action));
616 toolbar_item->file = g_strdup(TOOLBAR_TAG_SEPARATOR);
617 toolbar_item->index = A_SEPARATOR;
620 if (toolbar_item->index != -1) {
621 if (!toolbar_is_duplicate(toolbar_item->index, toolbar_type))
622 toolbar_config[toolbar_type].item_list =
623 g_slist_append(toolbar_config[toolbar_type].item_list, toolbar_item);
628 void toolbar_set_default(ToolbarType source)
630 DefaultToolbar default_toolbar_main[] = {
656 DefaultToolbar default_toolbar_compose[] = {
674 DefaultToolbar default_toolbar_msgview[] = {
692 if (source == TOOLBAR_MAIN)
693 toolbar_set_default_generic(TOOLBAR_MAIN, default_toolbar_main);
694 else if (source == TOOLBAR_COMPOSE)
695 toolbar_set_default_generic(TOOLBAR_COMPOSE, default_toolbar_compose);
696 else if (source == TOOLBAR_MSGVIEW)
697 toolbar_set_default_generic(TOOLBAR_MSGVIEW, default_toolbar_msgview);
700 void toolbar_save_config_file(ToolbarType source)
705 gchar *fileSpec = NULL;
707 debug_print("save Toolbar Configuration to %s\n", toolbar_config[source].conf_file);
709 fileSpec = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, toolbar_config[source].conf_file, NULL );
710 pfile = prefs_write_open(fileSpec);
713 if (fprintf(fp, "<?xml version=\"1.0\" encoding=\"%s\" ?>\n", CS_INTERNAL) < 0)
716 if (fprintf(fp, "<%s>\n", TOOLBAR_TAG_INDEX) < 0)
719 for (cur = toolbar_config[source].item_list; cur != NULL; cur = cur->next) {
720 ToolbarItem *toolbar_item = (ToolbarItem*) cur->data;
722 if (toolbar_item->index != A_SEPARATOR) {
723 if (fprintf(fp, "\t<%s %s=\"%s\" %s=\"",
725 TOOLBAR_ICON_FILE, toolbar_item->file,
726 TOOLBAR_ICON_TEXT) < 0)
728 if (xml_file_put_escape_str(fp, toolbar_item->text) < 0)
730 if (fprintf(fp, "\" %s=\"%s\"/>\n",
732 toolbar_ret_text_from_val(toolbar_item->index)) < 0)
735 if (fprintf(fp, "\t<%s/>\n", TOOLBAR_TAG_SEPARATOR) < 0)
740 if (fprintf(fp, "</%s>\n", TOOLBAR_TAG_INDEX) < 0)
744 if (prefs_file_close (pfile) < 0 )
745 g_warning("failed to write toolbar configuration to file");
749 FILE_OP_ERROR(fileSpec, "fprintf");
751 prefs_file_close_revert (pfile);
753 g_warning("failed to open toolbar configuration file for writing");
756 void toolbar_read_config_file(ToolbarType source)
758 XMLFile *file = NULL;
759 gchar *fileSpec = NULL;
761 gboolean rewrite = FALSE;
763 debug_print("read Toolbar Configuration from %s\n", toolbar_config[source].conf_file);
765 fileSpec = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, toolbar_config[source].conf_file, NULL );
766 file = xml_open_file(fileSpec);
769 toolbar_clear_list(source);
773 || (xml_get_dtd(file))
774 || (xml_parse_next_tag(file))
775 || (!xml_compare_tag(file, TOOLBAR_TAG_INDEX))) {
776 xml_close_file(file);
784 if (xml_parse_next_tag(file))
787 /* Get next tag (icon, icon_text or icon_action) */
788 if (xml_compare_tag(file, TOOLBAR_TAG_ITEM)) {
789 toolbar_parse_item(file, source, &rewrite);
790 } else if (xml_compare_tag(file, TOOLBAR_TAG_SEPARATOR)) {
791 ToolbarItem *item = g_new0(ToolbarItem, 1);
793 item->file = g_strdup(TOOLBAR_TAG_SEPARATOR);
794 item->index = A_SEPARATOR;
795 toolbar_config[source].item_list =
796 g_slist_append(toolbar_config[source].item_list, item);
800 xml_close_file(file);
802 debug_print("toolbar_read_config_file: rewriting toolbar\n");
803 toolbar_save_config_file(source);
807 if ((!file) || (g_slist_length(toolbar_config[source].item_list) == 0)) {
809 if (source == TOOLBAR_MAIN)
810 toolbar_set_default(TOOLBAR_MAIN);
811 else if (source == TOOLBAR_COMPOSE)
812 toolbar_set_default(TOOLBAR_COMPOSE);
813 else if (source == TOOLBAR_MSGVIEW)
814 toolbar_set_default(TOOLBAR_MSGVIEW);
816 g_warning("refusing to write unknown Toolbar Configuration number %d", source);
820 toolbar_save_config_file(source);
825 * clears list of toolbar items read from configuration files
827 void toolbar_clear_list(ToolbarType source)
829 while (toolbar_config[source].item_list != NULL) {
830 ToolbarItem *item = (ToolbarItem*) toolbar_config[source].item_list->data;
832 toolbar_config[source].item_list =
833 g_slist_remove(toolbar_config[source].item_list, item);
839 g_slist_free(toolbar_config[source].item_list);
844 * return list of Toolbar items
846 GSList *toolbar_get_list(ToolbarType source)
850 if ((source == TOOLBAR_MAIN) || (source == TOOLBAR_COMPOSE) || (source == TOOLBAR_MSGVIEW))
851 list = toolbar_config[source].item_list;
856 void toolbar_set_list_item(ToolbarItem *t_item, ToolbarType source)
858 ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
860 toolbar_item->file = g_strdup(t_item->file);
861 toolbar_item->text = g_strdup(t_item->text);
862 toolbar_item->index = t_item->index;
864 toolbar_config[source].item_list =
865 g_slist_append(toolbar_config[source].item_list,
869 static void toolbar_action_execute(GtkWidget *widget,
877 for (cur = action_list; cur != NULL; cur = cur->next) {
878 ToolbarClawsActions *act = (ToolbarClawsActions*)cur->data;
880 if (widget == act->widget) {
881 i = prefs_actions_find_by_name(act->name);
889 actions_execute(data, i, widget, source);
891 g_warning ("Error: did not find Claws Action to execute");
894 gboolean toolbar_check_action_btns(ToolbarType type)
896 GSList *temp, *curr, *list = toolbar_config[type].item_list;
897 gboolean modified = FALSE;
900 while (curr != NULL) {
901 ToolbarItem *toolbar_item = (ToolbarItem *) curr->data;
905 if (toolbar_item->index != A_CLAWS_ACTIONS)
908 if (prefs_actions_find_by_name(toolbar_item->text) == -1) {
909 list = g_slist_delete_link(list, temp);
910 g_free(toolbar_item->file);
911 g_free(toolbar_item->text);
912 g_free(toolbar_item);
920 #define CLAWS_SET_TOOL_ITEM_TIP(widget,tip) { \
921 gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), tip); \
924 #define CLAWS_SET_ARROW_TIP(widget,tip) { \
925 gtk_menu_tool_button_set_arrow_tooltip_text(GTK_MENU_TOOL_BUTTON(widget), tip); \
928 static void activate_compose_button (Toolbar *toolbar,
930 ComposeButtonType type)
932 if ((!toolbar->compose_mail_btn))
935 if (type == COMPOSEBUTTON_NEWS) {
936 gtk_tool_button_set_icon_widget(
937 GTK_TOOL_BUTTON(toolbar->compose_mail_btn),
938 toolbar->compose_news_icon);
940 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(toolbar->compose_mail_btn), _("Compose News message"));
942 gtk_widget_show(toolbar->compose_news_icon);
944 gtk_tool_button_set_icon_widget(
945 GTK_TOOL_BUTTON(toolbar->compose_mail_btn),
946 toolbar->compose_mail_icon);
948 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(toolbar->compose_mail_btn), _("Compose Email"));
950 gtk_widget_show(toolbar->compose_mail_icon);
952 toolbar->compose_btn_type = type;
955 void toolbar_set_compose_button(Toolbar *toolbar,
956 ComposeButtonType compose_btn_type)
958 if (toolbar->compose_btn_type != compose_btn_type)
959 activate_compose_button(toolbar,
960 prefs_common.toolbar_style,
964 static void activate_learn_button (Toolbar *toolbar,
966 LearnButtonType type)
968 if ((!toolbar->learn_spam_btn))
971 if (type == LEARN_SPAM) {
972 gtk_tool_button_set_icon_widget(
973 GTK_TOOL_BUTTON(toolbar->learn_spam_btn),
974 toolbar->learn_spam_icon);
975 gtk_tool_button_set_label(
976 GTK_TOOL_BUTTON(toolbar->learn_spam_btn),
979 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(toolbar->learn_spam_btn), _("Learn spam"));
981 gtk_widget_show(toolbar->learn_spam_icon);
983 gtk_tool_button_set_icon_widget(
984 GTK_TOOL_BUTTON(toolbar->learn_spam_btn),
985 toolbar->learn_ham_icon);
986 gtk_tool_button_set_label(
987 GTK_TOOL_BUTTON(toolbar->learn_spam_btn),
990 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(toolbar->learn_spam_btn), _("Learn ham"));
992 gtk_widget_show(toolbar->learn_ham_icon);
994 toolbar->learn_btn_type = type;
997 void toolbar_set_learn_button(Toolbar *toolbar,
998 LearnButtonType learn_btn_type)
1000 if (toolbar->learn_btn_type != learn_btn_type)
1001 activate_learn_button(toolbar,
1002 prefs_common.toolbar_style,
1006 void toolbar_toggle(guint action, gpointer data)
1008 MainWindow *mainwin = (MainWindow*)data;
1012 cm_return_if_fail(mainwin != NULL);
1014 toolbar_style(TOOLBAR_MAIN, action, mainwin);
1016 list = compose_get_compose_list();
1017 for (cur = list; cur != NULL; cur = cur->next) {
1018 toolbar_style(TOOLBAR_COMPOSE, action, cur->data);
1020 list = messageview_get_msgview_list();
1021 for (cur = list; cur != NULL; cur = cur->next) {
1022 toolbar_style(TOOLBAR_MSGVIEW, action, cur->data);
1027 void toolbar_set_style(GtkWidget *toolbar_wid, GtkWidget *handlebox_wid, guint action)
1029 switch ((ToolbarStyle)action) {
1031 gtk_widget_hide(handlebox_wid);
1034 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
1038 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
1042 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
1045 case TOOLBAR_BOTH_HORIZ:
1046 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
1047 GTK_TOOLBAR_BOTH_HORIZ);
1053 prefs_common.toolbar_style = (ToolbarStyle)action;
1054 gtk_widget_set_size_request(handlebox_wid, 1, -1);
1056 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
1057 gtk_widget_show(handlebox_wid);
1058 gtk_widget_queue_resize(handlebox_wid);
1062 * Change the style of toolbar
1064 static void toolbar_style(ToolbarType type, guint action, gpointer data)
1066 GtkWidget *handlebox_wid;
1067 GtkWidget *toolbar_wid;
1068 MainWindow *mainwin = (MainWindow*)data;
1069 Compose *compose = (Compose*)data;
1070 MessageView *msgview = (MessageView*)data;
1072 cm_return_if_fail(data != NULL);
1076 handlebox_wid = mainwin->handlebox;
1077 toolbar_wid = mainwin->toolbar->toolbar;
1079 case TOOLBAR_COMPOSE:
1080 handlebox_wid = compose->handlebox;
1081 toolbar_wid = compose->toolbar->toolbar;
1083 case TOOLBAR_MSGVIEW:
1084 handlebox_wid = msgview->handlebox;
1085 toolbar_wid = msgview->toolbar->toolbar;
1091 toolbar_set_style(toolbar_wid, handlebox_wid, action);
1094 /* Toolbar handling */
1095 static void toolbar_inc_cb(GtkWidget *widget,
1098 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1099 MainWindow *mainwin;
1101 cm_return_if_fail(toolbar_item != NULL);
1103 switch (toolbar_item->type) {
1105 mainwin = (MainWindow*)toolbar_item->parent;
1106 inc_mail_cb(mainwin, 0, NULL);
1113 static void toolbar_inc_all_cb(GtkWidget *widget,
1116 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1117 MainWindow *mainwin;
1119 cm_return_if_fail(toolbar_item != NULL);
1121 switch (toolbar_item->type) {
1123 mainwin = (MainWindow*)toolbar_item->parent;
1124 inc_all_account_mail_cb(mainwin, 0, NULL);
1131 static void toolbar_send_queued_cb(GtkWidget *widget,gpointer data)
1133 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1134 MainWindow *mainwin;
1136 cm_return_if_fail(toolbar_item != NULL);
1138 switch (toolbar_item->type) {
1140 mainwin = (MainWindow*)toolbar_item->parent;
1141 send_queue_cb(mainwin, 0, NULL);
1148 static void toolbar_exec_cb(GtkWidget *widget,
1151 MainWindow *mainwin = get_mainwin(data);
1153 cm_return_if_fail(mainwin != NULL);
1154 summary_execute(mainwin->summaryview);
1158 * Delete current/selected(s) message(s)
1160 static void toolbar_trash_cb(GtkWidget *widget, gpointer data)
1162 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1163 MainWindow *mainwin;
1165 cm_return_if_fail(toolbar_item != NULL);
1166 cm_return_if_fail(toolbar_item->parent);
1168 switch (toolbar_item->type) {
1169 case TOOLBAR_MSGVIEW:
1170 messageview_delete((MessageView *)toolbar_item->parent);
1173 mainwin = (MainWindow *)toolbar_item->parent;
1174 summary_delete_trash(mainwin->summaryview);
1177 debug_print("toolbar event not supported\n");
1183 * Delete current/selected(s) message(s)
1185 static void toolbar_delete_cb(GtkWidget *widget, gpointer data)
1187 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1188 MainWindow *mainwin;
1190 cm_return_if_fail(toolbar_item != NULL);
1191 cm_return_if_fail(toolbar_item->parent);
1193 switch (toolbar_item->type) {
1194 case TOOLBAR_MSGVIEW:
1195 messageview_delete((MessageView *)toolbar_item->parent);
1198 mainwin = (MainWindow *)toolbar_item->parent;
1199 summary_delete(mainwin->summaryview);
1202 debug_print("toolbar event not supported\n");
1207 static void toolbar_delete_dup_cb(GtkWidget *widget, gpointer data)
1209 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1210 MainWindow *mainwin = NULL;
1212 cm_return_if_fail(toolbar_item != NULL);
1214 switch (toolbar_item->type) {
1216 mainwin = (MainWindow*)toolbar_item->parent;
1217 mainwindow_delete_duplicated(mainwin);
1219 case TOOLBAR_COMPOSE:
1220 case TOOLBAR_MSGVIEW:
1228 * Compose new message
1230 static void toolbar_compose_cb(GtkWidget *widget, gpointer data)
1232 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1233 MainWindow *mainwin;
1234 MessageView *msgview;
1236 cm_return_if_fail(toolbar_item != NULL);
1238 switch (toolbar_item->type) {
1240 mainwin = (MainWindow*)toolbar_item->parent;
1241 if (mainwin->toolbar->compose_btn_type == COMPOSEBUTTON_NEWS)
1242 compose_news_cb(mainwin, 0, NULL);
1244 compose_mail_cb(mainwin, 0, NULL);
1246 case TOOLBAR_MSGVIEW:
1247 msgview = (MessageView*)toolbar_item->parent;
1248 compose_new_with_folderitem(NULL,
1249 msgview->msginfo->folder, NULL);
1252 debug_print("toolbar event not supported\n");
1256 static void toolbar_learn(gpointer data, guint as_spam)
1258 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1259 MainWindow *mainwin;
1260 MessageView *msgview;
1262 cm_return_if_fail(toolbar_item != NULL);
1264 switch (toolbar_item->type) {
1266 mainwin = (MainWindow*)toolbar_item->parent;
1268 mainwindow_learn(mainwin, TRUE);
1270 mainwindow_learn(mainwin, FALSE);
1272 case TOOLBAR_MSGVIEW:
1273 msgview = (MessageView*)toolbar_item->parent;
1275 messageview_learn(msgview, TRUE);
1277 messageview_learn(msgview, FALSE);
1280 debug_print("toolbar event not supported\n");
1284 static void toolbar_learn_cb(GtkWidget *widget, gpointer data)
1286 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1287 MainWindow *mainwin;
1288 MessageView *msgview;
1290 cm_return_if_fail(toolbar_item != NULL);
1292 switch (toolbar_item->type) {
1294 mainwin = (MainWindow*)toolbar_item->parent;
1295 if (mainwin->toolbar->learn_btn_type == LEARN_SPAM)
1296 mainwindow_learn(mainwin, TRUE);
1298 mainwindow_learn(mainwin, FALSE);
1300 case TOOLBAR_MSGVIEW:
1301 msgview = (MessageView*)toolbar_item->parent;
1302 if (msgview->toolbar->learn_btn_type == LEARN_SPAM)
1303 messageview_learn(msgview, TRUE);
1305 messageview_learn(msgview, FALSE);
1308 debug_print("toolbar event not supported\n");
1316 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
1318 toolbar_reply(data, (prefs_common.reply_with_quote ?
1319 COMPOSE_REPLY_WITH_QUOTE : COMPOSE_REPLY_WITHOUT_QUOTE));
1324 * Reply message to Sender and All recipients
1326 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
1329 (prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
1330 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE));
1335 * Reply to Mailing List
1337 static void toolbar_reply_to_list_cb(GtkWidget *widget, gpointer data)
1340 (prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_LIST_WITH_QUOTE
1341 : COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE));
1346 * Reply to sender of message
1348 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
1351 (prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
1352 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE));
1358 static void toolbar_addrbook_cb(GtkWidget *widget, gpointer data)
1360 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1363 cm_return_if_fail(toolbar_item != NULL);
1365 switch (toolbar_item->type) {
1367 case TOOLBAR_MSGVIEW:
1370 case TOOLBAR_COMPOSE:
1371 compose = (Compose *)toolbar_item->parent;
1376 #ifndef USE_ALT_ADDRBOOK
1377 addressbook_open(compose);
1379 GError* error = NULL;
1380 addressbook_connect_signals(compose);
1381 addressbook_dbus_open(TRUE, &error);
1383 g_warning("%s", error->message);
1384 g_error_free(error);
1391 * Forward current/selected(s) message(s)
1393 static void toolbar_forward_cb(GtkWidget *widget, gpointer data)
1395 toolbar_reply(data, (COMPOSE_FORWARD));
1399 * Goto Prev Unread Message
1401 static void toolbar_prev_unread_cb(GtkWidget *widget, gpointer data)
1403 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1404 MainWindow *mainwin;
1405 MessageView *msgview;
1407 cm_return_if_fail(toolbar_item != NULL);
1409 switch (toolbar_item->type) {
1411 mainwin = (MainWindow*)toolbar_item->parent;
1412 summary_select_prev_unread(mainwin->summaryview);
1415 case TOOLBAR_MSGVIEW:
1416 msgview = (MessageView*)toolbar_item->parent;
1417 msgview->updating = TRUE;
1418 summary_select_prev_unread(msgview->mainwin->summaryview);
1419 msgview->updating = FALSE;
1421 if (msgview->deferred_destroy) {
1422 debug_print("messageview got away!\n");
1423 messageview_destroy(msgview);
1427 /* Now we need to update the messageview window */
1428 if (msgview->mainwin->summaryview->selected) {
1429 #ifndef GENERIC_UMPC
1430 MsgInfo * msginfo = summary_get_selected_msg(msgview->mainwin->summaryview);
1433 messageview_show(msgview, msginfo,
1434 msgview->all_headers);
1437 gtk_widget_destroy(msgview->window);
1441 debug_print("toolbar event not supported\n");
1446 * Goto Next Unread Message
1448 static void toolbar_next_unread_cb(GtkWidget *widget, gpointer data)
1450 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1451 MainWindow *mainwin;
1452 MessageView *msgview;
1454 cm_return_if_fail(toolbar_item != NULL);
1456 switch (toolbar_item->type) {
1458 mainwin = (MainWindow*)toolbar_item->parent;
1459 summary_select_next_unread(mainwin->summaryview);
1462 case TOOLBAR_MSGVIEW:
1463 msgview = (MessageView*)toolbar_item->parent;
1464 msgview->updating = TRUE;
1465 summary_select_next_unread(msgview->mainwin->summaryview);
1466 msgview->updating = FALSE;
1468 if (msgview->deferred_destroy) {
1469 debug_print("messageview got away!\n");
1470 messageview_destroy(msgview);
1474 /* Now we need to update the messageview window */
1475 if (msgview->mainwin->summaryview->selected) {
1476 #ifndef GENERIC_UMPC
1477 MsgInfo * msginfo = summary_get_selected_msg(msgview->mainwin->summaryview);
1480 messageview_show(msgview, msginfo,
1481 msgview->all_headers);
1484 gtk_widget_destroy(msgview->window);
1488 debug_print("toolbar event not supported\n");
1492 static void toolbar_ignore_thread_cb(GtkWidget *widget, gpointer data)
1494 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1495 MainWindow *mainwin;
1497 cm_return_if_fail(toolbar_item != NULL);
1499 switch (toolbar_item->type) {
1501 mainwin = (MainWindow *) toolbar_item->parent;
1502 summary_toggle_ignore_thread(mainwin->summaryview);
1504 case TOOLBAR_MSGVIEW:
1505 /* TODO: see toolbar_next_unread_cb() if you need
1506 * this in the message view */
1509 debug_print("toolbar event not supported\n");
1514 static void toolbar_watch_thread_cb(GtkWidget *widget, gpointer data)
1516 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1517 MainWindow *mainwin;
1519 cm_return_if_fail(toolbar_item != NULL);
1521 switch (toolbar_item->type) {
1523 mainwin = (MainWindow *) toolbar_item->parent;
1524 summary_toggle_watch_thread(mainwin->summaryview);
1526 case TOOLBAR_MSGVIEW:
1527 /* TODO: see toolbar_next_unread_cb() if you need
1528 * this in the message view */
1531 debug_print("toolbar event not supported\n");
1536 static void toolbar_mark_cb(GtkWidget *widget, gpointer data)
1538 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1539 MainWindow *mainwin;
1541 cm_return_if_fail(toolbar_item != NULL);
1543 switch (toolbar_item->type) {
1545 mainwin = (MainWindow *) toolbar_item->parent;
1546 summary_mark(mainwin->summaryview);
1548 case TOOLBAR_MSGVIEW:
1549 /* TODO: see toolbar_next_unread_cb() if you need
1550 * this in the message view */
1553 debug_print("toolbar event not supported\n");
1558 static void toolbar_unmark_cb(GtkWidget *widget, gpointer data)
1560 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1561 MainWindow *mainwin;
1563 cm_return_if_fail(toolbar_item != NULL);
1565 switch (toolbar_item->type) {
1567 mainwin = (MainWindow *) toolbar_item->parent;
1568 summary_unmark(mainwin->summaryview);
1570 case TOOLBAR_MSGVIEW:
1571 /* TODO: see toolbar_next_unread_cb() if you need
1572 * this in the message view */
1575 debug_print("toolbar event not supported\n");
1580 static void toolbar_lock_cb(GtkWidget *widget, gpointer data)
1582 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1583 MainWindow *mainwin;
1585 cm_return_if_fail(toolbar_item != NULL);
1587 switch (toolbar_item->type) {
1589 mainwin = (MainWindow *) toolbar_item->parent;
1590 summary_msgs_lock(mainwin->summaryview);
1592 case TOOLBAR_MSGVIEW:
1593 /* TODO: see toolbar_next_unread_cb() if you need
1594 * this in the message view */
1597 debug_print("toolbar event not supported\n");
1602 static void toolbar_unlock_cb(GtkWidget *widget, gpointer data)
1604 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1605 MainWindow *mainwin;
1607 cm_return_if_fail(toolbar_item != NULL);
1609 switch (toolbar_item->type) {
1611 mainwin = (MainWindow *) toolbar_item->parent;
1612 summary_msgs_unlock(mainwin->summaryview);
1614 case TOOLBAR_MSGVIEW:
1615 /* TODO: see toolbar_next_unread_cb() if you need
1616 * this in the message view */
1619 debug_print("toolbar event not supported\n");
1624 static void toolbar_all_read_cb(GtkWidget *widget, gpointer data)
1626 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1627 MainWindow *mainwin;
1629 cm_return_if_fail(toolbar_item != NULL);
1631 switch (toolbar_item->type) {
1633 mainwin = (MainWindow *) toolbar_item->parent;
1634 summary_mark_all_read(mainwin->summaryview, TRUE);
1636 case TOOLBAR_MSGVIEW:
1637 /* TODO: see toolbar_next_unread_cb() if you need
1638 * this in the message view */
1641 debug_print("toolbar event not supported\n");
1646 static void toolbar_all_unread_cb(GtkWidget *widget, gpointer data)
1648 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1649 MainWindow *mainwin;
1651 cm_return_if_fail(toolbar_item != NULL);
1653 switch (toolbar_item->type) {
1655 mainwin = (MainWindow *) toolbar_item->parent;
1656 summary_mark_all_unread(mainwin->summaryview, TRUE);
1658 case TOOLBAR_MSGVIEW:
1659 /* TODO: see toolbar_next_unread_cb() if you need
1660 * this in the message view */
1663 debug_print("toolbar event not supported\n");
1668 static void toolbar_read_cb(GtkWidget *widget, gpointer data)
1670 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1671 MainWindow *mainwin;
1673 cm_return_if_fail(toolbar_item != NULL);
1675 switch (toolbar_item->type) {
1677 mainwin = (MainWindow *) toolbar_item->parent;
1678 summary_mark_as_read(mainwin->summaryview);
1680 case TOOLBAR_MSGVIEW:
1681 /* TODO: see toolbar_next_unread_cb() if you need
1682 * this in the message view */
1685 debug_print("toolbar event not supported\n");
1690 static void toolbar_unread_cb(GtkWidget *widget, gpointer data)
1692 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1693 MainWindow *mainwin;
1695 cm_return_if_fail(toolbar_item != NULL);
1697 switch (toolbar_item->type) {
1699 mainwin = (MainWindow *) toolbar_item->parent;
1700 summary_mark_as_unread(mainwin->summaryview);
1702 case TOOLBAR_MSGVIEW:
1703 /* TODO: see toolbar_next_unread_cb() if you need
1704 * this in the message view */
1707 debug_print("toolbar event not supported\n");
1712 static void toolbar_cancel_inc_cb(GtkWidget *widget, gpointer data)
1714 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1716 cm_return_if_fail(toolbar_item != NULL);
1721 static void toolbar_cancel_send_cb(GtkWidget *widget, gpointer data)
1723 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1725 cm_return_if_fail(toolbar_item != NULL);
1729 static void toolbar_cancel_all_cb(GtkWidget *widget, gpointer data)
1731 toolbar_cancel_inc_cb(widget, data);
1732 toolbar_cancel_send_cb(widget, data);
1735 static void toolbar_print_cb(GtkWidget *widget, gpointer data)
1737 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1738 MainWindow *mainwin;
1740 cm_return_if_fail(toolbar_item != NULL);
1742 switch (toolbar_item->type) {
1744 mainwin = (MainWindow *) toolbar_item->parent;
1745 summary_print(mainwin->summaryview);
1747 case TOOLBAR_MSGVIEW:
1748 /* TODO: see toolbar_next_unread_cb() if you need
1749 * this in the message view */
1752 debug_print("toolbar event not supported\n");
1757 static void toolbar_send_cb(GtkWidget *widget, gpointer data)
1759 compose_toolbar_cb(A_SEND, data);
1762 static void toolbar_send_later_cb(GtkWidget *widget, gpointer data)
1764 compose_toolbar_cb(A_SEND_LATER, data);
1767 static void toolbar_draft_cb(GtkWidget *widget, gpointer data)
1769 compose_toolbar_cb(A_DRAFT, data);
1772 static void toolbar_close_cb(GtkWidget *widget, gpointer data)
1774 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1775 MainWindow *mainwin;
1776 MessageView *messageview;
1779 cm_return_if_fail(toolbar_item != NULL);
1781 switch (toolbar_item->type) {
1783 mainwin = (MainWindow *) toolbar_item->parent;
1784 app_will_exit(NULL, mainwin);
1786 case TOOLBAR_MSGVIEW:
1787 messageview = (MessageView *)toolbar_item->parent;
1788 messageview_destroy(messageview);
1790 case TOOLBAR_COMPOSE:
1791 compose = (Compose *)toolbar_item->parent;
1792 compose_close_toolbar(compose);
1797 static void toolbar_preferences_cb(GtkWidget *widget, gpointer data)
1802 static void toolbar_open_mail_cb(GtkWidget *widget, gpointer data)
1804 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1805 MainWindow *mainwin;
1807 cm_return_if_fail(toolbar_item != NULL);
1809 switch (toolbar_item->type) {
1811 mainwin = (MainWindow *) toolbar_item->parent;
1812 summary_open_row(NULL, mainwin->summaryview);
1814 case TOOLBAR_MSGVIEW:
1815 debug_print("toolbar event not supported\n");
1817 case TOOLBAR_COMPOSE:
1818 debug_print("toolbar event not supported\n");
1823 static void toolbar_insert_cb(GtkWidget *widget, gpointer data)
1825 compose_toolbar_cb(A_INSERT, data);
1828 static void toolbar_attach_cb(GtkWidget *widget, gpointer data)
1830 compose_toolbar_cb(A_ATTACH, data);
1833 static void toolbar_sig_cb(GtkWidget *widget, gpointer data)
1835 compose_toolbar_cb(A_SIG, data);
1838 static void toolbar_replace_sig_cb(GtkWidget *widget, gpointer data)
1840 compose_toolbar_cb(A_REP_SIG, data);
1843 static void toolbar_ext_editor_cb(GtkWidget *widget, gpointer data)
1845 compose_toolbar_cb(A_EXTEDITOR, data);
1848 static void toolbar_linewrap_current_cb(GtkWidget *widget, gpointer data)
1850 compose_toolbar_cb(A_LINEWRAP_CURRENT, data);
1853 static void toolbar_linewrap_all_cb(GtkWidget *widget, gpointer data)
1855 compose_toolbar_cb(A_LINEWRAP_ALL, data);
1859 static void toolbar_check_spelling_cb(GtkWidget *widget, gpointer data)
1861 compose_toolbar_cb(A_CHECK_SPELLING, data);
1865 * Execute actions from toolbar
1867 static void toolbar_actions_execute_cb(GtkWidget *widget, gpointer data)
1869 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1870 GSList *action_list;
1871 MainWindow *mainwin;
1873 MessageView *msgview;
1874 gpointer parent = toolbar_item->parent;
1876 cm_return_if_fail(toolbar_item != NULL);
1878 switch (toolbar_item->type) {
1880 mainwin = (MainWindow*)parent;
1881 action_list = mainwin->toolbar->action_list;
1883 case TOOLBAR_COMPOSE:
1884 compose = (Compose*)parent;
1885 action_list = compose->toolbar->action_list;
1887 case TOOLBAR_MSGVIEW:
1888 msgview = (MessageView*)parent;
1889 action_list = msgview->toolbar->action_list;
1892 debug_print("toolbar event not supported\n");
1895 toolbar_action_execute(widget, action_list, parent, toolbar_item->type);
1898 static void toolbar_plugins_execute_cb(GtkWidget *widget, gpointer data)
1900 ToolbarItem *toolbar_item = data;
1901 prefs_toolbar_execute_plugin_item(toolbar_item->parent, toolbar_item->type, toolbar_item->text);
1904 static MainWindow *get_mainwin(gpointer data)
1906 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1907 MainWindow *mainwin = NULL;
1908 MessageView *msgview;
1910 cm_return_val_if_fail(toolbar_item != NULL, NULL);
1912 switch(toolbar_item->type) {
1914 mainwin = (MainWindow*)toolbar_item->parent;
1916 case TOOLBAR_MSGVIEW:
1917 msgview = (MessageView*)toolbar_item->parent;
1918 mainwin = (MainWindow*)msgview->mainwin;
1927 static void toolbar_go_folders_cb(GtkWidget *widget, gpointer data)
1929 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1930 MainWindow *mainwin = NULL;
1931 switch(toolbar_item->type) {
1933 mainwin = (MainWindow*)toolbar_item->parent;
1936 g_warning("wrong toolbar type");
1940 if (!mainwin->in_folder) {
1941 FolderItem *item = folderview_get_selected_item(mainwin->folderview);
1943 folderview_select(mainwin->folderview, item);
1946 folderview_grab_focus(mainwin->folderview);
1947 mainwindow_exit_folder(mainwin);
1951 static void toolbar_buttons_cb(GtkWidget *widget,
1958 void (*func)(GtkWidget *widget, gpointer data);
1960 { A_RECEIVE_ALL, toolbar_inc_all_cb },
1961 { A_RECEIVE_CUR, toolbar_inc_cb },
1962 { A_SEND_QUEUED, toolbar_send_queued_cb },
1963 { A_COMPOSE_EMAIL, toolbar_compose_cb },
1964 { A_COMPOSE_NEWS, toolbar_compose_cb },
1965 { A_REPLY_MESSAGE, toolbar_reply_cb },
1966 { A_REPLY_SENDER, toolbar_reply_to_sender_cb },
1967 { A_REPLY_ALL, toolbar_reply_to_all_cb },
1968 { A_REPLY_ML, toolbar_reply_to_list_cb },
1969 { A_FORWARD, toolbar_forward_cb },
1970 { A_TRASH, toolbar_trash_cb },
1971 { A_DELETE_REAL, toolbar_delete_cb },
1972 { A_EXECUTE, toolbar_exec_cb },
1973 { A_GOTO_PREV, toolbar_prev_unread_cb },
1974 { A_GOTO_NEXT, toolbar_next_unread_cb },
1975 { A_IGNORE_THREAD, toolbar_ignore_thread_cb },
1976 { A_WATCH_THREAD, toolbar_watch_thread_cb },
1977 { A_MARK, toolbar_mark_cb },
1978 { A_UNMARK, toolbar_unmark_cb },
1979 { A_LOCK, toolbar_lock_cb },
1980 { A_UNLOCK, toolbar_unlock_cb },
1981 { A_ALL_READ, toolbar_all_read_cb },
1982 { A_ALL_UNREAD, toolbar_all_unread_cb },
1983 { A_READ, toolbar_read_cb },
1984 { A_UNREAD, toolbar_unread_cb },
1985 { A_PRINT, toolbar_print_cb },
1986 { A_LEARN_SPAM, toolbar_learn_cb },
1987 { A_DELETE_DUP, toolbar_delete_dup_cb },
1988 { A_GO_FOLDERS, toolbar_go_folders_cb },
1990 { A_SEND, toolbar_send_cb },
1991 { A_SEND_LATER, toolbar_send_later_cb },
1992 { A_DRAFT, toolbar_draft_cb },
1993 { A_OPEN_MAIL, toolbar_open_mail_cb },
1994 { A_CLOSE, toolbar_close_cb },
1995 { A_PREFERENCES, toolbar_preferences_cb },
1996 { A_INSERT, toolbar_insert_cb },
1997 { A_ATTACH, toolbar_attach_cb },
1998 { A_SIG, toolbar_sig_cb },
1999 { A_REP_SIG, toolbar_replace_sig_cb },
2000 { A_EXTEDITOR, toolbar_ext_editor_cb },
2001 { A_LINEWRAP_CURRENT, toolbar_linewrap_current_cb },
2002 { A_LINEWRAP_ALL, toolbar_linewrap_all_cb },
2003 { A_ADDRBOOK, toolbar_addrbook_cb },
2005 { A_CHECK_SPELLING, toolbar_check_spelling_cb },
2007 { A_CLAWS_ACTIONS, toolbar_actions_execute_cb },
2008 { A_CANCEL_INC, toolbar_cancel_inc_cb },
2009 { A_CANCEL_SEND, toolbar_cancel_send_cb },
2010 { A_CANCEL_ALL, toolbar_cancel_all_cb },
2011 { A_CLAWS_PLUGINS, toolbar_plugins_execute_cb },
2014 num_items = sizeof(callbacks)/sizeof(callbacks[0]);
2016 for (i = 0; i < num_items; i++) {
2017 if (callbacks[i].index == item->index) {
2018 callbacks[i].func(widget, item);
2023 #ifndef GENERIC_UMPC
2024 #define TOOLBAR_ITEM(item,icon,text,tooltip) { \
2025 item = GTK_WIDGET(gtk_tool_button_new(icon, text)); \
2026 gtkut_widget_set_can_focus(gtk_bin_get_child(GTK_BIN(item)), FALSE); \
2027 gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE); \
2028 gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE); \
2029 g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item); \
2030 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1); \
2031 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(item), \
2035 #define TOOLBAR_MENUITEM(item,icon,text,tooltip,menutip) { \
2036 GtkWidget *child = NULL, *btn = NULL, *arr = NULL; \
2037 GList *gchild = NULL; \
2038 item = GTK_WIDGET(gtk_menu_tool_button_new(icon, text)); \
2039 gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE); \
2040 gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE); \
2041 g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item); \
2042 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1); \
2043 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(item), \
2045 CLAWS_SET_ARROW_TIP(GTK_MENU_TOOL_BUTTON(item), menutip); \
2046 child = gtk_bin_get_child(GTK_BIN(item)); \
2047 gchild = gtk_container_get_children( \
2048 GTK_CONTAINER(child)); \
2049 btn = (GtkWidget *)gchild->data; \
2050 gtkut_widget_set_can_focus(btn, FALSE); \
2051 arr = (GtkWidget *)(gchild->next?gchild->next->data:NULL); \
2052 gtkut_widget_set_can_focus(arr, FALSE); \
2053 g_list_free(gchild); \
2054 gchild = gtk_container_get_children(GTK_CONTAINER(arr)); \
2055 gtk_widget_set_size_request(GTK_WIDGET(gchild->data), 9, -1); \
2056 g_list_free(gchild); \
2059 #define TOOLBAR_ITEM(item,icon,text,tooltip) { \
2060 item = GTK_WIDGET(gtk_tool_button_new(icon, text)); \
2061 gtkut_widget_set_can_focus(gtk_bin_get_child(GTK_BIN(item)), FALSE); \
2062 gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE); \
2063 gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE); \
2064 g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item); \
2065 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1); \
2068 #define TOOLBAR_MENUITEM(item,icon,text,tooltip,menutip) { \
2069 GtkWidget *child = NULL, *btn = NULL, *arr = NULL; \
2070 GList *gchild = NULL; \
2071 item = GTK_WIDGET(gtk_menu_tool_button_new(icon, text)); \
2072 gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE); \
2073 gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE); \
2074 g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item); \
2075 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1); \
2076 child = gtk_bin_get_child(GTK_BIN(item)); \
2077 gchild = gtk_container_get_children( \
2078 GTK_CONTAINER(child)); \
2079 btn = (GtkWidget *)gchild->data; \
2080 gtkut_widget_set_can_focus(btn, FALSE); \
2081 arr = (GtkWidget *)(gchild->next?gchild->next->data:NULL); \
2082 gtkut_widget_set_can_focus(arr, FALSE); \
2083 g_list_free(gchild); \
2084 gchild = gtk_container_get_children(GTK_CONTAINER(arr)); \
2085 gtk_widget_set_size_request(GTK_WIDGET(gchild->data), 9, -1); \
2086 g_list_free(gchild); \
2090 #define ADD_MENU_ITEM(name,cb,data) { \
2091 item = gtk_menu_item_new_with_mnemonic(name); \
2092 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); \
2093 g_signal_connect(G_OBJECT(item), "activate", \
2096 g_object_set_data(G_OBJECT(item), "int-value", GINT_TO_POINTER(data)); \
2097 gtk_widget_show(item); \
2100 static void toolbar_reply_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_reply(toolbar_item, GPOINTER_TO_INT(int_value));
2108 static void toolbar_learn_menu_cb(GtkWidget *widget, gpointer data)
2110 gpointer int_value = g_object_get_data(G_OBJECT(widget), "int-value");
2111 ToolbarItem *toolbar_item = (ToolbarItem *)data;
2113 toolbar_learn(toolbar_item, GPOINTER_TO_INT(int_value));
2117 * Create a new toolbar with specified type
2118 * if a callback list is passed it will be used before the
2119 * common callback list
2121 Toolbar *toolbar_create(ToolbarType type,
2122 GtkWidget *container,
2125 ToolbarItem *toolbar_item;
2128 GtkWidget *icon_wid = NULL;
2129 GtkWidget *icon_news;
2130 GtkWidget *icon_ham;
2132 ToolbarClawsActions *action_item;
2134 GSList *toolbar_list;
2135 Toolbar *toolbar_data;
2137 toolbar_read_config_file(type);
2138 toolbar_list = toolbar_get_list(type);
2140 toolbar_data = g_new0(Toolbar, 1);
2142 toolbar = gtk_toolbar_new();
2144 gtk_orientable_set_orientation(GTK_ORIENTABLE(toolbar), GTK_ORIENTATION_HORIZONTAL);
2146 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_BOTH);
2147 gtk_toolbar_set_show_arrow(GTK_TOOLBAR(toolbar), TRUE);
2149 for (cur = toolbar_list; cur != NULL; cur = cur->next) {
2151 if (g_ascii_strcasecmp(((ToolbarItem*)cur->data)->file, TOOLBAR_TAG_SEPARATOR) == 0) {
2152 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), gtk_separator_tool_item_new(), -1);
2156 toolbar_item = g_new0(ToolbarItem, 1);
2157 toolbar_item->index = ((ToolbarItem*)cur->data)->index;
2158 toolbar_item->file = g_strdup(((ToolbarItem*)cur->data)->file);
2159 toolbar_item->text = g_strdup(((ToolbarItem*)cur->data)->text);
2160 toolbar_item->parent = data;
2161 toolbar_item->type = type;
2163 /* collect toolbar items in list to keep track */
2164 toolbar_data->item_list =
2165 g_slist_append(toolbar_data->item_list,
2167 icon_wid = stock_pixmap_widget(stock_pixmap_get_icon(toolbar_item->file));
2169 switch (toolbar_item->index) {
2172 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Go to folder list"));
2173 toolbar_data->folders_btn = item;
2176 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2177 _("Receive Mail from all Accounts"),
2178 _("Receive Mail from selected Account"));
2179 toolbar_data->getall_btn = item;
2182 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Receive Mail from current Account"));
2183 toolbar_data->get_btn = item;
2186 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Send Queued Messages"));
2187 toolbar_data->send_btn = item;
2190 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Close window"));
2191 toolbar_data->close_window_btn = item;
2194 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Open preferences"));
2195 toolbar_data->preferences_btn = item;
2198 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Open email"));
2199 toolbar_data->open_mail_btn = item;
2201 case A_COMPOSE_EMAIL:
2202 #ifndef GENERIC_UMPC
2203 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2205 _("Compose with selected Account"));
2206 toolbar_data->compose_mail_btn = item;
2207 toolbar_data->compose_mail_icon = icon_wid;
2208 g_object_ref(toolbar_data->compose_mail_icon);
2210 icon_news = stock_pixmap_widget(STOCK_PIXMAP_NEWS_COMPOSE);
2211 toolbar_data->compose_news_icon = icon_news;
2212 g_object_ref(toolbar_data->compose_news_icon);
2214 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2215 _("Compose Email"));
2216 toolbar_data->compose_mail_btn = item;
2217 toolbar_data->compose_mail_icon = icon_wid;
2219 icon_news = stock_pixmap_widget(STOCK_PIXMAP_NEWS_COMPOSE);
2220 toolbar_data->compose_news_icon = icon_news;
2224 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2227 toolbar_data->learn_spam_btn = item;
2228 toolbar_data->learn_spam_icon = icon_wid;
2229 g_object_ref(toolbar_data->learn_spam_icon);
2231 icon_ham = stock_pixmap_widget(STOCK_PIXMAP_HAM_BTN);
2232 toolbar_data->learn_ham_icon = icon_ham;
2233 g_object_ref(toolbar_data->learn_ham_icon);
2235 menu = gtk_menu_new();
2236 ADD_MENU_ITEM(_("Learn as _Spam"), toolbar_learn_menu_cb, TRUE);
2237 ADD_MENU_ITEM(_("Learn as _Ham"), toolbar_learn_menu_cb, FALSE);
2238 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->learn_spam_btn), menu);
2241 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Delete duplicates"));
2242 toolbar_data->delete_dup_btn = item;
2244 case A_REPLY_MESSAGE:
2245 #ifndef GENERIC_UMPC
2246 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2247 _("Reply to Message"),
2248 _("Reply to Message options"));
2249 toolbar_data->reply_btn = item;
2251 menu = gtk_menu_new();
2252 ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_WITH_QUOTE);
2253 ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_WITHOUT_QUOTE);
2254 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->reply_btn), menu);
2256 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2257 _("Reply to Message"));
2258 toolbar_data->reply_btn = item;
2261 case A_REPLY_SENDER:
2262 #ifndef GENERIC_UMPC
2263 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2264 _("Reply to Sender"),
2265 _("Reply to Sender options"));
2266 toolbar_data->replysender_btn = item;
2268 menu = gtk_menu_new();
2269 ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE);
2270 ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE);
2271 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->replysender_btn), menu);
2273 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2274 _("Reply to Sender"));
2275 toolbar_data->replysender_btn = item;
2279 #ifndef GENERIC_UMPC
2280 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2282 _("Reply to All options"));
2283 toolbar_data->replyall_btn = item;
2285 menu = gtk_menu_new();
2286 ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE);
2287 ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE);
2288 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->replyall_btn), menu);
2290 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2292 toolbar_data->replyall_btn = item;
2296 #ifndef GENERIC_UMPC
2297 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2298 _("Reply to Mailing-list"),
2299 _("Reply to Mailing-list options"));
2300 toolbar_data->replylist_btn = item;
2302 menu = gtk_menu_new();
2303 ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_LIST_WITH_QUOTE);
2304 ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE);
2305 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->replylist_btn), menu);
2307 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2308 _("Reply to Mailing-list"));
2309 toolbar_data->replylist_btn = item;
2313 #ifndef GENERIC_UMPC
2314 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2315 _("Forward Message"),
2316 _("Forward Message options"));
2317 toolbar_data->fwd_btn = item;
2319 menu = gtk_menu_new();
2320 ADD_MENU_ITEM(_("_Forward"), toolbar_reply_menu_cb, COMPOSE_FORWARD_INLINE);
2321 ADD_MENU_ITEM(_("For_ward as attachment"), toolbar_reply_menu_cb, COMPOSE_FORWARD_AS_ATTACH);
2322 ADD_MENU_ITEM(_("Redirec_t"), toolbar_reply_menu_cb, COMPOSE_REDIRECT);
2323 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->fwd_btn), menu);
2325 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2326 _("Forward Message"));
2327 toolbar_data->fwd_btn = item;
2331 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Trash Message"));
2332 toolbar_data->trash_btn = item;
2335 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Delete Message"));
2336 toolbar_data->delete_btn = item;
2339 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Execute"));
2340 toolbar_data->exec_btn = item;
2343 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Go to Previous Unread Message"));
2344 toolbar_data->prev_btn = item;
2347 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Go to Next Unread Message"));
2348 toolbar_data->next_btn = item;
2351 /* Compose Toolbar */
2353 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Send Message"));
2354 toolbar_data->send_btn = item;
2357 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Put into queue folder and send later"));
2358 toolbar_data->sendl_btn = item;
2361 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Save to draft folder"));
2362 toolbar_data->draft_btn = item;
2365 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Insert file"));
2366 toolbar_data->insert_btn = item;
2369 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Attach file"));
2370 toolbar_data->attach_btn = item;
2373 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Insert signature"));
2374 toolbar_data->sig_btn = item;
2377 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Replace signature"));
2378 toolbar_data->repsig_btn = item;
2381 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Edit with external editor"));
2382 toolbar_data->exteditor_btn = item;
2384 case A_LINEWRAP_CURRENT:
2385 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Wrap long lines of current paragraph"));
2386 toolbar_data->linewrap_current_btn = item;
2388 case A_LINEWRAP_ALL:
2389 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Wrap all long lines"));
2390 toolbar_data->linewrap_all_btn = item;
2393 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Address book"));
2394 toolbar_data->addrbook_btn = item;
2397 case A_CHECK_SPELLING:
2398 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Check spelling"));
2399 toolbar_data->spellcheck_btn = item;
2403 case A_CLAWS_ACTIONS:
2404 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,toolbar_item->text);
2405 action_item = g_new0(ToolbarClawsActions, 1);
2406 action_item->widget = item;
2407 action_item->name = g_strdup(toolbar_item->text);
2409 toolbar_data->action_list =
2410 g_slist_append(toolbar_data->action_list,
2414 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Cancel receiving"));
2415 toolbar_data->cancel_inc_btn = item;
2418 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Cancel sending"));
2419 toolbar_data->cancel_send_btn = item;
2422 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Cancel receiving/sending"));
2423 toolbar_data->cancel_all_btn = item;
2425 case A_CLAWS_PLUGINS:
2426 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text, toolbar_item->text);
2429 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2430 toolbar_ret_descr_from_val(toolbar_item->index));
2431 /* find and set the tool tip text */
2436 toolbar_data->toolbar = toolbar;
2438 gtk_widget_show_all(toolbar);
2440 if (type == TOOLBAR_MAIN) {
2442 MainWindow *mainwin = mainwindow_get_mainwindow();
2443 GtkWidget *progressbar = gtk_progress_bar_new();
2444 item = GTK_WIDGET(gtk_tool_item_new());
2445 gtk_container_add (GTK_CONTAINER (item), progressbar);
2446 gtk_widget_show(item);
2447 gtk_widget_set_size_request(progressbar, 84, -1);
2448 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1);
2449 mainwin->progressbar = progressbar;
2451 activate_compose_button(toolbar_data,
2452 prefs_common.toolbar_style,
2453 toolbar_data->compose_btn_type);
2455 if (type != TOOLBAR_COMPOSE)
2456 activate_learn_button(toolbar_data, prefs_common.toolbar_style,
2459 gtk_container_add(GTK_CONTAINER(container), toolbar);
2460 gtk_container_set_border_width(GTK_CONTAINER(container), 0);
2462 return toolbar_data;
2466 * Free toolbar structures
2468 void toolbar_destroy(Toolbar * toolbar) {
2470 TOOLBAR_DESTROY_ITEMS(toolbar->item_list);
2471 TOOLBAR_DESTROY_ACTIONS(toolbar->action_list);
2474 void toolbar_update(ToolbarType type, gpointer data)
2476 Toolbar *toolbar_data;
2477 GtkWidget *handlebox;
2478 MainWindow *mainwin = (MainWindow*)data;
2479 Compose *compose = (Compose*)data;
2480 MessageView *msgview = (MessageView*)data;
2482 #ifndef GENERIC_UMPC
2485 toolbar_data = mainwin->toolbar;
2486 handlebox = mainwin->handlebox;
2488 case TOOLBAR_COMPOSE:
2489 toolbar_data = compose->toolbar;
2490 handlebox = compose->handlebox;
2492 case TOOLBAR_MSGVIEW:
2493 toolbar_data = msgview->toolbar;
2494 handlebox = msgview->handlebox;
2500 gtk_container_remove(GTK_CONTAINER(handlebox),
2501 GTK_WIDGET(toolbar_data->toolbar));
2503 toolbar_init(toolbar_data);
2504 toolbar_data = toolbar_create(type, handlebox, data);
2508 toolbar_data = mainwin->toolbar;
2509 handlebox = mainwin->window;
2511 case TOOLBAR_COMPOSE:
2512 toolbar_data = compose->toolbar;
2513 handlebox = compose->window;
2515 case TOOLBAR_MSGVIEW:
2516 toolbar_data = msgview->toolbar;
2517 handlebox = msgview->window;
2522 toolbar_init(toolbar_data);
2523 toolbar_data = toolbar_create(type, handlebox, data);
2528 mainwin->toolbar = toolbar_data;
2530 case TOOLBAR_COMPOSE:
2531 compose->toolbar = toolbar_data;
2533 case TOOLBAR_MSGVIEW:
2534 msgview->toolbar = toolbar_data;
2538 toolbar_style(type, prefs_common.toolbar_style, data);
2540 if (type == TOOLBAR_MAIN) {
2541 toolbar_main_set_sensitive((MainWindow*)data);
2542 account_set_menu_only_toolbar();
2546 #define GTK_BUTTON_SET_SENSITIVE(widget,sensitive) { \
2547 gtk_widget_set_sensitive(widget, sensitive); \
2550 void toolbar_main_set_sensitive(gpointer data)
2552 SensitiveCondMask state;
2554 MainWindow *mainwin = (MainWindow*)data;
2555 Toolbar *toolbar = mainwin->toolbar;
2557 GSList *entry_list = NULL;
2559 typedef struct _Entry Entry;
2562 SensitiveCondMask cond;
2566 #define SET_WIDGET_COND(w, ...) \
2568 Entry *e = g_new0(Entry, 1); \
2570 e->cond = main_window_get_mask(__VA_ARGS__, -1); \
2571 entry_list = g_slist_append(entry_list, e); \
2574 /* match all bit flags */
2576 if (toolbar->get_btn)
2577 SET_WIDGET_COND(toolbar->get_btn,
2578 M_HAVE_ACCOUNT, M_UNLOCKED, M_HAVE_RETRIEVABLE_ACCOUNT);
2580 if (toolbar->getall_btn) {
2581 SET_WIDGET_COND(toolbar->getall_btn,
2582 M_HAVE_ACCOUNT, M_UNLOCKED, M_HAVE_ANY_RETRIEVABLE_ACCOUNT);
2584 if (toolbar->send_btn) {
2585 SET_WIDGET_COND(toolbar->send_btn,
2586 M_HAVE_QUEUED_MAILS);
2588 if (toolbar->compose_mail_btn) {
2589 SET_WIDGET_COND(toolbar->compose_mail_btn,
2592 if (toolbar->close_window_btn) {
2593 SET_WIDGET_COND(toolbar->close_window_btn,
2596 if (toolbar->open_mail_btn) {
2597 SET_WIDGET_COND(toolbar->open_mail_btn,
2598 M_TARGET_EXIST, M_SUMMARY_ISLIST);
2600 if (toolbar->reply_btn) {
2601 SET_WIDGET_COND(toolbar->reply_btn,
2602 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2604 if (toolbar->replyall_btn) {
2605 SET_WIDGET_COND(toolbar->replyall_btn,
2606 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2608 if (toolbar->replylist_btn) {
2609 SET_WIDGET_COND(toolbar->replylist_btn,
2610 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2612 if (toolbar->replysender_btn) {
2613 SET_WIDGET_COND(toolbar->replysender_btn,
2614 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2616 if (toolbar->fwd_btn) {
2617 SET_WIDGET_COND(toolbar->fwd_btn,
2618 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2621 if (prefs_common.next_unread_msg_dialog == NEXTUNREADMSGDIALOG_ASSUME_NO) {
2622 SET_WIDGET_COND(toolbar->next_btn, M_MSG_EXIST, M_SUMMARY_ISLIST);
2624 SET_WIDGET_COND(toolbar->next_btn, -1);
2627 if (toolbar->trash_btn)
2628 SET_WIDGET_COND(toolbar->trash_btn,
2629 M_TARGET_EXIST, M_ALLOW_DELETE, M_NOT_NEWS);
2631 if (toolbar->delete_btn)
2632 SET_WIDGET_COND(toolbar->delete_btn,
2633 M_TARGET_EXIST, M_ALLOW_DELETE);
2635 if (toolbar->delete_dup_btn)
2636 SET_WIDGET_COND(toolbar->delete_dup_btn,
2637 M_ALLOW_DELETE, M_SUMMARY_ISLIST);
2639 if (toolbar->exec_btn)
2640 SET_WIDGET_COND(toolbar->exec_btn,
2643 if (toolbar->learn_spam_btn)
2644 SET_WIDGET_COND(toolbar->learn_spam_btn,
2645 M_TARGET_EXIST, M_CAN_LEARN_SPAM, M_SUMMARY_ISLIST);
2647 if (toolbar->cancel_inc_btn)
2648 SET_WIDGET_COND(toolbar->cancel_inc_btn,
2651 if (toolbar->cancel_send_btn)
2652 SET_WIDGET_COND(toolbar->cancel_send_btn,
2655 for (cur = toolbar->action_list; cur != NULL; cur = cur->next) {
2656 ToolbarClawsActions *act = (ToolbarClawsActions*)cur->data;
2658 SET_WIDGET_COND(act->widget, M_TARGET_EXIST, M_UNLOCKED);
2661 state = main_window_get_current_state(mainwin);
2663 for (cur = entry_list; cur != NULL; cur = cur->next) {
2664 Entry *e = (Entry*) cur->data;
2666 if (e->widget != NULL) {
2667 sensitive = ((e->cond & state) == e->cond);
2668 GTK_BUTTON_SET_SENSITIVE(e->widget, sensitive);
2672 while (entry_list != NULL) {
2673 Entry *e = (Entry*) entry_list->data;
2676 entry_list = g_slist_remove(entry_list, e);
2679 /* match any bit flags */
2681 if (toolbar->cancel_all_btn)
2682 SET_WIDGET_COND(toolbar->cancel_all_btn,
2683 M_INC_ACTIVE, M_SEND_ACTIVE);
2685 for (cur = entry_list; cur != NULL; cur = cur->next) {
2686 Entry *e = (Entry*) cur->data;
2688 if (e->widget != NULL) {
2689 sensitive = ((e->cond & state) != 0);
2690 GTK_BUTTON_SET_SENSITIVE(e->widget, sensitive);
2694 while (entry_list != NULL) {
2695 Entry *e = (Entry*) entry_list->data;
2698 entry_list = g_slist_remove(entry_list, e);
2701 g_slist_free(entry_list);
2703 activate_compose_button(toolbar,
2704 prefs_common.toolbar_style,
2705 toolbar->compose_btn_type);
2707 #undef SET_WIDGET_COND
2710 void toolbar_comp_set_sensitive(gpointer data, gboolean sensitive)
2712 Compose *compose = (Compose*)data;
2713 GSList *items = compose->toolbar->action_list;
2715 if (compose->toolbar->send_btn)
2716 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->send_btn, sensitive);
2717 if (compose->toolbar->sendl_btn)
2718 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->sendl_btn, sensitive);
2719 if (compose->toolbar->draft_btn )
2720 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->draft_btn , sensitive);
2721 if (compose->toolbar->insert_btn )
2722 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->insert_btn , sensitive);
2723 if (compose->toolbar->attach_btn)
2724 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->attach_btn, sensitive);
2725 if (compose->toolbar->sig_btn)
2726 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->sig_btn, sensitive);
2727 if (compose->toolbar->repsig_btn)
2728 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->repsig_btn, sensitive);
2729 if (compose->toolbar->exteditor_btn)
2730 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->exteditor_btn, sensitive);
2731 if (compose->toolbar->linewrap_current_btn)
2732 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->linewrap_current_btn, sensitive);
2733 if (compose->toolbar->linewrap_all_btn)
2734 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->linewrap_all_btn, sensitive);
2735 if (compose->toolbar->addrbook_btn)
2736 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->addrbook_btn, sensitive);
2738 if (compose->toolbar->spellcheck_btn)
2739 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->spellcheck_btn, sensitive);
2741 for (; items != NULL; items = g_slist_next(items)) {
2742 ToolbarClawsActions *item = (ToolbarClawsActions *)items->data;
2743 GTK_BUTTON_SET_SENSITIVE(item->widget, sensitive);
2748 * Initialize toolbar structure
2750 static void toolbar_init(Toolbar * toolbar)
2753 toolbar->toolbar = NULL;
2754 toolbar->folders_btn = NULL;
2755 toolbar->get_btn = NULL;
2756 toolbar->getall_btn = NULL;
2757 toolbar->send_btn = NULL;
2758 toolbar->compose_mail_btn = NULL;
2759 toolbar->compose_mail_icon = NULL;
2760 toolbar->compose_news_icon = NULL;
2761 toolbar->reply_btn = NULL;
2762 toolbar->replysender_btn = NULL;
2763 toolbar->replyall_btn = NULL;
2764 toolbar->replylist_btn = NULL;
2765 toolbar->fwd_btn = NULL;
2766 toolbar->trash_btn = NULL;
2767 toolbar->delete_btn = NULL;
2768 toolbar->delete_dup_btn = NULL;
2769 toolbar->prev_btn = NULL;
2770 toolbar->next_btn = NULL;
2771 toolbar->exec_btn = NULL;
2772 toolbar->separator = NULL;
2773 toolbar->learn_spam_btn = NULL;
2774 toolbar->learn_spam_icon = NULL;
2775 toolbar->learn_ham_icon = NULL;
2776 toolbar->cancel_inc_btn = NULL;
2777 toolbar->cancel_send_btn = NULL;
2778 toolbar->cancel_all_btn = NULL;
2780 /* compose buttons */
2781 toolbar->sendl_btn = NULL;
2782 toolbar->draft_btn = NULL;
2783 toolbar->insert_btn = NULL;
2784 toolbar->attach_btn = NULL;
2785 toolbar->sig_btn = NULL;
2786 toolbar->repsig_btn = NULL;
2787 toolbar->exteditor_btn = NULL;
2788 toolbar->linewrap_current_btn = NULL;
2789 toolbar->linewrap_all_btn = NULL;
2790 toolbar->addrbook_btn = NULL;
2792 toolbar->open_mail_btn = NULL;
2793 toolbar->close_window_btn = NULL;
2794 toolbar->preferences_btn = NULL;
2795 toolbar->action_list = NULL;
2796 toolbar->item_list = NULL;
2798 toolbar->spellcheck_btn = NULL;
2801 toolbar_destroy(toolbar);
2806 static void toolbar_reply(gpointer data, guint action)
2808 ToolbarItem *toolbar_item = (ToolbarItem*)data;
2809 MainWindow *mainwin;
2810 MessageView *msgview;
2811 GSList *msginfo_list = NULL;
2813 cm_return_if_fail(toolbar_item != NULL);
2815 switch (toolbar_item->type) {
2817 mainwin = (MainWindow*)toolbar_item->parent;
2818 msginfo_list = summary_get_selection(mainwin->summaryview);
2819 msgview = (MessageView*)mainwin->messageview;
2821 case TOOLBAR_MSGVIEW:
2822 msgview = (MessageView*)toolbar_item->parent;
2823 cm_return_if_fail(msgview != NULL);
2824 msginfo_list = g_slist_append(msginfo_list, msgview->msginfo);
2830 cm_return_if_fail(msgview != NULL);
2831 cm_return_if_fail(msginfo_list != NULL);
2832 compose_reply_from_messageview(msgview, msginfo_list, action);
2833 g_slist_free(msginfo_list);
2835 /* TODO: update reply state ion summaryview */
2839 /* exported functions */
2841 void inc_mail_cb(gpointer data, guint action, GtkWidget *widget)
2843 MainWindow *mainwin = (MainWindow*)data;
2845 inc_mail(mainwin, prefs_common.newmail_notify_manu);
2848 void inc_all_account_mail_cb(gpointer data, guint action, GtkWidget *widget)
2850 MainWindow *mainwin = (MainWindow*)data;
2852 inc_all_account_mail(mainwin, FALSE, prefs_common.newmail_notify_manu);
2855 void send_queue_cb(gpointer data, guint action, GtkWidget *widget)
2859 gboolean got_error = FALSE;
2860 gchar *errstr = NULL;
2862 if (prefs_common.work_offline)
2863 if (alertpanel(_("Offline warning"),
2864 _("You're working offline. Override?"),
2865 GTK_STOCK_NO, GTK_STOCK_YES,
2866 NULL) != G_ALERTALTERNATE)
2869 /* ask for confirmation before sending queued messages only
2870 in online mode and if there is at least one message queued
2871 in any of the folder queue
2873 if (prefs_common.confirm_send_queued_messages) {
2875 /* check if there's a queued message */
2876 for (list = folder_get_list(); !found && list != NULL; list = list->next) {
2877 Folder *folder = list->data;
2879 found = !procmsg_queue_is_empty(folder->queue);
2881 /* if necessary, ask for confirmation before sending */
2882 if (found && !prefs_common.work_offline) {
2883 if (alertpanel(_("Send queued messages"),
2884 _("Send all queued messages?"),
2885 GTK_STOCK_CANCEL, _("_Send"),
2886 NULL) != G_ALERTALTERNATE)
2891 for (list = folder_get_list(); list != NULL; list = list->next) {
2892 Folder *folder = list->data;
2894 if (folder->queue) {
2895 if (procmsg_send_queue(folder->queue,
2896 prefs_common.savemsg,
2903 alertpanel_error_log(_("Some errors occurred while "
2904 "sending queued messages."));
2906 alertpanel_error_log(_("Some errors occurred "
2907 "while sending queued messages:\n%s"), errstr);
2913 void compose_mail_cb(gpointer data, guint action, GtkWidget *widget)
2915 MainWindow *mainwin = (MainWindow*)data;
2916 PrefsAccount *ac = NULL;
2917 FolderItem *item = mainwin->summaryview->folder_item;
2922 ac = account_find_from_item(item);
2923 if (ac && ac->protocol != A_NNTP && ac->protocol != A_IMAP4) {
2924 compose_new_with_folderitem(ac, item, NULL); /* CLAWS */
2930 * CLAWS - use current account
2932 if (cur_account && (cur_account->protocol != A_NNTP)) {
2933 compose_new_with_folderitem(cur_account, item, NULL);
2938 * CLAWS - just get the first one
2940 list = account_get_list();
2941 for (cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2942 ac = (PrefsAccount *) cur->data;
2943 if (ac->protocol != A_NNTP) {
2944 compose_new_with_folderitem(ac, item, NULL);
2950 void compose_news_cb(gpointer data, guint action, GtkWidget *widget)
2952 MainWindow *mainwin = (MainWindow*)data;
2953 PrefsAccount * ac = NULL;
2957 if (mainwin->summaryview->folder_item) {
2958 ac = mainwin->summaryview->folder_item->folder->account;
2959 if (ac && ac->protocol == A_NNTP) {
2960 compose_new_with_folderitem(ac,
2961 mainwin->summaryview->folder_item, NULL);
2966 list = account_get_list();
2967 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2968 ac = (PrefsAccount *) cur->data;
2969 if (ac->protocol == A_NNTP) {
2970 compose_new_with_folderitem(ac,
2971 mainwin->summaryview->folder_item, NULL);