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
,
84 static gint
toolbar_ret_val_from_text (const gchar
*text
);
85 static gchar
*toolbar_ret_text_from_val (gint val
);
87 static void toolbar_set_default_main (void);
88 static void toolbar_set_default_compose (void);
89 static void toolbar_set_default_msgview (void);
91 static void toolbar_style (ToolbarType type
,
95 static MainWindow
*get_mainwin (gpointer data
);
96 static void activate_compose_button (Toolbar
*toolbar
,
98 ComposeButtonType type
);
100 /* toolbar callbacks */
101 static void toolbar_reply (gpointer data
,
103 static void toolbar_learn (gpointer data
,
105 static void toolbar_delete_cb (GtkWidget
*widget
,
107 static void toolbar_trash_cb (GtkWidget
*widget
,
110 static void toolbar_compose_cb (GtkWidget
*widget
,
113 static void toolbar_learn_cb (GtkWidget
*widget
,
116 static void toolbar_reply_cb (GtkWidget
*widget
,
119 static void toolbar_reply_to_all_cb (GtkWidget
*widget
,
122 static void toolbar_reply_to_list_cb (GtkWidget
*widget
,
125 static void toolbar_reply_to_sender_cb (GtkWidget
*widget
,
128 static void toolbar_forward_cb (GtkWidget
*widget
,
131 static void toolbar_prev_unread_cb (GtkWidget
*widget
,
133 static void toolbar_next_unread_cb (GtkWidget
*widget
,
136 static void toolbar_ignore_thread_cb (GtkWidget
*widget
,
139 static void toolbar_watch_thread_cb (GtkWidget
*widget
,
142 static void toolbar_print_cb (GtkWidget
*widget
,
145 static void toolbar_actions_execute_cb (GtkWidget
*widget
,
147 static void toolbar_plugins_execute_cb (GtkWidget
*widget
,
151 static void toolbar_send_cb (GtkWidget
*widget
,
153 static void toolbar_send_later_cb (GtkWidget
*widget
,
155 static void toolbar_draft_cb (GtkWidget
*widget
,
157 static void toolbar_close_cb (GtkWidget
*widget
,
159 static void toolbar_preferences_cb (GtkWidget
*widget
,
161 static void toolbar_open_mail_cb (GtkWidget
*widget
,
163 static void toolbar_insert_cb (GtkWidget
*widget
,
165 static void toolbar_attach_cb (GtkWidget
*widget
,
167 static void toolbar_sig_cb (GtkWidget
*widget
,
169 static void toolbar_ext_editor_cb (GtkWidget
*widget
,
171 static void toolbar_linewrap_current_cb (GtkWidget
*widget
,
173 static void toolbar_linewrap_all_cb (GtkWidget
*widget
,
175 static void toolbar_addrbook_cb (GtkWidget
*widget
,
178 static void toolbar_check_spelling_cb (GtkWidget
*widget
,
181 static void toolbar_cancel_inc_cb (GtkWidget
*widget
,
183 static void toolbar_cancel_send_cb (GtkWidget
*widget
,
185 static void toolbar_cancel_all_cb (GtkWidget
*widget
,
191 } toolbar_text
[] = {
192 { "A_RECEIVE_ALL", N_("Receive Mail from all Accounts") },
193 { "A_RECEIVE_CUR", N_("Receive Mail from current Account") },
194 { "A_SEND_QUEUED", N_("Send Queued Messages") },
195 { "A_COMPOSE_EMAIL", N_("Compose Email") },
196 { "A_COMPOSE_NEWS", N_("Compose News") },
197 { "A_REPLY_MESSAGE", N_("Reply to Message") },
198 { "A_REPLY_SENDER", N_("Reply to Sender") },
199 { "A_REPLY_ALL", N_("Reply to All") },
200 { "A_REPLY_ML", N_("Reply to Mailing-list") },
201 { "A_OPEN_MAIL", N_("Open email") },
202 { "A_FORWARD", N_("Forward Message") },
203 { "A_TRASH", N_("Trash Message") },
204 { "A_DELETE_REAL", N_("Delete Message") },
205 { "A_EXECUTE", N_("Execute") },
206 { "A_GOTO_PREV", N_("Go to Previous Unread Message") },
207 { "A_GOTO_NEXT", N_("Go to Next Unread Message") },
208 { "A_IGNORE_THREAD", N_("Ignore thread") },
209 { "A_WATCH_THREAD", N_("Watch thread") },
210 { "A_PRINT", N_("Print") },
211 { "A_LEARN_SPAM", N_("Learn Spam or Ham") },
212 { "A_GO_FOLDERS", N_("Open folder/Go to folder list") },
213 { "A_PREFERENCES", N_("Preferences") },
215 { "A_SEND", N_("Send Message") },
216 { "A_SENDL", N_("Put into queue folder and send later") },
217 { "A_DRAFT", N_("Save to draft folder") },
218 { "A_INSERT", N_("Insert file") },
219 { "A_ATTACH", N_("Attach file") },
220 { "A_SIG", N_("Insert signature") },
221 { "A_REP_SIG", N_("Replace signature") },
222 { "A_EXTEDITOR", N_("Edit with external editor") },
223 { "A_LINEWRAP_CURRENT", N_("Wrap long lines of current paragraph") },
224 { "A_LINEWRAP_ALL", N_("Wrap all long lines") },
225 { "A_ADDRBOOK", N_("Address book") },
227 { "A_CHECK_SPELLING", N_("Check spelling") },
229 { "A_CLAWS_ACTIONS", N_("Claws Mail Actions Feature") },
230 { "A_CANCEL_INC", N_("Cancel receiving") },
231 { "A_CANCEL_SEND", N_("Cancel sending") },
232 { "A_CANCEL_ALL", N_("Cancel receiving/sending") },
233 { "A_CLOSE", N_("Close window") },
234 { "A_SEPARATOR", N_("Separator") },
235 { "A_CLAWS_PLUGINS", N_("Claws Mail Plugins") },
238 /* struct holds configuration files and a list of
239 * currently active toolbar items
240 * TOOLBAR_MAIN, TOOLBAR_COMPOSE and TOOLBAR_MSGVIEW
244 const gchar
*conf_file
;
246 } toolbar_config
[NUM_TOOLBARS
] = {
247 { "toolbar_main.xml", NULL
},
248 { "toolbar_compose.xml", NULL
},
249 { "toolbar_msgview.xml", NULL
}
252 gint
toolbar_ret_val_from_descr(const gchar
*descr
)
256 for (i
= 0; i
< N_ACTION_VAL
; i
++) {
257 if (g_utf8_collate(gettext(toolbar_text
[i
].descr
), descr
) == 0)
264 gchar
*toolbar_ret_descr_from_val(gint val
)
266 cm_return_val_if_fail(val
>=0 && val
< N_ACTION_VAL
, NULL
);
268 return gettext(toolbar_text
[val
].descr
);
271 static gint
toolbar_ret_val_from_text(const gchar
*text
)
275 for (i
= 0; i
< N_ACTION_VAL
; i
++) {
276 if (g_utf8_collate(toolbar_text
[i
].index_str
, text
) == 0)
283 static gchar
*toolbar_ret_text_from_val(gint val
)
285 cm_return_val_if_fail(val
>=0 && val
< N_ACTION_VAL
, NULL
);
287 return toolbar_text
[val
].index_str
;
290 static gboolean
toolbar_is_duplicate(gint action
, ToolbarType source
)
294 if ((action
== A_SEPARATOR
) || (action
== A_CLAWS_ACTIONS
) || (action
== A_CLAWS_PLUGINS
))
297 for (cur
= toolbar_config
[source
].item_list
; cur
!= NULL
; cur
= cur
->next
) {
298 ToolbarItem
*item
= (ToolbarItem
*) cur
->data
;
300 if (item
->index
== action
)
306 /* depending on toolbar type this function
307 returns a list of available toolbar events being
308 displayed by prefs_toolbar
310 GList
*toolbar_get_action_items(ToolbarType source
)
315 if (source
== TOOLBAR_MAIN
) {
316 gint main_items
[] = { A_RECEIVE_ALL
, A_RECEIVE_CUR
, A_SEND_QUEUED
,
317 A_COMPOSE_EMAIL
, A_REPLY_MESSAGE
, A_REPLY_SENDER
,
318 A_REPLY_ALL
, A_REPLY_ML
, A_OPEN_MAIL
, A_FORWARD
,
319 A_TRASH
, A_DELETE_REAL
, A_EXECUTE
, A_GOTO_PREV
,
320 A_GOTO_NEXT
, A_IGNORE_THREAD
, A_WATCH_THREAD
, A_PRINT
,
321 A_ADDRBOOK
, A_LEARN_SPAM
, A_GO_FOLDERS
,
322 A_CANCEL_INC
, A_CANCEL_SEND
, A_CANCEL_ALL
, A_PREFERENCES
};
324 for (i
= 0; i
< sizeof main_items
/ sizeof main_items
[0]; i
++) {
325 items
= g_list_append(items
, gettext(toolbar_text
[main_items
[i
]].descr
));
328 else if (source
== TOOLBAR_COMPOSE
) {
329 gint comp_items
[] = { A_SEND
, A_SENDL
, A_DRAFT
,
330 A_INSERT
, A_ATTACH
, A_SIG
,
331 A_REP_SIG
, A_EXTEDITOR
, A_LINEWRAP_CURRENT
,
332 A_LINEWRAP_ALL
, A_ADDRBOOK
,
338 for (i
= 0; i
< sizeof comp_items
/ sizeof comp_items
[0]; i
++)
339 items
= g_list_append(items
, gettext(toolbar_text
[comp_items
[i
]].descr
));
341 else if (source
== TOOLBAR_MSGVIEW
) {
342 gint msgv_items
[] = { A_COMPOSE_EMAIL
, A_REPLY_MESSAGE
, A_REPLY_SENDER
,
343 A_REPLY_ALL
, A_REPLY_ML
, A_FORWARD
,
344 A_TRASH
, A_DELETE_REAL
, A_GOTO_PREV
, A_GOTO_NEXT
,
345 A_ADDRBOOK
, A_LEARN_SPAM
, A_CLOSE
};
347 for (i
= 0; i
< sizeof msgv_items
/ sizeof msgv_items
[0]; i
++)
348 items
= g_list_append(items
, gettext(toolbar_text
[msgv_items
[i
]].descr
));
354 static void toolbar_parse_item(XMLFile
*file
, ToolbarType source
)
358 ToolbarItem
*item
= NULL
;
359 gboolean rewrite
= FALSE
;
361 attr
= xml_get_current_tag_attr(file
);
362 item
= g_new0(ToolbarItem
, 1);
364 name
= ((XMLAttr
*)attr
->data
)->name
;
365 value
= ((XMLAttr
*)attr
->data
)->value
;
367 if (g_utf8_collate(name
, TOOLBAR_ICON_FILE
) == 0)
368 item
->file
= g_strdup (value
);
369 else if (g_utf8_collate(name
, TOOLBAR_ICON_TEXT
) == 0)
370 item
->text
= g_strdup (*value
? gettext(value
):"");
371 else if (g_utf8_collate(name
, TOOLBAR_ICON_ACTION
) == 0)
372 item
->index
= toolbar_ret_val_from_text(value
);
373 if (item
->index
== -1 && !strcmp(value
, "A_DELETE")) {
375 item
->index
= A_TRASH
;
377 item
->file
= g_strdup("trash_btn");
379 item
->text
= g_strdup(C_("Toolbar", "Trash"));
382 if (item
->index
== -1 && !strcmp(value
, "A_SYL_ACTIONS")) {
384 item
->index
= A_CLAWS_ACTIONS
;
387 attr
= g_list_next(attr
);
389 if (item
->index
!= -1) {
391 if (!toolbar_is_duplicate(item
->index
, source
))
392 toolbar_config
[source
].item_list
= g_slist_append(toolbar_config
[source
].item_list
,
396 toolbar_save_config_file(source
);
400 const gchar
*toolbar_get_short_text(int action
) {
402 case A_GO_FOLDERS
: return _("Folders");
403 case A_OPEN_MAIL
: return _("Open");
404 case A_RECEIVE_ALL
: return _("Get Mail");
405 case A_RECEIVE_CUR
: return _("Get");
406 case A_SEND_QUEUED
: return _("Send");
407 case A_COMPOSE_EMAIL
: return C_("Toolbar", "Compose");
408 case A_COMPOSE_NEWS
: return C_("Toolbar", "Compose");
409 case A_REPLY_MESSAGE
: return _("Reply");
410 case A_REPLY_ALL
: return _("All");
411 case A_REPLY_SENDER
: return C_("Toolbar", "Sender");
412 case A_REPLY_ML
: return _("List");
413 case A_FORWARD
: return _("Forward");
414 case A_TRASH
: return C_("Toolbar", "Trash");
415 case A_DELETE_REAL
: return _("Delete");
416 case A_LEARN_SPAM
: return _("Spam");
417 case A_GOTO_PREV
: return _("Prev");
418 case A_GOTO_NEXT
: return _("Next");
419 case A_IGNORE_THREAD
: return _("Ignore thread");
420 case A_WATCH_THREAD
: return _("Watch thread");
421 case A_PRINT
: return _("Print");
422 case A_CLOSE
: return _("Close");
423 case A_PREFERENCES
: return _("Preferences");
424 case A_SEND
: return _("Send");
425 case A_SENDL
: return _("Send later");
426 case A_DRAFT
: return _("Draft");
427 case A_INSERT
: return _("Insert");
428 case A_ATTACH
: return _("Attach");
429 case A_SIG
: return _("Insert sig.");
430 case A_REP_SIG
: return _("Replace sig.");
431 case A_EXTEDITOR
: return _("Edit");
432 case A_LINEWRAP_CURRENT
:return _("Wrap para.");
433 case A_LINEWRAP_ALL
: return _("Wrap all");
434 case A_ADDRBOOK
: return _("Address");
435 case A_CANCEL_INC
: return _("Stop");
436 case A_CANCEL_SEND
: return _("Stop");
437 case A_CANCEL_ALL
: return _("Stop all");
438 case A_EXECUTE
: return _("Execute");
440 case A_CHECK_SPELLING
: return _("Check spelling");
446 gint
toolbar_get_icon(int action
) {
448 case A_GO_FOLDERS
: return STOCK_PIXMAP_GO_FOLDERS
;
449 case A_OPEN_MAIL
: return STOCK_PIXMAP_OPEN_MAIL
;
450 case A_RECEIVE_ALL
: return STOCK_PIXMAP_MAIL_RECEIVE_ALL
;
451 case A_RECEIVE_CUR
: return STOCK_PIXMAP_MAIL_RECEIVE
;
452 case A_SEND_QUEUED
: return STOCK_PIXMAP_MAIL_SEND_QUEUE
;
453 case A_COMPOSE_EMAIL
: return STOCK_PIXMAP_MAIL_COMPOSE
;
454 case A_COMPOSE_NEWS
: return STOCK_PIXMAP_NEWS_COMPOSE
;
455 case A_REPLY_MESSAGE
: return STOCK_PIXMAP_MAIL_REPLY
;
456 case A_REPLY_ALL
: return STOCK_PIXMAP_MAIL_REPLY_TO_ALL
;
457 case A_REPLY_SENDER
: return STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR
;
458 case A_REPLY_ML
: return STOCK_PIXMAP_MAIL_REPLY_TO_LIST
;
459 case A_FORWARD
: return STOCK_PIXMAP_MAIL_FORWARD
;
460 case A_TRASH
: return STOCK_PIXMAP_TRASH
;
461 case A_DELETE_REAL
: return STOCK_PIXMAP_DELETE
;
462 case A_LEARN_SPAM
: return STOCK_PIXMAP_SPAM_BTN
;
463 case A_GOTO_PREV
: return STOCK_PIXMAP_UP_ARROW
;
464 case A_GOTO_NEXT
: return STOCK_PIXMAP_DOWN_ARROW
;
465 case A_IGNORE_THREAD
: return STOCK_PIXMAP_IGNORETHREAD
;
466 case A_WATCH_THREAD
: return STOCK_PIXMAP_WATCHTHREAD
;
467 case A_PRINT
: return STOCK_PIXMAP_PRINTER
;
468 case A_CLOSE
: return STOCK_PIXMAP_CLOSE
;
469 case A_PREFERENCES
: return STOCK_PIXMAP_PREFERENCES
;
470 case A_SEND
: return STOCK_PIXMAP_MAIL_SEND
;
471 case A_SENDL
: return STOCK_PIXMAP_MAIL_SEND_QUEUE
;
472 case A_DRAFT
: return STOCK_PIXMAP_MAIL
;
473 case A_INSERT
: return STOCK_PIXMAP_INSERT_FILE
;
474 case A_ATTACH
: return STOCK_PIXMAP_MAIL_ATTACH
;
475 case A_SIG
: return STOCK_PIXMAP_MAIL_SIGN
;
476 case A_REP_SIG
: return STOCK_PIXMAP_MAIL_SIGN
;
477 case A_EXTEDITOR
: return STOCK_PIXMAP_EDIT_EXTERN
;
478 case A_LINEWRAP_CURRENT
:return STOCK_PIXMAP_LINEWRAP_CURRENT
;
479 case A_LINEWRAP_ALL
: return STOCK_PIXMAP_LINEWRAP_ALL
;
480 case A_ADDRBOOK
: return STOCK_PIXMAP_ADDRESS_BOOK
;
481 case A_CANCEL_INC
: return STOCK_PIXMAP_CANCEL
;
482 case A_CANCEL_SEND
: return STOCK_PIXMAP_CANCEL
;
483 case A_CANCEL_ALL
: return STOCK_PIXMAP_CANCEL
;
484 case A_EXECUTE
: return STOCK_PIXMAP_EXEC
;
486 case A_CHECK_SPELLING
: return STOCK_PIXMAP_CHECK_SPELLING
;
492 static void toolbar_set_default_main(void)
496 } default_toolbar
[] = {
524 for (i
= 0; i
< sizeof(default_toolbar
) / sizeof(default_toolbar
[0]); i
++) {
526 ToolbarItem
*toolbar_item
= g_new0(ToolbarItem
, 1);
528 if (default_toolbar
[i
].action
!= A_SEPARATOR
) {
531 if (toolbar_get_icon(default_toolbar
[i
].action
) > -1) {
532 file
= stock_pixmap_get_name((StockPixmap
)toolbar_get_icon(default_toolbar
[i
].action
));
535 toolbar_item
->file
= g_strdup(file
);
536 toolbar_item
->index
= default_toolbar
[i
].action
;
537 toolbar_item
->text
= g_strdup(toolbar_get_short_text(default_toolbar
[i
].action
));
540 toolbar_item
->file
= g_strdup(TOOLBAR_TAG_SEPARATOR
);
541 toolbar_item
->index
= A_SEPARATOR
;
544 if (toolbar_item
->index
!= -1) {
545 if ( !toolbar_is_duplicate(toolbar_item
->index
, TOOLBAR_MAIN
))
546 toolbar_config
[TOOLBAR_MAIN
].item_list
=
547 g_slist_append(toolbar_config
[TOOLBAR_MAIN
].item_list
, toolbar_item
);
552 static void toolbar_set_default_compose(void)
556 } default_toolbar
[] = {
575 for (i
= 0; i
< sizeof(default_toolbar
) / sizeof(default_toolbar
[0]); i
++) {
577 ToolbarItem
*toolbar_item
= g_new0(ToolbarItem
, 1);
579 if (default_toolbar
[i
].action
!= A_SEPARATOR
) {
582 if (toolbar_get_icon(default_toolbar
[i
].action
) > -1) {
583 file
= stock_pixmap_get_name((StockPixmap
)toolbar_get_icon(default_toolbar
[i
].action
));
585 toolbar_item
->file
= g_strdup(file
);
586 toolbar_item
->index
= default_toolbar
[i
].action
;
587 toolbar_item
->text
= g_strdup(toolbar_get_short_text(default_toolbar
[i
].action
));
590 toolbar_item
->file
= g_strdup(TOOLBAR_TAG_SEPARATOR
);
591 toolbar_item
->index
= A_SEPARATOR
;
594 if (toolbar_item
->index
!= -1) {
595 if ( !toolbar_is_duplicate(toolbar_item
->index
, TOOLBAR_COMPOSE
))
596 toolbar_config
[TOOLBAR_COMPOSE
].item_list
=
597 g_slist_append(toolbar_config
[TOOLBAR_COMPOSE
].item_list
, toolbar_item
);
602 static void toolbar_set_default_msgview(void)
606 } default_toolbar
[] = {
625 for (i
= 0; i
< sizeof(default_toolbar
) / sizeof(default_toolbar
[0]); i
++) {
627 ToolbarItem
*toolbar_item
= g_new0(ToolbarItem
, 1);
629 if (default_toolbar
[i
].action
!= A_SEPARATOR
) {
631 if (toolbar_get_icon(default_toolbar
[i
].action
) > -1) {
632 file
= stock_pixmap_get_name((StockPixmap
)toolbar_get_icon(default_toolbar
[i
].action
));
635 toolbar_item
->file
= g_strdup(file
);
636 toolbar_item
->index
= default_toolbar
[i
].action
;
637 toolbar_item
->text
= g_strdup(toolbar_get_short_text(default_toolbar
[i
].action
));
640 toolbar_item
->file
= g_strdup(TOOLBAR_TAG_SEPARATOR
);
641 toolbar_item
->index
= A_SEPARATOR
;
644 if (toolbar_item
->index
!= -1) {
645 if ( !toolbar_is_duplicate(toolbar_item
->index
, TOOLBAR_MSGVIEW
))
646 toolbar_config
[TOOLBAR_MSGVIEW
].item_list
=
647 g_slist_append(toolbar_config
[TOOLBAR_MSGVIEW
].item_list
, toolbar_item
);
652 void toolbar_set_default(ToolbarType source
)
654 if (source
== TOOLBAR_MAIN
)
655 toolbar_set_default_main();
656 else if (source
== TOOLBAR_COMPOSE
)
657 toolbar_set_default_compose();
658 else if (source
== TOOLBAR_MSGVIEW
)
659 toolbar_set_default_msgview();
662 void toolbar_save_config_file(ToolbarType source
)
667 gchar
*fileSpec
= NULL
;
669 debug_print("save Toolbar Configuration to %s\n", toolbar_config
[source
].conf_file
);
671 fileSpec
= g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S
, toolbar_config
[source
].conf_file
, NULL
);
672 pfile
= prefs_write_open(fileSpec
);
675 if (fprintf(fp
, "<?xml version=\"1.0\" encoding=\"%s\" ?>\n", CS_INTERNAL
) < 0)
678 if (fprintf(fp
, "<%s>\n", TOOLBAR_TAG_INDEX
) < 0)
681 for (cur
= toolbar_config
[source
].item_list
; cur
!= NULL
; cur
= cur
->next
) {
682 ToolbarItem
*toolbar_item
= (ToolbarItem
*) cur
->data
;
684 if (toolbar_item
->index
!= A_SEPARATOR
) {
685 if (fprintf(fp
, "\t<%s %s=\"%s\" %s=\"",
687 TOOLBAR_ICON_FILE
, toolbar_item
->file
,
688 TOOLBAR_ICON_TEXT
) < 0)
690 if (xml_file_put_escape_str(fp
, toolbar_item
->text
) < 0)
692 if (fprintf(fp
, "\" %s=\"%s\"/>\n",
694 toolbar_ret_text_from_val(toolbar_item
->index
)) < 0)
697 if (fprintf(fp
, "\t<%s/>\n", TOOLBAR_TAG_SEPARATOR
) < 0)
702 if (fprintf(fp
, "</%s>\n", TOOLBAR_TAG_INDEX
) < 0)
706 if (prefs_file_close (pfile
) < 0 )
707 g_warning("failed to write toolbar configuration to file");
711 FILE_OP_ERROR(fileSpec
, "fprintf");
713 prefs_file_close_revert (pfile
);
715 g_warning("failed to open toolbar configuration file for writing");
718 void toolbar_read_config_file(ToolbarType source
)
720 XMLFile
*file
= NULL
;
721 gchar
*fileSpec
= NULL
;
724 debug_print("read Toolbar Configuration from %s\n", toolbar_config
[source
].conf_file
);
726 fileSpec
= g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S
, toolbar_config
[source
].conf_file
, NULL
);
727 file
= xml_open_file(fileSpec
);
730 toolbar_clear_list(source
);
734 || (xml_get_dtd(file
))
735 || (xml_parse_next_tag(file
))
736 || (!xml_compare_tag(file
, TOOLBAR_TAG_INDEX
))) {
737 xml_close_file(file
);
745 if (xml_parse_next_tag(file
))
748 /* Get next tag (icon, icon_text or icon_action) */
749 if (xml_compare_tag(file
, TOOLBAR_TAG_ITEM
)) {
750 toolbar_parse_item(file
, source
);
751 } else if (xml_compare_tag(file
, TOOLBAR_TAG_SEPARATOR
)) {
752 ToolbarItem
*item
= g_new0(ToolbarItem
, 1);
754 item
->file
= g_strdup(TOOLBAR_TAG_SEPARATOR
);
755 item
->index
= A_SEPARATOR
;
756 toolbar_config
[source
].item_list
=
757 g_slist_append(toolbar_config
[source
].item_list
, item
);
761 xml_close_file(file
);
764 if ((!file
) || (g_slist_length(toolbar_config
[source
].item_list
) == 0)) {
766 if (source
== TOOLBAR_MAIN
)
767 toolbar_set_default(TOOLBAR_MAIN
);
768 else if (source
== TOOLBAR_COMPOSE
)
769 toolbar_set_default(TOOLBAR_COMPOSE
);
770 else if (source
== TOOLBAR_MSGVIEW
)
771 toolbar_set_default(TOOLBAR_MSGVIEW
);
773 g_warning("refusing to write unknown Toolbar Configuration number %d", source
);
777 toolbar_save_config_file(source
);
782 * clears list of toolbar items read from configuration files
784 void toolbar_clear_list(ToolbarType source
)
786 while (toolbar_config
[source
].item_list
!= NULL
) {
787 ToolbarItem
*item
= (ToolbarItem
*) toolbar_config
[source
].item_list
->data
;
789 toolbar_config
[source
].item_list
=
790 g_slist_remove(toolbar_config
[source
].item_list
, item
);
796 g_slist_free(toolbar_config
[source
].item_list
);
801 * return list of Toolbar items
803 GSList
*toolbar_get_list(ToolbarType source
)
807 if ((source
== TOOLBAR_MAIN
) || (source
== TOOLBAR_COMPOSE
) || (source
== TOOLBAR_MSGVIEW
))
808 list
= toolbar_config
[source
].item_list
;
813 void toolbar_set_list_item(ToolbarItem
*t_item
, ToolbarType source
)
815 ToolbarItem
*toolbar_item
= g_new0(ToolbarItem
, 1);
817 toolbar_item
->file
= g_strdup(t_item
->file
);
818 toolbar_item
->text
= g_strdup(t_item
->text
);
819 toolbar_item
->index
= t_item
->index
;
821 toolbar_config
[source
].item_list
=
822 g_slist_append(toolbar_config
[source
].item_list
,
826 static void toolbar_action_execute(GtkWidget
*widget
,
834 for (cur
= action_list
; cur
!= NULL
; cur
= cur
->next
) {
835 ToolbarClawsActions
*act
= (ToolbarClawsActions
*)cur
->data
;
837 if (widget
== act
->widget
) {
838 i
= prefs_actions_find_by_name(act
->name
);
846 actions_execute(data
, i
, widget
, source
);
848 g_warning ("Error: did not find Claws Action to execute");
851 gboolean
toolbar_check_action_btns(ToolbarType type
)
853 GSList
*temp
, *curr
, *list
= toolbar_config
[type
].item_list
;
854 gboolean modified
= FALSE
;
857 while (curr
!= NULL
) {
858 ToolbarItem
*toolbar_item
= (ToolbarItem
*) curr
->data
;
862 if (toolbar_item
->index
!= A_CLAWS_ACTIONS
)
865 if (prefs_actions_find_by_name(toolbar_item
->text
) == -1) {
866 list
= g_slist_delete_link(list
, temp
);
867 g_free(toolbar_item
->file
);
868 g_free(toolbar_item
->text
);
869 g_free(toolbar_item
);
877 #define CLAWS_SET_TOOL_ITEM_TIP(widget,tip) { \
878 gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), tip); \
881 #define CLAWS_SET_ARROW_TIP(widget,tip) { \
882 gtk_menu_tool_button_set_arrow_tooltip_text(GTK_MENU_TOOL_BUTTON(widget), tip); \
885 static void activate_compose_button (Toolbar
*toolbar
,
887 ComposeButtonType type
)
889 if ((!toolbar
->compose_mail_btn
))
892 if (type
== COMPOSEBUTTON_NEWS
) {
893 gtk_tool_button_set_icon_widget(
894 GTK_TOOL_BUTTON(toolbar
->compose_mail_btn
),
895 toolbar
->compose_news_icon
);
897 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(toolbar
->compose_mail_btn
), _("Compose News message"));
899 gtk_widget_show(toolbar
->compose_news_icon
);
901 gtk_tool_button_set_icon_widget(
902 GTK_TOOL_BUTTON(toolbar
->compose_mail_btn
),
903 toolbar
->compose_mail_icon
);
905 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(toolbar
->compose_mail_btn
), _("Compose Email"));
907 gtk_widget_show(toolbar
->compose_mail_icon
);
909 toolbar
->compose_btn_type
= type
;
912 void toolbar_set_compose_button(Toolbar
*toolbar
,
913 ComposeButtonType compose_btn_type
)
915 if (toolbar
->compose_btn_type
!= compose_btn_type
)
916 activate_compose_button(toolbar
,
917 prefs_common
.toolbar_style
,
921 static void activate_learn_button (Toolbar
*toolbar
,
923 LearnButtonType type
)
925 if ((!toolbar
->learn_spam_btn
))
928 if (type
== LEARN_SPAM
) {
929 gtk_tool_button_set_icon_widget(
930 GTK_TOOL_BUTTON(toolbar
->learn_spam_btn
),
931 toolbar
->learn_spam_icon
);
932 gtk_tool_button_set_label(
933 GTK_TOOL_BUTTON(toolbar
->learn_spam_btn
),
936 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(toolbar
->learn_spam_btn
), _("Learn spam"));
938 gtk_widget_show(toolbar
->learn_spam_icon
);
940 gtk_tool_button_set_icon_widget(
941 GTK_TOOL_BUTTON(toolbar
->learn_spam_btn
),
942 toolbar
->learn_ham_icon
);
943 gtk_tool_button_set_label(
944 GTK_TOOL_BUTTON(toolbar
->learn_spam_btn
),
947 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(toolbar
->learn_spam_btn
), _("Learn ham"));
949 gtk_widget_show(toolbar
->learn_ham_icon
);
951 toolbar
->learn_btn_type
= type
;
954 void toolbar_set_learn_button(Toolbar
*toolbar
,
955 LearnButtonType learn_btn_type
)
957 if (toolbar
->learn_btn_type
!= learn_btn_type
)
958 activate_learn_button(toolbar
,
959 prefs_common
.toolbar_style
,
963 void toolbar_toggle(guint action
, gpointer data
)
965 MainWindow
*mainwin
= (MainWindow
*)data
;
969 cm_return_if_fail(mainwin
!= NULL
);
971 toolbar_style(TOOLBAR_MAIN
, action
, mainwin
);
973 list
= compose_get_compose_list();
974 for (cur
= list
; cur
!= NULL
; cur
= cur
->next
) {
975 toolbar_style(TOOLBAR_COMPOSE
, action
, cur
->data
);
977 list
= messageview_get_msgview_list();
978 for (cur
= list
; cur
!= NULL
; cur
= cur
->next
) {
979 toolbar_style(TOOLBAR_MSGVIEW
, action
, cur
->data
);
984 void toolbar_set_style(GtkWidget
*toolbar_wid
, GtkWidget
*handlebox_wid
, guint action
)
986 switch ((ToolbarStyle
)action
) {
988 gtk_widget_hide(handlebox_wid
);
991 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid
),
995 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid
),
999 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid
),
1002 case TOOLBAR_BOTH_HORIZ
:
1003 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid
),
1004 GTK_TOOLBAR_BOTH_HORIZ
);
1010 prefs_common
.toolbar_style
= (ToolbarStyle
)action
;
1011 gtk_widget_set_size_request(handlebox_wid
, 1, -1);
1013 if (prefs_common
.toolbar_style
!= TOOLBAR_NONE
) {
1014 gtk_widget_show(handlebox_wid
);
1015 gtk_widget_queue_resize(handlebox_wid
);
1019 * Change the style of toolbar
1021 static void toolbar_style(ToolbarType type
, guint action
, gpointer data
)
1023 GtkWidget
*handlebox_wid
;
1024 GtkWidget
*toolbar_wid
;
1025 MainWindow
*mainwin
= (MainWindow
*)data
;
1026 Compose
*compose
= (Compose
*)data
;
1027 MessageView
*msgview
= (MessageView
*)data
;
1029 cm_return_if_fail(data
!= NULL
);
1033 handlebox_wid
= mainwin
->handlebox
;
1034 toolbar_wid
= mainwin
->toolbar
->toolbar
;
1036 case TOOLBAR_COMPOSE
:
1037 handlebox_wid
= compose
->handlebox
;
1038 toolbar_wid
= compose
->toolbar
->toolbar
;
1040 case TOOLBAR_MSGVIEW
:
1041 handlebox_wid
= msgview
->handlebox
;
1042 toolbar_wid
= msgview
->toolbar
->toolbar
;
1048 toolbar_set_style(toolbar_wid
, handlebox_wid
, action
);
1051 /* Toolbar handling */
1052 static void toolbar_inc_cb(GtkWidget
*widget
,
1055 ToolbarItem
*toolbar_item
= (ToolbarItem
*)data
;
1056 MainWindow
*mainwin
;
1058 cm_return_if_fail(toolbar_item
!= NULL
);
1060 switch (toolbar_item
->type
) {
1062 mainwin
= (MainWindow
*)toolbar_item
->parent
;
1063 inc_mail_cb(mainwin
, 0, NULL
);
1070 static void toolbar_inc_all_cb(GtkWidget
*widget
,
1073 ToolbarItem
*toolbar_item
= (ToolbarItem
*)data
;
1074 MainWindow
*mainwin
;
1076 cm_return_if_fail(toolbar_item
!= NULL
);
1078 switch (toolbar_item
->type
) {
1080 mainwin
= (MainWindow
*)toolbar_item
->parent
;
1081 inc_all_account_mail_cb(mainwin
, 0, NULL
);
1088 static void toolbar_send_queued_cb(GtkWidget
*widget
,gpointer data
)
1090 ToolbarItem
*toolbar_item
= (ToolbarItem
*)data
;
1091 MainWindow
*mainwin
;
1093 cm_return_if_fail(toolbar_item
!= NULL
);
1095 switch (toolbar_item
->type
) {
1097 mainwin
= (MainWindow
*)toolbar_item
->parent
;
1098 send_queue_cb(mainwin
, 0, NULL
);
1105 static void toolbar_exec_cb(GtkWidget
*widget
,
1108 MainWindow
*mainwin
= get_mainwin(data
);
1110 cm_return_if_fail(mainwin
!= NULL
);
1111 summary_execute(mainwin
->summaryview
);
1115 * Delete current/selected(s) message(s)
1117 static void toolbar_trash_cb(GtkWidget
*widget
, gpointer data
)
1119 ToolbarItem
*toolbar_item
= (ToolbarItem
*)data
;
1120 MainWindow
*mainwin
;
1122 cm_return_if_fail(toolbar_item
!= NULL
);
1123 cm_return_if_fail(toolbar_item
->parent
);
1125 switch (toolbar_item
->type
) {
1126 case TOOLBAR_MSGVIEW
:
1127 messageview_delete((MessageView
*)toolbar_item
->parent
);
1130 mainwin
= (MainWindow
*)toolbar_item
->parent
;
1131 summary_delete_trash(mainwin
->summaryview
);
1134 debug_print("toolbar event not supported\n");
1140 * Delete current/selected(s) message(s)
1142 static void toolbar_delete_cb(GtkWidget
*widget
, gpointer data
)
1144 ToolbarItem
*toolbar_item
= (ToolbarItem
*)data
;
1145 MainWindow
*mainwin
;
1147 cm_return_if_fail(toolbar_item
!= NULL
);
1148 cm_return_if_fail(toolbar_item
->parent
);
1150 switch (toolbar_item
->type
) {
1151 case TOOLBAR_MSGVIEW
:
1152 messageview_delete((MessageView
*)toolbar_item
->parent
);
1155 mainwin
= (MainWindow
*)toolbar_item
->parent
;
1156 summary_delete(mainwin
->summaryview
);
1159 debug_print("toolbar event not supported\n");
1166 * Compose new message
1168 static void toolbar_compose_cb(GtkWidget
*widget
, gpointer data
)
1170 ToolbarItem
*toolbar_item
= (ToolbarItem
*)data
;
1171 MainWindow
*mainwin
;
1172 MessageView
*msgview
;
1174 cm_return_if_fail(toolbar_item
!= NULL
);
1176 switch (toolbar_item
->type
) {
1178 mainwin
= (MainWindow
*)toolbar_item
->parent
;
1179 if (mainwin
->toolbar
->compose_btn_type
== COMPOSEBUTTON_NEWS
)
1180 compose_news_cb(mainwin
, 0, NULL
);
1182 compose_mail_cb(mainwin
, 0, NULL
);
1184 case TOOLBAR_MSGVIEW
:
1185 msgview
= (MessageView
*)toolbar_item
->parent
;
1186 compose_new_with_folderitem(NULL
,
1187 msgview
->msginfo
->folder
, NULL
);
1190 debug_print("toolbar event not supported\n");
1194 static void toolbar_learn(gpointer data
, guint as_spam
)
1196 ToolbarItem
*toolbar_item
= (ToolbarItem
*)data
;
1197 MainWindow
*mainwin
;
1198 MessageView
*msgview
;
1200 cm_return_if_fail(toolbar_item
!= NULL
);
1202 switch (toolbar_item
->type
) {
1204 mainwin
= (MainWindow
*)toolbar_item
->parent
;
1206 mainwindow_learn(mainwin
, TRUE
);
1208 mainwindow_learn(mainwin
, FALSE
);
1210 case TOOLBAR_MSGVIEW
:
1211 msgview
= (MessageView
*)toolbar_item
->parent
;
1213 messageview_learn(msgview
, TRUE
);
1215 messageview_learn(msgview
, FALSE
);
1218 debug_print("toolbar event not supported\n");
1222 static void toolbar_learn_cb(GtkWidget
*widget
, gpointer data
)
1224 ToolbarItem
*toolbar_item
= (ToolbarItem
*)data
;
1225 MainWindow
*mainwin
;
1226 MessageView
*msgview
;
1228 cm_return_if_fail(toolbar_item
!= NULL
);
1230 switch (toolbar_item
->type
) {
1232 mainwin
= (MainWindow
*)toolbar_item
->parent
;
1233 if (mainwin
->toolbar
->learn_btn_type
== LEARN_SPAM
)
1234 mainwindow_learn(mainwin
, TRUE
);
1236 mainwindow_learn(mainwin
, FALSE
);
1238 case TOOLBAR_MSGVIEW
:
1239 msgview
= (MessageView
*)toolbar_item
->parent
;
1240 if (msgview
->toolbar
->learn_btn_type
== LEARN_SPAM
)
1241 messageview_learn(msgview
, TRUE
);
1243 messageview_learn(msgview
, FALSE
);
1246 debug_print("toolbar event not supported\n");
1254 static void toolbar_reply_cb(GtkWidget
*widget
, gpointer data
)
1256 toolbar_reply(data
, (prefs_common
.reply_with_quote
?
1257 COMPOSE_REPLY_WITH_QUOTE
: COMPOSE_REPLY_WITHOUT_QUOTE
));
1262 * Reply message to Sender and All recipients
1264 static void toolbar_reply_to_all_cb(GtkWidget
*widget
, gpointer data
)
1267 (prefs_common
.reply_with_quote
? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
1268 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE
));
1273 * Reply to Mailing List
1275 static void toolbar_reply_to_list_cb(GtkWidget
*widget
, gpointer data
)
1278 (prefs_common
.reply_with_quote
? COMPOSE_REPLY_TO_LIST_WITH_QUOTE
1279 : COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE
));
1284 * Reply to sender of message
1286 static void toolbar_reply_to_sender_cb(GtkWidget
*widget
, gpointer data
)
1289 (prefs_common
.reply_with_quote
? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
1290 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE
));
1296 static void toolbar_addrbook_cb(GtkWidget
*widget
, gpointer data
)
1298 ToolbarItem
*toolbar_item
= (ToolbarItem
*)data
;
1301 cm_return_if_fail(toolbar_item
!= NULL
);
1303 switch (toolbar_item
->type
) {
1305 case TOOLBAR_MSGVIEW
:
1308 case TOOLBAR_COMPOSE
:
1309 compose
= (Compose
*)toolbar_item
->parent
;
1314 #ifndef USE_ALT_ADDRBOOK
1315 addressbook_open(compose
);
1317 GError
* error
= NULL
;
1318 addressbook_connect_signals(compose
);
1319 addressbook_dbus_open(TRUE
, &error
);
1321 g_warning("%s", error
->message
);
1322 g_error_free(error
);
1329 * Forward current/selected(s) message(s)
1331 static void toolbar_forward_cb(GtkWidget
*widget
, gpointer data
)
1333 toolbar_reply(data
, (COMPOSE_FORWARD
));
1337 * Goto Prev Unread Message
1339 static void toolbar_prev_unread_cb(GtkWidget
*widget
, gpointer data
)
1341 ToolbarItem
*toolbar_item
= (ToolbarItem
*)data
;
1342 MainWindow
*mainwin
;
1343 MessageView
*msgview
;
1345 cm_return_if_fail(toolbar_item
!= NULL
);
1347 switch (toolbar_item
->type
) {
1349 mainwin
= (MainWindow
*)toolbar_item
->parent
;
1350 summary_select_prev_unread(mainwin
->summaryview
);
1353 case TOOLBAR_MSGVIEW
:
1354 msgview
= (MessageView
*)toolbar_item
->parent
;
1355 msgview
->updating
= TRUE
;
1356 summary_select_prev_unread(msgview
->mainwin
->summaryview
);
1357 msgview
->updating
= FALSE
;
1359 if (msgview
->deferred_destroy
) {
1360 debug_print("messageview got away!\n");
1361 messageview_destroy(msgview
);
1365 /* Now we need to update the messageview window */
1366 if (msgview
->mainwin
->summaryview
->selected
) {
1367 #ifndef GENERIC_UMPC
1368 MsgInfo
* msginfo
= summary_get_selected_msg(msgview
->mainwin
->summaryview
);
1371 messageview_show(msgview
, msginfo
,
1372 msgview
->all_headers
);
1375 gtk_widget_destroy(msgview
->window
);
1379 debug_print("toolbar event not supported\n");
1384 * Goto Next Unread Message
1386 static void toolbar_next_unread_cb(GtkWidget
*widget
, gpointer data
)
1388 ToolbarItem
*toolbar_item
= (ToolbarItem
*)data
;
1389 MainWindow
*mainwin
;
1390 MessageView
*msgview
;
1392 cm_return_if_fail(toolbar_item
!= NULL
);
1394 switch (toolbar_item
->type
) {
1396 mainwin
= (MainWindow
*)toolbar_item
->parent
;
1397 summary_select_next_unread(mainwin
->summaryview
);
1400 case TOOLBAR_MSGVIEW
:
1401 msgview
= (MessageView
*)toolbar_item
->parent
;
1402 msgview
->updating
= TRUE
;
1403 summary_select_next_unread(msgview
->mainwin
->summaryview
);
1404 msgview
->updating
= FALSE
;
1406 if (msgview
->deferred_destroy
) {
1407 debug_print("messageview got away!\n");
1408 messageview_destroy(msgview
);
1412 /* Now we need to update the messageview window */
1413 if (msgview
->mainwin
->summaryview
->selected
) {
1414 #ifndef GENERIC_UMPC
1415 MsgInfo
* msginfo
= summary_get_selected_msg(msgview
->mainwin
->summaryview
);
1418 messageview_show(msgview
, msginfo
,
1419 msgview
->all_headers
);
1422 gtk_widget_destroy(msgview
->window
);
1426 debug_print("toolbar event not supported\n");
1430 static void toolbar_ignore_thread_cb(GtkWidget
*widget
, gpointer data
)
1432 ToolbarItem
*toolbar_item
= (ToolbarItem
*)data
;
1433 MainWindow
*mainwin
;
1435 cm_return_if_fail(toolbar_item
!= NULL
);
1437 switch (toolbar_item
->type
) {
1439 mainwin
= (MainWindow
*) toolbar_item
->parent
;
1440 summary_toggle_ignore_thread(mainwin
->summaryview
);
1442 case TOOLBAR_MSGVIEW
:
1443 /* TODO: see toolbar_next_unread_cb() if you need
1444 * this in the message view */
1447 debug_print("toolbar event not supported\n");
1452 static void toolbar_watch_thread_cb(GtkWidget
*widget
, gpointer data
)
1454 ToolbarItem
*toolbar_item
= (ToolbarItem
*)data
;
1455 MainWindow
*mainwin
;
1457 cm_return_if_fail(toolbar_item
!= NULL
);
1459 switch (toolbar_item
->type
) {
1461 mainwin
= (MainWindow
*) toolbar_item
->parent
;
1462 summary_toggle_watch_thread(mainwin
->summaryview
);
1464 case TOOLBAR_MSGVIEW
:
1465 /* TODO: see toolbar_next_unread_cb() if you need
1466 * this in the message view */
1469 debug_print("toolbar event not supported\n");
1474 static void toolbar_cancel_inc_cb(GtkWidget
*widget
, gpointer data
)
1476 ToolbarItem
*toolbar_item
= (ToolbarItem
*)data
;
1478 cm_return_if_fail(toolbar_item
!= NULL
);
1483 static void toolbar_cancel_send_cb(GtkWidget
*widget
, gpointer data
)
1485 ToolbarItem
*toolbar_item
= (ToolbarItem
*)data
;
1487 cm_return_if_fail(toolbar_item
!= NULL
);
1491 static void toolbar_cancel_all_cb(GtkWidget
*widget
, gpointer data
)
1493 toolbar_cancel_inc_cb(widget
, data
);
1494 toolbar_cancel_send_cb(widget
, data
);
1497 static void toolbar_print_cb(GtkWidget
*widget
, gpointer data
)
1499 ToolbarItem
*toolbar_item
= (ToolbarItem
*)data
;
1500 MainWindow
*mainwin
;
1502 cm_return_if_fail(toolbar_item
!= NULL
);
1504 switch (toolbar_item
->type
) {
1506 mainwin
= (MainWindow
*) toolbar_item
->parent
;
1507 summary_print(mainwin
->summaryview
);
1509 case TOOLBAR_MSGVIEW
:
1510 /* TODO: see toolbar_next_unread_cb() if you need
1511 * this in the message view */
1514 debug_print("toolbar event not supported\n");
1519 static void toolbar_send_cb(GtkWidget
*widget
, gpointer data
)
1521 compose_toolbar_cb(A_SEND
, data
);
1524 static void toolbar_send_later_cb(GtkWidget
*widget
, gpointer data
)
1526 compose_toolbar_cb(A_SENDL
, data
);
1529 static void toolbar_draft_cb(GtkWidget
*widget
, gpointer data
)
1531 compose_toolbar_cb(A_DRAFT
, data
);
1534 static void toolbar_close_cb(GtkWidget
*widget
, gpointer data
)
1536 ToolbarItem
*toolbar_item
= (ToolbarItem
*)data
;
1537 MainWindow
*mainwin
;
1538 MessageView
*messageview
;
1541 cm_return_if_fail(toolbar_item
!= NULL
);
1543 switch (toolbar_item
->type
) {
1545 mainwin
= (MainWindow
*) toolbar_item
->parent
;
1546 app_will_exit(NULL
, mainwin
);
1548 case TOOLBAR_MSGVIEW
:
1549 messageview
= (MessageView
*)toolbar_item
->parent
;
1550 messageview_destroy(messageview
);
1552 case TOOLBAR_COMPOSE
:
1553 compose
= (Compose
*)toolbar_item
->parent
;
1554 compose_close_toolbar(compose
);
1559 static void toolbar_preferences_cb(GtkWidget
*widget
, gpointer data
)
1564 static void toolbar_open_mail_cb(GtkWidget
*widget
, gpointer data
)
1566 ToolbarItem
*toolbar_item
= (ToolbarItem
*)data
;
1567 MainWindow
*mainwin
;
1569 cm_return_if_fail(toolbar_item
!= NULL
);
1571 switch (toolbar_item
->type
) {
1573 mainwin
= (MainWindow
*) toolbar_item
->parent
;
1574 summary_open_row(NULL
, mainwin
->summaryview
);
1576 case TOOLBAR_MSGVIEW
:
1577 debug_print("toolbar event not supported\n");
1579 case TOOLBAR_COMPOSE
:
1580 debug_print("toolbar event not supported\n");
1585 static void toolbar_insert_cb(GtkWidget
*widget
, gpointer data
)
1587 compose_toolbar_cb(A_INSERT
, data
);
1590 static void toolbar_attach_cb(GtkWidget
*widget
, gpointer data
)
1592 compose_toolbar_cb(A_ATTACH
, data
);
1595 static void toolbar_sig_cb(GtkWidget
*widget
, gpointer data
)
1597 compose_toolbar_cb(A_SIG
, data
);
1600 static void toolbar_replace_sig_cb(GtkWidget
*widget
, gpointer data
)
1602 compose_toolbar_cb(A_REP_SIG
, data
);
1605 static void toolbar_ext_editor_cb(GtkWidget
*widget
, gpointer data
)
1607 compose_toolbar_cb(A_EXTEDITOR
, data
);
1610 static void toolbar_linewrap_current_cb(GtkWidget
*widget
, gpointer data
)
1612 compose_toolbar_cb(A_LINEWRAP_CURRENT
, data
);
1615 static void toolbar_linewrap_all_cb(GtkWidget
*widget
, gpointer data
)
1617 compose_toolbar_cb(A_LINEWRAP_ALL
, data
);
1621 static void toolbar_check_spelling_cb(GtkWidget
*widget
, gpointer data
)
1623 compose_toolbar_cb(A_CHECK_SPELLING
, data
);
1627 * Execute actions from toolbar
1629 static void toolbar_actions_execute_cb(GtkWidget
*widget
, gpointer data
)
1631 ToolbarItem
*toolbar_item
= (ToolbarItem
*)data
;
1632 GSList
*action_list
;
1633 MainWindow
*mainwin
;
1635 MessageView
*msgview
;
1636 gpointer parent
= toolbar_item
->parent
;
1638 cm_return_if_fail(toolbar_item
!= NULL
);
1640 switch (toolbar_item
->type
) {
1642 mainwin
= (MainWindow
*)parent
;
1643 action_list
= mainwin
->toolbar
->action_list
;
1645 case TOOLBAR_COMPOSE
:
1646 compose
= (Compose
*)parent
;
1647 action_list
= compose
->toolbar
->action_list
;
1649 case TOOLBAR_MSGVIEW
:
1650 msgview
= (MessageView
*)parent
;
1651 action_list
= msgview
->toolbar
->action_list
;
1654 debug_print("toolbar event not supported\n");
1657 toolbar_action_execute(widget
, action_list
, parent
, toolbar_item
->type
);
1660 static void toolbar_plugins_execute_cb(GtkWidget
*widget
, gpointer data
)
1662 ToolbarItem
*toolbar_item
= data
;
1663 prefs_toolbar_execute_plugin_item(toolbar_item
->parent
, toolbar_item
->type
, toolbar_item
->text
);
1666 static MainWindow
*get_mainwin(gpointer data
)
1668 ToolbarItem
*toolbar_item
= (ToolbarItem
*)data
;
1669 MainWindow
*mainwin
= NULL
;
1670 MessageView
*msgview
;
1672 cm_return_val_if_fail(toolbar_item
!= NULL
, NULL
);
1674 switch(toolbar_item
->type
) {
1676 mainwin
= (MainWindow
*)toolbar_item
->parent
;
1678 case TOOLBAR_MSGVIEW
:
1679 msgview
= (MessageView
*)toolbar_item
->parent
;
1680 mainwin
= (MainWindow
*)msgview
->mainwin
;
1689 static void toolbar_go_folders_cb(GtkWidget
*widget
, gpointer data
)
1691 ToolbarItem
*toolbar_item
= (ToolbarItem
*)data
;
1692 MainWindow
*mainwin
= NULL
;
1693 switch(toolbar_item
->type
) {
1695 mainwin
= (MainWindow
*)toolbar_item
->parent
;
1698 g_warning("wrong toolbar type");
1702 if (!mainwin
->in_folder
) {
1703 FolderItem
*item
= folderview_get_selected_item(mainwin
->folderview
);
1705 folderview_select(mainwin
->folderview
, item
);
1708 folderview_grab_focus(mainwin
->folderview
);
1709 mainwindow_exit_folder(mainwin
);
1713 static void toolbar_buttons_cb(GtkWidget
*widget
,
1720 void (*func
)(GtkWidget
*widget
, gpointer data
);
1722 { A_RECEIVE_ALL
, toolbar_inc_all_cb
},
1723 { A_RECEIVE_CUR
, toolbar_inc_cb
},
1724 { A_SEND_QUEUED
, toolbar_send_queued_cb
},
1725 { A_COMPOSE_EMAIL
, toolbar_compose_cb
},
1726 { A_COMPOSE_NEWS
, toolbar_compose_cb
},
1727 { A_REPLY_MESSAGE
, toolbar_reply_cb
},
1728 { A_REPLY_SENDER
, toolbar_reply_to_sender_cb
},
1729 { A_REPLY_ALL
, toolbar_reply_to_all_cb
},
1730 { A_REPLY_ML
, toolbar_reply_to_list_cb
},
1731 { A_FORWARD
, toolbar_forward_cb
},
1732 { A_TRASH
, toolbar_trash_cb
},
1733 { A_DELETE_REAL
, toolbar_delete_cb
},
1734 { A_EXECUTE
, toolbar_exec_cb
},
1735 { A_GOTO_PREV
, toolbar_prev_unread_cb
},
1736 { A_GOTO_NEXT
, toolbar_next_unread_cb
},
1737 { A_IGNORE_THREAD
, toolbar_ignore_thread_cb
},
1738 { A_WATCH_THREAD
, toolbar_watch_thread_cb
},
1739 { A_PRINT
, toolbar_print_cb
},
1740 { A_LEARN_SPAM
, toolbar_learn_cb
},
1741 { A_GO_FOLDERS
, toolbar_go_folders_cb
},
1743 { A_SEND
, toolbar_send_cb
},
1744 { A_SENDL
, toolbar_send_later_cb
},
1745 { A_DRAFT
, toolbar_draft_cb
},
1746 { A_OPEN_MAIL
, toolbar_open_mail_cb
},
1747 { A_CLOSE
, toolbar_close_cb
},
1748 { A_PREFERENCES
, toolbar_preferences_cb
},
1749 { A_INSERT
, toolbar_insert_cb
},
1750 { A_ATTACH
, toolbar_attach_cb
},
1751 { A_SIG
, toolbar_sig_cb
},
1752 { A_REP_SIG
, toolbar_replace_sig_cb
},
1753 { A_EXTEDITOR
, toolbar_ext_editor_cb
},
1754 { A_LINEWRAP_CURRENT
, toolbar_linewrap_current_cb
},
1755 { A_LINEWRAP_ALL
, toolbar_linewrap_all_cb
},
1756 { A_ADDRBOOK
, toolbar_addrbook_cb
},
1758 { A_CHECK_SPELLING
, toolbar_check_spelling_cb
},
1760 { A_CLAWS_ACTIONS
, toolbar_actions_execute_cb
},
1761 { A_CANCEL_INC
, toolbar_cancel_inc_cb
},
1762 { A_CANCEL_SEND
, toolbar_cancel_send_cb
},
1763 { A_CANCEL_ALL
, toolbar_cancel_all_cb
},
1764 { A_CLAWS_PLUGINS
, toolbar_plugins_execute_cb
},
1767 num_items
= sizeof(callbacks
)/sizeof(callbacks
[0]);
1769 for (i
= 0; i
< num_items
; i
++) {
1770 if (callbacks
[i
].index
== item
->index
) {
1771 callbacks
[i
].func(widget
, item
);
1776 #ifndef GENERIC_UMPC
1777 #define TOOLBAR_ITEM(item,icon,text,tooltip) { \
1778 item = GTK_WIDGET(gtk_tool_button_new(icon, text)); \
1779 gtkut_widget_set_can_focus(gtk_bin_get_child(GTK_BIN(item)), FALSE); \
1780 gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE); \
1781 gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE); \
1782 g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item); \
1783 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1); \
1784 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(item), \
1788 #define TOOLBAR_MENUITEM(item,icon,text,tooltip,menutip) { \
1789 GtkWidget *child = NULL, *btn = NULL, *arr = NULL; \
1790 GList *gchild = NULL; \
1791 item = GTK_WIDGET(gtk_menu_tool_button_new(icon, text)); \
1792 gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE); \
1793 gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE); \
1794 g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item); \
1795 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1); \
1796 CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(item), \
1798 CLAWS_SET_ARROW_TIP(GTK_MENU_TOOL_BUTTON(item), menutip); \
1799 child = gtk_bin_get_child(GTK_BIN(item)); \
1800 gchild = gtk_container_get_children( \
1801 GTK_CONTAINER(child)); \
1802 btn = (GtkWidget *)gchild->data; \
1803 gtkut_widget_set_can_focus(btn, FALSE); \
1804 arr = (GtkWidget *)(gchild->next?gchild->next->data:NULL); \
1805 gtkut_widget_set_can_focus(arr, FALSE); \
1806 g_list_free(gchild); \
1807 gchild = gtk_container_get_children(GTK_CONTAINER(arr)); \
1808 gtk_widget_set_size_request(GTK_WIDGET(gchild->data), 9, -1); \
1809 g_list_free(gchild); \
1812 #define TOOLBAR_ITEM(item,icon,text,tooltip) { \
1813 item = GTK_WIDGET(gtk_tool_button_new(icon, text)); \
1814 gtkut_widget_set_can_focus(gtk_bin_get_child(GTK_BIN(item)), FALSE); \
1815 gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE); \
1816 gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE); \
1817 g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item); \
1818 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1); \
1821 #define TOOLBAR_MENUITEM(item,icon,text,tooltip,menutip) { \
1822 GtkWidget *child = NULL, *btn = NULL, *arr = NULL; \
1823 GList *gchild = NULL; \
1824 item = GTK_WIDGET(gtk_menu_tool_button_new(icon, text)); \
1825 gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE); \
1826 gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE); \
1827 g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item); \
1828 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1); \
1829 child = gtk_bin_get_child(GTK_BIN(item)); \
1830 gchild = gtk_container_get_children( \
1831 GTK_CONTAINER(child)); \
1832 btn = (GtkWidget *)gchild->data; \
1833 gtkut_widget_set_can_focus(btn, FALSE); \
1834 arr = (GtkWidget *)(gchild->next?gchild->next->data:NULL); \
1835 gtkut_widget_set_can_focus(arr, FALSE); \
1836 g_list_free(gchild); \
1837 gchild = gtk_container_get_children(GTK_CONTAINER(arr)); \
1838 gtk_widget_set_size_request(GTK_WIDGET(gchild->data), 9, -1); \
1839 g_list_free(gchild); \
1843 #define ADD_MENU_ITEM(name,cb,data) { \
1844 item = gtk_menu_item_new_with_mnemonic(name); \
1845 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); \
1846 g_signal_connect(G_OBJECT(item), "activate", \
1849 g_object_set_data(G_OBJECT(item), "int-value", GINT_TO_POINTER(data)); \
1850 gtk_widget_show(item); \
1853 static void toolbar_reply_menu_cb(GtkWidget
*widget
, gpointer data
)
1855 gpointer int_value
= g_object_get_data(G_OBJECT(widget
), "int-value");
1856 ToolbarItem
*toolbar_item
= (ToolbarItem
*)data
;
1858 toolbar_reply(toolbar_item
, GPOINTER_TO_INT(int_value
));
1861 static void toolbar_learn_menu_cb(GtkWidget
*widget
, gpointer data
)
1863 gpointer int_value
= g_object_get_data(G_OBJECT(widget
), "int-value");
1864 ToolbarItem
*toolbar_item
= (ToolbarItem
*)data
;
1866 toolbar_learn(toolbar_item
, GPOINTER_TO_INT(int_value
));
1870 * Create a new toolbar with specified type
1871 * if a callback list is passed it will be used before the
1872 * common callback list
1874 Toolbar
*toolbar_create(ToolbarType type
,
1875 GtkWidget
*container
,
1878 ToolbarItem
*toolbar_item
;
1881 GtkWidget
*icon_wid
= NULL
;
1882 GtkWidget
*icon_news
;
1883 GtkWidget
*icon_ham
;
1885 ToolbarClawsActions
*action_item
;
1887 GSList
*toolbar_list
;
1888 Toolbar
*toolbar_data
;
1890 toolbar_read_config_file(type
);
1891 toolbar_list
= toolbar_get_list(type
);
1893 toolbar_data
= g_new0(Toolbar
, 1);
1895 toolbar
= gtk_toolbar_new();
1897 gtk_orientable_set_orientation(GTK_ORIENTABLE(toolbar
), GTK_ORIENTATION_HORIZONTAL
);
1899 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar
), GTK_TOOLBAR_BOTH
);
1900 gtk_toolbar_set_show_arrow(GTK_TOOLBAR(toolbar
), TRUE
);
1902 for (cur
= toolbar_list
; cur
!= NULL
; cur
= cur
->next
) {
1904 if (g_ascii_strcasecmp(((ToolbarItem
*)cur
->data
)->file
, TOOLBAR_TAG_SEPARATOR
) == 0) {
1905 gtk_toolbar_insert(GTK_TOOLBAR(toolbar
), gtk_separator_tool_item_new(), -1);
1909 toolbar_item
= g_new0(ToolbarItem
, 1);
1910 toolbar_item
->index
= ((ToolbarItem
*)cur
->data
)->index
;
1911 toolbar_item
->file
= g_strdup(((ToolbarItem
*)cur
->data
)->file
);
1912 toolbar_item
->text
= g_strdup(((ToolbarItem
*)cur
->data
)->text
);
1913 toolbar_item
->parent
= data
;
1914 toolbar_item
->type
= type
;
1916 /* collect toolbar items in list to keep track */
1917 toolbar_data
->item_list
=
1918 g_slist_append(toolbar_data
->item_list
,
1920 icon_wid
= stock_pixmap_widget(stock_pixmap_get_icon(toolbar_item
->file
));
1922 switch (toolbar_item
->index
) {
1925 TOOLBAR_ITEM(item
,icon_wid
,toolbar_item
->text
,_("Go to folder list"));
1926 toolbar_data
->folders_btn
= item
;
1929 TOOLBAR_MENUITEM(item
,icon_wid
,toolbar_item
->text
,
1930 _("Receive Mail from all Accounts"),
1931 _("Receive Mail from selected Account"));
1932 toolbar_data
->getall_btn
= item
;
1935 TOOLBAR_ITEM(item
,icon_wid
,toolbar_item
->text
, _("Receive Mail from current Account"));
1936 toolbar_data
->get_btn
= item
;
1939 TOOLBAR_ITEM(item
,icon_wid
,toolbar_item
->text
,_("Send Queued Messages"));
1940 toolbar_data
->send_btn
= item
;
1943 TOOLBAR_ITEM(item
,icon_wid
,toolbar_item
->text
,_("Close window"));
1944 toolbar_data
->close_window_btn
= item
;
1947 TOOLBAR_ITEM(item
,icon_wid
,toolbar_item
->text
,_("Open preferences"));
1948 toolbar_data
->preferences_btn
= item
;
1951 TOOLBAR_ITEM(item
,icon_wid
,toolbar_item
->text
,_("Open email"));
1952 toolbar_data
->open_mail_btn
= item
;
1954 case A_COMPOSE_EMAIL
:
1955 #ifndef GENERIC_UMPC
1956 TOOLBAR_MENUITEM(item
,icon_wid
,toolbar_item
->text
,
1958 _("Compose with selected Account"));
1959 toolbar_data
->compose_mail_btn
= item
;
1960 toolbar_data
->compose_mail_icon
= icon_wid
;
1961 g_object_ref(toolbar_data
->compose_mail_icon
);
1963 icon_news
= stock_pixmap_widget(STOCK_PIXMAP_NEWS_COMPOSE
);
1964 toolbar_data
->compose_news_icon
= icon_news
;
1965 g_object_ref(toolbar_data
->compose_news_icon
);
1967 TOOLBAR_ITEM(item
,icon_wid
,toolbar_item
->text
,
1968 _("Compose Email"));
1969 toolbar_data
->compose_mail_btn
= item
;
1970 toolbar_data
->compose_mail_icon
= icon_wid
;
1972 icon_news
= stock_pixmap_widget(STOCK_PIXMAP_NEWS_COMPOSE
);
1973 toolbar_data
->compose_news_icon
= icon_news
;
1977 TOOLBAR_MENUITEM(item
,icon_wid
,toolbar_item
->text
,
1980 toolbar_data
->learn_spam_btn
= item
;
1981 toolbar_data
->learn_spam_icon
= icon_wid
;
1982 g_object_ref(toolbar_data
->learn_spam_icon
);
1984 icon_ham
= stock_pixmap_widget(STOCK_PIXMAP_HAM_BTN
);
1985 toolbar_data
->learn_ham_icon
= icon_ham
;
1986 g_object_ref(toolbar_data
->learn_ham_icon
);
1988 menu
= gtk_menu_new();
1989 ADD_MENU_ITEM(_("Learn as _Spam"), toolbar_learn_menu_cb
, TRUE
);
1990 ADD_MENU_ITEM(_("Learn as _Ham"), toolbar_learn_menu_cb
, FALSE
);
1991 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data
->learn_spam_btn
), menu
);
1993 case A_REPLY_MESSAGE
:
1994 #ifndef GENERIC_UMPC
1995 TOOLBAR_MENUITEM(item
,icon_wid
,toolbar_item
->text
,
1996 _("Reply to Message"),
1997 _("Reply to Message options"));
1998 toolbar_data
->reply_btn
= item
;
2000 menu
= gtk_menu_new();
2001 ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb
, COMPOSE_REPLY_WITH_QUOTE
);
2002 ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb
, COMPOSE_REPLY_WITHOUT_QUOTE
);
2003 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data
->reply_btn
), menu
);
2005 TOOLBAR_ITEM(item
,icon_wid
,toolbar_item
->text
,
2006 _("Reply to Message"));
2007 toolbar_data
->reply_btn
= item
;
2010 case A_REPLY_SENDER
:
2011 #ifndef GENERIC_UMPC
2012 TOOLBAR_MENUITEM(item
,icon_wid
,toolbar_item
->text
,
2013 _("Reply to Sender"),
2014 _("Reply to Sender options"));
2015 toolbar_data
->replysender_btn
= item
;
2017 menu
= gtk_menu_new();
2018 ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb
, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
);
2019 ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb
, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE
);
2020 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data
->replysender_btn
), menu
);
2022 TOOLBAR_ITEM(item
,icon_wid
,toolbar_item
->text
,
2023 _("Reply to Sender"));
2024 toolbar_data
->replysender_btn
= item
;
2028 #ifndef GENERIC_UMPC
2029 TOOLBAR_MENUITEM(item
,icon_wid
,toolbar_item
->text
,
2031 _("Reply to All options"));
2032 toolbar_data
->replyall_btn
= item
;
2034 menu
= gtk_menu_new();
2035 ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb
, COMPOSE_REPLY_TO_ALL_WITH_QUOTE
);
2036 ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb
, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE
);
2037 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data
->replyall_btn
), menu
);
2039 TOOLBAR_ITEM(item
,icon_wid
,toolbar_item
->text
,
2041 toolbar_data
->replyall_btn
= item
;
2045 #ifndef GENERIC_UMPC
2046 TOOLBAR_MENUITEM(item
,icon_wid
,toolbar_item
->text
,
2047 _("Reply to Mailing-list"),
2048 _("Reply to Mailing-list options"));
2049 toolbar_data
->replylist_btn
= item
;
2051 menu
= gtk_menu_new();
2052 ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb
, COMPOSE_REPLY_TO_LIST_WITH_QUOTE
);
2053 ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb
, COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE
);
2054 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data
->replylist_btn
), menu
);
2056 TOOLBAR_ITEM(item
,icon_wid
,toolbar_item
->text
,
2057 _("Reply to Mailing-list"));
2058 toolbar_data
->replylist_btn
= item
;
2062 #ifndef GENERIC_UMPC
2063 TOOLBAR_MENUITEM(item
,icon_wid
,toolbar_item
->text
,
2064 _("Forward Message"),
2065 _("Forward Message options"));
2066 toolbar_data
->fwd_btn
= item
;
2068 menu
= gtk_menu_new();
2069 ADD_MENU_ITEM(_("_Forward"), toolbar_reply_menu_cb
, COMPOSE_FORWARD_INLINE
);
2070 ADD_MENU_ITEM(_("For_ward as attachment"), toolbar_reply_menu_cb
, COMPOSE_FORWARD_AS_ATTACH
);
2071 ADD_MENU_ITEM(_("Redirec_t"), toolbar_reply_menu_cb
, COMPOSE_REDIRECT
);
2072 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data
->fwd_btn
), menu
);
2074 TOOLBAR_ITEM(item
,icon_wid
,toolbar_item
->text
,
2075 _("Forward Message"));
2076 toolbar_data
->fwd_btn
= item
;
2080 TOOLBAR_ITEM(item
,icon_wid
,toolbar_item
->text
,_("Trash Message"));
2081 toolbar_data
->trash_btn
= item
;
2084 TOOLBAR_ITEM(item
,icon_wid
,toolbar_item
->text
,_("Delete Message"));
2085 toolbar_data
->delete_btn
= item
;
2088 TOOLBAR_ITEM(item
,icon_wid
,toolbar_item
->text
,_("Execute"));
2089 toolbar_data
->exec_btn
= item
;
2092 TOOLBAR_ITEM(item
,icon_wid
,toolbar_item
->text
,_("Go to Previous Unread Message"));
2093 toolbar_data
->prev_btn
= item
;
2096 TOOLBAR_ITEM(item
,icon_wid
,toolbar_item
->text
,_("Go to Next Unread Message"));
2097 toolbar_data
->next_btn
= item
;
2100 /* Compose Toolbar */
2102 TOOLBAR_ITEM(item
,icon_wid
,toolbar_item
->text
,_("Send Message"));
2103 toolbar_data
->send_btn
= item
;
2106 TOOLBAR_ITEM(item
,icon_wid
,toolbar_item
->text
,_("Put into queue folder and send later"));
2107 toolbar_data
->sendl_btn
= item
;
2110 TOOLBAR_ITEM(item
,icon_wid
,toolbar_item
->text
,_("Save to draft folder"));
2111 toolbar_data
->draft_btn
= item
;
2114 TOOLBAR_ITEM(item
,icon_wid
,toolbar_item
->text
,_("Insert file"));
2115 toolbar_data
->insert_btn
= item
;
2118 TOOLBAR_ITEM(item
,icon_wid
,toolbar_item
->text
,_("Attach file"));
2119 toolbar_data
->attach_btn
= item
;
2122 TOOLBAR_ITEM(item
,icon_wid
,toolbar_item
->text
,_("Insert signature"));
2123 toolbar_data
->sig_btn
= item
;
2126 TOOLBAR_ITEM(item
,icon_wid
,toolbar_item
->text
,_("Replace signature"));
2127 toolbar_data
->repsig_btn
= item
;
2130 TOOLBAR_ITEM(item
,icon_wid
,toolbar_item
->text
,_("Edit with external editor"));
2131 toolbar_data
->exteditor_btn
= item
;
2133 case A_LINEWRAP_CURRENT
:
2134 TOOLBAR_ITEM(item
,icon_wid
,toolbar_item
->text
,_("Wrap long lines of current paragraph"));
2135 toolbar_data
->linewrap_current_btn
= item
;
2137 case A_LINEWRAP_ALL
:
2138 TOOLBAR_ITEM(item
,icon_wid
,toolbar_item
->text
,_("Wrap all long lines"));
2139 toolbar_data
->linewrap_all_btn
= item
;
2142 TOOLBAR_ITEM(item
,icon_wid
,toolbar_item
->text
,_("Address book"));
2143 toolbar_data
->addrbook_btn
= item
;
2146 case A_CHECK_SPELLING
:
2147 TOOLBAR_ITEM(item
,icon_wid
,toolbar_item
->text
,_("Check spelling"));
2148 toolbar_data
->spellcheck_btn
= item
;
2152 case A_CLAWS_ACTIONS
:
2153 TOOLBAR_ITEM(item
,icon_wid
,toolbar_item
->text
,toolbar_item
->text
);
2154 action_item
= g_new0(ToolbarClawsActions
, 1);
2155 action_item
->widget
= item
;
2156 action_item
->name
= g_strdup(toolbar_item
->text
);
2158 toolbar_data
->action_list
=
2159 g_slist_append(toolbar_data
->action_list
,
2163 TOOLBAR_ITEM(item
,icon_wid
,toolbar_item
->text
,_("Cancel receiving"));
2164 toolbar_data
->cancel_inc_btn
= item
;
2167 TOOLBAR_ITEM(item
,icon_wid
,toolbar_item
->text
,_("Cancel sending"));
2168 toolbar_data
->cancel_send_btn
= item
;
2171 TOOLBAR_ITEM(item
,icon_wid
,toolbar_item
->text
,_("Cancel receiving/sending"));
2172 toolbar_data
->cancel_all_btn
= item
;
2174 case A_CLAWS_PLUGINS
:
2175 TOOLBAR_ITEM(item
,icon_wid
,toolbar_item
->text
, toolbar_item
->text
);
2178 TOOLBAR_ITEM(item
,icon_wid
,toolbar_item
->text
,
2179 toolbar_ret_descr_from_val(toolbar_item
->index
));
2180 /* find and set the tool tip text */
2185 toolbar_data
->toolbar
= toolbar
;
2187 gtk_widget_show_all(toolbar
);
2189 if (type
== TOOLBAR_MAIN
) {
2191 MainWindow
*mainwin
= mainwindow_get_mainwindow();
2192 GtkWidget
*progressbar
= gtk_progress_bar_new();
2193 item
= GTK_WIDGET(gtk_tool_item_new());
2194 gtk_container_add (GTK_CONTAINER (item
), progressbar
);
2195 gtk_widget_show(item
);
2196 gtk_widget_set_size_request(progressbar
, 84, -1);
2197 gtk_toolbar_insert(GTK_TOOLBAR(toolbar
), GTK_TOOL_ITEM(item
), -1);
2198 mainwin
->progressbar
= progressbar
;
2200 activate_compose_button(toolbar_data
,
2201 prefs_common
.toolbar_style
,
2202 toolbar_data
->compose_btn_type
);
2204 if (type
!= TOOLBAR_COMPOSE
)
2205 activate_learn_button(toolbar_data
, prefs_common
.toolbar_style
,
2208 gtk_container_add(GTK_CONTAINER(container
), toolbar
);
2209 gtk_container_set_border_width(GTK_CONTAINER(container
), 0);
2211 return toolbar_data
;
2215 * Free toolbar structures
2217 void toolbar_destroy(Toolbar
* toolbar
) {
2219 TOOLBAR_DESTROY_ITEMS(toolbar
->item_list
);
2220 TOOLBAR_DESTROY_ACTIONS(toolbar
->action_list
);
2223 void toolbar_update(ToolbarType type
, gpointer data
)
2225 Toolbar
*toolbar_data
;
2226 GtkWidget
*handlebox
;
2227 MainWindow
*mainwin
= (MainWindow
*)data
;
2228 Compose
*compose
= (Compose
*)data
;
2229 MessageView
*msgview
= (MessageView
*)data
;
2231 #ifndef GENERIC_UMPC
2234 toolbar_data
= mainwin
->toolbar
;
2235 handlebox
= mainwin
->handlebox
;
2237 case TOOLBAR_COMPOSE
:
2238 toolbar_data
= compose
->toolbar
;
2239 handlebox
= compose
->handlebox
;
2241 case TOOLBAR_MSGVIEW
:
2242 toolbar_data
= msgview
->toolbar
;
2243 handlebox
= msgview
->handlebox
;
2249 gtk_container_remove(GTK_CONTAINER(handlebox
),
2250 GTK_WIDGET(toolbar_data
->toolbar
));
2252 toolbar_init(toolbar_data
);
2253 toolbar_data
= toolbar_create(type
, handlebox
, data
);
2257 toolbar_data
= mainwin
->toolbar
;
2258 handlebox
= mainwin
->window
;
2260 case TOOLBAR_COMPOSE
:
2261 toolbar_data
= compose
->toolbar
;
2262 handlebox
= compose
->window
;
2264 case TOOLBAR_MSGVIEW
:
2265 toolbar_data
= msgview
->toolbar
;
2266 handlebox
= msgview
->window
;
2271 toolbar_init(toolbar_data
);
2272 toolbar_data
= toolbar_create(type
, handlebox
, data
);
2277 mainwin
->toolbar
= toolbar_data
;
2279 case TOOLBAR_COMPOSE
:
2280 compose
->toolbar
= toolbar_data
;
2282 case TOOLBAR_MSGVIEW
:
2283 msgview
->toolbar
= toolbar_data
;
2287 toolbar_style(type
, prefs_common
.toolbar_style
, data
);
2289 if (type
== TOOLBAR_MAIN
) {
2290 toolbar_main_set_sensitive((MainWindow
*)data
);
2291 account_set_menu_only_toolbar();
2295 #define GTK_BUTTON_SET_SENSITIVE(widget,sensitive) { \
2296 gtk_widget_set_sensitive(widget, sensitive); \
2299 void toolbar_main_set_sensitive(gpointer data
)
2301 SensitiveCondMask state
;
2303 MainWindow
*mainwin
= (MainWindow
*)data
;
2304 Toolbar
*toolbar
= mainwin
->toolbar
;
2306 GSList
*entry_list
= NULL
;
2308 typedef struct _Entry Entry
;
2311 SensitiveCondMask cond
;
2315 #define SET_WIDGET_COND(w, ...) \
2317 Entry *e = g_new0(Entry, 1); \
2319 e->cond = main_window_get_mask(__VA_ARGS__, -1); \
2320 entry_list = g_slist_append(entry_list, e); \
2323 /* match all bit flags */
2325 if (toolbar
->get_btn
)
2326 SET_WIDGET_COND(toolbar
->get_btn
,
2327 M_HAVE_ACCOUNT
, M_UNLOCKED
, M_HAVE_RETRIEVABLE_ACCOUNT
);
2329 if (toolbar
->getall_btn
) {
2330 SET_WIDGET_COND(toolbar
->getall_btn
,
2331 M_HAVE_ACCOUNT
, M_UNLOCKED
, M_HAVE_ANY_RETRIEVABLE_ACCOUNT
);
2333 if (toolbar
->send_btn
) {
2334 SET_WIDGET_COND(toolbar
->send_btn
,
2335 M_HAVE_QUEUED_MAILS
);
2337 if (toolbar
->compose_mail_btn
) {
2338 SET_WIDGET_COND(toolbar
->compose_mail_btn
,
2341 if (toolbar
->close_window_btn
) {
2342 SET_WIDGET_COND(toolbar
->close_window_btn
,
2345 if (toolbar
->open_mail_btn
) {
2346 SET_WIDGET_COND(toolbar
->open_mail_btn
,
2347 M_TARGET_EXIST
, M_SUMMARY_ISLIST
);
2349 if (toolbar
->reply_btn
) {
2350 SET_WIDGET_COND(toolbar
->reply_btn
,
2351 M_HAVE_ACCOUNT
, M_TARGET_EXIST
, M_SUMMARY_ISLIST
);
2353 if (toolbar
->replyall_btn
) {
2354 SET_WIDGET_COND(toolbar
->replyall_btn
,
2355 M_HAVE_ACCOUNT
, M_TARGET_EXIST
, M_SUMMARY_ISLIST
);
2357 if (toolbar
->replylist_btn
) {
2358 SET_WIDGET_COND(toolbar
->replylist_btn
,
2359 M_HAVE_ACCOUNT
, M_TARGET_EXIST
, M_SUMMARY_ISLIST
);
2361 if (toolbar
->replysender_btn
) {
2362 SET_WIDGET_COND(toolbar
->replysender_btn
,
2363 M_HAVE_ACCOUNT
, M_TARGET_EXIST
, M_SUMMARY_ISLIST
);
2365 if (toolbar
->fwd_btn
) {
2366 SET_WIDGET_COND(toolbar
->fwd_btn
,
2367 M_HAVE_ACCOUNT
, M_TARGET_EXIST
, M_SUMMARY_ISLIST
);
2370 if (prefs_common
.next_unread_msg_dialog
== NEXTUNREADMSGDIALOG_ASSUME_NO
) {
2371 SET_WIDGET_COND(toolbar
->next_btn
, M_MSG_EXIST
, M_SUMMARY_ISLIST
);
2373 SET_WIDGET_COND(toolbar
->next_btn
, -1);
2376 if (toolbar
->trash_btn
)
2377 SET_WIDGET_COND(toolbar
->trash_btn
,
2378 M_TARGET_EXIST
, M_ALLOW_DELETE
, M_NOT_NEWS
);
2380 if (toolbar
->delete_btn
)
2381 SET_WIDGET_COND(toolbar
->delete_btn
,
2382 M_TARGET_EXIST
, M_ALLOW_DELETE
);
2384 if (toolbar
->exec_btn
)
2385 SET_WIDGET_COND(toolbar
->exec_btn
,
2388 if (toolbar
->learn_spam_btn
)
2389 SET_WIDGET_COND(toolbar
->learn_spam_btn
,
2390 M_TARGET_EXIST
, M_CAN_LEARN_SPAM
, M_SUMMARY_ISLIST
);
2392 if (toolbar
->cancel_inc_btn
)
2393 SET_WIDGET_COND(toolbar
->cancel_inc_btn
,
2396 if (toolbar
->cancel_send_btn
)
2397 SET_WIDGET_COND(toolbar
->cancel_send_btn
,
2400 for (cur
= toolbar
->action_list
; cur
!= NULL
; cur
= cur
->next
) {
2401 ToolbarClawsActions
*act
= (ToolbarClawsActions
*)cur
->data
;
2403 SET_WIDGET_COND(act
->widget
, M_TARGET_EXIST
, M_UNLOCKED
);
2406 state
= main_window_get_current_state(mainwin
);
2408 for (cur
= entry_list
; cur
!= NULL
; cur
= cur
->next
) {
2409 Entry
*e
= (Entry
*) cur
->data
;
2411 if (e
->widget
!= NULL
) {
2412 sensitive
= ((e
->cond
& state
) == e
->cond
);
2413 GTK_BUTTON_SET_SENSITIVE(e
->widget
, sensitive
);
2417 while (entry_list
!= NULL
) {
2418 Entry
*e
= (Entry
*) entry_list
->data
;
2421 entry_list
= g_slist_remove(entry_list
, e
);
2424 /* match any bit flags */
2426 if (toolbar
->cancel_all_btn
)
2427 SET_WIDGET_COND(toolbar
->cancel_all_btn
,
2428 M_INC_ACTIVE
, M_SEND_ACTIVE
);
2430 for (cur
= entry_list
; cur
!= NULL
; cur
= cur
->next
) {
2431 Entry
*e
= (Entry
*) cur
->data
;
2433 if (e
->widget
!= NULL
) {
2434 sensitive
= ((e
->cond
& state
) != 0);
2435 GTK_BUTTON_SET_SENSITIVE(e
->widget
, sensitive
);
2439 while (entry_list
!= NULL
) {
2440 Entry
*e
= (Entry
*) entry_list
->data
;
2443 entry_list
= g_slist_remove(entry_list
, e
);
2446 g_slist_free(entry_list
);
2448 activate_compose_button(toolbar
,
2449 prefs_common
.toolbar_style
,
2450 toolbar
->compose_btn_type
);
2452 #undef SET_WIDGET_COND
2455 void toolbar_comp_set_sensitive(gpointer data
, gboolean sensitive
)
2457 Compose
*compose
= (Compose
*)data
;
2458 GSList
*items
= compose
->toolbar
->action_list
;
2460 if (compose
->toolbar
->send_btn
)
2461 GTK_BUTTON_SET_SENSITIVE(compose
->toolbar
->send_btn
, sensitive
);
2462 if (compose
->toolbar
->sendl_btn
)
2463 GTK_BUTTON_SET_SENSITIVE(compose
->toolbar
->sendl_btn
, sensitive
);
2464 if (compose
->toolbar
->draft_btn
)
2465 GTK_BUTTON_SET_SENSITIVE(compose
->toolbar
->draft_btn
, sensitive
);
2466 if (compose
->toolbar
->insert_btn
)
2467 GTK_BUTTON_SET_SENSITIVE(compose
->toolbar
->insert_btn
, sensitive
);
2468 if (compose
->toolbar
->attach_btn
)
2469 GTK_BUTTON_SET_SENSITIVE(compose
->toolbar
->attach_btn
, sensitive
);
2470 if (compose
->toolbar
->sig_btn
)
2471 GTK_BUTTON_SET_SENSITIVE(compose
->toolbar
->sig_btn
, sensitive
);
2472 if (compose
->toolbar
->repsig_btn
)
2473 GTK_BUTTON_SET_SENSITIVE(compose
->toolbar
->repsig_btn
, sensitive
);
2474 if (compose
->toolbar
->exteditor_btn
)
2475 GTK_BUTTON_SET_SENSITIVE(compose
->toolbar
->exteditor_btn
, sensitive
);
2476 if (compose
->toolbar
->linewrap_current_btn
)
2477 GTK_BUTTON_SET_SENSITIVE(compose
->toolbar
->linewrap_current_btn
, sensitive
);
2478 if (compose
->toolbar
->linewrap_all_btn
)
2479 GTK_BUTTON_SET_SENSITIVE(compose
->toolbar
->linewrap_all_btn
, sensitive
);
2480 if (compose
->toolbar
->addrbook_btn
)
2481 GTK_BUTTON_SET_SENSITIVE(compose
->toolbar
->addrbook_btn
, sensitive
);
2483 if (compose
->toolbar
->spellcheck_btn
)
2484 GTK_BUTTON_SET_SENSITIVE(compose
->toolbar
->spellcheck_btn
, sensitive
);
2486 for (; items
!= NULL
; items
= g_slist_next(items
)) {
2487 ToolbarClawsActions
*item
= (ToolbarClawsActions
*)items
->data
;
2488 GTK_BUTTON_SET_SENSITIVE(item
->widget
, sensitive
);
2493 * Initialize toolbar structure
2495 static void toolbar_init(Toolbar
* toolbar
)
2498 toolbar
->toolbar
= NULL
;
2499 toolbar
->folders_btn
= NULL
;
2500 toolbar
->get_btn
= NULL
;
2501 toolbar
->getall_btn
= NULL
;
2502 toolbar
->send_btn
= NULL
;
2503 toolbar
->compose_mail_btn
= NULL
;
2504 toolbar
->compose_mail_icon
= NULL
;
2505 toolbar
->compose_news_icon
= NULL
;
2506 toolbar
->reply_btn
= NULL
;
2507 toolbar
->replysender_btn
= NULL
;
2508 toolbar
->replyall_btn
= NULL
;
2509 toolbar
->replylist_btn
= NULL
;
2510 toolbar
->fwd_btn
= NULL
;
2511 toolbar
->trash_btn
= NULL
;
2512 toolbar
->delete_btn
= NULL
;
2513 toolbar
->prev_btn
= NULL
;
2514 toolbar
->next_btn
= NULL
;
2515 toolbar
->exec_btn
= NULL
;
2516 toolbar
->separator
= NULL
;
2517 toolbar
->learn_spam_btn
= NULL
;
2518 toolbar
->learn_spam_icon
= NULL
;
2519 toolbar
->learn_ham_icon
= NULL
;
2520 toolbar
->cancel_inc_btn
= NULL
;
2521 toolbar
->cancel_send_btn
= NULL
;
2522 toolbar
->cancel_all_btn
= NULL
;
2524 /* compose buttons */
2525 toolbar
->sendl_btn
= NULL
;
2526 toolbar
->draft_btn
= NULL
;
2527 toolbar
->insert_btn
= NULL
;
2528 toolbar
->attach_btn
= NULL
;
2529 toolbar
->sig_btn
= NULL
;
2530 toolbar
->repsig_btn
= NULL
;
2531 toolbar
->exteditor_btn
= NULL
;
2532 toolbar
->linewrap_current_btn
= NULL
;
2533 toolbar
->linewrap_all_btn
= NULL
;
2534 toolbar
->addrbook_btn
= NULL
;
2536 toolbar
->open_mail_btn
= NULL
;
2537 toolbar
->close_window_btn
= NULL
;
2538 toolbar
->preferences_btn
= NULL
;
2539 toolbar
->action_list
= NULL
;
2540 toolbar
->item_list
= NULL
;
2542 toolbar
->spellcheck_btn
= NULL
;
2545 toolbar_destroy(toolbar
);
2550 static void toolbar_reply(gpointer data
, guint action
)
2552 ToolbarItem
*toolbar_item
= (ToolbarItem
*)data
;
2553 MainWindow
*mainwin
;
2554 MessageView
*msgview
;
2555 GSList
*msginfo_list
= NULL
;
2557 cm_return_if_fail(toolbar_item
!= NULL
);
2559 switch (toolbar_item
->type
) {
2561 mainwin
= (MainWindow
*)toolbar_item
->parent
;
2562 msginfo_list
= summary_get_selection(mainwin
->summaryview
);
2563 msgview
= (MessageView
*)mainwin
->messageview
;
2565 case TOOLBAR_MSGVIEW
:
2566 msgview
= (MessageView
*)toolbar_item
->parent
;
2567 cm_return_if_fail(msgview
!= NULL
);
2568 msginfo_list
= g_slist_append(msginfo_list
, msgview
->msginfo
);
2574 cm_return_if_fail(msgview
!= NULL
);
2575 cm_return_if_fail(msginfo_list
!= NULL
);
2576 compose_reply_from_messageview(msgview
, msginfo_list
, action
);
2577 g_slist_free(msginfo_list
);
2579 /* TODO: update reply state ion summaryview */
2583 /* exported functions */
2585 void inc_mail_cb(gpointer data
, guint action
, GtkWidget
*widget
)
2587 MainWindow
*mainwin
= (MainWindow
*)data
;
2589 inc_mail(mainwin
, prefs_common
.newmail_notify_manu
);
2592 void inc_all_account_mail_cb(gpointer data
, guint action
, GtkWidget
*widget
)
2594 MainWindow
*mainwin
= (MainWindow
*)data
;
2596 inc_all_account_mail(mainwin
, FALSE
, prefs_common
.newmail_notify_manu
);
2599 void send_queue_cb(gpointer data
, guint action
, GtkWidget
*widget
)
2603 gboolean got_error
= FALSE
;
2604 gchar
*errstr
= NULL
;
2606 if (prefs_common
.work_offline
)
2607 if (alertpanel(_("Offline warning"),
2608 _("You're working offline. Override?"),
2609 GTK_STOCK_NO
, GTK_STOCK_YES
,
2610 NULL
) != G_ALERTALTERNATE
)
2613 /* ask for confirmation before sending queued messages only
2614 in online mode and if there is at least one message queued
2615 in any of the folder queue
2617 if (prefs_common
.confirm_send_queued_messages
) {
2619 /* check if there's a queued message */
2620 for (list
= folder_get_list(); !found
&& list
!= NULL
; list
= list
->next
) {
2621 Folder
*folder
= list
->data
;
2623 found
= !procmsg_queue_is_empty(folder
->queue
);
2625 /* if necessary, ask for confirmation before sending */
2626 if (found
&& !prefs_common
.work_offline
) {
2627 if (alertpanel(_("Send queued messages"),
2628 _("Send all queued messages?"),
2629 GTK_STOCK_CANCEL
, _("_Send"),
2630 NULL
) != G_ALERTALTERNATE
)
2635 for (list
= folder_get_list(); list
!= NULL
; list
= list
->next
) {
2636 Folder
*folder
= list
->data
;
2638 if (folder
->queue
) {
2639 if (procmsg_send_queue(folder
->queue
,
2640 prefs_common
.savemsg
,
2647 alertpanel_error_log(_("Some errors occurred while "
2648 "sending queued messages."));
2650 alertpanel_error_log(_("Some errors occurred "
2651 "while sending queued messages:\n%s"), errstr
);
2657 void compose_mail_cb(gpointer data
, guint action
, GtkWidget
*widget
)
2659 MainWindow
*mainwin
= (MainWindow
*)data
;
2660 PrefsAccount
*ac
= NULL
;
2661 FolderItem
*item
= mainwin
->summaryview
->folder_item
;
2666 ac
= account_find_from_item(item
);
2667 if (ac
&& ac
->protocol
!= A_NNTP
&& ac
->protocol
!= A_IMAP4
) {
2668 compose_new_with_folderitem(ac
, item
, NULL
); /* CLAWS */
2674 * CLAWS - use current account
2676 if (cur_account
&& (cur_account
->protocol
!= A_NNTP
)) {
2677 compose_new_with_folderitem(cur_account
, item
, NULL
);
2682 * CLAWS - just get the first one
2684 list
= account_get_list();
2685 for (cur
= list
; cur
!= NULL
; cur
= g_list_next(cur
)) {
2686 ac
= (PrefsAccount
*) cur
->data
;
2687 if (ac
->protocol
!= A_NNTP
) {
2688 compose_new_with_folderitem(ac
, item
, NULL
);
2694 void compose_news_cb(gpointer data
, guint action
, GtkWidget
*widget
)
2696 MainWindow
*mainwin
= (MainWindow
*)data
;
2697 PrefsAccount
* ac
= NULL
;
2701 if (mainwin
->summaryview
->folder_item
) {
2702 ac
= mainwin
->summaryview
->folder_item
->folder
->account
;
2703 if (ac
&& ac
->protocol
== A_NNTP
) {
2704 compose_new_with_folderitem(ac
,
2705 mainwin
->summaryview
->folder_item
, NULL
);
2710 list
= account_get_list();
2711 for(cur
= list
; cur
!= NULL
; cur
= g_list_next(cur
)) {
2712 ac
= (PrefsAccount
*) cur
->data
;
2713 if (ac
->protocol
== A_NNTP
) {
2714 compose_new_with_folderitem(ac
,
2715 mainwin
->summaryview
->folder_item
, NULL
);