2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2001 Hiroyuki Yamamoto
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 2 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, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 * General functions for accessing address book files.
44 #include "stock_pixmap.h"
45 #include "mainwindow.h"
46 #include "messageview.h"
47 #include "prefs_common.h"
49 #include "prefs_actions.h"
50 #include "manage_window.h"
53 #include "prefs_toolbar.h"
54 #include "alertpanel.h"
57 #define TOOLBAR_TAG_INDEX "toolbar"
58 #define TOOLBAR_TAG_ITEM "item"
59 #define TOOLBAR_TAG_SEPARATOR SEPARATOR
61 #define TOOLBAR_ICON_FILE "file"
62 #define TOOLBAR_ICON_TEXT "text"
63 #define TOOLBAR_ICON_ACTION "action"
65 gboolean toolbar_is_duplicate (gint action,
67 static void toolbar_parse_item (XMLFile *file,
70 static gint toolbar_ret_val_from_text (const gchar *text);
71 static gchar *toolbar_ret_text_from_val (gint val);
73 static void toolbar_set_default_main (void);
74 static void toolbar_set_default_compose (void);
75 static void toolbar_set_default_msgview (void);
83 * Text Database linked to enumarated values in toolbar.h
85 static struct ToolbarText toolbar_text [] = {
87 { "A_RECEIVE_ALL", N_("Receive Mail on all Accounts") },
88 { "A_RECEIVE_CUR", N_("Receive Mail on current Account") },
89 { "A_SEND_QUEUED", N_("Send Queued Message(s)") },
90 { "A_COMPOSE_EMAIL", N_("Compose Email") },
91 { "A_COMPOSE_NEWS", N_("Compose News") },
92 { "A_REPLY_MESSAGE", N_("Reply to Message") },
93 { "A_REPLY_SENDER", N_("Reply to Sender") },
94 { "A_REPLY_ALL", N_("Reply to All") },
95 { "A_REPLY_ML", N_("Reply to Mailing-list") },
96 { "A_FORWARD", N_("Forward Message") },
97 { "A_DELETE", N_("Delete Message") },
98 { "A_EXECUTE", N_("Execute") },
99 { "A_GOTO_NEXT", N_("Goto Next Message") },
101 { "A_SEND", N_("Send Message") },
102 { "A_SENDL", N_("Put into queue folder and send later") },
103 { "A_DRAFT", N_("Save to draft folder") },
104 { "A_INSERT", N_("Insert file") },
105 { "A_ATTACH", N_("Attach file") },
106 { "A_SIG", N_("Insert signature") },
107 { "A_EXTEDITOR", N_("Edit with external editor") },
108 { "A_LINEWRAP", N_("Wrap all long lines") },
109 { "A_ADDRBOOK", N_("Address book") },
111 { "A_SYL_ACTIONS", N_("Sylpheed Actions Feature") },
112 { "A_SEPARATOR", ("") }
115 /* struct holds configuration files and a list of
116 * currently active toolbar items
117 * TOOLBAR_MAIN, TOOLBAR_COMPOSE and TOOLBAR_MSGVIEW
120 static ToolbarConfig toolbar_config[3] = {
121 { "toolbar_main.xml", NULL},
122 { "toolbar_compose.xml", NULL},
123 { "toolbar_msgview.xml", NULL}
126 gint toolbar_ret_val_from_descr(const gchar *descr)
130 for (i = 0; i < N_ACTION_VAL; i++) {
131 if (g_strcasecmp(gettext(toolbar_text[i].descr), descr) == 0)
138 gchar *toolbar_ret_descr_from_val(gint val)
140 g_return_val_if_fail(val >=0 && val < N_ACTION_VAL, NULL);
142 return gettext(toolbar_text[val].descr);
145 static gint toolbar_ret_val_from_text(const gchar *text)
149 for (i = 0; i < N_ACTION_VAL; i++) {
150 if (g_strcasecmp(toolbar_text[i].index_str, text) == 0)
157 static gchar *toolbar_ret_text_from_val(gint val)
159 g_return_val_if_fail(val >=0 && val < N_ACTION_VAL, NULL);
161 return toolbar_text[val].index_str;
164 gboolean toolbar_is_duplicate(gint action, ToolbarType source)
168 if ((action == A_SEPARATOR) || (action == A_SYL_ACTIONS))
171 for (cur = toolbar_config[source].item_list; cur != NULL; cur = cur->next) {
172 ToolbarItem *item = (ToolbarItem*) cur->data;
174 if (item->index == action)
180 GList *toolbar_get_action_items(ToolbarType source)
185 if (source == TOOLBAR_MAIN) {
186 gint main_items[13] = { A_RECEIVE_ALL, A_RECEIVE_CUR, A_SEND_QUEUED,
187 A_COMPOSE_EMAIL, A_REPLY_MESSAGE, A_REPLY_SENDER,
188 A_REPLY_ALL, A_REPLY_ML, A_FORWARD,
189 A_DELETE, A_EXECUTE, A_GOTO_NEXT,
192 for (i = 0; i < sizeof(main_items)/sizeof(main_items[0]); i++)
193 items = g_list_append(items, gettext(toolbar_text[main_items[i]].descr));
195 else if (source == TOOLBAR_COMPOSE) {
196 gint comp_items[10] = { A_SEND, A_SENDL, A_DRAFT,
197 A_INSERT, A_ATTACH, A_SIG,
198 A_EXTEDITOR, A_LINEWRAP, A_ADDRBOOK,
201 for (i = 0; i < sizeof(comp_items)/sizeof(comp_items[0]); i++)
202 items = g_list_append(items, gettext(toolbar_text[comp_items[i]].descr));
204 else if (source == TOOLBAR_MSGVIEW) {
205 gint msgv_items[8/*9*/] = { A_COMPOSE_EMAIL, A_REPLY_MESSAGE, A_REPLY_SENDER,
206 A_REPLY_ALL, A_REPLY_ML, A_FORWARD,
207 A_DELETE, A_GOTO_NEXT/* A_SYL_ACTIONS*/ };
209 for (i = 0; i < sizeof(msgv_items)/sizeof(msgv_items[0]); i++)
210 items = g_list_append(items, gettext(toolbar_text[msgv_items[i]].descr));
216 static void toolbar_parse_item(XMLFile *file, ToolbarType source)
220 ToolbarItem *item = NULL;
222 attr = xml_get_current_tag_attr(file);
223 item = g_new0(ToolbarItem, 1);
225 name = ((XMLAttr *)attr->data)->name;
226 value = ((XMLAttr *)attr->data)->value;
228 if (g_strcasecmp(name, TOOLBAR_ICON_FILE) == 0)
229 item->file = g_strdup (value);
230 else if (g_strcasecmp(name, TOOLBAR_ICON_TEXT) == 0)
231 item->text = g_strdup (value);
232 else if (g_strcasecmp(name, TOOLBAR_ICON_ACTION) == 0)
233 item->index = toolbar_ret_val_from_text(value);
235 attr = g_list_next(attr);
237 if (item->index != -1) {
239 if (!toolbar_is_duplicate(item->index, source))
240 toolbar_config[source].item_list = g_slist_append(toolbar_config[source].item_list,
245 static void toolbar_set_default_main(void)
251 } default_toolbar[] = {
252 { A_RECEIVE_CUR, STOCK_PIXMAP_MAIL_RECEIVE, _("Get") },
253 { A_RECEIVE_ALL, STOCK_PIXMAP_MAIL_RECEIVE_ALL, _("Get All") },
254 { A_SEPARATOR, 0, ("") },
255 { A_SEND_QUEUED, STOCK_PIXMAP_MAIL_SEND_QUEUE, _("Send") },
256 { A_COMPOSE_EMAIL, STOCK_PIXMAP_MAIL_COMPOSE, _("Email") },
257 { A_SEPARATOR, 0, ("") },
258 { A_REPLY_MESSAGE, STOCK_PIXMAP_MAIL_REPLY, _("Reply") },
259 { A_REPLY_ALL, STOCK_PIXMAP_MAIL_REPLY_TO_ALL, _("All") },
260 { A_REPLY_SENDER, STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR, _("Sender") },
261 { A_FORWARD, STOCK_PIXMAP_MAIL_FORWARD, _("Forward") },
262 { A_SEPARATOR, 0, ("") },
263 { A_DELETE, STOCK_PIXMAP_CLOSE, _("Delete") },
264 { A_EXECUTE, STOCK_PIXMAP_EXEC, _("Execute") },
265 { A_GOTO_NEXT, STOCK_PIXMAP_DOWN_ARROW, _("Next") }
270 for (i = 0; i < sizeof(default_toolbar) / sizeof(default_toolbar[0]); i++) {
272 ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
274 if (default_toolbar[i].action != A_SEPARATOR) {
276 gchar *file = stock_pixmap_get_name((StockPixmap)default_toolbar[i].icon);
278 toolbar_item->file = g_strdup(file);
279 toolbar_item->index = default_toolbar[i].action;
280 toolbar_item->text = g_strdup(default_toolbar[i].text);
283 toolbar_item->file = g_strdup(SEPARATOR);
284 toolbar_item->index = A_SEPARATOR;
287 if (toolbar_item->index != -1) {
288 if ( !toolbar_is_duplicate(toolbar_item->index, TOOLBAR_MAIN))
289 toolbar_config[TOOLBAR_MAIN].item_list =
290 g_slist_append(toolbar_config[TOOLBAR_MAIN].item_list, toolbar_item);
295 static void toolbar_set_default_compose(void)
301 } default_toolbar[] = {
302 { A_SEND, STOCK_PIXMAP_MAIL_SEND, _("Send") },
303 { A_SENDL, STOCK_PIXMAP_MAIL_SEND_QUEUE, _("Send later") },
304 { A_DRAFT, STOCK_PIXMAP_MAIL, _("Draft") },
305 { A_SEPARATOR, 0, ("") },
306 { A_INSERT, STOCK_PIXMAP_INSERT_FILE, _("Insert") },
307 { A_ATTACH, STOCK_PIXMAP_MAIL_ATTACH, _("Attach") },
308 { A_SIG, STOCK_PIXMAP_MAIL_SIGN, _("Signature") },
309 { A_SEPARATOR, 0, ("") },
310 { A_EXTEDITOR, STOCK_PIXMAP_EDIT_EXTERN, _("Editor") },
311 { A_LINEWRAP, STOCK_PIXMAP_LINEWRAP, _("Linewrap") },
312 { A_SEPARATOR, 0, ("") },
313 { A_ADDRBOOK, STOCK_PIXMAP_ADDRESS_BOOK, _("Address") }
318 for (i = 0; i < sizeof(default_toolbar) / sizeof(default_toolbar[0]); i++) {
320 ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
322 if (default_toolbar[i].action != A_SEPARATOR) {
324 gchar *file = stock_pixmap_get_name((StockPixmap)default_toolbar[i].icon);
326 toolbar_item->file = g_strdup(file);
327 toolbar_item->index = default_toolbar[i].action;
328 toolbar_item->text = g_strdup(default_toolbar[i].text);
331 toolbar_item->file = g_strdup(SEPARATOR);
332 toolbar_item->index = A_SEPARATOR;
335 if (toolbar_item->index != -1) {
336 if ( !toolbar_is_duplicate(toolbar_item->index, TOOLBAR_COMPOSE))
337 toolbar_config[TOOLBAR_COMPOSE].item_list =
338 g_slist_append(toolbar_config[TOOLBAR_COMPOSE].item_list, toolbar_item);
343 static void toolbar_set_default_msgview(void)
349 } default_toolbar[] = {
350 /*{ A_COMPOSE_EMAIL, STOCK_PIXMAP_MAIL_COMPOSE, _("Email") },
351 { A_SEPARATOR, 0, ("") },*/
352 { A_REPLY_MESSAGE, STOCK_PIXMAP_MAIL_REPLY, _("Reply") },
353 { A_REPLY_ALL, STOCK_PIXMAP_MAIL_REPLY_TO_ALL, _("All") },
354 { A_REPLY_SENDER, STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR, _("Sender") },
355 { A_FORWARD, STOCK_PIXMAP_MAIL_FORWARD, _("Forward") },
356 { A_SEPARATOR, 0, ("") },
357 { A_DELETE, STOCK_PIXMAP_CLOSE, _("Delete") },
358 { A_GOTO_NEXT, STOCK_PIXMAP_DOWN_ARROW, _("Next") }
363 for (i = 0; i < sizeof(default_toolbar) / sizeof(default_toolbar[0]); i++) {
365 ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
367 if (default_toolbar[i].action != A_SEPARATOR) {
369 gchar *file = stock_pixmap_get_name((StockPixmap)default_toolbar[i].icon);
371 toolbar_item->file = g_strdup(file);
372 toolbar_item->index = default_toolbar[i].action;
373 toolbar_item->text = g_strdup(default_toolbar[i].text);
376 toolbar_item->file = g_strdup(SEPARATOR);
377 toolbar_item->index = A_SEPARATOR;
380 if (toolbar_item->index != -1) {
381 if ( !toolbar_is_duplicate(toolbar_item->index, TOOLBAR_MSGVIEW))
382 toolbar_config[TOOLBAR_MSGVIEW].item_list =
383 g_slist_append(toolbar_config[TOOLBAR_MSGVIEW].item_list, toolbar_item);
388 void toolbar_set_default(ToolbarType source)
390 if (source == TOOLBAR_MAIN)
391 toolbar_set_default_main();
392 else if (source == TOOLBAR_COMPOSE)
393 toolbar_set_default_compose();
394 else if (source == TOOLBAR_MSGVIEW)
395 toolbar_set_default_msgview();
399 void toolbar_save_config_file(ToolbarType source)
404 gchar *fileSpec = NULL;
406 debug_print("save Toolbar Configuration to %s\n", toolbar_config[source].conf_file);
408 fileSpec = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, toolbar_config[source].conf_file, NULL );
409 pfile = prefs_write_open(fileSpec);
413 fprintf(fp, "<?xml version=\"1.0\" encoding=\"%s\" ?>\n",
414 conv_get_current_charset_str());
416 fprintf(fp, "<%s>\n", TOOLBAR_TAG_INDEX);
418 for (cur = toolbar_config[source].item_list; cur != NULL; cur = cur->next) {
419 ToolbarItem *toolbar_item = (ToolbarItem*) cur->data;
421 if (g_strcasecmp(toolbar_item->file, SEPARATOR) != 0)
422 fprintf(fp, "\t<%s %s=\"%s\" %s=\"%s\" %s=\"%s\"/>\n",
424 TOOLBAR_ICON_FILE, toolbar_item->file,
425 TOOLBAR_ICON_TEXT, toolbar_item->text,
427 toolbar_ret_text_from_val(toolbar_item->index));
429 fprintf(fp, "\t<%s/>\n", TOOLBAR_TAG_SEPARATOR);
432 fprintf(fp, "</%s>\n", TOOLBAR_TAG_INDEX);
434 if (prefs_write_close (pfile) < 0 )
435 g_warning("failed to write toolbar configuration to file\n");
437 g_warning("failed to open toolbar configuration file for writing\n");
440 void toolbar_read_config_file(ToolbarType source)
442 XMLFile *file = NULL;
443 gchar *fileSpec = NULL;
448 debug_print("read Toolbar Configuration from %s\n", toolbar_config[source].conf_file);
450 fileSpec = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, toolbar_config[source].conf_file, NULL );
451 file = xml_open_file(fileSpec);
454 toolbar_clear_list(source);
458 || (xml_get_dtd(file))
459 || (xml_parse_next_tag(file))
460 || (!xml_compare_tag(file, TOOLBAR_TAG_INDEX))) {
461 xml_close_file(file);
465 attr = xml_get_current_tag_attr(file);
472 if (xml_parse_next_tag(file))
475 /* Get next tag (icon, icon_text or icon_action) */
476 if (xml_compare_tag(file, TOOLBAR_TAG_ITEM)) {
477 toolbar_parse_item(file, source);
478 } else if (xml_compare_tag(file, TOOLBAR_TAG_SEPARATOR)) {
479 ToolbarItem *item = g_new0(ToolbarItem, 1);
481 item->file = g_strdup(SEPARATOR);
482 item->index = A_SEPARATOR;
483 toolbar_config[source].item_list =
484 g_slist_append(toolbar_config[source].item_list, item);
488 xml_close_file(file);
491 if ((!file) || (g_slist_length(toolbar_config[source].item_list) == 0)) {
493 if (source == TOOLBAR_MAIN)
494 toolbar_set_default(TOOLBAR_MAIN);
495 else if (source == TOOLBAR_COMPOSE)
496 toolbar_set_default(TOOLBAR_COMPOSE);
497 else if (source == TOOLBAR_MSGVIEW)
498 toolbar_set_default(TOOLBAR_MSGVIEW);
500 g_warning("failed to write Toolbar Configuration to %s\n", toolbar_config[source].conf_file);
504 toolbar_save_config_file(source);
509 * clears list of toolbar items read from configuration files
511 void toolbar_clear_list(ToolbarType source)
513 while (toolbar_config[source].item_list != NULL) {
514 ToolbarItem *item = (ToolbarItem*) toolbar_config[source].item_list->data;
516 toolbar_config[source].item_list =
517 g_slist_remove(toolbar_config[source].item_list, item);
525 g_slist_free(toolbar_config[source].item_list);
530 * return list of Toolbar items
532 GSList *toolbar_get_list(ToolbarType source)
536 if ((source == TOOLBAR_MAIN) || (source == TOOLBAR_COMPOSE) || (source == TOOLBAR_MSGVIEW))
537 list = toolbar_config[source].item_list;
542 void toolbar_set_list_item(ToolbarItem *t_item, ToolbarType source)
544 ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
546 toolbar_item->file = g_strdup(t_item->file);
547 toolbar_item->text = g_strdup(t_item->text);
548 toolbar_item->index = t_item->index;
550 toolbar_config[source].item_list =
551 g_slist_append(toolbar_config[source].item_list,
555 void toolbar_action_execute(GtkWidget *widget,
561 gchar *action, *action_p;
562 gboolean found = FALSE;
565 for (cur = action_list; cur != NULL; cur = cur->next) {
566 ToolbarSylpheedActions *act = (ToolbarSylpheedActions*)cur->data;
568 if (widget == act->widget) {
570 for (lop = prefs_common.actions_list; lop != NULL; lop = lop->next) {
571 action = g_strdup((gchar*)lop->data);
573 action_p = strstr(action, ": ");
575 if (g_strcasecmp(act->name, action) == 0) {
589 actions_execute(data, i, widget, source);
591 g_warning ("Error: did not find Sylpheed Action to execute");
595 * Change the style of toolbar
597 void common_toolbar_set_style(gpointer data, ToolbarType type)
599 GtkWidget *handlebox_wid;
600 GtkWidget *toolbar_wid;
603 MessageView *msgview;
605 g_return_if_fail(data != NULL);
609 mainwin = (MainWindow*)data;
610 handlebox_wid = mainwin->handlebox;
611 toolbar_wid = mainwin->toolbar->toolbar;
613 case TOOLBAR_COMPOSE:
614 compose = (Compose*)data;
615 handlebox_wid = compose->handlebox;
616 toolbar_wid = compose->toolbar->toolbar;
618 case TOOLBAR_MSGVIEW:
619 msgview = (MessageView*)data;
620 handlebox_wid = msgview->handlebox;
621 toolbar_wid = msgview->toolbar->toolbar;
624 debug_print("toolbar_set_style: not supported for this type of window\n");
628 switch (prefs_common.toolbar_style) {
630 gtk_widget_hide(handlebox_wid);
633 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
637 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
641 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
646 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
647 gtk_widget_show(handlebox_wid);
648 gtk_widget_queue_resize(handlebox_wid);
653 * Delete current/selected(s) message(s)
655 void common_toolbar_delete_cb(GtkWidget *widget,
658 ToolbarParent *parent = (ToolbarParent*)data;
660 MessageView *msgview;
662 g_return_if_fail(parent != NULL);
664 switch (parent->type) {
665 case TOOLBAR_MSGVIEW:
666 msgview = (MessageView*)parent->data;
668 /* make sure the selected msg in summaryview is
669 the one we are asked to delete
671 if (msgview->mainwin->summaryview->selected) {
672 SummaryView *summaryview = msgview->mainwin->summaryview;
673 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
674 MsgInfo *msginfo = gtk_ctree_node_get_row_data(ctree,
675 summaryview->selected);
676 if (msginfo->msgnum != msgview->msginfo->msgnum) {
677 alertpanel_error(_("Message already removed from folder."));
682 summary_delete(msgview->mainwin->summaryview);
684 if (msgview->mainwin->summaryview->selected) {
685 SummaryView *summaryview = msgview->mainwin->summaryview;
686 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
687 MsgInfo *msginfo = gtk_ctree_node_get_row_data(ctree,
688 summaryview->selected);
689 messageview_show(msgview, msginfo,
690 msgview->all_headers);
692 toolbar_clear_list(TOOLBAR_MSGVIEW);
693 TOOLBAR_DESTROY_ITEMS(msgview->toolbar->item_list);
694 TOOLBAR_DESTROY_ACTIONS(msgview->toolbar->action_list);
695 gtk_widget_destroy(msgview->window);
699 mainwin = (MainWindow*)parent->data;
700 summary_delete(mainwin->summaryview);
703 debug_print("toolbar_delete: Not supported for this type of window\n");
710 * Compose new message
712 void common_toolbar_compose_cb(GtkWidget *widget,
715 ToolbarParent *parent = (ToolbarParent*)data;
716 MessageView *msgview;
718 g_return_if_fail(parent != NULL);
720 switch (parent->type) {
721 case TOOLBAR_MSGVIEW:
722 msgview = (MessageView*)parent->data;
723 compose_new_with_folderitem(NULL,
724 msgview->msginfo->folder);
727 debug_print("toolbar_compose: Not supported for this type of window\n");
735 void common_toolbar_reply_cb(GtkWidget *widget,
738 ToolbarParent *parent = (ToolbarParent*)data;
739 MessageView *msgview;
741 g_return_if_fail(parent != NULL);
743 switch (parent->type) {
744 case TOOLBAR_MSGVIEW:
745 msgview = (MessageView*)parent->data;
746 compose_reply(msgview->msginfo,
747 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
748 : COMPOSE_REPLY_WITHOUT_QUOTE,
749 FALSE, FALSE, FALSE, NULL);
752 debug_print("toolbar_reply: Not supported for this type of window\n");
758 * Reply message to Sender and All recipients
760 void common_toolbar_reply_to_all_cb(GtkWidget *widget,
763 ToolbarParent *parent = (ToolbarParent*)data;
764 MessageView *msgview;
766 g_return_if_fail(parent != NULL);
768 switch (parent->type) {
769 case TOOLBAR_MSGVIEW:
770 msgview = (MessageView*)parent->data;
771 compose_reply(msgview->msginfo,
772 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
773 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
774 TRUE, FALSE, FALSE, NULL);
777 debug_print("toolbar_reply_to_all: Not supported for this type of window\n");
783 * Reply to Mailing List
785 void common_toolbar_reply_to_list_cb(GtkWidget *widget,
788 ToolbarParent *parent = (ToolbarParent*)data;
789 MessageView *msgview;
791 g_return_if_fail(parent != NULL);
793 switch (parent->type) {
794 case TOOLBAR_MSGVIEW:
795 msgview = (MessageView*)parent->data;
796 compose_reply(msgview->msginfo,
797 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_LIST_WITH_QUOTE
798 : COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE,
799 FALSE, TRUE, FALSE, NULL);
802 debug_print("toolbar_reply_to_list: Not supported for this type of window\n");
808 * Reply to sender of message
810 void common_toolbar_reply_to_sender_cb(GtkWidget *widget,
813 ToolbarParent *parent = (ToolbarParent*)data;
814 MessageView *msgview;
816 g_return_if_fail(parent != NULL);
818 switch (parent->type) {
819 case TOOLBAR_MSGVIEW:
820 msgview = (MessageView*)parent->data;
821 compose_reply(msgview->msginfo,
822 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
823 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
824 FALSE, FALSE, FALSE, NULL);
827 debug_print("toolbar_reply_to_sender: Not supported for this type of window\n");
833 * Forward current/selected(s) message(s)
835 void common_toolbar_forward_cb(GtkWidget *widget,
838 ToolbarParent *parent = (ToolbarParent*)data;
840 g_return_if_fail(parent != NULL);
842 switch (parent->type) {
844 REFERENCE FROM mainwindow.c
847 if (prefs_common.forward_as_attachment)
848 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
850 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
854 debug_print("toolbar_forward: Not supported for this type of window\n");
860 * Goto Next Unread Message
862 void common_toolbar_next_unread_cb(GtkWidget *widget,
865 ToolbarParent *parent = (ToolbarParent*)data;
867 MessageView *msgview;
869 g_return_if_fail(parent != NULL);
871 switch (parent->type) {
873 mainwin = (MainWindow*)parent->data;
874 summary_select_next_unread(mainwin->summaryview);
877 case TOOLBAR_MSGVIEW:
878 msgview = (MessageView*)parent->data;
880 * TODO: Check if summaryview stay in the same place when this message view was created
881 * if summary have other message select the next will be based on message selected in summaryview
883 summary_select_next_unread(msgview->mainwin->summaryview);
885 /** Now we need to update the messageview window */
886 if (msgview->mainwin->summaryview->selected) {
887 GtkCTree *ctree = GTK_CTREE(msgview->mainwin->summaryview->ctree);
889 MsgInfo * msginfo = gtk_ctree_node_get_row_data(ctree,
890 msgview->mainwin->summaryview->selected);
892 messageview_show(msgview, msginfo,
893 msgview->all_headers);
895 gtk_widget_destroy(msgview->window);
899 debug_print("toolbar_next_unread: Not supported for this type of window\n");
905 * Execute actions from toolbar
907 void common_toolbar_actions_execute_cb(GtkWidget *widget,
910 ToolbarParent *parent = (ToolbarParent*)data;
915 g_return_if_fail(parent != NULL);
917 switch (parent->type) {
919 mainwin = (MainWindow*)parent->data;
920 action_list = mainwin->toolbar->action_list;
922 case TOOLBAR_COMPOSE:
923 compose = (Compose*)parent->data;
924 action_list = compose->toolbar->action_list;
926 /* case TOOLBAR_MSGVIEW: not supported yet */
928 debug_print("toolbar_actions: not supported for this window type\n");
932 toolbar_action_execute(widget, action_list, parent->data, parent->type);