2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2001-2013 Hiroyuki Yamamoto and the Claws Mail team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 * General functions for accessing address book files.
26 #include "claws-features.h"
32 #include <glib/gi18n.h>
41 #include "mainwindow.h"
42 #include "summaryview.h"
47 #include "prefs_gtk.h"
49 #include "stock_pixmap.h"
50 #include "manage_window.h"
56 #include "prefs_actions.h"
57 #include "prefs_common.h"
58 #include "prefs_toolbar.h"
59 #include "alertpanel.h"
62 #include "send_message.h"
63 #ifndef USE_ALT_ADDRBOOK
64 #include "addressbook.h"
66 #include "addressbook-dbus.h"
70 #define TOOLBAR_TAG_INDEX "toolbar"
71 #define TOOLBAR_TAG_ITEM "item"
72 #define TOOLBAR_TAG_SEPARATOR "separator"
74 #define TOOLBAR_ICON_FILE "file"
75 #define TOOLBAR_ICON_TEXT "text"
76 #define TOOLBAR_ICON_ACTION "action"
78 static void toolbar_init(Toolbar * toolbar);
79 static gboolean toolbar_is_duplicate (gint action,
81 static void toolbar_parse_item (XMLFile *file,
82 ToolbarType source, gboolean *rewrite);
84 static gint toolbar_ret_val_from_text (const gchar *text);
85 static gchar *toolbar_ret_text_from_val (gint val);
87 static void toolbar_set_default_main (void);
88 static void toolbar_set_default_compose (void);
89 static void toolbar_set_default_msgview (void);
91 static void toolbar_style (ToolbarType type,
95 static MainWindow *get_mainwin (gpointer data);
96 static void activate_compose_button (Toolbar *toolbar,
98 ComposeButtonType type);
100 /* toolbar callbacks */
101 static void toolbar_reply (gpointer data,
103 static void toolbar_learn (gpointer data,
105 static void toolbar_delete_cb (GtkWidget *widget,
107 static void toolbar_trash_cb (GtkWidget *widget,
110 static void toolbar_compose_cb (GtkWidget *widget,
113 static void toolbar_learn_cb (GtkWidget *widget,
116 static void toolbar_reply_cb (GtkWidget *widget,
119 static void toolbar_reply_to_all_cb (GtkWidget *widget,
122 static void toolbar_reply_to_list_cb (GtkWidget *widget,
125 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
128 static void toolbar_forward_cb (GtkWidget *widget,
131 static void toolbar_prev_unread_cb (GtkWidget *widget,
133 static void toolbar_next_unread_cb (GtkWidget *widget,
136 static void toolbar_ignore_thread_cb (GtkWidget *widget,
139 static void toolbar_watch_thread_cb (GtkWidget *widget,
142 static void toolbar_mark_cb (GtkWidget *widget,
145 static void toolbar_unmark_cb (GtkWidget *widget,
148 static void toolbar_lock_cb (GtkWidget *widget,
151 static void toolbar_ulock_cb (GtkWidget *widget,
154 static void toolbar_all_read_cb (GtkWidget *widget,
157 static void toolbar_all_unread_cb (GtkWidget *widget,
160 static void toolbar_read_cb (GtkWidget *widget,
163 static void toolbar_unread_cb (GtkWidget *widget,
166 static void toolbar_print_cb (GtkWidget *widget,
169 static void toolbar_actions_execute_cb (GtkWidget *widget,
171 static void toolbar_plugins_execute_cb (GtkWidget *widget,
175 static void toolbar_send_cb (GtkWidget *widget,
177 static void toolbar_send_later_cb (GtkWidget *widget,
179 static void toolbar_draft_cb (GtkWidget *widget,
181 static void toolbar_close_cb (GtkWidget *widget,
183 static void toolbar_preferences_cb (GtkWidget *widget,
185 static void toolbar_open_mail_cb (GtkWidget *widget,
187 static void toolbar_insert_cb (GtkWidget *widget,
189 static void toolbar_attach_cb (GtkWidget *widget,
191 static void toolbar_sig_cb (GtkWidget *widget,
193 static void toolbar_ext_editor_cb (GtkWidget *widget,
195 static void toolbar_linewrap_current_cb (GtkWidget *widget,
197 static void toolbar_linewrap_all_cb (GtkWidget *widget,
199 static void toolbar_addrbook_cb (GtkWidget *widget,
202 static void toolbar_check_spelling_cb (GtkWidget *widget,
205 static void toolbar_cancel_inc_cb (GtkWidget *widget,
207 static void toolbar_cancel_send_cb (GtkWidget *widget,
209 static void toolbar_cancel_all_cb (GtkWidget *widget,
215 } toolbar_text [] = {
216 { "A_RECEIVE_ALL", N_("Receive Mail from all Accounts") },
217 { "A_RECEIVE_CUR", N_("Receive Mail from current Account") },
218 { "A_SEND_QUEUED", N_("Send Queued Messages") },
219 { "A_COMPOSE_EMAIL", N_("Compose Email") },
220 { "A_COMPOSE_NEWS", N_("Compose News") },
221 { "A_REPLY_MESSAGE", N_("Reply to Message") },
222 { "A_REPLY_SENDER", N_("Reply to Sender") },
223 { "A_REPLY_ALL", N_("Reply to All") },
224 { "A_REPLY_ML", N_("Reply to Mailing-list") },
225 { "A_OPEN_MAIL", N_("Open email") },
226 { "A_FORWARD", N_("Forward Message") },
227 { "A_TRASH", N_("Trash Message") },
228 { "A_DELETE_REAL", N_("Delete Message") },
229 { "A_EXECUTE", N_("Execute") },
230 { "A_GOTO_PREV", N_("Go to Previous Unread Message") },
231 { "A_GOTO_NEXT", N_("Go to Next Unread Message") },
233 { "A_IGNORE_THREAD", N_("Ignore thread") },
234 { "A_WATCH_THREAD", N_("Watch thread") },
235 { "A_MARK", N_("Mark Message") },
236 { "A_UNMARK", N_("Unmark Message") },
237 { "A_LOCK", N_("Lock Message") },
238 { "A_UNLOCK", N_("Unlock Message") },
239 { "A_ALL_READ", N_("Mark all Messages as read") },
240 { "A_ALL_UNREAD", N_("Mark all Messages as unread") },
241 { "A_READ", N_("Mark Message as read") },
242 { "A_UNREAD", N_("Mark Message as unread") },
244 { "A_PRINT", N_("Print") },
245 { "A_LEARN_SPAM", N_("Learn Spam or Ham") },
246 { "A_GO_FOLDERS", N_("Open folder/Go to folder list") },
247 { "A_PREFERENCES", N_("Preferences") },
249 { "A_SEND", N_("Send Message") },
250 { "A_SEND_LATER", N_("Put into queue folder and send later") },
251 { "A_DRAFT", N_("Save to draft folder") },
252 { "A_INSERT", N_("Insert file") },
253 { "A_ATTACH", N_("Attach file") },
254 { "A_SIG", N_("Insert signature") },
255 { "A_REP_SIG", N_("Replace signature") },
256 { "A_EXTEDITOR", N_("Edit with external editor") },
257 { "A_LINEWRAP_CURRENT", N_("Wrap long lines of current paragraph") },
258 { "A_LINEWRAP_ALL", N_("Wrap all long lines") },
259 { "A_ADDRBOOK", N_("Address book") },
261 { "A_CHECK_SPELLING", N_("Check spelling") },
263 { "A_CLAWS_ACTIONS", N_("Claws Mail Actions Feature") },
264 { "A_CANCEL_INC", N_("Cancel receiving") },
265 { "A_CANCEL_SEND", N_("Cancel sending") },
266 { "A_CANCEL_ALL", N_("Cancel receiving/sending") },
267 { "A_CLOSE", N_("Close window") },
268 { "A_SEPARATOR", N_("Separator") },
269 { "A_CLAWS_PLUGINS", N_("Claws Mail Plugins") }
272 /* migration table: support reading toolbar configuration files with
273 old action names and converting them to current action names,
274 see toolbar_parse_item(), which makes uses of this alias table.
277 const gchar *old_name;
278 const gchar *current_name;
279 } toolbar_migration [] = {
280 { "A_SYL_ACTIONS", "A_CLAWS_ACTIONS" },
281 { "A_SENDL", "A_SEND_LATER" },
285 /* struct holds configuration files and a list of
286 * currently active toolbar items
287 * TOOLBAR_MAIN, TOOLBAR_COMPOSE and TOOLBAR_MSGVIEW
291 const gchar *conf_file;
293 } toolbar_config[NUM_TOOLBARS] = {
294 { "toolbar_main.xml", NULL},
295 { "toolbar_compose.xml", NULL},
296 { "toolbar_msgview.xml", NULL}
299 gint toolbar_ret_val_from_descr(const gchar *descr)
303 for (i = 0; i < N_ACTION_VAL; i++) {
304 if (g_utf8_collate(gettext(toolbar_text[i].descr), descr) == 0)
311 gchar *toolbar_ret_descr_from_val(gint val)
313 cm_return_val_if_fail(val >=0 && val < N_ACTION_VAL, NULL);
315 return gettext(toolbar_text[val].descr);
318 static gint toolbar_ret_val_from_text(const gchar *text)
322 for (i = 0; i < N_ACTION_VAL; i++) {
323 if (g_utf8_collate(toolbar_text[i].index_str, text) == 0)
330 static gchar *toolbar_ret_text_from_val(gint val)
332 cm_return_val_if_fail(val >=0 && val < N_ACTION_VAL, NULL);
334 return toolbar_text[val].index_str;
337 static gboolean toolbar_is_duplicate(gint action, ToolbarType source)
341 if ((action == A_SEPARATOR) || (action == A_CLAWS_ACTIONS) || (action == A_CLAWS_PLUGINS))
344 for (cur = toolbar_config[source].item_list; cur != NULL; cur = cur->next) {
345 ToolbarItem *item = (ToolbarItem*) cur->data;
347 if (item->index == action)
353 /* depending on toolbar type this function
354 returns a list of available toolbar events being
355 displayed by prefs_toolbar
357 GList *toolbar_get_action_items(ToolbarType source)
362 if (source == TOOLBAR_MAIN) {
363 gint main_items[] = {
364 A_RECEIVE_ALL, A_RECEIVE_CUR, A_SEND_QUEUED,
365 A_COMPOSE_EMAIL, A_REPLY_MESSAGE, A_REPLY_SENDER,
366 A_REPLY_ALL, A_REPLY_ML, A_OPEN_MAIL, A_FORWARD,
367 A_TRASH, A_DELETE_REAL, A_EXECUTE, A_GOTO_PREV,
368 A_GOTO_NEXT, A_IGNORE_THREAD, A_WATCH_THREAD, A_MARK,
369 A_UNMARK, A_LOCK, A_UNLOCK, A_ALL_READ,
370 A_ALL_UNREAD, A_READ, A_UNREAD, A_PRINT,
371 A_ADDRBOOK, A_LEARN_SPAM, A_GO_FOLDERS,
372 A_CANCEL_INC, A_CANCEL_SEND, A_CANCEL_ALL, A_PREFERENCES };
374 for (i = 0; i < sizeof main_items / sizeof main_items[0]; i++) {
375 items = g_list_append(items, gettext(toolbar_text[main_items[i]].descr));
378 else if (source == TOOLBAR_COMPOSE) {
379 gint comp_items[] = {
380 A_SEND, A_SEND_LATER, A_DRAFT,
381 A_INSERT, A_ATTACH, A_SIG,
382 A_REP_SIG, A_EXTEDITOR, A_LINEWRAP_CURRENT,
383 A_LINEWRAP_ALL, A_ADDRBOOK,
389 for (i = 0; i < sizeof comp_items / sizeof comp_items[0]; i++)
390 items = g_list_append(items, gettext(toolbar_text[comp_items[i]].descr));
392 else if (source == TOOLBAR_MSGVIEW) {
393 gint msgv_items[] = {
394 A_COMPOSE_EMAIL, A_REPLY_MESSAGE, A_REPLY_SENDER,
395 A_REPLY_ALL, A_REPLY_ML, A_FORWARD,
396 A_TRASH, A_DELETE_REAL, A_GOTO_PREV, A_GOTO_NEXT,
397 A_ADDRBOOK, A_LEARN_SPAM, A_CLOSE };
399 for (i = 0; i < sizeof msgv_items / sizeof msgv_items[0]; i++)
400 items = g_list_append(items, gettext(toolbar_text[msgv_items[i]].descr));
406 static void toolbar_parse_item(XMLFile *file, ToolbarType source, gboolean *rewrite)
410 ToolbarItem *item = NULL;
412 g_return_if_fail(rewrite != NULL);
414 attr = xml_get_current_tag_attr(file);
415 item = g_new0(ToolbarItem, 1);
417 name = ((XMLAttr *)attr->data)->name;
418 value = ((XMLAttr *)attr->data)->value;
420 if (g_utf8_collate(name, TOOLBAR_ICON_FILE) == 0)
421 item->file = g_strdup (value);
422 else if (g_utf8_collate(name, TOOLBAR_ICON_TEXT) == 0)
423 item->text = g_strdup (*value ? gettext(value):"");
424 else if (g_utf8_collate(name, TOOLBAR_ICON_ACTION) == 0)
425 item->index = toolbar_ret_val_from_text(value);
427 if ((item->index == -1) && !strcmp(value, "A_DELETE")) {
429 item->index = A_TRASH;
431 item->file = g_strdup("trash_btn");
433 item->text = g_strdup(C_("Toolbar", "Trash"));
436 if (item->index == -1) {
437 /* item not found in table: try migrating old action names to current ones */
440 /* replace action name */
441 for (i = 0; toolbar_migration[i].old_name != NULL; i++) {
442 if (g_utf8_collate(value, toolbar_migration[i].old_name) == 0) {
443 item->index = toolbar_ret_val_from_text(toolbar_migration[i].current_name);
444 if (item->index != -1) {
446 debug_print("toolbar_parse_item: migrating action label from '%s' to '%s'\n",
447 value, toolbar_migration[i].current_name);
453 if ((item->index == -1) && !rewrite)
454 g_warning("toolbar_parse_item: unrecognized action name '%s'\n", value);
456 attr = g_list_next(attr);
458 if (item->index != -1) {
459 if (!toolbar_is_duplicate(item->index, source))
460 toolbar_config[source].item_list = g_slist_append(toolbar_config[source].item_list,
465 const gchar *toolbar_get_short_text(int action) {
467 case A_RECEIVE_ALL: return _("Get Mail");
468 case A_RECEIVE_CUR: return _("Get");
469 case A_SEND_QUEUED: return _("Send");
470 case A_COMPOSE_EMAIL: return C_("Toolbar", "Compose");
471 case A_COMPOSE_NEWS: return C_("Toolbar", "Compose");
472 case A_REPLY_MESSAGE: return _("Reply");
473 case A_REPLY_SENDER: return C_("Toolbar", "Sender");
474 case A_REPLY_ALL: return _("All");
475 case A_REPLY_ML: return _("List");
476 case A_OPEN_MAIL: return _("Open");
477 case A_FORWARD: return _("Forward");
478 case A_TRASH: return C_("Toolbar", "Trash");
479 case A_DELETE_REAL: return _("Delete");
480 case A_EXECUTE: return _("Execute");
481 case A_GOTO_PREV: return _("Prev");
482 case A_GOTO_NEXT: return _("Next");
484 case A_IGNORE_THREAD: return _("Ignore thread");
485 case A_WATCH_THREAD: return _("Watch thread");
486 case A_MARK: return _("Mark");
487 case A_UNMARK: return _("Unmark");
488 case A_LOCK: return _("Lock");
489 case A_UNLOCK: return _("Unlock");
490 case A_ALL_READ: return _("All read");
491 case A_ALL_UNREAD: return _("All unread");
492 case A_READ: return _("Read");
493 case A_UNREAD: return _("Unread");
495 case A_PRINT: return _("Print");
496 case A_LEARN_SPAM: return _("Spam");
497 case A_GO_FOLDERS: return _("Folders");
498 case A_PREFERENCES: return _("Preferences");
500 case A_SEND: return _("Send");
501 case A_SEND_LATER: return _("Send later");
502 case A_DRAFT: return _("Draft");
503 case A_INSERT: return _("Insert");
504 case A_ATTACH: return _("Attach");
505 case A_SIG: return _("Insert sig.");
506 case A_REP_SIG: return _("Replace sig.");
507 case A_EXTEDITOR: return _("Edit");
508 case A_LINEWRAP_CURRENT:return _("Wrap para.");
509 case A_LINEWRAP_ALL: return _("Wrap all");
510 case A_ADDRBOOK: return _("Address");
512 case A_CHECK_SPELLING: return _("Check spelling");
515 case A_CANCEL_INC: return _("Stop");
516 case A_CANCEL_SEND: return _("Stop");
517 case A_CANCEL_ALL: return _("Stop all");
518 case A_CLOSE: return _("Close");
523 gint toolbar_get_icon(int action) {
525 case A_RECEIVE_ALL: return STOCK_PIXMAP_MAIL_RECEIVE_ALL;
526 case A_RECEIVE_CUR: return STOCK_PIXMAP_MAIL_RECEIVE;
527 case A_SEND_QUEUED: return STOCK_PIXMAP_MAIL_SEND_QUEUE;
528 case A_COMPOSE_EMAIL: return STOCK_PIXMAP_MAIL_COMPOSE;
529 case A_COMPOSE_NEWS: return STOCK_PIXMAP_NEWS_COMPOSE;
530 case A_REPLY_MESSAGE: return STOCK_PIXMAP_MAIL_REPLY;
531 case A_REPLY_SENDER: return STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR;
532 case A_REPLY_ALL: return STOCK_PIXMAP_MAIL_REPLY_TO_ALL;
533 case A_REPLY_ML: return STOCK_PIXMAP_MAIL_REPLY_TO_LIST;
534 case A_OPEN_MAIL: return STOCK_PIXMAP_OPEN_MAIL;
535 case A_FORWARD: return STOCK_PIXMAP_MAIL_FORWARD;
536 case A_TRASH: return STOCK_PIXMAP_TRASH;
537 case A_DELETE_REAL: return STOCK_PIXMAP_DELETE;
538 case A_EXECUTE: return STOCK_PIXMAP_EXEC;
539 case A_GOTO_PREV: return STOCK_PIXMAP_UP_ARROW;
540 case A_GOTO_NEXT: return STOCK_PIXMAP_DOWN_ARROW;
542 case A_IGNORE_THREAD: return STOCK_PIXMAP_MARK_IGNORETHREAD;
543 case A_WATCH_THREAD: return STOCK_PIXMAP_MARK_WATCHTHREAD;
544 case A_MARK: return STOCK_PIXMAP_MARK_MARK;
545 case A_UNMARK: return STOCK_PIXMAP_MARK_UNMARK;
546 case A_LOCK: return STOCK_PIXMAP_MARK_LOCKED;
547 case A_UNLOCK: return STOCK_PIXMAP_MARK_UNLOCKED;
548 case A_ALL_READ: return STOCK_PIXMAP_MARK_ALLREAD;
549 case A_ALL_UNREAD: return STOCK_PIXMAP_MARK_ALLUNREAD;
550 case A_READ: return STOCK_PIXMAP_MARK_READ;
551 case A_UNREAD: return STOCK_PIXMAP_MARK_UNREAD;
553 case A_PRINT: return STOCK_PIXMAP_PRINTER;
554 case A_LEARN_SPAM: return STOCK_PIXMAP_SPAM_BTN;
555 case A_GO_FOLDERS: return STOCK_PIXMAP_GO_FOLDERS;
556 case A_PREFERENCES: return STOCK_PIXMAP_PREFERENCES;
558 case A_SEND: return STOCK_PIXMAP_MAIL_SEND;
559 case A_SEND_LATER: return STOCK_PIXMAP_MAIL_SEND_QUEUE;
560 case A_DRAFT: return STOCK_PIXMAP_MAIL;
561 case A_INSERT: return STOCK_PIXMAP_INSERT_FILE;
562 case A_ATTACH: return STOCK_PIXMAP_MAIL_ATTACH;
563 case A_SIG: return STOCK_PIXMAP_MAIL_SIGN;
564 case A_REP_SIG: return STOCK_PIXMAP_MAIL_SIGN;
565 case A_EXTEDITOR: return STOCK_PIXMAP_EDIT_EXTERN;
566 case A_LINEWRAP_CURRENT:return STOCK_PIXMAP_LINEWRAP_CURRENT;
567 case A_LINEWRAP_ALL: return STOCK_PIXMAP_LINEWRAP_ALL;
568 case A_ADDRBOOK: return STOCK_PIXMAP_ADDRESS_BOOK;
570 case A_CHECK_SPELLING: return STOCK_PIXMAP_CHECK_SPELLING;
573 case A_CANCEL_INC: return STOCK_PIXMAP_CANCEL;
574 case A_CANCEL_SEND: return STOCK_PIXMAP_CANCEL;
575 case A_CANCEL_ALL: return STOCK_PIXMAP_CANCEL;
576 case A_CLOSE: return STOCK_PIXMAP_CLOSE;
581 static void toolbar_set_default_main(void)
585 } default_toolbar[] = {
613 for (i = 0; i < sizeof(default_toolbar) / sizeof(default_toolbar[0]); i++) {
615 ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
617 if (default_toolbar[i].action != A_SEPARATOR) {
620 if (toolbar_get_icon(default_toolbar[i].action) > -1) {
621 file = stock_pixmap_get_name((StockPixmap)toolbar_get_icon(default_toolbar[i].action));
624 toolbar_item->file = g_strdup(file);
625 toolbar_item->index = default_toolbar[i].action;
626 toolbar_item->text = g_strdup(toolbar_get_short_text(default_toolbar[i].action));
629 toolbar_item->file = g_strdup(TOOLBAR_TAG_SEPARATOR);
630 toolbar_item->index = A_SEPARATOR;
633 if (toolbar_item->index != -1) {
634 if ( !toolbar_is_duplicate(toolbar_item->index, TOOLBAR_MAIN))
635 toolbar_config[TOOLBAR_MAIN].item_list =
636 g_slist_append(toolbar_config[TOOLBAR_MAIN].item_list, toolbar_item);
641 static void toolbar_set_default_compose(void)
645 } default_toolbar[] = {
664 for (i = 0; i < sizeof(default_toolbar) / sizeof(default_toolbar[0]); i++) {
666 ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
668 if (default_toolbar[i].action != A_SEPARATOR) {
671 if (toolbar_get_icon(default_toolbar[i].action) > -1) {
672 file = stock_pixmap_get_name((StockPixmap)toolbar_get_icon(default_toolbar[i].action));
674 toolbar_item->file = g_strdup(file);
675 toolbar_item->index = default_toolbar[i].action;
676 toolbar_item->text = g_strdup(toolbar_get_short_text(default_toolbar[i].action));
679 toolbar_item->file = g_strdup(TOOLBAR_TAG_SEPARATOR);
680 toolbar_item->index = A_SEPARATOR;
683 if (toolbar_item->index != -1) {
684 if ( !toolbar_is_duplicate(toolbar_item->index, TOOLBAR_COMPOSE))
685 toolbar_config[TOOLBAR_COMPOSE].item_list =
686 g_slist_append(toolbar_config[TOOLBAR_COMPOSE].item_list, toolbar_item);
691 static void toolbar_set_default_msgview(void)
695 } default_toolbar[] = {
714 for (i = 0; i < sizeof(default_toolbar) / sizeof(default_toolbar[0]); i++) {
716 ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
718 if (default_toolbar[i].action != A_SEPARATOR) {
720 if (toolbar_get_icon(default_toolbar[i].action) > -1) {
721 file = stock_pixmap_get_name((StockPixmap)toolbar_get_icon(default_toolbar[i].action));
724 toolbar_item->file = g_strdup(file);
725 toolbar_item->index = default_toolbar[i].action;
726 toolbar_item->text = g_strdup(toolbar_get_short_text(default_toolbar[i].action));
729 toolbar_item->file = g_strdup(TOOLBAR_TAG_SEPARATOR);
730 toolbar_item->index = A_SEPARATOR;
733 if (toolbar_item->index != -1) {
734 if ( !toolbar_is_duplicate(toolbar_item->index, TOOLBAR_MSGVIEW))
735 toolbar_config[TOOLBAR_MSGVIEW].item_list =
736 g_slist_append(toolbar_config[TOOLBAR_MSGVIEW].item_list, toolbar_item);
741 void toolbar_set_default(ToolbarType source)
743 if (source == TOOLBAR_MAIN)
744 toolbar_set_default_main();
745 else if (source == TOOLBAR_COMPOSE)
746 toolbar_set_default_compose();
747 else if (source == TOOLBAR_MSGVIEW)
748 toolbar_set_default_msgview();
751 void toolbar_save_config_file(ToolbarType source)
756 gchar *fileSpec = NULL;
758 debug_print("save Toolbar Configuration to %s\n", toolbar_config[source].conf_file);
760 fileSpec = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, toolbar_config[source].conf_file, NULL );
761 pfile = prefs_write_open(fileSpec);
764 if (fprintf(fp, "<?xml version=\"1.0\" encoding=\"%s\" ?>\n", CS_INTERNAL) < 0)
767 if (fprintf(fp, "<%s>\n", TOOLBAR_TAG_INDEX) < 0)
770 for (cur = toolbar_config[source].item_list; cur != NULL; cur = cur->next) {
771 ToolbarItem *toolbar_item = (ToolbarItem*) cur->data;
773 if (toolbar_item->index != A_SEPARATOR) {
774 if (fprintf(fp, "\t<%s %s=\"%s\" %s=\"",
776 TOOLBAR_ICON_FILE, toolbar_item->file,
777 TOOLBAR_ICON_TEXT) < 0)
779 if (xml_file_put_escape_str(fp, toolbar_item->text) < 0)
781 if (fprintf(fp, "\" %s=\"%s\"/>\n",
783 toolbar_ret_text_from_val(toolbar_item->index)) < 0)
786 if (fprintf(fp, "\t<%s/>\n", TOOLBAR_TAG_SEPARATOR) < 0)
791 if (fprintf(fp, "</%s>\n", TOOLBAR_TAG_INDEX) < 0)
795 if (prefs_file_close (pfile) < 0 )
796 g_warning("failed to write toolbar configuration to file");
800 FILE_OP_ERROR(fileSpec, "fprintf");
802 prefs_file_close_revert (pfile);
804 g_warning("failed to open toolbar configuration file for writing");
807 void toolbar_read_config_file(ToolbarType source)
809 XMLFile *file = NULL;
810 gchar *fileSpec = NULL;
812 gboolean rewrite = FALSE;
814 debug_print("read Toolbar Configuration from %s\n", toolbar_config[source].conf_file);
816 fileSpec = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, toolbar_config[source].conf_file, NULL );
817 file = xml_open_file(fileSpec);
820 toolbar_clear_list(source);
824 || (xml_get_dtd(file))
825 || (xml_parse_next_tag(file))
826 || (!xml_compare_tag(file, TOOLBAR_TAG_INDEX))) {
827 xml_close_file(file);
835 if (xml_parse_next_tag(file))
838 /* Get next tag (icon, icon_text or icon_action) */
839 if (xml_compare_tag(file, TOOLBAR_TAG_ITEM)) {
840 toolbar_parse_item(file, source, &rewrite);
841 } else if (xml_compare_tag(file, TOOLBAR_TAG_SEPARATOR)) {
842 ToolbarItem *item = g_new0(ToolbarItem, 1);
844 item->file = g_strdup(TOOLBAR_TAG_SEPARATOR);
845 item->index = A_SEPARATOR;
846 toolbar_config[source].item_list =
847 g_slist_append(toolbar_config[source].item_list, item);
851 xml_close_file(file);
853 debug_print("toolbar_read_config_file: rewriting toolbar\n");
854 toolbar_save_config_file(source);
858 if ((!file) || (g_slist_length(toolbar_config[source].item_list) == 0)) {
860 if (source == TOOLBAR_MAIN)
861 toolbar_set_default(TOOLBAR_MAIN);
862 else if (source == TOOLBAR_COMPOSE)
863 toolbar_set_default(TOOLBAR_COMPOSE);
864 else if (source == TOOLBAR_MSGVIEW)
865 toolbar_set_default(TOOLBAR_MSGVIEW);
867 g_warning("refusing to write unknown Toolbar Configuration number %d", source);
871 toolbar_save_config_file(source);
876 * clears list of toolbar items read from configuration files
878 void toolbar_clear_list(ToolbarType source)
880 while (toolbar_config[source].item_list != NULL) {
881 ToolbarItem *item = (ToolbarItem*) toolbar_config[source].item_list->data;
883 toolbar_config[source].item_list =
884 g_slist_remove(toolbar_config[source].item_list, item);
890 g_slist_free(toolbar_config[source].item_list);
895 * return list of Toolbar items
897 GSList *toolbar_get_list(ToolbarType source)
901 if ((source == TOOLBAR_MAIN) || (source == TOOLBAR_COMPOSE) || (source == TOOLBAR_MSGVIEW))
902 list = toolbar_config[source].item_list;
907 void toolbar_set_list_item(ToolbarItem *t_item, ToolbarType source)
909 ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
911 toolbar_item->file = g_strdup(t_item->file);
912 toolbar_item->text = g_strdup(t_item->text);
913 toolbar_item->index = t_item->index;
915 toolbar_config[source].item_list =
916 g_slist_append(toolbar_config[source].item_list,
920 static void toolbar_action_execute(GtkWidget *widget,
928 for (cur = action_list; cur != NULL; cur = cur->next) {
929 ToolbarClawsActions *act = (ToolbarClawsActions*)cur->data;
931 if (widget == act->widget) {
932 i = prefs_actions_find_by_name(act->name);
940 actions_execute(data, i, widget, source);
942 g_warning ("Error: did not find Claws Action to execute");
945 gboolean toolbar_check_action_btns(ToolbarType type)
947 GSList *temp, *curr, *list = toolbar_config[type].item_list;
948 gboolean modified = FALSE;
951 while (curr != NULL) {
952 ToolbarItem *toolbar_item = (ToolbarItem *) curr->data;
956 if (toolbar_item->index != A_CLAWS_ACTIONS)
959 if (prefs_actions_find_by_name(toolbar_item->text) == -1) {
960 list = g_slist_delete_link(list, temp);
961 g_free(toolbar_item->file);
962 g_free(toolbar_item->text);
963 g_free(toolbar_item);
971 #define CLAWS_SET_TOOL_ITEM_TIP(widget,tip) { \
972 gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), tip); \
975 #define CLAWS_SET_ARROW_TIP(widget,tip) { \
976 gtk_menu_tool_button_set_arrow_tooltip_text(GTK_MENU_TOOL_BUTTON(widget), tip); \
979 static void activate_compose_button (Toolbar *toolbar,
981 ComposeButtonType type)
983 if ((!toolbar->compose_mail_btn))
986 if (type == COMPOSEBUTTON_NEWS) {
987 gtk_tool_button_set_icon_widget(
988 GTK_TOOL_BUTTON(toolbar->compose_mail_btn),
989 toolbar->compose_news_icon);
991 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(toolbar->compose_mail_btn), _("Compose News message"));
993 gtk_widget_show(toolbar->compose_news_icon);
995 gtk_tool_button_set_icon_widget(
996 GTK_TOOL_BUTTON(toolbar->compose_mail_btn),
997 toolbar->compose_mail_icon);
999 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(toolbar->compose_mail_btn), _("Compose Email"));
1001 gtk_widget_show(toolbar->compose_mail_icon);
1003 toolbar->compose_btn_type = type;
1006 void toolbar_set_compose_button(Toolbar *toolbar,
1007 ComposeButtonType compose_btn_type)
1009 if (toolbar->compose_btn_type != compose_btn_type)
1010 activate_compose_button(toolbar,
1011 prefs_common.toolbar_style,
1015 static void activate_learn_button (Toolbar *toolbar,
1017 LearnButtonType type)
1019 if ((!toolbar->learn_spam_btn))
1022 if (type == LEARN_SPAM) {
1023 gtk_tool_button_set_icon_widget(
1024 GTK_TOOL_BUTTON(toolbar->learn_spam_btn),
1025 toolbar->learn_spam_icon);
1026 gtk_tool_button_set_label(
1027 GTK_TOOL_BUTTON(toolbar->learn_spam_btn),
1029 #ifndef GENERIC_UMPC
1030 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(toolbar->learn_spam_btn), _("Learn spam"));
1032 gtk_widget_show(toolbar->learn_spam_icon);
1034 gtk_tool_button_set_icon_widget(
1035 GTK_TOOL_BUTTON(toolbar->learn_spam_btn),
1036 toolbar->learn_ham_icon);
1037 gtk_tool_button_set_label(
1038 GTK_TOOL_BUTTON(toolbar->learn_spam_btn),
1040 #ifndef GENERIC_UMPC
1041 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(toolbar->learn_spam_btn), _("Learn ham"));
1043 gtk_widget_show(toolbar->learn_ham_icon);
1045 toolbar->learn_btn_type = type;
1048 void toolbar_set_learn_button(Toolbar *toolbar,
1049 LearnButtonType learn_btn_type)
1051 if (toolbar->learn_btn_type != learn_btn_type)
1052 activate_learn_button(toolbar,
1053 prefs_common.toolbar_style,
1057 void toolbar_toggle(guint action, gpointer data)
1059 MainWindow *mainwin = (MainWindow*)data;
1063 cm_return_if_fail(mainwin != NULL);
1065 toolbar_style(TOOLBAR_MAIN, action, mainwin);
1067 list = compose_get_compose_list();
1068 for (cur = list; cur != NULL; cur = cur->next) {
1069 toolbar_style(TOOLBAR_COMPOSE, action, cur->data);
1071 list = messageview_get_msgview_list();
1072 for (cur = list; cur != NULL; cur = cur->next) {
1073 toolbar_style(TOOLBAR_MSGVIEW, action, cur->data);
1078 void toolbar_set_style(GtkWidget *toolbar_wid, GtkWidget *handlebox_wid, guint action)
1080 switch ((ToolbarStyle)action) {
1082 gtk_widget_hide(handlebox_wid);
1085 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
1089 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
1093 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
1096 case TOOLBAR_BOTH_HORIZ:
1097 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
1098 GTK_TOOLBAR_BOTH_HORIZ);
1104 prefs_common.toolbar_style = (ToolbarStyle)action;
1105 gtk_widget_set_size_request(handlebox_wid, 1, -1);
1107 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
1108 gtk_widget_show(handlebox_wid);
1109 gtk_widget_queue_resize(handlebox_wid);
1113 * Change the style of toolbar
1115 static void toolbar_style(ToolbarType type, guint action, gpointer data)
1117 GtkWidget *handlebox_wid;
1118 GtkWidget *toolbar_wid;
1119 MainWindow *mainwin = (MainWindow*)data;
1120 Compose *compose = (Compose*)data;
1121 MessageView *msgview = (MessageView*)data;
1123 cm_return_if_fail(data != NULL);
1127 handlebox_wid = mainwin->handlebox;
1128 toolbar_wid = mainwin->toolbar->toolbar;
1130 case TOOLBAR_COMPOSE:
1131 handlebox_wid = compose->handlebox;
1132 toolbar_wid = compose->toolbar->toolbar;
1134 case TOOLBAR_MSGVIEW:
1135 handlebox_wid = msgview->handlebox;
1136 toolbar_wid = msgview->toolbar->toolbar;
1142 toolbar_set_style(toolbar_wid, handlebox_wid, action);
1145 /* Toolbar handling */
1146 static void toolbar_inc_cb(GtkWidget *widget,
1149 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1150 MainWindow *mainwin;
1152 cm_return_if_fail(toolbar_item != NULL);
1154 switch (toolbar_item->type) {
1156 mainwin = (MainWindow*)toolbar_item->parent;
1157 inc_mail_cb(mainwin, 0, NULL);
1164 static void toolbar_inc_all_cb(GtkWidget *widget,
1167 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1168 MainWindow *mainwin;
1170 cm_return_if_fail(toolbar_item != NULL);
1172 switch (toolbar_item->type) {
1174 mainwin = (MainWindow*)toolbar_item->parent;
1175 inc_all_account_mail_cb(mainwin, 0, NULL);
1182 static void toolbar_send_queued_cb(GtkWidget *widget,gpointer data)
1184 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1185 MainWindow *mainwin;
1187 cm_return_if_fail(toolbar_item != NULL);
1189 switch (toolbar_item->type) {
1191 mainwin = (MainWindow*)toolbar_item->parent;
1192 send_queue_cb(mainwin, 0, NULL);
1199 static void toolbar_exec_cb(GtkWidget *widget,
1202 MainWindow *mainwin = get_mainwin(data);
1204 cm_return_if_fail(mainwin != NULL);
1205 summary_execute(mainwin->summaryview);
1209 * Delete current/selected(s) message(s)
1211 static void toolbar_trash_cb(GtkWidget *widget, gpointer data)
1213 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1214 MainWindow *mainwin;
1216 cm_return_if_fail(toolbar_item != NULL);
1217 cm_return_if_fail(toolbar_item->parent);
1219 switch (toolbar_item->type) {
1220 case TOOLBAR_MSGVIEW:
1221 messageview_delete((MessageView *)toolbar_item->parent);
1224 mainwin = (MainWindow *)toolbar_item->parent;
1225 summary_delete_trash(mainwin->summaryview);
1228 debug_print("toolbar event not supported\n");
1234 * Delete current/selected(s) message(s)
1236 static void toolbar_delete_cb(GtkWidget *widget, gpointer data)
1238 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1239 MainWindow *mainwin;
1241 cm_return_if_fail(toolbar_item != NULL);
1242 cm_return_if_fail(toolbar_item->parent);
1244 switch (toolbar_item->type) {
1245 case TOOLBAR_MSGVIEW:
1246 messageview_delete((MessageView *)toolbar_item->parent);
1249 mainwin = (MainWindow *)toolbar_item->parent;
1250 summary_delete(mainwin->summaryview);
1253 debug_print("toolbar event not supported\n");
1260 * Compose new message
1262 static void toolbar_compose_cb(GtkWidget *widget, gpointer data)
1264 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1265 MainWindow *mainwin;
1266 MessageView *msgview;
1268 cm_return_if_fail(toolbar_item != NULL);
1270 switch (toolbar_item->type) {
1272 mainwin = (MainWindow*)toolbar_item->parent;
1273 if (mainwin->toolbar->compose_btn_type == COMPOSEBUTTON_NEWS)
1274 compose_news_cb(mainwin, 0, NULL);
1276 compose_mail_cb(mainwin, 0, NULL);
1278 case TOOLBAR_MSGVIEW:
1279 msgview = (MessageView*)toolbar_item->parent;
1280 compose_new_with_folderitem(NULL,
1281 msgview->msginfo->folder, NULL);
1284 debug_print("toolbar event not supported\n");
1288 static void toolbar_learn(gpointer data, guint as_spam)
1290 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1291 MainWindow *mainwin;
1292 MessageView *msgview;
1294 cm_return_if_fail(toolbar_item != NULL);
1296 switch (toolbar_item->type) {
1298 mainwin = (MainWindow*)toolbar_item->parent;
1300 mainwindow_learn(mainwin, TRUE);
1302 mainwindow_learn(mainwin, FALSE);
1304 case TOOLBAR_MSGVIEW:
1305 msgview = (MessageView*)toolbar_item->parent;
1307 messageview_learn(msgview, TRUE);
1309 messageview_learn(msgview, FALSE);
1312 debug_print("toolbar event not supported\n");
1316 static void toolbar_learn_cb(GtkWidget *widget, gpointer data)
1318 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1319 MainWindow *mainwin;
1320 MessageView *msgview;
1322 cm_return_if_fail(toolbar_item != NULL);
1324 switch (toolbar_item->type) {
1326 mainwin = (MainWindow*)toolbar_item->parent;
1327 if (mainwin->toolbar->learn_btn_type == LEARN_SPAM)
1328 mainwindow_learn(mainwin, TRUE);
1330 mainwindow_learn(mainwin, FALSE);
1332 case TOOLBAR_MSGVIEW:
1333 msgview = (MessageView*)toolbar_item->parent;
1334 if (msgview->toolbar->learn_btn_type == LEARN_SPAM)
1335 messageview_learn(msgview, TRUE);
1337 messageview_learn(msgview, FALSE);
1340 debug_print("toolbar event not supported\n");
1348 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
1350 toolbar_reply(data, (prefs_common.reply_with_quote ?
1351 COMPOSE_REPLY_WITH_QUOTE : COMPOSE_REPLY_WITHOUT_QUOTE));
1356 * Reply message to Sender and All recipients
1358 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
1361 (prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
1362 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE));
1367 * Reply to Mailing List
1369 static void toolbar_reply_to_list_cb(GtkWidget *widget, gpointer data)
1372 (prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_LIST_WITH_QUOTE
1373 : COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE));
1378 * Reply to sender of message
1380 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
1383 (prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
1384 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE));
1390 static void toolbar_addrbook_cb(GtkWidget *widget, gpointer data)
1392 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1395 cm_return_if_fail(toolbar_item != NULL);
1397 switch (toolbar_item->type) {
1399 case TOOLBAR_MSGVIEW:
1402 case TOOLBAR_COMPOSE:
1403 compose = (Compose *)toolbar_item->parent;
1408 #ifndef USE_ALT_ADDRBOOK
1409 addressbook_open(compose);
1411 GError* error = NULL;
1412 addressbook_connect_signals(compose);
1413 addressbook_dbus_open(TRUE, &error);
1415 g_warning("%s", error->message);
1416 g_error_free(error);
1423 * Forward current/selected(s) message(s)
1425 static void toolbar_forward_cb(GtkWidget *widget, gpointer data)
1427 toolbar_reply(data, (COMPOSE_FORWARD));
1431 * Goto Prev Unread Message
1433 static void toolbar_prev_unread_cb(GtkWidget *widget, gpointer data)
1435 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1436 MainWindow *mainwin;
1437 MessageView *msgview;
1439 cm_return_if_fail(toolbar_item != NULL);
1441 switch (toolbar_item->type) {
1443 mainwin = (MainWindow*)toolbar_item->parent;
1444 summary_select_prev_unread(mainwin->summaryview);
1447 case TOOLBAR_MSGVIEW:
1448 msgview = (MessageView*)toolbar_item->parent;
1449 msgview->updating = TRUE;
1450 summary_select_prev_unread(msgview->mainwin->summaryview);
1451 msgview->updating = FALSE;
1453 if (msgview->deferred_destroy) {
1454 debug_print("messageview got away!\n");
1455 messageview_destroy(msgview);
1459 /* Now we need to update the messageview window */
1460 if (msgview->mainwin->summaryview->selected) {
1461 #ifndef GENERIC_UMPC
1462 MsgInfo * msginfo = summary_get_selected_msg(msgview->mainwin->summaryview);
1465 messageview_show(msgview, msginfo,
1466 msgview->all_headers);
1469 gtk_widget_destroy(msgview->window);
1473 debug_print("toolbar event not supported\n");
1478 * Goto Next Unread Message
1480 static void toolbar_next_unread_cb(GtkWidget *widget, gpointer data)
1482 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1483 MainWindow *mainwin;
1484 MessageView *msgview;
1486 cm_return_if_fail(toolbar_item != NULL);
1488 switch (toolbar_item->type) {
1490 mainwin = (MainWindow*)toolbar_item->parent;
1491 summary_select_next_unread(mainwin->summaryview);
1494 case TOOLBAR_MSGVIEW:
1495 msgview = (MessageView*)toolbar_item->parent;
1496 msgview->updating = TRUE;
1497 summary_select_next_unread(msgview->mainwin->summaryview);
1498 msgview->updating = FALSE;
1500 if (msgview->deferred_destroy) {
1501 debug_print("messageview got away!\n");
1502 messageview_destroy(msgview);
1506 /* Now we need to update the messageview window */
1507 if (msgview->mainwin->summaryview->selected) {
1508 #ifndef GENERIC_UMPC
1509 MsgInfo * msginfo = summary_get_selected_msg(msgview->mainwin->summaryview);
1512 messageview_show(msgview, msginfo,
1513 msgview->all_headers);
1516 gtk_widget_destroy(msgview->window);
1520 debug_print("toolbar event not supported\n");
1524 static void toolbar_ignore_thread_cb(GtkWidget *widget, gpointer data)
1526 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1527 MainWindow *mainwin;
1529 cm_return_if_fail(toolbar_item != NULL);
1531 switch (toolbar_item->type) {
1533 mainwin = (MainWindow *) toolbar_item->parent;
1534 summary_toggle_ignore_thread(mainwin->summaryview);
1536 case TOOLBAR_MSGVIEW:
1537 /* TODO: see toolbar_next_unread_cb() if you need
1538 * this in the message view */
1541 debug_print("toolbar event not supported\n");
1546 static void toolbar_watch_thread_cb(GtkWidget *widget, gpointer data)
1548 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1549 MainWindow *mainwin;
1551 cm_return_if_fail(toolbar_item != NULL);
1553 switch (toolbar_item->type) {
1555 mainwin = (MainWindow *) toolbar_item->parent;
1556 summary_toggle_watch_thread(mainwin->summaryview);
1558 case TOOLBAR_MSGVIEW:
1559 /* TODO: see toolbar_next_unread_cb() if you need
1560 * this in the message view */
1563 debug_print("toolbar event not supported\n");
1568 static void toolbar_mark_cb(GtkWidget *widget, gpointer data)
1570 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1571 MainWindow *mainwin;
1573 cm_return_if_fail(toolbar_item != NULL);
1575 switch (toolbar_item->type) {
1577 mainwin = (MainWindow *) toolbar_item->parent;
1578 summary_mark(mainwin->summaryview);
1580 case TOOLBAR_MSGVIEW:
1581 /* TODO: see toolbar_next_unread_cb() if you need
1582 * this in the message view */
1585 debug_print("toolbar event not supported\n");
1590 static void toolbar_unmark_cb(GtkWidget *widget, gpointer data)
1592 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1593 MainWindow *mainwin;
1595 cm_return_if_fail(toolbar_item != NULL);
1597 switch (toolbar_item->type) {
1599 mainwin = (MainWindow *) toolbar_item->parent;
1600 summary_unmark(mainwin->summaryview);
1602 case TOOLBAR_MSGVIEW:
1603 /* TODO: see toolbar_next_unread_cb() if you need
1604 * this in the message view */
1607 debug_print("toolbar event not supported\n");
1612 static void toolbar_lock_cb(GtkWidget *widget, gpointer data)
1614 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1615 MainWindow *mainwin;
1617 cm_return_if_fail(toolbar_item != NULL);
1619 switch (toolbar_item->type) {
1621 mainwin = (MainWindow *) toolbar_item->parent;
1622 summary_msgs_lock(mainwin->summaryview);
1624 case TOOLBAR_MSGVIEW:
1625 /* TODO: see toolbar_next_unread_cb() if you need
1626 * this in the message view */
1629 debug_print("toolbar event not supported\n");
1634 static void toolbar_unlock_cb(GtkWidget *widget, gpointer data)
1636 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1637 MainWindow *mainwin;
1639 cm_return_if_fail(toolbar_item != NULL);
1641 switch (toolbar_item->type) {
1643 mainwin = (MainWindow *) toolbar_item->parent;
1644 summary_msgs_unlock(mainwin->summaryview);
1646 case TOOLBAR_MSGVIEW:
1647 /* TODO: see toolbar_next_unread_cb() if you need
1648 * this in the message view */
1651 debug_print("toolbar event not supported\n");
1656 static void toolbar_all_read_cb(GtkWidget *widget, gpointer data)
1658 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1659 MainWindow *mainwin;
1661 cm_return_if_fail(toolbar_item != NULL);
1663 switch (toolbar_item->type) {
1665 mainwin = (MainWindow *) toolbar_item->parent;
1666 summary_mark_all_read(mainwin->summaryview);
1668 case TOOLBAR_MSGVIEW:
1669 /* TODO: see toolbar_next_unread_cb() if you need
1670 * this in the message view */
1673 debug_print("toolbar event not supported\n");
1678 static void toolbar_all_unread_cb(GtkWidget *widget, gpointer data)
1680 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1681 MainWindow *mainwin;
1683 cm_return_if_fail(toolbar_item != NULL);
1685 switch (toolbar_item->type) {
1687 mainwin = (MainWindow *) toolbar_item->parent;
1688 summary_mark_all_unread(mainwin->summaryview);
1690 case TOOLBAR_MSGVIEW:
1691 /* TODO: see toolbar_next_unread_cb() if you need
1692 * this in the message view */
1695 debug_print("toolbar event not supported\n");
1700 static void toolbar_read_cb(GtkWidget *widget, gpointer data)
1702 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1703 MainWindow *mainwin;
1705 cm_return_if_fail(toolbar_item != NULL);
1707 switch (toolbar_item->type) {
1709 mainwin = (MainWindow *) toolbar_item->parent;
1710 summary_mark_as_read(mainwin->summaryview);
1712 case TOOLBAR_MSGVIEW:
1713 /* TODO: see toolbar_next_unread_cb() if you need
1714 * this in the message view */
1717 debug_print("toolbar event not supported\n");
1722 static void toolbar_unread_cb(GtkWidget *widget, gpointer data)
1724 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1725 MainWindow *mainwin;
1727 cm_return_if_fail(toolbar_item != NULL);
1729 switch (toolbar_item->type) {
1731 mainwin = (MainWindow *) toolbar_item->parent;
1732 summary_mark_as_unread(mainwin->summaryview);
1734 case TOOLBAR_MSGVIEW:
1735 /* TODO: see toolbar_next_unread_cb() if you need
1736 * this in the message view */
1739 debug_print("toolbar event not supported\n");
1744 static void toolbar_cancel_inc_cb(GtkWidget *widget, gpointer data)
1746 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1748 cm_return_if_fail(toolbar_item != NULL);
1753 static void toolbar_cancel_send_cb(GtkWidget *widget, gpointer data)
1755 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1757 cm_return_if_fail(toolbar_item != NULL);
1761 static void toolbar_cancel_all_cb(GtkWidget *widget, gpointer data)
1763 toolbar_cancel_inc_cb(widget, data);
1764 toolbar_cancel_send_cb(widget, data);
1767 static void toolbar_print_cb(GtkWidget *widget, gpointer data)
1769 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1770 MainWindow *mainwin;
1772 cm_return_if_fail(toolbar_item != NULL);
1774 switch (toolbar_item->type) {
1776 mainwin = (MainWindow *) toolbar_item->parent;
1777 summary_print(mainwin->summaryview);
1779 case TOOLBAR_MSGVIEW:
1780 /* TODO: see toolbar_next_unread_cb() if you need
1781 * this in the message view */
1784 debug_print("toolbar event not supported\n");
1789 static void toolbar_send_cb(GtkWidget *widget, gpointer data)
1791 compose_toolbar_cb(A_SEND, data);
1794 static void toolbar_send_later_cb(GtkWidget *widget, gpointer data)
1796 compose_toolbar_cb(A_SEND_LATER, data);
1799 static void toolbar_draft_cb(GtkWidget *widget, gpointer data)
1801 compose_toolbar_cb(A_DRAFT, data);
1804 static void toolbar_close_cb(GtkWidget *widget, gpointer data)
1806 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1807 MainWindow *mainwin;
1808 MessageView *messageview;
1811 cm_return_if_fail(toolbar_item != NULL);
1813 switch (toolbar_item->type) {
1815 mainwin = (MainWindow *) toolbar_item->parent;
1816 app_will_exit(NULL, mainwin);
1818 case TOOLBAR_MSGVIEW:
1819 messageview = (MessageView *)toolbar_item->parent;
1820 messageview_destroy(messageview);
1822 case TOOLBAR_COMPOSE:
1823 compose = (Compose *)toolbar_item->parent;
1824 compose_close_toolbar(compose);
1829 static void toolbar_preferences_cb(GtkWidget *widget, gpointer data)
1834 static void toolbar_open_mail_cb(GtkWidget *widget, gpointer data)
1836 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1837 MainWindow *mainwin;
1839 cm_return_if_fail(toolbar_item != NULL);
1841 switch (toolbar_item->type) {
1843 mainwin = (MainWindow *) toolbar_item->parent;
1844 summary_open_row(NULL, mainwin->summaryview);
1846 case TOOLBAR_MSGVIEW:
1847 debug_print("toolbar event not supported\n");
1849 case TOOLBAR_COMPOSE:
1850 debug_print("toolbar event not supported\n");
1855 static void toolbar_insert_cb(GtkWidget *widget, gpointer data)
1857 compose_toolbar_cb(A_INSERT, data);
1860 static void toolbar_attach_cb(GtkWidget *widget, gpointer data)
1862 compose_toolbar_cb(A_ATTACH, data);
1865 static void toolbar_sig_cb(GtkWidget *widget, gpointer data)
1867 compose_toolbar_cb(A_SIG, data);
1870 static void toolbar_replace_sig_cb(GtkWidget *widget, gpointer data)
1872 compose_toolbar_cb(A_REP_SIG, data);
1875 static void toolbar_ext_editor_cb(GtkWidget *widget, gpointer data)
1877 compose_toolbar_cb(A_EXTEDITOR, data);
1880 static void toolbar_linewrap_current_cb(GtkWidget *widget, gpointer data)
1882 compose_toolbar_cb(A_LINEWRAP_CURRENT, data);
1885 static void toolbar_linewrap_all_cb(GtkWidget *widget, gpointer data)
1887 compose_toolbar_cb(A_LINEWRAP_ALL, data);
1891 static void toolbar_check_spelling_cb(GtkWidget *widget, gpointer data)
1893 compose_toolbar_cb(A_CHECK_SPELLING, data);
1897 * Execute actions from toolbar
1899 static void toolbar_actions_execute_cb(GtkWidget *widget, gpointer data)
1901 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1902 GSList *action_list;
1903 MainWindow *mainwin;
1905 MessageView *msgview;
1906 gpointer parent = toolbar_item->parent;
1908 cm_return_if_fail(toolbar_item != NULL);
1910 switch (toolbar_item->type) {
1912 mainwin = (MainWindow*)parent;
1913 action_list = mainwin->toolbar->action_list;
1915 case TOOLBAR_COMPOSE:
1916 compose = (Compose*)parent;
1917 action_list = compose->toolbar->action_list;
1919 case TOOLBAR_MSGVIEW:
1920 msgview = (MessageView*)parent;
1921 action_list = msgview->toolbar->action_list;
1924 debug_print("toolbar event not supported\n");
1927 toolbar_action_execute(widget, action_list, parent, toolbar_item->type);
1930 static void toolbar_plugins_execute_cb(GtkWidget *widget, gpointer data)
1932 ToolbarItem *toolbar_item = data;
1933 prefs_toolbar_execute_plugin_item(toolbar_item->parent, toolbar_item->type, toolbar_item->text);
1936 static MainWindow *get_mainwin(gpointer data)
1938 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1939 MainWindow *mainwin = NULL;
1940 MessageView *msgview;
1942 cm_return_val_if_fail(toolbar_item != NULL, NULL);
1944 switch(toolbar_item->type) {
1946 mainwin = (MainWindow*)toolbar_item->parent;
1948 case TOOLBAR_MSGVIEW:
1949 msgview = (MessageView*)toolbar_item->parent;
1950 mainwin = (MainWindow*)msgview->mainwin;
1959 static void toolbar_go_folders_cb(GtkWidget *widget, gpointer data)
1961 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1962 MainWindow *mainwin = NULL;
1963 switch(toolbar_item->type) {
1965 mainwin = (MainWindow*)toolbar_item->parent;
1968 g_warning("wrong toolbar type");
1972 if (!mainwin->in_folder) {
1973 FolderItem *item = folderview_get_selected_item(mainwin->folderview);
1975 folderview_select(mainwin->folderview, item);
1978 folderview_grab_focus(mainwin->folderview);
1979 mainwindow_exit_folder(mainwin);
1983 static void toolbar_buttons_cb(GtkWidget *widget,
1990 void (*func)(GtkWidget *widget, gpointer data);
1992 { A_RECEIVE_ALL, toolbar_inc_all_cb },
1993 { A_RECEIVE_CUR, toolbar_inc_cb },
1994 { A_SEND_QUEUED, toolbar_send_queued_cb },
1995 { A_COMPOSE_EMAIL, toolbar_compose_cb },
1996 { A_COMPOSE_NEWS, toolbar_compose_cb },
1997 { A_REPLY_MESSAGE, toolbar_reply_cb },
1998 { A_REPLY_SENDER, toolbar_reply_to_sender_cb },
1999 { A_REPLY_ALL, toolbar_reply_to_all_cb },
2000 { A_REPLY_ML, toolbar_reply_to_list_cb },
2001 { A_FORWARD, toolbar_forward_cb },
2002 { A_TRASH, toolbar_trash_cb },
2003 { A_DELETE_REAL, toolbar_delete_cb },
2004 { A_EXECUTE, toolbar_exec_cb },
2005 { A_GOTO_PREV, toolbar_prev_unread_cb },
2006 { A_GOTO_NEXT, toolbar_next_unread_cb },
2007 { A_IGNORE_THREAD, toolbar_ignore_thread_cb },
2008 { A_WATCH_THREAD, toolbar_watch_thread_cb },
2009 { A_MARK, toolbar_mark_cb },
2010 { A_UNMARK, toolbar_unmark_cb },
2011 { A_LOCK, toolbar_lock_cb },
2012 { A_UNLOCK, toolbar_unlock_cb },
2013 { A_ALL_READ, toolbar_all_read_cb },
2014 { A_ALL_UNREAD, toolbar_all_unread_cb },
2015 { A_READ, toolbar_read_cb },
2016 { A_UNREAD, toolbar_unread_cb },
2017 { A_PRINT, toolbar_print_cb },
2018 { A_LEARN_SPAM, toolbar_learn_cb },
2019 { A_GO_FOLDERS, toolbar_go_folders_cb },
2021 { A_SEND, toolbar_send_cb },
2022 { A_SEND_LATER, toolbar_send_later_cb },
2023 { A_DRAFT, toolbar_draft_cb },
2024 { A_OPEN_MAIL, toolbar_open_mail_cb },
2025 { A_CLOSE, toolbar_close_cb },
2026 { A_PREFERENCES, toolbar_preferences_cb },
2027 { A_INSERT, toolbar_insert_cb },
2028 { A_ATTACH, toolbar_attach_cb },
2029 { A_SIG, toolbar_sig_cb },
2030 { A_REP_SIG, toolbar_replace_sig_cb },
2031 { A_EXTEDITOR, toolbar_ext_editor_cb },
2032 { A_LINEWRAP_CURRENT, toolbar_linewrap_current_cb },
2033 { A_LINEWRAP_ALL, toolbar_linewrap_all_cb },
2034 { A_ADDRBOOK, toolbar_addrbook_cb },
2036 { A_CHECK_SPELLING, toolbar_check_spelling_cb },
2038 { A_CLAWS_ACTIONS, toolbar_actions_execute_cb },
2039 { A_CANCEL_INC, toolbar_cancel_inc_cb },
2040 { A_CANCEL_SEND, toolbar_cancel_send_cb },
2041 { A_CANCEL_ALL, toolbar_cancel_all_cb },
2042 { A_CLAWS_PLUGINS, toolbar_plugins_execute_cb },
2045 num_items = sizeof(callbacks)/sizeof(callbacks[0]);
2047 for (i = 0; i < num_items; i++) {
2048 if (callbacks[i].index == item->index) {
2049 callbacks[i].func(widget, item);
2054 #ifndef GENERIC_UMPC
2055 #define TOOLBAR_ITEM(item,icon,text,tooltip) { \
2056 item = GTK_WIDGET(gtk_tool_button_new(icon, text)); \
2057 gtkut_widget_set_can_focus(gtk_bin_get_child(GTK_BIN(item)), FALSE); \
2058 gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE); \
2059 gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE); \
2060 g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item); \
2061 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1); \
2062 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(item), \
2066 #define TOOLBAR_MENUITEM(item,icon,text,tooltip,menutip) { \
2067 GtkWidget *child = NULL, *btn = NULL, *arr = NULL; \
2068 GList *gchild = NULL; \
2069 item = GTK_WIDGET(gtk_menu_tool_button_new(icon, text)); \
2070 gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE); \
2071 gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE); \
2072 g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item); \
2073 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1); \
2074 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(item), \
2076 CLAWS_SET_ARROW_TIP(GTK_MENU_TOOL_BUTTON(item), menutip); \
2077 child = gtk_bin_get_child(GTK_BIN(item)); \
2078 gchild = gtk_container_get_children( \
2079 GTK_CONTAINER(child)); \
2080 btn = (GtkWidget *)gchild->data; \
2081 gtkut_widget_set_can_focus(btn, FALSE); \
2082 arr = (GtkWidget *)(gchild->next?gchild->next->data:NULL); \
2083 gtkut_widget_set_can_focus(arr, FALSE); \
2084 g_list_free(gchild); \
2085 gchild = gtk_container_get_children(GTK_CONTAINER(arr)); \
2086 gtk_widget_set_size_request(GTK_WIDGET(gchild->data), 9, -1); \
2087 g_list_free(gchild); \
2090 #define TOOLBAR_ITEM(item,icon,text,tooltip) { \
2091 item = GTK_WIDGET(gtk_tool_button_new(icon, text)); \
2092 gtkut_widget_set_can_focus(gtk_bin_get_child(GTK_BIN(item)), FALSE); \
2093 gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE); \
2094 gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE); \
2095 g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item); \
2096 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1); \
2099 #define TOOLBAR_MENUITEM(item,icon,text,tooltip,menutip) { \
2100 GtkWidget *child = NULL, *btn = NULL, *arr = NULL; \
2101 GList *gchild = NULL; \
2102 item = GTK_WIDGET(gtk_menu_tool_button_new(icon, text)); \
2103 gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE); \
2104 gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE); \
2105 g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item); \
2106 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1); \
2107 child = gtk_bin_get_child(GTK_BIN(item)); \
2108 gchild = gtk_container_get_children( \
2109 GTK_CONTAINER(child)); \
2110 btn = (GtkWidget *)gchild->data; \
2111 gtkut_widget_set_can_focus(btn, FALSE); \
2112 arr = (GtkWidget *)(gchild->next?gchild->next->data:NULL); \
2113 gtkut_widget_set_can_focus(arr, FALSE); \
2114 g_list_free(gchild); \
2115 gchild = gtk_container_get_children(GTK_CONTAINER(arr)); \
2116 gtk_widget_set_size_request(GTK_WIDGET(gchild->data), 9, -1); \
2117 g_list_free(gchild); \
2121 #define ADD_MENU_ITEM(name,cb,data) { \
2122 item = gtk_menu_item_new_with_mnemonic(name); \
2123 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); \
2124 g_signal_connect(G_OBJECT(item), "activate", \
2127 g_object_set_data(G_OBJECT(item), "int-value", GINT_TO_POINTER(data)); \
2128 gtk_widget_show(item); \
2131 static void toolbar_reply_menu_cb(GtkWidget *widget, gpointer data)
2133 gpointer int_value = g_object_get_data(G_OBJECT(widget), "int-value");
2134 ToolbarItem *toolbar_item = (ToolbarItem *)data;
2136 toolbar_reply(toolbar_item, GPOINTER_TO_INT(int_value));
2139 static void toolbar_learn_menu_cb(GtkWidget *widget, gpointer data)
2141 gpointer int_value = g_object_get_data(G_OBJECT(widget), "int-value");
2142 ToolbarItem *toolbar_item = (ToolbarItem *)data;
2144 toolbar_learn(toolbar_item, GPOINTER_TO_INT(int_value));
2148 * Create a new toolbar with specified type
2149 * if a callback list is passed it will be used before the
2150 * common callback list
2152 Toolbar *toolbar_create(ToolbarType type,
2153 GtkWidget *container,
2156 ToolbarItem *toolbar_item;
2159 GtkWidget *icon_wid = NULL;
2160 GtkWidget *icon_news;
2161 GtkWidget *icon_ham;
2163 ToolbarClawsActions *action_item;
2165 GSList *toolbar_list;
2166 Toolbar *toolbar_data;
2168 toolbar_read_config_file(type);
2169 toolbar_list = toolbar_get_list(type);
2171 toolbar_data = g_new0(Toolbar, 1);
2173 toolbar = gtk_toolbar_new();
2175 gtk_orientable_set_orientation(GTK_ORIENTABLE(toolbar), GTK_ORIENTATION_HORIZONTAL);
2177 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_BOTH);
2178 gtk_toolbar_set_show_arrow(GTK_TOOLBAR(toolbar), TRUE);
2180 for (cur = toolbar_list; cur != NULL; cur = cur->next) {
2182 if (g_ascii_strcasecmp(((ToolbarItem*)cur->data)->file, TOOLBAR_TAG_SEPARATOR) == 0) {
2183 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), gtk_separator_tool_item_new(), -1);
2187 toolbar_item = g_new0(ToolbarItem, 1);
2188 toolbar_item->index = ((ToolbarItem*)cur->data)->index;
2189 toolbar_item->file = g_strdup(((ToolbarItem*)cur->data)->file);
2190 toolbar_item->text = g_strdup(((ToolbarItem*)cur->data)->text);
2191 toolbar_item->parent = data;
2192 toolbar_item->type = type;
2194 /* collect toolbar items in list to keep track */
2195 toolbar_data->item_list =
2196 g_slist_append(toolbar_data->item_list,
2198 icon_wid = stock_pixmap_widget(stock_pixmap_get_icon(toolbar_item->file));
2200 switch (toolbar_item->index) {
2203 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Go to folder list"));
2204 toolbar_data->folders_btn = item;
2207 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2208 _("Receive Mail from all Accounts"),
2209 _("Receive Mail from selected Account"));
2210 toolbar_data->getall_btn = item;
2213 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text, _("Receive Mail from current Account"));
2214 toolbar_data->get_btn = item;
2217 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Send Queued Messages"));
2218 toolbar_data->send_btn = item;
2221 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Close window"));
2222 toolbar_data->close_window_btn = item;
2225 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Open preferences"));
2226 toolbar_data->preferences_btn = item;
2229 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Open email"));
2230 toolbar_data->open_mail_btn = item;
2232 case A_COMPOSE_EMAIL:
2233 #ifndef GENERIC_UMPC
2234 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2236 _("Compose with selected Account"));
2237 toolbar_data->compose_mail_btn = item;
2238 toolbar_data->compose_mail_icon = icon_wid;
2239 g_object_ref(toolbar_data->compose_mail_icon);
2241 icon_news = stock_pixmap_widget(STOCK_PIXMAP_NEWS_COMPOSE);
2242 toolbar_data->compose_news_icon = icon_news;
2243 g_object_ref(toolbar_data->compose_news_icon);
2245 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2246 _("Compose Email"));
2247 toolbar_data->compose_mail_btn = item;
2248 toolbar_data->compose_mail_icon = icon_wid;
2250 icon_news = stock_pixmap_widget(STOCK_PIXMAP_NEWS_COMPOSE);
2251 toolbar_data->compose_news_icon = icon_news;
2255 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2258 toolbar_data->learn_spam_btn = item;
2259 toolbar_data->learn_spam_icon = icon_wid;
2260 g_object_ref(toolbar_data->learn_spam_icon);
2262 icon_ham = stock_pixmap_widget(STOCK_PIXMAP_HAM_BTN);
2263 toolbar_data->learn_ham_icon = icon_ham;
2264 g_object_ref(toolbar_data->learn_ham_icon);
2266 menu = gtk_menu_new();
2267 ADD_MENU_ITEM(_("Learn as _Spam"), toolbar_learn_menu_cb, TRUE);
2268 ADD_MENU_ITEM(_("Learn as _Ham"), toolbar_learn_menu_cb, FALSE);
2269 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->learn_spam_btn), menu);
2271 case A_REPLY_MESSAGE:
2272 #ifndef GENERIC_UMPC
2273 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2274 _("Reply to Message"),
2275 _("Reply to Message options"));
2276 toolbar_data->reply_btn = item;
2278 menu = gtk_menu_new();
2279 ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_WITH_QUOTE);
2280 ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_WITHOUT_QUOTE);
2281 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->reply_btn), menu);
2283 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2284 _("Reply to Message"));
2285 toolbar_data->reply_btn = item;
2288 case A_REPLY_SENDER:
2289 #ifndef GENERIC_UMPC
2290 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2291 _("Reply to Sender"),
2292 _("Reply to Sender options"));
2293 toolbar_data->replysender_btn = item;
2295 menu = gtk_menu_new();
2296 ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE);
2297 ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE);
2298 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->replysender_btn), menu);
2300 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2301 _("Reply to Sender"));
2302 toolbar_data->replysender_btn = item;
2306 #ifndef GENERIC_UMPC
2307 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2309 _("Reply to All options"));
2310 toolbar_data->replyall_btn = item;
2312 menu = gtk_menu_new();
2313 ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE);
2314 ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE);
2315 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->replyall_btn), menu);
2317 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2319 toolbar_data->replyall_btn = item;
2323 #ifndef GENERIC_UMPC
2324 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2325 _("Reply to Mailing-list"),
2326 _("Reply to Mailing-list options"));
2327 toolbar_data->replylist_btn = item;
2329 menu = gtk_menu_new();
2330 ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_LIST_WITH_QUOTE);
2331 ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE);
2332 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->replylist_btn), menu);
2334 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2335 _("Reply to Mailing-list"));
2336 toolbar_data->replylist_btn = item;
2340 #ifndef GENERIC_UMPC
2341 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2342 _("Forward Message"),
2343 _("Forward Message options"));
2344 toolbar_data->fwd_btn = item;
2346 menu = gtk_menu_new();
2347 ADD_MENU_ITEM(_("_Forward"), toolbar_reply_menu_cb, COMPOSE_FORWARD_INLINE);
2348 ADD_MENU_ITEM(_("For_ward as attachment"), toolbar_reply_menu_cb, COMPOSE_FORWARD_AS_ATTACH);
2349 ADD_MENU_ITEM(_("Redirec_t"), toolbar_reply_menu_cb, COMPOSE_REDIRECT);
2350 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->fwd_btn), menu);
2352 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2353 _("Forward Message"));
2354 toolbar_data->fwd_btn = item;
2358 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Trash Message"));
2359 toolbar_data->trash_btn = item;
2362 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Delete Message"));
2363 toolbar_data->delete_btn = item;
2366 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Execute"));
2367 toolbar_data->exec_btn = item;
2370 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Go to Previous Unread Message"));
2371 toolbar_data->prev_btn = item;
2374 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Go to Next Unread Message"));
2375 toolbar_data->next_btn = item;
2378 /* Compose Toolbar */
2380 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Send Message"));
2381 toolbar_data->send_btn = item;
2384 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Put into queue folder and send later"));
2385 toolbar_data->sendl_btn = item;
2388 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Save to draft folder"));
2389 toolbar_data->draft_btn = item;
2392 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Insert file"));
2393 toolbar_data->insert_btn = item;
2396 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Attach file"));
2397 toolbar_data->attach_btn = item;
2400 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Insert signature"));
2401 toolbar_data->sig_btn = item;
2404 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Replace signature"));
2405 toolbar_data->repsig_btn = item;
2408 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Edit with external editor"));
2409 toolbar_data->exteditor_btn = item;
2411 case A_LINEWRAP_CURRENT:
2412 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Wrap long lines of current paragraph"));
2413 toolbar_data->linewrap_current_btn = item;
2415 case A_LINEWRAP_ALL:
2416 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Wrap all long lines"));
2417 toolbar_data->linewrap_all_btn = item;
2420 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Address book"));
2421 toolbar_data->addrbook_btn = item;
2424 case A_CHECK_SPELLING:
2425 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Check spelling"));
2426 toolbar_data->spellcheck_btn = item;
2430 case A_CLAWS_ACTIONS:
2431 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,toolbar_item->text);
2432 action_item = g_new0(ToolbarClawsActions, 1);
2433 action_item->widget = item;
2434 action_item->name = g_strdup(toolbar_item->text);
2436 toolbar_data->action_list =
2437 g_slist_append(toolbar_data->action_list,
2441 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Cancel receiving"));
2442 toolbar_data->cancel_inc_btn = item;
2445 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Cancel sending"));
2446 toolbar_data->cancel_send_btn = item;
2449 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Cancel receiving/sending"));
2450 toolbar_data->cancel_all_btn = item;
2452 case A_CLAWS_PLUGINS:
2453 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text, toolbar_item->text);
2456 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2457 toolbar_ret_descr_from_val(toolbar_item->index));
2458 /* find and set the tool tip text */
2463 toolbar_data->toolbar = toolbar;
2465 gtk_widget_show_all(toolbar);
2467 if (type == TOOLBAR_MAIN) {
2469 MainWindow *mainwin = mainwindow_get_mainwindow();
2470 GtkWidget *progressbar = gtk_progress_bar_new();
2471 item = GTK_WIDGET(gtk_tool_item_new());
2472 gtk_container_add (GTK_CONTAINER (item), progressbar);
2473 gtk_widget_show(item);
2474 gtk_widget_set_size_request(progressbar, 84, -1);
2475 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1);
2476 mainwin->progressbar = progressbar;
2478 activate_compose_button(toolbar_data,
2479 prefs_common.toolbar_style,
2480 toolbar_data->compose_btn_type);
2482 if (type != TOOLBAR_COMPOSE)
2483 activate_learn_button(toolbar_data, prefs_common.toolbar_style,
2486 gtk_container_add(GTK_CONTAINER(container), toolbar);
2487 gtk_container_set_border_width(GTK_CONTAINER(container), 0);
2489 return toolbar_data;
2493 * Free toolbar structures
2495 void toolbar_destroy(Toolbar * toolbar) {
2497 TOOLBAR_DESTROY_ITEMS(toolbar->item_list);
2498 TOOLBAR_DESTROY_ACTIONS(toolbar->action_list);
2501 void toolbar_update(ToolbarType type, gpointer data)
2503 Toolbar *toolbar_data;
2504 GtkWidget *handlebox;
2505 MainWindow *mainwin = (MainWindow*)data;
2506 Compose *compose = (Compose*)data;
2507 MessageView *msgview = (MessageView*)data;
2509 #ifndef GENERIC_UMPC
2512 toolbar_data = mainwin->toolbar;
2513 handlebox = mainwin->handlebox;
2515 case TOOLBAR_COMPOSE:
2516 toolbar_data = compose->toolbar;
2517 handlebox = compose->handlebox;
2519 case TOOLBAR_MSGVIEW:
2520 toolbar_data = msgview->toolbar;
2521 handlebox = msgview->handlebox;
2527 gtk_container_remove(GTK_CONTAINER(handlebox),
2528 GTK_WIDGET(toolbar_data->toolbar));
2530 toolbar_init(toolbar_data);
2531 toolbar_data = toolbar_create(type, handlebox, data);
2535 toolbar_data = mainwin->toolbar;
2536 handlebox = mainwin->window;
2538 case TOOLBAR_COMPOSE:
2539 toolbar_data = compose->toolbar;
2540 handlebox = compose->window;
2542 case TOOLBAR_MSGVIEW:
2543 toolbar_data = msgview->toolbar;
2544 handlebox = msgview->window;
2549 toolbar_init(toolbar_data);
2550 toolbar_data = toolbar_create(type, handlebox, data);
2555 mainwin->toolbar = toolbar_data;
2557 case TOOLBAR_COMPOSE:
2558 compose->toolbar = toolbar_data;
2560 case TOOLBAR_MSGVIEW:
2561 msgview->toolbar = toolbar_data;
2565 toolbar_style(type, prefs_common.toolbar_style, data);
2567 if (type == TOOLBAR_MAIN) {
2568 toolbar_main_set_sensitive((MainWindow*)data);
2569 account_set_menu_only_toolbar();
2573 #define GTK_BUTTON_SET_SENSITIVE(widget,sensitive) { \
2574 gtk_widget_set_sensitive(widget, sensitive); \
2577 void toolbar_main_set_sensitive(gpointer data)
2579 SensitiveCondMask state;
2581 MainWindow *mainwin = (MainWindow*)data;
2582 Toolbar *toolbar = mainwin->toolbar;
2584 GSList *entry_list = NULL;
2586 typedef struct _Entry Entry;
2589 SensitiveCondMask cond;
2593 #define SET_WIDGET_COND(w, ...) \
2595 Entry *e = g_new0(Entry, 1); \
2597 e->cond = main_window_get_mask(__VA_ARGS__, -1); \
2598 entry_list = g_slist_append(entry_list, e); \
2601 /* match all bit flags */
2603 if (toolbar->get_btn)
2604 SET_WIDGET_COND(toolbar->get_btn,
2605 M_HAVE_ACCOUNT, M_UNLOCKED, M_HAVE_RETRIEVABLE_ACCOUNT);
2607 if (toolbar->getall_btn) {
2608 SET_WIDGET_COND(toolbar->getall_btn,
2609 M_HAVE_ACCOUNT, M_UNLOCKED, M_HAVE_ANY_RETRIEVABLE_ACCOUNT);
2611 if (toolbar->send_btn) {
2612 SET_WIDGET_COND(toolbar->send_btn,
2613 M_HAVE_QUEUED_MAILS);
2615 if (toolbar->compose_mail_btn) {
2616 SET_WIDGET_COND(toolbar->compose_mail_btn,
2619 if (toolbar->close_window_btn) {
2620 SET_WIDGET_COND(toolbar->close_window_btn,
2623 if (toolbar->open_mail_btn) {
2624 SET_WIDGET_COND(toolbar->open_mail_btn,
2625 M_TARGET_EXIST, M_SUMMARY_ISLIST);
2627 if (toolbar->reply_btn) {
2628 SET_WIDGET_COND(toolbar->reply_btn,
2629 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2631 if (toolbar->replyall_btn) {
2632 SET_WIDGET_COND(toolbar->replyall_btn,
2633 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2635 if (toolbar->replylist_btn) {
2636 SET_WIDGET_COND(toolbar->replylist_btn,
2637 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2639 if (toolbar->replysender_btn) {
2640 SET_WIDGET_COND(toolbar->replysender_btn,
2641 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2643 if (toolbar->fwd_btn) {
2644 SET_WIDGET_COND(toolbar->fwd_btn,
2645 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2648 if (prefs_common.next_unread_msg_dialog == NEXTUNREADMSGDIALOG_ASSUME_NO) {
2649 SET_WIDGET_COND(toolbar->next_btn, M_MSG_EXIST, M_SUMMARY_ISLIST);
2651 SET_WIDGET_COND(toolbar->next_btn, -1);
2654 if (toolbar->trash_btn)
2655 SET_WIDGET_COND(toolbar->trash_btn,
2656 M_TARGET_EXIST, M_ALLOW_DELETE, M_NOT_NEWS);
2658 if (toolbar->delete_btn)
2659 SET_WIDGET_COND(toolbar->delete_btn,
2660 M_TARGET_EXIST, M_ALLOW_DELETE);
2662 if (toolbar->exec_btn)
2663 SET_WIDGET_COND(toolbar->exec_btn,
2666 if (toolbar->learn_spam_btn)
2667 SET_WIDGET_COND(toolbar->learn_spam_btn,
2668 M_TARGET_EXIST, M_CAN_LEARN_SPAM, M_SUMMARY_ISLIST);
2670 if (toolbar->cancel_inc_btn)
2671 SET_WIDGET_COND(toolbar->cancel_inc_btn,
2674 if (toolbar->cancel_send_btn)
2675 SET_WIDGET_COND(toolbar->cancel_send_btn,
2678 for (cur = toolbar->action_list; cur != NULL; cur = cur->next) {
2679 ToolbarClawsActions *act = (ToolbarClawsActions*)cur->data;
2681 SET_WIDGET_COND(act->widget, M_TARGET_EXIST, M_UNLOCKED);
2684 state = main_window_get_current_state(mainwin);
2686 for (cur = entry_list; cur != NULL; cur = cur->next) {
2687 Entry *e = (Entry*) cur->data;
2689 if (e->widget != NULL) {
2690 sensitive = ((e->cond & state) == e->cond);
2691 GTK_BUTTON_SET_SENSITIVE(e->widget, sensitive);
2695 while (entry_list != NULL) {
2696 Entry *e = (Entry*) entry_list->data;
2699 entry_list = g_slist_remove(entry_list, e);
2702 /* match any bit flags */
2704 if (toolbar->cancel_all_btn)
2705 SET_WIDGET_COND(toolbar->cancel_all_btn,
2706 M_INC_ACTIVE, M_SEND_ACTIVE);
2708 for (cur = entry_list; cur != NULL; cur = cur->next) {
2709 Entry *e = (Entry*) cur->data;
2711 if (e->widget != NULL) {
2712 sensitive = ((e->cond & state) != 0);
2713 GTK_BUTTON_SET_SENSITIVE(e->widget, sensitive);
2717 while (entry_list != NULL) {
2718 Entry *e = (Entry*) entry_list->data;
2721 entry_list = g_slist_remove(entry_list, e);
2724 g_slist_free(entry_list);
2726 activate_compose_button(toolbar,
2727 prefs_common.toolbar_style,
2728 toolbar->compose_btn_type);
2730 #undef SET_WIDGET_COND
2733 void toolbar_comp_set_sensitive(gpointer data, gboolean sensitive)
2735 Compose *compose = (Compose*)data;
2736 GSList *items = compose->toolbar->action_list;
2738 if (compose->toolbar->send_btn)
2739 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->send_btn, sensitive);
2740 if (compose->toolbar->sendl_btn)
2741 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->sendl_btn, sensitive);
2742 if (compose->toolbar->draft_btn )
2743 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->draft_btn , sensitive);
2744 if (compose->toolbar->insert_btn )
2745 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->insert_btn , sensitive);
2746 if (compose->toolbar->attach_btn)
2747 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->attach_btn, sensitive);
2748 if (compose->toolbar->sig_btn)
2749 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->sig_btn, sensitive);
2750 if (compose->toolbar->repsig_btn)
2751 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->repsig_btn, sensitive);
2752 if (compose->toolbar->exteditor_btn)
2753 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->exteditor_btn, sensitive);
2754 if (compose->toolbar->linewrap_current_btn)
2755 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->linewrap_current_btn, sensitive);
2756 if (compose->toolbar->linewrap_all_btn)
2757 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->linewrap_all_btn, sensitive);
2758 if (compose->toolbar->addrbook_btn)
2759 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->addrbook_btn, sensitive);
2761 if (compose->toolbar->spellcheck_btn)
2762 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->spellcheck_btn, sensitive);
2764 for (; items != NULL; items = g_slist_next(items)) {
2765 ToolbarClawsActions *item = (ToolbarClawsActions *)items->data;
2766 GTK_BUTTON_SET_SENSITIVE(item->widget, sensitive);
2771 * Initialize toolbar structure
2773 static void toolbar_init(Toolbar * toolbar)
2776 toolbar->toolbar = NULL;
2777 toolbar->folders_btn = NULL;
2778 toolbar->get_btn = NULL;
2779 toolbar->getall_btn = NULL;
2780 toolbar->send_btn = NULL;
2781 toolbar->compose_mail_btn = NULL;
2782 toolbar->compose_mail_icon = NULL;
2783 toolbar->compose_news_icon = NULL;
2784 toolbar->reply_btn = NULL;
2785 toolbar->replysender_btn = NULL;
2786 toolbar->replyall_btn = NULL;
2787 toolbar->replylist_btn = NULL;
2788 toolbar->fwd_btn = NULL;
2789 toolbar->trash_btn = NULL;
2790 toolbar->delete_btn = NULL;
2791 toolbar->prev_btn = NULL;
2792 toolbar->next_btn = NULL;
2793 toolbar->exec_btn = NULL;
2794 toolbar->separator = NULL;
2795 toolbar->learn_spam_btn = NULL;
2796 toolbar->learn_spam_icon = NULL;
2797 toolbar->learn_ham_icon = NULL;
2798 toolbar->cancel_inc_btn = NULL;
2799 toolbar->cancel_send_btn = NULL;
2800 toolbar->cancel_all_btn = NULL;
2802 /* compose buttons */
2803 toolbar->sendl_btn = NULL;
2804 toolbar->draft_btn = NULL;
2805 toolbar->insert_btn = NULL;
2806 toolbar->attach_btn = NULL;
2807 toolbar->sig_btn = NULL;
2808 toolbar->repsig_btn = NULL;
2809 toolbar->exteditor_btn = NULL;
2810 toolbar->linewrap_current_btn = NULL;
2811 toolbar->linewrap_all_btn = NULL;
2812 toolbar->addrbook_btn = NULL;
2814 toolbar->open_mail_btn = NULL;
2815 toolbar->close_window_btn = NULL;
2816 toolbar->preferences_btn = NULL;
2817 toolbar->action_list = NULL;
2818 toolbar->item_list = NULL;
2820 toolbar->spellcheck_btn = NULL;
2823 toolbar_destroy(toolbar);
2828 static void toolbar_reply(gpointer data, guint action)
2830 ToolbarItem *toolbar_item = (ToolbarItem*)data;
2831 MainWindow *mainwin;
2832 MessageView *msgview;
2833 GSList *msginfo_list = NULL;
2835 cm_return_if_fail(toolbar_item != NULL);
2837 switch (toolbar_item->type) {
2839 mainwin = (MainWindow*)toolbar_item->parent;
2840 msginfo_list = summary_get_selection(mainwin->summaryview);
2841 msgview = (MessageView*)mainwin->messageview;
2843 case TOOLBAR_MSGVIEW:
2844 msgview = (MessageView*)toolbar_item->parent;
2845 cm_return_if_fail(msgview != NULL);
2846 msginfo_list = g_slist_append(msginfo_list, msgview->msginfo);
2852 cm_return_if_fail(msgview != NULL);
2853 cm_return_if_fail(msginfo_list != NULL);
2854 compose_reply_from_messageview(msgview, msginfo_list, action);
2855 g_slist_free(msginfo_list);
2857 /* TODO: update reply state ion summaryview */
2861 /* exported functions */
2863 void inc_mail_cb(gpointer data, guint action, GtkWidget *widget)
2865 MainWindow *mainwin = (MainWindow*)data;
2867 inc_mail(mainwin, prefs_common.newmail_notify_manu);
2870 void inc_all_account_mail_cb(gpointer data, guint action, GtkWidget *widget)
2872 MainWindow *mainwin = (MainWindow*)data;
2874 inc_all_account_mail(mainwin, FALSE, prefs_common.newmail_notify_manu);
2877 void send_queue_cb(gpointer data, guint action, GtkWidget *widget)
2881 gboolean got_error = FALSE;
2882 gchar *errstr = NULL;
2884 if (prefs_common.work_offline)
2885 if (alertpanel(_("Offline warning"),
2886 _("You're working offline. Override?"),
2887 GTK_STOCK_NO, GTK_STOCK_YES,
2888 NULL) != G_ALERTALTERNATE)
2891 /* ask for confirmation before sending queued messages only
2892 in online mode and if there is at least one message queued
2893 in any of the folder queue
2895 if (prefs_common.confirm_send_queued_messages) {
2897 /* check if there's a queued message */
2898 for (list = folder_get_list(); !found && list != NULL; list = list->next) {
2899 Folder *folder = list->data;
2901 found = !procmsg_queue_is_empty(folder->queue);
2903 /* if necessary, ask for confirmation before sending */
2904 if (found && !prefs_common.work_offline) {
2905 if (alertpanel(_("Send queued messages"),
2906 _("Send all queued messages?"),
2907 GTK_STOCK_CANCEL, _("_Send"),
2908 NULL) != G_ALERTALTERNATE)
2913 for (list = folder_get_list(); list != NULL; list = list->next) {
2914 Folder *folder = list->data;
2916 if (folder->queue) {
2917 if (procmsg_send_queue(folder->queue,
2918 prefs_common.savemsg,
2925 alertpanel_error_log(_("Some errors occurred while "
2926 "sending queued messages."));
2928 alertpanel_error_log(_("Some errors occurred "
2929 "while sending queued messages:\n%s"), errstr);
2935 void compose_mail_cb(gpointer data, guint action, GtkWidget *widget)
2937 MainWindow *mainwin = (MainWindow*)data;
2938 PrefsAccount *ac = NULL;
2939 FolderItem *item = mainwin->summaryview->folder_item;
2944 ac = account_find_from_item(item);
2945 if (ac && ac->protocol != A_NNTP && ac->protocol != A_IMAP4) {
2946 compose_new_with_folderitem(ac, item, NULL); /* CLAWS */
2952 * CLAWS - use current account
2954 if (cur_account && (cur_account->protocol != A_NNTP)) {
2955 compose_new_with_folderitem(cur_account, item, NULL);
2960 * CLAWS - just get the first one
2962 list = account_get_list();
2963 for (cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2964 ac = (PrefsAccount *) cur->data;
2965 if (ac->protocol != A_NNTP) {
2966 compose_new_with_folderitem(ac, item, NULL);
2972 void compose_news_cb(gpointer data, guint action, GtkWidget *widget)
2974 MainWindow *mainwin = (MainWindow*)data;
2975 PrefsAccount * ac = NULL;
2979 if (mainwin->summaryview->folder_item) {
2980 ac = mainwin->summaryview->folder_item->folder->account;
2981 if (ac && ac->protocol == A_NNTP) {
2982 compose_new_with_folderitem(ac,
2983 mainwin->summaryview->folder_item, NULL);
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,
2993 mainwin->summaryview->folder_item, NULL);