1e82a402453993882f554fc1270360959c19292f
[claws.git] / src / quote_fmt.c
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2007 Hiroyuki Yamamoto and the Claws Mail team
4  *
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.
9  *
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.
14  *
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/>.
17  * 
18  */
19
20 #ifdef HAVE_CONFIG_H
21 #  include "config.h"
22 #endif
23
24 #include <glib.h>
25 #include <glib/gi18n.h>
26 #include <gtk/gtk.h>
27 #include <gdk/gdkkeysyms.h>
28
29 #include "manage_window.h"
30 #include "description_window.h"
31 #include "gtkutils.h"
32
33 #include "prefs_gtk.h"
34 #include "prefs_common.h"
35 #include "quote_fmt.h"
36 #include "alertpanel.h"
37 #include "prefs_template.h"
38
39
40 /*
41  * Strings describing quote format strings
42  * 
43  * When adding new lines, remember to put 2 strings for each line
44  */
45 static gchar *quote_desc_strings[] = {
46         N_("<span weight=\"bold\">symbols:</span>"),                            NULL,
47         "%date_fmt{<span style=\"oblique\">fmt</span>} (%D{<span style=\"oblique\">fmt</span>})",       N_("customized date format (see 'man strftime')"), /* date expression */
48         "%date (%d)",                           N_("Date"), /* date */
49         "%from (%f)",                           N_("From"), /* from */
50         "%email (%A)",                          N_("email address of sender"), /* email address */
51         "%fullname (%N)",                       N_("full name of sender"), /* full name */
52         "%firstname (%F)",                      N_("first name of sender"), /* first name */
53         "%lastname (%L)",                       N_("last name of sender"), /* last name */
54         "%initials (%I)",                       N_("initials of sender"), /* initial of sender */
55         "%subject (%s)",                        N_("Subject"), /* subject */ 
56         "%to (%t)",                                     N_("To"), /* to */ 
57         "%cc (%c)",                                     N_("Cc"), /* cc */ 
58         "%newsgroups (%n)",                     N_("Newsgroups"), /* newsgroups */ 
59         "%references (%r)",                     N_("References"), /* references */ 
60         "%messageid (%i)",                      N_("Message-ID"), /* message-id */ 
61         "%msg (%M)",                            N_("message body"), /* message */
62         "%quoted_msg (%Q)",                     N_("quoted message body"), /* quoted message */
63         "%msg_no_sig (%m)",                     N_("message body without signature"), /* message with no signature */
64         "%quoted_msg_no_sig (%q)",      N_("quoted message body without signature"), /* quoted message with no signature */
65         "%tags",                                N_("message tags"), /* message tags */
66         "%dict (%T)",                           N_("current dictionary"), /* current dictionary */
67         "%cursor (%X)",                         N_("cursor position"), /* X marks the cursor spot */
68         "%account_fullname (%af)",      N_("account property: your name"), /* full name in compose account */
69         "%account_email (%am)",         N_("account property: your email address"), /* mail address in compose account */
70         "%account_name (%an)",          N_("account property: account name"), /* compose account name itself */
71         "%account_org (%ao)",           N_("account property: organization"), /* organization in compose account */
72         "%account_dict (%aT)",          N_("account property: default dictionary"), /* main dict (if enabled) in account */
73         "%addrbook_cc (%ABc)",          N_("address book <span style=\"oblique\">completion</span>: Cc"), /* completion of 'Cc' from address book */
74         "%addrbook_from (%ABf)",        N_("address book <span style=\"oblique\">completion</span>: From"), /* completion of 'From' from address book */
75         "%addrbook_to (%ABt)",          N_("address book <span style=\"oblique\">completion</span>: To"), /* completion of 'To' from address book */
76         "\\%",                          N_("literal %"),
77         "\\\\",                         N_("literal backslash"),
78         "\\?",                          N_("literal question mark"),
79         "\\!",                          N_("literal exclamation mark"),
80         "\\|",                          N_("literal pipe"),
81         "\\{",                          N_("literal opening curly brace"),
82         "\\}",                          N_("literal closing curly brace"),
83         "\\t",                          N_("tab"),
84         "\\n",                          N_("new line"),
85         "",                                     NULL,
86         N_("<span weight=\"bold\">commands:</span>"),           NULL,
87         "?x{<span style=\"oblique\">expr</span>}\n\n",          N_("insert <span style=\"oblique\">expr</span> if x is set, where x is one of\nthe [dfNFLIstcnriT, ad, af, ao, aT, ABc, ABf, ABt]\nsymbols (or their long equivalent)"),
88         "!x{<span style=\"oblique\">expr</span>}\n\n",          N_("insert <span style=\"oblique\">expr</span> if x is not set, where x is one of\nthe [dfNFLIstcnriT, ad, af, ao, aT, ABc, ABf, ABt]\nsymbols (or their long equivalent)"),
89         "|file{<span style=\"oblique\">sub_expr</span>}\n(|f{<span style=\"oblique\">sub_expr</span>})",                N_("insert file:\n<span style=\"oblique\">sub_expr</span> is evaluated as the path of the file to insert"), /* insert file */
90         "|program{<span style=\"oblique\">sub_expr</span>}\n(|p{<span style=\"oblique\">sub_expr</span>})\n",   N_("insert program output:\n<span style=\"oblique\">sub_expr</span> is evaluated as a command-line to get\nthe output from"), /* insert program output */
91         "|input{<span style=\"oblique\">sub_expr</span>}\n(|i{<span style=\"oblique\">sub_expr</span>})\n",             N_("insert user input:\n<span style=\"oblique\">sub_expr</span> is a variable to be replaced by\nuser-entered text"), /* insert user input */
92         "|attach{<span style=\"oblique\">sub_expr</span>}\n(|a{<span style=\"oblique\">sub_expr</span>})",              N_("attach file:\n<span style=\"oblique\">sub_expr</span> is evaluated as the path of the file to attach"), /* attach file */
93         "",                                     NULL,
94         N_("<span weight=\"bold\">definition of terms:</span>"),        NULL,
95         "<span style=\"oblique\">expr</span>\n",                        N_("text that can contain any of the symbols or\ncommands above"),
96         "<span style=\"oblique\">sub_expr</span>\n",            N_("text that can contain any of the symbols (no\ncommands) above"),
97         "<span style=\"oblique\">completion</span>\n\n\n",      N_("completion from address book only works with the first\naddress of the header, it outputs the full name\nof the contact if that address matches exactly\none contact in the address book"),
98         NULL,NULL
99 };
100
101 static DescriptionWindow quote_desc_win = { 
102         NULL,
103         NULL,
104         2,
105         N_("Description of symbols"),
106         N_("The following symbols and commands can be used:"),
107         quote_desc_strings
108 };
109
110
111 void quote_fmt_quote_description(GtkWidget *widget, GtkWidget *pref_window)
112 {
113         quote_desc_win.parent = pref_window;
114         description_window_create(&quote_desc_win);
115 }
116
117 void quotefmt_create_new_msg_fmt_widgets(GtkWindow *parent_window,
118                                                 GtkWidget *parent_box,
119                                                 GtkWidget **checkbtn_compose_with_format,
120                                                 GtkWidget **override_from_format,
121                                                 GtkWidget **edit_subject_format,
122                                                 GtkWidget **edit_body_format,
123                                                 gboolean add_info_button)
124 {
125         GtkWidget *checkbtn_use_format = NULL;
126         GtkWidget *vbox_format;
127         GtkWidget *hbox_format;
128         GtkWidget *hbox2_format;
129         GtkWidget *label_from;
130         GtkWidget *entry_from;
131         GtkWidget *label_subject;
132         GtkWidget *entry_subject;
133         GtkWidget *scrolledwin_format;
134         GtkWidget *text_format;
135
136         if (add_info_button)
137                 g_return_if_fail(parent_window != NULL);
138         g_return_if_fail(parent_box != NULL);
139         if (checkbtn_compose_with_format)
140                 g_return_if_fail(checkbtn_compose_with_format != NULL);
141
142         g_return_if_fail(edit_subject_format != NULL);
143         g_return_if_fail(edit_body_format != NULL);
144
145         if (checkbtn_compose_with_format)
146                 PACK_CHECK_BUTTON (parent_box, checkbtn_use_format, 
147                                    _("Use template when composing new messages"));
148
149         vbox_format = gtk_vbox_new (FALSE, 4);
150         gtk_widget_show(vbox_format);
151         gtk_container_add(GTK_CONTAINER (parent_box), vbox_format);
152         gtk_container_set_border_width (GTK_CONTAINER (vbox_format), 8);
153
154         if (override_from_format) {
155                 hbox2_format = gtk_hbox_new (FALSE, 8);
156                 gtk_widget_show (hbox2_format);
157                 gtk_box_pack_start (GTK_BOX (vbox_format), hbox2_format, FALSE, FALSE, 0);
158
159                 label_from = gtk_label_new (_("From"));
160                 gtk_widget_show (label_from);
161                 gtk_box_pack_start (GTK_BOX (hbox2_format), label_from, FALSE, FALSE, 0);
162
163                 entry_from = gtk_entry_new ();
164                 gtk_widget_show (entry_from);
165                 gtk_box_pack_start (GTK_BOX (hbox2_format), entry_from, TRUE, TRUE, 0);
166                 gtk_widget_set_size_request (entry_from, 100, -1);
167
168                 gtk_tooltips_set_tip(gtk_tooltips_new(), entry_from,
169                                 _("Override From header. This doesn't change the account used to compose the new message."),
170                                 NULL);
171         }
172
173         hbox_format = gtk_hbox_new (FALSE, 8);
174         gtk_widget_show (hbox_format);
175         gtk_box_pack_start (GTK_BOX (vbox_format), hbox_format, FALSE, FALSE, 0);
176
177         label_subject = gtk_label_new (_("Subject"));
178         gtk_widget_show (label_subject);
179         gtk_box_pack_start (GTK_BOX (hbox_format), label_subject, FALSE, FALSE, 0);
180
181         entry_subject = gtk_entry_new ();
182         gtk_widget_show (entry_subject);
183         gtk_box_pack_start (GTK_BOX (hbox_format), entry_subject, TRUE, TRUE, 0);
184         gtk_widget_set_size_request (entry_subject, 100, -1);
185
186         scrolledwin_format = gtk_scrolled_window_new (NULL, NULL);
187         gtk_widget_show (scrolledwin_format);
188         gtk_box_pack_start (GTK_BOX (vbox_format), scrolledwin_format,
189                             TRUE, TRUE, 0);
190         gtk_scrolled_window_set_policy
191                 (GTK_SCROLLED_WINDOW (scrolledwin_format),
192                  GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
193         gtk_scrolled_window_set_shadow_type
194                 (GTK_SCROLLED_WINDOW (scrolledwin_format), GTK_SHADOW_IN);
195
196         text_format = gtk_text_view_new ();
197         if (prefs_common.textfont) {
198                 PangoFontDescription *font_desc;
199
200                 font_desc = pango_font_description_from_string
201                                                 (prefs_common.textfont);
202                 if (font_desc) {
203                         gtk_widget_modify_font(text_format, font_desc);
204                         pango_font_description_free(font_desc);
205                 }
206         }
207         gtk_widget_show(text_format);
208         gtk_container_add(GTK_CONTAINER(scrolledwin_format), text_format);
209         gtk_text_view_set_editable (GTK_TEXT_VIEW (text_format), TRUE);
210         gtk_widget_set_size_request(text_format, -1, 100);
211
212         if (checkbtn_compose_with_format) {
213                 SET_TOGGLE_SENSITIVITY(checkbtn_use_format, label_subject);
214                 if (override_from_format)
215                         SET_TOGGLE_SENSITIVITY(checkbtn_use_format, entry_from);
216                 SET_TOGGLE_SENSITIVITY(checkbtn_use_format, entry_subject);
217                 SET_TOGGLE_SENSITIVITY(checkbtn_use_format, text_format);
218         }
219
220         if (add_info_button)
221                 quotefmt_add_info_button(parent_window, vbox_format);
222
223         if (checkbtn_compose_with_format)
224                 *checkbtn_compose_with_format = checkbtn_use_format;
225         if (override_from_format)
226                 *override_from_format = entry_from;
227         *edit_subject_format = entry_subject;
228         *edit_body_format = text_format;
229 }
230
231 void quotefmt_create_reply_fmt_widgets(GtkWindow *parent_window,
232                                                 GtkWidget *parent_box,
233                                                 GtkWidget **checkbtn_reply_with_format,
234                                                 GtkWidget **override_from_format,
235                                                 GtkWidget **edit_reply_quotemark,
236                                                 GtkWidget **edit_reply_format,
237                                                 gboolean add_info_button)
238 {
239         GtkWidget *checkbtn_use_format = NULL;
240         GtkWidget *vbox_quote;
241         GtkWidget *hbox1;
242         GtkWidget *hbox2;
243         GtkWidget *hbox3;
244         GtkWidget *label_quotemark;
245         GtkWidget *entry_quotemark;
246         GtkWidget *label_from;
247         GtkWidget *entry_from;
248         GtkWidget *scrolledwin_quotefmt;
249         GtkWidget *text_quotefmt;
250
251         if (add_info_button)
252                 g_return_if_fail(parent_window != NULL);
253         g_return_if_fail(parent_box != NULL);
254         if (checkbtn_reply_with_format)
255                 g_return_if_fail(checkbtn_reply_with_format != NULL);
256
257         g_return_if_fail(edit_reply_quotemark != NULL);
258         g_return_if_fail(edit_reply_format != NULL);
259
260         if (checkbtn_reply_with_format)
261                 PACK_CHECK_BUTTON (parent_box, checkbtn_use_format,
262                                    _("Use template when replying to messages"));
263
264         vbox_quote = gtk_vbox_new (FALSE, 4);
265         gtk_widget_show(vbox_quote);
266         gtk_container_add(GTK_CONTAINER (parent_box), vbox_quote);
267         gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8);
268
269         if (override_from_format) {
270                 hbox3 = gtk_hbox_new (FALSE, 8);
271                 gtk_widget_show (hbox3);
272                 gtk_box_pack_start (GTK_BOX (vbox_quote), hbox3, FALSE, FALSE, 0);
273
274                 label_from = gtk_label_new (_("From"));
275                 gtk_widget_show (label_from);
276                 gtk_box_pack_start (GTK_BOX (hbox3), label_from, FALSE, FALSE, 0);
277
278                 entry_from = gtk_entry_new ();
279                 gtk_widget_show (entry_from);
280                 gtk_box_pack_start (GTK_BOX (hbox3), entry_from, TRUE, TRUE, 0);
281                 gtk_widget_set_size_request (entry_from, 100, -1);
282
283                 gtk_tooltips_set_tip(gtk_tooltips_new(), entry_from,
284                                 _("Override From header. This doesn't change the account used to reply."),
285                                 NULL);
286         }
287
288         hbox1 = gtk_hbox_new (FALSE, 32);
289         gtk_widget_show (hbox1);
290         gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0);
291
292         hbox2 = gtk_hbox_new (FALSE, 8);
293         gtk_widget_show (hbox2);
294         gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
295
296         label_quotemark = gtk_label_new (_("Quotation mark"));
297         gtk_widget_show (label_quotemark);
298         gtk_box_pack_start (GTK_BOX (hbox2), label_quotemark, FALSE, FALSE, 0);
299
300         entry_quotemark = gtk_entry_new ();
301         gtk_widget_show (entry_quotemark);
302         gtk_box_pack_start (GTK_BOX (hbox2), entry_quotemark, FALSE, FALSE, 0);
303         gtk_widget_set_size_request (entry_quotemark, 64, -1);
304
305         scrolledwin_quotefmt = gtk_scrolled_window_new (NULL, NULL);
306         gtk_widget_show (scrolledwin_quotefmt);
307         gtk_box_pack_start (GTK_BOX (vbox_quote), scrolledwin_quotefmt,
308                             TRUE, TRUE, 0);
309         gtk_scrolled_window_set_policy
310                 (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt),
311                  GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
312         gtk_scrolled_window_set_shadow_type
313                 (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt), GTK_SHADOW_IN);
314
315         text_quotefmt = gtk_text_view_new ();
316         if (prefs_common.textfont) {
317                 PangoFontDescription *font_desc;
318
319                 font_desc = pango_font_description_from_string
320                                                 (prefs_common.textfont);
321                 if (font_desc) {
322                         gtk_widget_modify_font(text_quotefmt, font_desc);
323                         pango_font_description_free(font_desc);
324                 }
325         }
326         gtk_widget_show(text_quotefmt);
327         gtk_container_add(GTK_CONTAINER(scrolledwin_quotefmt), text_quotefmt);
328         gtk_text_view_set_editable (GTK_TEXT_VIEW (text_quotefmt), TRUE);
329         gtk_widget_set_size_request(text_quotefmt, -1, 100);
330
331         if (checkbtn_reply_with_format) {
332                 SET_TOGGLE_SENSITIVITY(checkbtn_use_format, label_quotemark);
333                 SET_TOGGLE_SENSITIVITY(checkbtn_use_format, entry_quotemark);
334                 if (override_from_format)
335                         SET_TOGGLE_SENSITIVITY(checkbtn_use_format, entry_from);
336                 SET_TOGGLE_SENSITIVITY(checkbtn_use_format, text_quotefmt);
337         }
338
339         if (add_info_button)
340                 quotefmt_add_info_button(parent_window, vbox_quote);
341
342         if (checkbtn_reply_with_format)
343                 *checkbtn_reply_with_format = checkbtn_use_format;
344         *edit_reply_quotemark = entry_quotemark;
345         if (override_from_format)
346                 *override_from_format = entry_from;
347         *edit_reply_format = text_quotefmt;
348 }
349
350 void quotefmt_create_forward_fmt_widgets(GtkWindow *parent_window,
351                                                 GtkWidget *parent_box,
352                                                 GtkWidget **checkbtn_forward_with_format,
353                                                 GtkWidget **override_from_format,
354                                                 GtkWidget **edit_fw_quotemark,
355                                                 GtkWidget **edit_fw_format,
356                                                 gboolean add_info_button)
357 {
358         GtkWidget *checkbtn_use_format = NULL;
359         GtkWidget *vbox_quote;
360         GtkWidget *hbox1;
361         GtkWidget *hbox2;
362         GtkWidget *hbox3;
363         GtkWidget *label_quotemark;
364         GtkWidget *entry_fw_quotemark;
365         GtkWidget *label_from;
366         GtkWidget *entry_from;
367         GtkWidget *scrolledwin_quotefmt;
368         GtkWidget *text_fw_quotefmt;
369
370         if (add_info_button)
371                 g_return_if_fail(parent_window != NULL);
372         g_return_if_fail(parent_box != NULL);
373         if (checkbtn_forward_with_format) {
374                 g_return_if_fail(checkbtn_forward_with_format != NULL);
375         }
376         g_return_if_fail(edit_fw_quotemark != NULL);
377         g_return_if_fail(edit_fw_format != NULL);
378
379         if (checkbtn_forward_with_format)
380                 PACK_CHECK_BUTTON (parent_box, checkbtn_use_format,
381                                    _("Use template when forwarding messages"));
382
383         vbox_quote = gtk_vbox_new (FALSE, 4);
384         gtk_widget_show(vbox_quote);
385         gtk_container_add(GTK_CONTAINER (parent_box), vbox_quote);
386         gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8);
387
388         if (override_from_format) {
389                 hbox3 = gtk_hbox_new (FALSE, 8);
390                 gtk_widget_show (hbox3);
391                 gtk_box_pack_start (GTK_BOX (vbox_quote), hbox3, FALSE, FALSE, 0);
392
393                 label_from = gtk_label_new (_("From"));
394                 gtk_widget_show (label_from);
395                 gtk_box_pack_start (GTK_BOX (hbox3), label_from, FALSE, FALSE, 0);
396
397                 entry_from = gtk_entry_new ();
398                 gtk_widget_show (entry_from);
399                 gtk_box_pack_start (GTK_BOX (hbox3), entry_from, TRUE, TRUE, 0);
400                 gtk_widget_set_size_request (entry_from, 100, -1);
401
402                 gtk_tooltips_set_tip(gtk_tooltips_new(), entry_from,
403                                 _("Override From header. This doesn't change the account used to forward."),
404                                 NULL);
405         }
406
407         hbox1 = gtk_hbox_new (FALSE, 32);
408         gtk_widget_show (hbox1);
409         gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0);
410
411         hbox2 = gtk_hbox_new (FALSE, 8);
412         gtk_widget_show (hbox2);
413         gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
414
415         label_quotemark = gtk_label_new (_("Quotation mark"));
416         gtk_widget_show (label_quotemark);
417         gtk_box_pack_start (GTK_BOX (hbox2), label_quotemark, FALSE, FALSE, 0);
418
419         entry_fw_quotemark = gtk_entry_new ();
420         gtk_widget_show (entry_fw_quotemark);
421         gtk_box_pack_start (GTK_BOX (hbox2), entry_fw_quotemark,
422                             FALSE, FALSE, 0);
423         gtk_widget_set_size_request (entry_fw_quotemark, 64, -1);
424
425         scrolledwin_quotefmt = gtk_scrolled_window_new (NULL, NULL);
426         gtk_widget_show (scrolledwin_quotefmt);
427         gtk_box_pack_start (GTK_BOX (vbox_quote), scrolledwin_quotefmt,
428                             TRUE, TRUE, 0);
429         gtk_scrolled_window_set_policy
430                 (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt),
431                  GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
432         gtk_scrolled_window_set_shadow_type
433                 (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt), GTK_SHADOW_IN);
434
435         text_fw_quotefmt = gtk_text_view_new ();
436         if (prefs_common.textfont) {
437                 PangoFontDescription *font_desc;
438
439                 font_desc = pango_font_description_from_string
440                                                 (prefs_common.textfont);
441                 if (font_desc) {
442                         gtk_widget_modify_font(text_fw_quotefmt, font_desc);
443                         pango_font_description_free(font_desc);
444                 }
445         }
446         gtk_widget_show(text_fw_quotefmt);
447         gtk_container_add(GTK_CONTAINER(scrolledwin_quotefmt),
448                           text_fw_quotefmt);
449         gtk_text_view_set_editable (GTK_TEXT_VIEW (text_fw_quotefmt), TRUE);
450         gtk_widget_set_size_request (text_fw_quotefmt, -1, 100);
451
452         if (checkbtn_forward_with_format) {
453                 SET_TOGGLE_SENSITIVITY(checkbtn_use_format, label_quotemark);
454                 SET_TOGGLE_SENSITIVITY(checkbtn_use_format, entry_fw_quotemark);
455                 if (override_from_format)
456                         SET_TOGGLE_SENSITIVITY(checkbtn_use_format, entry_from);
457                 SET_TOGGLE_SENSITIVITY(checkbtn_use_format, text_fw_quotefmt);
458         }
459
460         if (add_info_button)
461                 quotefmt_add_info_button(parent_window, vbox_quote);
462
463         if (checkbtn_forward_with_format)
464                 *checkbtn_forward_with_format = checkbtn_use_format;
465         *edit_fw_quotemark = entry_fw_quotemark;
466         if (override_from_format)
467                 *override_from_format = entry_from;
468         *edit_fw_format = text_fw_quotefmt;
469 }
470
471 void quotefmt_add_info_button(GtkWindow *parent_window, GtkWidget *parent_box)
472 {
473         GtkWidget *hbox_formatdesc;
474         GtkWidget *btn_formatdesc;
475
476         hbox_formatdesc = gtk_hbox_new (FALSE, 32);
477         gtk_widget_show (hbox_formatdesc);
478         gtk_box_pack_start (GTK_BOX (parent_box), hbox_formatdesc, FALSE, FALSE,
479                                 VBOX_BORDER);
480
481 #if GTK_CHECK_VERSION(2, 8, 0)
482         btn_formatdesc = gtk_button_new_from_stock(GTK_STOCK_INFO);
483 #else
484         btn_formatdesc =
485                 gtk_button_new_with_label (_("Description of symbols..."));
486 #endif
487         gtk_widget_show (btn_formatdesc);
488         gtk_box_pack_start (GTK_BOX (hbox_formatdesc), btn_formatdesc, FALSE, FALSE, 0);
489         g_signal_connect(G_OBJECT(btn_formatdesc), "clicked",
490                          G_CALLBACK(quote_fmt_quote_description), GTK_WIDGET(parent_window));
491 }
492
493
494 void quotefmt_check_new_msg_formats(gboolean use_format,
495                                                                         gchar *override_from_fmt,
496                                                                         gchar *subject_fmt,
497                                                                         gchar *body_fmt)
498 {
499         if (use_format) {
500                 gint line;
501
502                 if (override_from_fmt && !prefs_template_string_is_valid(override_from_fmt, NULL, FALSE))
503                         alertpanel_error(_("New message From format error."));
504
505                 if (!prefs_template_string_is_valid(subject_fmt, NULL, FALSE))
506                         alertpanel_error(_("New message subject format error."));
507
508                 if (!prefs_template_string_is_valid(body_fmt, &line, TRUE)) {
509                         alertpanel_error(_("New message body format error at line %d."), line);
510                 }
511         }
512 }
513
514 void quotefmt_check_reply_formats(gboolean use_format,
515                                                                         gchar *override_from_fmt,
516                                                                         gchar *quotation_mark,
517                                                                         gchar *body_fmt)
518 {
519         if (use_format) {
520                 gint line;
521
522                 if (!prefs_template_string_is_valid(quotation_mark, NULL, FALSE))
523                         alertpanel_error(_("Message reply quotation mark format error."));
524
525                 if (override_from_fmt && !prefs_template_string_is_valid(override_from_fmt, NULL, FALSE))
526                         alertpanel_error(_("Message reply From format error."));
527
528                 if (!prefs_template_string_is_valid(body_fmt, &line, TRUE)) {
529                         alertpanel_error(_("Message reply format error at line %d."), line);
530                 }
531         }
532 }
533
534 void quotefmt_check_forward_formats(gboolean use_format,
535                                                                         gchar *override_from_fmt,
536                                                                         gchar *quotation_mark,
537                                                                         gchar *body_fmt)
538 {
539         if (use_format) {
540                 gint line;
541
542                 if (!prefs_template_string_is_valid(quotation_mark, NULL, FALSE))
543                         alertpanel_error(_("Message forward quotation mark format error."));
544
545                 if (override_from_fmt && !prefs_template_string_is_valid(override_from_fmt, NULL, FALSE))
546                         alertpanel_error(_("Message forward From format error."));
547
548                 if (!prefs_template_string_is_valid(body_fmt, &line, TRUE)) {
549                         alertpanel_error(_("Message forward format error at line %d."), line);
550                 }
551         }
552 }