2 * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2001-2017 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/>.
20 * General functions for accessing address book files.
25 #include "claws-features.h"
31 #include <glib/gi18n.h>
40 #include "mainwindow.h"
41 #include "summaryview.h"
46 #include "prefs_gtk.h"
48 #include "stock_pixmap.h"
49 #include "manage_window.h"
55 #include "prefs_actions.h"
56 #include "prefs_common.h"
57 #include "prefs_toolbar.h"
58 #include "alertpanel.h"
61 #include "send_message.h"
62 #ifndef USE_ALT_ADDRBOOK
63 #include "addressbook.h"
65 #include "addressbook-dbus.h"
69 #define TOOLBAR_TAG_INDEX "toolbar"
70 #define TOOLBAR_TAG_ITEM "item"
71 #define TOOLBAR_TAG_SEPARATOR "separator"
73 #define TOOLBAR_ICON_FILE "file"
74 #define TOOLBAR_ICON_TEXT "text"
75 #define TOOLBAR_ICON_ACTION "action"
77 static void toolbar_init(Toolbar * toolbar);
78 static gboolean toolbar_is_duplicate (gint action,
80 static void toolbar_parse_item (XMLFile *file,
81 ToolbarType source, gboolean *rewrite);
83 static gint toolbar_ret_val_from_text (const gchar *text);
84 static gchar *toolbar_ret_text_from_val (gint val);
86 typedef struct _DefaultToolbar DefaultToolbar;
87 struct _DefaultToolbar {
90 static void toolbar_set_default_generic(ToolbarType toolbar_type,
91 DefaultToolbar *default_toolbar);
93 static void toolbar_style (ToolbarType type,
97 static MainWindow *get_mainwin (gpointer data);
98 static void activate_compose_button (Toolbar *toolbar,
100 ComposeButtonType type);
102 /* toolbar callbacks */
103 static void toolbar_reply (gpointer data,
106 static void toolbar_learn (gpointer data,
109 static void toolbar_delete_dup (gpointer data,
112 static void toolbar_trash_cb (GtkWidget *widget,
115 static void toolbar_delete_cb (GtkWidget *widget,
118 static void toolbar_delete_dup_cb (GtkWidget *widget,
122 static void toolbar_compose_cb (GtkWidget *widget,
125 static void toolbar_learn_cb (GtkWidget *widget,
128 static void toolbar_reply_cb (GtkWidget *widget,
131 static void toolbar_reply_to_all_cb (GtkWidget *widget,
134 static void toolbar_reply_to_list_cb (GtkWidget *widget,
137 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
140 static void toolbar_forward_cb (GtkWidget *widget,
143 static void toolbar_prev_unread_cb (GtkWidget *widget,
145 static void toolbar_next_unread_cb (GtkWidget *widget,
148 static void toolbar_ignore_thread_cb (GtkWidget *widget,
151 static void toolbar_watch_thread_cb (GtkWidget *widget,
154 static void toolbar_mark_cb (GtkWidget *widget,
157 static void toolbar_unmark_cb (GtkWidget *widget,
160 static void toolbar_lock_cb (GtkWidget *widget,
163 static void toolbar_ulock_cb (GtkWidget *widget,
166 static void toolbar_all_read_cb (GtkWidget *widget,
169 static void toolbar_all_unread_cb (GtkWidget *widget,
172 static void toolbar_read_cb (GtkWidget *widget,
175 static void toolbar_unread_cb (GtkWidget *widget,
178 static void toolbar_print_cb (GtkWidget *widget,
181 static void toolbar_actions_execute_cb (GtkWidget *widget,
183 static void toolbar_plugins_execute_cb (GtkWidget *widget,
187 static void toolbar_send_cb (GtkWidget *widget,
189 static void toolbar_send_later_cb (GtkWidget *widget,
191 static void toolbar_draft_cb (GtkWidget *widget,
193 static void toolbar_close_cb (GtkWidget *widget,
195 static void toolbar_preferences_cb (GtkWidget *widget,
197 static void toolbar_open_mail_cb (GtkWidget *widget,
199 static void toolbar_insert_cb (GtkWidget *widget,
201 static void toolbar_attach_cb (GtkWidget *widget,
203 static void toolbar_sig_cb (GtkWidget *widget,
205 static void toolbar_ext_editor_cb (GtkWidget *widget,
207 static void toolbar_linewrap_current_cb (GtkWidget *widget,
209 static void toolbar_linewrap_all_cb (GtkWidget *widget,
211 static void toolbar_addrbook_cb (GtkWidget *widget,
214 static void toolbar_check_spelling_cb (GtkWidget *widget,
217 static void toolbar_cancel_inc_cb (GtkWidget *widget,
219 static void toolbar_cancel_send_cb (GtkWidget *widget,
221 static void toolbar_cancel_all_cb (GtkWidget *widget,
227 } toolbar_text [] = {
228 { "A_RECEIVE_ALL", N_("Receive Mail from all Accounts") },
229 { "A_RECEIVE_CUR", N_("Receive Mail from current Account") },
230 { "A_SEND_QUEUED", N_("Send Queued Messages") },
231 { "A_COMPOSE_EMAIL", N_("Compose Email") },
232 { "A_COMPOSE_NEWS", N_("Compose News") },
233 { "A_REPLY_MESSAGE", N_("Reply to Message") },
234 { "A_REPLY_SENDER", N_("Reply to Sender") },
235 { "A_REPLY_ALL", N_("Reply to All") },
236 { "A_REPLY_ML", N_("Reply to Mailing-list") },
237 { "A_OPEN_MAIL", N_("Open email") },
238 { "A_FORWARD", N_("Forward Message") },
239 { "A_TRASH", N_("Trash Message") },
240 { "A_DELETE_REAL", N_("Delete Message") },
241 { "A_DELETE_DUP", N_("Delete duplicate messages") },
242 { "A_EXECUTE", N_("Execute") },
243 { "A_GOTO_PREV", N_("Go to Previous Unread Message") },
244 { "A_GOTO_NEXT", N_("Go to Next Unread Message") },
246 { "A_IGNORE_THREAD", N_("Ignore thread") },
247 { "A_WATCH_THREAD", N_("Watch thread") },
248 { "A_MARK", N_("Mark Message") },
249 { "A_UNMARK", N_("Unmark Message") },
250 { "A_LOCK", N_("Lock Message") },
251 { "A_UNLOCK", N_("Unlock Message") },
252 { "A_ALL_READ", N_("Mark all Messages as read") },
253 { "A_ALL_UNREAD", N_("Mark all Messages as unread") },
254 { "A_READ", N_("Mark Message as read") },
255 { "A_UNREAD", N_("Mark Message as unread") },
257 { "A_PRINT", N_("Print") },
258 { "A_LEARN_SPAM", N_("Learn Spam or Ham") },
259 { "A_GO_FOLDERS", N_("Open folder/Go to folder list") },
260 { "A_PREFERENCES", N_("Preferences") },
262 { "A_SEND", N_("Send Message") },
263 { "A_SEND_LATER", N_("Put into queue folder and send later") },
264 { "A_DRAFT", N_("Save to draft folder") },
265 { "A_INSERT", N_("Insert file") },
266 { "A_ATTACH", N_("Attach file") },
267 { "A_SIG", N_("Insert signature") },
268 { "A_REP_SIG", N_("Replace signature") },
269 { "A_EXTEDITOR", N_("Edit with external editor") },
270 { "A_LINEWRAP_CURRENT", N_("Wrap long lines of current paragraph") },
271 { "A_LINEWRAP_ALL", N_("Wrap all long lines") },
272 { "A_ADDRBOOK", N_("Address book") },
274 { "A_CHECK_SPELLING", N_("Check spelling") },
276 { "A_CLAWS_ACTIONS", N_("Claws Mail Actions Feature") },
277 { "A_CANCEL_INC", N_("Cancel receiving") },
278 { "A_CANCEL_SEND", N_("Cancel sending") },
279 { "A_CANCEL_ALL", N_("Cancel receiving/sending") },
280 { "A_CLOSE", N_("Close window") },
281 { "A_SEPARATOR", N_("Separator") },
282 { "A_CLAWS_PLUGINS", N_("Claws Mail Plugins") }
285 /* migration table: support reading toolbar configuration files with
286 old action names and converting them to current action names,
287 see toolbar_parse_item(), which makes uses of this alias table.
290 const gchar *old_name;
291 const gchar *current_name;
292 } toolbar_migration [] = {
293 { "A_SYL_ACTIONS", "A_CLAWS_ACTIONS" },
294 { "A_SENDL", "A_SEND_LATER" },
298 /* struct holds configuration files and a list of
299 * currently active toolbar items
300 * TOOLBAR_MAIN, TOOLBAR_COMPOSE and TOOLBAR_MSGVIEW
304 const gchar *conf_file;
306 } toolbar_config[NUM_TOOLBARS] = {
307 { "toolbar_main.xml", NULL},
308 { "toolbar_compose.xml", NULL},
309 { "toolbar_msgview.xml", NULL}
312 gint toolbar_ret_val_from_descr(const gchar *descr)
316 for (i = 0; i < N_ACTION_VAL; i++) {
317 if (g_utf8_collate(gettext(toolbar_text[i].descr), descr) == 0)
324 gchar *toolbar_ret_descr_from_val(gint val)
326 cm_return_val_if_fail(val >=0 && val < N_ACTION_VAL, NULL);
328 return gettext(toolbar_text[val].descr);
331 static gint toolbar_ret_val_from_text(const gchar *text)
335 for (i = 0; i < N_ACTION_VAL; i++) {
336 if (g_utf8_collate(toolbar_text[i].index_str, text) == 0)
343 static gchar *toolbar_ret_text_from_val(gint val)
345 cm_return_val_if_fail(val >=0 && val < N_ACTION_VAL, NULL);
347 return toolbar_text[val].index_str;
350 static gboolean toolbar_is_duplicate(gint action, ToolbarType source)
354 if ((action == A_SEPARATOR) || (action == A_CLAWS_ACTIONS) || (action == A_CLAWS_PLUGINS))
357 for (cur = toolbar_config[source].item_list; cur != NULL; cur = cur->next) {
358 ToolbarItem *item = (ToolbarItem*) cur->data;
360 if (item->index == action)
366 /* depending on toolbar type this function
367 returns a list of available toolbar events being
368 displayed by prefs_toolbar
370 GList *toolbar_get_action_items(ToolbarType source)
375 if (source == TOOLBAR_MAIN) {
376 gint main_items[] = {
377 A_RECEIVE_ALL, A_RECEIVE_CUR, A_SEND_QUEUED,
378 A_COMPOSE_EMAIL, A_REPLY_MESSAGE, A_REPLY_SENDER,
379 A_REPLY_ALL, A_REPLY_ML, A_OPEN_MAIL, A_FORWARD,
380 A_TRASH, A_DELETE_REAL, A_DELETE_DUP, A_EXECUTE,
381 A_GOTO_PREV, A_GOTO_NEXT, A_IGNORE_THREAD, A_WATCH_THREAD,
382 A_MARK, A_UNMARK, A_LOCK, A_UNLOCK,
383 A_ALL_READ, A_ALL_UNREAD, A_READ, A_UNREAD,
384 A_PRINT, A_ADDRBOOK, A_LEARN_SPAM, A_GO_FOLDERS,
385 A_CANCEL_INC, A_CANCEL_SEND, A_CANCEL_ALL, A_PREFERENCES };
387 for (i = 0; i < sizeof main_items / sizeof main_items[0]; i++) {
388 items = g_list_append(items, gettext(toolbar_text[main_items[i]].descr));
391 else if (source == TOOLBAR_COMPOSE) {
392 gint comp_items[] = {
393 A_SEND, A_SEND_LATER, A_DRAFT,
394 A_INSERT, A_ATTACH, A_SIG,
395 A_REP_SIG, A_EXTEDITOR, A_LINEWRAP_CURRENT,
396 A_LINEWRAP_ALL, A_ADDRBOOK,
402 for (i = 0; i < sizeof comp_items / sizeof comp_items[0]; i++)
403 items = g_list_append(items, gettext(toolbar_text[comp_items[i]].descr));
405 else if (source == TOOLBAR_MSGVIEW) {
406 gint msgv_items[] = {
407 A_COMPOSE_EMAIL, A_REPLY_MESSAGE, A_REPLY_SENDER,
408 A_REPLY_ALL, A_REPLY_ML, A_FORWARD,
409 A_TRASH, A_DELETE_REAL, A_GOTO_PREV, A_GOTO_NEXT,
410 A_ADDRBOOK, A_LEARN_SPAM, A_CLOSE };
412 for (i = 0; i < sizeof msgv_items / sizeof msgv_items[0]; i++)
413 items = g_list_append(items, gettext(toolbar_text[msgv_items[i]].descr));
419 static void toolbar_parse_item(XMLFile *file, ToolbarType source, gboolean *rewrite)
423 ToolbarItem *item = NULL;
425 g_return_if_fail(rewrite != NULL);
427 attr = xml_get_current_tag_attr(file);
428 item = g_new0(ToolbarItem, 1);
430 name = ((XMLAttr *)attr->data)->name;
431 value = ((XMLAttr *)attr->data)->value;
433 if (g_utf8_collate(name, TOOLBAR_ICON_FILE) == 0)
434 item->file = g_strdup (value);
435 else if (g_utf8_collate(name, TOOLBAR_ICON_TEXT) == 0)
436 item->text = g_strdup (*value ? gettext(value):"");
437 else if (g_utf8_collate(name, TOOLBAR_ICON_ACTION) == 0)
438 item->index = toolbar_ret_val_from_text(value);
440 if ((item->index == -1) && !strcmp(value, "A_DELETE")) {
442 item->index = A_TRASH;
444 item->file = g_strdup("trash_btn");
446 item->text = g_strdup(C_("Toolbar", "Trash"));
449 if (!strcmp(item->file, "mail") && !strcmp(value, "A_DRAFT")) {
450 /* switch icon file */
452 item->file = g_strdup("mail_draft");
455 if (item->index == -1) {
456 /* item not found in table: try migrating old action names to current ones */
459 /* replace action name */
460 for (i = 0; toolbar_migration[i].old_name != NULL; i++) {
461 if (g_utf8_collate(value, toolbar_migration[i].old_name) == 0) {
462 item->index = toolbar_ret_val_from_text(toolbar_migration[i].current_name);
463 if (item->index != -1) {
465 debug_print("toolbar_parse_item: migrating action label from '%s' to '%s'\n",
466 value, toolbar_migration[i].current_name);
472 if ((item->index == -1) && !rewrite)
473 g_warning("toolbar_parse_item: unrecognized action name '%s'\n", value);
475 attr = g_list_next(attr);
477 if (item->index != -1) {
478 if (!toolbar_is_duplicate(item->index, source))
479 toolbar_config[source].item_list = g_slist_append(toolbar_config[source].item_list,
484 const gchar *toolbar_get_short_text(int action) {
486 case A_RECEIVE_ALL: return _("Get Mail");
487 case A_RECEIVE_CUR: return _("Get");
488 case A_SEND_QUEUED: return _("Send");
489 case A_COMPOSE_EMAIL: return C_("Toolbar", "Compose");
490 case A_COMPOSE_NEWS: return C_("Toolbar", "Compose");
491 case A_REPLY_MESSAGE: return _("Reply");
492 case A_REPLY_SENDER: return C_("Toolbar", "Sender");
493 case A_REPLY_ALL: return _("All");
494 case A_REPLY_ML: return _("List");
495 case A_OPEN_MAIL: return _("Open");
496 case A_FORWARD: return _("Forward");
497 case A_TRASH: return C_("Toolbar", "Trash");
498 case A_DELETE_REAL: return _("Delete");
499 case A_DELETE_DUP: return _("Delete duplicates");
500 case A_EXECUTE: return _("Execute");
501 case A_GOTO_PREV: return _("Prev");
502 case A_GOTO_NEXT: return _("Next");
504 case A_IGNORE_THREAD: return _("Ignore thread");
505 case A_WATCH_THREAD: return _("Watch thread");
506 case A_MARK: return _("Mark");
507 case A_UNMARK: return _("Unmark");
508 case A_LOCK: return _("Lock");
509 case A_UNLOCK: return _("Unlock");
510 case A_ALL_READ: return _("All read");
511 case A_ALL_UNREAD: return _("All unread");
512 case A_READ: return _("Read");
513 case A_UNREAD: return _("Unread");
515 case A_PRINT: return _("Print");
516 case A_LEARN_SPAM: return _("Spam");
517 case A_GO_FOLDERS: return _("Folders");
518 case A_PREFERENCES: return _("Preferences");
520 case A_SEND: return _("Send");
521 case A_SEND_LATER: return _("Send later");
522 case A_DRAFT: return _("Draft");
523 case A_INSERT: return _("Insert");
524 case A_ATTACH: return _("Attach");
525 case A_SIG: return _("Insert sig.");
526 case A_REP_SIG: return _("Replace sig.");
527 case A_EXTEDITOR: return _("Edit");
528 case A_LINEWRAP_CURRENT:return _("Wrap para.");
529 case A_LINEWRAP_ALL: return _("Wrap all");
530 case A_ADDRBOOK: return _("Address");
532 case A_CHECK_SPELLING: return _("Check spelling");
535 case A_CANCEL_INC: return _("Stop");
536 case A_CANCEL_SEND: return _("Stop");
537 case A_CANCEL_ALL: return _("Stop all");
538 case A_CLOSE: return _("Close");
543 gint toolbar_get_icon(int action) {
545 case A_RECEIVE_ALL: return STOCK_PIXMAP_MAIL_RECEIVE_ALL;
546 case A_RECEIVE_CUR: return STOCK_PIXMAP_MAIL_RECEIVE;
547 case A_SEND_QUEUED: return STOCK_PIXMAP_MAIL_SEND_QUEUE;
548 case A_COMPOSE_EMAIL: return STOCK_PIXMAP_MAIL_COMPOSE;
549 case A_COMPOSE_NEWS: return STOCK_PIXMAP_NEWS_COMPOSE;
550 case A_REPLY_MESSAGE: return STOCK_PIXMAP_MAIL_REPLY;
551 case A_REPLY_SENDER: return STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR;
552 case A_REPLY_ALL: return STOCK_PIXMAP_MAIL_REPLY_TO_ALL;
553 case A_REPLY_ML: return STOCK_PIXMAP_MAIL_REPLY_TO_LIST;
554 case A_OPEN_MAIL: return STOCK_PIXMAP_OPEN_MAIL;
555 case A_FORWARD: return STOCK_PIXMAP_MAIL_FORWARD;
556 case A_TRASH: return STOCK_PIXMAP_TRASH;
557 case A_DELETE_REAL: return STOCK_PIXMAP_DELETE;
558 case A_DELETE_DUP: return STOCK_PIXMAP_DELETE_DUP;
559 case A_EXECUTE: return STOCK_PIXMAP_EXEC;
560 case A_GOTO_PREV: return STOCK_PIXMAP_UP_ARROW;
561 case A_GOTO_NEXT: return STOCK_PIXMAP_DOWN_ARROW;
563 case A_IGNORE_THREAD: return STOCK_PIXMAP_MARK_IGNORETHREAD;
564 case A_WATCH_THREAD: return STOCK_PIXMAP_MARK_WATCHTHREAD;
565 case A_MARK: return STOCK_PIXMAP_MARK_MARK;
566 case A_UNMARK: return STOCK_PIXMAP_MARK_UNMARK;
567 case A_LOCK: return STOCK_PIXMAP_MARK_LOCKED;
568 case A_UNLOCK: return STOCK_PIXMAP_MARK_UNLOCKED;
569 case A_ALL_READ: return STOCK_PIXMAP_MARK_ALLREAD;
570 case A_ALL_UNREAD: return STOCK_PIXMAP_MARK_ALLUNREAD;
571 case A_READ: return STOCK_PIXMAP_MARK_READ;
572 case A_UNREAD: return STOCK_PIXMAP_MARK_UNREAD;
574 case A_PRINT: return STOCK_PIXMAP_PRINTER;
575 case A_LEARN_SPAM: return STOCK_PIXMAP_SPAM_BTN;
576 case A_GO_FOLDERS: return STOCK_PIXMAP_GO_FOLDERS;
577 case A_PREFERENCES: return STOCK_PIXMAP_PREFERENCES;
579 case A_SEND: return STOCK_PIXMAP_MAIL_SEND;
580 case A_SEND_LATER: return STOCK_PIXMAP_MAIL_SEND_QUEUE;
581 case A_DRAFT: return STOCK_PIXMAP_MAIL_DRAFT;
582 case A_INSERT: return STOCK_PIXMAP_INSERT_FILE;
583 case A_ATTACH: return STOCK_PIXMAP_MAIL_ATTACH;
584 case A_SIG: return STOCK_PIXMAP_MAIL_SIGN;
585 case A_REP_SIG: return STOCK_PIXMAP_MAIL_SIGN;
586 case A_EXTEDITOR: return STOCK_PIXMAP_EDIT_EXTERN;
587 case A_LINEWRAP_CURRENT:return STOCK_PIXMAP_LINEWRAP_CURRENT;
588 case A_LINEWRAP_ALL: return STOCK_PIXMAP_LINEWRAP_ALL;
589 case A_ADDRBOOK: return STOCK_PIXMAP_ADDRESS_BOOK;
591 case A_CHECK_SPELLING: return STOCK_PIXMAP_CHECK_SPELLING;
594 case A_CANCEL_INC: return STOCK_PIXMAP_CANCEL;
595 case A_CANCEL_SEND: return STOCK_PIXMAP_CANCEL;
596 case A_CANCEL_ALL: return STOCK_PIXMAP_CANCEL;
597 case A_CLOSE: return STOCK_PIXMAP_CLOSE;
602 static void toolbar_set_default_generic(ToolbarType toolbar_type, DefaultToolbar *default_toolbar)
606 g_return_if_fail(default_toolbar != NULL);
608 for (i = 0; default_toolbar[i].action != N_ACTION_VAL; i++) {
610 ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
612 if (default_toolbar[i].action != A_SEPARATOR) {
616 icon = toolbar_get_icon(default_toolbar[i].action);
618 file = stock_pixmap_get_name((StockPixmap)icon);
620 toolbar_item->file = g_strdup(file);
621 toolbar_item->index = default_toolbar[i].action;
622 toolbar_item->text = g_strdup(toolbar_get_short_text(default_toolbar[i].action));
624 toolbar_item->file = g_strdup(TOOLBAR_TAG_SEPARATOR);
625 toolbar_item->index = A_SEPARATOR;
628 if (toolbar_item->index != -1) {
629 if (!toolbar_is_duplicate(toolbar_item->index, toolbar_type))
630 toolbar_config[toolbar_type].item_list =
631 g_slist_append(toolbar_config[toolbar_type].item_list, toolbar_item);
636 void toolbar_set_default(ToolbarType source)
638 DefaultToolbar default_toolbar_main[] = {
664 DefaultToolbar default_toolbar_compose[] = {
682 DefaultToolbar default_toolbar_msgview[] = {
700 if (source == TOOLBAR_MAIN)
701 toolbar_set_default_generic(TOOLBAR_MAIN, default_toolbar_main);
702 else if (source == TOOLBAR_COMPOSE)
703 toolbar_set_default_generic(TOOLBAR_COMPOSE, default_toolbar_compose);
704 else if (source == TOOLBAR_MSGVIEW)
705 toolbar_set_default_generic(TOOLBAR_MSGVIEW, default_toolbar_msgview);
708 void toolbar_save_config_file(ToolbarType source)
713 gchar *fileSpec = NULL;
715 debug_print("save Toolbar Configuration to %s\n", toolbar_config[source].conf_file);
717 fileSpec = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, toolbar_config[source].conf_file, NULL );
718 pfile = prefs_write_open(fileSpec);
721 if (fprintf(fp, "<?xml version=\"1.0\" encoding=\"%s\" ?>\n", CS_INTERNAL) < 0)
724 if (fprintf(fp, "<%s>\n", TOOLBAR_TAG_INDEX) < 0)
727 for (cur = toolbar_config[source].item_list; cur != NULL; cur = cur->next) {
728 ToolbarItem *toolbar_item = (ToolbarItem*) cur->data;
730 if (toolbar_item->index != A_SEPARATOR) {
731 if (fprintf(fp, "\t<%s %s=\"%s\" %s=\"",
733 TOOLBAR_ICON_FILE, toolbar_item->file,
734 TOOLBAR_ICON_TEXT) < 0)
736 if (xml_file_put_escape_str(fp, toolbar_item->text) < 0)
738 if (fprintf(fp, "\" %s=\"%s\"/>\n",
740 toolbar_ret_text_from_val(toolbar_item->index)) < 0)
743 if (fprintf(fp, "\t<%s/>\n", TOOLBAR_TAG_SEPARATOR) < 0)
748 if (fprintf(fp, "</%s>\n", TOOLBAR_TAG_INDEX) < 0)
752 if (prefs_file_close (pfile) < 0 )
753 g_warning("failed to write toolbar configuration to file");
757 FILE_OP_ERROR(fileSpec, "fprintf");
759 prefs_file_close_revert (pfile);
761 g_warning("failed to open toolbar configuration file for writing");
764 void toolbar_read_config_file(ToolbarType source)
766 XMLFile *file = NULL;
767 gchar *fileSpec = NULL;
769 gboolean rewrite = FALSE;
771 debug_print("read Toolbar Configuration from %s\n", toolbar_config[source].conf_file);
773 fileSpec = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, toolbar_config[source].conf_file, NULL );
774 file = xml_open_file(fileSpec);
777 toolbar_clear_list(source);
781 || (xml_get_dtd(file))
782 || (xml_parse_next_tag(file))
783 || (!xml_compare_tag(file, TOOLBAR_TAG_INDEX))) {
784 xml_close_file(file);
792 if (xml_parse_next_tag(file))
795 /* Get next tag (icon, icon_text or icon_action) */
796 if (xml_compare_tag(file, TOOLBAR_TAG_ITEM)) {
797 toolbar_parse_item(file, source, &rewrite);
798 } else if (xml_compare_tag(file, TOOLBAR_TAG_SEPARATOR)) {
799 ToolbarItem *item = g_new0(ToolbarItem, 1);
801 item->file = g_strdup(TOOLBAR_TAG_SEPARATOR);
802 item->index = A_SEPARATOR;
803 toolbar_config[source].item_list =
804 g_slist_append(toolbar_config[source].item_list, item);
808 xml_close_file(file);
810 debug_print("toolbar_read_config_file: rewriting toolbar\n");
811 toolbar_save_config_file(source);
815 if ((!file) || (g_slist_length(toolbar_config[source].item_list) == 0)) {
817 if (source == TOOLBAR_MAIN)
818 toolbar_set_default(TOOLBAR_MAIN);
819 else if (source == TOOLBAR_COMPOSE)
820 toolbar_set_default(TOOLBAR_COMPOSE);
821 else if (source == TOOLBAR_MSGVIEW)
822 toolbar_set_default(TOOLBAR_MSGVIEW);
824 g_warning("refusing to write unknown Toolbar Configuration number %d", source);
828 toolbar_save_config_file(source);
833 * clears list of toolbar items read from configuration files
835 void toolbar_clear_list(ToolbarType source)
837 while (toolbar_config[source].item_list != NULL) {
838 ToolbarItem *item = (ToolbarItem*) toolbar_config[source].item_list->data;
840 toolbar_config[source].item_list =
841 g_slist_remove(toolbar_config[source].item_list, item);
847 g_slist_free(toolbar_config[source].item_list);
852 * return list of Toolbar items
854 GSList *toolbar_get_list(ToolbarType source)
858 if ((source == TOOLBAR_MAIN) || (source == TOOLBAR_COMPOSE) || (source == TOOLBAR_MSGVIEW))
859 list = toolbar_config[source].item_list;
864 void toolbar_set_list_item(ToolbarItem *t_item, ToolbarType source)
866 ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
868 toolbar_item->file = g_strdup(t_item->file);
869 toolbar_item->text = g_strdup(t_item->text);
870 toolbar_item->index = t_item->index;
872 toolbar_config[source].item_list =
873 g_slist_append(toolbar_config[source].item_list,
877 static void toolbar_action_execute(GtkWidget *widget,
885 for (cur = action_list; cur != NULL; cur = cur->next) {
886 ToolbarClawsActions *act = (ToolbarClawsActions*)cur->data;
888 if (widget == act->widget) {
889 i = prefs_actions_find_by_name(act->name);
897 actions_execute(data, i, widget, source);
899 g_warning ("Error: did not find Claws Action to execute");
902 gboolean toolbar_check_action_btns(ToolbarType type)
904 GSList *temp, *curr, *list = toolbar_config[type].item_list;
905 gboolean modified = FALSE;
908 while (curr != NULL) {
909 ToolbarItem *toolbar_item = (ToolbarItem *) curr->data;
913 if (toolbar_item->index != A_CLAWS_ACTIONS)
916 if (prefs_actions_find_by_name(toolbar_item->text) == -1) {
917 list = g_slist_delete_link(list, temp);
918 g_free(toolbar_item->file);
919 g_free(toolbar_item->text);
920 g_free(toolbar_item);
928 #define CLAWS_SET_TOOL_ITEM_TIP(widget,tip) { \
929 gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), tip); \
932 #define CLAWS_SET_ARROW_TIP(widget,tip) { \
933 gtk_menu_tool_button_set_arrow_tooltip_text(GTK_MENU_TOOL_BUTTON(widget), tip); \
936 static void activate_compose_button (Toolbar *toolbar,
938 ComposeButtonType type)
940 if ((!toolbar->compose_mail_btn))
943 if (type == COMPOSEBUTTON_NEWS) {
944 gtk_tool_button_set_icon_widget(
945 GTK_TOOL_BUTTON(toolbar->compose_mail_btn),
946 toolbar->compose_news_icon);
948 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(toolbar->compose_mail_btn), _("Compose News message"));
950 gtk_widget_show(toolbar->compose_news_icon);
952 gtk_tool_button_set_icon_widget(
953 GTK_TOOL_BUTTON(toolbar->compose_mail_btn),
954 toolbar->compose_mail_icon);
956 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(toolbar->compose_mail_btn), _("Compose Email"));
958 gtk_widget_show(toolbar->compose_mail_icon);
960 toolbar->compose_btn_type = type;
963 void toolbar_set_compose_button(Toolbar *toolbar,
964 ComposeButtonType compose_btn_type)
966 if (toolbar->compose_btn_type != compose_btn_type)
967 activate_compose_button(toolbar,
968 prefs_common.toolbar_style,
972 static void activate_learn_button (Toolbar *toolbar,
974 LearnButtonType type)
976 if ((!toolbar->learn_spam_btn))
979 if (type == LEARN_SPAM) {
980 gtk_tool_button_set_icon_widget(
981 GTK_TOOL_BUTTON(toolbar->learn_spam_btn),
982 toolbar->learn_spam_icon);
983 gtk_tool_button_set_label(
984 GTK_TOOL_BUTTON(toolbar->learn_spam_btn),
987 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(toolbar->learn_spam_btn), _("Learn spam"));
989 gtk_widget_show(toolbar->learn_spam_icon);
991 gtk_tool_button_set_icon_widget(
992 GTK_TOOL_BUTTON(toolbar->learn_spam_btn),
993 toolbar->learn_ham_icon);
994 gtk_tool_button_set_label(
995 GTK_TOOL_BUTTON(toolbar->learn_spam_btn),
998 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(toolbar->learn_spam_btn), _("Learn ham"));
1000 gtk_widget_show(toolbar->learn_ham_icon);
1002 toolbar->learn_btn_type = type;
1005 void toolbar_set_learn_button(Toolbar *toolbar,
1006 LearnButtonType learn_btn_type)
1008 if (toolbar->learn_btn_type != learn_btn_type)
1009 activate_learn_button(toolbar,
1010 prefs_common.toolbar_style,
1014 void toolbar_toggle(guint action, gpointer data)
1016 MainWindow *mainwin = (MainWindow*)data;
1020 cm_return_if_fail(mainwin != NULL);
1022 toolbar_style(TOOLBAR_MAIN, action, mainwin);
1024 list = compose_get_compose_list();
1025 for (cur = list; cur != NULL; cur = cur->next) {
1026 toolbar_style(TOOLBAR_COMPOSE, action, cur->data);
1028 list = messageview_get_msgview_list();
1029 for (cur = list; cur != NULL; cur = cur->next) {
1030 toolbar_style(TOOLBAR_MSGVIEW, action, cur->data);
1035 void toolbar_set_style(GtkWidget *toolbar_wid, GtkWidget *handlebox_wid, guint action)
1037 switch ((ToolbarStyle)action) {
1039 gtk_widget_hide(handlebox_wid);
1042 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
1046 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
1050 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
1053 case TOOLBAR_BOTH_HORIZ:
1054 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
1055 GTK_TOOLBAR_BOTH_HORIZ);
1061 prefs_common.toolbar_style = (ToolbarStyle)action;
1062 gtk_widget_set_size_request(handlebox_wid, 1, -1);
1064 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
1065 gtk_widget_show(handlebox_wid);
1066 gtk_widget_queue_resize(handlebox_wid);
1070 * Change the style of toolbar
1072 static void toolbar_style(ToolbarType type, guint action, gpointer data)
1074 GtkWidget *handlebox_wid;
1075 GtkWidget *toolbar_wid;
1076 MainWindow *mainwin = (MainWindow*)data;
1077 Compose *compose = (Compose*)data;
1078 MessageView *msgview = (MessageView*)data;
1080 cm_return_if_fail(data != NULL);
1084 handlebox_wid = mainwin->handlebox;
1085 toolbar_wid = mainwin->toolbar->toolbar;
1087 case TOOLBAR_COMPOSE:
1088 handlebox_wid = compose->handlebox;
1089 toolbar_wid = compose->toolbar->toolbar;
1091 case TOOLBAR_MSGVIEW:
1092 handlebox_wid = msgview->handlebox;
1093 toolbar_wid = msgview->toolbar->toolbar;
1099 toolbar_set_style(toolbar_wid, handlebox_wid, action);
1102 /* Toolbar handling */
1103 static void toolbar_inc_cb(GtkWidget *widget,
1106 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1107 MainWindow *mainwin;
1109 cm_return_if_fail(toolbar_item != NULL);
1111 switch (toolbar_item->type) {
1113 mainwin = (MainWindow*)toolbar_item->parent;
1114 inc_mail_cb(mainwin, 0, NULL);
1121 static void toolbar_inc_all_cb(GtkWidget *widget,
1124 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1125 MainWindow *mainwin;
1127 cm_return_if_fail(toolbar_item != NULL);
1129 switch (toolbar_item->type) {
1131 mainwin = (MainWindow*)toolbar_item->parent;
1132 inc_all_account_mail_cb(mainwin, 0, NULL);
1139 static void toolbar_send_queued_cb(GtkWidget *widget,gpointer data)
1141 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1142 MainWindow *mainwin;
1144 cm_return_if_fail(toolbar_item != NULL);
1146 switch (toolbar_item->type) {
1148 mainwin = (MainWindow*)toolbar_item->parent;
1149 send_queue_cb(mainwin, 0, NULL);
1156 static void toolbar_exec_cb(GtkWidget *widget,
1159 MainWindow *mainwin = get_mainwin(data);
1161 cm_return_if_fail(mainwin != NULL);
1162 summary_execute(mainwin->summaryview);
1166 * Delete current/selected(s) message(s)
1168 static void toolbar_trash_cb(GtkWidget *widget, gpointer data)
1170 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1171 MainWindow *mainwin;
1173 cm_return_if_fail(toolbar_item != NULL);
1174 cm_return_if_fail(toolbar_item->parent);
1176 switch (toolbar_item->type) {
1177 case TOOLBAR_MSGVIEW:
1178 messageview_delete((MessageView *)toolbar_item->parent);
1181 mainwin = (MainWindow *)toolbar_item->parent;
1182 summary_delete_trash(mainwin->summaryview);
1185 debug_print("toolbar event not supported\n");
1191 * Delete current/selected(s) message(s)
1193 static void toolbar_delete_cb(GtkWidget *widget, gpointer data)
1195 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1196 MainWindow *mainwin;
1198 cm_return_if_fail(toolbar_item != NULL);
1199 cm_return_if_fail(toolbar_item->parent);
1201 switch (toolbar_item->type) {
1202 case TOOLBAR_MSGVIEW:
1203 messageview_delete((MessageView *)toolbar_item->parent);
1206 mainwin = (MainWindow *)toolbar_item->parent;
1207 summary_delete(mainwin->summaryview);
1210 debug_print("toolbar event not supported\n");
1215 static void toolbar_delete_dup(gpointer data, guint all)
1217 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1218 MainWindow *mainwin = NULL;
1220 cm_return_if_fail(toolbar_item != NULL);
1222 switch (toolbar_item->type) {
1224 mainwin = (MainWindow*)toolbar_item->parent;
1226 mainwindow_delete_duplicated_all(mainwin);
1228 mainwindow_delete_duplicated(mainwin);
1230 case TOOLBAR_COMPOSE:
1231 case TOOLBAR_MSGVIEW:
1234 debug_print("toolbar event not supported\n");
1239 static void toolbar_delete_dup_cb(GtkWidget *widget, gpointer data)
1241 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1242 MainWindow *mainwin = NULL;
1244 cm_return_if_fail(toolbar_item != NULL);
1246 switch (toolbar_item->type) {
1248 mainwin = (MainWindow*)toolbar_item->parent;
1249 mainwindow_delete_duplicated(mainwin);
1251 case TOOLBAR_COMPOSE:
1252 case TOOLBAR_MSGVIEW:
1260 * Compose new message
1262 static void toolbar_compose_cb(GtkWidget *widget, gpointer data)
1264 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1265 MainWindow *mainwin;
1266 MessageView *msgview;
1268 cm_return_if_fail(toolbar_item != NULL);
1270 switch (toolbar_item->type) {
1272 mainwin = (MainWindow*)toolbar_item->parent;
1273 if (mainwin->toolbar->compose_btn_type == COMPOSEBUTTON_NEWS)
1274 compose_news_cb(mainwin, 0, NULL);
1276 compose_mail_cb(mainwin, 0, NULL);
1278 case TOOLBAR_MSGVIEW:
1279 msgview = (MessageView*)toolbar_item->parent;
1280 compose_new_with_folderitem(NULL,
1281 msgview->msginfo->folder, NULL);
1284 debug_print("toolbar event not supported\n");
1288 static void toolbar_learn(gpointer data, guint as_spam)
1290 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1291 MainWindow *mainwin;
1292 MessageView *msgview;
1294 cm_return_if_fail(toolbar_item != NULL);
1296 switch (toolbar_item->type) {
1298 mainwin = (MainWindow*)toolbar_item->parent;
1300 mainwindow_learn(mainwin, TRUE);
1302 mainwindow_learn(mainwin, FALSE);
1304 case TOOLBAR_MSGVIEW:
1305 msgview = (MessageView*)toolbar_item->parent;
1307 messageview_learn(msgview, TRUE);
1309 messageview_learn(msgview, FALSE);
1312 debug_print("toolbar event not supported\n");
1316 static void toolbar_learn_cb(GtkWidget *widget, gpointer data)
1318 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1319 MainWindow *mainwin;
1320 MessageView *msgview;
1322 cm_return_if_fail(toolbar_item != NULL);
1324 switch (toolbar_item->type) {
1326 mainwin = (MainWindow*)toolbar_item->parent;
1327 if (mainwin->toolbar->learn_btn_type == LEARN_SPAM)
1328 mainwindow_learn(mainwin, TRUE);
1330 mainwindow_learn(mainwin, FALSE);
1332 case TOOLBAR_MSGVIEW:
1333 msgview = (MessageView*)toolbar_item->parent;
1334 if (msgview->toolbar->learn_btn_type == LEARN_SPAM)
1335 messageview_learn(msgview, TRUE);
1337 messageview_learn(msgview, FALSE);
1340 debug_print("toolbar event not supported\n");
1348 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
1350 toolbar_reply(data, (prefs_common.reply_with_quote ?
1351 COMPOSE_REPLY_WITH_QUOTE : COMPOSE_REPLY_WITHOUT_QUOTE));
1356 * Reply message to Sender and All recipients
1358 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
1361 (prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
1362 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE));
1367 * Reply to Mailing List
1369 static void toolbar_reply_to_list_cb(GtkWidget *widget, gpointer data)
1372 (prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_LIST_WITH_QUOTE
1373 : COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE));
1378 * Reply to sender of message
1380 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
1383 (prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
1384 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE));
1390 static void toolbar_addrbook_cb(GtkWidget *widget, gpointer data)
1392 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1395 cm_return_if_fail(toolbar_item != NULL);
1397 switch (toolbar_item->type) {
1399 case TOOLBAR_MSGVIEW:
1402 case TOOLBAR_COMPOSE:
1403 compose = (Compose *)toolbar_item->parent;
1408 #ifndef USE_ALT_ADDRBOOK
1409 addressbook_open(compose);
1411 GError* error = NULL;
1412 addressbook_connect_signals(compose);
1413 addressbook_dbus_open(TRUE, &error);
1415 g_warning("%s", error->message);
1416 g_error_free(error);
1423 * Forward current/selected(s) message(s)
1425 static void toolbar_forward_cb(GtkWidget *widget, gpointer data)
1427 toolbar_reply(data, (COMPOSE_FORWARD));
1431 * Goto Prev Unread Message
1433 static void toolbar_prev_unread_cb(GtkWidget *widget, gpointer data)
1435 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1436 MainWindow *mainwin;
1437 MessageView *msgview;
1439 cm_return_if_fail(toolbar_item != NULL);
1441 switch (toolbar_item->type) {
1443 mainwin = (MainWindow*)toolbar_item->parent;
1444 summary_select_prev_unread(mainwin->summaryview);
1447 case TOOLBAR_MSGVIEW:
1448 msgview = (MessageView*)toolbar_item->parent;
1449 msgview->updating = TRUE;
1450 summary_select_prev_unread(msgview->mainwin->summaryview);
1451 msgview->updating = FALSE;
1453 if (msgview->deferred_destroy) {
1454 debug_print("messageview got away!\n");
1455 messageview_destroy(msgview);
1459 /* Now we need to update the messageview window */
1460 if (msgview->mainwin->summaryview->selected) {
1461 #ifndef GENERIC_UMPC
1462 MsgInfo * msginfo = summary_get_selected_msg(msgview->mainwin->summaryview);
1465 messageview_show(msgview, msginfo,
1466 msgview->all_headers);
1469 gtk_widget_destroy(msgview->window);
1473 debug_print("toolbar event not supported\n");
1478 * Goto Next Unread Message
1480 static void toolbar_next_unread_cb(GtkWidget *widget, gpointer data)
1482 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1483 MainWindow *mainwin;
1484 MessageView *msgview;
1486 cm_return_if_fail(toolbar_item != NULL);
1488 switch (toolbar_item->type) {
1490 mainwin = (MainWindow*)toolbar_item->parent;
1491 summary_select_next_unread(mainwin->summaryview);
1494 case TOOLBAR_MSGVIEW:
1495 msgview = (MessageView*)toolbar_item->parent;
1496 msgview->updating = TRUE;
1497 summary_select_next_unread(msgview->mainwin->summaryview);
1498 msgview->updating = FALSE;
1500 if (msgview->deferred_destroy) {
1501 debug_print("messageview got away!\n");
1502 messageview_destroy(msgview);
1506 /* Now we need to update the messageview window */
1507 if (msgview->mainwin->summaryview->selected) {
1508 #ifndef GENERIC_UMPC
1509 MsgInfo * msginfo = summary_get_selected_msg(msgview->mainwin->summaryview);
1512 messageview_show(msgview, msginfo,
1513 msgview->all_headers);
1516 gtk_widget_destroy(msgview->window);
1520 debug_print("toolbar event not supported\n");
1524 static void toolbar_ignore_thread_cb(GtkWidget *widget, gpointer data)
1526 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1527 MainWindow *mainwin;
1529 cm_return_if_fail(toolbar_item != NULL);
1531 switch (toolbar_item->type) {
1533 mainwin = (MainWindow *) toolbar_item->parent;
1534 summary_toggle_ignore_thread(mainwin->summaryview);
1536 case TOOLBAR_MSGVIEW:
1537 /* TODO: see toolbar_next_unread_cb() if you need
1538 * this in the message view */
1541 debug_print("toolbar event not supported\n");
1546 static void toolbar_watch_thread_cb(GtkWidget *widget, gpointer data)
1548 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1549 MainWindow *mainwin;
1551 cm_return_if_fail(toolbar_item != NULL);
1553 switch (toolbar_item->type) {
1555 mainwin = (MainWindow *) toolbar_item->parent;
1556 summary_toggle_watch_thread(mainwin->summaryview);
1558 case TOOLBAR_MSGVIEW:
1559 /* TODO: see toolbar_next_unread_cb() if you need
1560 * this in the message view */
1563 debug_print("toolbar event not supported\n");
1568 static void toolbar_mark_cb(GtkWidget *widget, gpointer data)
1570 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1571 MainWindow *mainwin;
1573 cm_return_if_fail(toolbar_item != NULL);
1575 switch (toolbar_item->type) {
1577 mainwin = (MainWindow *) toolbar_item->parent;
1578 summary_mark(mainwin->summaryview);
1580 case TOOLBAR_MSGVIEW:
1581 /* TODO: see toolbar_next_unread_cb() if you need
1582 * this in the message view */
1585 debug_print("toolbar event not supported\n");
1590 static void toolbar_unmark_cb(GtkWidget *widget, gpointer data)
1592 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1593 MainWindow *mainwin;
1595 cm_return_if_fail(toolbar_item != NULL);
1597 switch (toolbar_item->type) {
1599 mainwin = (MainWindow *) toolbar_item->parent;
1600 summary_unmark(mainwin->summaryview);
1602 case TOOLBAR_MSGVIEW:
1603 /* TODO: see toolbar_next_unread_cb() if you need
1604 * this in the message view */
1607 debug_print("toolbar event not supported\n");
1612 static void toolbar_lock_cb(GtkWidget *widget, gpointer data)
1614 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1615 MainWindow *mainwin;
1617 cm_return_if_fail(toolbar_item != NULL);
1619 switch (toolbar_item->type) {
1621 mainwin = (MainWindow *) toolbar_item->parent;
1622 summary_msgs_lock(mainwin->summaryview);
1624 case TOOLBAR_MSGVIEW:
1625 /* TODO: see toolbar_next_unread_cb() if you need
1626 * this in the message view */
1629 debug_print("toolbar event not supported\n");
1634 static void toolbar_unlock_cb(GtkWidget *widget, gpointer data)
1636 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1637 MainWindow *mainwin;
1639 cm_return_if_fail(toolbar_item != NULL);
1641 switch (toolbar_item->type) {
1643 mainwin = (MainWindow *) toolbar_item->parent;
1644 summary_msgs_unlock(mainwin->summaryview);
1646 case TOOLBAR_MSGVIEW:
1647 /* TODO: see toolbar_next_unread_cb() if you need
1648 * this in the message view */
1651 debug_print("toolbar event not supported\n");
1656 static void toolbar_all_read_cb(GtkWidget *widget, gpointer data)
1658 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1659 MainWindow *mainwin;
1661 cm_return_if_fail(toolbar_item != NULL);
1663 switch (toolbar_item->type) {
1665 mainwin = (MainWindow *) toolbar_item->parent;
1666 summary_mark_all_read(mainwin->summaryview, TRUE);
1668 case TOOLBAR_MSGVIEW:
1669 /* TODO: see toolbar_next_unread_cb() if you need
1670 * this in the message view */
1673 debug_print("toolbar event not supported\n");
1678 static void toolbar_all_unread_cb(GtkWidget *widget, gpointer data)
1680 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1681 MainWindow *mainwin;
1683 cm_return_if_fail(toolbar_item != NULL);
1685 switch (toolbar_item->type) {
1687 mainwin = (MainWindow *) toolbar_item->parent;
1688 summary_mark_all_unread(mainwin->summaryview, TRUE);
1690 case TOOLBAR_MSGVIEW:
1691 /* TODO: see toolbar_next_unread_cb() if you need
1692 * this in the message view */
1695 debug_print("toolbar event not supported\n");
1700 static void toolbar_read_cb(GtkWidget *widget, gpointer data)
1702 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1703 MainWindow *mainwin;
1705 cm_return_if_fail(toolbar_item != NULL);
1707 switch (toolbar_item->type) {
1709 mainwin = (MainWindow *) toolbar_item->parent;
1710 summary_mark_as_read(mainwin->summaryview);
1712 case TOOLBAR_MSGVIEW:
1713 /* TODO: see toolbar_next_unread_cb() if you need
1714 * this in the message view */
1717 debug_print("toolbar event not supported\n");
1722 static void toolbar_unread_cb(GtkWidget *widget, gpointer data)
1724 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1725 MainWindow *mainwin;
1727 cm_return_if_fail(toolbar_item != NULL);
1729 switch (toolbar_item->type) {
1731 mainwin = (MainWindow *) toolbar_item->parent;
1732 summary_mark_as_unread(mainwin->summaryview);
1734 case TOOLBAR_MSGVIEW:
1735 /* TODO: see toolbar_next_unread_cb() if you need
1736 * this in the message view */
1739 debug_print("toolbar event not supported\n");
1744 static void toolbar_cancel_inc_cb(GtkWidget *widget, gpointer data)
1746 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1748 cm_return_if_fail(toolbar_item != NULL);
1753 static void toolbar_cancel_send_cb(GtkWidget *widget, gpointer data)
1755 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1757 cm_return_if_fail(toolbar_item != NULL);
1761 static void toolbar_cancel_all_cb(GtkWidget *widget, gpointer data)
1763 toolbar_cancel_inc_cb(widget, data);
1764 toolbar_cancel_send_cb(widget, data);
1767 static void toolbar_print_cb(GtkWidget *widget, gpointer data)
1769 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1770 MainWindow *mainwin;
1772 cm_return_if_fail(toolbar_item != NULL);
1774 switch (toolbar_item->type) {
1776 mainwin = (MainWindow *) toolbar_item->parent;
1777 summary_print(mainwin->summaryview);
1779 case TOOLBAR_MSGVIEW:
1780 /* TODO: see toolbar_next_unread_cb() if you need
1781 * this in the message view */
1784 debug_print("toolbar event not supported\n");
1789 static void toolbar_send_cb(GtkWidget *widget, gpointer data)
1791 compose_toolbar_cb(A_SEND, data);
1794 static void toolbar_send_later_cb(GtkWidget *widget, gpointer data)
1796 compose_toolbar_cb(A_SEND_LATER, data);
1799 static void toolbar_draft_cb(GtkWidget *widget, gpointer data)
1801 compose_toolbar_cb(A_DRAFT, data);
1804 static void toolbar_close_cb(GtkWidget *widget, gpointer data)
1806 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1807 MainWindow *mainwin;
1808 MessageView *messageview;
1811 cm_return_if_fail(toolbar_item != NULL);
1813 switch (toolbar_item->type) {
1815 mainwin = (MainWindow *) toolbar_item->parent;
1816 app_will_exit(NULL, mainwin);
1818 case TOOLBAR_MSGVIEW:
1819 messageview = (MessageView *)toolbar_item->parent;
1820 messageview_destroy(messageview);
1822 case TOOLBAR_COMPOSE:
1823 compose = (Compose *)toolbar_item->parent;
1824 compose_close_toolbar(compose);
1829 static void toolbar_preferences_cb(GtkWidget *widget, gpointer data)
1834 static void toolbar_open_mail_cb(GtkWidget *widget, gpointer data)
1836 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1837 MainWindow *mainwin;
1839 cm_return_if_fail(toolbar_item != NULL);
1841 switch (toolbar_item->type) {
1843 mainwin = (MainWindow *) toolbar_item->parent;
1844 summary_open_row(NULL, mainwin->summaryview);
1846 case TOOLBAR_MSGVIEW:
1847 debug_print("toolbar event not supported\n");
1849 case TOOLBAR_COMPOSE:
1850 debug_print("toolbar event not supported\n");
1855 static void toolbar_insert_cb(GtkWidget *widget, gpointer data)
1857 compose_toolbar_cb(A_INSERT, data);
1860 static void toolbar_attach_cb(GtkWidget *widget, gpointer data)
1862 compose_toolbar_cb(A_ATTACH, data);
1865 static void toolbar_sig_cb(GtkWidget *widget, gpointer data)
1867 compose_toolbar_cb(A_SIG, data);
1870 static void toolbar_replace_sig_cb(GtkWidget *widget, gpointer data)
1872 compose_toolbar_cb(A_REP_SIG, data);
1875 static void toolbar_ext_editor_cb(GtkWidget *widget, gpointer data)
1877 compose_toolbar_cb(A_EXTEDITOR, data);
1880 static void toolbar_linewrap_current_cb(GtkWidget *widget, gpointer data)
1882 compose_toolbar_cb(A_LINEWRAP_CURRENT, data);
1885 static void toolbar_linewrap_all_cb(GtkWidget *widget, gpointer data)
1887 compose_toolbar_cb(A_LINEWRAP_ALL, data);
1891 static void toolbar_check_spelling_cb(GtkWidget *widget, gpointer data)
1893 compose_toolbar_cb(A_CHECK_SPELLING, data);
1897 * Execute actions from toolbar
1899 static void toolbar_actions_execute_cb(GtkWidget *widget, gpointer data)
1901 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1902 GSList *action_list;
1903 MainWindow *mainwin;
1905 MessageView *msgview;
1906 gpointer parent = toolbar_item->parent;
1908 cm_return_if_fail(toolbar_item != NULL);
1910 switch (toolbar_item->type) {
1912 mainwin = (MainWindow*)parent;
1913 action_list = mainwin->toolbar->action_list;
1915 case TOOLBAR_COMPOSE:
1916 compose = (Compose*)parent;
1917 action_list = compose->toolbar->action_list;
1919 case TOOLBAR_MSGVIEW:
1920 msgview = (MessageView*)parent;
1921 action_list = msgview->toolbar->action_list;
1924 debug_print("toolbar event not supported\n");
1927 toolbar_action_execute(widget, action_list, parent, toolbar_item->type);
1930 static void toolbar_plugins_execute_cb(GtkWidget *widget, gpointer data)
1932 ToolbarItem *toolbar_item = data;
1933 prefs_toolbar_execute_plugin_item(toolbar_item->parent, toolbar_item->type, toolbar_item->text);
1936 static MainWindow *get_mainwin(gpointer data)
1938 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1939 MainWindow *mainwin = NULL;
1940 MessageView *msgview;
1942 cm_return_val_if_fail(toolbar_item != NULL, NULL);
1944 switch(toolbar_item->type) {
1946 mainwin = (MainWindow*)toolbar_item->parent;
1948 case TOOLBAR_MSGVIEW:
1949 msgview = (MessageView*)toolbar_item->parent;
1950 mainwin = (MainWindow*)msgview->mainwin;
1959 static void toolbar_go_folders_cb(GtkWidget *widget, gpointer data)
1961 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1962 MainWindow *mainwin = NULL;
1963 switch(toolbar_item->type) {
1965 mainwin = (MainWindow*)toolbar_item->parent;
1968 g_warning("wrong toolbar type");
1972 if (!mainwin->in_folder) {
1973 FolderItem *item = folderview_get_selected_item(mainwin->folderview);
1975 folderview_select(mainwin->folderview, item);
1978 folderview_grab_focus(mainwin->folderview);
1979 mainwindow_exit_folder(mainwin);
1983 static void toolbar_buttons_cb(GtkWidget *widget,
1990 void (*func)(GtkWidget *widget, gpointer data);
1992 { A_RECEIVE_ALL, toolbar_inc_all_cb },
1993 { A_RECEIVE_CUR, toolbar_inc_cb },
1994 { A_SEND_QUEUED, toolbar_send_queued_cb },
1995 { A_COMPOSE_EMAIL, toolbar_compose_cb },
1996 { A_COMPOSE_NEWS, toolbar_compose_cb },
1997 { A_REPLY_MESSAGE, toolbar_reply_cb },
1998 { A_REPLY_SENDER, toolbar_reply_to_sender_cb },
1999 { A_REPLY_ALL, toolbar_reply_to_all_cb },
2000 { A_REPLY_ML, toolbar_reply_to_list_cb },
2001 { A_FORWARD, toolbar_forward_cb },
2002 { A_TRASH, toolbar_trash_cb },
2003 { A_DELETE_REAL, toolbar_delete_cb },
2004 { A_EXECUTE, toolbar_exec_cb },
2005 { A_GOTO_PREV, toolbar_prev_unread_cb },
2006 { A_GOTO_NEXT, toolbar_next_unread_cb },
2007 { A_IGNORE_THREAD, toolbar_ignore_thread_cb },
2008 { A_WATCH_THREAD, toolbar_watch_thread_cb },
2009 { A_MARK, toolbar_mark_cb },
2010 { A_UNMARK, toolbar_unmark_cb },
2011 { A_LOCK, toolbar_lock_cb },
2012 { A_UNLOCK, toolbar_unlock_cb },
2013 { A_ALL_READ, toolbar_all_read_cb },
2014 { A_ALL_UNREAD, toolbar_all_unread_cb },
2015 { A_READ, toolbar_read_cb },
2016 { A_UNREAD, toolbar_unread_cb },
2017 { A_PRINT, toolbar_print_cb },
2018 { A_LEARN_SPAM, toolbar_learn_cb },
2019 { A_DELETE_DUP, toolbar_delete_dup_cb },
2020 { A_GO_FOLDERS, toolbar_go_folders_cb },
2022 { A_SEND, toolbar_send_cb },
2023 { A_SEND_LATER, toolbar_send_later_cb },
2024 { A_DRAFT, toolbar_draft_cb },
2025 { A_OPEN_MAIL, toolbar_open_mail_cb },
2026 { A_CLOSE, toolbar_close_cb },
2027 { A_PREFERENCES, toolbar_preferences_cb },
2028 { A_INSERT, toolbar_insert_cb },
2029 { A_ATTACH, toolbar_attach_cb },
2030 { A_SIG, toolbar_sig_cb },
2031 { A_REP_SIG, toolbar_replace_sig_cb },
2032 { A_EXTEDITOR, toolbar_ext_editor_cb },
2033 { A_LINEWRAP_CURRENT, toolbar_linewrap_current_cb },
2034 { A_LINEWRAP_ALL, toolbar_linewrap_all_cb },
2035 { A_ADDRBOOK, toolbar_addrbook_cb },
2037 { A_CHECK_SPELLING, toolbar_check_spelling_cb },
2039 { A_CLAWS_ACTIONS, toolbar_actions_execute_cb },
2040 { A_CANCEL_INC, toolbar_cancel_inc_cb },
2041 { A_CANCEL_SEND, toolbar_cancel_send_cb },
2042 { A_CANCEL_ALL, toolbar_cancel_all_cb },
2043 { A_CLAWS_PLUGINS, toolbar_plugins_execute_cb },
2046 num_items = sizeof(callbacks)/sizeof(callbacks[0]);
2048 for (i = 0; i < num_items; i++) {
2049 if (callbacks[i].index == item->index) {
2050 callbacks[i].func(widget, item);
2055 #ifndef GENERIC_UMPC
2056 #define TOOLBAR_ITEM(item,icon,text,tooltip) { \
2057 item = GTK_WIDGET(gtk_tool_button_new(icon, text)); \
2058 gtkut_widget_set_can_focus(gtk_bin_get_child(GTK_BIN(item)), FALSE); \
2059 gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE); \
2060 gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE); \
2061 g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item); \
2062 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1); \
2063 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(item), \
2067 #define TOOLBAR_MENUITEM(item,icon,text,tooltip,menutip) { \
2068 GtkWidget *child = NULL, *btn = NULL, *arr = NULL; \
2069 GList *gchild = NULL; \
2070 item = GTK_WIDGET(gtk_menu_tool_button_new(icon, text)); \
2071 gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE); \
2072 gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE); \
2073 g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item); \
2074 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1); \
2075 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(item), \
2077 CLAWS_SET_ARROW_TIP(GTK_MENU_TOOL_BUTTON(item), menutip); \
2078 child = gtk_bin_get_child(GTK_BIN(item)); \
2079 gchild = gtk_container_get_children( \
2080 GTK_CONTAINER(child)); \
2081 btn = (GtkWidget *)gchild->data; \
2082 gtkut_widget_set_can_focus(btn, FALSE); \
2083 arr = (GtkWidget *)(gchild->next?gchild->next->data:NULL); \
2084 gtkut_widget_set_can_focus(arr, FALSE); \
2085 g_list_free(gchild); \
2086 gchild = gtk_container_get_children(GTK_CONTAINER(arr)); \
2087 gtk_widget_set_size_request(GTK_WIDGET(gchild->data), 9, -1); \
2088 g_list_free(gchild); \
2091 #define TOOLBAR_ITEM(item,icon,text,tooltip) { \
2092 item = GTK_WIDGET(gtk_tool_button_new(icon, text)); \
2093 gtkut_widget_set_can_focus(gtk_bin_get_child(GTK_BIN(item)), FALSE); \
2094 gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE); \
2095 gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE); \
2096 g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item); \
2097 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1); \
2100 #define TOOLBAR_MENUITEM(item,icon,text,tooltip,menutip) { \
2101 GtkWidget *child = NULL, *btn = NULL, *arr = NULL; \
2102 GList *gchild = NULL; \
2103 item = GTK_WIDGET(gtk_menu_tool_button_new(icon, text)); \
2104 gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE); \
2105 gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE); \
2106 g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item); \
2107 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1); \
2108 child = gtk_bin_get_child(GTK_BIN(item)); \
2109 gchild = gtk_container_get_children( \
2110 GTK_CONTAINER(child)); \
2111 btn = (GtkWidget *)gchild->data; \
2112 gtkut_widget_set_can_focus(btn, FALSE); \
2113 arr = (GtkWidget *)(gchild->next?gchild->next->data:NULL); \
2114 gtkut_widget_set_can_focus(arr, FALSE); \
2115 g_list_free(gchild); \
2116 gchild = gtk_container_get_children(GTK_CONTAINER(arr)); \
2117 gtk_widget_set_size_request(GTK_WIDGET(gchild->data), 9, -1); \
2118 g_list_free(gchild); \
2122 #define ADD_MENU_ITEM(name,cb,data) { \
2123 item = gtk_menu_item_new_with_mnemonic(name); \
2124 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); \
2125 g_signal_connect(G_OBJECT(item), "activate", \
2128 g_object_set_data(G_OBJECT(item), "int-value", GINT_TO_POINTER(data)); \
2129 gtk_widget_show(item); \
2132 static void toolbar_reply_menu_cb(GtkWidget *widget, gpointer data)
2134 gpointer int_value = g_object_get_data(G_OBJECT(widget), "int-value");
2135 ToolbarItem *toolbar_item = (ToolbarItem *)data;
2137 toolbar_reply(toolbar_item, GPOINTER_TO_INT(int_value));
2140 static void toolbar_learn_menu_cb(GtkWidget *widget, gpointer data)
2142 gpointer int_value = g_object_get_data(G_OBJECT(widget), "int-value");
2143 ToolbarItem *toolbar_item = (ToolbarItem *)data;
2145 toolbar_learn(toolbar_item, GPOINTER_TO_INT(int_value));
2148 static void toolbar_delete_dup_menu_cb(GtkWidget *widget, gpointer data)
2150 gpointer int_value = g_object_get_data(G_OBJECT(widget), "int-value");
2151 ToolbarItem *toolbar_item = (ToolbarItem *)data;
2153 toolbar_delete_dup(toolbar_item, GPOINTER_TO_INT(int_value));
2157 * Create a new toolbar with specified type
2158 * if a callback list is passed it will be used before the
2159 * common callback list
2161 Toolbar *toolbar_create(ToolbarType type,
2162 GtkWidget *container,
2165 ToolbarItem *toolbar_item;
2168 GtkWidget *icon_wid = NULL;
2169 GtkWidget *icon_news;
2170 GtkWidget *icon_ham;
2172 ToolbarClawsActions *action_item;
2174 GSList *toolbar_list;
2175 Toolbar *toolbar_data;
2177 toolbar_read_config_file(type);
2178 toolbar_list = toolbar_get_list(type);
2180 toolbar_data = g_new0(Toolbar, 1);
2182 toolbar = gtk_toolbar_new();
2184 gtk_orientable_set_orientation(GTK_ORIENTABLE(toolbar), GTK_ORIENTATION_HORIZONTAL);
2186 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_BOTH);
2187 gtk_toolbar_set_show_arrow(GTK_TOOLBAR(toolbar), TRUE);
2189 for (cur = toolbar_list; cur != NULL; cur = cur->next) {
2191 if (g_ascii_strcasecmp(((ToolbarItem*)cur->data)->file, TOOLBAR_TAG_SEPARATOR) == 0) {
2192 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), gtk_separator_tool_item_new(), -1);
2196 toolbar_item = g_new0(ToolbarItem, 1);
2197 toolbar_item->index = ((ToolbarItem*)cur->data)->index;
2198 toolbar_item->file = g_strdup(((ToolbarItem*)cur->data)->file);
2199 toolbar_item->text = g_strdup(((ToolbarItem*)cur->data)->text);
2200 toolbar_item->parent = data;
2201 toolbar_item->type = type;
2203 /* collect toolbar items in list to keep track */
2204 toolbar_data->item_list =
2205 g_slist_append(toolbar_data->item_list,
2207 icon_wid = stock_pixmap_widget(stock_pixmap_get_icon(toolbar_item->file));
2209 switch (toolbar_item->index) {
2212 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Go to folder list"));
2213 toolbar_data->folders_btn = item;
2216 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2217 _("Receive Mail from all Accounts"),
2218 _("Receive Mail from selected Account"));
2219 toolbar_data->getall_btn = item;
2222 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Receive Mail from current Account"));
2223 toolbar_data->get_btn = item;
2226 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Send Queued Messages"));
2227 toolbar_data->send_btn = item;
2230 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Close window"));
2231 toolbar_data->close_window_btn = item;
2234 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Open preferences"));
2235 toolbar_data->preferences_btn = item;
2238 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Open email"));
2239 toolbar_data->open_mail_btn = item;
2241 case A_COMPOSE_EMAIL:
2242 #ifndef GENERIC_UMPC
2243 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2245 _("Compose with selected Account"));
2246 toolbar_data->compose_mail_btn = item;
2247 toolbar_data->compose_mail_icon = icon_wid;
2248 g_object_ref(toolbar_data->compose_mail_icon);
2250 icon_news = stock_pixmap_widget(STOCK_PIXMAP_NEWS_COMPOSE);
2251 toolbar_data->compose_news_icon = icon_news;
2252 g_object_ref(toolbar_data->compose_news_icon);
2254 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2255 _("Compose Email"));
2256 toolbar_data->compose_mail_btn = item;
2257 toolbar_data->compose_mail_icon = icon_wid;
2259 icon_news = stock_pixmap_widget(STOCK_PIXMAP_NEWS_COMPOSE);
2260 toolbar_data->compose_news_icon = icon_news;
2264 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2267 toolbar_data->learn_spam_btn = item;
2268 toolbar_data->learn_spam_icon = icon_wid;
2269 g_object_ref(toolbar_data->learn_spam_icon);
2271 icon_ham = stock_pixmap_widget(STOCK_PIXMAP_HAM_BTN);
2272 toolbar_data->learn_ham_icon = icon_ham;
2273 g_object_ref(toolbar_data->learn_ham_icon);
2275 menu = gtk_menu_new();
2276 ADD_MENU_ITEM(_("Learn as _Spam"), toolbar_learn_menu_cb, TRUE);
2277 ADD_MENU_ITEM(_("Learn as _Ham"), toolbar_learn_menu_cb, FALSE);
2278 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->learn_spam_btn), menu);
2281 #ifndef GENERIC_UMPC
2282 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2283 _("Delete duplicates"),
2284 _("Delete duplicates options"));
2285 toolbar_data->delete_dup_btn = item;
2287 menu = gtk_menu_new();
2288 ADD_MENU_ITEM(_("Delete duplicates in selected folder"), toolbar_delete_dup_menu_cb, FALSE);
2289 ADD_MENU_ITEM(_("Delete duplicates in all folders"), toolbar_delete_dup_menu_cb, TRUE);
2290 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->delete_dup_btn), menu);
2292 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Delete duplicates"));
2293 toolbar_data->delete_dup_btn = item;
2296 case A_REPLY_MESSAGE:
2297 #ifndef GENERIC_UMPC
2298 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2299 _("Reply to Message"),
2300 _("Reply to Message options"));
2301 toolbar_data->reply_btn = item;
2303 menu = gtk_menu_new();
2304 ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_WITH_QUOTE);
2305 ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_WITHOUT_QUOTE);
2306 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->reply_btn), menu);
2308 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2309 _("Reply to Message"));
2310 toolbar_data->reply_btn = item;
2313 case A_REPLY_SENDER:
2314 #ifndef GENERIC_UMPC
2315 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2316 _("Reply to Sender"),
2317 _("Reply to Sender options"));
2318 toolbar_data->replysender_btn = item;
2320 menu = gtk_menu_new();
2321 ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE);
2322 ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE);
2323 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->replysender_btn), menu);
2325 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2326 _("Reply to Sender"));
2327 toolbar_data->replysender_btn = item;
2331 #ifndef GENERIC_UMPC
2332 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2334 _("Reply to All options"));
2335 toolbar_data->replyall_btn = item;
2337 menu = gtk_menu_new();
2338 ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE);
2339 ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE);
2340 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->replyall_btn), menu);
2342 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2344 toolbar_data->replyall_btn = item;
2348 #ifndef GENERIC_UMPC
2349 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2350 _("Reply to Mailing-list"),
2351 _("Reply to Mailing-list options"));
2352 toolbar_data->replylist_btn = item;
2354 menu = gtk_menu_new();
2355 ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_LIST_WITH_QUOTE);
2356 ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE);
2357 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->replylist_btn), menu);
2359 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2360 _("Reply to Mailing-list"));
2361 toolbar_data->replylist_btn = item;
2365 #ifndef GENERIC_UMPC
2366 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2367 _("Forward Message"),
2368 _("Forward Message options"));
2369 toolbar_data->fwd_btn = item;
2371 menu = gtk_menu_new();
2372 ADD_MENU_ITEM(_("_Forward"), toolbar_reply_menu_cb, COMPOSE_FORWARD_INLINE);
2373 ADD_MENU_ITEM(_("For_ward as attachment"), toolbar_reply_menu_cb, COMPOSE_FORWARD_AS_ATTACH);
2374 ADD_MENU_ITEM(_("Redirec_t"), toolbar_reply_menu_cb, COMPOSE_REDIRECT);
2375 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->fwd_btn), menu);
2377 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2378 _("Forward Message"));
2379 toolbar_data->fwd_btn = item;
2383 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Trash Message"));
2384 toolbar_data->trash_btn = item;
2387 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Delete Message"));
2388 toolbar_data->delete_btn = item;
2391 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Execute"));
2392 toolbar_data->exec_btn = item;
2395 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Go to Previous Unread Message"));
2396 toolbar_data->prev_btn = item;
2399 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Go to Next Unread Message"));
2400 toolbar_data->next_btn = item;
2403 /* Compose Toolbar */
2405 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Send Message"));
2406 toolbar_data->send_btn = item;
2409 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Put into queue folder and send later"));
2410 toolbar_data->sendl_btn = item;
2413 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Save to draft folder"));
2414 toolbar_data->draft_btn = item;
2417 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Insert file"));
2418 toolbar_data->insert_btn = item;
2421 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Attach file"));
2422 toolbar_data->attach_btn = item;
2425 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Insert signature"));
2426 toolbar_data->sig_btn = item;
2429 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Replace signature"));
2430 toolbar_data->repsig_btn = item;
2433 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Edit with external editor"));
2434 toolbar_data->exteditor_btn = item;
2436 case A_LINEWRAP_CURRENT:
2437 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Wrap long lines of current paragraph"));
2438 toolbar_data->linewrap_current_btn = item;
2440 case A_LINEWRAP_ALL:
2441 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Wrap all long lines"));
2442 toolbar_data->linewrap_all_btn = item;
2445 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Address book"));
2446 toolbar_data->addrbook_btn = item;
2449 case A_CHECK_SPELLING:
2450 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Check spelling"));
2451 toolbar_data->spellcheck_btn = item;
2455 case A_CLAWS_ACTIONS:
2456 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,toolbar_item->text);
2457 action_item = g_new0(ToolbarClawsActions, 1);
2458 action_item->widget = item;
2459 action_item->name = g_strdup(toolbar_item->text);
2461 toolbar_data->action_list =
2462 g_slist_append(toolbar_data->action_list,
2466 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Cancel receiving"));
2467 toolbar_data->cancel_inc_btn = item;
2470 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Cancel sending"));
2471 toolbar_data->cancel_send_btn = item;
2474 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Cancel receiving/sending"));
2475 toolbar_data->cancel_all_btn = item;
2477 case A_CLAWS_PLUGINS:
2478 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text, toolbar_item->text);
2481 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2482 toolbar_ret_descr_from_val(toolbar_item->index));
2483 /* find and set the tool tip text */
2488 toolbar_data->toolbar = toolbar;
2490 gtk_widget_show_all(toolbar);
2492 if (type == TOOLBAR_MAIN) {
2494 MainWindow *mainwin = mainwindow_get_mainwindow();
2495 GtkWidget *progressbar = gtk_progress_bar_new();
2496 item = GTK_WIDGET(gtk_tool_item_new());
2497 gtk_container_add (GTK_CONTAINER (item), progressbar);
2498 gtk_widget_show(item);
2499 gtk_widget_set_size_request(progressbar, 84, -1);
2500 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1);
2501 mainwin->progressbar = progressbar;
2503 activate_compose_button(toolbar_data,
2504 prefs_common.toolbar_style,
2505 toolbar_data->compose_btn_type);
2507 if (type != TOOLBAR_COMPOSE)
2508 activate_learn_button(toolbar_data, prefs_common.toolbar_style,
2511 gtk_container_add(GTK_CONTAINER(container), toolbar);
2512 gtk_container_set_border_width(GTK_CONTAINER(container), 0);
2514 return toolbar_data;
2518 * Free toolbar structures
2520 void toolbar_destroy(Toolbar * toolbar) {
2522 TOOLBAR_DESTROY_ITEMS(toolbar->item_list);
2523 TOOLBAR_DESTROY_ACTIONS(toolbar->action_list);
2526 void toolbar_update(ToolbarType type, gpointer data)
2528 Toolbar *toolbar_data;
2529 GtkWidget *handlebox;
2530 MainWindow *mainwin = (MainWindow*)data;
2531 Compose *compose = (Compose*)data;
2532 MessageView *msgview = (MessageView*)data;
2534 #ifndef GENERIC_UMPC
2537 toolbar_data = mainwin->toolbar;
2538 handlebox = mainwin->handlebox;
2540 case TOOLBAR_COMPOSE:
2541 toolbar_data = compose->toolbar;
2542 handlebox = compose->handlebox;
2544 case TOOLBAR_MSGVIEW:
2545 toolbar_data = msgview->toolbar;
2546 handlebox = msgview->handlebox;
2552 gtk_container_remove(GTK_CONTAINER(handlebox),
2553 GTK_WIDGET(toolbar_data->toolbar));
2555 toolbar_init(toolbar_data);
2556 toolbar_data = toolbar_create(type, handlebox, data);
2560 toolbar_data = mainwin->toolbar;
2561 handlebox = mainwin->window;
2563 case TOOLBAR_COMPOSE:
2564 toolbar_data = compose->toolbar;
2565 handlebox = compose->window;
2567 case TOOLBAR_MSGVIEW:
2568 toolbar_data = msgview->toolbar;
2569 handlebox = msgview->window;
2574 toolbar_init(toolbar_data);
2575 toolbar_data = toolbar_create(type, handlebox, data);
2580 mainwin->toolbar = toolbar_data;
2582 case TOOLBAR_COMPOSE:
2583 compose->toolbar = toolbar_data;
2585 case TOOLBAR_MSGVIEW:
2586 msgview->toolbar = toolbar_data;
2590 toolbar_style(type, prefs_common.toolbar_style, data);
2592 if (type == TOOLBAR_MAIN) {
2593 toolbar_main_set_sensitive((MainWindow*)data);
2594 account_set_menu_only_toolbar();
2598 #define GTK_BUTTON_SET_SENSITIVE(widget,sensitive) { \
2599 gtk_widget_set_sensitive(widget, sensitive); \
2602 void toolbar_main_set_sensitive(gpointer data)
2604 SensitiveCondMask state;
2606 MainWindow *mainwin = (MainWindow*)data;
2607 Toolbar *toolbar = mainwin->toolbar;
2609 GSList *entry_list = NULL;
2611 typedef struct _Entry Entry;
2614 SensitiveCondMask cond;
2618 #define SET_WIDGET_COND(w, ...) \
2620 Entry *e = g_new0(Entry, 1); \
2622 e->cond = main_window_get_mask(__VA_ARGS__, -1); \
2623 entry_list = g_slist_append(entry_list, e); \
2626 /* match all bit flags */
2628 if (toolbar->get_btn)
2629 SET_WIDGET_COND(toolbar->get_btn,
2630 M_HAVE_ACCOUNT, M_UNLOCKED, M_HAVE_RETRIEVABLE_ACCOUNT);
2632 if (toolbar->getall_btn) {
2633 SET_WIDGET_COND(toolbar->getall_btn,
2634 M_HAVE_ACCOUNT, M_UNLOCKED, M_HAVE_ANY_RETRIEVABLE_ACCOUNT);
2636 if (toolbar->send_btn) {
2637 SET_WIDGET_COND(toolbar->send_btn,
2638 M_HAVE_QUEUED_MAILS);
2640 if (toolbar->compose_mail_btn) {
2641 SET_WIDGET_COND(toolbar->compose_mail_btn,
2644 if (toolbar->close_window_btn) {
2645 SET_WIDGET_COND(toolbar->close_window_btn,
2648 if (toolbar->open_mail_btn) {
2649 SET_WIDGET_COND(toolbar->open_mail_btn,
2650 M_TARGET_EXIST, M_SUMMARY_ISLIST);
2652 if (toolbar->reply_btn) {
2653 SET_WIDGET_COND(toolbar->reply_btn,
2654 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2656 if (toolbar->replyall_btn) {
2657 SET_WIDGET_COND(toolbar->replyall_btn,
2658 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2660 if (toolbar->replylist_btn) {
2661 SET_WIDGET_COND(toolbar->replylist_btn,
2662 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2664 if (toolbar->replysender_btn) {
2665 SET_WIDGET_COND(toolbar->replysender_btn,
2666 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2668 if (toolbar->fwd_btn) {
2669 SET_WIDGET_COND(toolbar->fwd_btn,
2670 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2673 if (prefs_common.next_unread_msg_dialog == NEXTUNREADMSGDIALOG_ASSUME_NO) {
2674 SET_WIDGET_COND(toolbar->next_btn, M_MSG_EXIST, M_SUMMARY_ISLIST);
2676 SET_WIDGET_COND(toolbar->next_btn, -1);
2679 if (toolbar->trash_btn)
2680 SET_WIDGET_COND(toolbar->trash_btn,
2681 M_TARGET_EXIST, M_ALLOW_DELETE, M_NOT_NEWS);
2683 if (toolbar->delete_btn)
2684 SET_WIDGET_COND(toolbar->delete_btn,
2685 M_TARGET_EXIST, M_ALLOW_DELETE);
2687 if (toolbar->delete_dup_btn)
2688 SET_WIDGET_COND(toolbar->delete_dup_btn,
2689 M_MSG_EXIST, M_ALLOW_DELETE, M_SUMMARY_ISLIST);
2691 if (toolbar->exec_btn)
2692 SET_WIDGET_COND(toolbar->exec_btn,
2695 if (toolbar->learn_spam_btn)
2696 SET_WIDGET_COND(toolbar->learn_spam_btn,
2697 M_TARGET_EXIST, M_CAN_LEARN_SPAM, M_SUMMARY_ISLIST);
2699 if (toolbar->cancel_inc_btn)
2700 SET_WIDGET_COND(toolbar->cancel_inc_btn,
2703 if (toolbar->cancel_send_btn)
2704 SET_WIDGET_COND(toolbar->cancel_send_btn,
2707 for (cur = toolbar->action_list; cur != NULL; cur = cur->next) {
2708 ToolbarClawsActions *act = (ToolbarClawsActions*)cur->data;
2710 SET_WIDGET_COND(act->widget, M_TARGET_EXIST, M_UNLOCKED);
2713 state = main_window_get_current_state(mainwin);
2715 for (cur = entry_list; cur != NULL; cur = cur->next) {
2716 Entry *e = (Entry*) cur->data;
2718 if (e->widget != NULL) {
2719 sensitive = ((e->cond & state) == e->cond);
2720 GTK_BUTTON_SET_SENSITIVE(e->widget, sensitive);
2724 while (entry_list != NULL) {
2725 Entry *e = (Entry*) entry_list->data;
2728 entry_list = g_slist_remove(entry_list, e);
2731 /* match any bit flags */
2733 if (toolbar->cancel_all_btn)
2734 SET_WIDGET_COND(toolbar->cancel_all_btn,
2735 M_INC_ACTIVE, M_SEND_ACTIVE);
2737 for (cur = entry_list; cur != NULL; cur = cur->next) {
2738 Entry *e = (Entry*) cur->data;
2740 if (e->widget != NULL) {
2741 sensitive = ((e->cond & state) != 0);
2742 GTK_BUTTON_SET_SENSITIVE(e->widget, sensitive);
2746 while (entry_list != NULL) {
2747 Entry *e = (Entry*) entry_list->data;
2750 entry_list = g_slist_remove(entry_list, e);
2753 g_slist_free(entry_list);
2755 activate_compose_button(toolbar,
2756 prefs_common.toolbar_style,
2757 toolbar->compose_btn_type);
2759 #undef SET_WIDGET_COND
2762 void toolbar_comp_set_sensitive(gpointer data, gboolean sensitive)
2764 Compose *compose = (Compose*)data;
2765 GSList *items = compose->toolbar->action_list;
2767 if (compose->toolbar->send_btn)
2768 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->send_btn, sensitive);
2769 if (compose->toolbar->sendl_btn)
2770 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->sendl_btn, sensitive);
2771 if (compose->toolbar->draft_btn )
2772 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->draft_btn , sensitive);
2773 if (compose->toolbar->insert_btn )
2774 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->insert_btn , sensitive);
2775 if (compose->toolbar->attach_btn)
2776 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->attach_btn, sensitive);
2777 if (compose->toolbar->sig_btn)
2778 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->sig_btn, sensitive);
2779 if (compose->toolbar->repsig_btn)
2780 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->repsig_btn, sensitive);
2781 if (compose->toolbar->exteditor_btn)
2782 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->exteditor_btn, sensitive);
2783 if (compose->toolbar->linewrap_current_btn)
2784 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->linewrap_current_btn, sensitive);
2785 if (compose->toolbar->linewrap_all_btn)
2786 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->linewrap_all_btn, sensitive);
2787 if (compose->toolbar->addrbook_btn)
2788 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->addrbook_btn, sensitive);
2790 if (compose->toolbar->spellcheck_btn)
2791 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->spellcheck_btn, sensitive);
2793 for (; items != NULL; items = g_slist_next(items)) {
2794 ToolbarClawsActions *item = (ToolbarClawsActions *)items->data;
2795 GTK_BUTTON_SET_SENSITIVE(item->widget, sensitive);
2800 * Initialize toolbar structure
2802 static void toolbar_init(Toolbar * toolbar)
2805 toolbar->toolbar = NULL;
2806 toolbar->folders_btn = NULL;
2807 toolbar->get_btn = NULL;
2808 toolbar->getall_btn = NULL;
2809 toolbar->send_btn = NULL;
2810 toolbar->compose_mail_btn = NULL;
2811 toolbar->compose_mail_icon = NULL;
2812 toolbar->compose_news_icon = NULL;
2813 toolbar->reply_btn = NULL;
2814 toolbar->replysender_btn = NULL;
2815 toolbar->replyall_btn = NULL;
2816 toolbar->replylist_btn = NULL;
2817 toolbar->fwd_btn = NULL;
2818 toolbar->trash_btn = NULL;
2819 toolbar->delete_btn = NULL;
2820 toolbar->delete_dup_btn = NULL;
2821 toolbar->prev_btn = NULL;
2822 toolbar->next_btn = NULL;
2823 toolbar->exec_btn = NULL;
2824 toolbar->separator = NULL;
2825 toolbar->learn_spam_btn = NULL;
2826 toolbar->learn_spam_icon = NULL;
2827 toolbar->learn_ham_icon = NULL;
2828 toolbar->cancel_inc_btn = NULL;
2829 toolbar->cancel_send_btn = NULL;
2830 toolbar->cancel_all_btn = NULL;
2832 /* compose buttons */
2833 toolbar->sendl_btn = NULL;
2834 toolbar->draft_btn = NULL;
2835 toolbar->insert_btn = NULL;
2836 toolbar->attach_btn = NULL;
2837 toolbar->sig_btn = NULL;
2838 toolbar->repsig_btn = NULL;
2839 toolbar->exteditor_btn = NULL;
2840 toolbar->linewrap_current_btn = NULL;
2841 toolbar->linewrap_all_btn = NULL;
2842 toolbar->addrbook_btn = NULL;
2844 toolbar->open_mail_btn = NULL;
2845 toolbar->close_window_btn = NULL;
2846 toolbar->preferences_btn = NULL;
2847 toolbar->action_list = NULL;
2848 toolbar->item_list = NULL;
2850 toolbar->spellcheck_btn = NULL;
2853 toolbar_destroy(toolbar);
2858 static void toolbar_reply(gpointer data, guint action)
2860 ToolbarItem *toolbar_item = (ToolbarItem*)data;
2861 MainWindow *mainwin;
2862 MessageView *msgview;
2863 GSList *msginfo_list = NULL;
2865 cm_return_if_fail(toolbar_item != NULL);
2867 switch (toolbar_item->type) {
2869 mainwin = (MainWindow*)toolbar_item->parent;
2870 msginfo_list = summary_get_selection(mainwin->summaryview);
2871 msgview = (MessageView*)mainwin->messageview;
2873 case TOOLBAR_MSGVIEW:
2874 msgview = (MessageView*)toolbar_item->parent;
2875 cm_return_if_fail(msgview != NULL);
2876 msginfo_list = g_slist_append(msginfo_list, msgview->msginfo);
2882 cm_return_if_fail(msgview != NULL);
2883 cm_return_if_fail(msginfo_list != NULL);
2884 compose_reply_from_messageview(msgview, msginfo_list, action);
2885 g_slist_free(msginfo_list);
2887 /* TODO: update reply state ion summaryview */
2891 /* exported functions */
2893 void inc_mail_cb(gpointer data, guint action, GtkWidget *widget)
2895 MainWindow *mainwin = (MainWindow*)data;
2897 inc_mail(mainwin, prefs_common.newmail_notify_manu);
2900 void inc_all_account_mail_cb(gpointer data, guint action, GtkWidget *widget)
2902 MainWindow *mainwin = (MainWindow*)data;
2904 inc_all_account_mail(mainwin, FALSE, prefs_common.newmail_notify_manu);
2907 void send_queue_cb(gpointer data, guint action, GtkWidget *widget)
2911 gboolean got_error = FALSE;
2912 gchar *errstr = NULL;
2914 if (prefs_common.work_offline)
2915 if (alertpanel(_("Offline warning"),
2916 _("You're working offline. Override?"),
2917 GTK_STOCK_NO, GTK_STOCK_YES,
2918 NULL) != G_ALERTALTERNATE)
2921 /* ask for confirmation before sending queued messages only
2922 in online mode and if there is at least one message queued
2923 in any of the folder queue
2925 if (prefs_common.confirm_send_queued_messages) {
2927 /* check if there's a queued message */
2928 for (list = folder_get_list(); !found && list != NULL; list = list->next) {
2929 Folder *folder = list->data;
2931 found = !procmsg_queue_is_empty(folder->queue);
2933 /* if necessary, ask for confirmation before sending */
2934 if (found && !prefs_common.work_offline) {
2935 if (alertpanel(_("Send queued messages"),
2936 _("Send all queued messages?"),
2937 GTK_STOCK_CANCEL, _("_Send"),
2938 NULL) != G_ALERTALTERNATE)
2943 for (list = folder_get_list(); list != NULL; list = list->next) {
2944 Folder *folder = list->data;
2946 if (folder->queue) {
2947 if (procmsg_send_queue(folder->queue,
2948 prefs_common.savemsg,
2955 alertpanel_error_log(_("Some errors occurred while "
2956 "sending queued messages."));
2958 alertpanel_error_log(_("Some errors occurred "
2959 "while sending queued messages:\n%s"), errstr);
2965 void compose_mail_cb(gpointer data, guint action, GtkWidget *widget)
2967 MainWindow *mainwin = (MainWindow*)data;
2968 PrefsAccount *ac = NULL;
2969 FolderItem *item = mainwin->summaryview->folder_item;
2974 ac = account_find_from_item(item);
2975 if (ac && ac->protocol != A_NNTP && ac->protocol != A_IMAP4) {
2976 compose_new_with_folderitem(ac, item, NULL); /* CLAWS */
2982 * CLAWS - use current account
2984 if (cur_account && (cur_account->protocol != A_NNTP)) {
2985 compose_new_with_folderitem(cur_account, item, NULL);
2990 * CLAWS - just get the first one
2992 list = account_get_list();
2993 for (cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2994 ac = (PrefsAccount *) cur->data;
2995 if (ac->protocol != A_NNTP) {
2996 compose_new_with_folderitem(ac, item, NULL);
3002 void compose_news_cb(gpointer data, guint action, GtkWidget *widget)
3004 MainWindow *mainwin = (MainWindow*)data;
3005 PrefsAccount * ac = NULL;
3009 if (mainwin->summaryview->folder_item) {
3010 ac = mainwin->summaryview->folder_item->folder->account;
3011 if (ac && ac->protocol == A_NNTP) {
3012 compose_new_with_folderitem(ac,
3013 mainwin->summaryview->folder_item, NULL);
3018 list = account_get_list();
3019 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
3020 ac = (PrefsAccount *) cur->data;
3021 if (ac->protocol == A_NNTP) {
3022 compose_new_with_folderitem(ac,
3023 mainwin->summaryview->folder_item, NULL);