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"
56 #define TOOLBAR_TAG_INDEX "toolbar"
57 #define TOOLBAR_TAG_ITEM "item"
58 #define TOOLBAR_TAG_SEPARATOR SEPARATOR
60 #define TOOLBAR_ICON_FILE "file"
61 #define TOOLBAR_ICON_TEXT "text"
62 #define TOOLBAR_ICON_ACTION "action"
64 gboolean toolbar_is_duplicate (gint action,
66 static void toolbar_parse_item (XMLFile *file,
69 static gint toolbar_ret_val_from_text (const gchar *text);
70 static gchar *toolbar_ret_text_from_val (gint val);
72 static void toolbar_set_default_main (void);
73 static void toolbar_set_default_compose (void);
74 static void toolbar_set_default_msgview (void);
76 static ToolbarType detect_window(gpointer data);
84 * Text Database linked to enumarated values in toolbar.h
86 static struct ToolbarText toolbar_text [] = {
88 { "A_RECEIVE_ALL", N_("Receive Mail on all Accounts") },
89 { "A_RECEIVE_CUR", N_("Receive Mail on current Account") },
90 { "A_SEND_QUEUED", N_("Send Queued Message(s)") },
91 { "A_COMPOSE_EMAIL", N_("Compose Email") },
92 { "A_COMPOSE_NEWS", N_("Compose News") },
93 { "A_REPLY_MESSAGE", N_("Reply to Message") },
94 { "A_REPLY_SENDER", N_("Reply to Sender") },
95 { "A_REPLY_ALL", N_("Reply to All") },
96 { "A_REPLY_ML", N_("Reply to Mailing-list") },
97 { "A_FORWARD", N_("Forward Message") },
98 { "A_DELETE", N_("Delete Message") },
99 { "A_EXECUTE", N_("Execute") },
100 { "A_GOTO_NEXT", N_("Goto Next Message") },
102 { "A_SEND", N_("Send Message") },
103 { "A_SENDL", N_("Put into queue folder and send later") },
104 { "A_DRAFT", N_("Save to draft folder") },
105 { "A_INSERT", N_("Insert file") },
106 { "A_ATTACH", N_("Attach file") },
107 { "A_SIG", N_("Insert signature") },
108 { "A_EXTEDITOR", N_("Edit with external editor") },
109 { "A_LINEWRAP", N_("Wrap all long lines") },
110 { "A_ADDRBOOK", N_("Address book") },
112 { "A_SYL_ACTIONS", N_("Sylpheed Actions Feature") },
113 { "A_SEPARATOR", ("") }
116 /* struct holds configuration files and a list of
117 * currently active toolbar items
118 * TOOLBAR_MAIN, TOOLBAR_COMPOSE and TOOLBAR_MSGVIEW
121 static ToolbarConfig toolbar_config[3] = {
122 { "toolbar_main.xml", NULL},
123 { "toolbar_compose.xml", NULL},
124 { "toolbar_msgview.xml", NULL}
127 gint toolbar_ret_val_from_descr(const gchar *descr)
131 for (i = 0; i < N_ACTION_VAL; i++) {
132 if (g_strcasecmp(gettext(toolbar_text[i].descr), descr) == 0)
139 gchar *toolbar_ret_descr_from_val(gint val)
141 g_return_val_if_fail(val >=0 && val < N_ACTION_VAL, NULL);
143 return gettext(toolbar_text[val].descr);
146 static gint toolbar_ret_val_from_text(const gchar *text)
150 for (i = 0; i < N_ACTION_VAL; i++) {
151 if (g_strcasecmp(toolbar_text[i].index_str, text) == 0)
158 static gchar *toolbar_ret_text_from_val(gint val)
160 g_return_val_if_fail(val >=0 && val < N_ACTION_VAL, NULL);
162 return toolbar_text[val].index_str;
165 gboolean toolbar_is_duplicate(gint action, ToolbarType source)
169 if ((action == A_SEPARATOR) || (action == A_SYL_ACTIONS))
172 for (cur = toolbar_config[source].item_list; cur != NULL; cur = cur->next) {
173 ToolbarItem *item = (ToolbarItem*) cur->data;
175 if (item->index == action)
181 GList *toolbar_get_action_items(ToolbarType source)
186 if (source == TOOLBAR_MAIN) {
187 gint main_items[13] = { A_RECEIVE_ALL, A_RECEIVE_CUR, A_SEND_QUEUED,
188 A_COMPOSE_EMAIL, A_REPLY_MESSAGE, A_REPLY_SENDER,
189 A_REPLY_ALL, A_REPLY_ML, A_FORWARD,
190 A_DELETE, A_EXECUTE, A_GOTO_NEXT,
193 for (i = 0; i < sizeof(main_items)/sizeof(main_items[0]); i++)
194 items = g_list_append(items, gettext(toolbar_text[main_items[i]].descr));
196 else if (source == TOOLBAR_COMPOSE) {
197 gint comp_items[10] = { A_SEND, A_SENDL, A_DRAFT,
198 A_INSERT, A_ATTACH, A_SIG,
199 A_EXTEDITOR, A_LINEWRAP, A_ADDRBOOK,
202 for (i = 0; i < sizeof(comp_items)/sizeof(comp_items[0]); i++)
203 items = g_list_append(items, gettext(toolbar_text[comp_items[i]].descr));
205 else if (source == TOOLBAR_MSGVIEW) {
206 gint msgv_items[8/*9*/] = { A_COMPOSE_EMAIL, A_REPLY_MESSAGE, A_REPLY_SENDER,
207 A_REPLY_ALL, A_REPLY_ML, A_FORWARD,
208 A_DELETE, A_GOTO_NEXT/* A_SYL_ACTIONS*/ };
210 for (i = 0; i < sizeof(msgv_items)/sizeof(msgv_items[0]); i++)
211 items = g_list_append(items, gettext(toolbar_text[msgv_items[i]].descr));
217 static void toolbar_parse_item(XMLFile *file, ToolbarType source)
221 ToolbarItem *item = NULL;
223 attr = xml_get_current_tag_attr(file);
224 item = g_new0(ToolbarItem, 1);
226 name = ((XMLAttr *)attr->data)->name;
227 value = ((XMLAttr *)attr->data)->value;
229 if (g_strcasecmp(name, TOOLBAR_ICON_FILE) == 0)
230 item->file = g_strdup (value);
231 else if (g_strcasecmp(name, TOOLBAR_ICON_TEXT) == 0)
232 item->text = g_strdup (value);
233 else if (g_strcasecmp(name, TOOLBAR_ICON_ACTION) == 0)
234 item->index = toolbar_ret_val_from_text(value);
236 attr = g_list_next(attr);
238 if (item->index != -1) {
240 if (!toolbar_is_duplicate(item->index, source))
241 toolbar_config[source].item_list = g_slist_append(toolbar_config[source].item_list,
246 static void toolbar_set_default_main(void)
252 } default_toolbar[] = {
253 { A_RECEIVE_CUR, STOCK_PIXMAP_MAIL_RECEIVE, _("Get") },
254 { A_RECEIVE_ALL, STOCK_PIXMAP_MAIL_RECEIVE_ALL, _("Get All") },
255 { A_SEPARATOR, 0, ("") },
256 { A_SEND_QUEUED, STOCK_PIXMAP_MAIL_SEND_QUEUE, _("Send") },
257 { A_COMPOSE_EMAIL, STOCK_PIXMAP_MAIL_COMPOSE, _("Email") },
258 { A_SEPARATOR, 0, ("") },
259 { A_REPLY_MESSAGE, STOCK_PIXMAP_MAIL_REPLY, _("Reply") },
260 { A_REPLY_ALL, STOCK_PIXMAP_MAIL_REPLY_TO_ALL, _("All") },
261 { A_REPLY_SENDER, STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR, _("Sender") },
262 { A_FORWARD, STOCK_PIXMAP_MAIL_FORWARD, _("Forward") },
263 { A_SEPARATOR, 0, ("") },
264 { A_DELETE, STOCK_PIXMAP_CLOSE, _("Delete") },
265 { A_EXECUTE, STOCK_PIXMAP_EXEC, _("Execute") },
266 { A_GOTO_NEXT, STOCK_PIXMAP_DOWN_ARROW, _("Next") }
271 for (i = 0; i < sizeof(default_toolbar) / sizeof(default_toolbar[0]); i++) {
273 ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
275 if (default_toolbar[i].action != A_SEPARATOR) {
277 gchar *file = stock_pixmap_get_name((StockPixmap)default_toolbar[i].icon);
279 toolbar_item->file = g_strdup(file);
280 toolbar_item->index = default_toolbar[i].action;
281 toolbar_item->text = g_strdup(default_toolbar[i].text);
284 toolbar_item->file = g_strdup(SEPARATOR);
285 toolbar_item->index = A_SEPARATOR;
288 if (toolbar_item->index != -1) {
289 if ( !toolbar_is_duplicate(toolbar_item->index, TOOLBAR_MAIN))
290 toolbar_config[TOOLBAR_MAIN].item_list =
291 g_slist_append(toolbar_config[TOOLBAR_MAIN].item_list, toolbar_item);
296 static void toolbar_set_default_compose(void)
302 } default_toolbar[] = {
303 { A_SEND, STOCK_PIXMAP_MAIL_SEND, _("Send") },
304 { A_SENDL, STOCK_PIXMAP_MAIL_SEND_QUEUE, _("Send later") },
305 { A_DRAFT, STOCK_PIXMAP_MAIL, _("Draft") },
306 { A_SEPARATOR, 0, ("") },
307 { A_INSERT, STOCK_PIXMAP_INSERT_FILE, _("Insert") },
308 { A_ATTACH, STOCK_PIXMAP_MAIL_ATTACH, _("Attach") },
309 { A_SIG, STOCK_PIXMAP_MAIL_SIGN, _("Signature") },
310 { A_SEPARATOR, 0, ("") },
311 { A_EXTEDITOR, STOCK_PIXMAP_EDIT_EXTERN, _("Editor") },
312 { A_LINEWRAP, STOCK_PIXMAP_LINEWRAP, _("Linewrap") },
313 { A_SEPARATOR, 0, ("") },
314 { A_ADDRBOOK, STOCK_PIXMAP_ADDRESS_BOOK, _("Address") }
319 for (i = 0; i < sizeof(default_toolbar) / sizeof(default_toolbar[0]); i++) {
321 ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
323 if (default_toolbar[i].action != A_SEPARATOR) {
325 gchar *file = stock_pixmap_get_name((StockPixmap)default_toolbar[i].icon);
327 toolbar_item->file = g_strdup(file);
328 toolbar_item->index = default_toolbar[i].action;
329 toolbar_item->text = g_strdup(default_toolbar[i].text);
332 toolbar_item->file = g_strdup(SEPARATOR);
333 toolbar_item->index = A_SEPARATOR;
336 if (toolbar_item->index != -1) {
337 if ( !toolbar_is_duplicate(toolbar_item->index, TOOLBAR_COMPOSE))
338 toolbar_config[TOOLBAR_COMPOSE].item_list =
339 g_slist_append(toolbar_config[TOOLBAR_COMPOSE].item_list, toolbar_item);
344 static void toolbar_set_default_msgview(void)
350 } default_toolbar[] = {
351 /*{ A_COMPOSE_EMAIL, STOCK_PIXMAP_MAIL_COMPOSE, _("Email") },
352 { A_SEPARATOR, 0, ("") },*/
353 { A_REPLY_MESSAGE, STOCK_PIXMAP_MAIL_REPLY, _("Reply") },
354 { A_REPLY_ALL, STOCK_PIXMAP_MAIL_REPLY_TO_ALL, _("All") },
355 { A_REPLY_SENDER, STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR, _("Sender") },
356 { A_FORWARD, STOCK_PIXMAP_MAIL_FORWARD, _("Forward") },
357 { A_SEPARATOR, 0, ("") },
358 { A_DELETE, STOCK_PIXMAP_CLOSE, _("Delete") },
359 { A_GOTO_NEXT, STOCK_PIXMAP_DOWN_ARROW, _("Next") }
364 for (i = 0; i < sizeof(default_toolbar) / sizeof(default_toolbar[0]); i++) {
366 ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
368 if (default_toolbar[i].action != A_SEPARATOR) {
370 gchar *file = stock_pixmap_get_name((StockPixmap)default_toolbar[i].icon);
372 toolbar_item->file = g_strdup(file);
373 toolbar_item->index = default_toolbar[i].action;
374 toolbar_item->text = g_strdup(default_toolbar[i].text);
377 toolbar_item->file = g_strdup(SEPARATOR);
378 toolbar_item->index = A_SEPARATOR;
381 if (toolbar_item->index != -1) {
382 if ( !toolbar_is_duplicate(toolbar_item->index, TOOLBAR_MSGVIEW))
383 toolbar_config[TOOLBAR_MSGVIEW].item_list =
384 g_slist_append(toolbar_config[TOOLBAR_MSGVIEW].item_list, toolbar_item);
389 void toolbar_set_default(ToolbarType source)
391 if (source == TOOLBAR_MAIN)
392 toolbar_set_default_main();
393 else if (source == TOOLBAR_COMPOSE)
394 toolbar_set_default_compose();
395 else if (source == TOOLBAR_MSGVIEW)
396 toolbar_set_default_msgview();
400 void toolbar_save_config_file(ToolbarType source)
405 gchar *fileSpec = NULL;
407 debug_print("save Toolbar Configuration to %s\n", toolbar_config[source].conf_file);
409 fileSpec = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, toolbar_config[source].conf_file, NULL );
410 pfile = prefs_write_open(fileSpec);
414 fprintf(fp, "<?xml version=\"1.0\" encoding=\"%s\" ?>\n",
415 conv_get_current_charset_str());
417 fprintf(fp, "<%s>\n", TOOLBAR_TAG_INDEX);
419 for (cur = toolbar_config[source].item_list; cur != NULL; cur = cur->next) {
420 ToolbarItem *toolbar_item = (ToolbarItem*) cur->data;
422 if (g_strcasecmp(toolbar_item->file, SEPARATOR) != 0)
423 fprintf(fp, "\t<%s %s=\"%s\" %s=\"%s\" %s=\"%s\"/>\n",
425 TOOLBAR_ICON_FILE, toolbar_item->file,
426 TOOLBAR_ICON_TEXT, toolbar_item->text,
428 toolbar_ret_text_from_val(toolbar_item->index));
430 fprintf(fp, "\t<%s/>\n", TOOLBAR_TAG_SEPARATOR);
433 fprintf(fp, "</%s>\n", TOOLBAR_TAG_INDEX);
435 if (prefs_write_close (pfile) < 0 )
436 g_warning("failed to write toolbar configuration to file\n");
438 g_warning("failed to open toolbar configuration file for writing\n");
441 void toolbar_read_config_file(ToolbarType source)
443 XMLFile *file = NULL;
444 gchar *fileSpec = NULL;
449 debug_print("read Toolbar Configuration from %s\n", toolbar_config[source].conf_file);
451 fileSpec = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, toolbar_config[source].conf_file, NULL );
452 file = xml_open_file(fileSpec);
455 toolbar_clear_list(source);
459 || (xml_get_dtd(file))
460 || (xml_parse_next_tag(file))
461 || (!xml_compare_tag(file, TOOLBAR_TAG_INDEX))) {
462 xml_close_file(file);
466 attr = xml_get_current_tag_attr(file);
473 if (xml_parse_next_tag(file))
476 /* Get next tag (icon, icon_text or icon_action) */
477 if (xml_compare_tag(file, TOOLBAR_TAG_ITEM)) {
478 toolbar_parse_item(file, source);
479 } else if (xml_compare_tag(file, TOOLBAR_TAG_SEPARATOR)) {
480 ToolbarItem *item = g_new0(ToolbarItem, 1);
482 item->file = g_strdup(SEPARATOR);
483 item->index = A_SEPARATOR;
484 toolbar_config[source].item_list =
485 g_slist_append(toolbar_config[source].item_list, item);
489 xml_close_file(file);
492 if ((!file) || (g_slist_length(toolbar_config[source].item_list) == 0)) {
494 if (source == TOOLBAR_MAIN)
495 toolbar_set_default(TOOLBAR_MAIN);
496 else if (source == TOOLBAR_COMPOSE)
497 toolbar_set_default(TOOLBAR_COMPOSE);
498 else if (source == TOOLBAR_MSGVIEW)
499 toolbar_set_default(TOOLBAR_MSGVIEW);
501 g_warning("failed to write Toolbar Configuration to %s\n", toolbar_config[source].conf_file);
505 toolbar_save_config_file(source);
510 * clears list of toolbar items read from configuration files
512 void toolbar_clear_list(ToolbarType source)
514 while (toolbar_config[source].item_list != NULL) {
515 ToolbarItem *item = (ToolbarItem*) toolbar_config[source].item_list->data;
517 toolbar_config[source].item_list =
518 g_slist_remove(toolbar_config[source].item_list, item);
526 g_slist_free(toolbar_config[source].item_list);
531 * return list of Toolbar items
533 GSList *toolbar_get_list(ToolbarType source)
537 if ((source == TOOLBAR_MAIN) || (source == TOOLBAR_COMPOSE) || (source == TOOLBAR_MSGVIEW))
538 list = toolbar_config[source].item_list;
543 void toolbar_set_list_item(ToolbarItem *t_item, ToolbarType source)
545 ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
547 toolbar_item->file = g_strdup(t_item->file);
548 toolbar_item->text = g_strdup(t_item->text);
549 toolbar_item->index = t_item->index;
551 toolbar_config[source].item_list =
552 g_slist_append(toolbar_config[source].item_list,
556 void toolbar_action_execute(GtkWidget *widget,
562 gchar *action, *action_p;
563 gboolean found = FALSE;
566 for (cur = action_list; cur != NULL; cur = cur->next) {
567 ToolbarSylpheedActions *act = (ToolbarSylpheedActions*)cur->data;
569 if (widget == act->widget) {
571 for (lop = prefs_common.actions_list; lop != NULL; lop = lop->next) {
572 action = g_strdup((gchar*)lop->data);
574 action_p = strstr(action, ": ");
576 if (g_strcasecmp(act->name, action) == 0) {
590 actions_execute(data, i, widget, source);
592 g_warning ("Error: did not find Sylpheed Action to execute");
596 * Change the style of toolbar
598 void common_toolbar_set_style(gpointer data, ToolbarType type)
600 GtkWidget *handlebox_wid;
601 GtkWidget *toolbar_wid;
604 MessageView *msgview;
606 g_return_if_fail(data != NULL);
610 mainwin = (MainWindow*)data;
611 handlebox_wid = mainwin->handlebox;
612 toolbar_wid = mainwin->toolbar->toolbar;
614 case TOOLBAR_COMPOSE:
615 compose = (Compose*)data;
616 handlebox_wid = compose->handlebox;
617 toolbar_wid = compose->toolbar->toolbar;
619 case TOOLBAR_MSGVIEW:
620 msgview = (MessageView*)data;
621 handlebox_wid = msgview->handlebox;
622 toolbar_wid = msgview->toolbar->toolbar;
625 debug_print("toolbar_set_style: not supported for this type of window\n");
629 switch (prefs_common.toolbar_style) {
631 gtk_widget_hide(handlebox_wid);
634 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
638 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
642 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
647 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
648 gtk_widget_show(handlebox_wid);
649 gtk_widget_queue_resize(handlebox_wid);
654 * Delete current/selected(s) message(s)
656 void common_toolbar_delete_cb(GtkWidget *widget,
659 ToolbarParent *parent = (ToolbarParent*)data;
661 MessageView *msgview;
663 g_return_if_fail(parent != NULL);
665 switch (parent->type) {
666 case TOOLBAR_MSGVIEW:
667 msgview = (MessageView*)parent->data;
668 summary_delete(msgview->mainwin->summaryview);
669 /* do we really want to close the widget ?
670 I`d rather have it staying open and moving to next msg
671 in summaryview ... - oha */
672 /* following code is already used somewhere else, perhaps wrap it in a function ? */
673 if (msgview->mainwin->summaryview->selected) {
674 GtkCTree *ctree = GTK_CTREE(msgview->mainwin->summaryview->ctree);
675 MsgInfo * msginfo = gtk_ctree_node_get_row_data(ctree,
676 msgview->mainwin->summaryview->selected);
677 messageview_show(msgview, msginfo,
678 msgview->all_headers);
680 toolbar_clear_list(TOOLBAR_MSGVIEW);
681 TOOLBAR_DESTROY_ITEMS(msgview->toolbar->item_list);
682 TOOLBAR_DESTROY_ACTIONS(msgview->toolbar->action_list);
683 gtk_widget_destroy(msgview->window);
687 mainwin = (MainWindow*)parent->data;
688 summary_delete(mainwin->summaryview);
691 debug_print("toolbar_delete: Not supported for this type of window\n");
698 * Compose new message
700 void common_toolbar_compose_cb(GtkWidget *widget,
703 ToolbarParent *parent = (ToolbarParent*)data;
704 MessageView *msgview;
706 g_return_if_fail(parent != NULL);
708 switch (parent->type) {
709 case TOOLBAR_MSGVIEW:
710 msgview = (MessageView*)parent->data;
711 compose_new_with_folderitem(NULL,
712 msgview->msginfo->folder);
715 debug_print("toolbar_compose: Not supported for this type of window\n");
723 void common_toolbar_reply_cb(GtkWidget *widget,
726 ToolbarParent *parent = (ToolbarParent*)data;
727 MessageView *msgview;
729 g_return_if_fail(parent != NULL);
731 switch (parent->type) {
732 case TOOLBAR_MSGVIEW:
733 msgview = (MessageView*)parent->data;
734 compose_reply(msgview->msginfo,
735 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
736 : COMPOSE_REPLY_WITHOUT_QUOTE,
737 FALSE, FALSE, FALSE, NULL);
740 debug_print("toolbar_reply: Not supported for this type of window\n");
746 * Reply message to Sender and All recipients
748 void common_toolbar_reply_to_all_cb(GtkWidget *widget,
751 ToolbarParent *parent = (ToolbarParent*)data;
752 MessageView *msgview;
754 g_return_if_fail(parent != NULL);
756 switch (parent->type) {
757 case TOOLBAR_MSGVIEW:
758 msgview = (MessageView*)parent->data;
759 compose_reply(msgview->msginfo,
760 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
761 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
762 TRUE, FALSE, FALSE, NULL);
765 debug_print("toolbar_reply_to_all: Not supported for this type of window\n");
771 * Reply to Mailing List
773 void common_toolbar_reply_to_list_cb(GtkWidget *widget,
776 ToolbarParent *parent = (ToolbarParent*)data;
777 MessageView *msgview;
779 g_return_if_fail(parent != NULL);
781 switch (parent->type) {
782 case TOOLBAR_MSGVIEW:
783 msgview = (MessageView*)parent->data;
784 compose_reply(msgview->msginfo,
785 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_LIST_WITH_QUOTE
786 : COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE,
787 FALSE, TRUE, FALSE, NULL);
790 debug_print("toolbar_reply_to_list: Not supported for this type of window\n");
796 * Reply to sender of message
798 void common_toolbar_reply_to_sender_cb(GtkWidget *widget,
801 ToolbarParent *parent = (ToolbarParent*)data;
802 MessageView *msgview;
804 g_return_if_fail(parent != NULL);
806 switch (parent->type) {
807 case TOOLBAR_MSGVIEW:
808 msgview = (MessageView*)parent->data;
809 compose_reply(msgview->msginfo,
810 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
811 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
812 FALSE, FALSE, FALSE, NULL);
815 debug_print("toolbar_reply_to_sender: Not supported for this type of window\n");
821 * Forward current/selected(s) message(s)
823 void common_toolbar_forward_cb(GtkWidget *widget,
826 ToolbarParent *parent = (ToolbarParent*)data;
827 MessageView *msgview;
829 g_return_if_fail(parent != NULL);
831 switch (parent->type) {
833 REFERENCE FROM mainwindow.c
836 if (prefs_common.forward_as_attachment)
837 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
839 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
843 debug_print("toolbar_forward: Not supported for this type of window\n");
849 * Goto Next Unread Message
851 void common_toolbar_next_unread_cb(GtkWidget *widget,
854 ToolbarParent *parent = (ToolbarParent*)data;
856 MessageView *msgview;
858 g_return_if_fail(parent != NULL);
860 switch (parent->type) {
862 mainwin = (MainWindow*)parent->data;
863 summary_select_next_unread(mainwin->summaryview);
866 case TOOLBAR_MSGVIEW:
867 msgview = (MessageView*)parent->data;
869 * TODO: Check if summaryview stay in the same place when this message view was created
870 * if summary have other message select the next will be based on message selected in summaryview
872 summary_select_next_unread(msgview->mainwin->summaryview);
874 /** Now we need to update the messageview window */
875 if (msgview->mainwin->summaryview->selected) {
876 GtkCTree *ctree = GTK_CTREE(msgview->mainwin->summaryview->ctree);
878 MsgInfo * msginfo = gtk_ctree_node_get_row_data(ctree,
879 msgview->mainwin->summaryview->selected);
881 messageview_show(msgview, msginfo,
882 msgview->all_headers);
884 gtk_widget_destroy(msgview->window);
888 debug_print("toolbar_next_unread: Not supported for this type of window\n");
894 * Execute actions from toolbar
896 void common_toolbar_actions_execute_cb(GtkWidget *widget,
899 ToolbarParent *parent = (ToolbarParent*)data;
904 g_return_if_fail(parent != NULL);
906 switch (parent->type) {
908 mainwin = (MainWindow*)parent->data;
909 action_list = mainwin->toolbar->action_list;
911 case TOOLBAR_COMPOSE:
912 compose = (Compose*)parent->data;
913 action_list = compose->toolbar->action_list;
915 /* case TOOLBAR_MSGVIEW: not supported yet */
917 debug_print("toolbar_actions: not supported for this window type\n");
921 toolbar_action_execute(widget, action_list, parent->data, parent->type);