2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2001-2013 Hiroyuki Yamamoto and the Claws Mail team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 * General functions for accessing address book files.
26 #include "claws-features.h"
32 #include <glib/gi18n.h>
41 #include "mainwindow.h"
42 #include "summaryview.h"
47 #include "prefs_gtk.h"
49 #include "stock_pixmap.h"
50 #include "manage_window.h"
56 #include "prefs_actions.h"
57 #include "prefs_common.h"
58 #include "prefs_toolbar.h"
59 #include "alertpanel.h"
62 #include "send_message.h"
63 #ifndef USE_ALT_ADDRBOOK
64 #include "addressbook.h"
66 #include "addressbook-dbus.h"
70 #define TOOLBAR_TAG_INDEX "toolbar"
71 #define TOOLBAR_TAG_ITEM "item"
72 #define TOOLBAR_TAG_SEPARATOR "separator"
74 #define TOOLBAR_ICON_FILE "file"
75 #define TOOLBAR_ICON_TEXT "text"
76 #define TOOLBAR_ICON_ACTION "action"
78 static void toolbar_init(Toolbar * toolbar);
79 static gboolean toolbar_is_duplicate (gint action,
81 static void toolbar_parse_item (XMLFile *file,
82 ToolbarType source, gboolean *rewrite);
84 static gint toolbar_ret_val_from_text (const gchar *text);
85 static gchar *toolbar_ret_text_from_val (gint val);
87 typedef struct _DefaultToolbar DefaultToolbar;
88 struct _DefaultToolbar {
91 static void toolbar_set_default_generic(ToolbarType toolbar_type,
92 DefaultToolbar *default_toolbar);
94 static void toolbar_style (ToolbarType type,
98 static MainWindow *get_mainwin (gpointer data);
99 static void activate_compose_button (Toolbar *toolbar,
101 ComposeButtonType type);
103 /* toolbar callbacks */
104 static void toolbar_reply (gpointer data,
106 static void toolbar_learn (gpointer data,
108 static void toolbar_delete_cb (GtkWidget *widget,
110 static void toolbar_trash_cb (GtkWidget *widget,
113 static void toolbar_compose_cb (GtkWidget *widget,
116 static void toolbar_learn_cb (GtkWidget *widget,
119 static void toolbar_reply_cb (GtkWidget *widget,
122 static void toolbar_reply_to_all_cb (GtkWidget *widget,
125 static void toolbar_reply_to_list_cb (GtkWidget *widget,
128 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
131 static void toolbar_forward_cb (GtkWidget *widget,
134 static void toolbar_prev_unread_cb (GtkWidget *widget,
136 static void toolbar_next_unread_cb (GtkWidget *widget,
139 static void toolbar_ignore_thread_cb (GtkWidget *widget,
142 static void toolbar_watch_thread_cb (GtkWidget *widget,
145 static void toolbar_mark_cb (GtkWidget *widget,
148 static void toolbar_unmark_cb (GtkWidget *widget,
151 static void toolbar_lock_cb (GtkWidget *widget,
154 static void toolbar_ulock_cb (GtkWidget *widget,
157 static void toolbar_all_read_cb (GtkWidget *widget,
160 static void toolbar_all_unread_cb (GtkWidget *widget,
163 static void toolbar_read_cb (GtkWidget *widget,
166 static void toolbar_unread_cb (GtkWidget *widget,
169 static void toolbar_print_cb (GtkWidget *widget,
172 static void toolbar_actions_execute_cb (GtkWidget *widget,
174 static void toolbar_plugins_execute_cb (GtkWidget *widget,
178 static void toolbar_send_cb (GtkWidget *widget,
180 static void toolbar_send_later_cb (GtkWidget *widget,
182 static void toolbar_draft_cb (GtkWidget *widget,
184 static void toolbar_close_cb (GtkWidget *widget,
186 static void toolbar_preferences_cb (GtkWidget *widget,
188 static void toolbar_open_mail_cb (GtkWidget *widget,
190 static void toolbar_insert_cb (GtkWidget *widget,
192 static void toolbar_attach_cb (GtkWidget *widget,
194 static void toolbar_sig_cb (GtkWidget *widget,
196 static void toolbar_ext_editor_cb (GtkWidget *widget,
198 static void toolbar_linewrap_current_cb (GtkWidget *widget,
200 static void toolbar_linewrap_all_cb (GtkWidget *widget,
202 static void toolbar_addrbook_cb (GtkWidget *widget,
205 static void toolbar_check_spelling_cb (GtkWidget *widget,
208 static void toolbar_cancel_inc_cb (GtkWidget *widget,
210 static void toolbar_cancel_send_cb (GtkWidget *widget,
212 static void toolbar_cancel_all_cb (GtkWidget *widget,
218 } toolbar_text [] = {
219 { "A_RECEIVE_ALL", N_("Receive Mail from all Accounts") },
220 { "A_RECEIVE_CUR", N_("Receive Mail from current Account") },
221 { "A_SEND_QUEUED", N_("Send Queued Messages") },
222 { "A_COMPOSE_EMAIL", N_("Compose Email") },
223 { "A_COMPOSE_NEWS", N_("Compose News") },
224 { "A_REPLY_MESSAGE", N_("Reply to Message") },
225 { "A_REPLY_SENDER", N_("Reply to Sender") },
226 { "A_REPLY_ALL", N_("Reply to All") },
227 { "A_REPLY_ML", N_("Reply to Mailing-list") },
228 { "A_OPEN_MAIL", N_("Open email") },
229 { "A_FORWARD", N_("Forward Message") },
230 { "A_TRASH", N_("Trash Message") },
231 { "A_DELETE_REAL", N_("Delete Message") },
232 { "A_EXECUTE", N_("Execute") },
233 { "A_GOTO_PREV", N_("Go to Previous Unread Message") },
234 { "A_GOTO_NEXT", N_("Go to Next Unread Message") },
236 { "A_IGNORE_THREAD", N_("Ignore thread") },
237 { "A_WATCH_THREAD", N_("Watch thread") },
238 { "A_MARK", N_("Mark Message") },
239 { "A_UNMARK", N_("Unmark Message") },
240 { "A_LOCK", N_("Lock Message") },
241 { "A_UNLOCK", N_("Unlock Message") },
242 { "A_ALL_READ", N_("Mark all Messages as read") },
243 { "A_ALL_UNREAD", N_("Mark all Messages as unread") },
244 { "A_READ", N_("Mark Message as read") },
245 { "A_UNREAD", N_("Mark Message as unread") },
247 { "A_PRINT", N_("Print") },
248 { "A_LEARN_SPAM", N_("Learn Spam or Ham") },
249 { "A_GO_FOLDERS", N_("Open folder/Go to folder list") },
250 { "A_PREFERENCES", N_("Preferences") },
252 { "A_SEND", N_("Send Message") },
253 { "A_SEND_LATER", N_("Put into queue folder and send later") },
254 { "A_DRAFT", N_("Save to draft folder") },
255 { "A_INSERT", N_("Insert file") },
256 { "A_ATTACH", N_("Attach file") },
257 { "A_SIG", N_("Insert signature") },
258 { "A_REP_SIG", N_("Replace signature") },
259 { "A_EXTEDITOR", N_("Edit with external editor") },
260 { "A_LINEWRAP_CURRENT", N_("Wrap long lines of current paragraph") },
261 { "A_LINEWRAP_ALL", N_("Wrap all long lines") },
262 { "A_ADDRBOOK", N_("Address book") },
264 { "A_CHECK_SPELLING", N_("Check spelling") },
266 { "A_CLAWS_ACTIONS", N_("Claws Mail Actions Feature") },
267 { "A_CANCEL_INC", N_("Cancel receiving") },
268 { "A_CANCEL_SEND", N_("Cancel sending") },
269 { "A_CANCEL_ALL", N_("Cancel receiving/sending") },
270 { "A_CLOSE", N_("Close window") },
271 { "A_SEPARATOR", N_("Separator") },
272 { "A_CLAWS_PLUGINS", N_("Claws Mail Plugins") }
275 /* migration table: support reading toolbar configuration files with
276 old action names and converting them to current action names,
277 see toolbar_parse_item(), which makes uses of this alias table.
280 const gchar *old_name;
281 const gchar *current_name;
282 } toolbar_migration [] = {
283 { "A_SYL_ACTIONS", "A_CLAWS_ACTIONS" },
284 { "A_SENDL", "A_SEND_LATER" },
288 /* struct holds configuration files and a list of
289 * currently active toolbar items
290 * TOOLBAR_MAIN, TOOLBAR_COMPOSE and TOOLBAR_MSGVIEW
294 const gchar *conf_file;
296 } toolbar_config[NUM_TOOLBARS] = {
297 { "toolbar_main.xml", NULL},
298 { "toolbar_compose.xml", NULL},
299 { "toolbar_msgview.xml", NULL}
302 gint toolbar_ret_val_from_descr(const gchar *descr)
306 for (i = 0; i < N_ACTION_VAL; i++) {
307 if (g_utf8_collate(gettext(toolbar_text[i].descr), descr) == 0)
314 gchar *toolbar_ret_descr_from_val(gint val)
316 cm_return_val_if_fail(val >=0 && val < N_ACTION_VAL, NULL);
318 return gettext(toolbar_text[val].descr);
321 static gint toolbar_ret_val_from_text(const gchar *text)
325 for (i = 0; i < N_ACTION_VAL; i++) {
326 if (g_utf8_collate(toolbar_text[i].index_str, text) == 0)
333 static gchar *toolbar_ret_text_from_val(gint val)
335 cm_return_val_if_fail(val >=0 && val < N_ACTION_VAL, NULL);
337 return toolbar_text[val].index_str;
340 static gboolean toolbar_is_duplicate(gint action, ToolbarType source)
344 if ((action == A_SEPARATOR) || (action == A_CLAWS_ACTIONS) || (action == A_CLAWS_PLUGINS))
347 for (cur = toolbar_config[source].item_list; cur != NULL; cur = cur->next) {
348 ToolbarItem *item = (ToolbarItem*) cur->data;
350 if (item->index == action)
356 /* depending on toolbar type this function
357 returns a list of available toolbar events being
358 displayed by prefs_toolbar
360 GList *toolbar_get_action_items(ToolbarType source)
365 if (source == TOOLBAR_MAIN) {
366 gint main_items[] = {
367 A_RECEIVE_ALL, A_RECEIVE_CUR, A_SEND_QUEUED,
368 A_COMPOSE_EMAIL, A_REPLY_MESSAGE, A_REPLY_SENDER,
369 A_REPLY_ALL, A_REPLY_ML, A_OPEN_MAIL, A_FORWARD,
370 A_TRASH, A_DELETE_REAL, A_EXECUTE, A_GOTO_PREV,
371 A_GOTO_NEXT, A_IGNORE_THREAD, A_WATCH_THREAD, A_MARK,
372 A_UNMARK, A_LOCK, A_UNLOCK, A_ALL_READ,
373 A_ALL_UNREAD, A_READ, A_UNREAD, A_PRINT,
374 A_ADDRBOOK, A_LEARN_SPAM, A_GO_FOLDERS,
375 A_CANCEL_INC, A_CANCEL_SEND, A_CANCEL_ALL, A_PREFERENCES };
377 for (i = 0; i < sizeof main_items / sizeof main_items[0]; i++) {
378 items = g_list_append(items, gettext(toolbar_text[main_items[i]].descr));
381 else if (source == TOOLBAR_COMPOSE) {
382 gint comp_items[] = {
383 A_SEND, A_SEND_LATER, A_DRAFT,
384 A_INSERT, A_ATTACH, A_SIG,
385 A_REP_SIG, A_EXTEDITOR, A_LINEWRAP_CURRENT,
386 A_LINEWRAP_ALL, A_ADDRBOOK,
392 for (i = 0; i < sizeof comp_items / sizeof comp_items[0]; i++)
393 items = g_list_append(items, gettext(toolbar_text[comp_items[i]].descr));
395 else if (source == TOOLBAR_MSGVIEW) {
396 gint msgv_items[] = {
397 A_COMPOSE_EMAIL, A_REPLY_MESSAGE, A_REPLY_SENDER,
398 A_REPLY_ALL, A_REPLY_ML, A_FORWARD,
399 A_TRASH, A_DELETE_REAL, A_GOTO_PREV, A_GOTO_NEXT,
400 A_ADDRBOOK, A_LEARN_SPAM, A_CLOSE };
402 for (i = 0; i < sizeof msgv_items / sizeof msgv_items[0]; i++)
403 items = g_list_append(items, gettext(toolbar_text[msgv_items[i]].descr));
409 static void toolbar_parse_item(XMLFile *file, ToolbarType source, gboolean *rewrite)
413 ToolbarItem *item = NULL;
415 g_return_if_fail(rewrite != NULL);
417 attr = xml_get_current_tag_attr(file);
418 item = g_new0(ToolbarItem, 1);
420 name = ((XMLAttr *)attr->data)->name;
421 value = ((XMLAttr *)attr->data)->value;
423 if (g_utf8_collate(name, TOOLBAR_ICON_FILE) == 0)
424 item->file = g_strdup (value);
425 else if (g_utf8_collate(name, TOOLBAR_ICON_TEXT) == 0)
426 item->text = g_strdup (*value ? gettext(value):"");
427 else if (g_utf8_collate(name, TOOLBAR_ICON_ACTION) == 0)
428 item->index = toolbar_ret_val_from_text(value);
430 if ((item->index == -1) && !strcmp(value, "A_DELETE")) {
432 item->index = A_TRASH;
434 item->file = g_strdup("trash_btn");
436 item->text = g_strdup(C_("Toolbar", "Trash"));
439 if (item->index == -1) {
440 /* item not found in table: try migrating old action names to current ones */
443 /* replace action name */
444 for (i = 0; toolbar_migration[i].old_name != NULL; i++) {
445 if (g_utf8_collate(value, toolbar_migration[i].old_name) == 0) {
446 item->index = toolbar_ret_val_from_text(toolbar_migration[i].current_name);
447 if (item->index != -1) {
449 debug_print("toolbar_parse_item: migrating action label from '%s' to '%s'\n",
450 value, toolbar_migration[i].current_name);
456 if ((item->index == -1) && !rewrite)
457 g_warning("toolbar_parse_item: unrecognized action name '%s'\n", value);
459 attr = g_list_next(attr);
461 if (item->index != -1) {
462 if (!toolbar_is_duplicate(item->index, source))
463 toolbar_config[source].item_list = g_slist_append(toolbar_config[source].item_list,
468 const gchar *toolbar_get_short_text(int action) {
470 case A_RECEIVE_ALL: return _("Get Mail");
471 case A_RECEIVE_CUR: return _("Get");
472 case A_SEND_QUEUED: return _("Send");
473 case A_COMPOSE_EMAIL: return C_("Toolbar", "Compose");
474 case A_COMPOSE_NEWS: return C_("Toolbar", "Compose");
475 case A_REPLY_MESSAGE: return _("Reply");
476 case A_REPLY_SENDER: return C_("Toolbar", "Sender");
477 case A_REPLY_ALL: return _("All");
478 case A_REPLY_ML: return _("List");
479 case A_OPEN_MAIL: return _("Open");
480 case A_FORWARD: return _("Forward");
481 case A_TRASH: return C_("Toolbar", "Trash");
482 case A_DELETE_REAL: return _("Delete");
483 case A_EXECUTE: return _("Execute");
484 case A_GOTO_PREV: return _("Prev");
485 case A_GOTO_NEXT: return _("Next");
487 case A_IGNORE_THREAD: return _("Ignore thread");
488 case A_WATCH_THREAD: return _("Watch thread");
489 case A_MARK: return _("Mark");
490 case A_UNMARK: return _("Unmark");
491 case A_LOCK: return _("Lock");
492 case A_UNLOCK: return _("Unlock");
493 case A_ALL_READ: return _("All read");
494 case A_ALL_UNREAD: return _("All unread");
495 case A_READ: return _("Read");
496 case A_UNREAD: return _("Unread");
498 case A_PRINT: return _("Print");
499 case A_LEARN_SPAM: return _("Spam");
500 case A_GO_FOLDERS: return _("Folders");
501 case A_PREFERENCES: return _("Preferences");
503 case A_SEND: return _("Send");
504 case A_SEND_LATER: return _("Send later");
505 case A_DRAFT: return _("Draft");
506 case A_INSERT: return _("Insert");
507 case A_ATTACH: return _("Attach");
508 case A_SIG: return _("Insert sig.");
509 case A_REP_SIG: return _("Replace sig.");
510 case A_EXTEDITOR: return _("Edit");
511 case A_LINEWRAP_CURRENT:return _("Wrap para.");
512 case A_LINEWRAP_ALL: return _("Wrap all");
513 case A_ADDRBOOK: return _("Address");
515 case A_CHECK_SPELLING: return _("Check spelling");
518 case A_CANCEL_INC: return _("Stop");
519 case A_CANCEL_SEND: return _("Stop");
520 case A_CANCEL_ALL: return _("Stop all");
521 case A_CLOSE: return _("Close");
526 gint toolbar_get_icon(int action) {
528 case A_RECEIVE_ALL: return STOCK_PIXMAP_MAIL_RECEIVE_ALL;
529 case A_RECEIVE_CUR: return STOCK_PIXMAP_MAIL_RECEIVE;
530 case A_SEND_QUEUED: return STOCK_PIXMAP_MAIL_SEND_QUEUE;
531 case A_COMPOSE_EMAIL: return STOCK_PIXMAP_MAIL_COMPOSE;
532 case A_COMPOSE_NEWS: return STOCK_PIXMAP_NEWS_COMPOSE;
533 case A_REPLY_MESSAGE: return STOCK_PIXMAP_MAIL_REPLY;
534 case A_REPLY_SENDER: return STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR;
535 case A_REPLY_ALL: return STOCK_PIXMAP_MAIL_REPLY_TO_ALL;
536 case A_REPLY_ML: return STOCK_PIXMAP_MAIL_REPLY_TO_LIST;
537 case A_OPEN_MAIL: return STOCK_PIXMAP_OPEN_MAIL;
538 case A_FORWARD: return STOCK_PIXMAP_MAIL_FORWARD;
539 case A_TRASH: return STOCK_PIXMAP_TRASH;
540 case A_DELETE_REAL: return STOCK_PIXMAP_DELETE;
541 case A_EXECUTE: return STOCK_PIXMAP_EXEC;
542 case A_GOTO_PREV: return STOCK_PIXMAP_UP_ARROW;
543 case A_GOTO_NEXT: return STOCK_PIXMAP_DOWN_ARROW;
545 case A_IGNORE_THREAD: return STOCK_PIXMAP_MARK_IGNORETHREAD;
546 case A_WATCH_THREAD: return STOCK_PIXMAP_MARK_WATCHTHREAD;
547 case A_MARK: return STOCK_PIXMAP_MARK_MARK;
548 case A_UNMARK: return STOCK_PIXMAP_MARK_UNMARK;
549 case A_LOCK: return STOCK_PIXMAP_MARK_LOCKED;
550 case A_UNLOCK: return STOCK_PIXMAP_MARK_UNLOCKED;
551 case A_ALL_READ: return STOCK_PIXMAP_MARK_ALLREAD;
552 case A_ALL_UNREAD: return STOCK_PIXMAP_MARK_ALLUNREAD;
553 case A_READ: return STOCK_PIXMAP_MARK_READ;
554 case A_UNREAD: return STOCK_PIXMAP_MARK_UNREAD;
556 case A_PRINT: return STOCK_PIXMAP_PRINTER;
557 case A_LEARN_SPAM: return STOCK_PIXMAP_SPAM_BTN;
558 case A_GO_FOLDERS: return STOCK_PIXMAP_GO_FOLDERS;
559 case A_PREFERENCES: return STOCK_PIXMAP_PREFERENCES;
561 case A_SEND: return STOCK_PIXMAP_MAIL_SEND;
562 case A_SEND_LATER: return STOCK_PIXMAP_MAIL_SEND_QUEUE;
563 case A_DRAFT: return STOCK_PIXMAP_MAIL;
564 case A_INSERT: return STOCK_PIXMAP_INSERT_FILE;
565 case A_ATTACH: return STOCK_PIXMAP_MAIL_ATTACH;
566 case A_SIG: return STOCK_PIXMAP_MAIL_SIGN;
567 case A_REP_SIG: return STOCK_PIXMAP_MAIL_SIGN;
568 case A_EXTEDITOR: return STOCK_PIXMAP_EDIT_EXTERN;
569 case A_LINEWRAP_CURRENT:return STOCK_PIXMAP_LINEWRAP_CURRENT;
570 case A_LINEWRAP_ALL: return STOCK_PIXMAP_LINEWRAP_ALL;
571 case A_ADDRBOOK: return STOCK_PIXMAP_ADDRESS_BOOK;
573 case A_CHECK_SPELLING: return STOCK_PIXMAP_CHECK_SPELLING;
576 case A_CANCEL_INC: return STOCK_PIXMAP_CANCEL;
577 case A_CANCEL_SEND: return STOCK_PIXMAP_CANCEL;
578 case A_CANCEL_ALL: return STOCK_PIXMAP_CANCEL;
579 case A_CLOSE: return STOCK_PIXMAP_CLOSE;
584 static void toolbar_set_default_generic(ToolbarType toolbar_type, DefaultToolbar *default_toolbar)
588 g_return_if_fail(default_toolbar != NULL);
590 for (i = 0; default_toolbar[i].action != N_ACTION_VAL; i++) {
592 ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
594 if (default_toolbar[i].action != A_SEPARATOR) {
598 icon = toolbar_get_icon(default_toolbar[i].action);
600 file = stock_pixmap_get_name((StockPixmap)icon);
602 toolbar_item->file = g_strdup(file);
603 toolbar_item->index = default_toolbar[i].action;
604 toolbar_item->text = g_strdup(toolbar_get_short_text(default_toolbar[i].action));
606 toolbar_item->file = g_strdup(TOOLBAR_TAG_SEPARATOR);
607 toolbar_item->index = A_SEPARATOR;
610 if (toolbar_item->index != -1) {
611 if (!toolbar_is_duplicate(toolbar_item->index, toolbar_type))
612 toolbar_config[toolbar_type].item_list =
613 g_slist_append(toolbar_config[toolbar_type].item_list, toolbar_item);
618 void toolbar_set_default(ToolbarType source)
620 DefaultToolbar default_toolbar_main[] = {
646 DefaultToolbar default_toolbar_compose[] = {
664 DefaultToolbar default_toolbar_msgview[] = {
682 if (source == TOOLBAR_MAIN)
683 toolbar_set_default_generic(TOOLBAR_MAIN, default_toolbar_main);
684 else if (source == TOOLBAR_COMPOSE)
685 toolbar_set_default_generic(TOOLBAR_COMPOSE, default_toolbar_compose);
686 else if (source == TOOLBAR_MSGVIEW)
687 toolbar_set_default_generic(TOOLBAR_MSGVIEW, default_toolbar_msgview);
690 void toolbar_save_config_file(ToolbarType source)
695 gchar *fileSpec = NULL;
697 debug_print("save Toolbar Configuration to %s\n", toolbar_config[source].conf_file);
699 fileSpec = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, toolbar_config[source].conf_file, NULL );
700 pfile = prefs_write_open(fileSpec);
703 if (fprintf(fp, "<?xml version=\"1.0\" encoding=\"%s\" ?>\n", CS_INTERNAL) < 0)
706 if (fprintf(fp, "<%s>\n", TOOLBAR_TAG_INDEX) < 0)
709 for (cur = toolbar_config[source].item_list; cur != NULL; cur = cur->next) {
710 ToolbarItem *toolbar_item = (ToolbarItem*) cur->data;
712 if (toolbar_item->index != A_SEPARATOR) {
713 if (fprintf(fp, "\t<%s %s=\"%s\" %s=\"",
715 TOOLBAR_ICON_FILE, toolbar_item->file,
716 TOOLBAR_ICON_TEXT) < 0)
718 if (xml_file_put_escape_str(fp, toolbar_item->text) < 0)
720 if (fprintf(fp, "\" %s=\"%s\"/>\n",
722 toolbar_ret_text_from_val(toolbar_item->index)) < 0)
725 if (fprintf(fp, "\t<%s/>\n", TOOLBAR_TAG_SEPARATOR) < 0)
730 if (fprintf(fp, "</%s>\n", TOOLBAR_TAG_INDEX) < 0)
734 if (prefs_file_close (pfile) < 0 )
735 g_warning("failed to write toolbar configuration to file");
739 FILE_OP_ERROR(fileSpec, "fprintf");
741 prefs_file_close_revert (pfile);
743 g_warning("failed to open toolbar configuration file for writing");
746 void toolbar_read_config_file(ToolbarType source)
748 XMLFile *file = NULL;
749 gchar *fileSpec = NULL;
751 gboolean rewrite = FALSE;
753 debug_print("read Toolbar Configuration from %s\n", toolbar_config[source].conf_file);
755 fileSpec = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, toolbar_config[source].conf_file, NULL );
756 file = xml_open_file(fileSpec);
759 toolbar_clear_list(source);
763 || (xml_get_dtd(file))
764 || (xml_parse_next_tag(file))
765 || (!xml_compare_tag(file, TOOLBAR_TAG_INDEX))) {
766 xml_close_file(file);
774 if (xml_parse_next_tag(file))
777 /* Get next tag (icon, icon_text or icon_action) */
778 if (xml_compare_tag(file, TOOLBAR_TAG_ITEM)) {
779 toolbar_parse_item(file, source, &rewrite);
780 } else if (xml_compare_tag(file, TOOLBAR_TAG_SEPARATOR)) {
781 ToolbarItem *item = g_new0(ToolbarItem, 1);
783 item->file = g_strdup(TOOLBAR_TAG_SEPARATOR);
784 item->index = A_SEPARATOR;
785 toolbar_config[source].item_list =
786 g_slist_append(toolbar_config[source].item_list, item);
790 xml_close_file(file);
792 debug_print("toolbar_read_config_file: rewriting toolbar\n");
793 toolbar_save_config_file(source);
797 if ((!file) || (g_slist_length(toolbar_config[source].item_list) == 0)) {
799 if (source == TOOLBAR_MAIN)
800 toolbar_set_default(TOOLBAR_MAIN);
801 else if (source == TOOLBAR_COMPOSE)
802 toolbar_set_default(TOOLBAR_COMPOSE);
803 else if (source == TOOLBAR_MSGVIEW)
804 toolbar_set_default(TOOLBAR_MSGVIEW);
806 g_warning("refusing to write unknown Toolbar Configuration number %d", source);
810 toolbar_save_config_file(source);
815 * clears list of toolbar items read from configuration files
817 void toolbar_clear_list(ToolbarType source)
819 while (toolbar_config[source].item_list != NULL) {
820 ToolbarItem *item = (ToolbarItem*) toolbar_config[source].item_list->data;
822 toolbar_config[source].item_list =
823 g_slist_remove(toolbar_config[source].item_list, item);
829 g_slist_free(toolbar_config[source].item_list);
834 * return list of Toolbar items
836 GSList *toolbar_get_list(ToolbarType source)
840 if ((source == TOOLBAR_MAIN) || (source == TOOLBAR_COMPOSE) || (source == TOOLBAR_MSGVIEW))
841 list = toolbar_config[source].item_list;
846 void toolbar_set_list_item(ToolbarItem *t_item, ToolbarType source)
848 ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
850 toolbar_item->file = g_strdup(t_item->file);
851 toolbar_item->text = g_strdup(t_item->text);
852 toolbar_item->index = t_item->index;
854 toolbar_config[source].item_list =
855 g_slist_append(toolbar_config[source].item_list,
859 static void toolbar_action_execute(GtkWidget *widget,
867 for (cur = action_list; cur != NULL; cur = cur->next) {
868 ToolbarClawsActions *act = (ToolbarClawsActions*)cur->data;
870 if (widget == act->widget) {
871 i = prefs_actions_find_by_name(act->name);
879 actions_execute(data, i, widget, source);
881 g_warning ("Error: did not find Claws Action to execute");
884 gboolean toolbar_check_action_btns(ToolbarType type)
886 GSList *temp, *curr, *list = toolbar_config[type].item_list;
887 gboolean modified = FALSE;
890 while (curr != NULL) {
891 ToolbarItem *toolbar_item = (ToolbarItem *) curr->data;
895 if (toolbar_item->index != A_CLAWS_ACTIONS)
898 if (prefs_actions_find_by_name(toolbar_item->text) == -1) {
899 list = g_slist_delete_link(list, temp);
900 g_free(toolbar_item->file);
901 g_free(toolbar_item->text);
902 g_free(toolbar_item);
910 #define CLAWS_SET_TOOL_ITEM_TIP(widget,tip) { \
911 gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), tip); \
914 #define CLAWS_SET_ARROW_TIP(widget,tip) { \
915 gtk_menu_tool_button_set_arrow_tooltip_text(GTK_MENU_TOOL_BUTTON(widget), tip); \
918 static void activate_compose_button (Toolbar *toolbar,
920 ComposeButtonType type)
922 if ((!toolbar->compose_mail_btn))
925 if (type == COMPOSEBUTTON_NEWS) {
926 gtk_tool_button_set_icon_widget(
927 GTK_TOOL_BUTTON(toolbar->compose_mail_btn),
928 toolbar->compose_news_icon);
930 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(toolbar->compose_mail_btn), _("Compose News message"));
932 gtk_widget_show(toolbar->compose_news_icon);
934 gtk_tool_button_set_icon_widget(
935 GTK_TOOL_BUTTON(toolbar->compose_mail_btn),
936 toolbar->compose_mail_icon);
938 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(toolbar->compose_mail_btn), _("Compose Email"));
940 gtk_widget_show(toolbar->compose_mail_icon);
942 toolbar->compose_btn_type = type;
945 void toolbar_set_compose_button(Toolbar *toolbar,
946 ComposeButtonType compose_btn_type)
948 if (toolbar->compose_btn_type != compose_btn_type)
949 activate_compose_button(toolbar,
950 prefs_common.toolbar_style,
954 static void activate_learn_button (Toolbar *toolbar,
956 LearnButtonType type)
958 if ((!toolbar->learn_spam_btn))
961 if (type == LEARN_SPAM) {
962 gtk_tool_button_set_icon_widget(
963 GTK_TOOL_BUTTON(toolbar->learn_spam_btn),
964 toolbar->learn_spam_icon);
965 gtk_tool_button_set_label(
966 GTK_TOOL_BUTTON(toolbar->learn_spam_btn),
969 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(toolbar->learn_spam_btn), _("Learn spam"));
971 gtk_widget_show(toolbar->learn_spam_icon);
973 gtk_tool_button_set_icon_widget(
974 GTK_TOOL_BUTTON(toolbar->learn_spam_btn),
975 toolbar->learn_ham_icon);
976 gtk_tool_button_set_label(
977 GTK_TOOL_BUTTON(toolbar->learn_spam_btn),
980 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(toolbar->learn_spam_btn), _("Learn ham"));
982 gtk_widget_show(toolbar->learn_ham_icon);
984 toolbar->learn_btn_type = type;
987 void toolbar_set_learn_button(Toolbar *toolbar,
988 LearnButtonType learn_btn_type)
990 if (toolbar->learn_btn_type != learn_btn_type)
991 activate_learn_button(toolbar,
992 prefs_common.toolbar_style,
996 void toolbar_toggle(guint action, gpointer data)
998 MainWindow *mainwin = (MainWindow*)data;
1002 cm_return_if_fail(mainwin != NULL);
1004 toolbar_style(TOOLBAR_MAIN, action, mainwin);
1006 list = compose_get_compose_list();
1007 for (cur = list; cur != NULL; cur = cur->next) {
1008 toolbar_style(TOOLBAR_COMPOSE, action, cur->data);
1010 list = messageview_get_msgview_list();
1011 for (cur = list; cur != NULL; cur = cur->next) {
1012 toolbar_style(TOOLBAR_MSGVIEW, action, cur->data);
1017 void toolbar_set_style(GtkWidget *toolbar_wid, GtkWidget *handlebox_wid, guint action)
1019 switch ((ToolbarStyle)action) {
1021 gtk_widget_hide(handlebox_wid);
1024 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
1028 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
1032 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
1035 case TOOLBAR_BOTH_HORIZ:
1036 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
1037 GTK_TOOLBAR_BOTH_HORIZ);
1043 prefs_common.toolbar_style = (ToolbarStyle)action;
1044 gtk_widget_set_size_request(handlebox_wid, 1, -1);
1046 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
1047 gtk_widget_show(handlebox_wid);
1048 gtk_widget_queue_resize(handlebox_wid);
1052 * Change the style of toolbar
1054 static void toolbar_style(ToolbarType type, guint action, gpointer data)
1056 GtkWidget *handlebox_wid;
1057 GtkWidget *toolbar_wid;
1058 MainWindow *mainwin = (MainWindow*)data;
1059 Compose *compose = (Compose*)data;
1060 MessageView *msgview = (MessageView*)data;
1062 cm_return_if_fail(data != NULL);
1066 handlebox_wid = mainwin->handlebox;
1067 toolbar_wid = mainwin->toolbar->toolbar;
1069 case TOOLBAR_COMPOSE:
1070 handlebox_wid = compose->handlebox;
1071 toolbar_wid = compose->toolbar->toolbar;
1073 case TOOLBAR_MSGVIEW:
1074 handlebox_wid = msgview->handlebox;
1075 toolbar_wid = msgview->toolbar->toolbar;
1081 toolbar_set_style(toolbar_wid, handlebox_wid, action);
1084 /* Toolbar handling */
1085 static void toolbar_inc_cb(GtkWidget *widget,
1088 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1089 MainWindow *mainwin;
1091 cm_return_if_fail(toolbar_item != NULL);
1093 switch (toolbar_item->type) {
1095 mainwin = (MainWindow*)toolbar_item->parent;
1096 inc_mail_cb(mainwin, 0, NULL);
1103 static void toolbar_inc_all_cb(GtkWidget *widget,
1106 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1107 MainWindow *mainwin;
1109 cm_return_if_fail(toolbar_item != NULL);
1111 switch (toolbar_item->type) {
1113 mainwin = (MainWindow*)toolbar_item->parent;
1114 inc_all_account_mail_cb(mainwin, 0, NULL);
1121 static void toolbar_send_queued_cb(GtkWidget *widget,gpointer data)
1123 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1124 MainWindow *mainwin;
1126 cm_return_if_fail(toolbar_item != NULL);
1128 switch (toolbar_item->type) {
1130 mainwin = (MainWindow*)toolbar_item->parent;
1131 send_queue_cb(mainwin, 0, NULL);
1138 static void toolbar_exec_cb(GtkWidget *widget,
1141 MainWindow *mainwin = get_mainwin(data);
1143 cm_return_if_fail(mainwin != NULL);
1144 summary_execute(mainwin->summaryview);
1148 * Delete current/selected(s) message(s)
1150 static void toolbar_trash_cb(GtkWidget *widget, gpointer data)
1152 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1153 MainWindow *mainwin;
1155 cm_return_if_fail(toolbar_item != NULL);
1156 cm_return_if_fail(toolbar_item->parent);
1158 switch (toolbar_item->type) {
1159 case TOOLBAR_MSGVIEW:
1160 messageview_delete((MessageView *)toolbar_item->parent);
1163 mainwin = (MainWindow *)toolbar_item->parent;
1164 summary_delete_trash(mainwin->summaryview);
1167 debug_print("toolbar event not supported\n");
1173 * Delete current/selected(s) message(s)
1175 static void toolbar_delete_cb(GtkWidget *widget, gpointer data)
1177 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1178 MainWindow *mainwin;
1180 cm_return_if_fail(toolbar_item != NULL);
1181 cm_return_if_fail(toolbar_item->parent);
1183 switch (toolbar_item->type) {
1184 case TOOLBAR_MSGVIEW:
1185 messageview_delete((MessageView *)toolbar_item->parent);
1188 mainwin = (MainWindow *)toolbar_item->parent;
1189 summary_delete(mainwin->summaryview);
1192 debug_print("toolbar event not supported\n");
1199 * Compose new message
1201 static void toolbar_compose_cb(GtkWidget *widget, gpointer data)
1203 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1204 MainWindow *mainwin;
1205 MessageView *msgview;
1207 cm_return_if_fail(toolbar_item != NULL);
1209 switch (toolbar_item->type) {
1211 mainwin = (MainWindow*)toolbar_item->parent;
1212 if (mainwin->toolbar->compose_btn_type == COMPOSEBUTTON_NEWS)
1213 compose_news_cb(mainwin, 0, NULL);
1215 compose_mail_cb(mainwin, 0, NULL);
1217 case TOOLBAR_MSGVIEW:
1218 msgview = (MessageView*)toolbar_item->parent;
1219 compose_new_with_folderitem(NULL,
1220 msgview->msginfo->folder, NULL);
1223 debug_print("toolbar event not supported\n");
1227 static void toolbar_learn(gpointer data, guint as_spam)
1229 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1230 MainWindow *mainwin;
1231 MessageView *msgview;
1233 cm_return_if_fail(toolbar_item != NULL);
1235 switch (toolbar_item->type) {
1237 mainwin = (MainWindow*)toolbar_item->parent;
1239 mainwindow_learn(mainwin, TRUE);
1241 mainwindow_learn(mainwin, FALSE);
1243 case TOOLBAR_MSGVIEW:
1244 msgview = (MessageView*)toolbar_item->parent;
1246 messageview_learn(msgview, TRUE);
1248 messageview_learn(msgview, FALSE);
1251 debug_print("toolbar event not supported\n");
1255 static void toolbar_learn_cb(GtkWidget *widget, gpointer data)
1257 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1258 MainWindow *mainwin;
1259 MessageView *msgview;
1261 cm_return_if_fail(toolbar_item != NULL);
1263 switch (toolbar_item->type) {
1265 mainwin = (MainWindow*)toolbar_item->parent;
1266 if (mainwin->toolbar->learn_btn_type == LEARN_SPAM)
1267 mainwindow_learn(mainwin, TRUE);
1269 mainwindow_learn(mainwin, FALSE);
1271 case TOOLBAR_MSGVIEW:
1272 msgview = (MessageView*)toolbar_item->parent;
1273 if (msgview->toolbar->learn_btn_type == LEARN_SPAM)
1274 messageview_learn(msgview, TRUE);
1276 messageview_learn(msgview, FALSE);
1279 debug_print("toolbar event not supported\n");
1287 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
1289 toolbar_reply(data, (prefs_common.reply_with_quote ?
1290 COMPOSE_REPLY_WITH_QUOTE : COMPOSE_REPLY_WITHOUT_QUOTE));
1295 * Reply message to Sender and All recipients
1297 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
1300 (prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
1301 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE));
1306 * Reply to Mailing List
1308 static void toolbar_reply_to_list_cb(GtkWidget *widget, gpointer data)
1311 (prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_LIST_WITH_QUOTE
1312 : COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE));
1317 * Reply to sender of message
1319 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
1322 (prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
1323 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE));
1329 static void toolbar_addrbook_cb(GtkWidget *widget, gpointer data)
1331 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1334 cm_return_if_fail(toolbar_item != NULL);
1336 switch (toolbar_item->type) {
1338 case TOOLBAR_MSGVIEW:
1341 case TOOLBAR_COMPOSE:
1342 compose = (Compose *)toolbar_item->parent;
1347 #ifndef USE_ALT_ADDRBOOK
1348 addressbook_open(compose);
1350 GError* error = NULL;
1351 addressbook_connect_signals(compose);
1352 addressbook_dbus_open(TRUE, &error);
1354 g_warning("%s", error->message);
1355 g_error_free(error);
1362 * Forward current/selected(s) message(s)
1364 static void toolbar_forward_cb(GtkWidget *widget, gpointer data)
1366 toolbar_reply(data, (COMPOSE_FORWARD));
1370 * Goto Prev Unread Message
1372 static void toolbar_prev_unread_cb(GtkWidget *widget, gpointer data)
1374 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1375 MainWindow *mainwin;
1376 MessageView *msgview;
1378 cm_return_if_fail(toolbar_item != NULL);
1380 switch (toolbar_item->type) {
1382 mainwin = (MainWindow*)toolbar_item->parent;
1383 summary_select_prev_unread(mainwin->summaryview);
1386 case TOOLBAR_MSGVIEW:
1387 msgview = (MessageView*)toolbar_item->parent;
1388 msgview->updating = TRUE;
1389 summary_select_prev_unread(msgview->mainwin->summaryview);
1390 msgview->updating = FALSE;
1392 if (msgview->deferred_destroy) {
1393 debug_print("messageview got away!\n");
1394 messageview_destroy(msgview);
1398 /* Now we need to update the messageview window */
1399 if (msgview->mainwin->summaryview->selected) {
1400 #ifndef GENERIC_UMPC
1401 MsgInfo * msginfo = summary_get_selected_msg(msgview->mainwin->summaryview);
1404 messageview_show(msgview, msginfo,
1405 msgview->all_headers);
1408 gtk_widget_destroy(msgview->window);
1412 debug_print("toolbar event not supported\n");
1417 * Goto Next Unread Message
1419 static void toolbar_next_unread_cb(GtkWidget *widget, gpointer data)
1421 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1422 MainWindow *mainwin;
1423 MessageView *msgview;
1425 cm_return_if_fail(toolbar_item != NULL);
1427 switch (toolbar_item->type) {
1429 mainwin = (MainWindow*)toolbar_item->parent;
1430 summary_select_next_unread(mainwin->summaryview);
1433 case TOOLBAR_MSGVIEW:
1434 msgview = (MessageView*)toolbar_item->parent;
1435 msgview->updating = TRUE;
1436 summary_select_next_unread(msgview->mainwin->summaryview);
1437 msgview->updating = FALSE;
1439 if (msgview->deferred_destroy) {
1440 debug_print("messageview got away!\n");
1441 messageview_destroy(msgview);
1445 /* Now we need to update the messageview window */
1446 if (msgview->mainwin->summaryview->selected) {
1447 #ifndef GENERIC_UMPC
1448 MsgInfo * msginfo = summary_get_selected_msg(msgview->mainwin->summaryview);
1451 messageview_show(msgview, msginfo,
1452 msgview->all_headers);
1455 gtk_widget_destroy(msgview->window);
1459 debug_print("toolbar event not supported\n");
1463 static void toolbar_ignore_thread_cb(GtkWidget *widget, gpointer data)
1465 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1466 MainWindow *mainwin;
1468 cm_return_if_fail(toolbar_item != NULL);
1470 switch (toolbar_item->type) {
1472 mainwin = (MainWindow *) toolbar_item->parent;
1473 summary_toggle_ignore_thread(mainwin->summaryview);
1475 case TOOLBAR_MSGVIEW:
1476 /* TODO: see toolbar_next_unread_cb() if you need
1477 * this in the message view */
1480 debug_print("toolbar event not supported\n");
1485 static void toolbar_watch_thread_cb(GtkWidget *widget, gpointer data)
1487 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1488 MainWindow *mainwin;
1490 cm_return_if_fail(toolbar_item != NULL);
1492 switch (toolbar_item->type) {
1494 mainwin = (MainWindow *) toolbar_item->parent;
1495 summary_toggle_watch_thread(mainwin->summaryview);
1497 case TOOLBAR_MSGVIEW:
1498 /* TODO: see toolbar_next_unread_cb() if you need
1499 * this in the message view */
1502 debug_print("toolbar event not supported\n");
1507 static void toolbar_mark_cb(GtkWidget *widget, gpointer data)
1509 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1510 MainWindow *mainwin;
1512 cm_return_if_fail(toolbar_item != NULL);
1514 switch (toolbar_item->type) {
1516 mainwin = (MainWindow *) toolbar_item->parent;
1517 summary_mark(mainwin->summaryview);
1519 case TOOLBAR_MSGVIEW:
1520 /* TODO: see toolbar_next_unread_cb() if you need
1521 * this in the message view */
1524 debug_print("toolbar event not supported\n");
1529 static void toolbar_unmark_cb(GtkWidget *widget, gpointer data)
1531 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1532 MainWindow *mainwin;
1534 cm_return_if_fail(toolbar_item != NULL);
1536 switch (toolbar_item->type) {
1538 mainwin = (MainWindow *) toolbar_item->parent;
1539 summary_unmark(mainwin->summaryview);
1541 case TOOLBAR_MSGVIEW:
1542 /* TODO: see toolbar_next_unread_cb() if you need
1543 * this in the message view */
1546 debug_print("toolbar event not supported\n");
1551 static void toolbar_lock_cb(GtkWidget *widget, gpointer data)
1553 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1554 MainWindow *mainwin;
1556 cm_return_if_fail(toolbar_item != NULL);
1558 switch (toolbar_item->type) {
1560 mainwin = (MainWindow *) toolbar_item->parent;
1561 summary_msgs_lock(mainwin->summaryview);
1563 case TOOLBAR_MSGVIEW:
1564 /* TODO: see toolbar_next_unread_cb() if you need
1565 * this in the message view */
1568 debug_print("toolbar event not supported\n");
1573 static void toolbar_unlock_cb(GtkWidget *widget, gpointer data)
1575 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1576 MainWindow *mainwin;
1578 cm_return_if_fail(toolbar_item != NULL);
1580 switch (toolbar_item->type) {
1582 mainwin = (MainWindow *) toolbar_item->parent;
1583 summary_msgs_unlock(mainwin->summaryview);
1585 case TOOLBAR_MSGVIEW:
1586 /* TODO: see toolbar_next_unread_cb() if you need
1587 * this in the message view */
1590 debug_print("toolbar event not supported\n");
1595 static void toolbar_all_read_cb(GtkWidget *widget, gpointer data)
1597 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1598 MainWindow *mainwin;
1600 cm_return_if_fail(toolbar_item != NULL);
1602 switch (toolbar_item->type) {
1604 mainwin = (MainWindow *) toolbar_item->parent;
1605 summary_mark_all_read(mainwin->summaryview, TRUE);
1607 case TOOLBAR_MSGVIEW:
1608 /* TODO: see toolbar_next_unread_cb() if you need
1609 * this in the message view */
1612 debug_print("toolbar event not supported\n");
1617 static void toolbar_all_unread_cb(GtkWidget *widget, gpointer data)
1619 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1620 MainWindow *mainwin;
1622 cm_return_if_fail(toolbar_item != NULL);
1624 switch (toolbar_item->type) {
1626 mainwin = (MainWindow *) toolbar_item->parent;
1627 summary_mark_all_unread(mainwin->summaryview, TRUE);
1629 case TOOLBAR_MSGVIEW:
1630 /* TODO: see toolbar_next_unread_cb() if you need
1631 * this in the message view */
1634 debug_print("toolbar event not supported\n");
1639 static void toolbar_read_cb(GtkWidget *widget, gpointer data)
1641 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1642 MainWindow *mainwin;
1644 cm_return_if_fail(toolbar_item != NULL);
1646 switch (toolbar_item->type) {
1648 mainwin = (MainWindow *) toolbar_item->parent;
1649 summary_mark_as_read(mainwin->summaryview);
1651 case TOOLBAR_MSGVIEW:
1652 /* TODO: see toolbar_next_unread_cb() if you need
1653 * this in the message view */
1656 debug_print("toolbar event not supported\n");
1661 static void toolbar_unread_cb(GtkWidget *widget, gpointer data)
1663 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1664 MainWindow *mainwin;
1666 cm_return_if_fail(toolbar_item != NULL);
1668 switch (toolbar_item->type) {
1670 mainwin = (MainWindow *) toolbar_item->parent;
1671 summary_mark_as_unread(mainwin->summaryview);
1673 case TOOLBAR_MSGVIEW:
1674 /* TODO: see toolbar_next_unread_cb() if you need
1675 * this in the message view */
1678 debug_print("toolbar event not supported\n");
1683 static void toolbar_cancel_inc_cb(GtkWidget *widget, gpointer data)
1685 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1687 cm_return_if_fail(toolbar_item != NULL);
1692 static void toolbar_cancel_send_cb(GtkWidget *widget, gpointer data)
1694 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1696 cm_return_if_fail(toolbar_item != NULL);
1700 static void toolbar_cancel_all_cb(GtkWidget *widget, gpointer data)
1702 toolbar_cancel_inc_cb(widget, data);
1703 toolbar_cancel_send_cb(widget, data);
1706 static void toolbar_print_cb(GtkWidget *widget, gpointer data)
1708 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1709 MainWindow *mainwin;
1711 cm_return_if_fail(toolbar_item != NULL);
1713 switch (toolbar_item->type) {
1715 mainwin = (MainWindow *) toolbar_item->parent;
1716 summary_print(mainwin->summaryview);
1718 case TOOLBAR_MSGVIEW:
1719 /* TODO: see toolbar_next_unread_cb() if you need
1720 * this in the message view */
1723 debug_print("toolbar event not supported\n");
1728 static void toolbar_send_cb(GtkWidget *widget, gpointer data)
1730 compose_toolbar_cb(A_SEND, data);
1733 static void toolbar_send_later_cb(GtkWidget *widget, gpointer data)
1735 compose_toolbar_cb(A_SEND_LATER, data);
1738 static void toolbar_draft_cb(GtkWidget *widget, gpointer data)
1740 compose_toolbar_cb(A_DRAFT, data);
1743 static void toolbar_close_cb(GtkWidget *widget, gpointer data)
1745 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1746 MainWindow *mainwin;
1747 MessageView *messageview;
1750 cm_return_if_fail(toolbar_item != NULL);
1752 switch (toolbar_item->type) {
1754 mainwin = (MainWindow *) toolbar_item->parent;
1755 app_will_exit(NULL, mainwin);
1757 case TOOLBAR_MSGVIEW:
1758 messageview = (MessageView *)toolbar_item->parent;
1759 messageview_destroy(messageview);
1761 case TOOLBAR_COMPOSE:
1762 compose = (Compose *)toolbar_item->parent;
1763 compose_close_toolbar(compose);
1768 static void toolbar_preferences_cb(GtkWidget *widget, gpointer data)
1773 static void toolbar_open_mail_cb(GtkWidget *widget, gpointer data)
1775 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1776 MainWindow *mainwin;
1778 cm_return_if_fail(toolbar_item != NULL);
1780 switch (toolbar_item->type) {
1782 mainwin = (MainWindow *) toolbar_item->parent;
1783 summary_open_row(NULL, mainwin->summaryview);
1785 case TOOLBAR_MSGVIEW:
1786 debug_print("toolbar event not supported\n");
1788 case TOOLBAR_COMPOSE:
1789 debug_print("toolbar event not supported\n");
1794 static void toolbar_insert_cb(GtkWidget *widget, gpointer data)
1796 compose_toolbar_cb(A_INSERT, data);
1799 static void toolbar_attach_cb(GtkWidget *widget, gpointer data)
1801 compose_toolbar_cb(A_ATTACH, data);
1804 static void toolbar_sig_cb(GtkWidget *widget, gpointer data)
1806 compose_toolbar_cb(A_SIG, data);
1809 static void toolbar_replace_sig_cb(GtkWidget *widget, gpointer data)
1811 compose_toolbar_cb(A_REP_SIG, data);
1814 static void toolbar_ext_editor_cb(GtkWidget *widget, gpointer data)
1816 compose_toolbar_cb(A_EXTEDITOR, data);
1819 static void toolbar_linewrap_current_cb(GtkWidget *widget, gpointer data)
1821 compose_toolbar_cb(A_LINEWRAP_CURRENT, data);
1824 static void toolbar_linewrap_all_cb(GtkWidget *widget, gpointer data)
1826 compose_toolbar_cb(A_LINEWRAP_ALL, data);
1830 static void toolbar_check_spelling_cb(GtkWidget *widget, gpointer data)
1832 compose_toolbar_cb(A_CHECK_SPELLING, data);
1836 * Execute actions from toolbar
1838 static void toolbar_actions_execute_cb(GtkWidget *widget, gpointer data)
1840 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1841 GSList *action_list;
1842 MainWindow *mainwin;
1844 MessageView *msgview;
1845 gpointer parent = toolbar_item->parent;
1847 cm_return_if_fail(toolbar_item != NULL);
1849 switch (toolbar_item->type) {
1851 mainwin = (MainWindow*)parent;
1852 action_list = mainwin->toolbar->action_list;
1854 case TOOLBAR_COMPOSE:
1855 compose = (Compose*)parent;
1856 action_list = compose->toolbar->action_list;
1858 case TOOLBAR_MSGVIEW:
1859 msgview = (MessageView*)parent;
1860 action_list = msgview->toolbar->action_list;
1863 debug_print("toolbar event not supported\n");
1866 toolbar_action_execute(widget, action_list, parent, toolbar_item->type);
1869 static void toolbar_plugins_execute_cb(GtkWidget *widget, gpointer data)
1871 ToolbarItem *toolbar_item = data;
1872 prefs_toolbar_execute_plugin_item(toolbar_item->parent, toolbar_item->type, toolbar_item->text);
1875 static MainWindow *get_mainwin(gpointer data)
1877 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1878 MainWindow *mainwin = NULL;
1879 MessageView *msgview;
1881 cm_return_val_if_fail(toolbar_item != NULL, NULL);
1883 switch(toolbar_item->type) {
1885 mainwin = (MainWindow*)toolbar_item->parent;
1887 case TOOLBAR_MSGVIEW:
1888 msgview = (MessageView*)toolbar_item->parent;
1889 mainwin = (MainWindow*)msgview->mainwin;
1898 static void toolbar_go_folders_cb(GtkWidget *widget, gpointer data)
1900 ToolbarItem *toolbar_item = (ToolbarItem*)data;
1901 MainWindow *mainwin = NULL;
1902 switch(toolbar_item->type) {
1904 mainwin = (MainWindow*)toolbar_item->parent;
1907 g_warning("wrong toolbar type");
1911 if (!mainwin->in_folder) {
1912 FolderItem *item = folderview_get_selected_item(mainwin->folderview);
1914 folderview_select(mainwin->folderview, item);
1917 folderview_grab_focus(mainwin->folderview);
1918 mainwindow_exit_folder(mainwin);
1922 static void toolbar_buttons_cb(GtkWidget *widget,
1929 void (*func)(GtkWidget *widget, gpointer data);
1931 { A_RECEIVE_ALL, toolbar_inc_all_cb },
1932 { A_RECEIVE_CUR, toolbar_inc_cb },
1933 { A_SEND_QUEUED, toolbar_send_queued_cb },
1934 { A_COMPOSE_EMAIL, toolbar_compose_cb },
1935 { A_COMPOSE_NEWS, toolbar_compose_cb },
1936 { A_REPLY_MESSAGE, toolbar_reply_cb },
1937 { A_REPLY_SENDER, toolbar_reply_to_sender_cb },
1938 { A_REPLY_ALL, toolbar_reply_to_all_cb },
1939 { A_REPLY_ML, toolbar_reply_to_list_cb },
1940 { A_FORWARD, toolbar_forward_cb },
1941 { A_TRASH, toolbar_trash_cb },
1942 { A_DELETE_REAL, toolbar_delete_cb },
1943 { A_EXECUTE, toolbar_exec_cb },
1944 { A_GOTO_PREV, toolbar_prev_unread_cb },
1945 { A_GOTO_NEXT, toolbar_next_unread_cb },
1946 { A_IGNORE_THREAD, toolbar_ignore_thread_cb },
1947 { A_WATCH_THREAD, toolbar_watch_thread_cb },
1948 { A_MARK, toolbar_mark_cb },
1949 { A_UNMARK, toolbar_unmark_cb },
1950 { A_LOCK, toolbar_lock_cb },
1951 { A_UNLOCK, toolbar_unlock_cb },
1952 { A_ALL_READ, toolbar_all_read_cb },
1953 { A_ALL_UNREAD, toolbar_all_unread_cb },
1954 { A_READ, toolbar_read_cb },
1955 { A_UNREAD, toolbar_unread_cb },
1956 { A_PRINT, toolbar_print_cb },
1957 { A_LEARN_SPAM, toolbar_learn_cb },
1958 { A_GO_FOLDERS, toolbar_go_folders_cb },
1960 { A_SEND, toolbar_send_cb },
1961 { A_SEND_LATER, toolbar_send_later_cb },
1962 { A_DRAFT, toolbar_draft_cb },
1963 { A_OPEN_MAIL, toolbar_open_mail_cb },
1964 { A_CLOSE, toolbar_close_cb },
1965 { A_PREFERENCES, toolbar_preferences_cb },
1966 { A_INSERT, toolbar_insert_cb },
1967 { A_ATTACH, toolbar_attach_cb },
1968 { A_SIG, toolbar_sig_cb },
1969 { A_REP_SIG, toolbar_replace_sig_cb },
1970 { A_EXTEDITOR, toolbar_ext_editor_cb },
1971 { A_LINEWRAP_CURRENT, toolbar_linewrap_current_cb },
1972 { A_LINEWRAP_ALL, toolbar_linewrap_all_cb },
1973 { A_ADDRBOOK, toolbar_addrbook_cb },
1975 { A_CHECK_SPELLING, toolbar_check_spelling_cb },
1977 { A_CLAWS_ACTIONS, toolbar_actions_execute_cb },
1978 { A_CANCEL_INC, toolbar_cancel_inc_cb },
1979 { A_CANCEL_SEND, toolbar_cancel_send_cb },
1980 { A_CANCEL_ALL, toolbar_cancel_all_cb },
1981 { A_CLAWS_PLUGINS, toolbar_plugins_execute_cb },
1984 num_items = sizeof(callbacks)/sizeof(callbacks[0]);
1986 for (i = 0; i < num_items; i++) {
1987 if (callbacks[i].index == item->index) {
1988 callbacks[i].func(widget, item);
1993 #ifndef GENERIC_UMPC
1994 #define TOOLBAR_ITEM(item,icon,text,tooltip) { \
1995 item = GTK_WIDGET(gtk_tool_button_new(icon, text)); \
1996 gtkut_widget_set_can_focus(gtk_bin_get_child(GTK_BIN(item)), FALSE); \
1997 gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE); \
1998 gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE); \
1999 g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item); \
2000 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1); \
2001 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(item), \
2005 #define TOOLBAR_MENUITEM(item,icon,text,tooltip,menutip) { \
2006 GtkWidget *child = NULL, *btn = NULL, *arr = NULL; \
2007 GList *gchild = NULL; \
2008 item = GTK_WIDGET(gtk_menu_tool_button_new(icon, text)); \
2009 gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE); \
2010 gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE); \
2011 g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item); \
2012 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1); \
2013 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(item), \
2015 CLAWS_SET_ARROW_TIP(GTK_MENU_TOOL_BUTTON(item), menutip); \
2016 child = gtk_bin_get_child(GTK_BIN(item)); \
2017 gchild = gtk_container_get_children( \
2018 GTK_CONTAINER(child)); \
2019 btn = (GtkWidget *)gchild->data; \
2020 gtkut_widget_set_can_focus(btn, FALSE); \
2021 arr = (GtkWidget *)(gchild->next?gchild->next->data:NULL); \
2022 gtkut_widget_set_can_focus(arr, FALSE); \
2023 g_list_free(gchild); \
2024 gchild = gtk_container_get_children(GTK_CONTAINER(arr)); \
2025 gtk_widget_set_size_request(GTK_WIDGET(gchild->data), 9, -1); \
2026 g_list_free(gchild); \
2029 #define TOOLBAR_ITEM(item,icon,text,tooltip) { \
2030 item = GTK_WIDGET(gtk_tool_button_new(icon, text)); \
2031 gtkut_widget_set_can_focus(gtk_bin_get_child(GTK_BIN(item)), FALSE); \
2032 gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE); \
2033 gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE); \
2034 g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item); \
2035 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1); \
2038 #define TOOLBAR_MENUITEM(item,icon,text,tooltip,menutip) { \
2039 GtkWidget *child = NULL, *btn = NULL, *arr = NULL; \
2040 GList *gchild = NULL; \
2041 item = GTK_WIDGET(gtk_menu_tool_button_new(icon, text)); \
2042 gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE); \
2043 gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE); \
2044 g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item); \
2045 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1); \
2046 child = gtk_bin_get_child(GTK_BIN(item)); \
2047 gchild = gtk_container_get_children( \
2048 GTK_CONTAINER(child)); \
2049 btn = (GtkWidget *)gchild->data; \
2050 gtkut_widget_set_can_focus(btn, FALSE); \
2051 arr = (GtkWidget *)(gchild->next?gchild->next->data:NULL); \
2052 gtkut_widget_set_can_focus(arr, FALSE); \
2053 g_list_free(gchild); \
2054 gchild = gtk_container_get_children(GTK_CONTAINER(arr)); \
2055 gtk_widget_set_size_request(GTK_WIDGET(gchild->data), 9, -1); \
2056 g_list_free(gchild); \
2060 #define ADD_MENU_ITEM(name,cb,data) { \
2061 item = gtk_menu_item_new_with_mnemonic(name); \
2062 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); \
2063 g_signal_connect(G_OBJECT(item), "activate", \
2066 g_object_set_data(G_OBJECT(item), "int-value", GINT_TO_POINTER(data)); \
2067 gtk_widget_show(item); \
2070 static void toolbar_reply_menu_cb(GtkWidget *widget, gpointer data)
2072 gpointer int_value = g_object_get_data(G_OBJECT(widget), "int-value");
2073 ToolbarItem *toolbar_item = (ToolbarItem *)data;
2075 toolbar_reply(toolbar_item, GPOINTER_TO_INT(int_value));
2078 static void toolbar_learn_menu_cb(GtkWidget *widget, gpointer data)
2080 gpointer int_value = g_object_get_data(G_OBJECT(widget), "int-value");
2081 ToolbarItem *toolbar_item = (ToolbarItem *)data;
2083 toolbar_learn(toolbar_item, GPOINTER_TO_INT(int_value));
2087 * Create a new toolbar with specified type
2088 * if a callback list is passed it will be used before the
2089 * common callback list
2091 Toolbar *toolbar_create(ToolbarType type,
2092 GtkWidget *container,
2095 ToolbarItem *toolbar_item;
2098 GtkWidget *icon_wid = NULL;
2099 GtkWidget *icon_news;
2100 GtkWidget *icon_ham;
2102 ToolbarClawsActions *action_item;
2104 GSList *toolbar_list;
2105 Toolbar *toolbar_data;
2107 toolbar_read_config_file(type);
2108 toolbar_list = toolbar_get_list(type);
2110 toolbar_data = g_new0(Toolbar, 1);
2112 toolbar = gtk_toolbar_new();
2114 gtk_orientable_set_orientation(GTK_ORIENTABLE(toolbar), GTK_ORIENTATION_HORIZONTAL);
2116 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_BOTH);
2117 gtk_toolbar_set_show_arrow(GTK_TOOLBAR(toolbar), TRUE);
2119 for (cur = toolbar_list; cur != NULL; cur = cur->next) {
2121 if (g_ascii_strcasecmp(((ToolbarItem*)cur->data)->file, TOOLBAR_TAG_SEPARATOR) == 0) {
2122 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), gtk_separator_tool_item_new(), -1);
2126 toolbar_item = g_new0(ToolbarItem, 1);
2127 toolbar_item->index = ((ToolbarItem*)cur->data)->index;
2128 toolbar_item->file = g_strdup(((ToolbarItem*)cur->data)->file);
2129 toolbar_item->text = g_strdup(((ToolbarItem*)cur->data)->text);
2130 toolbar_item->parent = data;
2131 toolbar_item->type = type;
2133 /* collect toolbar items in list to keep track */
2134 toolbar_data->item_list =
2135 g_slist_append(toolbar_data->item_list,
2137 icon_wid = stock_pixmap_widget(stock_pixmap_get_icon(toolbar_item->file));
2139 switch (toolbar_item->index) {
2142 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Go to folder list"));
2143 toolbar_data->folders_btn = item;
2146 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2147 _("Receive Mail from all Accounts"),
2148 _("Receive Mail from selected Account"));
2149 toolbar_data->getall_btn = item;
2152 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text, _("Receive Mail from current Account"));
2153 toolbar_data->get_btn = item;
2156 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Send Queued Messages"));
2157 toolbar_data->send_btn = item;
2160 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Close window"));
2161 toolbar_data->close_window_btn = item;
2164 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Open preferences"));
2165 toolbar_data->preferences_btn = item;
2168 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Open email"));
2169 toolbar_data->open_mail_btn = item;
2171 case A_COMPOSE_EMAIL:
2172 #ifndef GENERIC_UMPC
2173 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2175 _("Compose with selected Account"));
2176 toolbar_data->compose_mail_btn = item;
2177 toolbar_data->compose_mail_icon = icon_wid;
2178 g_object_ref(toolbar_data->compose_mail_icon);
2180 icon_news = stock_pixmap_widget(STOCK_PIXMAP_NEWS_COMPOSE);
2181 toolbar_data->compose_news_icon = icon_news;
2182 g_object_ref(toolbar_data->compose_news_icon);
2184 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2185 _("Compose Email"));
2186 toolbar_data->compose_mail_btn = item;
2187 toolbar_data->compose_mail_icon = icon_wid;
2189 icon_news = stock_pixmap_widget(STOCK_PIXMAP_NEWS_COMPOSE);
2190 toolbar_data->compose_news_icon = icon_news;
2194 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2197 toolbar_data->learn_spam_btn = item;
2198 toolbar_data->learn_spam_icon = icon_wid;
2199 g_object_ref(toolbar_data->learn_spam_icon);
2201 icon_ham = stock_pixmap_widget(STOCK_PIXMAP_HAM_BTN);
2202 toolbar_data->learn_ham_icon = icon_ham;
2203 g_object_ref(toolbar_data->learn_ham_icon);
2205 menu = gtk_menu_new();
2206 ADD_MENU_ITEM(_("Learn as _Spam"), toolbar_learn_menu_cb, TRUE);
2207 ADD_MENU_ITEM(_("Learn as _Ham"), toolbar_learn_menu_cb, FALSE);
2208 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->learn_spam_btn), menu);
2210 case A_REPLY_MESSAGE:
2211 #ifndef GENERIC_UMPC
2212 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2213 _("Reply to Message"),
2214 _("Reply to Message options"));
2215 toolbar_data->reply_btn = item;
2217 menu = gtk_menu_new();
2218 ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_WITH_QUOTE);
2219 ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_WITHOUT_QUOTE);
2220 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->reply_btn), menu);
2222 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2223 _("Reply to Message"));
2224 toolbar_data->reply_btn = item;
2227 case A_REPLY_SENDER:
2228 #ifndef GENERIC_UMPC
2229 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2230 _("Reply to Sender"),
2231 _("Reply to Sender options"));
2232 toolbar_data->replysender_btn = item;
2234 menu = gtk_menu_new();
2235 ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE);
2236 ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE);
2237 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->replysender_btn), menu);
2239 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2240 _("Reply to Sender"));
2241 toolbar_data->replysender_btn = item;
2245 #ifndef GENERIC_UMPC
2246 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2248 _("Reply to All options"));
2249 toolbar_data->replyall_btn = item;
2251 menu = gtk_menu_new();
2252 ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE);
2253 ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE);
2254 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->replyall_btn), menu);
2256 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2258 toolbar_data->replyall_btn = item;
2262 #ifndef GENERIC_UMPC
2263 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2264 _("Reply to Mailing-list"),
2265 _("Reply to Mailing-list options"));
2266 toolbar_data->replylist_btn = item;
2268 menu = gtk_menu_new();
2269 ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_LIST_WITH_QUOTE);
2270 ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE);
2271 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->replylist_btn), menu);
2273 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2274 _("Reply to Mailing-list"));
2275 toolbar_data->replylist_btn = item;
2279 #ifndef GENERIC_UMPC
2280 TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
2281 _("Forward Message"),
2282 _("Forward Message options"));
2283 toolbar_data->fwd_btn = item;
2285 menu = gtk_menu_new();
2286 ADD_MENU_ITEM(_("_Forward"), toolbar_reply_menu_cb, COMPOSE_FORWARD_INLINE);
2287 ADD_MENU_ITEM(_("For_ward as attachment"), toolbar_reply_menu_cb, COMPOSE_FORWARD_AS_ATTACH);
2288 ADD_MENU_ITEM(_("Redirec_t"), toolbar_reply_menu_cb, COMPOSE_REDIRECT);
2289 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->fwd_btn), menu);
2291 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2292 _("Forward Message"));
2293 toolbar_data->fwd_btn = item;
2297 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Trash Message"));
2298 toolbar_data->trash_btn = item;
2301 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Delete Message"));
2302 toolbar_data->delete_btn = item;
2305 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Execute"));
2306 toolbar_data->exec_btn = item;
2309 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Go to Previous Unread Message"));
2310 toolbar_data->prev_btn = item;
2313 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Go to Next Unread Message"));
2314 toolbar_data->next_btn = item;
2317 /* Compose Toolbar */
2319 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Send Message"));
2320 toolbar_data->send_btn = item;
2323 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Put into queue folder and send later"));
2324 toolbar_data->sendl_btn = item;
2327 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Save to draft folder"));
2328 toolbar_data->draft_btn = item;
2331 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Insert file"));
2332 toolbar_data->insert_btn = item;
2335 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Attach file"));
2336 toolbar_data->attach_btn = item;
2339 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Insert signature"));
2340 toolbar_data->sig_btn = item;
2343 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Replace signature"));
2344 toolbar_data->repsig_btn = item;
2347 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Edit with external editor"));
2348 toolbar_data->exteditor_btn = item;
2350 case A_LINEWRAP_CURRENT:
2351 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Wrap long lines of current paragraph"));
2352 toolbar_data->linewrap_current_btn = item;
2354 case A_LINEWRAP_ALL:
2355 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Wrap all long lines"));
2356 toolbar_data->linewrap_all_btn = item;
2359 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Address book"));
2360 toolbar_data->addrbook_btn = item;
2363 case A_CHECK_SPELLING:
2364 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Check spelling"));
2365 toolbar_data->spellcheck_btn = item;
2369 case A_CLAWS_ACTIONS:
2370 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,toolbar_item->text);
2371 action_item = g_new0(ToolbarClawsActions, 1);
2372 action_item->widget = item;
2373 action_item->name = g_strdup(toolbar_item->text);
2375 toolbar_data->action_list =
2376 g_slist_append(toolbar_data->action_list,
2380 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Cancel receiving"));
2381 toolbar_data->cancel_inc_btn = item;
2384 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Cancel sending"));
2385 toolbar_data->cancel_send_btn = item;
2388 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Cancel receiving/sending"));
2389 toolbar_data->cancel_all_btn = item;
2391 case A_CLAWS_PLUGINS:
2392 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text, toolbar_item->text);
2395 TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
2396 toolbar_ret_descr_from_val(toolbar_item->index));
2397 /* find and set the tool tip text */
2402 toolbar_data->toolbar = toolbar;
2404 gtk_widget_show_all(toolbar);
2406 if (type == TOOLBAR_MAIN) {
2408 MainWindow *mainwin = mainwindow_get_mainwindow();
2409 GtkWidget *progressbar = gtk_progress_bar_new();
2410 item = GTK_WIDGET(gtk_tool_item_new());
2411 gtk_container_add (GTK_CONTAINER (item), progressbar);
2412 gtk_widget_show(item);
2413 gtk_widget_set_size_request(progressbar, 84, -1);
2414 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1);
2415 mainwin->progressbar = progressbar;
2417 activate_compose_button(toolbar_data,
2418 prefs_common.toolbar_style,
2419 toolbar_data->compose_btn_type);
2421 if (type != TOOLBAR_COMPOSE)
2422 activate_learn_button(toolbar_data, prefs_common.toolbar_style,
2425 gtk_container_add(GTK_CONTAINER(container), toolbar);
2426 gtk_container_set_border_width(GTK_CONTAINER(container), 0);
2428 return toolbar_data;
2432 * Free toolbar structures
2434 void toolbar_destroy(Toolbar * toolbar) {
2436 TOOLBAR_DESTROY_ITEMS(toolbar->item_list);
2437 TOOLBAR_DESTROY_ACTIONS(toolbar->action_list);
2440 void toolbar_update(ToolbarType type, gpointer data)
2442 Toolbar *toolbar_data;
2443 GtkWidget *handlebox;
2444 MainWindow *mainwin = (MainWindow*)data;
2445 Compose *compose = (Compose*)data;
2446 MessageView *msgview = (MessageView*)data;
2448 #ifndef GENERIC_UMPC
2451 toolbar_data = mainwin->toolbar;
2452 handlebox = mainwin->handlebox;
2454 case TOOLBAR_COMPOSE:
2455 toolbar_data = compose->toolbar;
2456 handlebox = compose->handlebox;
2458 case TOOLBAR_MSGVIEW:
2459 toolbar_data = msgview->toolbar;
2460 handlebox = msgview->handlebox;
2466 gtk_container_remove(GTK_CONTAINER(handlebox),
2467 GTK_WIDGET(toolbar_data->toolbar));
2469 toolbar_init(toolbar_data);
2470 toolbar_data = toolbar_create(type, handlebox, data);
2474 toolbar_data = mainwin->toolbar;
2475 handlebox = mainwin->window;
2477 case TOOLBAR_COMPOSE:
2478 toolbar_data = compose->toolbar;
2479 handlebox = compose->window;
2481 case TOOLBAR_MSGVIEW:
2482 toolbar_data = msgview->toolbar;
2483 handlebox = msgview->window;
2488 toolbar_init(toolbar_data);
2489 toolbar_data = toolbar_create(type, handlebox, data);
2494 mainwin->toolbar = toolbar_data;
2496 case TOOLBAR_COMPOSE:
2497 compose->toolbar = toolbar_data;
2499 case TOOLBAR_MSGVIEW:
2500 msgview->toolbar = toolbar_data;
2504 toolbar_style(type, prefs_common.toolbar_style, data);
2506 if (type == TOOLBAR_MAIN) {
2507 toolbar_main_set_sensitive((MainWindow*)data);
2508 account_set_menu_only_toolbar();
2512 #define GTK_BUTTON_SET_SENSITIVE(widget,sensitive) { \
2513 gtk_widget_set_sensitive(widget, sensitive); \
2516 void toolbar_main_set_sensitive(gpointer data)
2518 SensitiveCondMask state;
2520 MainWindow *mainwin = (MainWindow*)data;
2521 Toolbar *toolbar = mainwin->toolbar;
2523 GSList *entry_list = NULL;
2525 typedef struct _Entry Entry;
2528 SensitiveCondMask cond;
2532 #define SET_WIDGET_COND(w, ...) \
2534 Entry *e = g_new0(Entry, 1); \
2536 e->cond = main_window_get_mask(__VA_ARGS__, -1); \
2537 entry_list = g_slist_append(entry_list, e); \
2540 /* match all bit flags */
2542 if (toolbar->get_btn)
2543 SET_WIDGET_COND(toolbar->get_btn,
2544 M_HAVE_ACCOUNT, M_UNLOCKED, M_HAVE_RETRIEVABLE_ACCOUNT);
2546 if (toolbar->getall_btn) {
2547 SET_WIDGET_COND(toolbar->getall_btn,
2548 M_HAVE_ACCOUNT, M_UNLOCKED, M_HAVE_ANY_RETRIEVABLE_ACCOUNT);
2550 if (toolbar->send_btn) {
2551 SET_WIDGET_COND(toolbar->send_btn,
2552 M_HAVE_QUEUED_MAILS);
2554 if (toolbar->compose_mail_btn) {
2555 SET_WIDGET_COND(toolbar->compose_mail_btn,
2558 if (toolbar->close_window_btn) {
2559 SET_WIDGET_COND(toolbar->close_window_btn,
2562 if (toolbar->open_mail_btn) {
2563 SET_WIDGET_COND(toolbar->open_mail_btn,
2564 M_TARGET_EXIST, M_SUMMARY_ISLIST);
2566 if (toolbar->reply_btn) {
2567 SET_WIDGET_COND(toolbar->reply_btn,
2568 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2570 if (toolbar->replyall_btn) {
2571 SET_WIDGET_COND(toolbar->replyall_btn,
2572 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2574 if (toolbar->replylist_btn) {
2575 SET_WIDGET_COND(toolbar->replylist_btn,
2576 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2578 if (toolbar->replysender_btn) {
2579 SET_WIDGET_COND(toolbar->replysender_btn,
2580 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2582 if (toolbar->fwd_btn) {
2583 SET_WIDGET_COND(toolbar->fwd_btn,
2584 M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
2587 if (prefs_common.next_unread_msg_dialog == NEXTUNREADMSGDIALOG_ASSUME_NO) {
2588 SET_WIDGET_COND(toolbar->next_btn, M_MSG_EXIST, M_SUMMARY_ISLIST);
2590 SET_WIDGET_COND(toolbar->next_btn, -1);
2593 if (toolbar->trash_btn)
2594 SET_WIDGET_COND(toolbar->trash_btn,
2595 M_TARGET_EXIST, M_ALLOW_DELETE, M_NOT_NEWS);
2597 if (toolbar->delete_btn)
2598 SET_WIDGET_COND(toolbar->delete_btn,
2599 M_TARGET_EXIST, M_ALLOW_DELETE);
2601 if (toolbar->exec_btn)
2602 SET_WIDGET_COND(toolbar->exec_btn,
2605 if (toolbar->learn_spam_btn)
2606 SET_WIDGET_COND(toolbar->learn_spam_btn,
2607 M_TARGET_EXIST, M_CAN_LEARN_SPAM, M_SUMMARY_ISLIST);
2609 if (toolbar->cancel_inc_btn)
2610 SET_WIDGET_COND(toolbar->cancel_inc_btn,
2613 if (toolbar->cancel_send_btn)
2614 SET_WIDGET_COND(toolbar->cancel_send_btn,
2617 for (cur = toolbar->action_list; cur != NULL; cur = cur->next) {
2618 ToolbarClawsActions *act = (ToolbarClawsActions*)cur->data;
2620 SET_WIDGET_COND(act->widget, M_TARGET_EXIST, M_UNLOCKED);
2623 state = main_window_get_current_state(mainwin);
2625 for (cur = entry_list; cur != NULL; cur = cur->next) {
2626 Entry *e = (Entry*) cur->data;
2628 if (e->widget != NULL) {
2629 sensitive = ((e->cond & state) == e->cond);
2630 GTK_BUTTON_SET_SENSITIVE(e->widget, sensitive);
2634 while (entry_list != NULL) {
2635 Entry *e = (Entry*) entry_list->data;
2638 entry_list = g_slist_remove(entry_list, e);
2641 /* match any bit flags */
2643 if (toolbar->cancel_all_btn)
2644 SET_WIDGET_COND(toolbar->cancel_all_btn,
2645 M_INC_ACTIVE, M_SEND_ACTIVE);
2647 for (cur = entry_list; cur != NULL; cur = cur->next) {
2648 Entry *e = (Entry*) cur->data;
2650 if (e->widget != NULL) {
2651 sensitive = ((e->cond & state) != 0);
2652 GTK_BUTTON_SET_SENSITIVE(e->widget, sensitive);
2656 while (entry_list != NULL) {
2657 Entry *e = (Entry*) entry_list->data;
2660 entry_list = g_slist_remove(entry_list, e);
2663 g_slist_free(entry_list);
2665 activate_compose_button(toolbar,
2666 prefs_common.toolbar_style,
2667 toolbar->compose_btn_type);
2669 #undef SET_WIDGET_COND
2672 void toolbar_comp_set_sensitive(gpointer data, gboolean sensitive)
2674 Compose *compose = (Compose*)data;
2675 GSList *items = compose->toolbar->action_list;
2677 if (compose->toolbar->send_btn)
2678 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->send_btn, sensitive);
2679 if (compose->toolbar->sendl_btn)
2680 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->sendl_btn, sensitive);
2681 if (compose->toolbar->draft_btn )
2682 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->draft_btn , sensitive);
2683 if (compose->toolbar->insert_btn )
2684 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->insert_btn , sensitive);
2685 if (compose->toolbar->attach_btn)
2686 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->attach_btn, sensitive);
2687 if (compose->toolbar->sig_btn)
2688 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->sig_btn, sensitive);
2689 if (compose->toolbar->repsig_btn)
2690 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->repsig_btn, sensitive);
2691 if (compose->toolbar->exteditor_btn)
2692 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->exteditor_btn, sensitive);
2693 if (compose->toolbar->linewrap_current_btn)
2694 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->linewrap_current_btn, sensitive);
2695 if (compose->toolbar->linewrap_all_btn)
2696 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->linewrap_all_btn, sensitive);
2697 if (compose->toolbar->addrbook_btn)
2698 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->addrbook_btn, sensitive);
2700 if (compose->toolbar->spellcheck_btn)
2701 GTK_BUTTON_SET_SENSITIVE(compose->toolbar->spellcheck_btn, sensitive);
2703 for (; items != NULL; items = g_slist_next(items)) {
2704 ToolbarClawsActions *item = (ToolbarClawsActions *)items->data;
2705 GTK_BUTTON_SET_SENSITIVE(item->widget, sensitive);
2710 * Initialize toolbar structure
2712 static void toolbar_init(Toolbar * toolbar)
2715 toolbar->toolbar = NULL;
2716 toolbar->folders_btn = NULL;
2717 toolbar->get_btn = NULL;
2718 toolbar->getall_btn = NULL;
2719 toolbar->send_btn = NULL;
2720 toolbar->compose_mail_btn = NULL;
2721 toolbar->compose_mail_icon = NULL;
2722 toolbar->compose_news_icon = NULL;
2723 toolbar->reply_btn = NULL;
2724 toolbar->replysender_btn = NULL;
2725 toolbar->replyall_btn = NULL;
2726 toolbar->replylist_btn = NULL;
2727 toolbar->fwd_btn = NULL;
2728 toolbar->trash_btn = NULL;
2729 toolbar->delete_btn = NULL;
2730 toolbar->prev_btn = NULL;
2731 toolbar->next_btn = NULL;
2732 toolbar->exec_btn = NULL;
2733 toolbar->separator = NULL;
2734 toolbar->learn_spam_btn = NULL;
2735 toolbar->learn_spam_icon = NULL;
2736 toolbar->learn_ham_icon = NULL;
2737 toolbar->cancel_inc_btn = NULL;
2738 toolbar->cancel_send_btn = NULL;
2739 toolbar->cancel_all_btn = NULL;
2741 /* compose buttons */
2742 toolbar->sendl_btn = NULL;
2743 toolbar->draft_btn = NULL;
2744 toolbar->insert_btn = NULL;
2745 toolbar->attach_btn = NULL;
2746 toolbar->sig_btn = NULL;
2747 toolbar->repsig_btn = NULL;
2748 toolbar->exteditor_btn = NULL;
2749 toolbar->linewrap_current_btn = NULL;
2750 toolbar->linewrap_all_btn = NULL;
2751 toolbar->addrbook_btn = NULL;
2753 toolbar->open_mail_btn = NULL;
2754 toolbar->close_window_btn = NULL;
2755 toolbar->preferences_btn = NULL;
2756 toolbar->action_list = NULL;
2757 toolbar->item_list = NULL;
2759 toolbar->spellcheck_btn = NULL;
2762 toolbar_destroy(toolbar);
2767 static void toolbar_reply(gpointer data, guint action)
2769 ToolbarItem *toolbar_item = (ToolbarItem*)data;
2770 MainWindow *mainwin;
2771 MessageView *msgview;
2772 GSList *msginfo_list = NULL;
2774 cm_return_if_fail(toolbar_item != NULL);
2776 switch (toolbar_item->type) {
2778 mainwin = (MainWindow*)toolbar_item->parent;
2779 msginfo_list = summary_get_selection(mainwin->summaryview);
2780 msgview = (MessageView*)mainwin->messageview;
2782 case TOOLBAR_MSGVIEW:
2783 msgview = (MessageView*)toolbar_item->parent;
2784 cm_return_if_fail(msgview != NULL);
2785 msginfo_list = g_slist_append(msginfo_list, msgview->msginfo);
2791 cm_return_if_fail(msgview != NULL);
2792 cm_return_if_fail(msginfo_list != NULL);
2793 compose_reply_from_messageview(msgview, msginfo_list, action);
2794 g_slist_free(msginfo_list);
2796 /* TODO: update reply state ion summaryview */
2800 /* exported functions */
2802 void inc_mail_cb(gpointer data, guint action, GtkWidget *widget)
2804 MainWindow *mainwin = (MainWindow*)data;
2806 inc_mail(mainwin, prefs_common.newmail_notify_manu);
2809 void inc_all_account_mail_cb(gpointer data, guint action, GtkWidget *widget)
2811 MainWindow *mainwin = (MainWindow*)data;
2813 inc_all_account_mail(mainwin, FALSE, prefs_common.newmail_notify_manu);
2816 void send_queue_cb(gpointer data, guint action, GtkWidget *widget)
2820 gboolean got_error = FALSE;
2821 gchar *errstr = NULL;
2823 if (prefs_common.work_offline)
2824 if (alertpanel(_("Offline warning"),
2825 _("You're working offline. Override?"),
2826 GTK_STOCK_NO, GTK_STOCK_YES,
2827 NULL) != G_ALERTALTERNATE)
2830 /* ask for confirmation before sending queued messages only
2831 in online mode and if there is at least one message queued
2832 in any of the folder queue
2834 if (prefs_common.confirm_send_queued_messages) {
2836 /* check if there's a queued message */
2837 for (list = folder_get_list(); !found && list != NULL; list = list->next) {
2838 Folder *folder = list->data;
2840 found = !procmsg_queue_is_empty(folder->queue);
2842 /* if necessary, ask for confirmation before sending */
2843 if (found && !prefs_common.work_offline) {
2844 if (alertpanel(_("Send queued messages"),
2845 _("Send all queued messages?"),
2846 GTK_STOCK_CANCEL, _("_Send"),
2847 NULL) != G_ALERTALTERNATE)
2852 for (list = folder_get_list(); list != NULL; list = list->next) {
2853 Folder *folder = list->data;
2855 if (folder->queue) {
2856 if (procmsg_send_queue(folder->queue,
2857 prefs_common.savemsg,
2864 alertpanel_error_log(_("Some errors occurred while "
2865 "sending queued messages."));
2867 alertpanel_error_log(_("Some errors occurred "
2868 "while sending queued messages:\n%s"), errstr);
2874 void compose_mail_cb(gpointer data, guint action, GtkWidget *widget)
2876 MainWindow *mainwin = (MainWindow*)data;
2877 PrefsAccount *ac = NULL;
2878 FolderItem *item = mainwin->summaryview->folder_item;
2883 ac = account_find_from_item(item);
2884 if (ac && ac->protocol != A_NNTP && ac->protocol != A_IMAP4) {
2885 compose_new_with_folderitem(ac, item, NULL); /* CLAWS */
2891 * CLAWS - use current account
2893 if (cur_account && (cur_account->protocol != A_NNTP)) {
2894 compose_new_with_folderitem(cur_account, item, NULL);
2899 * CLAWS - just get the first one
2901 list = account_get_list();
2902 for (cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2903 ac = (PrefsAccount *) cur->data;
2904 if (ac->protocol != A_NNTP) {
2905 compose_new_with_folderitem(ac, item, NULL);
2911 void compose_news_cb(gpointer data, guint action, GtkWidget *widget)
2913 MainWindow *mainwin = (MainWindow*)data;
2914 PrefsAccount * ac = NULL;
2918 if (mainwin->summaryview->folder_item) {
2919 ac = mainwin->summaryview->folder_item->folder->account;
2920 if (ac && ac->protocol == A_NNTP) {
2921 compose_new_with_folderitem(ac,
2922 mainwin->summaryview->folder_item, NULL);
2927 list = account_get_list();
2928 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2929 ac = (PrefsAccount *) cur->data;
2930 if (ac->protocol == A_NNTP) {
2931 compose_new_with_folderitem(ac,
2932 mainwin->summaryview->folder_item, NULL);