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_unlock_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_PRIVACY_SIGN", N_("Sign") },
273 { "A_PRIVACY_ENCRYPT", N_("Encrypt") },
274 { "A_CLAWS_ACTIONS", N_("Claws Mail Actions Feature") },
275 { "A_CANCEL_INC", N_("Cancel receiving") },
276 { "A_CANCEL_SEND", N_("Cancel sending") },
277 { "A_CANCEL_ALL", N_("Cancel receiving/sending") },
278 { "A_CLOSE", N_("Close window") },
279 { "A_SEPARATOR", N_("Separator") },
280 { "A_CLAWS_PLUGINS", N_("Claws Mail Plugins") }
283 /* migration table: support reading toolbar configuration files with
284 old action names and converting them to current action names,
285 see toolbar_parse_item(), which makes uses of this alias table.
288 const gchar *old_name;
289 const gchar *current_name;
290 } toolbar_migration [] = {
291 { "A_SYL_ACTIONS", "A_CLAWS_ACTIONS" },
292 { "A_SENDL", "A_SEND_LATER" },
296 /* struct holds configuration files and a list of
297 * currently active toolbar items
298 * TOOLBAR_MAIN, TOOLBAR_COMPOSE and TOOLBAR_MSGVIEW
302 const gchar *conf_file;
304 } toolbar_config[NUM_TOOLBARS] = {
305 { "toolbar_main.xml", NULL},
306 { "toolbar_compose.xml", NULL},
307 { "toolbar_msgview.xml", NULL}
310 gint toolbar_ret_val_from_descr(const gchar *descr)
314 for (i = 0; i < N_ACTION_VAL; i++) {
315 if (g_utf8_collate(gettext(toolbar_text[i].descr), descr) == 0)
322 gchar *toolbar_ret_descr_from_val(gint val)
324 cm_return_val_if_fail(val >=0 && val < N_ACTION_VAL, NULL);
326 return gettext(toolbar_text[val].descr);
329 static gint toolbar_ret_val_from_text(const gchar *text)
333 for (i = 0; i < N_ACTION_VAL; i++) {
334 if (g_utf8_collate(toolbar_text[i].index_str, text) == 0)
341 static gchar *toolbar_ret_text_from_val(gint val)
343 cm_return_val_if_fail(val >=0 && val < N_ACTION_VAL, NULL);
345 return toolbar_text[val].index_str;
348 static gboolean toolbar_is_duplicate(gint action, ToolbarType source)
352 if ((action == A_SEPARATOR) || (action == A_CLAWS_ACTIONS) || (action == A_CLAWS_PLUGINS))
355 for (cur = toolbar_config[source].item_list; cur != NULL; cur = cur->next) {
356 ToolbarItem *item = (ToolbarItem*) cur->data;
358 if (item->index == action)
364 /* depending on toolbar type this function
365 returns a list of available toolbar events being
366 displayed by prefs_toolbar
368 GList *toolbar_get_action_items(ToolbarType source)
373 if (source == TOOLBAR_MAIN) {
374 gint main_items[] = {
375 A_RECEIVE_ALL, A_RECEIVE_CUR, A_SEND_QUEUED,
376 A_COMPOSE_EMAIL, A_REPLY_MESSAGE, A_REPLY_SENDER,
377 A_REPLY_ALL, A_REPLY_ML, A_OPEN_MAIL, A_FORWARD,
378 A_TRASH, A_DELETE_REAL, A_DELETE_DUP, A_EXECUTE,
379 A_GOTO_PREV, A_GOTO_NEXT, A_IGNORE_THREAD, A_WATCH_THREAD,
380 A_MARK, A_UNMARK, A_LOCK, A_UNLOCK,
381 A_ALL_READ, A_ALL_UNREAD, A_READ, A_UNREAD,
382 A_PRINT, A_ADDRBOOK, A_LEARN_SPAM, A_GO_FOLDERS,
383 A_CANCEL_INC, A_CANCEL_SEND, A_CANCEL_ALL, A_PREFERENCES };
385 for (i = 0; i < sizeof main_items / sizeof main_items[0]; i++) {
386 items = g_list_append(items, gettext(toolbar_text[main_items[i]].descr));
389 else if (source == TOOLBAR_COMPOSE) {
390 gint comp_items[] = {
391 A_SEND, A_SEND_LATER, A_DRAFT,
392 A_INSERT, A_ATTACH, A_SIG,
393 A_REP_SIG, A_EXTEDITOR, A_LINEWRAP_CURRENT,
394 A_LINEWRAP_ALL, A_ADDRBOOK,
398 A_PRIVACY_SIGN, A_PRIVACY_ENCRYPT,
401 for (i = 0; i < sizeof comp_items / sizeof comp_items[0]; i++)
402 items = g_list_append(items, gettext(toolbar_text[comp_items[i]].descr));
404 else if (source == TOOLBAR_MSGVIEW) {
405 gint msgv_items[] = {
406 A_COMPOSE_EMAIL, A_REPLY_MESSAGE, A_REPLY_SENDER,
407 A_REPLY_ALL, A_REPLY_ML, A_FORWARD,
408 A_TRASH, A_DELETE_REAL, A_GOTO_PREV, A_GOTO_NEXT,
409 A_ADDRBOOK, A_LEARN_SPAM, A_CLOSE };
411 for (i = 0; i < sizeof msgv_items / sizeof msgv_items[0]; i++)
412 items = g_list_append(items, gettext(toolbar_text[msgv_items[i]].descr));
418 static void toolbar_parse_item(XMLFile *file, ToolbarType source, gboolean *rewrite)
422 ToolbarItem *item = NULL;
424 g_return_if_fail(rewrite != NULL);
426 attr = xml_get_current_tag_attr(file);
427 item = g_new0(ToolbarItem, 1);
429 name = ((XMLAttr *)attr->data)->name;
430 value = ((XMLAttr *)attr->data)->value;
432 if (g_utf8_collate(name, TOOLBAR_ICON_FILE) == 0)
433 item->file = g_strdup (value);
434 else if (g_utf8_collate(name, TOOLBAR_ICON_TEXT) == 0)
435 item->text = g_strdup (*value ? gettext(value):"");
436 else if (g_utf8_collate(name, TOOLBAR_ICON_ACTION) == 0)
437 item->index = toolbar_ret_val_from_text(value);
439 if ((item->index == -1) && !strcmp(value, "A_DELETE")) {
441 item->index = A_TRASH;
443 item->file = g_strdup("trash_btn");
445 item->text = g_strdup(C_("Toolbar", "Trash"));
448 if (!strcmp(item->file, "mail") && !strcmp(value, "A_DRAFT")) {
449 /* switch icon file */
451 item->file = g_strdup("mail_draft");
454 if (item->index == -1) {
455 /* item not found in table: try migrating old action names to current ones */
458 /* replace action name */
459 for (i = 0; toolbar_migration[i].old_name != NULL; i++) {
460 if (g_utf8_collate(value, toolbar_migration[i].old_name) == 0) {
461 item->index = toolbar_ret_val_from_text(toolbar_migration[i].current_name);
462 if (item->index != -1) {
464 debug_print("toolbar_parse_item: migrating action label from '%s' to '%s'\n",
465 value, toolbar_migration[i].current_name);
471 if ((item->index == -1) && !rewrite)
472 g_warning("toolbar_parse_item: unrecognized action name '%s'\n", value);
474 attr = g_list_next(attr);
476 if (item->index != -1) {
477 if (!toolbar_is_duplicate(item->index, source))
478 toolbar_config[source].item_list = g_slist_append(toolbar_config[source].item_list,
483 const gchar *toolbar_get_short_text(int action) {
485 case A_RECEIVE_ALL: return _("Get Mail");
486 case A_RECEIVE_CUR: return _("Get");
487 case A_SEND_QUEUED: return _("Send");
488 case A_COMPOSE_EMAIL: return C_("Toolbar", "Compose");
489 case A_COMPOSE_NEWS: return C_("Toolbar", "Compose");
490 case A_REPLY_MESSAGE: return _("Reply");
491 case A_REPLY_SENDER: return C_("Toolbar", "Sender");
492 case A_REPLY_ALL: return _("All");
493 case A_REPLY_ML: return _("List");
494 case A_OPEN_MAIL: return _("Open");
495 case A_FORWARD: return _("Forward");
496 case A_TRASH: return C_("Toolbar", "Trash");
497 case A_DELETE_REAL: return _("Delete");
498 case A_DELETE_DUP: return _("Delete duplicates");
499 case A_EXECUTE: return _("Execute");
500 case A_GOTO_PREV: return _("Prev");
501 case A_GOTO_NEXT: return _("Next");
503 case A_IGNORE_THREAD: return _("Ignore thread");
504 case A_WATCH_THREAD: return _("Watch thread");
505 case A_MARK: return _("Mark");
506 case A_UNMARK: return _("Unmark");
507 case A_LOCK: return _("Lock");
508 case A_UNLOCK: return _("Unlock");
509 case A_ALL_READ: return _("All read");
510 case A_ALL_UNREAD: return _("All unread");
511 case A_READ: return _("Read");
512 case A_UNREAD: return _("Unread");
514 case A_PRINT: return _("Print");
515 case A_LEARN_SPAM: return _("Spam");
516 case A_GO_FOLDERS: return _("Folders");
517 case A_PREFERENCES: return _("Preferences");
519 case A_SEND: return _("Send");
520 case A_SEND_LATER: return _("Send later");
521 case A_DRAFT: return _("Draft");
522 case A_INSERT: return _("Insert");
523 case A_ATTACH: return _("Attach");
524 case A_SIG: return _("Insert sig.");
525 case A_REP_SIG: return _("Replace sig.");
526 case A_EXTEDITOR: return _("Edit");
527 case A_LINEWRAP_CURRENT:return _("Wrap para.");
528 case A_LINEWRAP_ALL: return _("Wrap all");
529 case A_ADDRBOOK: return _("Address");
531 case A_CHECK_SPELLING: return _("Check spelling");
533 case A_PRIVACY_SIGN: return _("Sign");
534 case A_PRIVACY_ENCRYPT: return _("Encrypt");
536 case A_CANCEL_INC: return _("Stop");
537 case A_CANCEL_SEND: return _("Stop");
538 case A_CANCEL_ALL: return _("Stop all");
539 case A_CLOSE: return _("Close");
544 gint toolbar_get_icon(int action) {
546 case A_RECEIVE_ALL: return STOCK_PIXMAP_MAIL_RECEIVE_ALL;
547 case A_RECEIVE_CUR: return STOCK_PIXMAP_MAIL_RECEIVE;
548 case A_SEND_QUEUED: return STOCK_PIXMAP_MAIL_SEND_QUEUE;
549 case A_COMPOSE_EMAIL: return STOCK_PIXMAP_MAIL_COMPOSE;
550 case A_COMPOSE_NEWS: return STOCK_PIXMAP_NEWS_COMPOSE;
551 case A_REPLY_MESSAGE: return STOCK_PIXMAP_MAIL_REPLY;
552 case A_REPLY_SENDER: return STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR;
553 case A_REPLY_ALL: return STOCK_PIXMAP_MAIL_REPLY_TO_ALL;
554 case A_REPLY_ML: return STOCK_PIXMAP_MAIL_REPLY_TO_LIST;
555 case A_OPEN_MAIL: return STOCK_PIXMAP_OPEN_MAIL;
556 case A_FORWARD: return STOCK_PIXMAP_MAIL_FORWARD;
557 case A_TRASH: return STOCK_PIXMAP_TRASH;
558 case A_DELETE_REAL: return STOCK_PIXMAP_DELETE;
559 case A_DELETE_DUP: return STOCK_PIXMAP_DELETE_DUP;
560 case A_EXECUTE: return STOCK_PIXMAP_EXEC;
561 case A_GOTO_PREV: return STOCK_PIXMAP_UP_ARROW;
562 case A_GOTO_NEXT: return STOCK_PIXMAP_DOWN_ARROW;
564 case A_IGNORE_THREAD: return STOCK_PIXMAP_MARK_IGNORETHREAD;
565 case A_WATCH_THREAD: return STOCK_PIXMAP_MARK_WATCHTHREAD;
566 case A_MARK: return STOCK_PIXMAP_MARK_MARK;
567 case A_UNMARK: return STOCK_PIXMAP_MARK_UNMARK;
568 case A_LOCK: return STOCK_PIXMAP_MARK_LOCKED;
569 case A_UNLOCK: return STOCK_PIXMAP_MARK_UNLOCKED;
570 case A_ALL_READ: return STOCK_PIXMAP_MARK_ALLREAD;
571 case A_ALL_UNREAD: return STOCK_PIXMAP_MARK_ALLUNREAD;
572 case A_READ: return STOCK_PIXMAP_MARK_READ;
573 case A_UNREAD: return STOCK_PIXMAP_MARK_UNREAD;
575 case A_PRINT: return STOCK_PIXMAP_PRINTER_BTN;
576 case A_LEARN_SPAM: return STOCK_PIXMAP_SPAM_BTN;
577 case A_GO_FOLDERS: return STOCK_PIXMAP_GO_FOLDERS;
578 case A_PREFERENCES: return STOCK_PIXMAP_PREFERENCES;
580 case A_SEND: return STOCK_PIXMAP_MAIL_SEND;
581 case A_SEND_LATER: return STOCK_PIXMAP_MAIL_SEND_QUEUE;
582 case A_DRAFT: return STOCK_PIXMAP_MAIL_DRAFT;
583 case A_INSERT: return STOCK_PIXMAP_INSERT_FILE;
584 case A_ATTACH: return STOCK_PIXMAP_MAIL_ATTACH;
585 case A_SIG: return STOCK_PIXMAP_MAIL_SIGN;
586 case A_REP_SIG: return STOCK_PIXMAP_MAIL_SIGN;
587 case A_EXTEDITOR: return STOCK_PIXMAP_EDIT_EXTERN;
588 case A_LINEWRAP_CURRENT:return STOCK_PIXMAP_LINEWRAP_CURRENT;
589 case A_LINEWRAP_ALL: return STOCK_PIXMAP_LINEWRAP_ALL;
590 case A_ADDRBOOK: return STOCK_PIXMAP_ADDRESS_BOOK;
592 case A_CHECK_SPELLING: return STOCK_PIXMAP_CHECK_SPELLING;
594 case A_PRIVACY_SIGN: return STOCK_PIXMAP_MAIL_PRIVACY_SIGNED;
595 case A_PRIVACY_ENCRYPT: return STOCK_PIXMAP_MAIL_PRIVACY_ENCRYPTED;
597 case A_CANCEL_INC: return STOCK_PIXMAP_CANCEL;
598 case A_CANCEL_SEND: return STOCK_PIXMAP_CANCEL;
599 case A_CANCEL_ALL: return STOCK_PIXMAP_CANCEL;
600 case A_CLOSE: return STOCK_PIXMAP_CLOSE;
605 static void toolbar_set_default_generic(ToolbarType toolbar_type, DefaultToolbar *default_toolbar)
609 g_return_if_fail(default_toolbar != NULL);
611 for (i = 0; default_toolbar[i].action != N_ACTION_VAL; i++) {
613 ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
615 if (default_toolbar[i].action != A_SEPARATOR) {
619 icon = toolbar_get_icon(default_toolbar[i].action);
621 file = stock_pixmap_get_name((StockPixmap)icon);
623 toolbar_item->file = g_strdup(file);
624 toolbar_item->index = default_toolbar[i].action;
625 toolbar_item->text = g_strdup(toolbar_get_short_text(default_toolbar[i].action));
627 toolbar_item->file = g_strdup(TOOLBAR_TAG_SEPARATOR);
628 toolbar_item->index = A_SEPARATOR;
631 if (toolbar_item->index != -1) {
632 if (!toolbar_is_duplicate(toolbar_item->index, toolbar_type))
633 toolbar_config[toolbar_type].item_list =
634 g_slist_append(toolbar_config[toolbar_type].item_list, toolbar_item);
639 void toolbar_set_default(ToolbarType source)
641 DefaultToolbar default_toolbar_main[] = {
667 DefaultToolbar default_toolbar_compose[] = {
685 DefaultToolbar default_toolbar_msgview[] = {
703 if (source == TOOLBAR_MAIN)
704 toolbar_set_default_generic(TOOLBAR_MAIN, default_toolbar_main);
705 else if (source == TOOLBAR_COMPOSE)
706 toolbar_set_default_generic(TOOLBAR_COMPOSE, default_toolbar_compose);
707 else if (source == TOOLBAR_MSGVIEW)
708 toolbar_set_default_generic(TOOLBAR_MSGVIEW, default_toolbar_msgview);
711 void toolbar_save_config_file(ToolbarType source)
716 gchar *fileSpec = NULL;
718 debug_print("save Toolbar Configuration to %s\n", toolbar_config[source].conf_file);
720 fileSpec = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, toolbar_config[source].conf_file, NULL );
721 pfile = prefs_write_open(fileSpec);
724 if (fprintf(fp, "<?xml version=\"1.0\" encoding=\"%s\" ?>\n", CS_INTERNAL) < 0)
727 if (fprintf(fp, "<%s>\n", TOOLBAR_TAG_INDEX) < 0)
730 for (cur = toolbar_config[source].item_list; cur != NULL; cur = cur->next) {
731 ToolbarItem *toolbar_item = (ToolbarItem*) cur->data;
733 if (toolbar_item->index != A_SEPARATOR) {
734 if (fprintf(fp, "\t<%s %s=\"%s\" %s=\"",
736 TOOLBAR_ICON_FILE, toolbar_item->file,
737 TOOLBAR_ICON_TEXT) < 0)
739 if (xml_file_put_escape_str(fp, toolbar_item->text) < 0)
741 if (fprintf(fp, "\" %s=\"%s\"/>\n",
743 toolbar_ret_text_from_val(toolbar_item->index)) < 0)
746 if (fprintf(fp, "\t<%s/>\n", TOOLBAR_TAG_SEPARATOR) < 0)
751 if (fprintf(fp, "</%s>\n", TOOLBAR_TAG_INDEX) < 0)
755 if (prefs_file_close (pfile) < 0 )
756 g_warning("failed to write toolbar configuration to file");
760 FILE_OP_ERROR(fileSpec, "fprintf");
762 prefs_file_close_revert (pfile);
764 g_warning("failed to open toolbar configuration file for writing");
767 void toolbar_read_config_file(ToolbarType source)
769 XMLFile *file = NULL;
770 gchar *fileSpec = NULL;
772 gboolean rewrite = FALSE;
774 debug_print("read Toolbar Configuration from %s\n", toolbar_config[source].conf_file);
776 fileSpec = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, toolbar_config[source].conf_file, NULL );
777 file = xml_open_file(fileSpec);
780 toolbar_clear_list(source);
784 || (xml_get_dtd(file))
785 || (xml_parse_next_tag(file))
786 || (!xml_compare_tag(file, TOOLBAR_TAG_INDEX))) {
787 xml_close_file(file);
795 if (xml_parse_next_tag(file))
798 /* Get next tag (icon, icon_text or icon_action) */
799 if (xml_compare_tag(file, TOOLBAR_TAG_ITEM)) {
800 toolbar_parse_item(file, source, &rewrite);
801 } else if (xml_compare_tag(file, TOOLBAR_TAG_SEPARATOR)) {
802 ToolbarItem *item = g_new0(ToolbarItem, 1);
804 item->file = g_strdup(TOOLBAR_TAG_SEPARATOR);
805 item->index = A_SEPARATOR;
806 toolbar_config[source].item_list =
807 g_slist_append(toolbar_config[source].item_list, item);
811 xml_close_file(file);
813 debug_print("toolbar_read_config_file: rewriting toolbar\n");
814 toolbar_save_config_file(source);
818 if ((!file) || (g_slist_length(toolbar_config[source].item_list) == 0)) {
820 if (source == TOOLBAR_MAIN)
821 toolbar_set_default(TOOLBAR_MAIN);
822 else if (source == TOOLBAR_COMPOSE)
823 toolbar_set_default(TOOLBAR_COMPOSE);
824 else if (source == TOOLBAR_MSGVIEW)
825 toolbar_set_default(TOOLBAR_MSGVIEW);
827 g_warning("refusing to write unknown Toolbar Configuration number %d", source);
831 toolbar_save_config_file(source);
836 * clears list of toolbar items read from configuration files
838 void toolbar_clear_list(ToolbarType source)
840 while (toolbar_config[source].item_list != NULL) {
841 ToolbarItem *item = (ToolbarItem*) toolbar_config[source].item_list->data;
843 toolbar_config[source].item_list =
844 g_slist_remove(toolbar_config[source].item_list, item);
850 g_slist_free(toolbar_config[source].item_list);
855 * return list of Toolbar items
857 GSList *toolbar_get_list(ToolbarType source)
861 if ((source == TOOLBAR_MAIN) || (source == TOOLBAR_COMPOSE) || (source == TOOLBAR_MSGVIEW))
862 list = toolbar_config[source].item_list;
867 void toolbar_set_list_item(ToolbarItem *t_item, ToolbarType source)
869 ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
871 toolbar_item->file = g_strdup(t_item->file);
872 toolbar_item->text = g_strdup(t_item->text);
873 toolbar_item->index = t_item->index;
875 toolbar_config[source].item_list =
876 g_slist_append(toolbar_config[source].item_list,
880 static void toolbar_action_execute(GtkWidget *widget,
888 for (cur = action_list; cur != NULL; cur = cur->next) {
889 ToolbarClawsActions *act = (ToolbarClawsActions*)cur->data;
891 if (widget == act->widget) {
892 i = prefs_actions_find_by_name(act->name);
900 actions_execute(data, i, widget, source);
902 g_warning ("Error: did not find Claws Action to execute");
905 gboolean toolbar_check_action_btns(ToolbarType type)
907 GSList *temp, *curr, *list = toolbar_config[type].item_list;
908 gboolean modified = FALSE;
911 while (curr != NULL) {
912 ToolbarItem *toolbar_item = (ToolbarItem *) curr->data;
916 if (toolbar_item->index != A_CLAWS_ACTIONS)
919 if (prefs_actions_find_by_name(toolbar_item->text) == -1) {
920 list = g_slist_delete_link(list, temp);
921 g_free(toolbar_item->file);
922 g_free(toolbar_item->text);
923 g_free(toolbar_item);
931 #define CLAWS_SET_TOOL_ITEM_TIP(widget,tip) { \
932 gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), tip); \
935 #define CLAWS_SET_ARROW_TIP(widget,tip) { \
936 gtk_menu_tool_button_set_arrow_tooltip_text(GTK_MENU_TOOL_BUTTON(widget), tip); \
939 static void activate_compose_button (Toolbar *toolbar,
941 ComposeButtonType type)
943 if ((!toolbar->compose_mail_btn))
946 if (type == COMPOSEBUTTON_NEWS) {
947 gtk_tool_button_set_icon_widget(
948 GTK_TOOL_BUTTON(toolbar->compose_mail_btn),
949 toolbar->compose_news_icon);
951 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(toolbar->compose_mail_btn), _("Compose News message"));
953 gtk_widget_show(toolbar->compose_news_icon);
955 gtk_tool_button_set_icon_widget(
956 GTK_TOOL_BUTTON(toolbar->compose_mail_btn),
957 toolbar->compose_mail_icon);
959 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(toolbar->compose_mail_btn), _("Compose Email"));
961 gtk_widget_show(toolbar->compose_mail_icon);
963 toolbar->compose_btn_type = type;
966 void toolbar_set_compose_button(Toolbar *toolbar,
967 ComposeButtonType compose_btn_type)
969 if (toolbar->compose_btn_type != compose_btn_type)
970 activate_compose_button(toolbar,
971 prefs_common.toolbar_style,
975 static void activate_learn_button (Toolbar *toolbar,
977 LearnButtonType type)
979 if ((!toolbar->learn_spam_btn))
982 if (type == LEARN_SPAM) {
983 gtk_tool_button_set_icon_widget(
984 GTK_TOOL_BUTTON(toolbar->learn_spam_btn),
985 toolbar->learn_spam_icon);
986 gtk_tool_button_set_label(
987 GTK_TOOL_BUTTON(toolbar->learn_spam_btn),
990 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(toolbar->learn_spam_btn), _("Learn spam"));
992 gtk_widget_show(toolbar->learn_spam_icon);
994 gtk_tool_button_set_icon_widget(
995 GTK_TOOL_BUTTON(toolbar->learn_spam_btn),
996 toolbar->learn_ham_icon);
997 gtk_tool_button_set_label(
998 GTK_TOOL_BUTTON(toolbar->learn_spam_btn),
1000 #ifndef GENERIC_UMPC
1001 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(toolbar->learn_spam_btn), _("Learn ham"));
1003 gtk_widget_show(toolbar->learn_ham_icon);
1005 toolbar->learn_btn_type = type;
1008 void toolbar_set_learn_button(Toolbar *toolbar,
1009 LearnButtonType learn_btn_type)
1011 if (toolbar->learn_btn_type != learn_btn_type)
1012 activate_learn_button(toolbar,
1013 prefs_common.toolbar_style,
1017 void toolbar_toggle(guint action, gpointer data)
1019 MainWindow *mainwin = (MainWindow*)data;
1023 cm_return_if_fail(mainwin != NULL);
1025 toolbar_style(TOOLBAR_MAIN, action, mainwin);
1027 list = compose_get_compose_list();
1028 for (cur = list; cur != NULL; cur = cur->next) {
1029 toolbar_style(TOOLBAR_COMPOSE, action, cur->data);
1031 list = messageview_get_msgview_list();
1032 for (cur = list; cur != NULL; cur = cur->next) {
1033 toolbar_style(TOOLBAR_MSGVIEW, action, cur->data);
1038 void toolbar_set_style(GtkWidget *toolbar_wid, GtkWidget *handlebox_wid, guint action)
1040 switch ((ToolbarStyle)action) {
1042 gtk_widget_hide(handlebox_wid);
1045 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
1049 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
1053 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
1056 case TOOLBAR_BOTH_HORIZ:
1057 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
1058 GTK_TOOLBAR_BOTH_HORIZ);
1064 prefs_common.toolbar_style = (ToolbarStyle)action;
1065 gtk_widget_set_size_request(handlebox_wid, 1, -1);
1067 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
1068 gtk_widget_show(handlebox_wid);
1069 gtk_widget_queue_resize(handlebox_wid);
1073 * Change the style of toolbar
1075 static void toolbar_style(ToolbarType type, guint action, gpointer data)
1077 GtkWidget *handlebox_wid;
1078 GtkWidget *toolbar_wid;
1079 MainWindow *mainwin = (MainWindow*)data;
1080 Compose *compose = (Compose*)data;
1081 MessageView *msgview = (MessageView*)data;
1083 cm_return_if_fail(data != NULL);
1087 handlebox_wid = mainwin->handlebox;
1088 toolbar_wid = mainwin->toolbar->toolbar;
1090 case TOOLBAR_COMPOSE:
1091 handlebox_wid = compose->handlebox;
1092 toolbar_wid = compose->toolbar->toolbar;
1094 case TOOLBAR_MSGVIEW:
1095 handlebox_wid = msgview->handlebox;
1096 toolbar_wid = msgview->toolbar->toolbar;
1102 toolbar_set_style(toolbar_wid, handlebox_wid, action);
1105 /* Toolbar handling */
1106 static void toolbar_inc_cb(GtkWidget *widget,
1109 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1110 MainWindow *mainwin;
1112 cm_return_if_fail(toolbar_item != NULL);
1114 switch (toolbar_item->type) {
1116 mainwin = (MainWindow*)toolbar_item->parent;
1117 inc_mail_cb(mainwin, 0, NULL);
1124 static void toolbar_inc_all_cb(GtkWidget *widget,
1127 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1128 MainWindow *mainwin;
1130 cm_return_if_fail(toolbar_item != NULL);
1132 switch (toolbar_item->type) {
1134 mainwin = (MainWindow*)toolbar_item->parent;
1135 inc_all_account_mail_cb(mainwin, 0, NULL);
1142 static void toolbar_send_queued_cb(GtkWidget *widget,gpointer data)
1144 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1145 MainWindow *mainwin;
1147 cm_return_if_fail(toolbar_item != NULL);
1149 switch (toolbar_item->type) {
1151 mainwin = (MainWindow*)toolbar_item->parent;
1152 send_queue_cb(mainwin, 0, NULL);
1159 static void toolbar_exec_cb(GtkWidget *widget,
1162 MainWindow *mainwin = get_mainwin(data);
1164 cm_return_if_fail(mainwin != NULL);
1165 summary_execute(mainwin->summaryview);
1169 * Delete current/selected(s) message(s)
1171 static void toolbar_trash_cb(GtkWidget *widget, gpointer data)
1173 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1174 MainWindow *mainwin;
1176 cm_return_if_fail(toolbar_item != NULL);
1177 cm_return_if_fail(toolbar_item->parent);
1179 switch (toolbar_item->type) {
1180 case TOOLBAR_MSGVIEW:
1181 messageview_delete((MessageView *)toolbar_item->parent);
1184 mainwin = (MainWindow *)toolbar_item->parent;
1185 summary_delete_trash(mainwin->summaryview);
1188 debug_print("toolbar event not supported\n");
1194 * Delete current/selected(s) message(s)
1196 static void toolbar_delete_cb(GtkWidget *widget, gpointer data)
1198 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1199 MainWindow *mainwin;
1201 cm_return_if_fail(toolbar_item != NULL);
1202 cm_return_if_fail(toolbar_item->parent);
1204 switch (toolbar_item->type) {
1205 case TOOLBAR_MSGVIEW:
1206 messageview_delete((MessageView *)toolbar_item->parent);
1209 mainwin = (MainWindow *)toolbar_item->parent;
1210 summary_delete(mainwin->summaryview);
1213 debug_print("toolbar event not supported\n");
1218 static void toolbar_delete_dup(gpointer data, guint all)
1220 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1221 MainWindow *mainwin = NULL;
1223 cm_return_if_fail(toolbar_item != NULL);
1225 switch (toolbar_item->type) {
1227 mainwin = (MainWindow*)toolbar_item->parent;
1229 mainwindow_delete_duplicated_all(mainwin);
1231 mainwindow_delete_duplicated(mainwin);
1233 case TOOLBAR_COMPOSE:
1234 case TOOLBAR_MSGVIEW:
1237 debug_print("toolbar event not supported\n");
1242 static void toolbar_delete_dup_cb(GtkWidget *widget, gpointer data)
1244 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1245 MainWindow *mainwin = NULL;
1247 cm_return_if_fail(toolbar_item != NULL);
1249 switch (toolbar_item->type) {
1251 mainwin = (MainWindow*)toolbar_item->parent;
1252 mainwindow_delete_duplicated(mainwin);
1254 case TOOLBAR_COMPOSE:
1255 case TOOLBAR_MSGVIEW:
1263 * Compose new message
1265 static void toolbar_compose_cb(GtkWidget *widget, gpointer data)
1267 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1268 MainWindow *mainwin;
1269 MessageView *msgview;
1271 cm_return_if_fail(toolbar_item != NULL);
1273 switch (toolbar_item->type) {
1275 mainwin = (MainWindow*)toolbar_item->parent;
1276 if (mainwin->toolbar->compose_btn_type == COMPOSEBUTTON_NEWS)
1277 compose_news_cb(mainwin, 0, NULL);
1279 compose_mail_cb(mainwin, 0, NULL);
1281 case TOOLBAR_MSGVIEW:
1282 msgview = (MessageView*)toolbar_item->parent;
1283 compose_new_with_folderitem(NULL,
1284 msgview->msginfo->folder, NULL);
1287 debug_print("toolbar event not supported\n");
1291 static void toolbar_learn(gpointer data, guint as_spam)
1293 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1294 MainWindow *mainwin;
1295 MessageView *msgview;
1297 cm_return_if_fail(toolbar_item != NULL);
1299 switch (toolbar_item->type) {
1301 mainwin = (MainWindow*)toolbar_item->parent;
1303 mainwindow_learn(mainwin, TRUE);
1305 mainwindow_learn(mainwin, FALSE);
1307 case TOOLBAR_MSGVIEW:
1308 msgview = (MessageView*)toolbar_item->parent;
1310 messageview_learn(msgview, TRUE);
1312 messageview_learn(msgview, FALSE);
1315 debug_print("toolbar event not supported\n");
1319 static void toolbar_learn_cb(GtkWidget *widget, gpointer data)
1321 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1322 MainWindow *mainwin;
1323 MessageView *msgview;
1325 cm_return_if_fail(toolbar_item != NULL);
1327 switch (toolbar_item->type) {
1329 mainwin = (MainWindow*)toolbar_item->parent;
1330 if (mainwin->toolbar->learn_btn_type == LEARN_SPAM)
1331 mainwindow_learn(mainwin, TRUE);
1333 mainwindow_learn(mainwin, FALSE);
1335 case TOOLBAR_MSGVIEW:
1336 msgview = (MessageView*)toolbar_item->parent;
1337 if (msgview->toolbar->learn_btn_type == LEARN_SPAM)
1338 messageview_learn(msgview, TRUE);
1340 messageview_learn(msgview, FALSE);
1343 debug_print("toolbar event not supported\n");
1351 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
1353 toolbar_reply(data, (prefs_common.reply_with_quote ?
1354 COMPOSE_REPLY_WITH_QUOTE : COMPOSE_REPLY_WITHOUT_QUOTE));
1359 * Reply message to Sender and All recipients
1361 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
1364 (prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
1365 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE));
1370 * Reply to Mailing List
1372 static void toolbar_reply_to_list_cb(GtkWidget *widget, gpointer data)
1375 (prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_LIST_WITH_QUOTE
1376 : COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE));
1381 * Reply to sender of message
1383 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
1386 (prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
1387 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE));
1393 static void toolbar_addrbook_cb(GtkWidget *widget, gpointer data)
1395 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1398 cm_return_if_fail(toolbar_item != NULL);
1400 switch (toolbar_item->type) {
1402 case TOOLBAR_MSGVIEW:
1405 case TOOLBAR_COMPOSE:
1406 compose = (Compose *)toolbar_item->parent;
1411 #ifndef USE_ALT_ADDRBOOK
1412 addressbook_open(compose);
1414 GError* error = NULL;
1415 addressbook_connect_signals(compose);
1416 addressbook_dbus_open(TRUE, &error);
1418 g_warning("%s", error->message);
1419 g_error_free(error);
1426 * Forward current/selected(s) message(s)
1428 static void toolbar_forward_cb(GtkWidget *widget, gpointer data)
1430 toolbar_reply(data, (COMPOSE_FORWARD));
1434 * Goto Prev Unread Message
1436 static void toolbar_prev_unread_cb(GtkWidget *widget, gpointer data)
1438 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1439 MainWindow *mainwin;
1440 MessageView *msgview;
1442 cm_return_if_fail(toolbar_item != NULL);
1444 switch (toolbar_item->type) {
1446 mainwin = (MainWindow*)toolbar_item->parent;
1447 summary_select_prev_unread(mainwin->summaryview);
1450 case TOOLBAR_MSGVIEW:
1451 msgview = (MessageView*)toolbar_item->parent;
1452 msgview->updating = TRUE;
1453 summary_select_prev_unread(msgview->mainwin->summaryview);
1454 msgview->updating = FALSE;
1456 if (msgview->deferred_destroy) {
1457 debug_print("messageview got away!\n");
1458 messageview_destroy(msgview);
1462 /* Now we need to update the messageview window */
1463 if (msgview->mainwin->summaryview->selected) {
1464 #ifndef GENERIC_UMPC
1465 MsgInfo * msginfo = summary_get_selected_msg(msgview->mainwin->summaryview);
1468 messageview_show(msgview, msginfo,
1469 msgview->all_headers);
1472 gtk_widget_destroy(msgview->window);
1476 debug_print("toolbar event not supported\n");
1481 * Goto Next Unread Message
1483 static void toolbar_next_unread_cb(GtkWidget *widget, gpointer data)
1485 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1486 MainWindow *mainwin;
1487 MessageView *msgview;
1489 cm_return_if_fail(toolbar_item != NULL);
1491 switch (toolbar_item->type) {
1493 mainwin = (MainWindow*)toolbar_item->parent;
1494 summary_select_next_unread(mainwin->summaryview);
1497 case TOOLBAR_MSGVIEW:
1498 msgview = (MessageView*)toolbar_item->parent;
1499 msgview->updating = TRUE;
1500 summary_select_next_unread(msgview->mainwin->summaryview);
1501 msgview->updating = FALSE;
1503 if (msgview->deferred_destroy) {
1504 debug_print("messageview got away!\n");
1505 messageview_destroy(msgview);
1509 /* Now we need to update the messageview window */
1510 if (msgview->mainwin->summaryview->selected) {
1511 #ifndef GENERIC_UMPC
1512 MsgInfo * msginfo = summary_get_selected_msg(msgview->mainwin->summaryview);
1515 messageview_show(msgview, msginfo,
1516 msgview->all_headers);
1519 gtk_widget_destroy(msgview->window);
1523 debug_print("toolbar event not supported\n");
1527 static void toolbar_ignore_thread_cb(GtkWidget *widget, gpointer data)
1529 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1530 MainWindow *mainwin;
1532 cm_return_if_fail(toolbar_item != NULL);
1534 switch (toolbar_item->type) {
1536 mainwin = (MainWindow *) toolbar_item->parent;
1537 summary_toggle_ignore_thread(mainwin->summaryview);
1539 case TOOLBAR_MSGVIEW:
1540 /* TODO: see toolbar_next_unread_cb() if you need
1541 * this in the message view */
1544 debug_print("toolbar event not supported\n");
1549 static void toolbar_watch_thread_cb(GtkWidget *widget, gpointer data)
1551 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1552 MainWindow *mainwin;
1554 cm_return_if_fail(toolbar_item != NULL);
1556 switch (toolbar_item->type) {
1558 mainwin = (MainWindow *) toolbar_item->parent;
1559 summary_toggle_watch_thread(mainwin->summaryview);
1561 case TOOLBAR_MSGVIEW:
1562 /* TODO: see toolbar_next_unread_cb() if you need
1563 * this in the message view */
1566 debug_print("toolbar event not supported\n");
1571 static void toolbar_mark_cb(GtkWidget *widget, gpointer data)
1573 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1574 MainWindow *mainwin;
1576 cm_return_if_fail(toolbar_item != NULL);
1578 switch (toolbar_item->type) {
1580 mainwin = (MainWindow *) toolbar_item->parent;
1581 summary_mark(mainwin->summaryview);
1583 case TOOLBAR_MSGVIEW:
1584 /* TODO: see toolbar_next_unread_cb() if you need
1585 * this in the message view */
1588 debug_print("toolbar event not supported\n");
1593 static void toolbar_unmark_cb(GtkWidget *widget, gpointer data)
1595 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1596 MainWindow *mainwin;
1598 cm_return_if_fail(toolbar_item != NULL);
1600 switch (toolbar_item->type) {
1602 mainwin = (MainWindow *) toolbar_item->parent;
1603 summary_unmark(mainwin->summaryview);
1605 case TOOLBAR_MSGVIEW:
1606 /* TODO: see toolbar_next_unread_cb() if you need
1607 * this in the message view */
1610 debug_print("toolbar event not supported\n");
1615 static void toolbar_lock_cb(GtkWidget *widget, gpointer data)
1617 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1618 MainWindow *mainwin;
1620 cm_return_if_fail(toolbar_item != NULL);
1622 switch (toolbar_item->type) {
1624 mainwin = (MainWindow *) toolbar_item->parent;
1625 summary_msgs_lock(mainwin->summaryview);
1627 case TOOLBAR_MSGVIEW:
1628 /* TODO: see toolbar_next_unread_cb() if you need
1629 * this in the message view */
1632 debug_print("toolbar event not supported\n");
1637 static void toolbar_unlock_cb(GtkWidget *widget, gpointer data)
1639 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1640 MainWindow *mainwin;
1642 cm_return_if_fail(toolbar_item != NULL);
1644 switch (toolbar_item->type) {
1646 mainwin = (MainWindow *) toolbar_item->parent;
1647 summary_msgs_unlock(mainwin->summaryview);
1649 case TOOLBAR_MSGVIEW:
1650 /* TODO: see toolbar_next_unread_cb() if you need
1651 * this in the message view */
1654 debug_print("toolbar event not supported\n");
1659 static void toolbar_all_read_cb(GtkWidget *widget, gpointer data)
1661 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1662 MainWindow *mainwin;
1664 cm_return_if_fail(toolbar_item != NULL);
1666 switch (toolbar_item->type) {
1668 mainwin = (MainWindow *) toolbar_item->parent;
1669 summary_mark_all_read(mainwin->summaryview, TRUE);
1671 case TOOLBAR_MSGVIEW:
1672 /* TODO: see toolbar_next_unread_cb() if you need
1673 * this in the message view */
1676 debug_print("toolbar event not supported\n");
1681 static void toolbar_all_unread_cb(GtkWidget *widget, gpointer data)
1683 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1684 MainWindow *mainwin;
1686 cm_return_if_fail(toolbar_item != NULL);
1688 switch (toolbar_item->type) {
1690 mainwin = (MainWindow *) toolbar_item->parent;
1691 summary_mark_all_unread(mainwin->summaryview, TRUE);
1693 case TOOLBAR_MSGVIEW:
1694 /* TODO: see toolbar_next_unread_cb() if you need
1695 * this in the message view */
1698 debug_print("toolbar event not supported\n");
1703 static void toolbar_read_cb(GtkWidget *widget, gpointer data)
1705 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1706 MainWindow *mainwin;
1708 cm_return_if_fail(toolbar_item != NULL);
1710 switch (toolbar_item->type) {
1712 mainwin = (MainWindow *) toolbar_item->parent;
1713 summary_mark_as_read(mainwin->summaryview);
1715 case TOOLBAR_MSGVIEW:
1716 /* TODO: see toolbar_next_unread_cb() if you need
1717 * this in the message view */
1720 debug_print("toolbar event not supported\n");
1725 static void toolbar_unread_cb(GtkWidget *widget, gpointer data)
1727 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1728 MainWindow *mainwin;
1730 cm_return_if_fail(toolbar_item != NULL);
1732 switch (toolbar_item->type) {
1734 mainwin = (MainWindow *) toolbar_item->parent;
1735 summary_mark_as_unread(mainwin->summaryview);
1737 case TOOLBAR_MSGVIEW:
1738 /* TODO: see toolbar_next_unread_cb() if you need
1739 * this in the message view */
1742 debug_print("toolbar event not supported\n");
1747 static void toolbar_cancel_inc_cb(GtkWidget *widget, gpointer data)
1749 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1751 cm_return_if_fail(toolbar_item != NULL);
1756 static void toolbar_cancel_send_cb(GtkWidget *widget, gpointer data)
1758 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1760 cm_return_if_fail(toolbar_item != NULL);
1764 static void toolbar_cancel_all_cb(GtkWidget *widget, gpointer data)
1766 toolbar_cancel_inc_cb(widget, data);
1767 toolbar_cancel_send_cb(widget, data);
1770 static void toolbar_print_cb(GtkWidget *widget, gpointer data)
1772 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1773 MainWindow *mainwin;
1775 cm_return_if_fail(toolbar_item != NULL);
1777 switch (toolbar_item->type) {
1779 mainwin = (MainWindow *) toolbar_item->parent;
1780 summary_print(mainwin->summaryview);
1782 case TOOLBAR_MSGVIEW:
1783 /* TODO: see toolbar_next_unread_cb() if you need
1784 * this in the message view */
1787 debug_print("toolbar event not supported\n");
1792 static void toolbar_send_cb(GtkWidget *widget, gpointer data)
1794 compose_toolbar_cb(A_SEND, data);
1797 static void toolbar_send_later_cb(GtkWidget *widget, gpointer data)
1799 compose_toolbar_cb(A_SEND_LATER, data);
1802 static void toolbar_draft_cb(GtkWidget *widget, gpointer data)
1804 compose_toolbar_cb(A_DRAFT, data);
1807 static void toolbar_close_cb(GtkWidget *widget, gpointer data)
1809 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1810 MainWindow *mainwin;
1811 MessageView *messageview;
1814 cm_return_if_fail(toolbar_item != NULL);
1816 switch (toolbar_item->type) {
1818 mainwin = (MainWindow *) toolbar_item->parent;
1819 app_will_exit(NULL, mainwin);
1821 case TOOLBAR_MSGVIEW:
1822 messageview = (MessageView *)toolbar_item->parent;
1823 messageview_destroy(messageview);
1825 case TOOLBAR_COMPOSE:
1826 compose = (Compose *)toolbar_item->parent;
1827 compose_close_toolbar(compose);
1832 static void toolbar_preferences_cb(GtkWidget *widget, gpointer data)
1837 static void toolbar_open_mail_cb(GtkWidget *widget, gpointer data)
1839 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1840 MainWindow *mainwin;
1842 cm_return_if_fail(toolbar_item != NULL);
1844 switch (toolbar_item->type) {
1846 mainwin = (MainWindow *) toolbar_item->parent;
1847 summary_open_row(NULL, mainwin->summaryview);
1849 case TOOLBAR_MSGVIEW:
1850 debug_print("toolbar event not supported\n");
1852 case TOOLBAR_COMPOSE:
1853 debug_print("toolbar event not supported\n");
1858 static void toolbar_insert_cb(GtkWidget *widget, gpointer data)
1860 compose_toolbar_cb(A_INSERT, data);
1863 static void toolbar_attach_cb(GtkWidget *widget, gpointer data)
1865 compose_toolbar_cb(A_ATTACH, data);
1868 static void toolbar_sig_cb(GtkWidget *widget, gpointer data)
1870 compose_toolbar_cb(A_SIG, data);
1873 static void toolbar_replace_sig_cb(GtkWidget *widget, gpointer data)
1875 compose_toolbar_cb(A_REP_SIG, data);
1878 static void toolbar_ext_editor_cb(GtkWidget *widget, gpointer data)
1880 compose_toolbar_cb(A_EXTEDITOR, data);
1883 static void toolbar_linewrap_current_cb(GtkWidget *widget, gpointer data)
1885 compose_toolbar_cb(A_LINEWRAP_CURRENT, data);
1888 static void toolbar_linewrap_all_cb(GtkWidget *widget, gpointer data)
1890 compose_toolbar_cb(A_LINEWRAP_ALL, data);
1894 static void toolbar_check_spelling_cb(GtkWidget *widget, gpointer data)
1896 compose_toolbar_cb(A_CHECK_SPELLING, data);
1900 static void toolbar_privacy_sign_cb(GtkWidget *widget, gpointer data)
1902 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1903 Compose *compose = (Compose *)toolbar_item->parent;
1904 gboolean state = gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(widget));
1906 cm_return_if_fail(compose != NULL);
1907 compose_use_signing(compose, state);
1910 /* Any time the toggle button gets toggled, we want to update its tooltip. */
1911 static void toolbar_privacy_sign_toggled_cb(GtkWidget *widget, gpointer data)
1913 gboolean state = gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(widget));
1916 gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), _("Message will be signed"));
1918 gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), _("Message will not be signed"));
1921 static void toolbar_privacy_encrypt_cb(GtkWidget *widget, gpointer data)
1923 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1924 Compose *compose = (Compose *)toolbar_item->parent;
1925 gboolean state = gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(widget));
1927 cm_return_if_fail(compose != NULL);
1928 compose_use_encryption(compose, state);
1931 /* Any time the toggle button gets toggled, we want to update its tooltip. */
1932 static void toolbar_privacy_encrypt_toggled_cb(GtkWidget *widget, gpointer data)
1934 gboolean state = gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(widget));
1937 gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), _("Message will be encrypted"));
1939 gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), _("Message will not be encrypted"));
1943 * Execute actions from toolbar
1945 static void toolbar_actions_execute_cb(GtkWidget *widget, gpointer data)
1947 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1948 GSList *action_list;
1949 MainWindow *mainwin;
1951 MessageView *msgview;
1952 gpointer parent = toolbar_item->parent;
1954 cm_return_if_fail(toolbar_item != NULL);
1956 switch (toolbar_item->type) {
1958 mainwin = (MainWindow*)parent;
1959 action_list = mainwin->toolbar->action_list;
1961 case TOOLBAR_COMPOSE:
1962 compose = (Compose*)parent;
1963 action_list = compose->toolbar->action_list;
1965 case TOOLBAR_MSGVIEW:
1966 msgview = (MessageView*)parent;
1967 action_list = msgview->toolbar->action_list;
1970 debug_print("toolbar event not supported\n");
1973 toolbar_action_execute(widget, action_list, parent, toolbar_item->type);
1976 static void toolbar_plugins_execute_cb(GtkWidget *widget, gpointer data)
1978 ToolbarItem *toolbar_item = data;
1979 prefs_toolbar_execute_plugin_item(toolbar_item->parent, toolbar_item->type, toolbar_item->text);
1982 static MainWindow *get_mainwin(gpointer data)
1984 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1985 MainWindow *mainwin = NULL;
1986 MessageView *msgview;
1988 cm_return_val_if_fail(toolbar_item != NULL, NULL);
1990 switch(toolbar_item->type) {
1992 mainwin = (MainWindow*)toolbar_item->parent;
1994 case TOOLBAR_MSGVIEW:
1995 msgview = (MessageView*)toolbar_item->parent;
1996 mainwin = (MainWindow*)msgview->mainwin;
2005 static void toolbar_go_folders_cb(GtkWidget *widget, gpointer data)
2007 ToolbarItem *toolbar_item = (ToolbarItem*)data;
2008 MainWindow *mainwin = NULL;
2009 switch(toolbar_item->type) {
2011 mainwin = (MainWindow*)toolbar_item->parent;
2014 g_warning("wrong toolbar type");
2018 if (!mainwin->in_folder) {
2019 FolderItem *item = folderview_get_selected_item(mainwin->folderview);
2021 folderview_select(mainwin->folderview, item);
2024 folderview_grab_focus(mainwin->folderview);
2025 mainwindow_exit_folder(mainwin);
2029 static void toolbar_buttons_cb(GtkWidget *widget,
2036 void (*func)(GtkWidget *widget, gpointer data);
2038 { A_RECEIVE_ALL, toolbar_inc_all_cb },
2039 { A_RECEIVE_CUR, toolbar_inc_cb },
2040 { A_SEND_QUEUED, toolbar_send_queued_cb },
2041 { A_COMPOSE_EMAIL, toolbar_compose_cb },
2042 { A_COMPOSE_NEWS, toolbar_compose_cb },
2043 { A_REPLY_MESSAGE, toolbar_reply_cb },
2044 { A_REPLY_SENDER, toolbar_reply_to_sender_cb },
2045 { A_REPLY_ALL, toolbar_reply_to_all_cb },
2046 { A_REPLY_ML, toolbar_reply_to_list_cb },
2047 { A_FORWARD, toolbar_forward_cb },
2048 { A_TRASH, toolbar_trash_cb },
2049 { A_DELETE_REAL, toolbar_delete_cb },
2050 { A_EXECUTE, toolbar_exec_cb },
2051 { A_GOTO_PREV, toolbar_prev_unread_cb },
2052 { A_GOTO_NEXT, toolbar_next_unread_cb },
2053 { A_IGNORE_THREAD, toolbar_ignore_thread_cb },
2054 { A_WATCH_THREAD, toolbar_watch_thread_cb },
2055 { A_MARK, toolbar_mark_cb },
2056 { A_UNMARK, toolbar_unmark_cb },
2057 { A_LOCK, toolbar_lock_cb },
2058 { A_UNLOCK, toolbar_unlock_cb },
2059 { A_ALL_READ, toolbar_all_read_cb },
2060 { A_ALL_UNREAD, toolbar_all_unread_cb },
2061 { A_READ, toolbar_read_cb },
2062 { A_UNREAD, toolbar_unread_cb },
2063 { A_PRINT, toolbar_print_cb },
2064 { A_LEARN_SPAM, toolbar_learn_cb },
2065 { A_DELETE_DUP, toolbar_delete_dup_cb },
2066 { A_GO_FOLDERS, toolbar_go_folders_cb },
2068 { A_SEND, toolbar_send_cb },
2069 { A_SEND_LATER, toolbar_send_later_cb },
2070 { A_DRAFT, toolbar_draft_cb },
2071 { A_OPEN_MAIL, toolbar_open_mail_cb },
2072 { A_CLOSE, toolbar_close_cb },
2073 { A_PREFERENCES, toolbar_preferences_cb },
2074 { A_INSERT, toolbar_insert_cb },
2075 { A_ATTACH, toolbar_attach_cb },
2076 { A_SIG, toolbar_sig_cb },
2077 { A_REP_SIG, toolbar_replace_sig_cb },
2078 { A_EXTEDITOR, toolbar_ext_editor_cb },
2079 { A_LINEWRAP_CURRENT, toolbar_linewrap_current_cb },
2080 { A_LINEWRAP_ALL, toolbar_linewrap_all_cb },
2081 { A_ADDRBOOK, toolbar_addrbook_cb },
2083 { A_CHECK_SPELLING, toolbar_check_spelling_cb },
2085 { A_PRIVACY_SIGN, toolbar_privacy_sign_cb },
2086 { A_PRIVACY_ENCRYPT, toolbar_privacy_encrypt_cb },
2087 { A_CLAWS_ACTIONS, toolbar_actions_execute_cb },
2088 { A_CANCEL_INC, toolbar_cancel_inc_cb },
2089 { A_CANCEL_SEND, toolbar_cancel_send_cb },
2090 { A_CANCEL_ALL, toolbar_cancel_all_cb },
2091 { A_CLAWS_PLUGINS, toolbar_plugins_execute_cb },
2094 num_items = sizeof(callbacks)/sizeof(callbacks[0]);
2096 for (i = 0; i < num_items; i++) {
2097 if (callbacks[i].index == item->index) {
2098 callbacks[i].func(widget, item);
2103 #ifndef GENERIC_UMPC
2104 #define TOOLBAR_ITEM(item,icon,text,tooltip) { \
2105 item = GTK_WIDGET(gtk_tool_button_new(icon, text)); \
2106 gtkut_widget_set_can_focus(gtk_bin_get_child(GTK_BIN(item)), FALSE); \
2107 gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE); \
2108 gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE); \
2109 g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item); \
2110 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1); \
2111 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(item), \
2115 #define TOOLBAR_TOGGLE_ITEM(item,icon,text,tooltip) { \
2116 item = GTK_WIDGET(gtk_toggle_tool_button_new()); \
2117 gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(item), icon); \
2118 gtk_tool_button_set_label(GTK_TOOL_BUTTON(item), text); \
2119 gtkut_widget_set_can_focus(gtk_bin_get_child(GTK_BIN(item)), FALSE); \
2120 gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE); \
2121 gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE); \
2122 g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item); \
2123 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1); \
2124 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(item), \
2128 #define TOOLBAR_MENUITEM(item,icon,text,tooltip,menutip) { \
2129 GtkWidget *child = NULL, *btn = NULL, *arr = NULL; \
2130 GList *gchild = NULL; \
2131 item = GTK_WIDGET(gtk_menu_tool_button_new(icon, text)); \
2132 gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE); \
2133 gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE); \
2134 g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item); \
2135 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1); \
2136 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(item), \
2138 CLAWS_SET_ARROW_TIP(GTK_MENU_TOOL_BUTTON(item), menutip); \
2139 child = gtk_bin_get_child(GTK_BIN(item)); \
2140 gchild = gtk_container_get_children( \
2141 GTK_CONTAINER(child)); \
2142 btn = (GtkWidget *)gchild->data; \
2143 gtkut_widget_set_can_focus(btn, FALSE); \
2144 arr = (GtkWidget *)(gchild->next?gchild->next->data:NULL); \
2145 gtkut_widget_set_can_focus(arr, FALSE); \
2146 g_list_free(gchild); \
2147 gchild = gtk_container_get_children(GTK_CONTAINER(arr)); \
2148 gtk_widget_set_size_request(GTK_WIDGET(gchild->data), 9, -1); \
2149 g_list_free(gchild); \
2154 #define TOOLBAR_ITEM(item,icon,text,tooltip) { \
2155 item = GTK_WIDGET(gtk_tool_button_new(icon, text)); \
2156 gtkut_widget_set_can_focus(gtk_bin_get_child(GTK_BIN(item)), FALSE); \
2157 gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE); \
2158 gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE); \
2159 g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item); \
2160 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1); \
2163 #define TOOLBAR_TOGGLE_ITEM(item,icon,text,tooltip) { \
2164 item = GTK_WIDGET(gtk_toggle_tool_button_new()); \
2165 gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(item), icon); \
2166 gtk_tool_button_set_label(GTK_TOOL_BUTTON(item), text); \
2167 gtkut_widget_set_can_focus(gtk_bin_get_child(GTK_BIN(item)), FALSE); \
2168 gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE); \
2169 gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE); \
2170 g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item); \
2171 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1); \
2174 #define TOOLBAR_MENUITEM(item,icon,text,tooltip,menutip) { \
2175 GtkWidget *child = NULL, *btn = NULL, *arr = NULL; \
2176 GList *gchild = NULL; \
2177 item = GTK_WIDGET(gtk_menu_tool_button_new(icon, text)); \
2178 gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE); \
2179 gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE); \
2180 g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item); \
2181 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1); \
2182 child = gtk_bin_get_child(GTK_BIN(item)); \
2183 gchild = gtk_container_get_children( \
2184 GTK_CONTAINER(child)); \
2185 btn = (GtkWidget *)gchild->data; \
2186 gtkut_widget_set_can_focus(btn, FALSE); \
2187 arr = (GtkWidget *)(gchild->next?gchild->next->data:NULL); \
2188 gtkut_widget_set_can_focus(arr, FALSE); \
2189 g_list_free(gchild); \
2190 gchild = gtk_container_get_children(GTK_CONTAINER(arr)); \
2191 gtk_widget_set_size_request(GTK_WIDGET(gchild->data), 9, -1); \
2192 g_list_free(gchild); \
2196 #define ADD_MENU_ITEM(name,cb,data) { \
2197 item = gtk_menu_item_new_with_mnemonic(name); \
2198 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); \
2199 g_signal_connect(G_OBJECT(item), "activate", \
2202 g_object_set_data(G_OBJECT(item), "int-value", GINT_TO_POINTER(data)); \
2203 gtk_widget_show(item); \
2206 static void toolbar_reply_menu_cb(GtkWidget *widget, gpointer data)
2208 gpointer int_value = g_object_get_data(G_OBJECT(widget), "int-value");
2209 ToolbarItem *toolbar_item = (ToolbarItem *)data;
2211 toolbar_reply(toolbar_item, GPOINTER_TO_INT(int_value));
2214 static void toolbar_learn_menu_cb(GtkWidget *widget, gpointer data)
2216 gpointer int_value = g_object_get_data(G_OBJECT(widget), "int-value");
2217 ToolbarItem *toolbar_item = (ToolbarItem *)data;
2219 toolbar_learn(toolbar_item, GPOINTER_TO_INT(int_value));
2222 static void toolbar_delete_dup_menu_cb(GtkWidget *widget, gpointer data)
2224 gpointer int_value = g_object_get_data(G_OBJECT(widget), "int-value");
2225 ToolbarItem *toolbar_item = (ToolbarItem *)data;
2227 toolbar_delete_dup(toolbar_item, GPOINTER_TO_INT(int_value));
2231 * Create a new toolbar with specified type
2232 * if a callback list is passed it will be used before the
2233 * common callback list
2235 Toolbar *toolbar_create(ToolbarType type,
2236 GtkWidget *container,
2239 ToolbarItem *toolbar_item;
2242 GtkWidget *icon_wid = NULL;
2243 GtkWidget *icon_news;
2244 GtkWidget *icon_ham;
2246 ToolbarClawsActions *action_item;
2248 GSList *toolbar_list;
2249 Toolbar *toolbar_data;
2251 toolbar_read_config_file(type);
2252 toolbar_list = toolbar_get_list(type);
2254 toolbar_data = g_new0(Toolbar, 1);
2256 toolbar = gtk_toolbar_new();
2258 gtk_orientable_set_orientation(GTK_ORIENTABLE(toolbar), GTK_ORIENTATION_HORIZONTAL);
2260 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_BOTH);
2261 gtk_toolbar_set_show_arrow(GTK_TOOLBAR(toolbar), TRUE);
2263 for (cur = toolbar_list; cur != NULL; cur = cur->next) {
2265 if (g_ascii_strcasecmp(((ToolbarItem*)cur->data)->file, TOOLBAR_TAG_SEPARATOR) == 0) {
2266 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), gtk_separator_tool_item_new(), -1);
2270 toolbar_item = g_new0(ToolbarItem, 1);
2271 toolbar_item->index = ((ToolbarItem*)cur->data)->index;
2272 toolbar_item->file = g_strdup(((ToolbarItem*)cur->data)->file);
2273 toolbar_item->text = g_strdup(((ToolbarItem*)cur->data)->text);
2274 toolbar_item->parent = data;
2275 toolbar_item->type = type;
2277 /* collect toolbar items in list to keep track */
2278 toolbar_data->item_list =
2279 g_slist_append(toolbar_data->item_list,
2281 icon_wid = stock_pixmap_widget(stock_pixmap_get_icon(toolbar_item->file));
2283 switch (toolbar_item->index) {
2286 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Go to folder list"));
2287 toolbar_data->folders_btn = item;
2290 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2291 _("Receive Mail from all Accounts"),
2292 _("Receive Mail from selected Account"));
2293 toolbar_data->getall_btn = item;
2296 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Receive Mail from current Account"));
2297 toolbar_data->get_btn = item;
2300 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Send Queued Messages"));
2301 toolbar_data->send_btn = item;
2304 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Close window"));
2305 toolbar_data->close_window_btn = item;
2308 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Open preferences"));
2309 toolbar_data->preferences_btn = item;
2312 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Open email"));
2313 toolbar_data->open_mail_btn = item;
2315 case A_COMPOSE_EMAIL:
2316 #ifndef GENERIC_UMPC
2317 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2319 _("Compose with selected Account"));
2320 toolbar_data->compose_mail_btn = item;
2321 toolbar_data->compose_mail_icon = icon_wid;
2322 g_object_ref(toolbar_data->compose_mail_icon);
2324 icon_news = stock_pixmap_widget(STOCK_PIXMAP_NEWS_COMPOSE);
2325 toolbar_data->compose_news_icon = icon_news;
2326 g_object_ref(toolbar_data->compose_news_icon);
2328 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2329 _("Compose Email"));
2330 toolbar_data->compose_mail_btn = item;
2331 toolbar_data->compose_mail_icon = icon_wid;
2333 icon_news = stock_pixmap_widget(STOCK_PIXMAP_NEWS_COMPOSE);
2334 toolbar_data->compose_news_icon = icon_news;
2338 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2341 toolbar_data->learn_spam_btn = item;
2342 toolbar_data->learn_spam_icon = icon_wid;
2343 g_object_ref(toolbar_data->learn_spam_icon);
2345 icon_ham = stock_pixmap_widget(STOCK_PIXMAP_HAM_BTN);
2346 toolbar_data->learn_ham_icon = icon_ham;
2347 g_object_ref(toolbar_data->learn_ham_icon);
2349 menu = gtk_menu_new();
2350 ADD_MENU_ITEM(_("Learn as _Spam"), toolbar_learn_menu_cb, TRUE);
2351 ADD_MENU_ITEM(_("Learn as _Ham"), toolbar_learn_menu_cb, FALSE);
2352 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->learn_spam_btn), menu);
2355 #ifndef GENERIC_UMPC
2356 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2357 _("Delete duplicates"),
2358 _("Delete duplicates options"));
2359 toolbar_data->delete_dup_btn = item;
2361 menu = gtk_menu_new();
2362 ADD_MENU_ITEM(_("Delete duplicates in selected folder"), toolbar_delete_dup_menu_cb, FALSE);
2363 ADD_MENU_ITEM(_("Delete duplicates in all folders"), toolbar_delete_dup_menu_cb, TRUE);
2364 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->delete_dup_btn), menu);
2366 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Delete duplicates"));
2367 toolbar_data->delete_dup_btn = item;
2370 case A_REPLY_MESSAGE:
2371 #ifndef GENERIC_UMPC
2372 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2373 _("Reply to Message"),
2374 _("Reply to Message options"));
2375 toolbar_data->reply_btn = item;
2377 menu = gtk_menu_new();
2378 ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_WITH_QUOTE);
2379 ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_WITHOUT_QUOTE);
2380 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->reply_btn), menu);
2382 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2383 _("Reply to Message"));
2384 toolbar_data->reply_btn = item;
2387 case A_REPLY_SENDER:
2388 #ifndef GENERIC_UMPC
2389 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2390 _("Reply to Sender"),
2391 _("Reply to Sender options"));
2392 toolbar_data->replysender_btn = item;
2394 menu = gtk_menu_new();
2395 ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE);
2396 ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE);
2397 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->replysender_btn), menu);
2399 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2400 _("Reply to Sender"));
2401 toolbar_data->replysender_btn = item;
2405 #ifndef GENERIC_UMPC
2406 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2408 _("Reply to All options"));
2409 toolbar_data->replyall_btn = item;
2411 menu = gtk_menu_new();
2412 ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE);
2413 ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE);
2414 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->replyall_btn), menu);
2416 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2418 toolbar_data->replyall_btn = item;
2422 #ifndef GENERIC_UMPC
2423 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2424 _("Reply to Mailing-list"),
2425 _("Reply to Mailing-list options"));
2426 toolbar_data->replylist_btn = item;
2428 menu = gtk_menu_new();
2429 ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_LIST_WITH_QUOTE);
2430 ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE);
2431 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->replylist_btn), menu);
2433 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2434 _("Reply to Mailing-list"));
2435 toolbar_data->replylist_btn = item;
2439 #ifndef GENERIC_UMPC
2440 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2441 _("Forward Message"),
2442 _("Forward Message options"));
2443 toolbar_data->fwd_btn = item;
2445 menu = gtk_menu_new();
2446 ADD_MENU_ITEM(_("_Forward"), toolbar_reply_menu_cb, COMPOSE_FORWARD_INLINE);
2447 ADD_MENU_ITEM(_("For_ward as attachment"), toolbar_reply_menu_cb, COMPOSE_FORWARD_AS_ATTACH);
2448 ADD_MENU_ITEM(_("Redirec_t"), toolbar_reply_menu_cb, COMPOSE_REDIRECT);
2449 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->fwd_btn), menu);
2451 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2452 _("Forward Message"));
2453 toolbar_data->fwd_btn = item;
2457 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Trash Message"));
2458 toolbar_data->trash_btn = item;
2461 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Delete Message"));
2462 toolbar_data->delete_btn = item;
2465 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Execute"));
2466 toolbar_data->exec_btn = item;
2469 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Go to Previous Unread Message"));
2470 toolbar_data->prev_btn = item;
2473 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Go to Next Unread Message"));
2474 toolbar_data->next_btn = item;
2477 /* Compose Toolbar */
2479 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Send Message"));
2480 toolbar_data->send_btn = item;
2483 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Put into queue folder and send later"));
2484 toolbar_data->sendl_btn = item;
2487 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Save to draft folder"));
2488 toolbar_data->draft_btn = item;
2491 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Insert file"));
2492 toolbar_data->insert_btn = item;
2495 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Attach file"));
2496 toolbar_data->attach_btn = item;
2499 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Insert signature"));
2500 toolbar_data->sig_btn = item;
2503 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Replace signature"));
2504 toolbar_data->repsig_btn = item;
2507 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Edit with external editor"));
2508 toolbar_data->exteditor_btn = item;
2510 case A_LINEWRAP_CURRENT:
2511 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Wrap long lines of current paragraph"));
2512 toolbar_data->linewrap_current_btn = item;
2514 case A_LINEWRAP_ALL:
2515 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Wrap all long lines"));
2516 toolbar_data->linewrap_all_btn = item;
2519 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Address book"));
2520 toolbar_data->addrbook_btn = item;
2523 case A_CHECK_SPELLING:
2524 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Check spelling"));
2525 toolbar_data->spellcheck_btn = item;
2528 case A_PRIVACY_SIGN:
2529 TOOLBAR_TOGGLE_ITEM(item,icon_wid,toolbar_item->text,_("Sign"));
2530 g_signal_connect (G_OBJECT(item), "toggled",
2531 G_CALLBACK(toolbar_privacy_sign_toggled_cb), NULL);
2532 /* Call the "toggled" handler to set correct tooltip. */
2533 toolbar_privacy_sign_toggled_cb(item, NULL);
2534 toolbar_data->privacy_sign_btn = item;
2536 case A_PRIVACY_ENCRYPT:
2537 TOOLBAR_TOGGLE_ITEM(item,icon_wid,toolbar_item->text,_("Encrypt"));
2538 g_signal_connect (G_OBJECT(item), "toggled",
2539 G_CALLBACK(toolbar_privacy_encrypt_toggled_cb), NULL);
2540 /* Call the "toggled" handler to set correct tooltip. */
2541 toolbar_privacy_encrypt_toggled_cb(item, NULL);
2542 toolbar_data->privacy_encrypt_btn = item;
2545 case A_CLAWS_ACTIONS:
2546 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,toolbar_item->text);
2547 action_item = g_new0(ToolbarClawsActions, 1);
2548 action_item->widget = item;
2549 action_item->name = g_strdup(toolbar_item->text);
2551 toolbar_data->action_list =
2552 g_slist_append(toolbar_data->action_list,
2556 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Cancel receiving"));
2557 toolbar_data->cancel_inc_btn = item;
2560 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Cancel sending"));
2561 toolbar_data->cancel_send_btn = item;
2564 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Cancel receiving/sending"));
2565 toolbar_data->cancel_all_btn = item;
2567 case A_CLAWS_PLUGINS:
2568 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text, toolbar_item->text);
2571 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2572 toolbar_ret_descr_from_val(toolbar_item->index));
2573 /* find and set the tool tip text */
2578 toolbar_data->toolbar = toolbar;
2580 gtk_widget_show_all(toolbar);
2582 if (type == TOOLBAR_MAIN) {
2584 MainWindow *mainwin = mainwindow_get_mainwindow();
2585 GtkWidget *progressbar = gtk_progress_bar_new();
2586 item = GTK_WIDGET(gtk_tool_item_new());
2587 gtk_container_add (GTK_CONTAINER (item), progressbar);
2588 gtk_widget_show(item);
2589 gtk_widget_set_size_request(progressbar, 84, -1);
2590 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1);
2591 mainwin->progressbar = progressbar;
2593 activate_compose_button(toolbar_data,
2594 prefs_common.toolbar_style,
2595 toolbar_data->compose_btn_type);
2597 if (type != TOOLBAR_COMPOSE)
2598 activate_learn_button(toolbar_data, prefs_common.toolbar_style,
2601 gtk_container_add(GTK_CONTAINER(container), toolbar);
2602 gtk_container_set_border_width(GTK_CONTAINER(container), 0);
2604 return toolbar_data;
2608 * Free toolbar structures
2610 void toolbar_destroy(Toolbar * toolbar) {
2612 TOOLBAR_DESTROY_ITEMS(toolbar->item_list);
2613 TOOLBAR_DESTROY_ACTIONS(toolbar->action_list);
2616 void toolbar_update(ToolbarType type, gpointer data)
2618 Toolbar *toolbar_data;
2619 GtkWidget *handlebox;
2620 MainWindow *mainwin = (MainWindow*)data;
2621 Compose *compose = (Compose*)data;
2622 MessageView *msgview = (MessageView*)data;
2624 #ifndef GENERIC_UMPC
2627 toolbar_data = mainwin->toolbar;
2628 handlebox = mainwin->handlebox;
2630 case TOOLBAR_COMPOSE:
2631 toolbar_data = compose->toolbar;
2632 handlebox = compose->handlebox;
2634 case TOOLBAR_MSGVIEW:
2635 toolbar_data = msgview->toolbar;
2636 handlebox = msgview->handlebox;
2642 gtk_container_remove(GTK_CONTAINER(handlebox),
2643 GTK_WIDGET(toolbar_data->toolbar));
2645 toolbar_init(toolbar_data);
2646 toolbar_data = toolbar_create(type, handlebox, data);
2650 toolbar_data = mainwin->toolbar;
2651 handlebox = mainwin->window;
2653 case TOOLBAR_COMPOSE:
2654 toolbar_data = compose->toolbar;
2655 handlebox = compose->window;
2657 case TOOLBAR_MSGVIEW:
2658 toolbar_data = msgview->toolbar;
2659 handlebox = msgview->window;
2664 toolbar_init(toolbar_data);
2665 toolbar_data = toolbar_create(type, handlebox, data);
2670 mainwin->toolbar = toolbar_data;
2672 case TOOLBAR_COMPOSE:
2673 compose->toolbar = toolbar_data;
2675 case TOOLBAR_MSGVIEW:
2676 msgview->toolbar = toolbar_data;
2680 toolbar_style(type, prefs_common.toolbar_style, data);
2682 if (type == TOOLBAR_MAIN) {
2683 toolbar_main_set_sensitive((MainWindow*)data);
2684 account_set_menu_only_toolbar();
2688 #define GTK_BUTTON_SET_SENSITIVE(widget,sensitive) { \
2689 gtk_widget_set_sensitive(widget, sensitive); \
2692 void toolbar_main_set_sensitive(gpointer data)
2694 SensitiveCondMask state;
2696 MainWindow *mainwin = (MainWindow*)data;
2697 Toolbar *toolbar = mainwin->toolbar;
2699 GSList *entry_list = NULL;
2701 typedef struct _Entry Entry;
2704 SensitiveCondMask cond;
2708 #define SET_WIDGET_COND(w, ...) \
2710 Entry *e = g_new0(Entry, 1); \
2712 e->cond = main_window_get_mask(__VA_ARGS__, -1); \
2713 entry_list = g_slist_append(entry_list, e); \
2716 /* match all bit flags */
2718 if (toolbar->get_btn)
2719 SET_WIDGET_COND(toolbar->get_btn,
2720 M_HAVE_ACCOUNT, M_UNLOCKED, M_HAVE_RETRIEVABLE_ACCOUNT);
2722 if (toolbar->getall_btn) {
2723 SET_WIDGET_COND(toolbar->getall_btn,
2724 M_HAVE_ACCOUNT, M_UNLOCKED, M_HAVE_ANY_RETRIEVABLE_ACCOUNT);
2726 if (toolbar->send_btn) {
2727 SET_WIDGET_COND(toolbar->send_btn,
2728 M_HAVE_QUEUED_MAILS);
2730 if (toolbar->compose_mail_btn) {
2731 SET_WIDGET_COND(toolbar->compose_mail_btn,
2734 if (toolbar->close_window_btn) {
2735 SET_WIDGET_COND(toolbar->close_window_btn,
2738 if (toolbar->open_mail_btn) {
2739 SET_WIDGET_COND(toolbar->open_mail_btn,
2740 M_TARGET_EXIST, M_SUMMARY_ISLIST);
2742 if (toolbar->reply_btn) {
2743 SET_WIDGET_COND(toolbar->reply_btn,
2744 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2746 if (toolbar->replyall_btn) {
2747 SET_WIDGET_COND(toolbar->replyall_btn,
2748 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2750 if (toolbar->replylist_btn) {
2751 SET_WIDGET_COND(toolbar->replylist_btn,
2752 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2754 if (toolbar->replysender_btn) {
2755 SET_WIDGET_COND(toolbar->replysender_btn,
2756 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2758 if (toolbar->fwd_btn) {
2759 SET_WIDGET_COND(toolbar->fwd_btn,
2760 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2763 if (prefs_common.next_unread_msg_dialog == NEXTUNREADMSGDIALOG_ASSUME_NO) {
2764 SET_WIDGET_COND(toolbar->next_btn, M_MSG_EXIST, M_SUMMARY_ISLIST);
2766 SET_WIDGET_COND(toolbar->next_btn, -1);
2769 if (toolbar->trash_btn)
2770 SET_WIDGET_COND(toolbar->trash_btn,
2771 M_TARGET_EXIST, M_ALLOW_DELETE, M_NOT_NEWS);
2773 if (toolbar->delete_btn)
2774 SET_WIDGET_COND(toolbar->delete_btn,
2775 M_TARGET_EXIST, M_ALLOW_DELETE);
2777 if (toolbar->delete_dup_btn)
2778 SET_WIDGET_COND(toolbar->delete_dup_btn,
2779 M_MSG_EXIST, M_ALLOW_DELETE, M_SUMMARY_ISLIST);
2781 if (toolbar->exec_btn)
2782 SET_WIDGET_COND(toolbar->exec_btn,
2785 if (toolbar->learn_spam_btn)
2786 SET_WIDGET_COND(toolbar->learn_spam_btn,
2787 M_TARGET_EXIST, M_CAN_LEARN_SPAM, M_SUMMARY_ISLIST);
2789 if (toolbar->cancel_inc_btn)
2790 SET_WIDGET_COND(toolbar->cancel_inc_btn,
2793 if (toolbar->cancel_send_btn)
2794 SET_WIDGET_COND(toolbar->cancel_send_btn,
2797 for (cur = toolbar->action_list; cur != NULL; cur = cur->next) {
2798 ToolbarClawsActions *act = (ToolbarClawsActions*)cur->data;
2800 SET_WIDGET_COND(act->widget, M_TARGET_EXIST, M_UNLOCKED);
2803 state = main_window_get_current_state(mainwin);
2805 for (cur = entry_list; cur != NULL; cur = cur->next) {
2806 Entry *e = (Entry*) cur->data;
2808 if (e->widget != NULL) {
2809 sensitive = ((e->cond & state) == e->cond);
2810 GTK_BUTTON_SET_SENSITIVE(e->widget, sensitive);
2814 while (entry_list != NULL) {
2815 Entry *e = (Entry*) entry_list->data;
2818 entry_list = g_slist_remove(entry_list, e);
2821 /* match any bit flags */
2823 if (toolbar->cancel_all_btn)
2824 SET_WIDGET_COND(toolbar->cancel_all_btn,
2825 M_INC_ACTIVE, M_SEND_ACTIVE);
2827 for (cur = entry_list; cur != NULL; cur = cur->next) {
2828 Entry *e = (Entry*) cur->data;
2830 if (e->widget != NULL) {
2831 sensitive = ((e->cond & state) != 0);
2832 GTK_BUTTON_SET_SENSITIVE(e->widget, sensitive);
2836 while (entry_list != NULL) {
2837 Entry *e = (Entry*) entry_list->data;
2840 entry_list = g_slist_remove(entry_list, e);
2843 g_slist_free(entry_list);
2845 activate_compose_button(toolbar,
2846 prefs_common.toolbar_style,
2847 toolbar->compose_btn_type);
2849 #undef SET_WIDGET_COND
2852 void toolbar_comp_set_sensitive(gpointer data, gboolean sensitive)
2854 Compose *compose = (Compose*)data;
2855 GSList *items = compose->toolbar->action_list;
2857 if (compose->toolbar->send_btn)
2858 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->send_btn, sensitive);
2859 if (compose->toolbar->sendl_btn)
2860 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->sendl_btn, sensitive);
2861 if (compose->toolbar->draft_btn )
2862 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->draft_btn , sensitive);
2863 if (compose->toolbar->insert_btn )
2864 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->insert_btn , sensitive);
2865 if (compose->toolbar->attach_btn)
2866 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->attach_btn, sensitive);
2867 if (compose->toolbar->sig_btn)
2868 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->sig_btn, sensitive);
2869 if (compose->toolbar->repsig_btn)
2870 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->repsig_btn, sensitive);
2871 if (compose->toolbar->exteditor_btn)
2872 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->exteditor_btn, sensitive);
2873 if (compose->toolbar->linewrap_current_btn)
2874 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->linewrap_current_btn, sensitive);
2875 if (compose->toolbar->linewrap_all_btn)
2876 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->linewrap_all_btn, sensitive);
2877 if (compose->toolbar->addrbook_btn)
2878 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->addrbook_btn, sensitive);
2880 if (compose->toolbar->spellcheck_btn)
2881 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->spellcheck_btn, sensitive);
2883 for (; items != NULL; items = g_slist_next(items)) {
2884 ToolbarClawsActions *item = (ToolbarClawsActions *)items->data;
2885 GTK_BUTTON_SET_SENSITIVE(item->widget, sensitive);
2890 * Initialize toolbar structure
2892 static void toolbar_init(Toolbar * toolbar)
2895 toolbar->toolbar = NULL;
2896 toolbar->folders_btn = NULL;
2897 toolbar->get_btn = NULL;
2898 toolbar->getall_btn = NULL;
2899 toolbar->send_btn = NULL;
2900 toolbar->compose_mail_btn = NULL;
2901 toolbar->compose_mail_icon = NULL;
2902 toolbar->compose_news_icon = NULL;
2903 toolbar->reply_btn = NULL;
2904 toolbar->replysender_btn = NULL;
2905 toolbar->replyall_btn = NULL;
2906 toolbar->replylist_btn = NULL;
2907 toolbar->fwd_btn = NULL;
2908 toolbar->trash_btn = NULL;
2909 toolbar->delete_btn = NULL;
2910 toolbar->delete_dup_btn = NULL;
2911 toolbar->prev_btn = NULL;
2912 toolbar->next_btn = NULL;
2913 toolbar->exec_btn = NULL;
2914 toolbar->separator = NULL;
2915 toolbar->learn_spam_btn = NULL;
2916 toolbar->learn_spam_icon = NULL;
2917 toolbar->learn_ham_icon = NULL;
2918 toolbar->cancel_inc_btn = NULL;
2919 toolbar->cancel_send_btn = NULL;
2920 toolbar->cancel_all_btn = NULL;
2922 /* compose buttons */
2923 toolbar->sendl_btn = NULL;
2924 toolbar->draft_btn = NULL;
2925 toolbar->insert_btn = NULL;
2926 toolbar->attach_btn = NULL;
2927 toolbar->sig_btn = NULL;
2928 toolbar->repsig_btn = NULL;
2929 toolbar->exteditor_btn = NULL;
2930 toolbar->linewrap_current_btn = NULL;
2931 toolbar->linewrap_all_btn = NULL;
2932 toolbar->addrbook_btn = NULL;
2934 toolbar->open_mail_btn = NULL;
2935 toolbar->close_window_btn = NULL;
2936 toolbar->preferences_btn = NULL;
2937 toolbar->action_list = NULL;
2938 toolbar->item_list = NULL;
2940 toolbar->spellcheck_btn = NULL;
2943 toolbar->privacy_sign_btn = NULL;
2944 toolbar->privacy_encrypt_btn = NULL;
2946 toolbar_destroy(toolbar);
2951 static void toolbar_reply(gpointer data, guint action)
2953 ToolbarItem *toolbar_item = (ToolbarItem*)data;
2954 MainWindow *mainwin;
2955 MessageView *msgview;
2956 GSList *msginfo_list = NULL;
2958 cm_return_if_fail(toolbar_item != NULL);
2960 switch (toolbar_item->type) {
2962 mainwin = (MainWindow*)toolbar_item->parent;
2963 msginfo_list = summary_get_selection(mainwin->summaryview);
2964 msgview = (MessageView*)mainwin->messageview;
2966 case TOOLBAR_MSGVIEW:
2967 msgview = (MessageView*)toolbar_item->parent;
2968 cm_return_if_fail(msgview != NULL);
2969 msginfo_list = g_slist_append(msginfo_list, msgview->msginfo);
2975 cm_return_if_fail(msgview != NULL);
2976 cm_return_if_fail(msginfo_list != NULL);
2977 compose_reply_from_messageview(msgview, msginfo_list, action);
2978 g_slist_free(msginfo_list);
2980 /* TODO: update reply state ion summaryview */
2984 /* exported functions */
2986 void inc_mail_cb(gpointer data, guint action, GtkWidget *widget)
2988 MainWindow *mainwin = (MainWindow*)data;
2990 inc_mail(mainwin, prefs_common.newmail_notify_manu);
2993 void inc_all_account_mail_cb(gpointer data, guint action, GtkWidget *widget)
2995 MainWindow *mainwin = (MainWindow*)data;
2997 inc_all_account_mail(mainwin, FALSE, prefs_common.newmail_notify_manu);
3000 void send_queue_cb(gpointer data, guint action, GtkWidget *widget)
3004 gboolean got_error = FALSE;
3005 gchar *errstr = NULL;
3007 if (prefs_common.work_offline)
3008 if (alertpanel(_("Offline warning"),
3009 _("You're working offline. Override?"),
3010 GTK_STOCK_NO, GTK_STOCK_YES,
3011 NULL) != G_ALERTALTERNATE)
3014 /* ask for confirmation before sending queued messages only
3015 in online mode and if there is at least one message queued
3016 in any of the folder queue
3018 if (prefs_common.confirm_send_queued_messages) {
3020 /* check if there's a queued message */
3021 for (list = folder_get_list(); !found && list != NULL; list = list->next) {
3022 Folder *folder = list->data;
3024 found = !procmsg_queue_is_empty(folder->queue);
3026 /* if necessary, ask for confirmation before sending */
3027 if (found && !prefs_common.work_offline) {
3028 if (alertpanel(_("Send queued messages"),
3029 _("Send all queued messages?"),
3030 GTK_STOCK_CANCEL, _("_Send"),
3031 NULL) != G_ALERTALTERNATE)
3036 for (list = folder_get_list(); list != NULL; list = list->next) {
3037 Folder *folder = list->data;
3039 if (folder->queue) {
3040 if (procmsg_send_queue(folder->queue,
3041 prefs_common.savemsg,
3048 alertpanel_error_log(_("Some errors occurred while "
3049 "sending queued messages."));
3051 alertpanel_error_log(_("Some errors occurred "
3052 "while sending queued messages:\n%s"), errstr);
3058 void compose_mail_cb(gpointer data, guint action, GtkWidget *widget)
3060 MainWindow *mainwin = (MainWindow*)data;
3061 PrefsAccount *ac = NULL;
3062 FolderItem *item = mainwin->summaryview->folder_item;
3067 ac = account_find_from_item(item);
3068 if (ac && ac->protocol != A_NNTP && ac->protocol != A_IMAP4) {
3069 compose_new_with_folderitem(ac, item, NULL); /* CLAWS */
3075 * CLAWS - use current account
3077 if (cur_account && (cur_account->protocol != A_NNTP)) {
3078 compose_new_with_folderitem(cur_account, item, NULL);
3083 * CLAWS - just get the first one
3085 list = account_get_list();
3086 for (cur = list ; cur != NULL ; cur = g_list_next(cur)) {
3087 ac = (PrefsAccount *) cur->data;
3088 if (ac->protocol != A_NNTP) {
3089 compose_new_with_folderitem(ac, item, NULL);
3095 void compose_news_cb(gpointer data, guint action, GtkWidget *widget)
3097 MainWindow *mainwin = (MainWindow*)data;
3098 PrefsAccount * ac = NULL;
3102 if (mainwin->summaryview->folder_item) {
3103 ac = mainwin->summaryview->folder_item->folder->account;
3104 if (ac && ac->protocol == A_NNTP) {
3105 compose_new_with_folderitem(ac,
3106 mainwin->summaryview->folder_item, NULL);
3111 list = account_get_list();
3112 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
3113 ac = (PrefsAccount *) cur->data;
3114 if (ac->protocol == A_NNTP) {
3115 compose_new_with_folderitem(ac,
3116 mainwin->summaryview->folder_item, NULL);