Revert g9737584.
[claws.git] / src / prefs_folder_item.c
1 /*
2  * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2016 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 /* alfons - all folder item specific settings should migrate into 
20  * folderlist.xml!!! the old folderitemrc file will only serve for a few 
21  * versions (for compatibility) */
22
23 #ifdef HAVE_CONFIG_H
24 #  include "config.h"
25 #include "claws-features.h"
26 #endif
27
28 #include "defs.h"
29
30 #include <glib.h>
31 #include <glib/gi18n.h>
32 #include "folder.h"
33 #include "alertpanel.h"
34 #include "prefs_folder_item.h"
35 #include "folderview.h"
36 #include "folder.h"
37 #include "summaryview.h"
38 #include "menu.h"
39 #include "account.h"
40 #include "prefs_gtk.h"
41 #include "manage_window.h"
42 #include "utils.h"
43 #include "addr_compl.h"
44 #include "prefs_common.h"
45 #include "gtkutils.h"
46 #include "filtering.h"
47 #include "folder_item_prefs.h"
48 #include "gtk/colorsel.h"
49 #include "string_match.h"
50 #include "quote_fmt.h"
51 #include "combobox.h"
52 #include "stock_pixmap.h"
53
54 #if USE_ENCHANT
55 #include "gtkaspell.h"
56 #endif
57
58 #define ASSIGN_STRING(string, value) \
59         { \
60                 g_free(string); \
61                 string = (value); \
62         }
63
64 typedef struct _FolderItemGeneralPage FolderItemGeneralPage;
65 typedef struct _FolderItemComposePage FolderItemComposePage;
66 typedef struct _FolderItemTemplatesPage FolderItemTemplatesPage;
67 static gboolean can_save = TRUE;
68
69 struct _FolderItemGeneralPage
70 {
71         PrefsPage page;
72
73         FolderItem *item;
74
75         GtkWidget *table;
76         GtkWidget *no_save_warning;
77         GtkWidget *folder_type;
78         GtkWidget *checkbtn_simplify_subject;
79         GtkWidget *entry_simplify_subject;
80         GtkWidget *entry_regexp_test_string;
81         GtkWidget *entry_regexp_test_result;
82         GtkWidget *checkbtn_folder_chmod;
83         GtkWidget *entry_folder_chmod;
84         GtkWidget *folder_color_btn;
85         GtkWidget *checkbtn_enable_processing;
86         GtkWidget *checkbtn_enable_processing_when_opening;
87         GtkWidget *checkbtn_newmailcheck;
88         GtkWidget *checkbtn_offlinesync;
89         GtkWidget *label_offlinesync;
90         GtkWidget *entry_offlinesync;
91         GtkWidget *label_end_offlinesync;
92         GtkWidget *checkbtn_remove_old_offlinesync;
93         GtkWidget *promote_html_part;
94         
95         /* apply to sub folders */
96         GtkWidget *simplify_subject_rec_checkbtn;
97         GtkWidget *folder_chmod_rec_checkbtn;
98         GtkWidget *folder_color_rec_checkbtn;
99         GtkWidget *enable_processing_rec_checkbtn;
100         GtkWidget *enable_processing_when_opening_rec_checkbtn;
101         GtkWidget *newmailcheck_rec_checkbtn;
102         GtkWidget *offlinesync_rec_checkbtn;
103         GtkWidget *promote_html_part_rec_checkbtn;
104
105         gint       folder_color;
106 };
107
108 struct _FolderItemComposePage
109 {
110         PrefsPage page;
111
112         FolderItem *item;
113
114         GtkWidget *window;
115         GtkWidget *table;
116         GtkWidget *no_save_warning;
117         GtkWidget *checkbtn_request_return_receipt;
118         GtkWidget *checkbtn_save_copy_to_folder;
119         GtkWidget *checkbtn_default_to;
120         GtkWidget *entry_default_to;
121         GtkWidget *checkbtn_default_reply_to;
122         GtkWidget *entry_default_reply_to;
123         GtkWidget *checkbtn_default_cc;
124         GtkWidget *entry_default_cc;
125         GtkWidget *checkbtn_default_bcc;
126         GtkWidget *entry_default_bcc;
127         GtkWidget *checkbtn_default_replyto;
128         GtkWidget *entry_default_replyto;
129         GtkWidget *checkbtn_enable_default_account;
130         GtkWidget *optmenu_default_account;
131 #if USE_ENCHANT
132         GtkWidget *checkbtn_enable_default_dictionary;
133         GtkWidget *checkbtn_enable_default_alt_dictionary;
134         GtkWidget *combo_default_dictionary;
135         GtkWidget *combo_default_alt_dictionary;
136 #endif
137
138         /* apply to sub folders */
139         GtkWidget *request_return_receipt_rec_checkbtn;
140         GtkWidget *save_copy_to_folder_rec_checkbtn;
141         GtkWidget *default_to_rec_checkbtn;
142         GtkWidget *default_reply_to_rec_checkbtn;
143         GtkWidget *default_cc_rec_checkbtn;
144         GtkWidget *default_bcc_rec_checkbtn;
145         GtkWidget *default_replyto_rec_checkbtn;
146         GtkWidget *default_account_rec_checkbtn;
147 #if USE_ENCHANT
148         GtkWidget *default_dictionary_rec_checkbtn;
149         GtkWidget *default_alt_dictionary_rec_checkbtn;
150 #endif
151 };
152
153 struct _FolderItemTemplatesPage
154 {
155         PrefsPage page;
156
157         FolderItem *item;
158
159         GtkWidget *window;
160         GtkWidget *table;
161         GtkWidget *checkbtn_compose_with_format;
162         GtkWidget *compose_override_from_format;
163         GtkWidget *compose_subject_format;
164         GtkWidget *compose_body_format;
165         GtkWidget *checkbtn_reply_with_format;
166         GtkWidget *reply_quotemark;
167         GtkWidget *reply_override_from_format;
168         GtkWidget *reply_body_format;
169         GtkWidget *checkbtn_forward_with_format;
170         GtkWidget *forward_quotemark;
171         GtkWidget *forward_override_from_format;
172         GtkWidget *forward_body_format;
173
174         /* apply to sub folders */
175         GtkWidget *new_msg_format_rec_checkbtn;
176         GtkWidget *reply_format_rec_checkbtn;
177         GtkWidget *forward_format_rec_checkbtn;
178 };
179
180
181 static void general_save_folder_prefs(FolderItem *folder, FolderItemGeneralPage *page);
182 static void compose_save_folder_prefs(FolderItem *folder, FolderItemComposePage *page);
183 static void templates_save_folder_prefs(FolderItem *folder, FolderItemTemplatesPage *page);
184
185 static gboolean general_save_recurse_func(GNode *node, gpointer data);
186 static gboolean compose_save_recurse_func(GNode *node, gpointer data);
187 static gboolean templates_save_recurse_func(GNode *node, gpointer data);
188
189 static gint prefs_folder_item_chmod_mode                (gchar *folder_chmod);
190
191 static void folder_color_set_dialog(GtkWidget *widget, gpointer data);
192 static void clean_cache_cb(GtkWidget *widget, gpointer data);
193 static void folder_regexp_test_cb(GtkWidget *widget, gpointer data);
194 static void folder_regexp_set_subject_example_cb(GtkWidget *widget, gpointer data);
195
196 #define SAFE_STRING(str) \
197         (str) ? (str) : ""
198
199 static GtkWidget *prefs_folder_no_save_warning_create_widget() {
200         GtkWidget *hbox;
201         GtkWidget *icon;
202         GtkWidget *label;
203
204         hbox = gtk_hbox_new(FALSE, 0);
205
206         icon = stock_pixmap_widget(STOCK_PIXMAP_NOTICE_WARN);
207         gtk_box_pack_start(GTK_BOX(hbox), icon, FALSE, FALSE, 8);
208
209         label = gtk_label_new(g_strconcat("<i>",
210                 _("These preferences will not be saved as this folder "
211                 "is a top-level folder.\nHowever, you can set them for the "
212                 "whole mailbox tree by using \"Apply to subfolders\"."),
213                 "</i>", NULL));
214         gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
215         gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
216         gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
217
218         return hbox;
219 }
220
221 static void prefs_folder_item_general_create_widget_func(PrefsPage * page_,
222                                                    GtkWindow * window,
223                                                    gpointer data)
224 {
225         FolderItemGeneralPage *page = (FolderItemGeneralPage *) page_;
226         FolderItem *item = (FolderItem *) data;
227         guint rowcount;
228
229         GtkWidget *table;
230         GtkWidget *hbox, *hbox2, *hbox_spc;
231         GtkWidget *label;
232         
233         GtkListStore *folder_type_menu;
234         GtkWidget *folder_type;
235         GtkTreeIter iter;
236         GtkWidget *dummy_checkbtn, *clean_cache_btn;
237         SpecialFolderItemType type;
238         GtkWidget *no_save_warning = NULL;
239
240         GtkWidget *checkbtn_simplify_subject;
241         GtkWidget *entry_simplify_subject;
242         GtkWidget *label_regexp_test;
243         GtkWidget *entry_regexp_test_string;
244         GtkWidget *label_regexp_result;
245         GtkWidget *entry_regexp_test_result;
246
247         GtkWidget *checkbtn_folder_chmod;
248         GtkWidget *entry_folder_chmod;
249         GtkWidget *folder_color;
250         GtkWidget *folder_color_btn;
251         GtkWidget *checkbtn_enable_processing;
252         GtkWidget *checkbtn_enable_processing_when_opening;
253         GtkWidget *checkbtn_newmailcheck;
254         GtkWidget *checkbtn_offlinesync;
255         GtkWidget *label_offlinesync;
256         GtkWidget *entry_offlinesync;
257         GtkWidget *label_end_offlinesync;
258         GtkWidget *checkbtn_remove_old_offlinesync;
259         GtkWidget *promote_html_part;
260         GtkListStore *promote_html_part_menu;
261
262         GtkWidget *simplify_subject_rec_checkbtn;
263
264         GtkWidget *folder_chmod_rec_checkbtn;
265         GtkWidget *folder_color_rec_checkbtn;
266         GtkWidget *enable_processing_rec_checkbtn;
267         GtkWidget *enable_processing_when_opening_rec_checkbtn;
268         GtkWidget *newmailcheck_rec_checkbtn;
269         GtkWidget *offlinesync_rec_checkbtn;
270         GtkWidget *promote_html_part_rec_checkbtn;
271
272         page->item         = item;
273
274         /* Table */
275         table = gtk_table_new(12, 3, FALSE);
276         gtk_container_set_border_width (GTK_CONTAINER (table), VBOX_BORDER);
277         gtk_table_set_row_spacings(GTK_TABLE(table), 4);
278         gtk_table_set_col_spacings(GTK_TABLE(table), 4);
279         rowcount = 0;
280
281         if (!can_save) {
282                 no_save_warning = prefs_folder_no_save_warning_create_widget();
283                 gtk_table_attach(GTK_TABLE(table), no_save_warning, 0, 3,
284                         rowcount, rowcount + 1, GTK_FILL, 0, 0, 0);
285                 rowcount++;
286         }
287         
288         /* Apply to subfolders */
289         label = gtk_label_new(_("Apply to\nsubfolders"));
290         gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.5);
291         gtk_table_attach(GTK_TABLE(table), label, 2, 3,
292                          rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
293         rowcount++;
294
295         /* folder_type */
296         folder_type = gtkut_sc_combobox_create(NULL, FALSE);
297         gtk_widget_show (folder_type);
298
299         type = F_NORMAL;
300         if (item->stype == F_INBOX)
301                 type = F_INBOX;
302         else if (folder_has_parent_of_type(item, F_OUTBOX))
303                 type = F_OUTBOX;
304         else if (folder_has_parent_of_type(item, F_DRAFT))
305                 type = F_DRAFT;
306         else if (folder_has_parent_of_type(item, F_QUEUE))
307                 type = F_QUEUE;
308         else if (folder_has_parent_of_type(item, F_TRASH))
309                 type = F_TRASH;
310
311         folder_type_menu = GTK_LIST_STORE(gtk_combo_box_get_model(
312                                 GTK_COMBO_BOX(folder_type)));
313
314         COMBOBOX_ADD (folder_type_menu, _("Normal"),  F_NORMAL);
315         COMBOBOX_ADD (folder_type_menu, _("Inbox"),  F_INBOX);
316         COMBOBOX_ADD (folder_type_menu, _("Outbox"),  F_OUTBOX);
317         COMBOBOX_ADD (folder_type_menu, _("Drafts"),  F_DRAFT);
318         COMBOBOX_ADD (folder_type_menu, _("Queue"),  F_QUEUE);
319         COMBOBOX_ADD (folder_type_menu, _("Trash"),  F_TRASH);
320
321         combobox_select_by_data(GTK_COMBO_BOX(folder_type), type);
322
323         dummy_checkbtn = gtk_check_button_new();
324         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dummy_checkbtn), type != F_INBOX);
325         gtk_widget_set_sensitive(dummy_checkbtn, FALSE);
326
327         if (type == item->stype && type == F_NORMAL)
328                 gtk_widget_set_sensitive(folder_type, TRUE);
329         else
330                 gtk_widget_set_sensitive(folder_type, FALSE);
331
332         label = gtk_label_new(_("Folder type"));
333         gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
334         gtk_table_attach(GTK_TABLE(table), label, 0, 1, 
335                          rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0);
336         gtk_table_attach(GTK_TABLE(table), folder_type, 1, 2, 
337                          rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0);
338         gtk_table_attach(GTK_TABLE(table), dummy_checkbtn, 2, 3, 
339                          rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
340
341         rowcount++;
342
343         /* Simplify Subject */
344         checkbtn_simplify_subject = gtk_check_button_new_with_label(_("Simplify Subject RegExp"));
345         gtk_table_attach(GTK_TABLE(table), checkbtn_simplify_subject, 0, 1, 
346                          rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0);
347         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_simplify_subject), 
348                                      item->prefs->enable_simplify_subject);
349
350         g_signal_connect(G_OBJECT(checkbtn_simplify_subject), "toggled",
351                         G_CALLBACK(folder_regexp_set_subject_example_cb), page);
352
353         entry_simplify_subject = gtk_entry_new();
354         gtk_table_attach(GTK_TABLE(table), entry_simplify_subject, 1, 2, 
355                          rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
356         SET_TOGGLE_SENSITIVITY(checkbtn_simplify_subject, entry_simplify_subject);
357         gtk_entry_set_text(GTK_ENTRY(entry_simplify_subject), 
358                            SAFE_STRING(item->prefs->simplify_subject_regexp));
359
360         g_signal_connect(G_OBJECT(entry_simplify_subject), "changed",
361                         G_CALLBACK(folder_regexp_test_cb), page);
362
363         simplify_subject_rec_checkbtn = gtk_check_button_new();
364         gtk_table_attach(GTK_TABLE(table), simplify_subject_rec_checkbtn, 2, 3, 
365                          rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
366
367         rowcount++;
368
369         /* Test string */
370         label_regexp_test = gtk_label_new(_("Test string:"));
371         gtk_misc_set_alignment(GTK_MISC(label_regexp_test), 1, 0.5);
372         gtk_table_attach(GTK_TABLE(table), label_regexp_test, 0, 1, 
373                          rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0);
374         SET_TOGGLE_SENSITIVITY(checkbtn_simplify_subject, label_regexp_test);
375
376         entry_regexp_test_string = gtk_entry_new();
377         gtk_table_attach(GTK_TABLE(table), entry_regexp_test_string, 1, 2, 
378                          rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
379         SET_TOGGLE_SENSITIVITY(checkbtn_simplify_subject, entry_regexp_test_string);
380
381         g_signal_connect(G_OBJECT(entry_regexp_test_string), "changed",
382                         G_CALLBACK(folder_regexp_test_cb), page);
383
384         rowcount++;
385         
386         /* Test result */
387         label_regexp_result = gtk_label_new(_("Result:"));
388         gtk_misc_set_alignment(GTK_MISC(label_regexp_result), 1, 0.5);
389         gtk_table_attach(GTK_TABLE(table), label_regexp_result, 0, 1, 
390                          rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0);
391         SET_TOGGLE_SENSITIVITY(checkbtn_simplify_subject, label_regexp_result);
392
393         entry_regexp_test_result = gtk_entry_new();
394         gtk_table_attach(GTK_TABLE(table), entry_regexp_test_result, 1, 2, 
395                          rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
396         SET_TOGGLE_SENSITIVITY(checkbtn_simplify_subject, entry_regexp_test_result);
397         gtk_editable_set_editable(GTK_EDITABLE(entry_regexp_test_result), FALSE);
398
399         rowcount++;
400
401         /* Folder chmod */
402         checkbtn_folder_chmod = gtk_check_button_new_with_label(_("Folder chmod"));
403         gtk_table_attach(GTK_TABLE(table), checkbtn_folder_chmod, 0, 1, 
404                          rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0);
405
406         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_folder_chmod), 
407                                      item->prefs->enable_folder_chmod);
408
409         entry_folder_chmod = gtk_entry_new();
410         gtk_table_attach(GTK_TABLE(table), entry_folder_chmod, 1, 2, 
411                          rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
412         SET_TOGGLE_SENSITIVITY(checkbtn_folder_chmod, entry_folder_chmod);
413         if (item->prefs->folder_chmod) {
414                 gchar *buf;
415
416                 buf = g_strdup_printf("%o", item->prefs->folder_chmod);
417                 gtk_entry_set_text(GTK_ENTRY(entry_folder_chmod), buf);
418                 g_free(buf);
419         }
420         
421         folder_chmod_rec_checkbtn = gtk_check_button_new();
422         gtk_table_attach(GTK_TABLE(table), folder_chmod_rec_checkbtn, 2, 3, 
423                          rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
424
425         rowcount++;
426         
427         /* Folder color */
428         folder_color = gtk_label_new(_("Folder color"));
429         gtk_misc_set_alignment(GTK_MISC(folder_color), 0, 0.5);
430         gtk_table_attach(GTK_TABLE(table), folder_color, 0, 1, 
431                          rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0);
432
433         hbox = gtk_hbox_new(FALSE, 0);
434         gtk_table_attach(GTK_TABLE(table), hbox, 1, 2, 
435                          rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
436
437         folder_color_btn = gtk_button_new_with_label("");
438         gtk_widget_set_size_request(folder_color_btn, 36, 26);
439         gtk_box_pack_start (GTK_BOX(hbox), folder_color_btn, FALSE, FALSE, 0);
440         CLAWS_SET_TIP(folder_color_btn,
441                              _("Pick color for folder"));
442
443         page->folder_color = item->prefs->color;
444
445         g_signal_connect(G_OBJECT(folder_color_btn), "clicked",
446                          G_CALLBACK(folder_color_set_dialog),
447                          page);
448
449         gtkut_set_widget_bgcolor_rgb(folder_color_btn, item->prefs->color);
450
451         folder_color_rec_checkbtn = gtk_check_button_new();
452         gtk_table_attach(GTK_TABLE(table), folder_color_rec_checkbtn, 2, 3, 
453                          rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
454
455         rowcount++;
456
457         /* Enable processing at startup */
458         checkbtn_enable_processing =
459                 gtk_check_button_new_with_label(_("Run Processing rules at start-up"));
460         gtk_table_attach(GTK_TABLE(table), checkbtn_enable_processing, 0, 2, 
461                          rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
462
463         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_processing), 
464                                      item->prefs->enable_processing);
465
466         enable_processing_rec_checkbtn = gtk_check_button_new();
467         gtk_table_attach(GTK_TABLE(table), enable_processing_rec_checkbtn, 2, 3, 
468                          rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
469         
470         rowcount++;
471
472         /* Enable processing rules when opening folder */
473         checkbtn_enable_processing_when_opening =
474                 gtk_check_button_new_with_label(_("Run Processing rules when opening"));
475         gtk_table_attach(GTK_TABLE(table), checkbtn_enable_processing_when_opening, 0, 2, 
476                          rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
477
478         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_processing_when_opening), 
479                                      item->prefs->enable_processing_when_opening);
480
481         enable_processing_when_opening_rec_checkbtn = gtk_check_button_new();
482         gtk_table_attach(GTK_TABLE(table), enable_processing_when_opening_rec_checkbtn, 2, 3, 
483                          rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
484         
485         rowcount++;
486
487         /* Check folder for new mail */
488         checkbtn_newmailcheck = gtk_check_button_new_with_label(_("Scan for new mail"));
489         CLAWS_SET_TIP(checkbtn_newmailcheck,
490                              _("Turn this option on if mail is delivered directly "
491                                "to this folder by server side filtering on IMAP or "
492                                "by an external application"));
493         gtk_table_attach(GTK_TABLE(table), checkbtn_newmailcheck, 0, 2,
494                          rowcount, rowcount+1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
495         
496         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_newmailcheck),
497                                                                  item->prefs->newmailcheck);
498         newmailcheck_rec_checkbtn = gtk_check_button_new();
499         gtk_table_attach(GTK_TABLE(table), newmailcheck_rec_checkbtn, 2, 3, 
500                          rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
501
502         rowcount++;
503
504         /* Select HTML part by default? */
505         hbox = gtk_hbox_new (FALSE, 2);
506         gtk_widget_show (hbox);
507         gtk_table_attach (GTK_TABLE(table), hbox, 0, 2,
508                         rowcount, rowcount+1, GTK_FILL, GTK_FILL, 0, 0);
509
510         label = gtk_label_new(_("Select the HTML part of multipart messages"));
511         gtk_widget_show (label);
512         gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 0);
513
514         promote_html_part = gtkut_sc_combobox_create (NULL, FALSE);
515         gtk_widget_show (promote_html_part);
516         gtk_box_pack_start (GTK_BOX(hbox), promote_html_part, FALSE, FALSE, 0);
517
518         promote_html_part_menu = GTK_LIST_STORE(gtk_combo_box_get_model(
519                                 GTK_COMBO_BOX(promote_html_part)));
520         COMBOBOX_ADD (promote_html_part_menu, _("Default"), HTML_PROMOTE_DEFAULT);
521         COMBOBOX_ADD (promote_html_part_menu, _("No"), HTML_PROMOTE_NEVER);
522         COMBOBOX_ADD (promote_html_part_menu, _("Yes"), HTML_PROMOTE_ALWAYS);
523
524         combobox_select_by_data(GTK_COMBO_BOX(promote_html_part),
525                         item->prefs->promote_html_part);
526
527         CLAWS_SET_TIP(hbox, _("\"Default\" will follow global preference (found in /Preferences/"
528                               "Message View/Text Options)"));
529
530         promote_html_part_rec_checkbtn = gtk_check_button_new();
531         gtk_widget_show (promote_html_part_rec_checkbtn);
532         gtk_table_attach(GTK_TABLE(table), promote_html_part_rec_checkbtn, 2, 3, 
533                          rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
534         rowcount++;
535
536         /* Synchronise folder for offline use */
537         checkbtn_offlinesync = gtk_check_button_new_with_label(_("Synchronise for offline use"));
538         gtk_table_attach(GTK_TABLE(table), checkbtn_offlinesync, 0, 2,
539                          rowcount, rowcount+1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
540         
541         offlinesync_rec_checkbtn = gtk_check_button_new();
542         gtk_table_attach(GTK_TABLE(table), offlinesync_rec_checkbtn, 2, 3, 
543                          rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
544
545         rowcount++;
546
547         hbox = gtk_hbox_new (FALSE, 8);
548         gtk_widget_show (hbox);
549         gtk_table_attach(GTK_TABLE(table), hbox, 0, 3,
550                          rowcount, rowcount+1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
551         rowcount++;
552
553         hbox_spc = gtk_hbox_new (FALSE, 0);
554         gtk_widget_show (hbox_spc);
555         gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
556         gtk_widget_set_size_request (hbox_spc, 12, -1);
557
558         label_offlinesync = gtk_label_new(_("Fetch message bodies from the last"));
559         gtk_widget_show (label_offlinesync);
560         gtk_box_pack_start (GTK_BOX (hbox), label_offlinesync, FALSE, FALSE, 0);
561
562         entry_offlinesync = gtk_entry_new();
563         gtk_widget_set_size_request (entry_offlinesync, 64, -1);
564         gtk_widget_show (entry_offlinesync);
565         CLAWS_SET_TIP(entry_offlinesync, _("0: all bodies"));
566         gtk_box_pack_start (GTK_BOX (hbox), entry_offlinesync, FALSE, FALSE, 0);
567
568         label_end_offlinesync = gtk_label_new(_("days"));
569         gtk_widget_show (label_end_offlinesync);
570         gtk_box_pack_start (GTK_BOX (hbox), label_end_offlinesync, FALSE, FALSE, 0);
571
572         checkbtn_remove_old_offlinesync = gtk_check_button_new_with_label(
573                                                 _("Remove older messages bodies"));
574
575         hbox2 = gtk_hbox_new (FALSE, 8);
576         gtk_widget_show (hbox2);
577         gtk_table_attach(GTK_TABLE(table), hbox2, 0, 3,
578                          rowcount, rowcount+1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
579         rowcount++;
580
581         hbox_spc = gtk_hbox_new (FALSE, 0);
582         gtk_widget_show (hbox_spc);
583         gtk_box_pack_start (GTK_BOX (hbox2), hbox_spc, FALSE, FALSE, 0);
584         gtk_widget_set_size_request (hbox_spc, 12, -1);
585         gtk_box_pack_start (GTK_BOX (hbox2), checkbtn_remove_old_offlinesync, FALSE, FALSE, 0);
586
587         SET_TOGGLE_SENSITIVITY (checkbtn_offlinesync, hbox);
588         SET_TOGGLE_SENSITIVITY (checkbtn_offlinesync, hbox2);
589         
590         clean_cache_btn = gtk_button_new_with_label(_("Discard folder cache"));
591         gtk_widget_show (clean_cache_btn);
592         gtk_table_attach(GTK_TABLE(table), clean_cache_btn, 0, 1,
593                          rowcount, rowcount+1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
594         g_signal_connect(G_OBJECT(clean_cache_btn), "clicked",
595                          G_CALLBACK(clean_cache_cb),
596                          page);
597
598         gtk_widget_show_all(table);
599
600         if (item->folder && (item->folder->klass->type != F_IMAP && 
601             item->folder->klass->type != F_NEWS)) {
602                 item->prefs->offlinesync = TRUE;
603                 item->prefs->offlinesync_days = 0;
604                 item->prefs->remove_old_bodies = FALSE;
605
606                 gtk_widget_set_sensitive(GTK_WIDGET(checkbtn_offlinesync),
607                                                                  FALSE);
608                 gtk_widget_set_sensitive(GTK_WIDGET(offlinesync_rec_checkbtn),
609                                                                  FALSE);
610                 gtk_widget_hide(GTK_WIDGET(checkbtn_offlinesync));
611                 gtk_widget_hide(GTK_WIDGET(hbox));
612                 gtk_widget_hide(GTK_WIDGET(hbox2));
613                 gtk_widget_hide(GTK_WIDGET(offlinesync_rec_checkbtn));
614                 gtk_widget_hide(GTK_WIDGET(clean_cache_btn));
615         
616         }
617         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_offlinesync),
618                                                                  item->prefs->offlinesync);
619         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_remove_old_offlinesync),
620                                                                  item->prefs->remove_old_bodies);
621         gtk_entry_set_text(GTK_ENTRY(entry_offlinesync), itos(item->prefs->offlinesync_days));
622
623         page->table = table;
624         page->folder_type = folder_type;
625         page->no_save_warning = no_save_warning;
626
627         page->checkbtn_simplify_subject = checkbtn_simplify_subject;
628         page->entry_simplify_subject = entry_simplify_subject;
629         page->entry_regexp_test_string = entry_regexp_test_string;
630         page->entry_regexp_test_result = entry_regexp_test_result;
631
632         page->checkbtn_folder_chmod = checkbtn_folder_chmod;
633         page->entry_folder_chmod = entry_folder_chmod;
634         page->folder_color_btn = folder_color_btn;
635         page->checkbtn_enable_processing = checkbtn_enable_processing;
636         page->checkbtn_enable_processing_when_opening = checkbtn_enable_processing_when_opening;
637         page->checkbtn_newmailcheck = checkbtn_newmailcheck;
638         page->checkbtn_offlinesync = checkbtn_offlinesync;
639         page->label_offlinesync = label_offlinesync;
640         page->entry_offlinesync = entry_offlinesync;
641         page->label_end_offlinesync = label_end_offlinesync;
642         page->checkbtn_remove_old_offlinesync = checkbtn_remove_old_offlinesync;
643         page->promote_html_part = promote_html_part;
644
645
646         page->simplify_subject_rec_checkbtn  = simplify_subject_rec_checkbtn;
647
648         page->folder_chmod_rec_checkbtn      = folder_chmod_rec_checkbtn;
649         page->folder_color_rec_checkbtn      = folder_color_rec_checkbtn;
650         page->enable_processing_rec_checkbtn = enable_processing_rec_checkbtn;
651         page->enable_processing_when_opening_rec_checkbtn = enable_processing_when_opening_rec_checkbtn;
652         page->newmailcheck_rec_checkbtn      = newmailcheck_rec_checkbtn;
653         page->offlinesync_rec_checkbtn       = offlinesync_rec_checkbtn;
654         page->promote_html_part_rec_checkbtn = promote_html_part_rec_checkbtn;
655
656         page->page.widget = table;
657
658         folder_regexp_set_subject_example_cb(NULL, page);
659 }
660
661 static void prefs_folder_item_general_destroy_widget_func(PrefsPage *page_) 
662 {
663         /* FolderItemGeneralPage *page = (FolderItemGeneralPage *) page_; */
664 }
665
666 /** \brief  Save the prefs in page to folder.
667  *
668  *  If the folder is not the one  specified in page->item, then only those properties 
669  *  that have the relevant 'apply to sub folders' button checked are saved
670  */
671 static void general_save_folder_prefs(FolderItem *folder, FolderItemGeneralPage *page)
672 {
673         FolderItemPrefs *prefs = folder->prefs;
674         gchar *buf;
675         gboolean all = FALSE, summary_update_needed = FALSE;
676         SpecialFolderItemType type = F_NORMAL;
677         FolderView *folderview = mainwindow_get_mainwindow()->folderview;
678         HTMLPromoteType promote_html_part = HTML_PROMOTE_DEFAULT;
679
680         if (folder->path == NULL)
681                 return;
682
683         cm_return_if_fail(prefs != NULL);
684
685         if (page->item == folder) 
686                 all = TRUE;
687
688         type = combobox_get_active_data(GTK_COMBO_BOX(page->folder_type));
689         if (all && folder->stype != type && page->item->parent_stype == F_NORMAL) {
690                 folder_item_change_type(folder, type);
691                 summary_update_needed = TRUE;
692         }
693
694         promote_html_part =
695                 combobox_get_active_data(GTK_COMBO_BOX(page->promote_html_part));
696         if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->promote_html_part_rec_checkbtn)))
697                 prefs->promote_html_part = promote_html_part;
698
699         if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->simplify_subject_rec_checkbtn))) {
700                 gboolean old_simplify_subject = prefs->enable_simplify_subject;
701                 int regexp_diffs = strcmp2(prefs->simplify_subject_regexp, gtk_editable_get_chars(
702                                         GTK_EDITABLE(page->entry_simplify_subject), 0, -1));
703                 prefs->enable_simplify_subject =
704                         gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_simplify_subject));
705                 ASSIGN_STRING(prefs->simplify_subject_regexp,
706                               gtk_editable_get_chars(GTK_EDITABLE(page->entry_simplify_subject), 0, -1));
707                 if (old_simplify_subject != prefs->enable_simplify_subject || regexp_diffs != 0)
708                         summary_update_needed = TRUE;
709         }
710
711         if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->folder_chmod_rec_checkbtn))) {
712                 prefs->enable_folder_chmod = 
713                         gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_folder_chmod));
714                 buf = gtk_editable_get_chars(GTK_EDITABLE(page->entry_folder_chmod), 0, -1);
715                 prefs->folder_chmod = prefs_folder_item_chmod_mode(buf);
716                 g_free(buf);
717         }
718
719         if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->folder_color_rec_checkbtn))) {
720                 int old_color = prefs->color;
721                 prefs->color = page->folder_color;
722         
723                 /* update folder view */
724                 if (prefs->color != old_color)
725                         folder_item_update(folder, F_ITEM_UPDATE_MSGCNT);
726         }
727
728         if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->enable_processing_rec_checkbtn))) {
729                 prefs->enable_processing = 
730                         gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_enable_processing));
731         }
732
733         if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->enable_processing_when_opening_rec_checkbtn))) {
734                 prefs->enable_processing_when_opening = 
735                         gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_enable_processing_when_opening));
736         }
737
738         if (all ||  gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->newmailcheck_rec_checkbtn))) {
739                 prefs->newmailcheck = 
740                         gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_newmailcheck));
741         }
742
743         if (all ||  gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->offlinesync_rec_checkbtn))) {
744                 prefs->offlinesync = 
745                         gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_offlinesync));
746                 prefs->offlinesync_days = 
747                         atoi(gtk_entry_get_text(GTK_ENTRY(page->entry_offlinesync)));
748                 prefs->remove_old_bodies =
749                         gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_remove_old_offlinesync));
750         }
751
752         folder_item_prefs_save_config(folder);
753
754         if (folder->opened && summary_update_needed) {
755                 summary_set_prefs_from_folderitem(folderview->summaryview, folder);
756                 summary_show(folderview->summaryview, folder);
757         }       
758 }       
759
760 static gboolean general_save_recurse_func(GNode *node, gpointer data)
761 {
762         FolderItem *item = (FolderItem *) node->data;
763         FolderItemGeneralPage *page = (FolderItemGeneralPage *) data;
764
765         cm_return_val_if_fail(item != NULL, TRUE);
766         cm_return_val_if_fail(page != NULL, TRUE);
767
768         general_save_folder_prefs(item, page);
769
770         /* optimise by not continuing if none of the 'apply to sub folders'
771            check boxes are selected - and optimise the checking by only doing
772            it once */
773         if ((node == page->item->node) &&
774             !(
775               gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->simplify_subject_rec_checkbtn)) ||
776               gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->folder_chmod_rec_checkbtn)) ||
777               gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->folder_color_rec_checkbtn)) ||
778               gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->enable_processing_rec_checkbtn)) ||
779               gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->enable_processing_when_opening_rec_checkbtn)) ||
780               gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->newmailcheck_rec_checkbtn)) ||
781               gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->offlinesync_rec_checkbtn)) ||
782                                 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->promote_html_part_rec_checkbtn))
783                         ))
784                 return TRUE;
785         else 
786                 return FALSE;
787 }
788
789 static void prefs_folder_item_general_save_func(PrefsPage *page_) 
790 {
791         FolderItemGeneralPage *page = (FolderItemGeneralPage *) page_;
792
793         g_node_traverse(page->item->node, G_PRE_ORDER, G_TRAVERSE_ALL,
794                         -1, general_save_recurse_func, page);
795         
796         main_window_set_menu_sensitive(mainwindow_get_mainwindow());
797
798 }
799
800 static RecvProtocol item_protocol(FolderItem *item)
801 {
802         if (!item)
803                 return A_NONE;
804         if (!item->folder)
805                 return A_NONE;
806         if (!item->folder->account)
807                 return A_NONE;
808         return item->folder->account->protocol;
809 }
810
811 static void prefs_folder_item_compose_create_widget_func(PrefsPage * page_,
812                                                    GtkWindow * window,
813                                                    gpointer data)
814 {
815         FolderItemComposePage *page = (FolderItemComposePage *) page_;
816         FolderItem *item = (FolderItem *) data;
817         guint rowcount;
818         gchar *text = NULL;
819
820         GtkWidget *table;
821         GtkWidget *label;
822         
823         GtkWidget *no_save_warning = NULL;
824         GtkWidget *checkbtn_request_return_receipt = NULL;
825         GtkWidget *checkbtn_save_copy_to_folder = NULL;
826         GtkWidget *checkbtn_default_to = NULL;
827         GtkWidget *entry_default_to = NULL;
828         GtkWidget *checkbtn_default_reply_to = NULL;
829         GtkWidget *entry_default_reply_to = NULL;
830         GtkWidget *checkbtn_default_cc = NULL;
831         GtkWidget *entry_default_cc = NULL;
832         GtkWidget *checkbtn_default_bcc = NULL;
833         GtkWidget *entry_default_bcc = NULL;
834         GtkWidget *checkbtn_default_replyto = NULL;
835         GtkWidget *entry_default_replyto = NULL;
836         GtkWidget *checkbtn_enable_default_account = NULL;
837         GtkWidget *optmenu_default_account = NULL;
838         GtkListStore *optmenu_default_account_menu = NULL;
839         GtkTreeIter iter;
840 #if USE_ENCHANT
841         GtkWidget *checkbtn_enable_default_dictionary = NULL;
842         GtkWidget *combo_default_dictionary = NULL;
843         GtkWidget *checkbtn_enable_default_alt_dictionary = NULL;
844         GtkWidget *combo_default_alt_dictionary = NULL;
845         GtkWidget *default_dictionary_rec_checkbtn = NULL;
846         GtkWidget *default_alt_dictionary_rec_checkbtn = NULL;
847         gchar *dictionary;
848 #endif
849         GtkWidget *request_return_receipt_rec_checkbtn = NULL;
850         GtkWidget *save_copy_to_folder_rec_checkbtn = NULL;
851         GtkWidget *default_to_rec_checkbtn = NULL;
852         GtkWidget *default_reply_to_rec_checkbtn = NULL;
853         GtkWidget *default_cc_rec_checkbtn = NULL;
854         GtkWidget *default_bcc_rec_checkbtn = NULL;
855         GtkWidget *default_replyto_rec_checkbtn = NULL;
856         GtkWidget *default_account_rec_checkbtn = NULL;
857
858         GList *cur_ac;
859         GList *account_list;
860         PrefsAccount *ac_prefs;
861         gboolean default_account_set = FALSE;
862
863         page->item         = item;
864
865         /* Table */
866 #if USE_ENCHANT
867 # define TABLEHEIGHT 7
868 #else
869 # define TABLEHEIGHT 6
870 #endif
871         table = gtk_table_new(TABLEHEIGHT, 3, FALSE);
872         gtk_container_set_border_width (GTK_CONTAINER (table), VBOX_BORDER);
873         gtk_table_set_row_spacings(GTK_TABLE(table), 4);
874         gtk_table_set_col_spacings(GTK_TABLE(table), 4);
875         rowcount = 0;
876
877         if (!can_save) {
878                 no_save_warning = prefs_folder_no_save_warning_create_widget();
879                 gtk_table_attach(GTK_TABLE(table), no_save_warning, 0, 3,
880                          rowcount, rowcount + 1, GTK_FILL, 0, 0, 0);
881                 rowcount++;
882         }
883         
884         /* Apply to subfolders */
885         label = gtk_label_new(_("Apply to\nsubfolders"));
886         gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.5);
887         gtk_table_attach(GTK_TABLE(table), label, 2, 3,
888                          rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
889         rowcount++;
890
891         if (item_protocol(item) != A_NNTP) {
892                 /* Request Return Receipt */
893                 checkbtn_request_return_receipt = gtk_check_button_new_with_label
894                         (_("Request Return Receipt"));
895                 gtk_table_attach(GTK_TABLE(table), checkbtn_request_return_receipt, 
896                                  0, 2, rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, 
897                                  GTK_FILL, 0, 0);
898                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_request_return_receipt),
899                                              item->ret_rcpt ? TRUE : FALSE);
900
901                 request_return_receipt_rec_checkbtn = gtk_check_button_new();
902                 gtk_table_attach(GTK_TABLE(table), request_return_receipt_rec_checkbtn, 2, 3, 
903                                  rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
904
905                 rowcount++;
906
907                 /* Save Copy to Folder */
908                 checkbtn_save_copy_to_folder = gtk_check_button_new_with_label
909                         (_("Save copy of outgoing messages to this folder instead of Sent"));
910                 gtk_table_attach(GTK_TABLE(table), checkbtn_save_copy_to_folder, 0, 2, 
911                                  rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0);
912                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_save_copy_to_folder),
913                                              item->prefs->save_copy_to_folder ? TRUE : FALSE);
914
915                 save_copy_to_folder_rec_checkbtn = gtk_check_button_new();
916                 gtk_table_attach(GTK_TABLE(table), save_copy_to_folder_rec_checkbtn, 2, 3, 
917                                  rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
918
919                 rowcount++;
920
921                 /* Default To */
922                 text = g_strdup_printf(_("Default %s"), prefs_common_translated_header_name("To:"));
923                 checkbtn_default_to = gtk_check_button_new_with_label(text);
924                 gtk_table_attach(GTK_TABLE(table), checkbtn_default_to, 0, 1, 
925                                  rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
926                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_default_to), 
927                                              item->prefs->enable_default_to);
928                 g_free(text);
929
930                 entry_default_to = gtk_entry_new();
931                 gtk_table_attach(GTK_TABLE(table), entry_default_to, 1, 2,
932                                  rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
933                 SET_TOGGLE_SENSITIVITY(checkbtn_default_to, entry_default_to);
934                 gtk_entry_set_text(GTK_ENTRY(entry_default_to), SAFE_STRING(item->prefs->default_to));
935                 address_completion_register_entry(GTK_ENTRY(entry_default_to),
936                                 TRUE);
937
938                 default_to_rec_checkbtn = gtk_check_button_new();
939                 gtk_table_attach(GTK_TABLE(table), default_to_rec_checkbtn, 2, 3, 
940                                  rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
941
942                 rowcount++;
943
944                 /* Default address to reply to */
945                 text = g_strdup_printf(_("Default %s for replies"), prefs_common_translated_header_name("To:"));
946                 checkbtn_default_reply_to = gtk_check_button_new_with_label(text);
947                 gtk_table_attach(GTK_TABLE(table), checkbtn_default_reply_to, 0, 1, 
948                                  rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
949                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_default_reply_to), 
950                                              item->prefs->enable_default_reply_to);
951                 g_free(text);
952
953                 entry_default_reply_to = gtk_entry_new();
954                 gtk_table_attach(GTK_TABLE(table), entry_default_reply_to, 1, 2,
955                                  rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
956                 SET_TOGGLE_SENSITIVITY(checkbtn_default_reply_to, entry_default_reply_to);
957                 gtk_entry_set_text(GTK_ENTRY(entry_default_reply_to), SAFE_STRING(item->prefs->default_reply_to));
958                 address_completion_register_entry(
959                                 GTK_ENTRY(entry_default_reply_to), TRUE);
960
961                 default_reply_to_rec_checkbtn = gtk_check_button_new();
962                 gtk_table_attach(GTK_TABLE(table), default_reply_to_rec_checkbtn, 2, 3, 
963                                  rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
964
965                 rowcount++;
966
967                 /* Default Cc */
968                 text = g_strdup_printf(_("Default %s"), prefs_common_translated_header_name("Cc:"));
969                 checkbtn_default_cc = gtk_check_button_new_with_label(text);
970                 gtk_table_attach(GTK_TABLE(table), checkbtn_default_cc, 0, 1, 
971                                  rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
972                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_default_cc), 
973                                              item->prefs->enable_default_cc);
974                 g_free(text);
975
976                 entry_default_cc = gtk_entry_new();
977                 gtk_table_attach(GTK_TABLE(table), entry_default_cc, 1, 2,
978                                  rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
979                 SET_TOGGLE_SENSITIVITY(checkbtn_default_cc, entry_default_cc);
980                 gtk_entry_set_text(GTK_ENTRY(entry_default_cc), SAFE_STRING(item->prefs->default_cc));
981                 address_completion_register_entry(GTK_ENTRY(entry_default_cc),
982                                 TRUE);
983
984                 default_cc_rec_checkbtn = gtk_check_button_new();
985                 gtk_table_attach(GTK_TABLE(table), default_cc_rec_checkbtn, 2, 3, 
986                                  rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
987
988                 rowcount++;
989
990                 /* Default Bcc */
991                 text = g_strdup_printf(_("Default %s"), prefs_common_translated_header_name("Bcc:"));
992                 checkbtn_default_bcc = gtk_check_button_new_with_label(text);
993                 gtk_table_attach(GTK_TABLE(table), checkbtn_default_bcc, 0, 1, 
994                                  rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
995                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_default_bcc), 
996                                              item->prefs->enable_default_bcc);
997                 g_free(text);
998
999                 entry_default_bcc = gtk_entry_new();
1000                 gtk_table_attach(GTK_TABLE(table), entry_default_bcc, 1, 2,
1001                                  rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
1002                 SET_TOGGLE_SENSITIVITY(checkbtn_default_bcc, entry_default_bcc);
1003                 gtk_entry_set_text(GTK_ENTRY(entry_default_bcc), SAFE_STRING(item->prefs->default_bcc));
1004                 address_completion_register_entry(GTK_ENTRY(entry_default_bcc),
1005                                 TRUE);
1006
1007                 default_bcc_rec_checkbtn = gtk_check_button_new();
1008                 gtk_table_attach(GTK_TABLE(table), default_bcc_rec_checkbtn, 2, 3, 
1009                                  rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
1010
1011                 rowcount++;
1012
1013                 /* Default Reply-to */
1014                 text = g_strdup_printf(_("Default %s"), prefs_common_translated_header_name("Reply-To:"));
1015                 checkbtn_default_replyto = gtk_check_button_new_with_label(text);
1016                 gtk_table_attach(GTK_TABLE(table), checkbtn_default_replyto, 0, 1, 
1017                                  rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
1018                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_default_replyto), 
1019                                              item->prefs->enable_default_replyto);
1020                 g_free(text);
1021
1022                 entry_default_replyto = gtk_entry_new();
1023                 gtk_table_attach(GTK_TABLE(table), entry_default_replyto, 1, 2,
1024                                  rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
1025                 SET_TOGGLE_SENSITIVITY(checkbtn_default_replyto, entry_default_replyto);
1026                 gtk_entry_set_text(GTK_ENTRY(entry_default_replyto), SAFE_STRING(item->prefs->default_replyto));
1027                 address_completion_register_entry(GTK_ENTRY(entry_default_replyto),
1028                                 TRUE);
1029
1030                 default_replyto_rec_checkbtn = gtk_check_button_new();
1031                 gtk_table_attach(GTK_TABLE(table), default_replyto_rec_checkbtn, 2, 3, 
1032                                  rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
1033
1034                 rowcount++;
1035         }
1036         /* Default account */
1037         checkbtn_enable_default_account = gtk_check_button_new_with_label(_("Default account"));
1038         gtk_table_attach(GTK_TABLE(table), checkbtn_enable_default_account, 0, 1, 
1039                          rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
1040         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_default_account), 
1041                                      item->prefs->enable_default_account);
1042
1043         optmenu_default_account = gtkut_sc_combobox_create(NULL, FALSE);
1044         gtk_table_attach(GTK_TABLE(table), optmenu_default_account, 1, 2, 
1045                          rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
1046         optmenu_default_account_menu = GTK_LIST_STORE(
1047                         gtk_combo_box_get_model(GTK_COMBO_BOX(optmenu_default_account)));
1048
1049         account_list = account_get_list();
1050         for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1051                 ac_prefs = (PrefsAccount *)cur_ac->data;
1052                 if (item->folder->account &&
1053                     ( (item_protocol(item) == A_NNTP && ac_prefs->protocol != A_NNTP)
1054                     ||(item_protocol(item) != A_NNTP && ac_prefs->protocol == A_NNTP))) 
1055                         continue;
1056
1057                 if (item->folder->klass->type != F_NEWS && ac_prefs->protocol == A_NNTP)
1058                         continue;
1059
1060                 COMBOBOX_ADD_ESCAPED (optmenu_default_account_menu,
1061                                         ac_prefs->account_name?ac_prefs->account_name : _("Untitled"),
1062                                         ac_prefs->account_id);
1063
1064                 /* Set combobox to current default account id */
1065                 if (ac_prefs->account_id == item->prefs->default_account) {
1066                         combobox_select_by_data(GTK_COMBO_BOX(optmenu_default_account),
1067                                         ac_prefs->account_id);
1068                         default_account_set = TRUE;
1069                 }
1070         }
1071
1072         /* If nothing has been set (folder doesn't have a default account set),
1073          * pre-select global default account, since that's what actually used
1074          * anyway. We don't want nothing selected in combobox. */
1075         if( !default_account_set )
1076                 combobox_select_by_data(GTK_COMBO_BOX(optmenu_default_account),
1077                                 account_get_default()->account_id);
1078
1079         SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_account, optmenu_default_account);
1080
1081         default_account_rec_checkbtn = gtk_check_button_new();
1082         gtk_table_attach(GTK_TABLE(table), default_account_rec_checkbtn, 2, 3, 
1083                          rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
1084         rowcount++;
1085
1086 #if USE_ENCHANT
1087         /* Default dictionary */
1088         checkbtn_enable_default_dictionary = gtk_check_button_new_with_label(_("Default dictionary"));
1089         gtk_table_attach(GTK_TABLE(table), checkbtn_enable_default_dictionary, 0, 1,
1090                          rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
1091         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_default_dictionary),
1092                                      item->prefs->enable_default_dictionary);
1093
1094         combo_default_dictionary = gtkaspell_dictionary_combo_new(TRUE);
1095         gtk_table_attach(GTK_TABLE(table), combo_default_dictionary, 1, 2,
1096                          rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
1097
1098         dictionary = item->prefs->default_dictionary;
1099         if (dictionary && strrchr(dictionary, '/')) {
1100                 gchar *tmp = g_strdup(strrchr(dictionary, '/')+1);
1101                 g_free(item->prefs->default_dictionary);
1102                 item->prefs->default_dictionary = tmp;
1103                 dictionary = item->prefs->default_dictionary;
1104         }
1105         if (item->prefs->default_dictionary &&
1106             strchr(item->prefs->default_dictionary, '-')) {
1107                 *(strchr(item->prefs->default_dictionary, '-')) = '\0';
1108         }
1109         if (dictionary)
1110                 gtkaspell_set_dictionary_menu_active_item(
1111                         GTK_COMBO_BOX(combo_default_dictionary), dictionary);
1112
1113         SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_dictionary, combo_default_dictionary);
1114
1115         default_dictionary_rec_checkbtn = gtk_check_button_new();
1116         gtk_table_attach(GTK_TABLE(table), default_dictionary_rec_checkbtn, 2, 3, 
1117                          rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
1118         
1119         rowcount++;
1120
1121         /* Default dictionary */
1122         checkbtn_enable_default_alt_dictionary = gtk_check_button_new_with_label(_("Default alternate dictionary"));
1123         gtk_table_attach(GTK_TABLE(table), checkbtn_enable_default_alt_dictionary, 0, 1,
1124                          rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
1125         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_default_alt_dictionary),
1126                                      item->prefs->enable_default_alt_dictionary);
1127
1128         combo_default_alt_dictionary = gtkaspell_dictionary_combo_new(FALSE);
1129         gtk_table_attach(GTK_TABLE(table), combo_default_alt_dictionary, 1, 2,
1130                          rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
1131
1132         dictionary = item->prefs->default_alt_dictionary;
1133         if (dictionary && strrchr(dictionary, '/')) {
1134                 gchar *tmp = g_strdup(strrchr(dictionary, '/')+1);
1135                 g_free(item->prefs->default_alt_dictionary);
1136                 item->prefs->default_alt_dictionary = tmp;
1137                 dictionary = item->prefs->default_alt_dictionary;
1138         }
1139         if (item->prefs->default_alt_dictionary &&
1140             strchr(item->prefs->default_alt_dictionary, '-')) {
1141                 *(strchr(item->prefs->default_alt_dictionary, '-')) = '\0';
1142         }
1143         if (dictionary)
1144                 gtkaspell_set_dictionary_menu_active_item(
1145                         GTK_COMBO_BOX(combo_default_alt_dictionary), dictionary);
1146
1147         SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_alt_dictionary, combo_default_alt_dictionary);
1148
1149         default_alt_dictionary_rec_checkbtn = gtk_check_button_new();
1150         gtk_table_attach(GTK_TABLE(table), default_alt_dictionary_rec_checkbtn, 2, 3, 
1151                          rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
1152         
1153         rowcount++;
1154 #endif
1155
1156         gtk_widget_show_all(table);
1157
1158         page->window = GTK_WIDGET(window);
1159         page->table = table;
1160         page->no_save_warning = no_save_warning;
1161         page->checkbtn_request_return_receipt = checkbtn_request_return_receipt;
1162         page->checkbtn_save_copy_to_folder = checkbtn_save_copy_to_folder;
1163         page->checkbtn_default_to = checkbtn_default_to;
1164         page->entry_default_to = entry_default_to;
1165         page->checkbtn_default_reply_to = checkbtn_default_reply_to;
1166         page->entry_default_reply_to = entry_default_reply_to;
1167         page->checkbtn_default_cc = checkbtn_default_cc;
1168         page->entry_default_cc = entry_default_cc;
1169         page->checkbtn_default_bcc = checkbtn_default_bcc;
1170         page->entry_default_bcc = entry_default_bcc;
1171         page->checkbtn_default_replyto = checkbtn_default_replyto;
1172         page->entry_default_replyto = entry_default_replyto;
1173         page->checkbtn_enable_default_account = checkbtn_enable_default_account;
1174         page->optmenu_default_account = optmenu_default_account;
1175 #ifdef USE_ENCHANT
1176         page->checkbtn_enable_default_dictionary = checkbtn_enable_default_dictionary;
1177         page->combo_default_dictionary = combo_default_dictionary;
1178         page->checkbtn_enable_default_alt_dictionary = checkbtn_enable_default_alt_dictionary;
1179         page->combo_default_alt_dictionary = combo_default_alt_dictionary;
1180 #endif
1181
1182         page->request_return_receipt_rec_checkbtn = request_return_receipt_rec_checkbtn;
1183         page->save_copy_to_folder_rec_checkbtn    = save_copy_to_folder_rec_checkbtn;
1184         page->default_to_rec_checkbtn             = default_to_rec_checkbtn;
1185         page->default_reply_to_rec_checkbtn       = default_reply_to_rec_checkbtn;
1186         page->default_cc_rec_checkbtn             = default_cc_rec_checkbtn;
1187         page->default_bcc_rec_checkbtn            = default_bcc_rec_checkbtn;
1188         page->default_replyto_rec_checkbtn                = default_replyto_rec_checkbtn;
1189         page->default_account_rec_checkbtn        = default_account_rec_checkbtn;
1190 #if USE_ENCHANT
1191         page->default_dictionary_rec_checkbtn = default_dictionary_rec_checkbtn;
1192         page->default_alt_dictionary_rec_checkbtn = default_alt_dictionary_rec_checkbtn;
1193 #endif
1194
1195         page->page.widget = table;
1196 }
1197
1198 static void prefs_folder_item_compose_destroy_widget_func(PrefsPage *page_) 
1199 {
1200         FolderItemComposePage *page = (FolderItemComposePage *) page_;
1201
1202         if (page->entry_default_to)
1203                 address_completion_unregister_entry(GTK_ENTRY(page->entry_default_to));
1204         if (page->entry_default_reply_to)
1205                 address_completion_unregister_entry(GTK_ENTRY(page->entry_default_reply_to));
1206         if (page->entry_default_cc)
1207                 address_completion_unregister_entry(GTK_ENTRY(page->entry_default_cc));
1208         if (page->entry_default_bcc)
1209                 address_completion_unregister_entry(GTK_ENTRY(page->entry_default_bcc));
1210         if (page->entry_default_replyto)
1211                 address_completion_unregister_entry(GTK_ENTRY(page->entry_default_replyto));
1212 }
1213
1214 /** \brief  Save the prefs in page to folder.
1215  *
1216  *  If the folder is not the one  specified in page->item, then only those properties 
1217  *  that have the relevant 'apply to sub folders' button checked are saved
1218  */
1219 static void compose_save_folder_prefs(FolderItem *folder, FolderItemComposePage *page)
1220 {
1221         FolderItemPrefs *prefs = folder->prefs;
1222
1223         gboolean all = FALSE;
1224
1225         if (folder->path == NULL)
1226                 return;
1227
1228         if (page->item == folder) 
1229                 all = TRUE;
1230
1231         cm_return_if_fail(prefs != NULL);
1232
1233         if (item_protocol(folder) != A_NNTP) {
1234                 if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->request_return_receipt_rec_checkbtn))) {
1235                         prefs->request_return_receipt = 
1236                                 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_request_return_receipt));
1237                         /* MIGRATION */    
1238                         folder->ret_rcpt = prefs->request_return_receipt;
1239                 }
1240
1241                 if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->save_copy_to_folder_rec_checkbtn))) {
1242                         prefs->save_copy_to_folder = 
1243                                 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_save_copy_to_folder));
1244                 }
1245
1246                 if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_to_rec_checkbtn))) {
1247
1248                         prefs->enable_default_to = 
1249                                 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_default_to));
1250                         ASSIGN_STRING(prefs->default_to,
1251                                       gtk_editable_get_chars(GTK_EDITABLE(page->entry_default_to), 0, -1));
1252                 }
1253
1254                 if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_reply_to_rec_checkbtn))) {
1255                         prefs->enable_default_reply_to = 
1256                                 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_default_reply_to));
1257                         ASSIGN_STRING(prefs->default_reply_to,
1258                                       gtk_editable_get_chars(GTK_EDITABLE(page->entry_default_reply_to), 0, -1));
1259                 }
1260
1261                 if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_cc_rec_checkbtn))) {
1262
1263                         prefs->enable_default_cc = 
1264                                 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_default_cc));
1265                         ASSIGN_STRING(prefs->default_cc,
1266                                       gtk_editable_get_chars(GTK_EDITABLE(page->entry_default_cc), 0, -1));
1267                 }
1268
1269                 if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_bcc_rec_checkbtn))) {
1270
1271                         prefs->enable_default_bcc = 
1272                                 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_default_bcc));
1273                         ASSIGN_STRING(prefs->default_bcc,
1274                                       gtk_editable_get_chars(GTK_EDITABLE(page->entry_default_bcc), 0, -1));
1275                 }
1276
1277                 if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_replyto_rec_checkbtn))) {
1278
1279                         prefs->enable_default_replyto = 
1280                                 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_default_replyto));
1281                         ASSIGN_STRING(prefs->default_replyto,
1282                                       gtk_editable_get_chars(GTK_EDITABLE(page->entry_default_replyto), 0, -1));
1283                 }
1284
1285         } else {
1286                 prefs->request_return_receipt = FALSE;
1287                 prefs->save_copy_to_folder = FALSE;
1288                 prefs->enable_default_to = FALSE;
1289                 prefs->enable_default_reply_to = FALSE;
1290                 prefs->enable_default_cc = FALSE;
1291                 prefs->enable_default_bcc = FALSE;
1292                 prefs->enable_default_replyto = FALSE;
1293         }
1294
1295         if (all || gtk_toggle_button_get_active(
1296                                 GTK_TOGGLE_BUTTON(page->default_account_rec_checkbtn))) {
1297                 prefs->enable_default_account = 
1298                         gtk_toggle_button_get_active(
1299                                         GTK_TOGGLE_BUTTON(page->checkbtn_enable_default_account));
1300                 prefs->default_account = combobox_get_active_data(
1301                                 GTK_COMBO_BOX(page->optmenu_default_account));
1302         }
1303
1304 #if USE_ENCHANT
1305         if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_dictionary_rec_checkbtn))) {
1306                 prefs->enable_default_dictionary =
1307                         gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_enable_default_dictionary));
1308                 ASSIGN_STRING(prefs->default_dictionary,
1309                               gtkaspell_get_dictionary_menu_active_item(
1310                                         GTK_COMBO_BOX(page->combo_default_dictionary)));
1311         }
1312         if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_alt_dictionary_rec_checkbtn))) {
1313                 prefs->enable_default_alt_dictionary =
1314                         gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_enable_default_alt_dictionary));
1315                 ASSIGN_STRING(prefs->default_alt_dictionary,
1316                               gtkaspell_get_dictionary_menu_active_item(
1317                                       GTK_COMBO_BOX(page->combo_default_alt_dictionary)));
1318         }
1319 #endif
1320
1321         folder_item_prefs_save_config(folder);
1322 }       
1323
1324 static gboolean compose_save_recurse_func(GNode *node, gpointer data)
1325 {
1326         FolderItem *item = (FolderItem *) node->data;
1327         FolderItemComposePage *page = (FolderItemComposePage *) data;
1328
1329         cm_return_val_if_fail(item != NULL, TRUE);
1330         cm_return_val_if_fail(page != NULL, TRUE);
1331
1332         compose_save_folder_prefs(item, page);
1333
1334         /* optimise by not continuing if none of the 'apply to sub folders'
1335            check boxes are selected - and optimise the checking by only doing
1336            it once */
1337         if ((node == page->item->node) && item_protocol(item) != A_NNTP &&
1338             !(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->request_return_receipt_rec_checkbtn)) ||
1339               gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->save_copy_to_folder_rec_checkbtn)) ||
1340               gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_to_rec_checkbtn)) ||
1341               gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_account_rec_checkbtn)) ||
1342               gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_cc_rec_checkbtn)) ||
1343               gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_bcc_rec_checkbtn)) ||
1344               gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_replyto_rec_checkbtn)) ||
1345 #if USE_ENCHANT
1346               gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_dictionary_rec_checkbtn)) ||
1347               gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_alt_dictionary_rec_checkbtn)) ||
1348 #endif
1349               gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_reply_to_rec_checkbtn))
1350                         ))
1351                 return TRUE;
1352         else if ((node == page->item->node) && item_protocol(item) == A_NNTP &&
1353             !(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_account_rec_checkbtn)) 
1354 #if USE_ENCHANT
1355               || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_dictionary_rec_checkbtn))
1356               || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_alt_dictionary_rec_checkbtn))
1357 #endif
1358                     ))
1359                 return TRUE;
1360         else 
1361                 return FALSE;
1362 }
1363
1364 static void prefs_folder_item_compose_save_func(PrefsPage *page_) 
1365 {
1366         FolderItemComposePage *page = (FolderItemComposePage *) page_;
1367
1368         g_node_traverse(page->item->node, G_PRE_ORDER, G_TRAVERSE_ALL,
1369                         -1, compose_save_recurse_func, page);
1370
1371 }
1372
1373 static void prefs_folder_item_templates_create_widget_func(PrefsPage * page_,
1374                                                    GtkWindow * window,
1375                                                    gpointer data)
1376 {
1377         FolderItemTemplatesPage *page = (FolderItemTemplatesPage *) page_;
1378         FolderItem *item = (FolderItem *) data;
1379
1380         GtkWidget *notebook;
1381         GtkWidget *vbox;
1382         GtkWidget *page_vbox;
1383         GtkWidget *no_save_warning;
1384         GtkWidget *new_msg_format_rec_checkbtn;
1385         GtkWidget *reply_format_rec_checkbtn;
1386         GtkWidget *forward_format_rec_checkbtn;
1387         GtkWidget *hbox;
1388         GtkWidget *vbox_format;
1389         
1390         page->item = item;
1391
1392         page_vbox = gtk_vbox_new (FALSE, 0);
1393         gtk_container_set_border_width (GTK_CONTAINER (page_vbox), VBOX_BORDER);
1394         gtk_widget_show (page_vbox);
1395         
1396         if (!can_save) {
1397                 no_save_warning = prefs_folder_no_save_warning_create_widget();
1398                 gtk_box_pack_start(GTK_BOX(page_vbox),
1399                                    no_save_warning, FALSE, FALSE, 0);
1400         }
1401
1402         /* Notebook */
1403         notebook = gtk_notebook_new();
1404         gtk_widget_show(notebook);
1405         gtk_box_pack_start(GTK_BOX(page_vbox), notebook, TRUE, TRUE, 4);
1406
1407         /* compose format */
1408         vbox = gtk_vbox_new (FALSE, VSPACING);
1409         gtk_widget_show (vbox);
1410         gtk_container_set_border_width (GTK_CONTAINER (vbox), VBOX_BORDER);
1411
1412         quotefmt_create_new_msg_fmt_widgets(
1413                                 window,
1414                                 vbox,
1415                                 &page->checkbtn_compose_with_format,
1416                                 &page->compose_override_from_format,
1417                                 &page->compose_subject_format,
1418                                 &page->compose_body_format,
1419                                 FALSE, FALSE);
1420         address_completion_register_entry(GTK_ENTRY(page->compose_override_from_format),
1421                         TRUE);
1422         
1423         vbox_format = gtk_widget_get_parent(
1424                         gtk_widget_get_parent(page->compose_body_format));
1425
1426         hbox = gtk_hbox_new (FALSE, 0);
1427         gtk_box_pack_end (GTK_BOX(vbox_format), hbox, FALSE, FALSE, 0);
1428         quotefmt_add_info_button(window, hbox);
1429         
1430         new_msg_format_rec_checkbtn = gtk_check_button_new_with_label(
1431                         _("Apply to subfolders"));
1432         gtk_box_pack_end (GTK_BOX(hbox), new_msg_format_rec_checkbtn, FALSE, FALSE, 0);
1433         gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, gtk_label_new(_("Compose")));
1434
1435         /* reply format */
1436         vbox = gtk_vbox_new (FALSE, VSPACING);
1437         gtk_widget_show (vbox);
1438         gtk_container_set_border_width (GTK_CONTAINER (vbox), VBOX_BORDER);
1439
1440         quotefmt_create_reply_fmt_widgets(
1441                                 window,
1442                                 vbox,
1443                                 &page->checkbtn_reply_with_format,
1444                                 &page->reply_override_from_format,
1445                                 &page->reply_quotemark,
1446                                 &page->reply_body_format,
1447                                 FALSE, FALSE);
1448         address_completion_register_entry(GTK_ENTRY(page->reply_override_from_format),
1449                         TRUE);
1450
1451         vbox_format = gtk_widget_get_parent(
1452                         gtk_widget_get_parent(page->reply_body_format));
1453
1454         hbox = gtk_hbox_new (FALSE, 0);
1455         gtk_box_pack_end (GTK_BOX(vbox_format), hbox, FALSE, FALSE, 0);
1456         quotefmt_add_info_button(window, hbox);
1457
1458         reply_format_rec_checkbtn = gtk_check_button_new_with_label(
1459                         _("Apply to subfolders"));
1460         gtk_box_pack_end (GTK_BOX(hbox), reply_format_rec_checkbtn, FALSE, FALSE, 0);
1461         gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, gtk_label_new(_("Reply")));
1462
1463         /* forward format */
1464         vbox = gtk_vbox_new (FALSE, VSPACING);
1465         gtk_widget_show (vbox);
1466         gtk_container_set_border_width (GTK_CONTAINER (vbox), VBOX_BORDER);
1467
1468         quotefmt_create_forward_fmt_widgets(
1469                                 window,
1470                                 vbox,
1471                                 &page->checkbtn_forward_with_format,
1472                                 &page->forward_override_from_format,
1473                                 &page->forward_quotemark,
1474                                 &page->forward_body_format,
1475                                 FALSE, FALSE);
1476         address_completion_register_entry(GTK_ENTRY(page->forward_override_from_format),
1477                         TRUE);
1478
1479         vbox_format = gtk_widget_get_parent(
1480                         gtk_widget_get_parent(page->forward_body_format));
1481
1482         hbox = gtk_hbox_new (FALSE, 0);
1483         gtk_box_pack_end (GTK_BOX(vbox_format), hbox, FALSE, FALSE, 0);
1484         quotefmt_add_info_button(window, hbox);
1485
1486         forward_format_rec_checkbtn = gtk_check_button_new_with_label(
1487                         _("Apply to subfolders"));
1488         gtk_box_pack_end (GTK_BOX(hbox), forward_format_rec_checkbtn, FALSE, FALSE, 0);
1489         gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, gtk_label_new(_("Forward")));
1490
1491         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(page->checkbtn_compose_with_format),
1492                         item->prefs->compose_with_format);
1493         pref_set_entry_from_pref(GTK_ENTRY(page->compose_override_from_format),
1494                         item->prefs->compose_override_from_format);
1495         pref_set_entry_from_pref(GTK_ENTRY(page->compose_subject_format),
1496                         item->prefs->compose_subject_format);
1497         pref_set_textview_from_pref(GTK_TEXT_VIEW(page->compose_body_format),
1498                         item->prefs->compose_body_format);
1499
1500         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(page->checkbtn_reply_with_format),
1501                         item->prefs->reply_with_format);
1502         pref_set_entry_from_pref(GTK_ENTRY(page->reply_quotemark),
1503                         item->prefs->reply_quotemark);
1504         pref_set_entry_from_pref(GTK_ENTRY(page->reply_override_from_format),
1505                         item->prefs->reply_override_from_format);
1506         pref_set_textview_from_pref(GTK_TEXT_VIEW(page->reply_body_format),
1507                         item->prefs->reply_body_format);
1508
1509         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(page->checkbtn_forward_with_format),
1510                         item->prefs->forward_with_format);
1511         pref_set_entry_from_pref(GTK_ENTRY(page->forward_quotemark),
1512                         item->prefs->forward_quotemark);
1513         pref_set_entry_from_pref(GTK_ENTRY(page->forward_override_from_format),
1514                         item->prefs->forward_override_from_format);
1515         pref_set_textview_from_pref(GTK_TEXT_VIEW(page->forward_body_format),
1516                         item->prefs->forward_body_format);
1517
1518         gtk_widget_show_all(page_vbox);
1519
1520         page->window = GTK_WIDGET(window);
1521
1522         page->new_msg_format_rec_checkbtn = new_msg_format_rec_checkbtn;
1523         page->reply_format_rec_checkbtn = reply_format_rec_checkbtn;
1524         page->forward_format_rec_checkbtn = forward_format_rec_checkbtn;
1525
1526         page->page.widget = page_vbox;
1527 }
1528
1529 static void prefs_folder_item_templates_destroy_widget_func(PrefsPage *page_) 
1530 {
1531         FolderItemTemplatesPage *page = (FolderItemTemplatesPage *) page_;
1532
1533         if (page->compose_override_from_format)
1534                 address_completion_unregister_entry(GTK_ENTRY(page->compose_override_from_format));             
1535         if (page->reply_override_from_format)
1536                 address_completion_unregister_entry(GTK_ENTRY(page->reply_override_from_format));               
1537         if (page->forward_override_from_format)
1538                 address_completion_unregister_entry(GTK_ENTRY(page->forward_override_from_format));             
1539 }
1540
1541 /** \brief  Save the prefs in page to folder.
1542  *
1543  *  If the folder is not the one  specified in page->item, then only those properties 
1544  *  that have the relevant 'apply to sub folders' button checked are saved
1545  */
1546 static void templates_save_folder_prefs(FolderItem *folder, FolderItemTemplatesPage *page)
1547 {
1548         FolderItemPrefs *prefs = folder->prefs;
1549         gboolean all = FALSE;
1550
1551         if (folder->path == NULL)
1552                 return;
1553
1554         if (page->item == folder) 
1555                 all = TRUE;
1556
1557         cm_return_if_fail(prefs != NULL);
1558
1559         /* save and check formats */
1560
1561         if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->new_msg_format_rec_checkbtn))) {
1562                 
1563                 prefs->compose_with_format =
1564                         gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_compose_with_format));
1565                 prefs->compose_override_from_format = pref_get_pref_from_entry(
1566                                 GTK_ENTRY(page->compose_override_from_format));
1567                 prefs->compose_subject_format = pref_get_pref_from_entry(
1568                                 GTK_ENTRY(page->compose_subject_format));
1569                 prefs->compose_body_format = pref_get_pref_from_textview(
1570                                 GTK_TEXT_VIEW(page->compose_body_format));
1571                 quotefmt_check_new_msg_formats(prefs->compose_with_format,
1572                                                 prefs->compose_override_from_format,
1573                                                 prefs->compose_subject_format,
1574                                                 prefs->compose_body_format);
1575         }
1576
1577         if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->reply_format_rec_checkbtn))) {
1578                 prefs->reply_with_format =
1579                         gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_reply_with_format));
1580                 prefs->reply_quotemark = gtk_editable_get_chars(
1581                                 GTK_EDITABLE(page->reply_quotemark), 0, -1);
1582                 prefs->reply_override_from_format = pref_get_pref_from_entry(
1583                                 GTK_ENTRY(page->reply_override_from_format));
1584                 prefs->reply_body_format = pref_get_pref_from_textview(
1585                                 GTK_TEXT_VIEW(page->reply_body_format));
1586                 quotefmt_check_reply_formats(prefs->reply_with_format,
1587                                                                                 prefs->reply_override_from_format,
1588                                                                                 prefs->reply_quotemark,
1589                                                                                 prefs->reply_body_format);
1590         }
1591
1592         if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->forward_format_rec_checkbtn))) {
1593                 prefs->forward_with_format =
1594                         gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_forward_with_format));
1595                 prefs->forward_quotemark = gtk_editable_get_chars(
1596                                 GTK_EDITABLE(page->forward_quotemark), 0, -1);
1597                 prefs->forward_override_from_format = pref_get_pref_from_entry(
1598                                 GTK_ENTRY(page->forward_override_from_format));
1599                 prefs->forward_body_format = pref_get_pref_from_textview(
1600                                 GTK_TEXT_VIEW(page->forward_body_format));
1601                 quotefmt_check_forward_formats(prefs->forward_with_format,
1602                                                                                 prefs->forward_override_from_format,
1603                                                                                 prefs->forward_quotemark,
1604                                                                                 prefs->forward_body_format);
1605         }
1606
1607         folder_item_prefs_save_config(folder);
1608 }       
1609
1610 static gboolean templates_save_recurse_func(GNode *node, gpointer data)
1611 {
1612         FolderItem *item = (FolderItem *) node->data;
1613         FolderItemTemplatesPage *page = (FolderItemTemplatesPage *) data;
1614
1615         cm_return_val_if_fail(item != NULL, TRUE);
1616         cm_return_val_if_fail(page != NULL, TRUE);
1617
1618         templates_save_folder_prefs(item, page);
1619
1620         /* optimise by not continuing if none of the 'apply to sub folders'
1621            check boxes are selected - and optimise the checking by only doing
1622            it once */
1623         if ((node == page->item->node) &&
1624             !(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->new_msg_format_rec_checkbtn)) ||
1625               gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->reply_format_rec_checkbtn)) ||
1626               gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->forward_format_rec_checkbtn))))
1627                 return TRUE;
1628         else 
1629                 return FALSE;
1630
1631         return FALSE;
1632 }
1633
1634 static void prefs_folder_item_templates_save_func(PrefsPage *page_) 
1635 {
1636         FolderItemTemplatesPage *page = (FolderItemTemplatesPage *) page_;
1637
1638         g_node_traverse(page->item->node, G_PRE_ORDER, G_TRAVERSE_ALL,
1639                         -1, templates_save_recurse_func, page);
1640
1641 }
1642
1643 static gint prefs_folder_item_chmod_mode(gchar *folder_chmod) 
1644 {
1645         gint newmode = 0;
1646         gchar *tmp;
1647
1648         if (folder_chmod) {
1649                 newmode = strtol(folder_chmod, &tmp, 8);
1650                 if (!(*(folder_chmod) && !(*tmp)))
1651                         newmode = 0;
1652         }
1653
1654         return newmode;
1655 }
1656
1657 static void folder_color_set_dialog(GtkWidget *widget, gpointer data)
1658 {
1659         FolderItemGeneralPage *page = (FolderItemGeneralPage *) data;
1660         gint rgbcolor;
1661
1662         rgbcolor = colorsel_select_color_rgb(_("Pick color for folder"), 
1663                                              page->folder_color);
1664         gtkut_set_widget_bgcolor_rgb(page->folder_color_btn, rgbcolor);
1665         page->folder_color = rgbcolor;
1666 }
1667
1668 static void clean_cache_cb(GtkWidget *widget, gpointer data)
1669 {
1670         FolderItemGeneralPage *page = (FolderItemGeneralPage *) data;
1671         FolderItem *item = page->item;
1672         gboolean was_open = FALSE;
1673         FolderView *folderview = NULL;
1674
1675         if (alertpanel_full(_("Discard cache"), 
1676                             _("Do you really want to discard the local cached "
1677                               "data for this folder?"),
1678                                  GTK_STOCK_CANCEL, g_strconcat("+", _("Discard"), NULL),
1679                                  NULL, FALSE, NULL, ALERT_WARNING, G_ALERTDEFAULT)
1680                 != G_ALERTALTERNATE)
1681                 return;
1682         
1683         if (mainwindow_get_mainwindow())
1684                 folderview = mainwindow_get_mainwindow()->folderview;
1685
1686         if (folderview && item->opened) {
1687                 folderview_close_opened(folderview, FALSE);
1688                 was_open = TRUE;
1689         }
1690         folder_item_discard_cache(item);
1691         if (was_open)
1692                 folderview_select(folderview,item);
1693 }
1694
1695 static regex_t *summary_compile_simplify_regexp(gchar *simplify_subject_regexp)
1696 {
1697         int err;
1698         gchar buf[BUFFSIZE];
1699         regex_t *preg = NULL;
1700
1701         preg = g_new0(regex_t, 1);
1702
1703         err = string_match_precompile(simplify_subject_regexp, 
1704                                       preg, REG_EXTENDED);
1705         if (err) {
1706                 regerror(err, preg, buf, BUFFSIZE);
1707                 g_free(preg);
1708                 preg = NULL;
1709         }
1710
1711         return preg;
1712 }
1713
1714 static void folder_regexp_test_cb(GtkWidget *widget, gpointer data)
1715 {
1716 #if !GTK_CHECK_VERSION(3, 0, 0)
1717         static GdkColor red;
1718         static gboolean colors_initialised = FALSE;
1719 #else
1720         static GdkColor red = { (guint32)0, (guint16)0xff, (guint16)0x70, (guint16)0x70 };
1721 #endif
1722         static gchar buf[BUFFSIZE];
1723         FolderItemGeneralPage *page = (FolderItemGeneralPage *)data;
1724         gchar *test_string, *regexp;
1725         regex_t *preg;
1726
1727         regexp = g_strdup(gtk_entry_get_text(GTK_ENTRY(page->entry_simplify_subject)));
1728         test_string = g_strdup(gtk_entry_get_text(GTK_ENTRY(page->entry_regexp_test_string)));
1729
1730         if (!regexp || !regexp[0]) {
1731                 gtk_widget_modify_base(page->entry_simplify_subject,
1732                                 GTK_STATE_NORMAL, NULL);
1733                 if (test_string)
1734                         gtk_entry_set_text(GTK_ENTRY(page->entry_regexp_test_result), test_string);
1735                         
1736                 g_free(test_string);
1737                 g_free(regexp);
1738                 return;
1739         }
1740
1741         if (!test_string || !test_string[0]) {
1742                 g_free(test_string);
1743                 g_free(regexp);
1744                 return;
1745         }
1746
1747 #if !GTK_CHECK_VERSION(3, 0, 0)
1748         if (!colors_initialised) {
1749                 gdk_color_parse("#ff7070", &red);
1750                 colors_initialised = gdk_colormap_alloc_color(
1751                         gdk_colormap_get_system(), &red, FALSE, TRUE);
1752         }
1753 #endif
1754
1755         preg = summary_compile_simplify_regexp(regexp);
1756 #if !GTK_CHECK_VERSION(3, 0, 0)
1757         if (colors_initialised)
1758                 gtk_widget_modify_base(page->entry_simplify_subject,
1759                                 GTK_STATE_NORMAL, preg ? NULL : &red);
1760 #endif
1761
1762         if (preg != NULL) {
1763                 string_remove_match(buf, BUFFSIZE, test_string, preg);
1764
1765                 gtk_entry_set_text(GTK_ENTRY(page->entry_regexp_test_result), buf);
1766
1767                 regfree(preg);
1768                 g_free(preg);
1769         }
1770
1771         g_free(test_string);
1772         g_free(regexp);
1773 }
1774
1775 static gchar *folder_regexp_get_subject_example(void)
1776 {
1777         MsgInfo *msginfo_selected;
1778         SummaryView *summaryview = NULL;
1779
1780         if (!mainwindow_get_mainwindow())
1781                 return NULL;
1782         summaryview = mainwindow_get_mainwindow()->summaryview;
1783
1784         msginfo_selected = summary_get_selected_msg(summaryview);
1785         return msginfo_selected ? g_strdup(msginfo_selected->subject) : NULL;
1786 }
1787
1788 static void folder_regexp_set_subject_example_cb(GtkWidget *widget, gpointer data)
1789 {
1790         FolderItemGeneralPage *page = (FolderItemGeneralPage *)data;
1791
1792         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_simplify_subject))) {
1793                 gchar *subject = folder_regexp_get_subject_example();
1794                 if (subject) {
1795                         gtk_entry_set_text(GTK_ENTRY(page->entry_regexp_test_string), subject);
1796                         g_free(subject);
1797                 }
1798         }
1799 }
1800
1801 static void register_general_page()
1802 {
1803         static gchar *pfi_general_path[2];
1804         static FolderItemGeneralPage folder_item_general_page;
1805
1806         pfi_general_path[0] = _("General");
1807         pfi_general_path[1] = NULL;
1808
1809         folder_item_general_page.page.path = pfi_general_path;
1810         folder_item_general_page.page.create_widget = prefs_folder_item_general_create_widget_func;
1811         folder_item_general_page.page.destroy_widget = prefs_folder_item_general_destroy_widget_func;
1812         folder_item_general_page.page.save_page = prefs_folder_item_general_save_func;
1813         
1814         prefs_folder_item_register_page((PrefsPage *) &folder_item_general_page, NULL);
1815 }
1816
1817
1818 static void register_compose_page(void)
1819 {
1820         static gchar *pfi_compose_path[2];
1821         static FolderItemComposePage folder_item_compose_page;
1822
1823         pfi_compose_path[0] = _("Compose");
1824         pfi_compose_path[1] = NULL;
1825
1826         folder_item_compose_page.page.path = pfi_compose_path;
1827         folder_item_compose_page.page.create_widget = prefs_folder_item_compose_create_widget_func;
1828         folder_item_compose_page.page.destroy_widget = prefs_folder_item_compose_destroy_widget_func;
1829         folder_item_compose_page.page.save_page = prefs_folder_item_compose_save_func;
1830         
1831         prefs_folder_item_register_page((PrefsPage *) &folder_item_compose_page, NULL);
1832 }
1833
1834 static void register_templates_page(void)
1835 {
1836         static gchar *pfi_templates_path[2];
1837         static FolderItemTemplatesPage folder_item_templates_page;
1838
1839         pfi_templates_path[0] = _("Templates");
1840         pfi_templates_path[1] = NULL;
1841
1842         folder_item_templates_page.page.path = pfi_templates_path;
1843         folder_item_templates_page.page.create_widget = prefs_folder_item_templates_create_widget_func;
1844         folder_item_templates_page.page.destroy_widget = prefs_folder_item_templates_destroy_widget_func;
1845         folder_item_templates_page.page.save_page = prefs_folder_item_templates_save_func;
1846         
1847         prefs_folder_item_register_page((PrefsPage *) &folder_item_templates_page, NULL);
1848 }
1849
1850 static GSList *prefs_pages = NULL;
1851
1852 static void prefs_folder_item_address_completion_start(PrefsWindow *window)
1853 {
1854         address_completion_start(window->window);
1855 }
1856
1857 static void prefs_folder_item_address_completion_end(PrefsWindow *window)
1858 {
1859         address_completion_end(window->window);
1860 }
1861
1862 void prefs_folder_item_open(FolderItem *item)
1863 {
1864         gchar *id, *title;
1865         GSList *pages;
1866
1867         if (prefs_pages == NULL) {
1868                 register_general_page();
1869                 register_compose_page();
1870                 register_templates_page();
1871         }
1872
1873         if (item->path) {
1874                 id = folder_item_get_identifier (item);
1875                 can_save = TRUE;
1876         } else {
1877                 id = g_strdup(item->name);
1878                 can_save = FALSE;
1879         }
1880         
1881         pages = g_slist_concat(
1882                         g_slist_copy(prefs_pages),
1883                         g_slist_copy(item->folder->klass->prefs_pages));
1884
1885         title = g_strdup_printf (_("Properties for folder %s"), id);
1886         g_free (id);
1887         prefswindow_open(title, pages, item,
1888                         &prefs_common.folderitemwin_width, &prefs_common.folderitemwin_height,
1889                         prefs_folder_item_address_completion_start,
1890                         NULL,
1891                         prefs_folder_item_address_completion_end);
1892
1893         g_slist_free(pages);
1894         g_free (title);
1895 }
1896
1897 void prefs_folder_item_register_page(PrefsPage *page, FolderClass *klass)
1898 {
1899         if (klass != NULL)
1900                 klass->prefs_pages = g_slist_append(klass->prefs_pages, page);
1901         else
1902                 prefs_pages = g_slist_append(prefs_pages, page);
1903 }
1904
1905 void prefs_folder_item_unregister_page(PrefsPage *page, FolderClass *klass)
1906 {
1907         if (klass != NULL)
1908                 klass->prefs_pages = g_slist_remove(klass->prefs_pages, page);
1909         else
1910                 prefs_pages = g_slist_remove(prefs_pages, page);
1911 }