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_delete_dup (gpointer data,
113 static void toolbar_trash_cb (GtkWidget *widget,
116 static void toolbar_delete_cb (GtkWidget *widget,
119 static void toolbar_delete_dup_cb (GtkWidget *widget,
123 static void toolbar_compose_cb (GtkWidget *widget,
126 static void toolbar_learn_cb (GtkWidget *widget,
129 static void toolbar_reply_cb (GtkWidget *widget,
132 static void toolbar_reply_to_all_cb (GtkWidget *widget,
135 static void toolbar_reply_to_list_cb (GtkWidget *widget,
138 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
141 static void toolbar_forward_cb (GtkWidget *widget,
144 static void toolbar_prev_unread_cb (GtkWidget *widget,
146 static void toolbar_next_unread_cb (GtkWidget *widget,
149 static void toolbar_ignore_thread_cb (GtkWidget *widget,
152 static void toolbar_watch_thread_cb (GtkWidget *widget,
155 static void toolbar_mark_cb (GtkWidget *widget,
158 static void toolbar_unmark_cb (GtkWidget *widget,
161 static void toolbar_lock_cb (GtkWidget *widget,
164 static void toolbar_ulock_cb (GtkWidget *widget,
167 static void toolbar_all_read_cb (GtkWidget *widget,
170 static void toolbar_all_unread_cb (GtkWidget *widget,
173 static void toolbar_read_cb (GtkWidget *widget,
176 static void toolbar_unread_cb (GtkWidget *widget,
179 static void toolbar_print_cb (GtkWidget *widget,
182 static void toolbar_actions_execute_cb (GtkWidget *widget,
184 static void toolbar_plugins_execute_cb (GtkWidget *widget,
188 static void toolbar_send_cb (GtkWidget *widget,
190 static void toolbar_send_later_cb (GtkWidget *widget,
192 static void toolbar_draft_cb (GtkWidget *widget,
194 static void toolbar_close_cb (GtkWidget *widget,
196 static void toolbar_preferences_cb (GtkWidget *widget,
198 static void toolbar_open_mail_cb (GtkWidget *widget,
200 static void toolbar_insert_cb (GtkWidget *widget,
202 static void toolbar_attach_cb (GtkWidget *widget,
204 static void toolbar_sig_cb (GtkWidget *widget,
206 static void toolbar_ext_editor_cb (GtkWidget *widget,
208 static void toolbar_linewrap_current_cb (GtkWidget *widget,
210 static void toolbar_linewrap_all_cb (GtkWidget *widget,
212 static void toolbar_addrbook_cb (GtkWidget *widget,
215 static void toolbar_check_spelling_cb (GtkWidget *widget,
218 static void toolbar_cancel_inc_cb (GtkWidget *widget,
220 static void toolbar_cancel_send_cb (GtkWidget *widget,
222 static void toolbar_cancel_all_cb (GtkWidget *widget,
228 } toolbar_text [] = {
229 { "A_RECEIVE_ALL", N_("Receive Mail from all Accounts") },
230 { "A_RECEIVE_CUR", N_("Receive Mail from current Account") },
231 { "A_SEND_QUEUED", N_("Send Queued Messages") },
232 { "A_COMPOSE_EMAIL", N_("Compose Email") },
233 { "A_COMPOSE_NEWS", N_("Compose News") },
234 { "A_REPLY_MESSAGE", N_("Reply to Message") },
235 { "A_REPLY_SENDER", N_("Reply to Sender") },
236 { "A_REPLY_ALL", N_("Reply to All") },
237 { "A_REPLY_ML", N_("Reply to Mailing-list") },
238 { "A_OPEN_MAIL", N_("Open email") },
239 { "A_FORWARD", N_("Forward Message") },
240 { "A_TRASH", N_("Trash Message") },
241 { "A_DELETE_REAL", N_("Delete Message") },
242 { "A_DELETE_DUP", N_("Delete duplicate messages") },
243 { "A_EXECUTE", N_("Execute") },
244 { "A_GOTO_PREV", N_("Go to Previous Unread Message") },
245 { "A_GOTO_NEXT", N_("Go to Next Unread Message") },
247 { "A_IGNORE_THREAD", N_("Ignore thread") },
248 { "A_WATCH_THREAD", N_("Watch thread") },
249 { "A_MARK", N_("Mark Message") },
250 { "A_UNMARK", N_("Unmark Message") },
251 { "A_LOCK", N_("Lock Message") },
252 { "A_UNLOCK", N_("Unlock Message") },
253 { "A_ALL_READ", N_("Mark all Messages as read") },
254 { "A_ALL_UNREAD", N_("Mark all Messages as unread") },
255 { "A_READ", N_("Mark Message as read") },
256 { "A_UNREAD", N_("Mark Message as unread") },
258 { "A_PRINT", N_("Print") },
259 { "A_LEARN_SPAM", N_("Learn Spam or Ham") },
260 { "A_GO_FOLDERS", N_("Open folder/Go to folder list") },
261 { "A_PREFERENCES", N_("Preferences") },
263 { "A_SEND", N_("Send Message") },
264 { "A_SEND_LATER", N_("Put into queue folder and send later") },
265 { "A_DRAFT", N_("Save to draft folder") },
266 { "A_INSERT", N_("Insert file") },
267 { "A_ATTACH", N_("Attach file") },
268 { "A_SIG", N_("Insert signature") },
269 { "A_REP_SIG", N_("Replace signature") },
270 { "A_EXTEDITOR", N_("Edit with external editor") },
271 { "A_LINEWRAP_CURRENT", N_("Wrap long lines of current paragraph") },
272 { "A_LINEWRAP_ALL", N_("Wrap all long lines") },
273 { "A_ADDRBOOK", N_("Address book") },
275 { "A_CHECK_SPELLING", N_("Check spelling") },
277 { "A_CLAWS_ACTIONS", N_("Claws Mail Actions Feature") },
278 { "A_CANCEL_INC", N_("Cancel receiving") },
279 { "A_CANCEL_SEND", N_("Cancel sending") },
280 { "A_CANCEL_ALL", N_("Cancel receiving/sending") },
281 { "A_CLOSE", N_("Close window") },
282 { "A_SEPARATOR", N_("Separator") },
283 { "A_CLAWS_PLUGINS", N_("Claws Mail Plugins") }
286 /* migration table: support reading toolbar configuration files with
287 old action names and converting them to current action names,
288 see toolbar_parse_item(), which makes uses of this alias table.
291 const gchar *old_name;
292 const gchar *current_name;
293 } toolbar_migration [] = {
294 { "A_SYL_ACTIONS", "A_CLAWS_ACTIONS" },
295 { "A_SENDL", "A_SEND_LATER" },
299 /* struct holds configuration files and a list of
300 * currently active toolbar items
301 * TOOLBAR_MAIN, TOOLBAR_COMPOSE and TOOLBAR_MSGVIEW
305 const gchar *conf_file;
307 } toolbar_config[NUM_TOOLBARS] = {
308 { "toolbar_main.xml", NULL},
309 { "toolbar_compose.xml", NULL},
310 { "toolbar_msgview.xml", NULL}
313 gint toolbar_ret_val_from_descr(const gchar *descr)
317 for (i = 0; i < N_ACTION_VAL; i++) {
318 if (g_utf8_collate(gettext(toolbar_text[i].descr), descr) == 0)
325 gchar *toolbar_ret_descr_from_val(gint val)
327 cm_return_val_if_fail(val >=0 && val < N_ACTION_VAL, NULL);
329 return gettext(toolbar_text[val].descr);
332 static gint toolbar_ret_val_from_text(const gchar *text)
336 for (i = 0; i < N_ACTION_VAL; i++) {
337 if (g_utf8_collate(toolbar_text[i].index_str, text) == 0)
344 static gchar *toolbar_ret_text_from_val(gint val)
346 cm_return_val_if_fail(val >=0 && val < N_ACTION_VAL, NULL);
348 return toolbar_text[val].index_str;
351 static gboolean toolbar_is_duplicate(gint action, ToolbarType source)
355 if ((action == A_SEPARATOR) || (action == A_CLAWS_ACTIONS) || (action == A_CLAWS_PLUGINS))
358 for (cur = toolbar_config[source].item_list; cur != NULL; cur = cur->next) {
359 ToolbarItem *item = (ToolbarItem*) cur->data;
361 if (item->index == action)
367 /* depending on toolbar type this function
368 returns a list of available toolbar events being
369 displayed by prefs_toolbar
371 GList *toolbar_get_action_items(ToolbarType source)
376 if (source == TOOLBAR_MAIN) {
377 gint main_items[] = {
378 A_RECEIVE_ALL, A_RECEIVE_CUR, A_SEND_QUEUED,
379 A_COMPOSE_EMAIL, A_REPLY_MESSAGE, A_REPLY_SENDER,
380 A_REPLY_ALL, A_REPLY_ML, A_OPEN_MAIL, A_FORWARD,
381 A_TRASH, A_DELETE_REAL, A_DELETE_DUP, A_EXECUTE,
382 A_GOTO_PREV, A_GOTO_NEXT, A_IGNORE_THREAD, A_WATCH_THREAD,
383 A_MARK, A_UNMARK, A_LOCK, A_UNLOCK,
384 A_ALL_READ, A_ALL_UNREAD, A_READ, A_UNREAD,
385 A_PRINT, A_ADDRBOOK, A_LEARN_SPAM, A_GO_FOLDERS,
386 A_CANCEL_INC, A_CANCEL_SEND, A_CANCEL_ALL, A_PREFERENCES };
388 for (i = 0; i < sizeof main_items / sizeof main_items[0]; i++) {
389 items = g_list_append(items, gettext(toolbar_text[main_items[i]].descr));
392 else if (source == TOOLBAR_COMPOSE) {
393 gint comp_items[] = {
394 A_SEND, A_SEND_LATER, A_DRAFT,
395 A_INSERT, A_ATTACH, A_SIG,
396 A_REP_SIG, A_EXTEDITOR, A_LINEWRAP_CURRENT,
397 A_LINEWRAP_ALL, A_ADDRBOOK,
403 for (i = 0; i < sizeof comp_items / sizeof comp_items[0]; i++)
404 items = g_list_append(items, gettext(toolbar_text[comp_items[i]].descr));
406 else if (source == TOOLBAR_MSGVIEW) {
407 gint msgv_items[] = {
408 A_COMPOSE_EMAIL, A_REPLY_MESSAGE, A_REPLY_SENDER,
409 A_REPLY_ALL, A_REPLY_ML, A_FORWARD,
410 A_TRASH, A_DELETE_REAL, A_GOTO_PREV, A_GOTO_NEXT,
411 A_ADDRBOOK, A_LEARN_SPAM, A_CLOSE };
413 for (i = 0; i < sizeof msgv_items / sizeof msgv_items[0]; i++)
414 items = g_list_append(items, gettext(toolbar_text[msgv_items[i]].descr));
420 static void toolbar_parse_item(XMLFile *file, ToolbarType source, gboolean *rewrite)
424 ToolbarItem *item = NULL;
426 g_return_if_fail(rewrite != NULL);
428 attr = xml_get_current_tag_attr(file);
429 item = g_new0(ToolbarItem, 1);
431 name = ((XMLAttr *)attr->data)->name;
432 value = ((XMLAttr *)attr->data)->value;
434 if (g_utf8_collate(name, TOOLBAR_ICON_FILE) == 0)
435 item->file = g_strdup (value);
436 else if (g_utf8_collate(name, TOOLBAR_ICON_TEXT) == 0)
437 item->text = g_strdup (*value ? gettext(value):"");
438 else if (g_utf8_collate(name, TOOLBAR_ICON_ACTION) == 0)
439 item->index = toolbar_ret_val_from_text(value);
441 if ((item->index == -1) && !strcmp(value, "A_DELETE")) {
443 item->index = A_TRASH;
445 item->file = g_strdup("trash_btn");
447 item->text = g_strdup(C_("Toolbar", "Trash"));
450 if (item->index == -1) {
451 /* item not found in table: try migrating old action names to current ones */
454 /* replace action name */
455 for (i = 0; toolbar_migration[i].old_name != NULL; i++) {
456 if (g_utf8_collate(value, toolbar_migration[i].old_name) == 0) {
457 item->index = toolbar_ret_val_from_text(toolbar_migration[i].current_name);
458 if (item->index != -1) {
460 debug_print("toolbar_parse_item: migrating action label from '%s' to '%s'\n",
461 value, toolbar_migration[i].current_name);
467 if ((item->index == -1) && !rewrite)
468 g_warning("toolbar_parse_item: unrecognized action name '%s'\n", value);
470 attr = g_list_next(attr);
472 if (item->index != -1) {
473 if (!toolbar_is_duplicate(item->index, source))
474 toolbar_config[source].item_list = g_slist_append(toolbar_config[source].item_list,
479 const gchar *toolbar_get_short_text(int action) {
481 case A_RECEIVE_ALL: return _("Get Mail");
482 case A_RECEIVE_CUR: return _("Get");
483 case A_SEND_QUEUED: return _("Send");
484 case A_COMPOSE_EMAIL: return C_("Toolbar", "Compose");
485 case A_COMPOSE_NEWS: return C_("Toolbar", "Compose");
486 case A_REPLY_MESSAGE: return _("Reply");
487 case A_REPLY_SENDER: return C_("Toolbar", "Sender");
488 case A_REPLY_ALL: return _("All");
489 case A_REPLY_ML: return _("List");
490 case A_OPEN_MAIL: return _("Open");
491 case A_FORWARD: return _("Forward");
492 case A_TRASH: return C_("Toolbar", "Trash");
493 case A_DELETE_REAL: return _("Delete");
494 case A_DELETE_DUP: return _("Delete duplicates");
495 case A_EXECUTE: return _("Execute");
496 case A_GOTO_PREV: return _("Prev");
497 case A_GOTO_NEXT: return _("Next");
499 case A_IGNORE_THREAD: return _("Ignore thread");
500 case A_WATCH_THREAD: return _("Watch thread");
501 case A_MARK: return _("Mark");
502 case A_UNMARK: return _("Unmark");
503 case A_LOCK: return _("Lock");
504 case A_UNLOCK: return _("Unlock");
505 case A_ALL_READ: return _("All read");
506 case A_ALL_UNREAD: return _("All unread");
507 case A_READ: return _("Read");
508 case A_UNREAD: return _("Unread");
510 case A_PRINT: return _("Print");
511 case A_LEARN_SPAM: return _("Spam");
512 case A_GO_FOLDERS: return _("Folders");
513 case A_PREFERENCES: return _("Preferences");
515 case A_SEND: return _("Send");
516 case A_SEND_LATER: return _("Send later");
517 case A_DRAFT: return _("Draft");
518 case A_INSERT: return _("Insert");
519 case A_ATTACH: return _("Attach");
520 case A_SIG: return _("Insert sig.");
521 case A_REP_SIG: return _("Replace sig.");
522 case A_EXTEDITOR: return _("Edit");
523 case A_LINEWRAP_CURRENT:return _("Wrap para.");
524 case A_LINEWRAP_ALL: return _("Wrap all");
525 case A_ADDRBOOK: return _("Address");
527 case A_CHECK_SPELLING: return _("Check spelling");
530 case A_CANCEL_INC: return _("Stop");
531 case A_CANCEL_SEND: return _("Stop");
532 case A_CANCEL_ALL: return _("Stop all");
533 case A_CLOSE: return _("Close");
538 gint toolbar_get_icon(int action) {
540 case A_RECEIVE_ALL: return STOCK_PIXMAP_MAIL_RECEIVE_ALL;
541 case A_RECEIVE_CUR: return STOCK_PIXMAP_MAIL_RECEIVE;
542 case A_SEND_QUEUED: return STOCK_PIXMAP_MAIL_SEND_QUEUE;
543 case A_COMPOSE_EMAIL: return STOCK_PIXMAP_MAIL_COMPOSE;
544 case A_COMPOSE_NEWS: return STOCK_PIXMAP_NEWS_COMPOSE;
545 case A_REPLY_MESSAGE: return STOCK_PIXMAP_MAIL_REPLY;
546 case A_REPLY_SENDER: return STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR;
547 case A_REPLY_ALL: return STOCK_PIXMAP_MAIL_REPLY_TO_ALL;
548 case A_REPLY_ML: return STOCK_PIXMAP_MAIL_REPLY_TO_LIST;
549 case A_OPEN_MAIL: return STOCK_PIXMAP_OPEN_MAIL;
550 case A_FORWARD: return STOCK_PIXMAP_MAIL_FORWARD;
551 case A_TRASH: return STOCK_PIXMAP_TRASH;
552 case A_DELETE_REAL: return STOCK_PIXMAP_DELETE;
553 case A_DELETE_DUP: return STOCK_PIXMAP_DELETE_DUP;
554 case A_EXECUTE: return STOCK_PIXMAP_EXEC;
555 case A_GOTO_PREV: return STOCK_PIXMAP_UP_ARROW;
556 case A_GOTO_NEXT: return STOCK_PIXMAP_DOWN_ARROW;
558 case A_IGNORE_THREAD: return STOCK_PIXMAP_MARK_IGNORETHREAD;
559 case A_WATCH_THREAD: return STOCK_PIXMAP_MARK_WATCHTHREAD;
560 case A_MARK: return STOCK_PIXMAP_MARK_MARK;
561 case A_UNMARK: return STOCK_PIXMAP_MARK_UNMARK;
562 case A_LOCK: return STOCK_PIXMAP_MARK_LOCKED;
563 case A_UNLOCK: return STOCK_PIXMAP_MARK_UNLOCKED;
564 case A_ALL_READ: return STOCK_PIXMAP_MARK_ALLREAD;
565 case A_ALL_UNREAD: return STOCK_PIXMAP_MARK_ALLUNREAD;
566 case A_READ: return STOCK_PIXMAP_MARK_READ;
567 case A_UNREAD: return STOCK_PIXMAP_MARK_UNREAD;
569 case A_PRINT: return STOCK_PIXMAP_PRINTER;
570 case A_LEARN_SPAM: return STOCK_PIXMAP_SPAM_BTN;
571 case A_GO_FOLDERS: return STOCK_PIXMAP_GO_FOLDERS;
572 case A_PREFERENCES: return STOCK_PIXMAP_PREFERENCES;
574 case A_SEND: return STOCK_PIXMAP_MAIL_SEND;
575 case A_SEND_LATER: return STOCK_PIXMAP_MAIL_SEND_QUEUE;
576 case A_DRAFT: return STOCK_PIXMAP_MAIL;
577 case A_INSERT: return STOCK_PIXMAP_INSERT_FILE;
578 case A_ATTACH: return STOCK_PIXMAP_MAIL_ATTACH;
579 case A_SIG: return STOCK_PIXMAP_MAIL_SIGN;
580 case A_REP_SIG: return STOCK_PIXMAP_MAIL_SIGN;
581 case A_EXTEDITOR: return STOCK_PIXMAP_EDIT_EXTERN;
582 case A_LINEWRAP_CURRENT:return STOCK_PIXMAP_LINEWRAP_CURRENT;
583 case A_LINEWRAP_ALL: return STOCK_PIXMAP_LINEWRAP_ALL;
584 case A_ADDRBOOK: return STOCK_PIXMAP_ADDRESS_BOOK;
586 case A_CHECK_SPELLING: return STOCK_PIXMAP_CHECK_SPELLING;
589 case A_CANCEL_INC: return STOCK_PIXMAP_CANCEL;
590 case A_CANCEL_SEND: return STOCK_PIXMAP_CANCEL;
591 case A_CANCEL_ALL: return STOCK_PIXMAP_CANCEL;
592 case A_CLOSE: return STOCK_PIXMAP_CLOSE;
597 static void toolbar_set_default_generic(ToolbarType toolbar_type, DefaultToolbar *default_toolbar)
601 g_return_if_fail(default_toolbar != NULL);
603 for (i = 0; default_toolbar[i].action != N_ACTION_VAL; i++) {
605 ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
607 if (default_toolbar[i].action != A_SEPARATOR) {
611 icon = toolbar_get_icon(default_toolbar[i].action);
613 file = stock_pixmap_get_name((StockPixmap)icon);
615 toolbar_item->file = g_strdup(file);
616 toolbar_item->index = default_toolbar[i].action;
617 toolbar_item->text = g_strdup(toolbar_get_short_text(default_toolbar[i].action));
619 toolbar_item->file = g_strdup(TOOLBAR_TAG_SEPARATOR);
620 toolbar_item->index = A_SEPARATOR;
623 if (toolbar_item->index != -1) {
624 if (!toolbar_is_duplicate(toolbar_item->index, toolbar_type))
625 toolbar_config[toolbar_type].item_list =
626 g_slist_append(toolbar_config[toolbar_type].item_list, toolbar_item);
631 void toolbar_set_default(ToolbarType source)
633 DefaultToolbar default_toolbar_main[] = {
659 DefaultToolbar default_toolbar_compose[] = {
677 DefaultToolbar default_toolbar_msgview[] = {
695 if (source == TOOLBAR_MAIN)
696 toolbar_set_default_generic(TOOLBAR_MAIN, default_toolbar_main);
697 else if (source == TOOLBAR_COMPOSE)
698 toolbar_set_default_generic(TOOLBAR_COMPOSE, default_toolbar_compose);
699 else if (source == TOOLBAR_MSGVIEW)
700 toolbar_set_default_generic(TOOLBAR_MSGVIEW, default_toolbar_msgview);
703 void toolbar_save_config_file(ToolbarType source)
708 gchar *fileSpec = NULL;
710 debug_print("save Toolbar Configuration to %s\n", toolbar_config[source].conf_file);
712 fileSpec = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, toolbar_config[source].conf_file, NULL );
713 pfile = prefs_write_open(fileSpec);
716 if (fprintf(fp, "<?xml version=\"1.0\" encoding=\"%s\" ?>\n", CS_INTERNAL) < 0)
719 if (fprintf(fp, "<%s>\n", TOOLBAR_TAG_INDEX) < 0)
722 for (cur = toolbar_config[source].item_list; cur != NULL; cur = cur->next) {
723 ToolbarItem *toolbar_item = (ToolbarItem*) cur->data;
725 if (toolbar_item->index != A_SEPARATOR) {
726 if (fprintf(fp, "\t<%s %s=\"%s\" %s=\"",
728 TOOLBAR_ICON_FILE, toolbar_item->file,
729 TOOLBAR_ICON_TEXT) < 0)
731 if (xml_file_put_escape_str(fp, toolbar_item->text) < 0)
733 if (fprintf(fp, "\" %s=\"%s\"/>\n",
735 toolbar_ret_text_from_val(toolbar_item->index)) < 0)
738 if (fprintf(fp, "\t<%s/>\n", TOOLBAR_TAG_SEPARATOR) < 0)
743 if (fprintf(fp, "</%s>\n", TOOLBAR_TAG_INDEX) < 0)
747 if (prefs_file_close (pfile) < 0 )
748 g_warning("failed to write toolbar configuration to file");
752 FILE_OP_ERROR(fileSpec, "fprintf");
754 prefs_file_close_revert (pfile);
756 g_warning("failed to open toolbar configuration file for writing");
759 void toolbar_read_config_file(ToolbarType source)
761 XMLFile *file = NULL;
762 gchar *fileSpec = NULL;
764 gboolean rewrite = FALSE;
766 debug_print("read Toolbar Configuration from %s\n", toolbar_config[source].conf_file);
768 fileSpec = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, toolbar_config[source].conf_file, NULL );
769 file = xml_open_file(fileSpec);
772 toolbar_clear_list(source);
776 || (xml_get_dtd(file))
777 || (xml_parse_next_tag(file))
778 || (!xml_compare_tag(file, TOOLBAR_TAG_INDEX))) {
779 xml_close_file(file);
787 if (xml_parse_next_tag(file))
790 /* Get next tag (icon, icon_text or icon_action) */
791 if (xml_compare_tag(file, TOOLBAR_TAG_ITEM)) {
792 toolbar_parse_item(file, source, &rewrite);
793 } else if (xml_compare_tag(file, TOOLBAR_TAG_SEPARATOR)) {
794 ToolbarItem *item = g_new0(ToolbarItem, 1);
796 item->file = g_strdup(TOOLBAR_TAG_SEPARATOR);
797 item->index = A_SEPARATOR;
798 toolbar_config[source].item_list =
799 g_slist_append(toolbar_config[source].item_list, item);
803 xml_close_file(file);
805 debug_print("toolbar_read_config_file: rewriting toolbar\n");
806 toolbar_save_config_file(source);
810 if ((!file) || (g_slist_length(toolbar_config[source].item_list) == 0)) {
812 if (source == TOOLBAR_MAIN)
813 toolbar_set_default(TOOLBAR_MAIN);
814 else if (source == TOOLBAR_COMPOSE)
815 toolbar_set_default(TOOLBAR_COMPOSE);
816 else if (source == TOOLBAR_MSGVIEW)
817 toolbar_set_default(TOOLBAR_MSGVIEW);
819 g_warning("refusing to write unknown Toolbar Configuration number %d", source);
823 toolbar_save_config_file(source);
828 * clears list of toolbar items read from configuration files
830 void toolbar_clear_list(ToolbarType source)
832 while (toolbar_config[source].item_list != NULL) {
833 ToolbarItem *item = (ToolbarItem*) toolbar_config[source].item_list->data;
835 toolbar_config[source].item_list =
836 g_slist_remove(toolbar_config[source].item_list, item);
842 g_slist_free(toolbar_config[source].item_list);
847 * return list of Toolbar items
849 GSList *toolbar_get_list(ToolbarType source)
853 if ((source == TOOLBAR_MAIN) || (source == TOOLBAR_COMPOSE) || (source == TOOLBAR_MSGVIEW))
854 list = toolbar_config[source].item_list;
859 void toolbar_set_list_item(ToolbarItem *t_item, ToolbarType source)
861 ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
863 toolbar_item->file = g_strdup(t_item->file);
864 toolbar_item->text = g_strdup(t_item->text);
865 toolbar_item->index = t_item->index;
867 toolbar_config[source].item_list =
868 g_slist_append(toolbar_config[source].item_list,
872 static void toolbar_action_execute(GtkWidget *widget,
880 for (cur = action_list; cur != NULL; cur = cur->next) {
881 ToolbarClawsActions *act = (ToolbarClawsActions*)cur->data;
883 if (widget == act->widget) {
884 i = prefs_actions_find_by_name(act->name);
892 actions_execute(data, i, widget, source);
894 g_warning ("Error: did not find Claws Action to execute");
897 gboolean toolbar_check_action_btns(ToolbarType type)
899 GSList *temp, *curr, *list = toolbar_config[type].item_list;
900 gboolean modified = FALSE;
903 while (curr != NULL) {
904 ToolbarItem *toolbar_item = (ToolbarItem *) curr->data;
908 if (toolbar_item->index != A_CLAWS_ACTIONS)
911 if (prefs_actions_find_by_name(toolbar_item->text) == -1) {
912 list = g_slist_delete_link(list, temp);
913 g_free(toolbar_item->file);
914 g_free(toolbar_item->text);
915 g_free(toolbar_item);
923 #define CLAWS_SET_TOOL_ITEM_TIP(widget,tip) { \
924 gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), tip); \
927 #define CLAWS_SET_ARROW_TIP(widget,tip) { \
928 gtk_menu_tool_button_set_arrow_tooltip_text(GTK_MENU_TOOL_BUTTON(widget), tip); \
931 static void activate_compose_button (Toolbar *toolbar,
933 ComposeButtonType type)
935 if ((!toolbar->compose_mail_btn))
938 if (type == COMPOSEBUTTON_NEWS) {
939 gtk_tool_button_set_icon_widget(
940 GTK_TOOL_BUTTON(toolbar->compose_mail_btn),
941 toolbar->compose_news_icon);
943 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(toolbar->compose_mail_btn), _("Compose News message"));
945 gtk_widget_show(toolbar->compose_news_icon);
947 gtk_tool_button_set_icon_widget(
948 GTK_TOOL_BUTTON(toolbar->compose_mail_btn),
949 toolbar->compose_mail_icon);
951 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(toolbar->compose_mail_btn), _("Compose Email"));
953 gtk_widget_show(toolbar->compose_mail_icon);
955 toolbar->compose_btn_type = type;
958 void toolbar_set_compose_button(Toolbar *toolbar,
959 ComposeButtonType compose_btn_type)
961 if (toolbar->compose_btn_type != compose_btn_type)
962 activate_compose_button(toolbar,
963 prefs_common.toolbar_style,
967 static void activate_learn_button (Toolbar *toolbar,
969 LearnButtonType type)
971 if ((!toolbar->learn_spam_btn))
974 if (type == LEARN_SPAM) {
975 gtk_tool_button_set_icon_widget(
976 GTK_TOOL_BUTTON(toolbar->learn_spam_btn),
977 toolbar->learn_spam_icon);
978 gtk_tool_button_set_label(
979 GTK_TOOL_BUTTON(toolbar->learn_spam_btn),
982 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(toolbar->learn_spam_btn), _("Learn spam"));
984 gtk_widget_show(toolbar->learn_spam_icon);
986 gtk_tool_button_set_icon_widget(
987 GTK_TOOL_BUTTON(toolbar->learn_spam_btn),
988 toolbar->learn_ham_icon);
989 gtk_tool_button_set_label(
990 GTK_TOOL_BUTTON(toolbar->learn_spam_btn),
993 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(toolbar->learn_spam_btn), _("Learn ham"));
995 gtk_widget_show(toolbar->learn_ham_icon);
997 toolbar->learn_btn_type = type;
1000 void toolbar_set_learn_button(Toolbar *toolbar,
1001 LearnButtonType learn_btn_type)
1003 if (toolbar->learn_btn_type != learn_btn_type)
1004 activate_learn_button(toolbar,
1005 prefs_common.toolbar_style,
1009 void toolbar_toggle(guint action, gpointer data)
1011 MainWindow *mainwin = (MainWindow*)data;
1015 cm_return_if_fail(mainwin != NULL);
1017 toolbar_style(TOOLBAR_MAIN, action, mainwin);
1019 list = compose_get_compose_list();
1020 for (cur = list; cur != NULL; cur = cur->next) {
1021 toolbar_style(TOOLBAR_COMPOSE, action, cur->data);
1023 list = messageview_get_msgview_list();
1024 for (cur = list; cur != NULL; cur = cur->next) {
1025 toolbar_style(TOOLBAR_MSGVIEW, action, cur->data);
1030 void toolbar_set_style(GtkWidget *toolbar_wid, GtkWidget *handlebox_wid, guint action)
1032 switch ((ToolbarStyle)action) {
1034 gtk_widget_hide(handlebox_wid);
1037 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
1041 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
1045 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
1048 case TOOLBAR_BOTH_HORIZ:
1049 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
1050 GTK_TOOLBAR_BOTH_HORIZ);
1056 prefs_common.toolbar_style = (ToolbarStyle)action;
1057 gtk_widget_set_size_request(handlebox_wid, 1, -1);
1059 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
1060 gtk_widget_show(handlebox_wid);
1061 gtk_widget_queue_resize(handlebox_wid);
1065 * Change the style of toolbar
1067 static void toolbar_style(ToolbarType type, guint action, gpointer data)
1069 GtkWidget *handlebox_wid;
1070 GtkWidget *toolbar_wid;
1071 MainWindow *mainwin = (MainWindow*)data;
1072 Compose *compose = (Compose*)data;
1073 MessageView *msgview = (MessageView*)data;
1075 cm_return_if_fail(data != NULL);
1079 handlebox_wid = mainwin->handlebox;
1080 toolbar_wid = mainwin->toolbar->toolbar;
1082 case TOOLBAR_COMPOSE:
1083 handlebox_wid = compose->handlebox;
1084 toolbar_wid = compose->toolbar->toolbar;
1086 case TOOLBAR_MSGVIEW:
1087 handlebox_wid = msgview->handlebox;
1088 toolbar_wid = msgview->toolbar->toolbar;
1094 toolbar_set_style(toolbar_wid, handlebox_wid, action);
1097 /* Toolbar handling */
1098 static void toolbar_inc_cb(GtkWidget *widget,
1101 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1102 MainWindow *mainwin;
1104 cm_return_if_fail(toolbar_item != NULL);
1106 switch (toolbar_item->type) {
1108 mainwin = (MainWindow*)toolbar_item->parent;
1109 inc_mail_cb(mainwin, 0, NULL);
1116 static void toolbar_inc_all_cb(GtkWidget *widget,
1119 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1120 MainWindow *mainwin;
1122 cm_return_if_fail(toolbar_item != NULL);
1124 switch (toolbar_item->type) {
1126 mainwin = (MainWindow*)toolbar_item->parent;
1127 inc_all_account_mail_cb(mainwin, 0, NULL);
1134 static void toolbar_send_queued_cb(GtkWidget *widget,gpointer data)
1136 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1137 MainWindow *mainwin;
1139 cm_return_if_fail(toolbar_item != NULL);
1141 switch (toolbar_item->type) {
1143 mainwin = (MainWindow*)toolbar_item->parent;
1144 send_queue_cb(mainwin, 0, NULL);
1151 static void toolbar_exec_cb(GtkWidget *widget,
1154 MainWindow *mainwin = get_mainwin(data);
1156 cm_return_if_fail(mainwin != NULL);
1157 summary_execute(mainwin->summaryview);
1161 * Delete current/selected(s) message(s)
1163 static void toolbar_trash_cb(GtkWidget *widget, gpointer data)
1165 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1166 MainWindow *mainwin;
1168 cm_return_if_fail(toolbar_item != NULL);
1169 cm_return_if_fail(toolbar_item->parent);
1171 switch (toolbar_item->type) {
1172 case TOOLBAR_MSGVIEW:
1173 messageview_delete((MessageView *)toolbar_item->parent);
1176 mainwin = (MainWindow *)toolbar_item->parent;
1177 summary_delete_trash(mainwin->summaryview);
1180 debug_print("toolbar event not supported\n");
1186 * Delete current/selected(s) message(s)
1188 static void toolbar_delete_cb(GtkWidget *widget, gpointer data)
1190 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1191 MainWindow *mainwin;
1193 cm_return_if_fail(toolbar_item != NULL);
1194 cm_return_if_fail(toolbar_item->parent);
1196 switch (toolbar_item->type) {
1197 case TOOLBAR_MSGVIEW:
1198 messageview_delete((MessageView *)toolbar_item->parent);
1201 mainwin = (MainWindow *)toolbar_item->parent;
1202 summary_delete(mainwin->summaryview);
1205 debug_print("toolbar event not supported\n");
1210 static void toolbar_delete_dup(gpointer data, guint all)
1212 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1213 MainWindow *mainwin = NULL;
1215 cm_return_if_fail(toolbar_item != NULL);
1217 switch (toolbar_item->type) {
1219 mainwin = (MainWindow*)toolbar_item->parent;
1221 mainwindow_delete_duplicated_all(mainwin);
1223 mainwindow_delete_duplicated(mainwin);
1225 case TOOLBAR_COMPOSE:
1226 case TOOLBAR_MSGVIEW:
1229 debug_print("toolbar event not supported\n");
1234 static void toolbar_delete_dup_cb(GtkWidget *widget, gpointer data)
1236 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1237 MainWindow *mainwin = NULL;
1239 cm_return_if_fail(toolbar_item != NULL);
1241 switch (toolbar_item->type) {
1243 mainwin = (MainWindow*)toolbar_item->parent;
1244 mainwindow_delete_duplicated(mainwin);
1246 case TOOLBAR_COMPOSE:
1247 case TOOLBAR_MSGVIEW:
1255 * Compose new message
1257 static void toolbar_compose_cb(GtkWidget *widget, gpointer data)
1259 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1260 MainWindow *mainwin;
1261 MessageView *msgview;
1263 cm_return_if_fail(toolbar_item != NULL);
1265 switch (toolbar_item->type) {
1267 mainwin = (MainWindow*)toolbar_item->parent;
1268 if (mainwin->toolbar->compose_btn_type == COMPOSEBUTTON_NEWS)
1269 compose_news_cb(mainwin, 0, NULL);
1271 compose_mail_cb(mainwin, 0, NULL);
1273 case TOOLBAR_MSGVIEW:
1274 msgview = (MessageView*)toolbar_item->parent;
1275 compose_new_with_folderitem(NULL,
1276 msgview->msginfo->folder, NULL);
1279 debug_print("toolbar event not supported\n");
1283 static void toolbar_learn(gpointer data, guint as_spam)
1285 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1286 MainWindow *mainwin;
1287 MessageView *msgview;
1289 cm_return_if_fail(toolbar_item != NULL);
1291 switch (toolbar_item->type) {
1293 mainwin = (MainWindow*)toolbar_item->parent;
1295 mainwindow_learn(mainwin, TRUE);
1297 mainwindow_learn(mainwin, FALSE);
1299 case TOOLBAR_MSGVIEW:
1300 msgview = (MessageView*)toolbar_item->parent;
1302 messageview_learn(msgview, TRUE);
1304 messageview_learn(msgview, FALSE);
1307 debug_print("toolbar event not supported\n");
1311 static void toolbar_learn_cb(GtkWidget *widget, gpointer data)
1313 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1314 MainWindow *mainwin;
1315 MessageView *msgview;
1317 cm_return_if_fail(toolbar_item != NULL);
1319 switch (toolbar_item->type) {
1321 mainwin = (MainWindow*)toolbar_item->parent;
1322 if (mainwin->toolbar->learn_btn_type == LEARN_SPAM)
1323 mainwindow_learn(mainwin, TRUE);
1325 mainwindow_learn(mainwin, FALSE);
1327 case TOOLBAR_MSGVIEW:
1328 msgview = (MessageView*)toolbar_item->parent;
1329 if (msgview->toolbar->learn_btn_type == LEARN_SPAM)
1330 messageview_learn(msgview, TRUE);
1332 messageview_learn(msgview, FALSE);
1335 debug_print("toolbar event not supported\n");
1343 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
1345 toolbar_reply(data, (prefs_common.reply_with_quote ?
1346 COMPOSE_REPLY_WITH_QUOTE : COMPOSE_REPLY_WITHOUT_QUOTE));
1351 * Reply message to Sender and All recipients
1353 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
1356 (prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
1357 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE));
1362 * Reply to Mailing List
1364 static void toolbar_reply_to_list_cb(GtkWidget *widget, gpointer data)
1367 (prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_LIST_WITH_QUOTE
1368 : COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE));
1373 * Reply to sender of message
1375 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
1378 (prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
1379 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE));
1385 static void toolbar_addrbook_cb(GtkWidget *widget, gpointer data)
1387 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1390 cm_return_if_fail(toolbar_item != NULL);
1392 switch (toolbar_item->type) {
1394 case TOOLBAR_MSGVIEW:
1397 case TOOLBAR_COMPOSE:
1398 compose = (Compose *)toolbar_item->parent;
1403 #ifndef USE_ALT_ADDRBOOK
1404 addressbook_open(compose);
1406 GError* error = NULL;
1407 addressbook_connect_signals(compose);
1408 addressbook_dbus_open(TRUE, &error);
1410 g_warning("%s", error->message);
1411 g_error_free(error);
1418 * Forward current/selected(s) message(s)
1420 static void toolbar_forward_cb(GtkWidget *widget, gpointer data)
1422 toolbar_reply(data, (COMPOSE_FORWARD));
1426 * Goto Prev Unread Message
1428 static void toolbar_prev_unread_cb(GtkWidget *widget, gpointer data)
1430 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1431 MainWindow *mainwin;
1432 MessageView *msgview;
1434 cm_return_if_fail(toolbar_item != NULL);
1436 switch (toolbar_item->type) {
1438 mainwin = (MainWindow*)toolbar_item->parent;
1439 summary_select_prev_unread(mainwin->summaryview);
1442 case TOOLBAR_MSGVIEW:
1443 msgview = (MessageView*)toolbar_item->parent;
1444 msgview->updating = TRUE;
1445 summary_select_prev_unread(msgview->mainwin->summaryview);
1446 msgview->updating = FALSE;
1448 if (msgview->deferred_destroy) {
1449 debug_print("messageview got away!\n");
1450 messageview_destroy(msgview);
1454 /* Now we need to update the messageview window */
1455 if (msgview->mainwin->summaryview->selected) {
1456 #ifndef GENERIC_UMPC
1457 MsgInfo * msginfo = summary_get_selected_msg(msgview->mainwin->summaryview);
1460 messageview_show(msgview, msginfo,
1461 msgview->all_headers);
1464 gtk_widget_destroy(msgview->window);
1468 debug_print("toolbar event not supported\n");
1473 * Goto Next Unread Message
1475 static void toolbar_next_unread_cb(GtkWidget *widget, gpointer data)
1477 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1478 MainWindow *mainwin;
1479 MessageView *msgview;
1481 cm_return_if_fail(toolbar_item != NULL);
1483 switch (toolbar_item->type) {
1485 mainwin = (MainWindow*)toolbar_item->parent;
1486 summary_select_next_unread(mainwin->summaryview);
1489 case TOOLBAR_MSGVIEW:
1490 msgview = (MessageView*)toolbar_item->parent;
1491 msgview->updating = TRUE;
1492 summary_select_next_unread(msgview->mainwin->summaryview);
1493 msgview->updating = FALSE;
1495 if (msgview->deferred_destroy) {
1496 debug_print("messageview got away!\n");
1497 messageview_destroy(msgview);
1501 /* Now we need to update the messageview window */
1502 if (msgview->mainwin->summaryview->selected) {
1503 #ifndef GENERIC_UMPC
1504 MsgInfo * msginfo = summary_get_selected_msg(msgview->mainwin->summaryview);
1507 messageview_show(msgview, msginfo,
1508 msgview->all_headers);
1511 gtk_widget_destroy(msgview->window);
1515 debug_print("toolbar event not supported\n");
1519 static void toolbar_ignore_thread_cb(GtkWidget *widget, gpointer data)
1521 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1522 MainWindow *mainwin;
1524 cm_return_if_fail(toolbar_item != NULL);
1526 switch (toolbar_item->type) {
1528 mainwin = (MainWindow *) toolbar_item->parent;
1529 summary_toggle_ignore_thread(mainwin->summaryview);
1531 case TOOLBAR_MSGVIEW:
1532 /* TODO: see toolbar_next_unread_cb() if you need
1533 * this in the message view */
1536 debug_print("toolbar event not supported\n");
1541 static void toolbar_watch_thread_cb(GtkWidget *widget, gpointer data)
1543 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1544 MainWindow *mainwin;
1546 cm_return_if_fail(toolbar_item != NULL);
1548 switch (toolbar_item->type) {
1550 mainwin = (MainWindow *) toolbar_item->parent;
1551 summary_toggle_watch_thread(mainwin->summaryview);
1553 case TOOLBAR_MSGVIEW:
1554 /* TODO: see toolbar_next_unread_cb() if you need
1555 * this in the message view */
1558 debug_print("toolbar event not supported\n");
1563 static void toolbar_mark_cb(GtkWidget *widget, gpointer data)
1565 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1566 MainWindow *mainwin;
1568 cm_return_if_fail(toolbar_item != NULL);
1570 switch (toolbar_item->type) {
1572 mainwin = (MainWindow *) toolbar_item->parent;
1573 summary_mark(mainwin->summaryview);
1575 case TOOLBAR_MSGVIEW:
1576 /* TODO: see toolbar_next_unread_cb() if you need
1577 * this in the message view */
1580 debug_print("toolbar event not supported\n");
1585 static void toolbar_unmark_cb(GtkWidget *widget, gpointer data)
1587 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1588 MainWindow *mainwin;
1590 cm_return_if_fail(toolbar_item != NULL);
1592 switch (toolbar_item->type) {
1594 mainwin = (MainWindow *) toolbar_item->parent;
1595 summary_unmark(mainwin->summaryview);
1597 case TOOLBAR_MSGVIEW:
1598 /* TODO: see toolbar_next_unread_cb() if you need
1599 * this in the message view */
1602 debug_print("toolbar event not supported\n");
1607 static void toolbar_lock_cb(GtkWidget *widget, gpointer data)
1609 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1610 MainWindow *mainwin;
1612 cm_return_if_fail(toolbar_item != NULL);
1614 switch (toolbar_item->type) {
1616 mainwin = (MainWindow *) toolbar_item->parent;
1617 summary_msgs_lock(mainwin->summaryview);
1619 case TOOLBAR_MSGVIEW:
1620 /* TODO: see toolbar_next_unread_cb() if you need
1621 * this in the message view */
1624 debug_print("toolbar event not supported\n");
1629 static void toolbar_unlock_cb(GtkWidget *widget, gpointer data)
1631 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1632 MainWindow *mainwin;
1634 cm_return_if_fail(toolbar_item != NULL);
1636 switch (toolbar_item->type) {
1638 mainwin = (MainWindow *) toolbar_item->parent;
1639 summary_msgs_unlock(mainwin->summaryview);
1641 case TOOLBAR_MSGVIEW:
1642 /* TODO: see toolbar_next_unread_cb() if you need
1643 * this in the message view */
1646 debug_print("toolbar event not supported\n");
1651 static void toolbar_all_read_cb(GtkWidget *widget, gpointer data)
1653 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1654 MainWindow *mainwin;
1656 cm_return_if_fail(toolbar_item != NULL);
1658 switch (toolbar_item->type) {
1660 mainwin = (MainWindow *) toolbar_item->parent;
1661 summary_mark_all_read(mainwin->summaryview, TRUE);
1663 case TOOLBAR_MSGVIEW:
1664 /* TODO: see toolbar_next_unread_cb() if you need
1665 * this in the message view */
1668 debug_print("toolbar event not supported\n");
1673 static void toolbar_all_unread_cb(GtkWidget *widget, gpointer data)
1675 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1676 MainWindow *mainwin;
1678 cm_return_if_fail(toolbar_item != NULL);
1680 switch (toolbar_item->type) {
1682 mainwin = (MainWindow *) toolbar_item->parent;
1683 summary_mark_all_unread(mainwin->summaryview, TRUE);
1685 case TOOLBAR_MSGVIEW:
1686 /* TODO: see toolbar_next_unread_cb() if you need
1687 * this in the message view */
1690 debug_print("toolbar event not supported\n");
1695 static void toolbar_read_cb(GtkWidget *widget, gpointer data)
1697 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1698 MainWindow *mainwin;
1700 cm_return_if_fail(toolbar_item != NULL);
1702 switch (toolbar_item->type) {
1704 mainwin = (MainWindow *) toolbar_item->parent;
1705 summary_mark_as_read(mainwin->summaryview);
1707 case TOOLBAR_MSGVIEW:
1708 /* TODO: see toolbar_next_unread_cb() if you need
1709 * this in the message view */
1712 debug_print("toolbar event not supported\n");
1717 static void toolbar_unread_cb(GtkWidget *widget, gpointer data)
1719 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1720 MainWindow *mainwin;
1722 cm_return_if_fail(toolbar_item != NULL);
1724 switch (toolbar_item->type) {
1726 mainwin = (MainWindow *) toolbar_item->parent;
1727 summary_mark_as_unread(mainwin->summaryview);
1729 case TOOLBAR_MSGVIEW:
1730 /* TODO: see toolbar_next_unread_cb() if you need
1731 * this in the message view */
1734 debug_print("toolbar event not supported\n");
1739 static void toolbar_cancel_inc_cb(GtkWidget *widget, gpointer data)
1741 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1743 cm_return_if_fail(toolbar_item != NULL);
1748 static void toolbar_cancel_send_cb(GtkWidget *widget, gpointer data)
1750 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1752 cm_return_if_fail(toolbar_item != NULL);
1756 static void toolbar_cancel_all_cb(GtkWidget *widget, gpointer data)
1758 toolbar_cancel_inc_cb(widget, data);
1759 toolbar_cancel_send_cb(widget, data);
1762 static void toolbar_print_cb(GtkWidget *widget, gpointer data)
1764 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1765 MainWindow *mainwin;
1767 cm_return_if_fail(toolbar_item != NULL);
1769 switch (toolbar_item->type) {
1771 mainwin = (MainWindow *) toolbar_item->parent;
1772 summary_print(mainwin->summaryview);
1774 case TOOLBAR_MSGVIEW:
1775 /* TODO: see toolbar_next_unread_cb() if you need
1776 * this in the message view */
1779 debug_print("toolbar event not supported\n");
1784 static void toolbar_send_cb(GtkWidget *widget, gpointer data)
1786 compose_toolbar_cb(A_SEND, data);
1789 static void toolbar_send_later_cb(GtkWidget *widget, gpointer data)
1791 compose_toolbar_cb(A_SEND_LATER, data);
1794 static void toolbar_draft_cb(GtkWidget *widget, gpointer data)
1796 compose_toolbar_cb(A_DRAFT, data);
1799 static void toolbar_close_cb(GtkWidget *widget, gpointer data)
1801 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1802 MainWindow *mainwin;
1803 MessageView *messageview;
1806 cm_return_if_fail(toolbar_item != NULL);
1808 switch (toolbar_item->type) {
1810 mainwin = (MainWindow *) toolbar_item->parent;
1811 app_will_exit(NULL, mainwin);
1813 case TOOLBAR_MSGVIEW:
1814 messageview = (MessageView *)toolbar_item->parent;
1815 messageview_destroy(messageview);
1817 case TOOLBAR_COMPOSE:
1818 compose = (Compose *)toolbar_item->parent;
1819 compose_close_toolbar(compose);
1824 static void toolbar_preferences_cb(GtkWidget *widget, gpointer data)
1829 static void toolbar_open_mail_cb(GtkWidget *widget, gpointer data)
1831 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1832 MainWindow *mainwin;
1834 cm_return_if_fail(toolbar_item != NULL);
1836 switch (toolbar_item->type) {
1838 mainwin = (MainWindow *) toolbar_item->parent;
1839 summary_open_row(NULL, mainwin->summaryview);
1841 case TOOLBAR_MSGVIEW:
1842 debug_print("toolbar event not supported\n");
1844 case TOOLBAR_COMPOSE:
1845 debug_print("toolbar event not supported\n");
1850 static void toolbar_insert_cb(GtkWidget *widget, gpointer data)
1852 compose_toolbar_cb(A_INSERT, data);
1855 static void toolbar_attach_cb(GtkWidget *widget, gpointer data)
1857 compose_toolbar_cb(A_ATTACH, data);
1860 static void toolbar_sig_cb(GtkWidget *widget, gpointer data)
1862 compose_toolbar_cb(A_SIG, data);
1865 static void toolbar_replace_sig_cb(GtkWidget *widget, gpointer data)
1867 compose_toolbar_cb(A_REP_SIG, data);
1870 static void toolbar_ext_editor_cb(GtkWidget *widget, gpointer data)
1872 compose_toolbar_cb(A_EXTEDITOR, data);
1875 static void toolbar_linewrap_current_cb(GtkWidget *widget, gpointer data)
1877 compose_toolbar_cb(A_LINEWRAP_CURRENT, data);
1880 static void toolbar_linewrap_all_cb(GtkWidget *widget, gpointer data)
1882 compose_toolbar_cb(A_LINEWRAP_ALL, data);
1886 static void toolbar_check_spelling_cb(GtkWidget *widget, gpointer data)
1888 compose_toolbar_cb(A_CHECK_SPELLING, data);
1892 * Execute actions from toolbar
1894 static void toolbar_actions_execute_cb(GtkWidget *widget, gpointer data)
1896 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1897 GSList *action_list;
1898 MainWindow *mainwin;
1900 MessageView *msgview;
1901 gpointer parent = toolbar_item->parent;
1903 cm_return_if_fail(toolbar_item != NULL);
1905 switch (toolbar_item->type) {
1907 mainwin = (MainWindow*)parent;
1908 action_list = mainwin->toolbar->action_list;
1910 case TOOLBAR_COMPOSE:
1911 compose = (Compose*)parent;
1912 action_list = compose->toolbar->action_list;
1914 case TOOLBAR_MSGVIEW:
1915 msgview = (MessageView*)parent;
1916 action_list = msgview->toolbar->action_list;
1919 debug_print("toolbar event not supported\n");
1922 toolbar_action_execute(widget, action_list, parent, toolbar_item->type);
1925 static void toolbar_plugins_execute_cb(GtkWidget *widget, gpointer data)
1927 ToolbarItem *toolbar_item = data;
1928 prefs_toolbar_execute_plugin_item(toolbar_item->parent, toolbar_item->type, toolbar_item->text);
1931 static MainWindow *get_mainwin(gpointer data)
1933 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1934 MainWindow *mainwin = NULL;
1935 MessageView *msgview;
1937 cm_return_val_if_fail(toolbar_item != NULL, NULL);
1939 switch(toolbar_item->type) {
1941 mainwin = (MainWindow*)toolbar_item->parent;
1943 case TOOLBAR_MSGVIEW:
1944 msgview = (MessageView*)toolbar_item->parent;
1945 mainwin = (MainWindow*)msgview->mainwin;
1954 static void toolbar_go_folders_cb(GtkWidget *widget, gpointer data)
1956 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1957 MainWindow *mainwin = NULL;
1958 switch(toolbar_item->type) {
1960 mainwin = (MainWindow*)toolbar_item->parent;
1963 g_warning("wrong toolbar type");
1967 if (!mainwin->in_folder) {
1968 FolderItem *item = folderview_get_selected_item(mainwin->folderview);
1970 folderview_select(mainwin->folderview, item);
1973 folderview_grab_focus(mainwin->folderview);
1974 mainwindow_exit_folder(mainwin);
1978 static void toolbar_buttons_cb(GtkWidget *widget,
1985 void (*func)(GtkWidget *widget, gpointer data);
1987 { A_RECEIVE_ALL, toolbar_inc_all_cb },
1988 { A_RECEIVE_CUR, toolbar_inc_cb },
1989 { A_SEND_QUEUED, toolbar_send_queued_cb },
1990 { A_COMPOSE_EMAIL, toolbar_compose_cb },
1991 { A_COMPOSE_NEWS, toolbar_compose_cb },
1992 { A_REPLY_MESSAGE, toolbar_reply_cb },
1993 { A_REPLY_SENDER, toolbar_reply_to_sender_cb },
1994 { A_REPLY_ALL, toolbar_reply_to_all_cb },
1995 { A_REPLY_ML, toolbar_reply_to_list_cb },
1996 { A_FORWARD, toolbar_forward_cb },
1997 { A_TRASH, toolbar_trash_cb },
1998 { A_DELETE_REAL, toolbar_delete_cb },
1999 { A_EXECUTE, toolbar_exec_cb },
2000 { A_GOTO_PREV, toolbar_prev_unread_cb },
2001 { A_GOTO_NEXT, toolbar_next_unread_cb },
2002 { A_IGNORE_THREAD, toolbar_ignore_thread_cb },
2003 { A_WATCH_THREAD, toolbar_watch_thread_cb },
2004 { A_MARK, toolbar_mark_cb },
2005 { A_UNMARK, toolbar_unmark_cb },
2006 { A_LOCK, toolbar_lock_cb },
2007 { A_UNLOCK, toolbar_unlock_cb },
2008 { A_ALL_READ, toolbar_all_read_cb },
2009 { A_ALL_UNREAD, toolbar_all_unread_cb },
2010 { A_READ, toolbar_read_cb },
2011 { A_UNREAD, toolbar_unread_cb },
2012 { A_PRINT, toolbar_print_cb },
2013 { A_LEARN_SPAM, toolbar_learn_cb },
2014 { A_DELETE_DUP, toolbar_delete_dup_cb },
2015 { A_GO_FOLDERS, toolbar_go_folders_cb },
2017 { A_SEND, toolbar_send_cb },
2018 { A_SEND_LATER, toolbar_send_later_cb },
2019 { A_DRAFT, toolbar_draft_cb },
2020 { A_OPEN_MAIL, toolbar_open_mail_cb },
2021 { A_CLOSE, toolbar_close_cb },
2022 { A_PREFERENCES, toolbar_preferences_cb },
2023 { A_INSERT, toolbar_insert_cb },
2024 { A_ATTACH, toolbar_attach_cb },
2025 { A_SIG, toolbar_sig_cb },
2026 { A_REP_SIG, toolbar_replace_sig_cb },
2027 { A_EXTEDITOR, toolbar_ext_editor_cb },
2028 { A_LINEWRAP_CURRENT, toolbar_linewrap_current_cb },
2029 { A_LINEWRAP_ALL, toolbar_linewrap_all_cb },
2030 { A_ADDRBOOK, toolbar_addrbook_cb },
2032 { A_CHECK_SPELLING, toolbar_check_spelling_cb },
2034 { A_CLAWS_ACTIONS, toolbar_actions_execute_cb },
2035 { A_CANCEL_INC, toolbar_cancel_inc_cb },
2036 { A_CANCEL_SEND, toolbar_cancel_send_cb },
2037 { A_CANCEL_ALL, toolbar_cancel_all_cb },
2038 { A_CLAWS_PLUGINS, toolbar_plugins_execute_cb },
2041 num_items = sizeof(callbacks)/sizeof(callbacks[0]);
2043 for (i = 0; i < num_items; i++) {
2044 if (callbacks[i].index == item->index) {
2045 callbacks[i].func(widget, item);
2050 #ifndef GENERIC_UMPC
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); \
2058 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(item), \
2062 #define TOOLBAR_MENUITEM(item,icon,text,tooltip,menutip) { \
2063 GtkWidget *child = NULL, *btn = NULL, *arr = NULL; \
2064 GList *gchild = NULL; \
2065 item = GTK_WIDGET(gtk_menu_tool_button_new(icon, text)); \
2066 gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE); \
2067 gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE); \
2068 g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item); \
2069 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1); \
2070 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(item), \
2072 CLAWS_SET_ARROW_TIP(GTK_MENU_TOOL_BUTTON(item), menutip); \
2073 child = gtk_bin_get_child(GTK_BIN(item)); \
2074 gchild = gtk_container_get_children( \
2075 GTK_CONTAINER(child)); \
2076 btn = (GtkWidget *)gchild->data; \
2077 gtkut_widget_set_can_focus(btn, FALSE); \
2078 arr = (GtkWidget *)(gchild->next?gchild->next->data:NULL); \
2079 gtkut_widget_set_can_focus(arr, FALSE); \
2080 g_list_free(gchild); \
2081 gchild = gtk_container_get_children(GTK_CONTAINER(arr)); \
2082 gtk_widget_set_size_request(GTK_WIDGET(gchild->data), 9, -1); \
2083 g_list_free(gchild); \
2086 #define TOOLBAR_ITEM(item,icon,text,tooltip) { \
2087 item = GTK_WIDGET(gtk_tool_button_new(icon, text)); \
2088 gtkut_widget_set_can_focus(gtk_bin_get_child(GTK_BIN(item)), FALSE); \
2089 gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE); \
2090 gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE); \
2091 g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item); \
2092 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1); \
2095 #define TOOLBAR_MENUITEM(item,icon,text,tooltip,menutip) { \
2096 GtkWidget *child = NULL, *btn = NULL, *arr = NULL; \
2097 GList *gchild = NULL; \
2098 item = GTK_WIDGET(gtk_menu_tool_button_new(icon, text)); \
2099 gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE); \
2100 gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE); \
2101 g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item); \
2102 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1); \
2103 child = gtk_bin_get_child(GTK_BIN(item)); \
2104 gchild = gtk_container_get_children( \
2105 GTK_CONTAINER(child)); \
2106 btn = (GtkWidget *)gchild->data; \
2107 gtkut_widget_set_can_focus(btn, FALSE); \
2108 arr = (GtkWidget *)(gchild->next?gchild->next->data:NULL); \
2109 gtkut_widget_set_can_focus(arr, FALSE); \
2110 g_list_free(gchild); \
2111 gchild = gtk_container_get_children(GTK_CONTAINER(arr)); \
2112 gtk_widget_set_size_request(GTK_WIDGET(gchild->data), 9, -1); \
2113 g_list_free(gchild); \
2117 #define ADD_MENU_ITEM(name,cb,data) { \
2118 item = gtk_menu_item_new_with_mnemonic(name); \
2119 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); \
2120 g_signal_connect(G_OBJECT(item), "activate", \
2123 g_object_set_data(G_OBJECT(item), "int-value", GINT_TO_POINTER(data)); \
2124 gtk_widget_show(item); \
2127 static void toolbar_reply_menu_cb(GtkWidget *widget, gpointer data)
2129 gpointer int_value = g_object_get_data(G_OBJECT(widget), "int-value");
2130 ToolbarItem *toolbar_item = (ToolbarItem *)data;
2132 toolbar_reply(toolbar_item, GPOINTER_TO_INT(int_value));
2135 static void toolbar_learn_menu_cb(GtkWidget *widget, gpointer data)
2137 gpointer int_value = g_object_get_data(G_OBJECT(widget), "int-value");
2138 ToolbarItem *toolbar_item = (ToolbarItem *)data;
2140 toolbar_learn(toolbar_item, GPOINTER_TO_INT(int_value));
2143 static void toolbar_delete_dup_menu_cb(GtkWidget *widget, gpointer data)
2145 gpointer int_value = g_object_get_data(G_OBJECT(widget), "int-value");
2146 ToolbarItem *toolbar_item = (ToolbarItem *)data;
2148 toolbar_delete_dup(toolbar_item, GPOINTER_TO_INT(int_value));
2152 * Create a new toolbar with specified type
2153 * if a callback list is passed it will be used before the
2154 * common callback list
2156 Toolbar *toolbar_create(ToolbarType type,
2157 GtkWidget *container,
2160 ToolbarItem *toolbar_item;
2163 GtkWidget *icon_wid = NULL;
2164 GtkWidget *icon_news;
2165 GtkWidget *icon_ham;
2167 ToolbarClawsActions *action_item;
2169 GSList *toolbar_list;
2170 Toolbar *toolbar_data;
2172 toolbar_read_config_file(type);
2173 toolbar_list = toolbar_get_list(type);
2175 toolbar_data = g_new0(Toolbar, 1);
2177 toolbar = gtk_toolbar_new();
2179 gtk_orientable_set_orientation(GTK_ORIENTABLE(toolbar), GTK_ORIENTATION_HORIZONTAL);
2181 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_BOTH);
2182 gtk_toolbar_set_show_arrow(GTK_TOOLBAR(toolbar), TRUE);
2184 for (cur = toolbar_list; cur != NULL; cur = cur->next) {
2186 if (g_ascii_strcasecmp(((ToolbarItem*)cur->data)->file, TOOLBAR_TAG_SEPARATOR) == 0) {
2187 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), gtk_separator_tool_item_new(), -1);
2191 toolbar_item = g_new0(ToolbarItem, 1);
2192 toolbar_item->index = ((ToolbarItem*)cur->data)->index;
2193 toolbar_item->file = g_strdup(((ToolbarItem*)cur->data)->file);
2194 toolbar_item->text = g_strdup(((ToolbarItem*)cur->data)->text);
2195 toolbar_item->parent = data;
2196 toolbar_item->type = type;
2198 /* collect toolbar items in list to keep track */
2199 toolbar_data->item_list =
2200 g_slist_append(toolbar_data->item_list,
2202 icon_wid = stock_pixmap_widget(stock_pixmap_get_icon(toolbar_item->file));
2204 switch (toolbar_item->index) {
2207 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Go to folder list"));
2208 toolbar_data->folders_btn = item;
2211 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2212 _("Receive Mail from all Accounts"),
2213 _("Receive Mail from selected Account"));
2214 toolbar_data->getall_btn = item;
2217 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Receive Mail from current Account"));
2218 toolbar_data->get_btn = item;
2221 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Send Queued Messages"));
2222 toolbar_data->send_btn = item;
2225 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Close window"));
2226 toolbar_data->close_window_btn = item;
2229 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Open preferences"));
2230 toolbar_data->preferences_btn = item;
2233 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Open email"));
2234 toolbar_data->open_mail_btn = item;
2236 case A_COMPOSE_EMAIL:
2237 #ifndef GENERIC_UMPC
2238 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2240 _("Compose with selected Account"));
2241 toolbar_data->compose_mail_btn = item;
2242 toolbar_data->compose_mail_icon = icon_wid;
2243 g_object_ref(toolbar_data->compose_mail_icon);
2245 icon_news = stock_pixmap_widget(STOCK_PIXMAP_NEWS_COMPOSE);
2246 toolbar_data->compose_news_icon = icon_news;
2247 g_object_ref(toolbar_data->compose_news_icon);
2249 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2250 _("Compose Email"));
2251 toolbar_data->compose_mail_btn = item;
2252 toolbar_data->compose_mail_icon = icon_wid;
2254 icon_news = stock_pixmap_widget(STOCK_PIXMAP_NEWS_COMPOSE);
2255 toolbar_data->compose_news_icon = icon_news;
2259 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2262 toolbar_data->learn_spam_btn = item;
2263 toolbar_data->learn_spam_icon = icon_wid;
2264 g_object_ref(toolbar_data->learn_spam_icon);
2266 icon_ham = stock_pixmap_widget(STOCK_PIXMAP_HAM_BTN);
2267 toolbar_data->learn_ham_icon = icon_ham;
2268 g_object_ref(toolbar_data->learn_ham_icon);
2270 menu = gtk_menu_new();
2271 ADD_MENU_ITEM(_("Learn as _Spam"), toolbar_learn_menu_cb, TRUE);
2272 ADD_MENU_ITEM(_("Learn as _Ham"), toolbar_learn_menu_cb, FALSE);
2273 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->learn_spam_btn), menu);
2276 #ifndef GENERIC_UMPC
2277 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2278 _("Delete duplicates"),
2279 _("Delete duplicates options"));
2280 toolbar_data->delete_dup_btn = item;
2282 menu = gtk_menu_new();
2283 ADD_MENU_ITEM(_("Delete duplicates in selected folder"), toolbar_delete_dup_menu_cb, FALSE);
2284 ADD_MENU_ITEM(_("Delete duplicates in all folders"), toolbar_delete_dup_menu_cb, TRUE);
2285 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->delete_dup_btn), menu);
2287 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Delete duplicates"));
2288 toolbar_data->delete_dup_btn = item;
2291 case A_REPLY_MESSAGE:
2292 #ifndef GENERIC_UMPC
2293 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2294 _("Reply to Message"),
2295 _("Reply to Message options"));
2296 toolbar_data->reply_btn = item;
2298 menu = gtk_menu_new();
2299 ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_WITH_QUOTE);
2300 ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_WITHOUT_QUOTE);
2301 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->reply_btn), menu);
2303 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2304 _("Reply to Message"));
2305 toolbar_data->reply_btn = item;
2308 case A_REPLY_SENDER:
2309 #ifndef GENERIC_UMPC
2310 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2311 _("Reply to Sender"),
2312 _("Reply to Sender options"));
2313 toolbar_data->replysender_btn = item;
2315 menu = gtk_menu_new();
2316 ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE);
2317 ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE);
2318 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->replysender_btn), menu);
2320 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2321 _("Reply to Sender"));
2322 toolbar_data->replysender_btn = item;
2326 #ifndef GENERIC_UMPC
2327 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2329 _("Reply to All options"));
2330 toolbar_data->replyall_btn = item;
2332 menu = gtk_menu_new();
2333 ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE);
2334 ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE);
2335 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->replyall_btn), menu);
2337 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2339 toolbar_data->replyall_btn = item;
2343 #ifndef GENERIC_UMPC
2344 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2345 _("Reply to Mailing-list"),
2346 _("Reply to Mailing-list options"));
2347 toolbar_data->replylist_btn = item;
2349 menu = gtk_menu_new();
2350 ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_LIST_WITH_QUOTE);
2351 ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE);
2352 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->replylist_btn), menu);
2354 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2355 _("Reply to Mailing-list"));
2356 toolbar_data->replylist_btn = item;
2360 #ifndef GENERIC_UMPC
2361 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2362 _("Forward Message"),
2363 _("Forward Message options"));
2364 toolbar_data->fwd_btn = item;
2366 menu = gtk_menu_new();
2367 ADD_MENU_ITEM(_("_Forward"), toolbar_reply_menu_cb, COMPOSE_FORWARD_INLINE);
2368 ADD_MENU_ITEM(_("For_ward as attachment"), toolbar_reply_menu_cb, COMPOSE_FORWARD_AS_ATTACH);
2369 ADD_MENU_ITEM(_("Redirec_t"), toolbar_reply_menu_cb, COMPOSE_REDIRECT);
2370 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->fwd_btn), menu);
2372 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2373 _("Forward Message"));
2374 toolbar_data->fwd_btn = item;
2378 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Trash Message"));
2379 toolbar_data->trash_btn = item;
2382 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Delete Message"));
2383 toolbar_data->delete_btn = item;
2386 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Execute"));
2387 toolbar_data->exec_btn = item;
2390 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Go to Previous Unread Message"));
2391 toolbar_data->prev_btn = item;
2394 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Go to Next Unread Message"));
2395 toolbar_data->next_btn = item;
2398 /* Compose Toolbar */
2400 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Send Message"));
2401 toolbar_data->send_btn = item;
2404 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Put into queue folder and send later"));
2405 toolbar_data->sendl_btn = item;
2408 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Save to draft folder"));
2409 toolbar_data->draft_btn = item;
2412 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Insert file"));
2413 toolbar_data->insert_btn = item;
2416 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Attach file"));
2417 toolbar_data->attach_btn = item;
2420 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Insert signature"));
2421 toolbar_data->sig_btn = item;
2424 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Replace signature"));
2425 toolbar_data->repsig_btn = item;
2428 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Edit with external editor"));
2429 toolbar_data->exteditor_btn = item;
2431 case A_LINEWRAP_CURRENT:
2432 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Wrap long lines of current paragraph"));
2433 toolbar_data->linewrap_current_btn = item;
2435 case A_LINEWRAP_ALL:
2436 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Wrap all long lines"));
2437 toolbar_data->linewrap_all_btn = item;
2440 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Address book"));
2441 toolbar_data->addrbook_btn = item;
2444 case A_CHECK_SPELLING:
2445 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Check spelling"));
2446 toolbar_data->spellcheck_btn = item;
2450 case A_CLAWS_ACTIONS:
2451 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,toolbar_item->text);
2452 action_item = g_new0(ToolbarClawsActions, 1);
2453 action_item->widget = item;
2454 action_item->name = g_strdup(toolbar_item->text);
2456 toolbar_data->action_list =
2457 g_slist_append(toolbar_data->action_list,
2461 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Cancel receiving"));
2462 toolbar_data->cancel_inc_btn = item;
2465 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Cancel sending"));
2466 toolbar_data->cancel_send_btn = item;
2469 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Cancel receiving/sending"));
2470 toolbar_data->cancel_all_btn = item;
2472 case A_CLAWS_PLUGINS:
2473 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text, toolbar_item->text);
2476 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2477 toolbar_ret_descr_from_val(toolbar_item->index));
2478 /* find and set the tool tip text */
2483 toolbar_data->toolbar = toolbar;
2485 gtk_widget_show_all(toolbar);
2487 if (type == TOOLBAR_MAIN) {
2489 MainWindow *mainwin = mainwindow_get_mainwindow();
2490 GtkWidget *progressbar = gtk_progress_bar_new();
2491 item = GTK_WIDGET(gtk_tool_item_new());
2492 gtk_container_add (GTK_CONTAINER (item), progressbar);
2493 gtk_widget_show(item);
2494 gtk_widget_set_size_request(progressbar, 84, -1);
2495 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1);
2496 mainwin->progressbar = progressbar;
2498 activate_compose_button(toolbar_data,
2499 prefs_common.toolbar_style,
2500 toolbar_data->compose_btn_type);
2502 if (type != TOOLBAR_COMPOSE)
2503 activate_learn_button(toolbar_data, prefs_common.toolbar_style,
2506 gtk_container_add(GTK_CONTAINER(container), toolbar);
2507 gtk_container_set_border_width(GTK_CONTAINER(container), 0);
2509 return toolbar_data;
2513 * Free toolbar structures
2515 void toolbar_destroy(Toolbar * toolbar) {
2517 TOOLBAR_DESTROY_ITEMS(toolbar->item_list);
2518 TOOLBAR_DESTROY_ACTIONS(toolbar->action_list);
2521 void toolbar_update(ToolbarType type, gpointer data)
2523 Toolbar *toolbar_data;
2524 GtkWidget *handlebox;
2525 MainWindow *mainwin = (MainWindow*)data;
2526 Compose *compose = (Compose*)data;
2527 MessageView *msgview = (MessageView*)data;
2529 #ifndef GENERIC_UMPC
2532 toolbar_data = mainwin->toolbar;
2533 handlebox = mainwin->handlebox;
2535 case TOOLBAR_COMPOSE:
2536 toolbar_data = compose->toolbar;
2537 handlebox = compose->handlebox;
2539 case TOOLBAR_MSGVIEW:
2540 toolbar_data = msgview->toolbar;
2541 handlebox = msgview->handlebox;
2547 gtk_container_remove(GTK_CONTAINER(handlebox),
2548 GTK_WIDGET(toolbar_data->toolbar));
2550 toolbar_init(toolbar_data);
2551 toolbar_data = toolbar_create(type, handlebox, data);
2555 toolbar_data = mainwin->toolbar;
2556 handlebox = mainwin->window;
2558 case TOOLBAR_COMPOSE:
2559 toolbar_data = compose->toolbar;
2560 handlebox = compose->window;
2562 case TOOLBAR_MSGVIEW:
2563 toolbar_data = msgview->toolbar;
2564 handlebox = msgview->window;
2569 toolbar_init(toolbar_data);
2570 toolbar_data = toolbar_create(type, handlebox, data);
2575 mainwin->toolbar = toolbar_data;
2577 case TOOLBAR_COMPOSE:
2578 compose->toolbar = toolbar_data;
2580 case TOOLBAR_MSGVIEW:
2581 msgview->toolbar = toolbar_data;
2585 toolbar_style(type, prefs_common.toolbar_style, data);
2587 if (type == TOOLBAR_MAIN) {
2588 toolbar_main_set_sensitive((MainWindow*)data);
2589 account_set_menu_only_toolbar();
2593 #define GTK_BUTTON_SET_SENSITIVE(widget,sensitive) { \
2594 gtk_widget_set_sensitive(widget, sensitive); \
2597 void toolbar_main_set_sensitive(gpointer data)
2599 SensitiveCondMask state;
2601 MainWindow *mainwin = (MainWindow*)data;
2602 Toolbar *toolbar = mainwin->toolbar;
2604 GSList *entry_list = NULL;
2606 typedef struct _Entry Entry;
2609 SensitiveCondMask cond;
2613 #define SET_WIDGET_COND(w, ...) \
2615 Entry *e = g_new0(Entry, 1); \
2617 e->cond = main_window_get_mask(__VA_ARGS__, -1); \
2618 entry_list = g_slist_append(entry_list, e); \
2621 /* match all bit flags */
2623 if (toolbar->get_btn)
2624 SET_WIDGET_COND(toolbar->get_btn,
2625 M_HAVE_ACCOUNT, M_UNLOCKED, M_HAVE_RETRIEVABLE_ACCOUNT);
2627 if (toolbar->getall_btn) {
2628 SET_WIDGET_COND(toolbar->getall_btn,
2629 M_HAVE_ACCOUNT, M_UNLOCKED, M_HAVE_ANY_RETRIEVABLE_ACCOUNT);
2631 if (toolbar->send_btn) {
2632 SET_WIDGET_COND(toolbar->send_btn,
2633 M_HAVE_QUEUED_MAILS);
2635 if (toolbar->compose_mail_btn) {
2636 SET_WIDGET_COND(toolbar->compose_mail_btn,
2639 if (toolbar->close_window_btn) {
2640 SET_WIDGET_COND(toolbar->close_window_btn,
2643 if (toolbar->open_mail_btn) {
2644 SET_WIDGET_COND(toolbar->open_mail_btn,
2645 M_TARGET_EXIST, M_SUMMARY_ISLIST);
2647 if (toolbar->reply_btn) {
2648 SET_WIDGET_COND(toolbar->reply_btn,
2649 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2651 if (toolbar->replyall_btn) {
2652 SET_WIDGET_COND(toolbar->replyall_btn,
2653 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2655 if (toolbar->replylist_btn) {
2656 SET_WIDGET_COND(toolbar->replylist_btn,
2657 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2659 if (toolbar->replysender_btn) {
2660 SET_WIDGET_COND(toolbar->replysender_btn,
2661 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2663 if (toolbar->fwd_btn) {
2664 SET_WIDGET_COND(toolbar->fwd_btn,
2665 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2668 if (prefs_common.next_unread_msg_dialog == NEXTUNREADMSGDIALOG_ASSUME_NO) {
2669 SET_WIDGET_COND(toolbar->next_btn, M_MSG_EXIST, M_SUMMARY_ISLIST);
2671 SET_WIDGET_COND(toolbar->next_btn, -1);
2674 if (toolbar->trash_btn)
2675 SET_WIDGET_COND(toolbar->trash_btn,
2676 M_TARGET_EXIST, M_ALLOW_DELETE, M_NOT_NEWS);
2678 if (toolbar->delete_btn)
2679 SET_WIDGET_COND(toolbar->delete_btn,
2680 M_TARGET_EXIST, M_ALLOW_DELETE);
2682 if (toolbar->delete_dup_btn)
2683 SET_WIDGET_COND(toolbar->delete_dup_btn,
2684 M_MSG_EXIST, M_ALLOW_DELETE, M_SUMMARY_ISLIST);
2686 if (toolbar->exec_btn)
2687 SET_WIDGET_COND(toolbar->exec_btn,
2690 if (toolbar->learn_spam_btn)
2691 SET_WIDGET_COND(toolbar->learn_spam_btn,
2692 M_TARGET_EXIST, M_CAN_LEARN_SPAM, M_SUMMARY_ISLIST);
2694 if (toolbar->cancel_inc_btn)
2695 SET_WIDGET_COND(toolbar->cancel_inc_btn,
2698 if (toolbar->cancel_send_btn)
2699 SET_WIDGET_COND(toolbar->cancel_send_btn,
2702 for (cur = toolbar->action_list; cur != NULL; cur = cur->next) {
2703 ToolbarClawsActions *act = (ToolbarClawsActions*)cur->data;
2705 SET_WIDGET_COND(act->widget, M_TARGET_EXIST, M_UNLOCKED);
2708 state = main_window_get_current_state(mainwin);
2710 for (cur = entry_list; cur != NULL; cur = cur->next) {
2711 Entry *e = (Entry*) cur->data;
2713 if (e->widget != NULL) {
2714 sensitive = ((e->cond & state) == e->cond);
2715 GTK_BUTTON_SET_SENSITIVE(e->widget, sensitive);
2719 while (entry_list != NULL) {
2720 Entry *e = (Entry*) entry_list->data;
2723 entry_list = g_slist_remove(entry_list, e);
2726 /* match any bit flags */
2728 if (toolbar->cancel_all_btn)
2729 SET_WIDGET_COND(toolbar->cancel_all_btn,
2730 M_INC_ACTIVE, M_SEND_ACTIVE);
2732 for (cur = entry_list; cur != NULL; cur = cur->next) {
2733 Entry *e = (Entry*) cur->data;
2735 if (e->widget != NULL) {
2736 sensitive = ((e->cond & state) != 0);
2737 GTK_BUTTON_SET_SENSITIVE(e->widget, sensitive);
2741 while (entry_list != NULL) {
2742 Entry *e = (Entry*) entry_list->data;
2745 entry_list = g_slist_remove(entry_list, e);
2748 g_slist_free(entry_list);
2750 activate_compose_button(toolbar,
2751 prefs_common.toolbar_style,
2752 toolbar->compose_btn_type);
2754 #undef SET_WIDGET_COND
2757 void toolbar_comp_set_sensitive(gpointer data, gboolean sensitive)
2759 Compose *compose = (Compose*)data;
2760 GSList *items = compose->toolbar->action_list;
2762 if (compose->toolbar->send_btn)
2763 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->send_btn, sensitive);
2764 if (compose->toolbar->sendl_btn)
2765 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->sendl_btn, sensitive);
2766 if (compose->toolbar->draft_btn )
2767 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->draft_btn , sensitive);
2768 if (compose->toolbar->insert_btn )
2769 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->insert_btn , sensitive);
2770 if (compose->toolbar->attach_btn)
2771 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->attach_btn, sensitive);
2772 if (compose->toolbar->sig_btn)
2773 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->sig_btn, sensitive);
2774 if (compose->toolbar->repsig_btn)
2775 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->repsig_btn, sensitive);
2776 if (compose->toolbar->exteditor_btn)
2777 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->exteditor_btn, sensitive);
2778 if (compose->toolbar->linewrap_current_btn)
2779 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->linewrap_current_btn, sensitive);
2780 if (compose->toolbar->linewrap_all_btn)
2781 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->linewrap_all_btn, sensitive);
2782 if (compose->toolbar->addrbook_btn)
2783 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->addrbook_btn, sensitive);
2785 if (compose->toolbar->spellcheck_btn)
2786 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->spellcheck_btn, sensitive);
2788 for (; items != NULL; items = g_slist_next(items)) {
2789 ToolbarClawsActions *item = (ToolbarClawsActions *)items->data;
2790 GTK_BUTTON_SET_SENSITIVE(item->widget, sensitive);
2795 * Initialize toolbar structure
2797 static void toolbar_init(Toolbar * toolbar)
2800 toolbar->toolbar = NULL;
2801 toolbar->folders_btn = NULL;
2802 toolbar->get_btn = NULL;
2803 toolbar->getall_btn = NULL;
2804 toolbar->send_btn = NULL;
2805 toolbar->compose_mail_btn = NULL;
2806 toolbar->compose_mail_icon = NULL;
2807 toolbar->compose_news_icon = NULL;
2808 toolbar->reply_btn = NULL;
2809 toolbar->replysender_btn = NULL;
2810 toolbar->replyall_btn = NULL;
2811 toolbar->replylist_btn = NULL;
2812 toolbar->fwd_btn = NULL;
2813 toolbar->trash_btn = NULL;
2814 toolbar->delete_btn = NULL;
2815 toolbar->delete_dup_btn = NULL;
2816 toolbar->prev_btn = NULL;
2817 toolbar->next_btn = NULL;
2818 toolbar->exec_btn = NULL;
2819 toolbar->separator = NULL;
2820 toolbar->learn_spam_btn = NULL;
2821 toolbar->learn_spam_icon = NULL;
2822 toolbar->learn_ham_icon = NULL;
2823 toolbar->cancel_inc_btn = NULL;
2824 toolbar->cancel_send_btn = NULL;
2825 toolbar->cancel_all_btn = NULL;
2827 /* compose buttons */
2828 toolbar->sendl_btn = NULL;
2829 toolbar->draft_btn = NULL;
2830 toolbar->insert_btn = NULL;
2831 toolbar->attach_btn = NULL;
2832 toolbar->sig_btn = NULL;
2833 toolbar->repsig_btn = NULL;
2834 toolbar->exteditor_btn = NULL;
2835 toolbar->linewrap_current_btn = NULL;
2836 toolbar->linewrap_all_btn = NULL;
2837 toolbar->addrbook_btn = NULL;
2839 toolbar->open_mail_btn = NULL;
2840 toolbar->close_window_btn = NULL;
2841 toolbar->preferences_btn = NULL;
2842 toolbar->action_list = NULL;
2843 toolbar->item_list = NULL;
2845 toolbar->spellcheck_btn = NULL;
2848 toolbar_destroy(toolbar);
2853 static void toolbar_reply(gpointer data, guint action)
2855 ToolbarItem *toolbar_item = (ToolbarItem*)data;
2856 MainWindow *mainwin;
2857 MessageView *msgview;
2858 GSList *msginfo_list = NULL;
2860 cm_return_if_fail(toolbar_item != NULL);
2862 switch (toolbar_item->type) {
2864 mainwin = (MainWindow*)toolbar_item->parent;
2865 msginfo_list = summary_get_selection(mainwin->summaryview);
2866 msgview = (MessageView*)mainwin->messageview;
2868 case TOOLBAR_MSGVIEW:
2869 msgview = (MessageView*)toolbar_item->parent;
2870 cm_return_if_fail(msgview != NULL);
2871 msginfo_list = g_slist_append(msginfo_list, msgview->msginfo);
2877 cm_return_if_fail(msgview != NULL);
2878 cm_return_if_fail(msginfo_list != NULL);
2879 compose_reply_from_messageview(msgview, msginfo_list, action);
2880 g_slist_free(msginfo_list);
2882 /* TODO: update reply state ion summaryview */
2886 /* exported functions */
2888 void inc_mail_cb(gpointer data, guint action, GtkWidget *widget)
2890 MainWindow *mainwin = (MainWindow*)data;
2892 inc_mail(mainwin, prefs_common.newmail_notify_manu);
2895 void inc_all_account_mail_cb(gpointer data, guint action, GtkWidget *widget)
2897 MainWindow *mainwin = (MainWindow*)data;
2899 inc_all_account_mail(mainwin, FALSE, prefs_common.newmail_notify_manu);
2902 void send_queue_cb(gpointer data, guint action, GtkWidget *widget)
2906 gboolean got_error = FALSE;
2907 gchar *errstr = NULL;
2909 if (prefs_common.work_offline)
2910 if (alertpanel(_("Offline warning"),
2911 _("You're working offline. Override?"),
2912 GTK_STOCK_NO, GTK_STOCK_YES,
2913 NULL) != G_ALERTALTERNATE)
2916 /* ask for confirmation before sending queued messages only
2917 in online mode and if there is at least one message queued
2918 in any of the folder queue
2920 if (prefs_common.confirm_send_queued_messages) {
2922 /* check if there's a queued message */
2923 for (list = folder_get_list(); !found && list != NULL; list = list->next) {
2924 Folder *folder = list->data;
2926 found = !procmsg_queue_is_empty(folder->queue);
2928 /* if necessary, ask for confirmation before sending */
2929 if (found && !prefs_common.work_offline) {
2930 if (alertpanel(_("Send queued messages"),
2931 _("Send all queued messages?"),
2932 GTK_STOCK_CANCEL, _("_Send"),
2933 NULL) != G_ALERTALTERNATE)
2938 for (list = folder_get_list(); list != NULL; list = list->next) {
2939 Folder *folder = list->data;
2941 if (folder->queue) {
2942 if (procmsg_send_queue(folder->queue,
2943 prefs_common.savemsg,
2950 alertpanel_error_log(_("Some errors occurred while "
2951 "sending queued messages."));
2953 alertpanel_error_log(_("Some errors occurred "
2954 "while sending queued messages:\n%s"), errstr);
2960 void compose_mail_cb(gpointer data, guint action, GtkWidget *widget)
2962 MainWindow *mainwin = (MainWindow*)data;
2963 PrefsAccount *ac = NULL;
2964 FolderItem *item = mainwin->summaryview->folder_item;
2969 ac = account_find_from_item(item);
2970 if (ac && ac->protocol != A_NNTP && ac->protocol != A_IMAP4) {
2971 compose_new_with_folderitem(ac, item, NULL); /* CLAWS */
2977 * CLAWS - use current account
2979 if (cur_account && (cur_account->protocol != A_NNTP)) {
2980 compose_new_with_folderitem(cur_account, item, NULL);
2985 * CLAWS - just get the first one
2987 list = account_get_list();
2988 for (cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2989 ac = (PrefsAccount *) cur->data;
2990 if (ac->protocol != A_NNTP) {
2991 compose_new_with_folderitem(ac, item, NULL);
2997 void compose_news_cb(gpointer data, guint action, GtkWidget *widget)
2999 MainWindow *mainwin = (MainWindow*)data;
3000 PrefsAccount * ac = NULL;
3004 if (mainwin->summaryview->folder_item) {
3005 ac = mainwin->summaryview->folder_item->folder->account;
3006 if (ac && ac->protocol == A_NNTP) {
3007 compose_new_with_folderitem(ac,
3008 mainwin->summaryview->folder_item, NULL);
3013 list = account_get_list();
3014 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
3015 ac = (PrefsAccount *) cur->data;
3016 if (ac->protocol == A_NNTP) {
3017 compose_new_with_folderitem(ac,
3018 mainwin->summaryview->folder_item, NULL);