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/>.
21 #include "claws-features.h"
27 #include <glib/gi18n.h>
36 #include "mainwindow.h"
37 #include "summaryview.h"
42 #include "prefs_gtk.h"
44 #include "stock_pixmap.h"
45 #include "manage_window.h"
51 #include "prefs_actions.h"
52 #include "prefs_common.h"
53 #include "prefs_toolbar.h"
54 #include "alertpanel.h"
57 #include "send_message.h"
58 #ifndef USE_ALT_ADDRBOOK
59 #include "addressbook.h"
61 #include "addressbook-dbus.h"
65 #define TOOLBAR_TAG_INDEX "toolbar"
66 #define TOOLBAR_TAG_ITEM "item"
67 #define TOOLBAR_TAG_SEPARATOR "separator"
69 #define TOOLBAR_ICON_FILE "file"
70 #define TOOLBAR_ICON_TEXT "text"
71 #define TOOLBAR_ICON_ACTION "action"
73 static void toolbar_init(Toolbar * toolbar);
74 static gboolean toolbar_is_duplicate (gint action,
76 static void toolbar_parse_item (XMLFile *file,
77 ToolbarType source, gboolean *rewrite);
79 static gint toolbar_ret_val_from_text (const gchar *text);
80 static gchar *toolbar_ret_text_from_val (gint val);
82 typedef struct _DefaultToolbar DefaultToolbar;
83 struct _DefaultToolbar {
86 static void toolbar_set_default_generic(ToolbarType toolbar_type,
87 DefaultToolbar *default_toolbar);
89 static void toolbar_style (ToolbarType type,
93 static MainWindow *get_mainwin (gpointer data);
94 static void activate_compose_button (Toolbar *toolbar,
96 ComposeButtonType type);
98 /* toolbar callbacks */
99 static void toolbar_reply (gpointer data,
102 static void toolbar_learn (gpointer data,
105 static void toolbar_delete_dup (gpointer data,
108 static void toolbar_trash_cb (GtkWidget *widget,
111 static void toolbar_delete_cb (GtkWidget *widget,
114 static void toolbar_delete_dup_cb (GtkWidget *widget,
118 static void toolbar_compose_cb (GtkWidget *widget,
121 static void toolbar_learn_cb (GtkWidget *widget,
124 static void toolbar_reply_cb (GtkWidget *widget,
127 static void toolbar_reply_to_all_cb (GtkWidget *widget,
130 static void toolbar_reply_to_list_cb (GtkWidget *widget,
133 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
136 static void toolbar_forward_cb (GtkWidget *widget,
139 static void toolbar_prev_unread_cb (GtkWidget *widget,
141 static void toolbar_next_unread_cb (GtkWidget *widget,
144 static void toolbar_ignore_thread_cb (GtkWidget *widget,
147 static void toolbar_watch_thread_cb (GtkWidget *widget,
150 static void toolbar_mark_cb (GtkWidget *widget,
153 static void toolbar_unmark_cb (GtkWidget *widget,
156 static void toolbar_lock_cb (GtkWidget *widget,
159 static void toolbar_ulock_cb (GtkWidget *widget,
162 static void toolbar_all_read_cb (GtkWidget *widget,
165 static void toolbar_all_unread_cb (GtkWidget *widget,
168 static void toolbar_read_cb (GtkWidget *widget,
171 static void toolbar_unread_cb (GtkWidget *widget,
174 static void toolbar_print_cb (GtkWidget *widget,
177 static void toolbar_actions_execute_cb (GtkWidget *widget,
179 static void toolbar_plugins_execute_cb (GtkWidget *widget,
183 static void toolbar_send_cb (GtkWidget *widget,
185 static void toolbar_send_later_cb (GtkWidget *widget,
187 static void toolbar_draft_cb (GtkWidget *widget,
189 static void toolbar_close_cb (GtkWidget *widget,
191 static void toolbar_preferences_cb (GtkWidget *widget,
193 static void toolbar_open_mail_cb (GtkWidget *widget,
195 static void toolbar_insert_cb (GtkWidget *widget,
197 static void toolbar_attach_cb (GtkWidget *widget,
199 static void toolbar_sig_cb (GtkWidget *widget,
201 static void toolbar_ext_editor_cb (GtkWidget *widget,
203 static void toolbar_linewrap_current_cb (GtkWidget *widget,
205 static void toolbar_linewrap_all_cb (GtkWidget *widget,
207 static void toolbar_addrbook_cb (GtkWidget *widget,
210 static void toolbar_check_spelling_cb (GtkWidget *widget,
213 static void toolbar_cancel_inc_cb (GtkWidget *widget,
215 static void toolbar_cancel_send_cb (GtkWidget *widget,
217 static void toolbar_cancel_all_cb (GtkWidget *widget,
223 } toolbar_text [] = {
224 { "A_RECEIVE_ALL", N_("Receive Mail from all Accounts") },
225 { "A_RECEIVE_CUR", N_("Receive Mail from current Account") },
226 { "A_SEND_QUEUED", N_("Send Queued Messages") },
227 { "A_COMPOSE_EMAIL", N_("Compose Email") },
228 { "A_COMPOSE_NEWS", N_("Compose News") },
229 { "A_REPLY_MESSAGE", N_("Reply to Message") },
230 { "A_REPLY_SENDER", N_("Reply to Sender") },
231 { "A_REPLY_ALL", N_("Reply to All") },
232 { "A_REPLY_ML", N_("Reply to Mailing-list") },
233 { "A_OPEN_MAIL", N_("Open email") },
234 { "A_FORWARD", N_("Forward Message") },
235 { "A_TRASH", N_("Trash Message") },
236 { "A_DELETE_REAL", N_("Delete Message") },
237 { "A_DELETE_DUP", N_("Delete duplicate messages") },
238 { "A_EXECUTE", N_("Execute") },
239 { "A_GOTO_PREV", N_("Go to Previous Unread Message") },
240 { "A_GOTO_NEXT", N_("Go to Next Unread Message") },
242 { "A_IGNORE_THREAD", N_("Ignore thread") },
243 { "A_WATCH_THREAD", N_("Watch thread") },
244 { "A_MARK", N_("Mark Message") },
245 { "A_UNMARK", N_("Unmark Message") },
246 { "A_LOCK", N_("Lock Message") },
247 { "A_UNLOCK", N_("Unlock Message") },
248 { "A_ALL_READ", N_("Mark all Messages as read") },
249 { "A_ALL_UNREAD", N_("Mark all Messages as unread") },
250 { "A_READ", N_("Mark Message as read") },
251 { "A_UNREAD", N_("Mark Message as unread") },
253 { "A_PRINT", N_("Print") },
254 { "A_LEARN_SPAM", N_("Learn Spam or Ham") },
255 { "A_GO_FOLDERS", N_("Open folder/Go to folder list") },
256 { "A_PREFERENCES", N_("Preferences") },
258 { "A_SEND", N_("Send Message") },
259 { "A_SEND_LATER", N_("Put into queue folder and send later") },
260 { "A_DRAFT", N_("Save to draft folder") },
261 { "A_INSERT", N_("Insert file") },
262 { "A_ATTACH", N_("Attach file") },
263 { "A_SIG", N_("Insert signature") },
264 { "A_REP_SIG", N_("Replace signature") },
265 { "A_EXTEDITOR", N_("Edit with external editor") },
266 { "A_LINEWRAP_CURRENT", N_("Wrap long lines of current paragraph") },
267 { "A_LINEWRAP_ALL", N_("Wrap all long lines") },
268 { "A_ADDRBOOK", N_("Address book") },
270 { "A_CHECK_SPELLING", N_("Check spelling") },
272 { "A_CLAWS_ACTIONS", N_("Claws Mail Actions Feature") },
273 { "A_CANCEL_INC", N_("Cancel receiving") },
274 { "A_CANCEL_SEND", N_("Cancel sending") },
275 { "A_CANCEL_ALL", N_("Cancel receiving/sending") },
276 { "A_CLOSE", N_("Close window") },
277 { "A_SEPARATOR", N_("Separator") },
278 { "A_CLAWS_PLUGINS", N_("Claws Mail Plugins") }
281 /* migration table: support reading toolbar configuration files with
282 old action names and converting them to current action names,
283 see toolbar_parse_item(), which makes uses of this alias table.
286 const gchar *old_name;
287 const gchar *current_name;
288 } toolbar_migration [] = {
289 { "A_SYL_ACTIONS", "A_CLAWS_ACTIONS" },
290 { "A_SENDL", "A_SEND_LATER" },
294 /* struct holds configuration files and a list of
295 * currently active toolbar items
296 * TOOLBAR_MAIN, TOOLBAR_COMPOSE and TOOLBAR_MSGVIEW
300 const gchar *conf_file;
302 } toolbar_config[NUM_TOOLBARS] = {
303 { "toolbar_main.xml", NULL},
304 { "toolbar_compose.xml", NULL},
305 { "toolbar_msgview.xml", NULL}
308 gint toolbar_ret_val_from_descr(const gchar *descr)
312 for (i = 0; i < N_ACTION_VAL; i++) {
313 if (g_utf8_collate(gettext(toolbar_text[i].descr), descr) == 0)
320 gchar *toolbar_ret_descr_from_val(gint val)
322 cm_return_val_if_fail(val >=0 && val < N_ACTION_VAL, NULL);
324 return gettext(toolbar_text[val].descr);
327 static gint toolbar_ret_val_from_text(const gchar *text)
331 for (i = 0; i < N_ACTION_VAL; i++) {
332 if (g_utf8_collate(toolbar_text[i].index_str, text) == 0)
339 static gchar *toolbar_ret_text_from_val(gint val)
341 cm_return_val_if_fail(val >=0 && val < N_ACTION_VAL, NULL);
343 return toolbar_text[val].index_str;
346 static gboolean toolbar_is_duplicate(gint action, ToolbarType source)
350 if ((action == A_SEPARATOR) || (action == A_CLAWS_ACTIONS) || (action == A_CLAWS_PLUGINS))
353 for (cur = toolbar_config[source].item_list; cur != NULL; cur = cur->next) {
354 ToolbarItem *item = (ToolbarItem*) cur->data;
356 if (item->index == action)
362 /* depending on toolbar type this function
363 returns a list of available toolbar events being
364 displayed by prefs_toolbar
366 GList *toolbar_get_action_items(ToolbarType source)
371 if (source == TOOLBAR_MAIN) {
372 gint main_items[] = {
373 A_RECEIVE_ALL, A_RECEIVE_CUR, A_SEND_QUEUED,
374 A_COMPOSE_EMAIL, A_REPLY_MESSAGE, A_REPLY_SENDER,
375 A_REPLY_ALL, A_REPLY_ML, A_OPEN_MAIL, A_FORWARD,
376 A_TRASH, A_DELETE_REAL, A_DELETE_DUP, A_EXECUTE,
377 A_GOTO_PREV, A_GOTO_NEXT, A_IGNORE_THREAD, A_WATCH_THREAD,
378 A_MARK, A_UNMARK, A_LOCK, A_UNLOCK,
379 A_ALL_READ, A_ALL_UNREAD, A_READ, A_UNREAD,
380 A_PRINT, A_ADDRBOOK, A_LEARN_SPAM, A_GO_FOLDERS,
381 A_CANCEL_INC, A_CANCEL_SEND, A_CANCEL_ALL, A_PREFERENCES };
383 for (i = 0; i < sizeof main_items / sizeof main_items[0]; i++) {
384 items = g_list_append(items, gettext(toolbar_text[main_items[i]].descr));
387 else if (source == TOOLBAR_COMPOSE) {
388 gint comp_items[] = {
389 A_SEND, A_SEND_LATER, A_DRAFT,
390 A_INSERT, A_ATTACH, A_SIG,
391 A_REP_SIG, A_EXTEDITOR, A_LINEWRAP_CURRENT,
392 A_LINEWRAP_ALL, A_ADDRBOOK,
398 for (i = 0; i < sizeof comp_items / sizeof comp_items[0]; i++)
399 items = g_list_append(items, gettext(toolbar_text[comp_items[i]].descr));
401 else if (source == TOOLBAR_MSGVIEW) {
402 gint msgv_items[] = {
403 A_COMPOSE_EMAIL, A_REPLY_MESSAGE, A_REPLY_SENDER,
404 A_REPLY_ALL, A_REPLY_ML, A_FORWARD,
405 A_TRASH, A_DELETE_REAL, A_GOTO_PREV, A_GOTO_NEXT,
406 A_ADDRBOOK, A_LEARN_SPAM, A_CLOSE };
408 for (i = 0; i < sizeof msgv_items / sizeof msgv_items[0]; i++)
409 items = g_list_append(items, gettext(toolbar_text[msgv_items[i]].descr));
415 static void toolbar_parse_item(XMLFile *file, ToolbarType source, gboolean *rewrite)
419 ToolbarItem *item = NULL;
421 g_return_if_fail(rewrite != NULL);
423 attr = xml_get_current_tag_attr(file);
424 item = g_new0(ToolbarItem, 1);
426 name = ((XMLAttr *)attr->data)->name;
427 value = ((XMLAttr *)attr->data)->value;
429 if (g_utf8_collate(name, TOOLBAR_ICON_FILE) == 0)
430 item->file = g_strdup (value);
431 else if (g_utf8_collate(name, TOOLBAR_ICON_TEXT) == 0)
432 item->text = g_strdup (*value ? gettext(value):"");
433 else if (g_utf8_collate(name, TOOLBAR_ICON_ACTION) == 0)
434 item->index = toolbar_ret_val_from_text(value);
436 if ((item->index == -1) && !strcmp(value, "A_DELETE")) {
438 item->index = A_TRASH;
440 item->file = g_strdup("trash_btn");
442 item->text = g_strdup(C_("Toolbar", "Trash"));
445 if (!strcmp(item->file, "mail") && !strcmp(value, "A_DRAFT")) {
446 /* switch icon file */
448 item->file = g_strdup("mail_draft");
451 if (item->index == -1) {
452 /* item not found in table: try migrating old action names to current ones */
455 /* replace action name */
456 for (i = 0; toolbar_migration[i].old_name != NULL; i++) {
457 if (g_utf8_collate(value, toolbar_migration[i].old_name) == 0) {
458 item->index = toolbar_ret_val_from_text(toolbar_migration[i].current_name);
459 if (item->index != -1) {
461 debug_print("toolbar_parse_item: migrating action label from '%s' to '%s'\n",
462 value, toolbar_migration[i].current_name);
468 if ((item->index == -1) && !rewrite)
469 g_warning("toolbar_parse_item: unrecognized action name '%s'\n", value);
471 attr = g_list_next(attr);
473 if (item->index != -1) {
474 if (!toolbar_is_duplicate(item->index, source))
475 toolbar_config[source].item_list = g_slist_append(toolbar_config[source].item_list,
480 const gchar *toolbar_get_short_text(int action) {
482 case A_RECEIVE_ALL: return _("Get Mail");
483 case A_RECEIVE_CUR: return _("Get");
484 case A_SEND_QUEUED: return _("Send");
485 case A_COMPOSE_EMAIL: return C_("Toolbar", "Compose");
486 case A_COMPOSE_NEWS: return C_("Toolbar", "Compose");
487 case A_REPLY_MESSAGE: return _("Reply");
488 case A_REPLY_SENDER: return C_("Toolbar", "Sender");
489 case A_REPLY_ALL: return _("All");
490 case A_REPLY_ML: return _("List");
491 case A_OPEN_MAIL: return _("Open");
492 case A_FORWARD: return _("Forward");
493 case A_TRASH: return C_("Toolbar", "Trash");
494 case A_DELETE_REAL: return _("Delete");
495 case A_DELETE_DUP: return _("Delete duplicates");
496 case A_EXECUTE: return _("Execute");
497 case A_GOTO_PREV: return _("Prev");
498 case A_GOTO_NEXT: return _("Next");
500 case A_IGNORE_THREAD: return _("Ignore thread");
501 case A_WATCH_THREAD: return _("Watch thread");
502 case A_MARK: return _("Mark");
503 case A_UNMARK: return _("Unmark");
504 case A_LOCK: return _("Lock");
505 case A_UNLOCK: return _("Unlock");
506 case A_ALL_READ: return _("All read");
507 case A_ALL_UNREAD: return _("All unread");
508 case A_READ: return _("Read");
509 case A_UNREAD: return _("Unread");
511 case A_PRINT: return _("Print");
512 case A_LEARN_SPAM: return _("Spam");
513 case A_GO_FOLDERS: return _("Folders");
514 case A_PREFERENCES: return _("Preferences");
516 case A_SEND: return _("Send");
517 case A_SEND_LATER: return _("Send later");
518 case A_DRAFT: return _("Draft");
519 case A_INSERT: return _("Insert");
520 case A_ATTACH: return _("Attach");
521 case A_SIG: return _("Insert sig.");
522 case A_REP_SIG: return _("Replace sig.");
523 case A_EXTEDITOR: return _("Edit");
524 case A_LINEWRAP_CURRENT:return _("Wrap para.");
525 case A_LINEWRAP_ALL: return _("Wrap all");
526 case A_ADDRBOOK: return _("Address");
528 case A_CHECK_SPELLING: return _("Check spelling");
531 case A_CANCEL_INC: return _("Stop");
532 case A_CANCEL_SEND: return _("Stop");
533 case A_CANCEL_ALL: return _("Stop all");
534 case A_CLOSE: return _("Close");
539 gint toolbar_get_icon(int action) {
541 case A_RECEIVE_ALL: return STOCK_PIXMAP_MAIL_RECEIVE_ALL;
542 case A_RECEIVE_CUR: return STOCK_PIXMAP_MAIL_RECEIVE;
543 case A_SEND_QUEUED: return STOCK_PIXMAP_MAIL_SEND_QUEUE;
544 case A_COMPOSE_EMAIL: return STOCK_PIXMAP_MAIL_COMPOSE;
545 case A_COMPOSE_NEWS: return STOCK_PIXMAP_NEWS_COMPOSE;
546 case A_REPLY_MESSAGE: return STOCK_PIXMAP_MAIL_REPLY;
547 case A_REPLY_SENDER: return STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR;
548 case A_REPLY_ALL: return STOCK_PIXMAP_MAIL_REPLY_TO_ALL;
549 case A_REPLY_ML: return STOCK_PIXMAP_MAIL_REPLY_TO_LIST;
550 case A_OPEN_MAIL: return STOCK_PIXMAP_OPEN_MAIL;
551 case A_FORWARD: return STOCK_PIXMAP_MAIL_FORWARD;
552 case A_TRASH: return STOCK_PIXMAP_TRASH;
553 case A_DELETE_REAL: return STOCK_PIXMAP_DELETE;
554 case A_DELETE_DUP: return STOCK_PIXMAP_DELETE_DUP;
555 case A_EXECUTE: return STOCK_PIXMAP_EXEC;
556 case A_GOTO_PREV: return STOCK_PIXMAP_UP_ARROW;
557 case A_GOTO_NEXT: return STOCK_PIXMAP_DOWN_ARROW;
559 case A_IGNORE_THREAD: return STOCK_PIXMAP_MARK_IGNORETHREAD;
560 case A_WATCH_THREAD: return STOCK_PIXMAP_MARK_WATCHTHREAD;
561 case A_MARK: return STOCK_PIXMAP_MARK_MARK;
562 case A_UNMARK: return STOCK_PIXMAP_MARK_UNMARK;
563 case A_LOCK: return STOCK_PIXMAP_MARK_LOCKED;
564 case A_UNLOCK: return STOCK_PIXMAP_MARK_UNLOCKED;
565 case A_ALL_READ: return STOCK_PIXMAP_MARK_ALLREAD;
566 case A_ALL_UNREAD: return STOCK_PIXMAP_MARK_ALLUNREAD;
567 case A_READ: return STOCK_PIXMAP_MARK_READ;
568 case A_UNREAD: return STOCK_PIXMAP_MARK_UNREAD;
570 case A_PRINT: return STOCK_PIXMAP_PRINTER;
571 case A_LEARN_SPAM: return STOCK_PIXMAP_SPAM_BTN;
572 case A_GO_FOLDERS: return STOCK_PIXMAP_GO_FOLDERS;
573 case A_PREFERENCES: return STOCK_PIXMAP_PREFERENCES;
575 case A_SEND: return STOCK_PIXMAP_MAIL_SEND;
576 case A_SEND_LATER: return STOCK_PIXMAP_MAIL_SEND_QUEUE;
577 case A_DRAFT: return STOCK_PIXMAP_MAIL_DRAFT;
578 case A_INSERT: return STOCK_PIXMAP_INSERT_FILE;
579 case A_ATTACH: return STOCK_PIXMAP_MAIL_ATTACH;
580 case A_SIG: return STOCK_PIXMAP_MAIL_SIGN;
581 case A_REP_SIG: return STOCK_PIXMAP_MAIL_SIGN;
582 case A_EXTEDITOR: return STOCK_PIXMAP_EDIT_EXTERN;
583 case A_LINEWRAP_CURRENT:return STOCK_PIXMAP_LINEWRAP_CURRENT;
584 case A_LINEWRAP_ALL: return STOCK_PIXMAP_LINEWRAP_ALL;
585 case A_ADDRBOOK: return STOCK_PIXMAP_ADDRESS_BOOK;
587 case A_CHECK_SPELLING: return STOCK_PIXMAP_CHECK_SPELLING;
590 case A_CANCEL_INC: return STOCK_PIXMAP_CANCEL;
591 case A_CANCEL_SEND: return STOCK_PIXMAP_CANCEL;
592 case A_CANCEL_ALL: return STOCK_PIXMAP_CANCEL;
593 case A_CLOSE: return STOCK_PIXMAP_CLOSE;
598 static void toolbar_set_default_generic(ToolbarType toolbar_type, DefaultToolbar *default_toolbar)
602 g_return_if_fail(default_toolbar != NULL);
604 for (i = 0; default_toolbar[i].action != N_ACTION_VAL; i++) {
606 ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
608 if (default_toolbar[i].action != A_SEPARATOR) {
612 icon = toolbar_get_icon(default_toolbar[i].action);
614 file = stock_pixmap_get_name((StockPixmap)icon);
616 toolbar_item->file = g_strdup(file);
617 toolbar_item->index = default_toolbar[i].action;
618 toolbar_item->text = g_strdup(toolbar_get_short_text(default_toolbar[i].action));
620 toolbar_item->file = g_strdup(TOOLBAR_TAG_SEPARATOR);
621 toolbar_item->index = A_SEPARATOR;
624 if (toolbar_item->index != -1) {
625 if (!toolbar_is_duplicate(toolbar_item->index, toolbar_type))
626 toolbar_config[toolbar_type].item_list =
627 g_slist_append(toolbar_config[toolbar_type].item_list, toolbar_item);
632 void toolbar_set_default(ToolbarType source)
634 DefaultToolbar default_toolbar_main[] = {
660 DefaultToolbar default_toolbar_compose[] = {
678 DefaultToolbar default_toolbar_msgview[] = {
696 if (source == TOOLBAR_MAIN)
697 toolbar_set_default_generic(TOOLBAR_MAIN, default_toolbar_main);
698 else if (source == TOOLBAR_COMPOSE)
699 toolbar_set_default_generic(TOOLBAR_COMPOSE, default_toolbar_compose);
700 else if (source == TOOLBAR_MSGVIEW)
701 toolbar_set_default_generic(TOOLBAR_MSGVIEW, default_toolbar_msgview);
704 void toolbar_save_config_file(ToolbarType source)
709 gchar *fileSpec = NULL;
711 debug_print("save Toolbar Configuration to %s\n", toolbar_config[source].conf_file);
713 fileSpec = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, toolbar_config[source].conf_file, NULL );
714 pfile = prefs_write_open(fileSpec);
717 if (fprintf(fp, "<?xml version=\"1.0\" encoding=\"%s\" ?>\n", CS_INTERNAL) < 0)
720 if (fprintf(fp, "<%s>\n", TOOLBAR_TAG_INDEX) < 0)
723 for (cur = toolbar_config[source].item_list; cur != NULL; cur = cur->next) {
724 ToolbarItem *toolbar_item = (ToolbarItem*) cur->data;
726 if (toolbar_item->index != A_SEPARATOR) {
727 if (fprintf(fp, "\t<%s %s=\"%s\" %s=\"",
729 TOOLBAR_ICON_FILE, toolbar_item->file,
730 TOOLBAR_ICON_TEXT) < 0)
732 if (xml_file_put_escape_str(fp, toolbar_item->text) < 0)
734 if (fprintf(fp, "\" %s=\"%s\"/>\n",
736 toolbar_ret_text_from_val(toolbar_item->index)) < 0)
739 if (fprintf(fp, "\t<%s/>\n", TOOLBAR_TAG_SEPARATOR) < 0)
744 if (fprintf(fp, "</%s>\n", TOOLBAR_TAG_INDEX) < 0)
748 if (prefs_file_close (pfile) < 0 )
749 g_warning("failed to write toolbar configuration to file");
753 FILE_OP_ERROR(fileSpec, "fprintf");
755 prefs_file_close_revert (pfile);
757 g_warning("failed to open toolbar configuration file for writing");
760 void toolbar_read_config_file(ToolbarType source)
762 XMLFile *file = NULL;
763 gchar *fileSpec = NULL;
765 gboolean rewrite = FALSE;
767 debug_print("read Toolbar Configuration from %s\n", toolbar_config[source].conf_file);
769 fileSpec = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, toolbar_config[source].conf_file, NULL );
770 file = xml_open_file(fileSpec);
773 toolbar_clear_list(source);
777 || (xml_get_dtd(file))
778 || (xml_parse_next_tag(file))
779 || (!xml_compare_tag(file, TOOLBAR_TAG_INDEX))) {
780 xml_close_file(file);
788 if (xml_parse_next_tag(file))
791 /* Get next tag (icon, icon_text or icon_action) */
792 if (xml_compare_tag(file, TOOLBAR_TAG_ITEM)) {
793 toolbar_parse_item(file, source, &rewrite);
794 } else if (xml_compare_tag(file, TOOLBAR_TAG_SEPARATOR)) {
795 ToolbarItem *item = g_new0(ToolbarItem, 1);
797 item->file = g_strdup(TOOLBAR_TAG_SEPARATOR);
798 item->index = A_SEPARATOR;
799 toolbar_config[source].item_list =
800 g_slist_append(toolbar_config[source].item_list, item);
804 xml_close_file(file);
806 debug_print("toolbar_read_config_file: rewriting toolbar\n");
807 toolbar_save_config_file(source);
811 if ((!file) || (g_slist_length(toolbar_config[source].item_list) == 0)) {
813 if (source == TOOLBAR_MAIN)
814 toolbar_set_default(TOOLBAR_MAIN);
815 else if (source == TOOLBAR_COMPOSE)
816 toolbar_set_default(TOOLBAR_COMPOSE);
817 else if (source == TOOLBAR_MSGVIEW)
818 toolbar_set_default(TOOLBAR_MSGVIEW);
820 g_warning("refusing to write unknown Toolbar Configuration number %d", source);
824 toolbar_save_config_file(source);
829 * clears list of toolbar items read from configuration files
831 void toolbar_clear_list(ToolbarType source)
833 while (toolbar_config[source].item_list != NULL) {
834 ToolbarItem *item = (ToolbarItem*) toolbar_config[source].item_list->data;
836 toolbar_config[source].item_list =
837 g_slist_remove(toolbar_config[source].item_list, item);
843 g_slist_free(toolbar_config[source].item_list);
848 * return list of Toolbar items
850 GSList *toolbar_get_list(ToolbarType source)
854 if ((source == TOOLBAR_MAIN) || (source == TOOLBAR_COMPOSE) || (source == TOOLBAR_MSGVIEW))
855 list = toolbar_config[source].item_list;
860 void toolbar_set_list_item(ToolbarItem *t_item, ToolbarType source)
862 ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
864 toolbar_item->file = g_strdup(t_item->file);
865 toolbar_item->text = g_strdup(t_item->text);
866 toolbar_item->index = t_item->index;
868 toolbar_config[source].item_list =
869 g_slist_append(toolbar_config[source].item_list,
873 static void toolbar_action_execute(GtkWidget *widget,
881 for (cur = action_list; cur != NULL; cur = cur->next) {
882 ToolbarClawsActions *act = (ToolbarClawsActions*)cur->data;
884 if (widget == act->widget) {
885 i = prefs_actions_find_by_name(act->name);
893 actions_execute(data, i, widget, source);
895 g_warning ("Error: did not find Claws Action to execute");
898 gboolean toolbar_check_action_btns(ToolbarType type)
900 GSList *temp, *curr, *list = toolbar_config[type].item_list;
901 gboolean modified = FALSE;
904 while (curr != NULL) {
905 ToolbarItem *toolbar_item = (ToolbarItem *) curr->data;
909 if (toolbar_item->index != A_CLAWS_ACTIONS)
912 if (prefs_actions_find_by_name(toolbar_item->text) == -1) {
913 list = g_slist_delete_link(list, temp);
914 g_free(toolbar_item->file);
915 g_free(toolbar_item->text);
916 g_free(toolbar_item);
924 #define CLAWS_SET_TOOL_ITEM_TIP(widget,tip) { \
925 gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), tip); \
928 #define CLAWS_SET_ARROW_TIP(widget,tip) { \
929 gtk_menu_tool_button_set_arrow_tooltip_text(GTK_MENU_TOOL_BUTTON(widget), tip); \
932 static void activate_compose_button (Toolbar *toolbar,
934 ComposeButtonType type)
936 if ((!toolbar->compose_mail_btn))
939 if (type == COMPOSEBUTTON_NEWS) {
940 gtk_tool_button_set_icon_widget(
941 GTK_TOOL_BUTTON(toolbar->compose_mail_btn),
942 toolbar->compose_news_icon);
944 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(toolbar->compose_mail_btn), _("Compose News message"));
946 gtk_widget_show(toolbar->compose_news_icon);
948 gtk_tool_button_set_icon_widget(
949 GTK_TOOL_BUTTON(toolbar->compose_mail_btn),
950 toolbar->compose_mail_icon);
952 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(toolbar->compose_mail_btn), _("Compose Email"));
954 gtk_widget_show(toolbar->compose_mail_icon);
956 toolbar->compose_btn_type = type;
959 void toolbar_set_compose_button(Toolbar *toolbar,
960 ComposeButtonType compose_btn_type)
962 if (toolbar->compose_btn_type != compose_btn_type)
963 activate_compose_button(toolbar,
964 prefs_common.toolbar_style,
968 static void activate_learn_button (Toolbar *toolbar,
970 LearnButtonType type)
972 if ((!toolbar->learn_spam_btn))
975 if (type == LEARN_SPAM) {
976 gtk_tool_button_set_icon_widget(
977 GTK_TOOL_BUTTON(toolbar->learn_spam_btn),
978 toolbar->learn_spam_icon);
979 gtk_tool_button_set_label(
980 GTK_TOOL_BUTTON(toolbar->learn_spam_btn),
983 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(toolbar->learn_spam_btn), _("Learn spam"));
985 gtk_widget_show(toolbar->learn_spam_icon);
987 gtk_tool_button_set_icon_widget(
988 GTK_TOOL_BUTTON(toolbar->learn_spam_btn),
989 toolbar->learn_ham_icon);
990 gtk_tool_button_set_label(
991 GTK_TOOL_BUTTON(toolbar->learn_spam_btn),
994 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(toolbar->learn_spam_btn), _("Learn ham"));
996 gtk_widget_show(toolbar->learn_ham_icon);
998 toolbar->learn_btn_type = type;
1001 void toolbar_set_learn_button(Toolbar *toolbar,
1002 LearnButtonType learn_btn_type)
1004 if (toolbar->learn_btn_type != learn_btn_type)
1005 activate_learn_button(toolbar,
1006 prefs_common.toolbar_style,
1010 void toolbar_toggle(guint action, gpointer data)
1012 MainWindow *mainwin = (MainWindow*)data;
1016 cm_return_if_fail(mainwin != NULL);
1018 toolbar_style(TOOLBAR_MAIN, action, mainwin);
1020 list = compose_get_compose_list();
1021 for (cur = list; cur != NULL; cur = cur->next) {
1022 toolbar_style(TOOLBAR_COMPOSE, action, cur->data);
1024 list = messageview_get_msgview_list();
1025 for (cur = list; cur != NULL; cur = cur->next) {
1026 toolbar_style(TOOLBAR_MSGVIEW, action, cur->data);
1031 void toolbar_set_style(GtkWidget *toolbar_wid, GtkWidget *handlebox_wid, guint action)
1033 switch ((ToolbarStyle)action) {
1035 gtk_widget_hide(handlebox_wid);
1038 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
1042 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
1046 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
1049 case TOOLBAR_BOTH_HORIZ:
1050 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
1051 GTK_TOOLBAR_BOTH_HORIZ);
1057 prefs_common.toolbar_style = (ToolbarStyle)action;
1058 gtk_widget_set_size_request(handlebox_wid, 1, -1);
1060 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
1061 gtk_widget_show(handlebox_wid);
1062 gtk_widget_queue_resize(handlebox_wid);
1066 * Change the style of toolbar
1068 static void toolbar_style(ToolbarType type, guint action, gpointer data)
1070 GtkWidget *handlebox_wid;
1071 GtkWidget *toolbar_wid;
1072 MainWindow *mainwin = (MainWindow*)data;
1073 Compose *compose = (Compose*)data;
1074 MessageView *msgview = (MessageView*)data;
1076 cm_return_if_fail(data != NULL);
1080 handlebox_wid = mainwin->handlebox;
1081 toolbar_wid = mainwin->toolbar->toolbar;
1083 case TOOLBAR_COMPOSE:
1084 handlebox_wid = compose->handlebox;
1085 toolbar_wid = compose->toolbar->toolbar;
1087 case TOOLBAR_MSGVIEW:
1088 handlebox_wid = msgview->handlebox;
1089 toolbar_wid = msgview->toolbar->toolbar;
1095 toolbar_set_style(toolbar_wid, handlebox_wid, action);
1098 /* Toolbar handling */
1099 static void toolbar_inc_cb(GtkWidget *widget,
1102 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1103 MainWindow *mainwin;
1105 cm_return_if_fail(toolbar_item != NULL);
1107 switch (toolbar_item->type) {
1109 mainwin = (MainWindow*)toolbar_item->parent;
1110 inc_mail_cb(mainwin, 0, NULL);
1117 static void toolbar_inc_all_cb(GtkWidget *widget,
1120 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1121 MainWindow *mainwin;
1123 cm_return_if_fail(toolbar_item != NULL);
1125 switch (toolbar_item->type) {
1127 mainwin = (MainWindow*)toolbar_item->parent;
1128 inc_all_account_mail_cb(mainwin, 0, NULL);
1135 static void toolbar_send_queued_cb(GtkWidget *widget,gpointer data)
1137 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1138 MainWindow *mainwin;
1140 cm_return_if_fail(toolbar_item != NULL);
1142 switch (toolbar_item->type) {
1144 mainwin = (MainWindow*)toolbar_item->parent;
1145 send_queue_cb(mainwin, 0, NULL);
1152 static void toolbar_exec_cb(GtkWidget *widget,
1155 MainWindow *mainwin = get_mainwin(data);
1157 cm_return_if_fail(mainwin != NULL);
1158 summary_execute(mainwin->summaryview);
1162 * Delete current/selected(s) message(s)
1164 static void toolbar_trash_cb(GtkWidget *widget, gpointer data)
1166 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1167 MainWindow *mainwin;
1169 cm_return_if_fail(toolbar_item != NULL);
1170 cm_return_if_fail(toolbar_item->parent);
1172 switch (toolbar_item->type) {
1173 case TOOLBAR_MSGVIEW:
1174 messageview_delete((MessageView *)toolbar_item->parent);
1177 mainwin = (MainWindow *)toolbar_item->parent;
1178 summary_delete_trash(mainwin->summaryview);
1181 debug_print("toolbar event not supported\n");
1187 * Delete current/selected(s) message(s)
1189 static void toolbar_delete_cb(GtkWidget *widget, gpointer data)
1191 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1192 MainWindow *mainwin;
1194 cm_return_if_fail(toolbar_item != NULL);
1195 cm_return_if_fail(toolbar_item->parent);
1197 switch (toolbar_item->type) {
1198 case TOOLBAR_MSGVIEW:
1199 messageview_delete((MessageView *)toolbar_item->parent);
1202 mainwin = (MainWindow *)toolbar_item->parent;
1203 summary_delete(mainwin->summaryview);
1206 debug_print("toolbar event not supported\n");
1211 static void toolbar_delete_dup(gpointer data, guint all)
1213 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1214 MainWindow *mainwin = NULL;
1216 cm_return_if_fail(toolbar_item != NULL);
1218 switch (toolbar_item->type) {
1220 mainwin = (MainWindow*)toolbar_item->parent;
1222 mainwindow_delete_duplicated_all(mainwin);
1224 mainwindow_delete_duplicated(mainwin);
1226 case TOOLBAR_COMPOSE:
1227 case TOOLBAR_MSGVIEW:
1230 debug_print("toolbar event not supported\n");
1235 static void toolbar_delete_dup_cb(GtkWidget *widget, gpointer data)
1237 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1238 MainWindow *mainwin = NULL;
1240 cm_return_if_fail(toolbar_item != NULL);
1242 switch (toolbar_item->type) {
1244 mainwin = (MainWindow*)toolbar_item->parent;
1245 mainwindow_delete_duplicated(mainwin);
1247 case TOOLBAR_COMPOSE:
1248 case TOOLBAR_MSGVIEW:
1256 * Compose new message
1258 static void toolbar_compose_cb(GtkWidget *widget, gpointer data)
1260 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1261 MainWindow *mainwin;
1262 MessageView *msgview;
1264 cm_return_if_fail(toolbar_item != NULL);
1266 switch (toolbar_item->type) {
1268 mainwin = (MainWindow*)toolbar_item->parent;
1269 if (mainwin->toolbar->compose_btn_type == COMPOSEBUTTON_NEWS)
1270 compose_news_cb(mainwin, 0, NULL);
1272 compose_mail_cb(mainwin, 0, NULL);
1274 case TOOLBAR_MSGVIEW:
1275 msgview = (MessageView*)toolbar_item->parent;
1276 compose_new_with_folderitem(NULL,
1277 msgview->msginfo->folder, NULL);
1280 debug_print("toolbar event not supported\n");
1284 static void toolbar_learn(gpointer data, guint as_spam)
1286 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1287 MainWindow *mainwin;
1288 MessageView *msgview;
1290 cm_return_if_fail(toolbar_item != NULL);
1292 switch (toolbar_item->type) {
1294 mainwin = (MainWindow*)toolbar_item->parent;
1296 mainwindow_learn(mainwin, TRUE);
1298 mainwindow_learn(mainwin, FALSE);
1300 case TOOLBAR_MSGVIEW:
1301 msgview = (MessageView*)toolbar_item->parent;
1303 messageview_learn(msgview, TRUE);
1305 messageview_learn(msgview, FALSE);
1308 debug_print("toolbar event not supported\n");
1312 static void toolbar_learn_cb(GtkWidget *widget, gpointer data)
1314 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1315 MainWindow *mainwin;
1316 MessageView *msgview;
1318 cm_return_if_fail(toolbar_item != NULL);
1320 switch (toolbar_item->type) {
1322 mainwin = (MainWindow*)toolbar_item->parent;
1323 if (mainwin->toolbar->learn_btn_type == LEARN_SPAM)
1324 mainwindow_learn(mainwin, TRUE);
1326 mainwindow_learn(mainwin, FALSE);
1328 case TOOLBAR_MSGVIEW:
1329 msgview = (MessageView*)toolbar_item->parent;
1330 if (msgview->toolbar->learn_btn_type == LEARN_SPAM)
1331 messageview_learn(msgview, TRUE);
1333 messageview_learn(msgview, FALSE);
1336 debug_print("toolbar event not supported\n");
1344 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
1346 toolbar_reply(data, (prefs_common.reply_with_quote ?
1347 COMPOSE_REPLY_WITH_QUOTE : COMPOSE_REPLY_WITHOUT_QUOTE));
1352 * Reply message to Sender and All recipients
1354 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
1357 (prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
1358 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE));
1363 * Reply to Mailing List
1365 static void toolbar_reply_to_list_cb(GtkWidget *widget, gpointer data)
1368 (prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_LIST_WITH_QUOTE
1369 : COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE));
1374 * Reply to sender of message
1376 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
1379 (prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
1380 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE));
1386 static void toolbar_addrbook_cb(GtkWidget *widget, gpointer data)
1388 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1391 cm_return_if_fail(toolbar_item != NULL);
1393 switch (toolbar_item->type) {
1395 case TOOLBAR_MSGVIEW:
1398 case TOOLBAR_COMPOSE:
1399 compose = (Compose *)toolbar_item->parent;
1404 #ifndef USE_ALT_ADDRBOOK
1405 addressbook_open(compose);
1407 GError* error = NULL;
1408 addressbook_connect_signals(compose);
1409 addressbook_dbus_open(TRUE, &error);
1411 g_warning("%s", error->message);
1412 g_error_free(error);
1419 * Forward current/selected(s) message(s)
1421 static void toolbar_forward_cb(GtkWidget *widget, gpointer data)
1423 toolbar_reply(data, (COMPOSE_FORWARD));
1427 * Goto Prev Unread Message
1429 static void toolbar_prev_unread_cb(GtkWidget *widget, gpointer data)
1431 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1432 MainWindow *mainwin;
1433 MessageView *msgview;
1435 cm_return_if_fail(toolbar_item != NULL);
1437 switch (toolbar_item->type) {
1439 mainwin = (MainWindow*)toolbar_item->parent;
1440 summary_select_prev_unread(mainwin->summaryview);
1443 case TOOLBAR_MSGVIEW:
1444 msgview = (MessageView*)toolbar_item->parent;
1445 msgview->updating = TRUE;
1446 summary_select_prev_unread(msgview->mainwin->summaryview);
1447 msgview->updating = FALSE;
1449 if (msgview->deferred_destroy) {
1450 debug_print("messageview got away!\n");
1451 messageview_destroy(msgview);
1455 /* Now we need to update the messageview window */
1456 if (msgview->mainwin->summaryview->selected) {
1457 #ifndef GENERIC_UMPC
1458 MsgInfo * msginfo = summary_get_selected_msg(msgview->mainwin->summaryview);
1461 messageview_show(msgview, msginfo,
1462 msgview->all_headers);
1465 gtk_widget_destroy(msgview->window);
1469 debug_print("toolbar event not supported\n");
1474 * Goto Next Unread Message
1476 static void toolbar_next_unread_cb(GtkWidget *widget, gpointer data)
1478 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1479 MainWindow *mainwin;
1480 MessageView *msgview;
1482 cm_return_if_fail(toolbar_item != NULL);
1484 switch (toolbar_item->type) {
1486 mainwin = (MainWindow*)toolbar_item->parent;
1487 summary_select_next_unread(mainwin->summaryview);
1490 case TOOLBAR_MSGVIEW:
1491 msgview = (MessageView*)toolbar_item->parent;
1492 msgview->updating = TRUE;
1493 summary_select_next_unread(msgview->mainwin->summaryview);
1494 msgview->updating = FALSE;
1496 if (msgview->deferred_destroy) {
1497 debug_print("messageview got away!\n");
1498 messageview_destroy(msgview);
1502 /* Now we need to update the messageview window */
1503 if (msgview->mainwin->summaryview->selected) {
1504 #ifndef GENERIC_UMPC
1505 MsgInfo * msginfo = summary_get_selected_msg(msgview->mainwin->summaryview);
1508 messageview_show(msgview, msginfo,
1509 msgview->all_headers);
1512 gtk_widget_destroy(msgview->window);
1516 debug_print("toolbar event not supported\n");
1520 static void toolbar_ignore_thread_cb(GtkWidget *widget, gpointer data)
1522 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1523 MainWindow *mainwin;
1525 cm_return_if_fail(toolbar_item != NULL);
1527 switch (toolbar_item->type) {
1529 mainwin = (MainWindow *) toolbar_item->parent;
1530 summary_toggle_ignore_thread(mainwin->summaryview);
1532 case TOOLBAR_MSGVIEW:
1533 /* TODO: see toolbar_next_unread_cb() if you need
1534 * this in the message view */
1537 debug_print("toolbar event not supported\n");
1542 static void toolbar_watch_thread_cb(GtkWidget *widget, gpointer data)
1544 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1545 MainWindow *mainwin;
1547 cm_return_if_fail(toolbar_item != NULL);
1549 switch (toolbar_item->type) {
1551 mainwin = (MainWindow *) toolbar_item->parent;
1552 summary_toggle_watch_thread(mainwin->summaryview);
1554 case TOOLBAR_MSGVIEW:
1555 /* TODO: see toolbar_next_unread_cb() if you need
1556 * this in the message view */
1559 debug_print("toolbar event not supported\n");
1564 static void toolbar_mark_cb(GtkWidget *widget, gpointer data)
1566 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1567 MainWindow *mainwin;
1569 cm_return_if_fail(toolbar_item != NULL);
1571 switch (toolbar_item->type) {
1573 mainwin = (MainWindow *) toolbar_item->parent;
1574 summary_mark(mainwin->summaryview);
1576 case TOOLBAR_MSGVIEW:
1577 /* TODO: see toolbar_next_unread_cb() if you need
1578 * this in the message view */
1581 debug_print("toolbar event not supported\n");
1586 static void toolbar_unmark_cb(GtkWidget *widget, gpointer data)
1588 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1589 MainWindow *mainwin;
1591 cm_return_if_fail(toolbar_item != NULL);
1593 switch (toolbar_item->type) {
1595 mainwin = (MainWindow *) toolbar_item->parent;
1596 summary_unmark(mainwin->summaryview);
1598 case TOOLBAR_MSGVIEW:
1599 /* TODO: see toolbar_next_unread_cb() if you need
1600 * this in the message view */
1603 debug_print("toolbar event not supported\n");
1608 static void toolbar_lock_cb(GtkWidget *widget, gpointer data)
1610 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1611 MainWindow *mainwin;
1613 cm_return_if_fail(toolbar_item != NULL);
1615 switch (toolbar_item->type) {
1617 mainwin = (MainWindow *) toolbar_item->parent;
1618 summary_msgs_lock(mainwin->summaryview);
1620 case TOOLBAR_MSGVIEW:
1621 /* TODO: see toolbar_next_unread_cb() if you need
1622 * this in the message view */
1625 debug_print("toolbar event not supported\n");
1630 static void toolbar_unlock_cb(GtkWidget *widget, gpointer data)
1632 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1633 MainWindow *mainwin;
1635 cm_return_if_fail(toolbar_item != NULL);
1637 switch (toolbar_item->type) {
1639 mainwin = (MainWindow *) toolbar_item->parent;
1640 summary_msgs_unlock(mainwin->summaryview);
1642 case TOOLBAR_MSGVIEW:
1643 /* TODO: see toolbar_next_unread_cb() if you need
1644 * this in the message view */
1647 debug_print("toolbar event not supported\n");
1652 static void toolbar_all_read_cb(GtkWidget *widget, gpointer data)
1654 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1655 MainWindow *mainwin;
1657 cm_return_if_fail(toolbar_item != NULL);
1659 switch (toolbar_item->type) {
1661 mainwin = (MainWindow *) toolbar_item->parent;
1662 summary_mark_all_read(mainwin->summaryview, TRUE);
1664 case TOOLBAR_MSGVIEW:
1665 /* TODO: see toolbar_next_unread_cb() if you need
1666 * this in the message view */
1669 debug_print("toolbar event not supported\n");
1674 static void toolbar_all_unread_cb(GtkWidget *widget, gpointer data)
1676 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1677 MainWindow *mainwin;
1679 cm_return_if_fail(toolbar_item != NULL);
1681 switch (toolbar_item->type) {
1683 mainwin = (MainWindow *) toolbar_item->parent;
1684 summary_mark_all_unread(mainwin->summaryview, TRUE);
1686 case TOOLBAR_MSGVIEW:
1687 /* TODO: see toolbar_next_unread_cb() if you need
1688 * this in the message view */
1691 debug_print("toolbar event not supported\n");
1696 static void toolbar_read_cb(GtkWidget *widget, gpointer data)
1698 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1699 MainWindow *mainwin;
1701 cm_return_if_fail(toolbar_item != NULL);
1703 switch (toolbar_item->type) {
1705 mainwin = (MainWindow *) toolbar_item->parent;
1706 summary_mark_as_read(mainwin->summaryview);
1708 case TOOLBAR_MSGVIEW:
1709 /* TODO: see toolbar_next_unread_cb() if you need
1710 * this in the message view */
1713 debug_print("toolbar event not supported\n");
1718 static void toolbar_unread_cb(GtkWidget *widget, gpointer data)
1720 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1721 MainWindow *mainwin;
1723 cm_return_if_fail(toolbar_item != NULL);
1725 switch (toolbar_item->type) {
1727 mainwin = (MainWindow *) toolbar_item->parent;
1728 summary_mark_as_unread(mainwin->summaryview);
1730 case TOOLBAR_MSGVIEW:
1731 /* TODO: see toolbar_next_unread_cb() if you need
1732 * this in the message view */
1735 debug_print("toolbar event not supported\n");
1740 static void toolbar_cancel_inc_cb(GtkWidget *widget, gpointer data)
1742 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1744 cm_return_if_fail(toolbar_item != NULL);
1749 static void toolbar_cancel_send_cb(GtkWidget *widget, gpointer data)
1751 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1753 cm_return_if_fail(toolbar_item != NULL);
1757 static void toolbar_cancel_all_cb(GtkWidget *widget, gpointer data)
1759 toolbar_cancel_inc_cb(widget, data);
1760 toolbar_cancel_send_cb(widget, data);
1763 static void toolbar_print_cb(GtkWidget *widget, gpointer data)
1765 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1766 MainWindow *mainwin;
1768 cm_return_if_fail(toolbar_item != NULL);
1770 switch (toolbar_item->type) {
1772 mainwin = (MainWindow *) toolbar_item->parent;
1773 summary_print(mainwin->summaryview);
1775 case TOOLBAR_MSGVIEW:
1776 /* TODO: see toolbar_next_unread_cb() if you need
1777 * this in the message view */
1780 debug_print("toolbar event not supported\n");
1785 static void toolbar_send_cb(GtkWidget *widget, gpointer data)
1787 compose_toolbar_cb(A_SEND, data);
1790 static void toolbar_send_later_cb(GtkWidget *widget, gpointer data)
1792 compose_toolbar_cb(A_SEND_LATER, data);
1795 static void toolbar_draft_cb(GtkWidget *widget, gpointer data)
1797 compose_toolbar_cb(A_DRAFT, data);
1800 static void toolbar_close_cb(GtkWidget *widget, gpointer data)
1802 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1803 MainWindow *mainwin;
1804 MessageView *messageview;
1807 cm_return_if_fail(toolbar_item != NULL);
1809 switch (toolbar_item->type) {
1811 mainwin = (MainWindow *) toolbar_item->parent;
1812 app_will_exit(NULL, mainwin);
1814 case TOOLBAR_MSGVIEW:
1815 messageview = (MessageView *)toolbar_item->parent;
1816 messageview_destroy(messageview);
1818 case TOOLBAR_COMPOSE:
1819 compose = (Compose *)toolbar_item->parent;
1820 compose_close_toolbar(compose);
1825 static void toolbar_preferences_cb(GtkWidget *widget, gpointer data)
1830 static void toolbar_open_mail_cb(GtkWidget *widget, gpointer data)
1832 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1833 MainWindow *mainwin;
1835 cm_return_if_fail(toolbar_item != NULL);
1837 switch (toolbar_item->type) {
1839 mainwin = (MainWindow *) toolbar_item->parent;
1840 summary_open_row(NULL, mainwin->summaryview);
1842 case TOOLBAR_MSGVIEW:
1843 debug_print("toolbar event not supported\n");
1845 case TOOLBAR_COMPOSE:
1846 debug_print("toolbar event not supported\n");
1851 static void toolbar_insert_cb(GtkWidget *widget, gpointer data)
1853 compose_toolbar_cb(A_INSERT, data);
1856 static void toolbar_attach_cb(GtkWidget *widget, gpointer data)
1858 compose_toolbar_cb(A_ATTACH, data);
1861 static void toolbar_sig_cb(GtkWidget *widget, gpointer data)
1863 compose_toolbar_cb(A_SIG, data);
1866 static void toolbar_replace_sig_cb(GtkWidget *widget, gpointer data)
1868 compose_toolbar_cb(A_REP_SIG, data);
1871 static void toolbar_ext_editor_cb(GtkWidget *widget, gpointer data)
1873 compose_toolbar_cb(A_EXTEDITOR, data);
1876 static void toolbar_linewrap_current_cb(GtkWidget *widget, gpointer data)
1878 compose_toolbar_cb(A_LINEWRAP_CURRENT, data);
1881 static void toolbar_linewrap_all_cb(GtkWidget *widget, gpointer data)
1883 compose_toolbar_cb(A_LINEWRAP_ALL, data);
1887 static void toolbar_check_spelling_cb(GtkWidget *widget, gpointer data)
1889 compose_toolbar_cb(A_CHECK_SPELLING, data);
1893 * Execute actions from toolbar
1895 static void toolbar_actions_execute_cb(GtkWidget *widget, gpointer data)
1897 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1898 GSList *action_list;
1899 MainWindow *mainwin;
1901 MessageView *msgview;
1902 gpointer parent = toolbar_item->parent;
1904 cm_return_if_fail(toolbar_item != NULL);
1906 switch (toolbar_item->type) {
1908 mainwin = (MainWindow*)parent;
1909 action_list = mainwin->toolbar->action_list;
1911 case TOOLBAR_COMPOSE:
1912 compose = (Compose*)parent;
1913 action_list = compose->toolbar->action_list;
1915 case TOOLBAR_MSGVIEW:
1916 msgview = (MessageView*)parent;
1917 action_list = msgview->toolbar->action_list;
1920 debug_print("toolbar event not supported\n");
1923 toolbar_action_execute(widget, action_list, parent, toolbar_item->type);
1926 static void toolbar_plugins_execute_cb(GtkWidget *widget, gpointer data)
1928 ToolbarItem *toolbar_item = data;
1929 prefs_toolbar_execute_plugin_item(toolbar_item->parent, toolbar_item->type, toolbar_item->text);
1932 static MainWindow *get_mainwin(gpointer data)
1934 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1935 MainWindow *mainwin = NULL;
1936 MessageView *msgview;
1938 cm_return_val_if_fail(toolbar_item != NULL, NULL);
1940 switch(toolbar_item->type) {
1942 mainwin = (MainWindow*)toolbar_item->parent;
1944 case TOOLBAR_MSGVIEW:
1945 msgview = (MessageView*)toolbar_item->parent;
1946 mainwin = (MainWindow*)msgview->mainwin;
1955 static void toolbar_go_folders_cb(GtkWidget *widget, gpointer data)
1957 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1958 MainWindow *mainwin = NULL;
1959 switch(toolbar_item->type) {
1961 mainwin = (MainWindow*)toolbar_item->parent;
1964 g_warning("wrong toolbar type");
1968 if (!mainwin->in_folder) {
1969 FolderItem *item = folderview_get_selected_item(mainwin->folderview);
1971 folderview_select(mainwin->folderview, item);
1974 folderview_grab_focus(mainwin->folderview);
1975 mainwindow_exit_folder(mainwin);
1979 static void toolbar_buttons_cb(GtkWidget *widget,
1986 void (*func)(GtkWidget *widget, gpointer data);
1988 { A_RECEIVE_ALL, toolbar_inc_all_cb },
1989 { A_RECEIVE_CUR, toolbar_inc_cb },
1990 { A_SEND_QUEUED, toolbar_send_queued_cb },
1991 { A_COMPOSE_EMAIL, toolbar_compose_cb },
1992 { A_COMPOSE_NEWS, toolbar_compose_cb },
1993 { A_REPLY_MESSAGE, toolbar_reply_cb },
1994 { A_REPLY_SENDER, toolbar_reply_to_sender_cb },
1995 { A_REPLY_ALL, toolbar_reply_to_all_cb },
1996 { A_REPLY_ML, toolbar_reply_to_list_cb },
1997 { A_FORWARD, toolbar_forward_cb },
1998 { A_TRASH, toolbar_trash_cb },
1999 { A_DELETE_REAL, toolbar_delete_cb },
2000 { A_EXECUTE, toolbar_exec_cb },
2001 { A_GOTO_PREV, toolbar_prev_unread_cb },
2002 { A_GOTO_NEXT, toolbar_next_unread_cb },
2003 { A_IGNORE_THREAD, toolbar_ignore_thread_cb },
2004 { A_WATCH_THREAD, toolbar_watch_thread_cb },
2005 { A_MARK, toolbar_mark_cb },
2006 { A_UNMARK, toolbar_unmark_cb },
2007 { A_LOCK, toolbar_lock_cb },
2008 { A_UNLOCK, toolbar_unlock_cb },
2009 { A_ALL_READ, toolbar_all_read_cb },
2010 { A_ALL_UNREAD, toolbar_all_unread_cb },
2011 { A_READ, toolbar_read_cb },
2012 { A_UNREAD, toolbar_unread_cb },
2013 { A_PRINT, toolbar_print_cb },
2014 { A_LEARN_SPAM, toolbar_learn_cb },
2015 { A_DELETE_DUP, toolbar_delete_dup_cb },
2016 { A_GO_FOLDERS, toolbar_go_folders_cb },
2018 { A_SEND, toolbar_send_cb },
2019 { A_SEND_LATER, toolbar_send_later_cb },
2020 { A_DRAFT, toolbar_draft_cb },
2021 { A_OPEN_MAIL, toolbar_open_mail_cb },
2022 { A_CLOSE, toolbar_close_cb },
2023 { A_PREFERENCES, toolbar_preferences_cb },
2024 { A_INSERT, toolbar_insert_cb },
2025 { A_ATTACH, toolbar_attach_cb },
2026 { A_SIG, toolbar_sig_cb },
2027 { A_REP_SIG, toolbar_replace_sig_cb },
2028 { A_EXTEDITOR, toolbar_ext_editor_cb },
2029 { A_LINEWRAP_CURRENT, toolbar_linewrap_current_cb },
2030 { A_LINEWRAP_ALL, toolbar_linewrap_all_cb },
2031 { A_ADDRBOOK, toolbar_addrbook_cb },
2033 { A_CHECK_SPELLING, toolbar_check_spelling_cb },
2035 { A_CLAWS_ACTIONS, toolbar_actions_execute_cb },
2036 { A_CANCEL_INC, toolbar_cancel_inc_cb },
2037 { A_CANCEL_SEND, toolbar_cancel_send_cb },
2038 { A_CANCEL_ALL, toolbar_cancel_all_cb },
2039 { A_CLAWS_PLUGINS, toolbar_plugins_execute_cb },
2042 num_items = sizeof(callbacks)/sizeof(callbacks[0]);
2044 for (i = 0; i < num_items; i++) {
2045 if (callbacks[i].index == item->index) {
2046 callbacks[i].func(widget, item);
2051 #ifndef GENERIC_UMPC
2052 #define TOOLBAR_ITEM(item,icon,text,tooltip) { \
2053 item = GTK_WIDGET(gtk_tool_button_new(icon, text)); \
2054 gtkut_widget_set_can_focus(gtk_bin_get_child(GTK_BIN(item)), FALSE); \
2055 gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE); \
2056 gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE); \
2057 g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item); \
2058 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1); \
2059 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(item), \
2063 #define TOOLBAR_MENUITEM(item,icon,text,tooltip,menutip) { \
2064 GtkWidget *child = NULL, *btn = NULL, *arr = NULL; \
2065 GList *gchild = NULL; \
2066 item = GTK_WIDGET(gtk_menu_tool_button_new(icon, text)); \
2067 gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE); \
2068 gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE); \
2069 g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item); \
2070 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1); \
2071 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(item), \
2073 CLAWS_SET_ARROW_TIP(GTK_MENU_TOOL_BUTTON(item), menutip); \
2074 child = gtk_bin_get_child(GTK_BIN(item)); \
2075 gchild = gtk_container_get_children( \
2076 GTK_CONTAINER(child)); \
2077 btn = (GtkWidget *)gchild->data; \
2078 gtkut_widget_set_can_focus(btn, FALSE); \
2079 arr = (GtkWidget *)(gchild->next?gchild->next->data:NULL); \
2080 gtkut_widget_set_can_focus(arr, FALSE); \
2081 g_list_free(gchild); \
2082 gchild = gtk_container_get_children(GTK_CONTAINER(arr)); \
2083 gtk_widget_set_size_request(GTK_WIDGET(gchild->data), 9, -1); \
2084 g_list_free(gchild); \
2087 #define TOOLBAR_ITEM(item,icon,text,tooltip) { \
2088 item = GTK_WIDGET(gtk_tool_button_new(icon, text)); \
2089 gtkut_widget_set_can_focus(gtk_bin_get_child(GTK_BIN(item)), FALSE); \
2090 gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE); \
2091 gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE); \
2092 g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item); \
2093 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1); \
2096 #define TOOLBAR_MENUITEM(item,icon,text,tooltip,menutip) { \
2097 GtkWidget *child = NULL, *btn = NULL, *arr = NULL; \
2098 GList *gchild = NULL; \
2099 item = GTK_WIDGET(gtk_menu_tool_button_new(icon, text)); \
2100 gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE); \
2101 gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE); \
2102 g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item); \
2103 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1); \
2104 child = gtk_bin_get_child(GTK_BIN(item)); \
2105 gchild = gtk_container_get_children( \
2106 GTK_CONTAINER(child)); \
2107 btn = (GtkWidget *)gchild->data; \
2108 gtkut_widget_set_can_focus(btn, FALSE); \
2109 arr = (GtkWidget *)(gchild->next?gchild->next->data:NULL); \
2110 gtkut_widget_set_can_focus(arr, FALSE); \
2111 g_list_free(gchild); \
2112 gchild = gtk_container_get_children(GTK_CONTAINER(arr)); \
2113 gtk_widget_set_size_request(GTK_WIDGET(gchild->data), 9, -1); \
2114 g_list_free(gchild); \
2118 #define ADD_MENU_ITEM(name,cb,data) { \
2119 item = gtk_menu_item_new_with_mnemonic(name); \
2120 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); \
2121 g_signal_connect(G_OBJECT(item), "activate", \
2124 g_object_set_data(G_OBJECT(item), "int-value", GINT_TO_POINTER(data)); \
2125 gtk_widget_show(item); \
2128 static void toolbar_reply_menu_cb(GtkWidget *widget, gpointer data)
2130 gpointer int_value = g_object_get_data(G_OBJECT(widget), "int-value");
2131 ToolbarItem *toolbar_item = (ToolbarItem *)data;
2133 toolbar_reply(toolbar_item, GPOINTER_TO_INT(int_value));
2136 static void toolbar_learn_menu_cb(GtkWidget *widget, gpointer data)
2138 gpointer int_value = g_object_get_data(G_OBJECT(widget), "int-value");
2139 ToolbarItem *toolbar_item = (ToolbarItem *)data;
2141 toolbar_learn(toolbar_item, GPOINTER_TO_INT(int_value));
2144 static void toolbar_delete_dup_menu_cb(GtkWidget *widget, gpointer data)
2146 gpointer int_value = g_object_get_data(G_OBJECT(widget), "int-value");
2147 ToolbarItem *toolbar_item = (ToolbarItem *)data;
2149 toolbar_delete_dup(toolbar_item, GPOINTER_TO_INT(int_value));
2153 * Create a new toolbar with specified type
2154 * if a callback list is passed it will be used before the
2155 * common callback list
2157 Toolbar *toolbar_create(ToolbarType type,
2158 GtkWidget *container,
2161 ToolbarItem *toolbar_item;
2164 GtkWidget *icon_wid = NULL;
2165 GtkWidget *icon_news;
2166 GtkWidget *icon_ham;
2168 ToolbarClawsActions *action_item;
2170 GSList *toolbar_list;
2171 Toolbar *toolbar_data;
2173 toolbar_read_config_file(type);
2174 toolbar_list = toolbar_get_list(type);
2176 toolbar_data = g_new0(Toolbar, 1);
2178 toolbar = gtk_toolbar_new();
2180 gtk_orientable_set_orientation(GTK_ORIENTABLE(toolbar), GTK_ORIENTATION_HORIZONTAL);
2182 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_BOTH);
2183 gtk_toolbar_set_show_arrow(GTK_TOOLBAR(toolbar), TRUE);
2185 for (cur = toolbar_list; cur != NULL; cur = cur->next) {
2187 if (g_ascii_strcasecmp(((ToolbarItem*)cur->data)->file, TOOLBAR_TAG_SEPARATOR) == 0) {
2188 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), gtk_separator_tool_item_new(), -1);
2192 toolbar_item = g_new0(ToolbarItem, 1);
2193 toolbar_item->index = ((ToolbarItem*)cur->data)->index;
2194 toolbar_item->file = g_strdup(((ToolbarItem*)cur->data)->file);
2195 toolbar_item->text = g_strdup(((ToolbarItem*)cur->data)->text);
2196 toolbar_item->parent = data;
2197 toolbar_item->type = type;
2199 /* collect toolbar items in list to keep track */
2200 toolbar_data->item_list =
2201 g_slist_append(toolbar_data->item_list,
2203 icon_wid = stock_pixmap_widget(stock_pixmap_get_icon(toolbar_item->file));
2205 switch (toolbar_item->index) {
2208 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Go to folder list"));
2209 toolbar_data->folders_btn = item;
2212 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2213 _("Receive Mail from all Accounts"),
2214 _("Receive Mail from selected Account"));
2215 toolbar_data->getall_btn = item;
2218 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Receive Mail from current Account"));
2219 toolbar_data->get_btn = item;
2222 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Send Queued Messages"));
2223 toolbar_data->send_btn = item;
2226 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Close window"));
2227 toolbar_data->close_window_btn = item;
2230 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Open preferences"));
2231 toolbar_data->preferences_btn = item;
2234 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Open email"));
2235 toolbar_data->open_mail_btn = item;
2237 case A_COMPOSE_EMAIL:
2238 #ifndef GENERIC_UMPC
2239 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2241 _("Compose with selected Account"));
2242 toolbar_data->compose_mail_btn = item;
2243 toolbar_data->compose_mail_icon = icon_wid;
2244 g_object_ref(toolbar_data->compose_mail_icon);
2246 icon_news = stock_pixmap_widget(STOCK_PIXMAP_NEWS_COMPOSE);
2247 toolbar_data->compose_news_icon = icon_news;
2248 g_object_ref(toolbar_data->compose_news_icon);
2250 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2251 _("Compose Email"));
2252 toolbar_data->compose_mail_btn = item;
2253 toolbar_data->compose_mail_icon = icon_wid;
2255 icon_news = stock_pixmap_widget(STOCK_PIXMAP_NEWS_COMPOSE);
2256 toolbar_data->compose_news_icon = icon_news;
2260 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2263 toolbar_data->learn_spam_btn = item;
2264 toolbar_data->learn_spam_icon = icon_wid;
2265 g_object_ref(toolbar_data->learn_spam_icon);
2267 icon_ham = stock_pixmap_widget(STOCK_PIXMAP_HAM_BTN);
2268 toolbar_data->learn_ham_icon = icon_ham;
2269 g_object_ref(toolbar_data->learn_ham_icon);
2271 menu = gtk_menu_new();
2272 ADD_MENU_ITEM(_("Learn as _Spam"), toolbar_learn_menu_cb, TRUE);
2273 ADD_MENU_ITEM(_("Learn as _Ham"), toolbar_learn_menu_cb, FALSE);
2274 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->learn_spam_btn), menu);
2277 #ifndef GENERIC_UMPC
2278 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2279 _("Delete duplicates"),
2280 _("Delete duplicates options"));
2281 toolbar_data->delete_dup_btn = item;
2283 menu = gtk_menu_new();
2284 ADD_MENU_ITEM(_("Delete duplicates in selected folder"), toolbar_delete_dup_menu_cb, FALSE);
2285 ADD_MENU_ITEM(_("Delete duplicates in all folders"), toolbar_delete_dup_menu_cb, TRUE);
2286 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->delete_dup_btn), menu);
2288 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Delete duplicates"));
2289 toolbar_data->delete_dup_btn = item;
2292 case A_REPLY_MESSAGE:
2293 #ifndef GENERIC_UMPC
2294 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2295 _("Reply to Message"),
2296 _("Reply to Message options"));
2297 toolbar_data->reply_btn = item;
2299 menu = gtk_menu_new();
2300 ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_WITH_QUOTE);
2301 ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_WITHOUT_QUOTE);
2302 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->reply_btn), menu);
2304 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2305 _("Reply to Message"));
2306 toolbar_data->reply_btn = item;
2309 case A_REPLY_SENDER:
2310 #ifndef GENERIC_UMPC
2311 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2312 _("Reply to Sender"),
2313 _("Reply to Sender options"));
2314 toolbar_data->replysender_btn = item;
2316 menu = gtk_menu_new();
2317 ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE);
2318 ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE);
2319 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->replysender_btn), menu);
2321 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2322 _("Reply to Sender"));
2323 toolbar_data->replysender_btn = item;
2327 #ifndef GENERIC_UMPC
2328 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2330 _("Reply to All options"));
2331 toolbar_data->replyall_btn = item;
2333 menu = gtk_menu_new();
2334 ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE);
2335 ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE);
2336 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->replyall_btn), menu);
2338 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2340 toolbar_data->replyall_btn = item;
2344 #ifndef GENERIC_UMPC
2345 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2346 _("Reply to Mailing-list"),
2347 _("Reply to Mailing-list options"));
2348 toolbar_data->replylist_btn = item;
2350 menu = gtk_menu_new();
2351 ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_LIST_WITH_QUOTE);
2352 ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE);
2353 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->replylist_btn), menu);
2355 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2356 _("Reply to Mailing-list"));
2357 toolbar_data->replylist_btn = item;
2361 #ifndef GENERIC_UMPC
2362 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2363 _("Forward Message"),
2364 _("Forward Message options"));
2365 toolbar_data->fwd_btn = item;
2367 menu = gtk_menu_new();
2368 ADD_MENU_ITEM(_("_Forward"), toolbar_reply_menu_cb, COMPOSE_FORWARD_INLINE);
2369 ADD_MENU_ITEM(_("For_ward as attachment"), toolbar_reply_menu_cb, COMPOSE_FORWARD_AS_ATTACH);
2370 ADD_MENU_ITEM(_("Redirec_t"), toolbar_reply_menu_cb, COMPOSE_REDIRECT);
2371 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->fwd_btn), menu);
2373 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2374 _("Forward Message"));
2375 toolbar_data->fwd_btn = item;
2379 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Trash Message"));
2380 toolbar_data->trash_btn = item;
2383 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Delete Message"));
2384 toolbar_data->delete_btn = item;
2387 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Execute"));
2388 toolbar_data->exec_btn = item;
2391 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Go to Previous Unread Message"));
2392 toolbar_data->prev_btn = item;
2395 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Go to Next Unread Message"));
2396 toolbar_data->next_btn = item;
2399 /* Compose Toolbar */
2401 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Send Message"));
2402 toolbar_data->send_btn = item;
2405 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Put into queue folder and send later"));
2406 toolbar_data->sendl_btn = item;
2409 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Save to draft folder"));
2410 toolbar_data->draft_btn = item;
2413 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Insert file"));
2414 toolbar_data->insert_btn = item;
2417 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Attach file"));
2418 toolbar_data->attach_btn = item;
2421 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Insert signature"));
2422 toolbar_data->sig_btn = item;
2425 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Replace signature"));
2426 toolbar_data->repsig_btn = item;
2429 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Edit with external editor"));
2430 toolbar_data->exteditor_btn = item;
2432 case A_LINEWRAP_CURRENT:
2433 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Wrap long lines of current paragraph"));
2434 toolbar_data->linewrap_current_btn = item;
2436 case A_LINEWRAP_ALL:
2437 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Wrap all long lines"));
2438 toolbar_data->linewrap_all_btn = item;
2441 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Address book"));
2442 toolbar_data->addrbook_btn = item;
2445 case A_CHECK_SPELLING:
2446 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Check spelling"));
2447 toolbar_data->spellcheck_btn = item;
2451 case A_CLAWS_ACTIONS:
2452 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,toolbar_item->text);
2453 action_item = g_new0(ToolbarClawsActions, 1);
2454 action_item->widget = item;
2455 action_item->name = g_strdup(toolbar_item->text);
2457 toolbar_data->action_list =
2458 g_slist_append(toolbar_data->action_list,
2462 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Cancel receiving"));
2463 toolbar_data->cancel_inc_btn = item;
2466 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Cancel sending"));
2467 toolbar_data->cancel_send_btn = item;
2470 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Cancel receiving/sending"));
2471 toolbar_data->cancel_all_btn = item;
2473 case A_CLAWS_PLUGINS:
2474 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text, toolbar_item->text);
2477 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2478 toolbar_ret_descr_from_val(toolbar_item->index));
2479 /* find and set the tool tip text */
2484 toolbar_data->toolbar = toolbar;
2486 gtk_widget_show_all(toolbar);
2488 if (type == TOOLBAR_MAIN) {
2490 MainWindow *mainwin = mainwindow_get_mainwindow();
2491 GtkWidget *progressbar = gtk_progress_bar_new();
2492 item = GTK_WIDGET(gtk_tool_item_new());
2493 gtk_container_add (GTK_CONTAINER (item), progressbar);
2494 gtk_widget_show(item);
2495 gtk_widget_set_size_request(progressbar, 84, -1);
2496 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1);
2497 mainwin->progressbar = progressbar;
2499 activate_compose_button(toolbar_data,
2500 prefs_common.toolbar_style,
2501 toolbar_data->compose_btn_type);
2503 if (type != TOOLBAR_COMPOSE)
2504 activate_learn_button(toolbar_data, prefs_common.toolbar_style,
2507 gtk_container_add(GTK_CONTAINER(container), toolbar);
2508 gtk_container_set_border_width(GTK_CONTAINER(container), 0);
2510 return toolbar_data;
2514 * Free toolbar structures
2516 void toolbar_destroy(Toolbar * toolbar) {
2518 TOOLBAR_DESTROY_ITEMS(toolbar->item_list);
2519 TOOLBAR_DESTROY_ACTIONS(toolbar->action_list);
2522 void toolbar_update(ToolbarType type, gpointer data)
2524 Toolbar *toolbar_data;
2525 GtkWidget *handlebox;
2526 MainWindow *mainwin = (MainWindow*)data;
2527 Compose *compose = (Compose*)data;
2528 MessageView *msgview = (MessageView*)data;
2530 #ifndef GENERIC_UMPC
2533 toolbar_data = mainwin->toolbar;
2534 handlebox = mainwin->handlebox;
2536 case TOOLBAR_COMPOSE:
2537 toolbar_data = compose->toolbar;
2538 handlebox = compose->handlebox;
2540 case TOOLBAR_MSGVIEW:
2541 toolbar_data = msgview->toolbar;
2542 handlebox = msgview->handlebox;
2548 gtk_container_remove(GTK_CONTAINER(handlebox),
2549 GTK_WIDGET(toolbar_data->toolbar));
2551 toolbar_init(toolbar_data);
2552 toolbar_data = toolbar_create(type, handlebox, data);
2556 toolbar_data = mainwin->toolbar;
2557 handlebox = mainwin->window;
2559 case TOOLBAR_COMPOSE:
2560 toolbar_data = compose->toolbar;
2561 handlebox = compose->window;
2563 case TOOLBAR_MSGVIEW:
2564 toolbar_data = msgview->toolbar;
2565 handlebox = msgview->window;
2570 toolbar_init(toolbar_data);
2571 toolbar_data = toolbar_create(type, handlebox, data);
2576 mainwin->toolbar = toolbar_data;
2578 case TOOLBAR_COMPOSE:
2579 compose->toolbar = toolbar_data;
2581 case TOOLBAR_MSGVIEW:
2582 msgview->toolbar = toolbar_data;
2586 toolbar_style(type, prefs_common.toolbar_style, data);
2588 if (type == TOOLBAR_MAIN) {
2589 toolbar_main_set_sensitive((MainWindow*)data);
2590 account_set_menu_only_toolbar();
2594 #define GTK_BUTTON_SET_SENSITIVE(widget,sensitive) { \
2595 gtk_widget_set_sensitive(widget, sensitive); \
2598 void toolbar_main_set_sensitive(gpointer data)
2600 SensitiveCondMask state;
2602 MainWindow *mainwin = (MainWindow*)data;
2603 Toolbar *toolbar = mainwin->toolbar;
2605 GSList *entry_list = NULL;
2607 typedef struct _Entry Entry;
2610 SensitiveCondMask cond;
2614 #define SET_WIDGET_COND(w, ...) \
2616 Entry *e = g_new0(Entry, 1); \
2618 e->cond = main_window_get_mask(__VA_ARGS__, -1); \
2619 entry_list = g_slist_append(entry_list, e); \
2622 /* match all bit flags */
2624 if (toolbar->get_btn)
2625 SET_WIDGET_COND(toolbar->get_btn,
2626 M_HAVE_ACCOUNT, M_UNLOCKED, M_HAVE_RETRIEVABLE_ACCOUNT);
2628 if (toolbar->getall_btn) {
2629 SET_WIDGET_COND(toolbar->getall_btn,
2630 M_HAVE_ACCOUNT, M_UNLOCKED, M_HAVE_ANY_RETRIEVABLE_ACCOUNT);
2632 if (toolbar->send_btn) {
2633 SET_WIDGET_COND(toolbar->send_btn,
2634 M_HAVE_QUEUED_MAILS);
2636 if (toolbar->compose_mail_btn) {
2637 SET_WIDGET_COND(toolbar->compose_mail_btn,
2640 if (toolbar->close_window_btn) {
2641 SET_WIDGET_COND(toolbar->close_window_btn,
2644 if (toolbar->open_mail_btn) {
2645 SET_WIDGET_COND(toolbar->open_mail_btn,
2646 M_TARGET_EXIST, M_SUMMARY_ISLIST);
2648 if (toolbar->reply_btn) {
2649 SET_WIDGET_COND(toolbar->reply_btn,
2650 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2652 if (toolbar->replyall_btn) {
2653 SET_WIDGET_COND(toolbar->replyall_btn,
2654 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2656 if (toolbar->replylist_btn) {
2657 SET_WIDGET_COND(toolbar->replylist_btn,
2658 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2660 if (toolbar->replysender_btn) {
2661 SET_WIDGET_COND(toolbar->replysender_btn,
2662 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2664 if (toolbar->fwd_btn) {
2665 SET_WIDGET_COND(toolbar->fwd_btn,
2666 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2669 if (prefs_common.next_unread_msg_dialog == NEXTUNREADMSGDIALOG_ASSUME_NO) {
2670 SET_WIDGET_COND(toolbar->next_btn, M_MSG_EXIST, M_SUMMARY_ISLIST);
2672 SET_WIDGET_COND(toolbar->next_btn, -1);
2675 if (toolbar->trash_btn)
2676 SET_WIDGET_COND(toolbar->trash_btn,
2677 M_TARGET_EXIST, M_ALLOW_DELETE, M_NOT_NEWS);
2679 if (toolbar->delete_btn)
2680 SET_WIDGET_COND(toolbar->delete_btn,
2681 M_TARGET_EXIST, M_ALLOW_DELETE);
2683 if (toolbar->delete_dup_btn)
2684 SET_WIDGET_COND(toolbar->delete_dup_btn,
2685 M_MSG_EXIST, M_ALLOW_DELETE, M_SUMMARY_ISLIST);
2687 if (toolbar->exec_btn)
2688 SET_WIDGET_COND(toolbar->exec_btn,
2691 if (toolbar->learn_spam_btn)
2692 SET_WIDGET_COND(toolbar->learn_spam_btn,
2693 M_TARGET_EXIST, M_CAN_LEARN_SPAM, M_SUMMARY_ISLIST);
2695 if (toolbar->cancel_inc_btn)
2696 SET_WIDGET_COND(toolbar->cancel_inc_btn,
2699 if (toolbar->cancel_send_btn)
2700 SET_WIDGET_COND(toolbar->cancel_send_btn,
2703 for (cur = toolbar->action_list; cur != NULL; cur = cur->next) {
2704 ToolbarClawsActions *act = (ToolbarClawsActions*)cur->data;
2706 SET_WIDGET_COND(act->widget, M_TARGET_EXIST, M_UNLOCKED);
2709 state = main_window_get_current_state(mainwin);
2711 for (cur = entry_list; cur != NULL; cur = cur->next) {
2712 Entry *e = (Entry*) cur->data;
2714 if (e->widget != NULL) {
2715 sensitive = ((e->cond & state) == e->cond);
2716 GTK_BUTTON_SET_SENSITIVE(e->widget, sensitive);
2720 while (entry_list != NULL) {
2721 Entry *e = (Entry*) entry_list->data;
2724 entry_list = g_slist_remove(entry_list, e);
2727 /* match any bit flags */
2729 if (toolbar->cancel_all_btn)
2730 SET_WIDGET_COND(toolbar->cancel_all_btn,
2731 M_INC_ACTIVE, M_SEND_ACTIVE);
2733 for (cur = entry_list; cur != NULL; cur = cur->next) {
2734 Entry *e = (Entry*) cur->data;
2736 if (e->widget != NULL) {
2737 sensitive = ((e->cond & state) != 0);
2738 GTK_BUTTON_SET_SENSITIVE(e->widget, sensitive);
2742 while (entry_list != NULL) {
2743 Entry *e = (Entry*) entry_list->data;
2746 entry_list = g_slist_remove(entry_list, e);
2749 g_slist_free(entry_list);
2751 activate_compose_button(toolbar,
2752 prefs_common.toolbar_style,
2753 toolbar->compose_btn_type);
2755 #undef SET_WIDGET_COND
2758 void toolbar_comp_set_sensitive(gpointer data, gboolean sensitive)
2760 Compose *compose = (Compose*)data;
2761 GSList *items = compose->toolbar->action_list;
2763 if (compose->toolbar->send_btn)
2764 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->send_btn, sensitive);
2765 if (compose->toolbar->sendl_btn)
2766 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->sendl_btn, sensitive);
2767 if (compose->toolbar->draft_btn )
2768 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->draft_btn , sensitive);
2769 if (compose->toolbar->insert_btn )
2770 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->insert_btn , sensitive);
2771 if (compose->toolbar->attach_btn)
2772 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->attach_btn, sensitive);
2773 if (compose->toolbar->sig_btn)
2774 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->sig_btn, sensitive);
2775 if (compose->toolbar->repsig_btn)
2776 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->repsig_btn, sensitive);
2777 if (compose->toolbar->exteditor_btn)
2778 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->exteditor_btn, sensitive);
2779 if (compose->toolbar->linewrap_current_btn)
2780 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->linewrap_current_btn, sensitive);
2781 if (compose->toolbar->linewrap_all_btn)
2782 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->linewrap_all_btn, sensitive);
2783 if (compose->toolbar->addrbook_btn)
2784 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->addrbook_btn, sensitive);
2786 if (compose->toolbar->spellcheck_btn)
2787 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->spellcheck_btn, sensitive);
2789 for (; items != NULL; items = g_slist_next(items)) {
2790 ToolbarClawsActions *item = (ToolbarClawsActions *)items->data;
2791 GTK_BUTTON_SET_SENSITIVE(item->widget, sensitive);
2796 * Initialize toolbar structure
2798 static void toolbar_init(Toolbar * toolbar)
2801 toolbar->toolbar = NULL;
2802 toolbar->folders_btn = NULL;
2803 toolbar->get_btn = NULL;
2804 toolbar->getall_btn = NULL;
2805 toolbar->send_btn = NULL;
2806 toolbar->compose_mail_btn = NULL;
2807 toolbar->compose_mail_icon = NULL;
2808 toolbar->compose_news_icon = NULL;
2809 toolbar->reply_btn = NULL;
2810 toolbar->replysender_btn = NULL;
2811 toolbar->replyall_btn = NULL;
2812 toolbar->replylist_btn = NULL;
2813 toolbar->fwd_btn = NULL;
2814 toolbar->trash_btn = NULL;
2815 toolbar->delete_btn = NULL;
2816 toolbar->delete_dup_btn = NULL;
2817 toolbar->prev_btn = NULL;
2818 toolbar->next_btn = NULL;
2819 toolbar->exec_btn = NULL;
2820 toolbar->separator = NULL;
2821 toolbar->learn_spam_btn = NULL;
2822 toolbar->learn_spam_icon = NULL;
2823 toolbar->learn_ham_icon = NULL;
2824 toolbar->cancel_inc_btn = NULL;
2825 toolbar->cancel_send_btn = NULL;
2826 toolbar->cancel_all_btn = NULL;
2828 /* compose buttons */
2829 toolbar->sendl_btn = NULL;
2830 toolbar->draft_btn = NULL;
2831 toolbar->insert_btn = NULL;
2832 toolbar->attach_btn = NULL;
2833 toolbar->sig_btn = NULL;
2834 toolbar->repsig_btn = NULL;
2835 toolbar->exteditor_btn = NULL;
2836 toolbar->linewrap_current_btn = NULL;
2837 toolbar->linewrap_all_btn = NULL;
2838 toolbar->addrbook_btn = NULL;
2840 toolbar->open_mail_btn = NULL;
2841 toolbar->close_window_btn = NULL;
2842 toolbar->preferences_btn = NULL;
2843 toolbar->action_list = NULL;
2844 toolbar->item_list = NULL;
2846 toolbar->spellcheck_btn = NULL;
2849 toolbar_destroy(toolbar);
2854 static void toolbar_reply(gpointer data, guint action)
2856 ToolbarItem *toolbar_item = (ToolbarItem*)data;
2857 MainWindow *mainwin;
2858 MessageView *msgview;
2859 GSList *msginfo_list = NULL;
2861 cm_return_if_fail(toolbar_item != NULL);
2863 switch (toolbar_item->type) {
2865 mainwin = (MainWindow*)toolbar_item->parent;
2866 msginfo_list = summary_get_selection(mainwin->summaryview);
2867 msgview = (MessageView*)mainwin->messageview;
2869 case TOOLBAR_MSGVIEW:
2870 msgview = (MessageView*)toolbar_item->parent;
2871 cm_return_if_fail(msgview != NULL);
2872 msginfo_list = g_slist_append(msginfo_list, msgview->msginfo);
2878 cm_return_if_fail(msgview != NULL);
2879 cm_return_if_fail(msginfo_list != NULL);
2880 compose_reply_from_messageview(msgview, msginfo_list, action);
2881 g_slist_free(msginfo_list);
2883 /* TODO: update reply state ion summaryview */
2887 /* exported functions */
2889 void inc_mail_cb(gpointer data, guint action, GtkWidget *widget)
2891 MainWindow *mainwin = (MainWindow*)data;
2893 inc_mail(mainwin, prefs_common.newmail_notify_manu);
2896 void inc_all_account_mail_cb(gpointer data, guint action, GtkWidget *widget)
2898 MainWindow *mainwin = (MainWindow*)data;
2900 inc_all_account_mail(mainwin, FALSE, prefs_common.newmail_notify_manu);
2903 void send_queue_cb(gpointer data, guint action, GtkWidget *widget)
2907 gboolean got_error = FALSE;
2908 gchar *errstr = NULL;
2910 if (prefs_common.work_offline)
2911 if (alertpanel(_("Offline warning"),
2912 _("You're working offline. Override?"),
2913 GTK_STOCK_NO, GTK_STOCK_YES,
2914 NULL) != G_ALERTALTERNATE)
2917 /* ask for confirmation before sending queued messages only
2918 in online mode and if there is at least one message queued
2919 in any of the folder queue
2921 if (prefs_common.confirm_send_queued_messages) {
2923 /* check if there's a queued message */
2924 for (list = folder_get_list(); !found && list != NULL; list = list->next) {
2925 Folder *folder = list->data;
2927 found = !procmsg_queue_is_empty(folder->queue);
2929 /* if necessary, ask for confirmation before sending */
2930 if (found && !prefs_common.work_offline) {
2931 if (alertpanel(_("Send queued messages"),
2932 _("Send all queued messages?"),
2933 GTK_STOCK_CANCEL, _("_Send"),
2934 NULL) != G_ALERTALTERNATE)
2939 for (list = folder_get_list(); list != NULL; list = list->next) {
2940 Folder *folder = list->data;
2942 if (folder->queue) {
2943 if (procmsg_send_queue(folder->queue,
2944 prefs_common.savemsg,
2951 alertpanel_error_log(_("Some errors occurred while "
2952 "sending queued messages."));
2954 alertpanel_error_log(_("Some errors occurred "
2955 "while sending queued messages:\n%s"), errstr);
2961 void compose_mail_cb(gpointer data, guint action, GtkWidget *widget)
2963 MainWindow *mainwin = (MainWindow*)data;
2964 PrefsAccount *ac = NULL;
2965 FolderItem *item = mainwin->summaryview->folder_item;
2970 ac = account_find_from_item(item);
2971 if (ac && ac->protocol != A_NNTP && ac->protocol != A_IMAP4) {
2972 compose_new_with_folderitem(ac, item, NULL); /* CLAWS */
2978 * CLAWS - use current account
2980 if (cur_account && (cur_account->protocol != A_NNTP)) {
2981 compose_new_with_folderitem(cur_account, item, NULL);
2986 * CLAWS - just get the first one
2988 list = account_get_list();
2989 for (cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2990 ac = (PrefsAccount *) cur->data;
2991 if (ac->protocol != A_NNTP) {
2992 compose_new_with_folderitem(ac, item, NULL);
2998 void compose_news_cb(gpointer data, guint action, GtkWidget *widget)
3000 MainWindow *mainwin = (MainWindow*)data;
3001 PrefsAccount * ac = NULL;
3005 if (mainwin->summaryview->folder_item) {
3006 ac = mainwin->summaryview->folder_item->folder->account;
3007 if (ac && ac->protocol == A_NNTP) {
3008 compose_new_with_folderitem(ac,
3009 mainwin->summaryview->folder_item, NULL);
3014 list = account_get_list();
3015 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
3016 ac = (PrefsAccount *) cur->data;
3017 if (ac->protocol == A_NNTP) {
3018 compose_new_with_folderitem(ac,
3019 mainwin->summaryview->folder_item, NULL);