inital gtk2 patch
[claws.git] / src / prefs_folder_item.c
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2001 Hiroyuki Yamamoto
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 2 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, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 /* alfons - all folder item specific settings should migrate into 
21  * folderlist.xml!!! the old folderitemrc file will only serve for a few 
22  * versions (for compatibility) */
23
24 #ifdef HAVE_CONFIG_H
25 #  include "config.h"
26 #endif
27
28 #include "intl.h"
29 #include "defs.h"
30 #include "folder.h"
31 #include "prefs_folder_item.h"
32 #include "folderview.h"
33 #include "summaryview.h"
34 #include "menu.h"
35 #include "account.h"
36 #include "prefs_gtk.h"
37 #include "manage_window.h"
38 #include "utils.h"
39 #include "addr_compl.h"
40 #include "prefs_common.h"
41 #include "prefs_scoring.h"
42 #include "gtkutils.h"
43 #include "filtering.h"
44 #include "folder_item_prefs.h"
45 #include "gtk/colorsel.h"
46
47 #if USE_ASPELL
48 #include "gtkaspell.h"
49 #endif
50
51 #define ASSIGN_STRING(string, value) \
52         { \
53                 g_free(string); \
54                 string = (value); \
55         }
56
57 struct FolderItemGeneralPage
58 {
59         PrefsPage page;
60
61         FolderItem *item;
62
63         GtkWidget *table;
64         GtkWidget *checkbtn_simplify_subject;
65         GtkWidget *entry_simplify_subject;
66         GtkWidget *checkbtn_folder_chmod;
67         GtkWidget *entry_folder_chmod;
68         GtkWidget *folder_color_btn;
69
70         gint       folder_color;
71 };
72
73 struct FolderItemComposePage
74 {
75         PrefsPage page;
76
77         FolderItem *item;
78
79         GtkWidget *window;
80         GtkWidget *table;
81         GtkWidget *checkbtn_request_return_receipt;
82         GtkWidget *checkbtn_save_copy_to_folder;
83         GtkWidget *checkbtn_default_to;
84         GtkWidget *entry_default_to;
85         GtkWidget *checkbtn_default_reply_to;
86         GtkWidget *entry_default_reply_to;
87         GtkWidget *checkbtn_enable_default_account;
88         GtkWidget *optmenu_default_account;
89 #if USE_ASPELL
90         GtkWidget *checkbtn_enable_default_dictionary;
91         GtkWidget *optmenu_default_dictionary;
92 #endif
93 };
94
95
96 gint prefs_folder_item_chmod_mode               (gchar *folder_chmod);
97
98 static void folder_color_set_dialog(GtkWidget *widget, gpointer data);
99
100 #define SAFE_STRING(str) \
101         (str) ? (str) : ""
102
103 void prefs_folder_item_general_create_widget_func(PrefsPage * _page,
104                                                    GtkWindow * window,
105                                                    gpointer data)
106 {
107         struct FolderItemGeneralPage *page = (struct FolderItemGeneralPage *) _page;
108         FolderItem *item = (FolderItem *) data;
109         guint rowcount;
110
111         GtkWidget *table;
112         GtkWidget *hbox;
113         
114         GtkWidget *checkbtn_simplify_subject;
115         GtkWidget *entry_simplify_subject;
116         GtkWidget *checkbtn_folder_chmod;
117         GtkWidget *entry_folder_chmod;
118         GtkWidget *folder_color;
119         GtkWidget *folder_color_btn;
120
121         page->item         = item;
122
123         /* Table */
124         table = gtk_table_new(3, 2, FALSE);
125         gtk_widget_show(table);
126         gtk_table_set_row_spacings(GTK_TABLE(table), -1);
127         rowcount = 0;
128
129         /* Simplify Subject */
130         checkbtn_simplify_subject = gtk_check_button_new_with_label(_("Simplify Subject RegExp: "));
131         gtk_widget_show(checkbtn_simplify_subject);
132         gtk_table_attach(GTK_TABLE(table), checkbtn_simplify_subject, 0, 1, 
133                          rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
134         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_simplify_subject), 
135                                      item->prefs->enable_simplify_subject);
136
137         entry_simplify_subject = gtk_entry_new();
138         gtk_widget_show(entry_simplify_subject);
139         gtk_table_attach_defaults(GTK_TABLE(table), entry_simplify_subject, 1, 2, 
140                                   rowcount, rowcount + 1);
141         SET_TOGGLE_SENSITIVITY(checkbtn_simplify_subject, entry_simplify_subject);
142         gtk_entry_set_text(GTK_ENTRY(entry_simplify_subject), 
143                            SAFE_STRING(item->prefs->simplify_subject_regexp));
144
145         rowcount++;
146
147         /* Folder chmod */
148         checkbtn_folder_chmod = gtk_check_button_new_with_label(_("Folder chmod: "));
149         gtk_widget_show(checkbtn_folder_chmod);
150         gtk_table_attach(GTK_TABLE(table), checkbtn_folder_chmod, 0, 1, 
151                          rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
152
153         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_folder_chmod), 
154                                      item->prefs->enable_folder_chmod);
155
156         entry_folder_chmod = gtk_entry_new();
157         gtk_widget_show(entry_folder_chmod);
158         gtk_table_attach_defaults(GTK_TABLE(table), entry_folder_chmod, 1, 2, 
159                                   rowcount, rowcount + 1);
160         SET_TOGGLE_SENSITIVITY(checkbtn_folder_chmod, entry_folder_chmod);
161         if (item->prefs->folder_chmod) {
162                 gchar *buf;
163
164                 buf = g_strdup_printf("%o", item->prefs->folder_chmod);
165                 gtk_entry_set_text(GTK_ENTRY(entry_folder_chmod), buf);
166                 g_free(buf);
167         }
168         
169         rowcount++;
170
171         /* Folder color */
172         folder_color = gtk_label_new(_("Folder color: "));
173         gtk_misc_set_alignment(GTK_MISC(folder_color), 0, 0.5);
174         gtk_widget_show(folder_color);
175         gtk_table_attach_defaults(GTK_TABLE(table), folder_color, 0, 1, 
176                          rowcount, rowcount + 1);
177
178         hbox = gtk_hbox_new(FALSE, 0);
179         gtk_widget_show(hbox);
180         gtk_table_attach_defaults(GTK_TABLE(table), hbox, 1, 2, 
181                                   rowcount, rowcount + 1);
182
183         folder_color_btn = gtk_button_new_with_label("");
184         gtk_widget_set_size_request(folder_color_btn, 36, 26);
185         gtk_box_pack_start (GTK_BOX(hbox), folder_color_btn, FALSE, FALSE, 0);
186
187         page->folder_color = item->prefs->color;
188
189         g_signal_connect(G_OBJECT(folder_color_btn), "clicked",
190                          G_CALLBACK(folder_color_set_dialog),
191                          page);
192
193         gtkut_set_widget_bgcolor_rgb(folder_color_btn, item->prefs->color);
194
195         rowcount++;
196
197         page->table = table;
198         page->checkbtn_simplify_subject = checkbtn_simplify_subject;
199         page->entry_simplify_subject = entry_simplify_subject;
200         page->checkbtn_folder_chmod = checkbtn_folder_chmod;
201         page->entry_folder_chmod = entry_folder_chmod;
202         page->folder_color_btn = folder_color_btn;
203
204         page->page.widget = table;
205 }
206
207 void prefs_folder_item_general_destroy_widget_func(PrefsPage *_page) 
208 {
209         /* struct FolderItemGeneralPage *page = (struct FolderItemGeneralPage *) _page; */
210 }
211
212 void prefs_folder_item_general_save_func(PrefsPage *_page) 
213 {
214         gchar *buf;
215         struct FolderItemGeneralPage *page = (struct FolderItemGeneralPage *) _page;
216         FolderItemPrefs *prefs = page->item->prefs;
217         gboolean   old_simplify_val;
218         gchar     *old_simplify_str;
219
220         g_return_if_fail(prefs != NULL);
221
222         prefs->enable_simplify_subject =
223             gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_simplify_subject));
224         ASSIGN_STRING(prefs->simplify_subject_regexp,
225             gtk_editable_get_chars(GTK_EDITABLE(page->entry_simplify_subject), 0, -1));
226         
227 /*
228         if (page->item == page->folderview->summaryview->folder_item &&
229             (prefs->enable_simplify_subject != old_simplify_val ||  
230             0 != strcmp2(prefs->simplify_subject_regexp, old_simplify_str))) {
231                 summary_clear_all(page->folderview->summaryview);
232                 page->folderview->opened = NULL;
233                 page->folderview->selected = NULL;
234                 folderview_select(page->folderview, page->item);
235         }
236 */
237         prefs->enable_folder_chmod = 
238             gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_folder_chmod));
239         buf = gtk_editable_get_chars(GTK_EDITABLE(page->entry_folder_chmod), 0, -1);
240         prefs->folder_chmod = prefs_folder_item_chmod_mode(buf);
241         g_free(buf);
242
243         prefs->color = page->folder_color;
244         /* update folder view */
245         if (prefs->color > 0)
246                 folder_item_update(page->item, F_ITEM_UPDATE_MSGCNT);
247
248         folder_item_prefs_save_config(page->item);
249 }
250
251 void prefs_folder_item_compose_create_widget_func(PrefsPage * _page,
252                                                    GtkWindow * window,
253                                                    gpointer data)
254 {
255         struct FolderItemComposePage *page = (struct FolderItemComposePage *) _page;
256         FolderItem *item = (FolderItem *) data;
257         guint rowcount;
258
259         GtkWidget *table;
260         
261         GtkWidget *checkbtn_request_return_receipt;
262         GtkWidget *checkbtn_save_copy_to_folder;
263         GtkWidget *checkbtn_default_to;
264         GtkWidget *entry_default_to;
265         GtkWidget *checkbtn_default_reply_to;
266         GtkWidget *entry_default_reply_to;
267         GtkWidget *checkbtn_enable_default_account;
268         GtkWidget *optmenu_default_account;
269         GtkWidget *optmenu_default_account_menu;
270         GtkWidget *optmenu_default_account_menuitem;
271 #if USE_ASPELL
272         GtkWidget *checkbtn_enable_default_dictionary;
273         GtkWidget *optmenu_default_dictionary;
274         GtkWidget *optmenu_default_dictionary_menu;
275         GtkWidget *opemenu_default_dictionary_menuitem;
276 #endif
277         GList *cur_ac;
278         GList *account_list;
279 #if USE_ASPELL
280         gchar *dictionary;
281 #endif
282         PrefsAccount *ac_prefs;
283         GtkOptionMenu *optmenu;
284         GtkWidget *menu;
285         GtkWidget *menuitem;
286         gint account_index, index;
287
288         page->item         = item;
289
290         /* Table */
291 #if USE_ASPELL
292 # define TABLEHEIGHT 6
293 #else
294 # define TABLEHEIGHT 5
295 #endif
296         table = gtk_table_new(TABLEHEIGHT, 2, FALSE);
297         gtk_widget_show(table);
298         gtk_table_set_row_spacings(GTK_TABLE(table), -1);
299         rowcount = 0;
300
301         /* Request Return Receipt */
302         checkbtn_request_return_receipt = gtk_check_button_new_with_label
303                 (_("Request Return Receipt"));
304         gtk_widget_show(checkbtn_request_return_receipt);
305         gtk_table_attach(GTK_TABLE(table), checkbtn_request_return_receipt, 
306                          0, 2, rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, 
307                          GTK_FILL, 0, 0);
308         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_request_return_receipt),
309                                      item->ret_rcpt ? TRUE : FALSE);
310
311         rowcount++;
312
313         /* Save Copy to Folder */
314         checkbtn_save_copy_to_folder = gtk_check_button_new_with_label
315                 (_("Save copy of outgoing messages to this folder instead of Sent"));
316         gtk_widget_show(checkbtn_save_copy_to_folder);
317         gtk_table_attach(GTK_TABLE(table), checkbtn_save_copy_to_folder, 0, 2, 
318                          rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0);
319         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_save_copy_to_folder),
320                                      item->prefs->save_copy_to_folder ? TRUE : FALSE);
321
322         rowcount++;
323
324         /* Default To */
325         checkbtn_default_to = gtk_check_button_new_with_label(_("Default To: "));
326         gtk_widget_show(checkbtn_default_to);
327         gtk_table_attach(GTK_TABLE(table), checkbtn_default_to, 0, 1, 
328                          rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
329         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_default_to), 
330                                      item->prefs->enable_default_to);
331
332         entry_default_to = gtk_entry_new();
333         gtk_widget_show(entry_default_to);
334         gtk_table_attach_defaults(GTK_TABLE(table), entry_default_to, 1, 2, rowcount, rowcount + 1);
335         SET_TOGGLE_SENSITIVITY(checkbtn_default_to, entry_default_to);
336         gtk_entry_set_text(GTK_ENTRY(entry_default_to), SAFE_STRING(item->prefs->default_to));
337         address_completion_register_entry(GTK_ENTRY(entry_default_to));
338
339         rowcount++;
340
341         /* Default address to reply to */
342         checkbtn_default_reply_to = gtk_check_button_new_with_label(_("Send replies to: "));
343         gtk_widget_show(checkbtn_default_reply_to);
344         gtk_table_attach(GTK_TABLE(table), checkbtn_default_reply_to, 0, 1, 
345                          rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
346         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_default_reply_to), 
347                                      item->prefs->enable_default_reply_to);
348
349         entry_default_reply_to = gtk_entry_new();
350         gtk_widget_show(entry_default_reply_to);
351         gtk_table_attach_defaults(GTK_TABLE(table), entry_default_reply_to, 1, 2, rowcount, rowcount + 1);
352         SET_TOGGLE_SENSITIVITY(checkbtn_default_reply_to, entry_default_reply_to);
353         gtk_entry_set_text(GTK_ENTRY(entry_default_reply_to), SAFE_STRING(item->prefs->default_reply_to));
354         address_completion_register_entry(GTK_ENTRY(entry_default_reply_to));
355
356         rowcount++;
357
358         /* Default account */
359         checkbtn_enable_default_account = gtk_check_button_new_with_label(_("Default account: "));
360         gtk_widget_show(checkbtn_enable_default_account);
361         gtk_table_attach(GTK_TABLE(table), checkbtn_enable_default_account, 0, 1, 
362                          rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
363         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_default_account), 
364                                      item->prefs->enable_default_account);
365
366         optmenu_default_account = gtk_option_menu_new ();
367         gtk_widget_show (optmenu_default_account);
368         gtk_table_attach_defaults(GTK_TABLE(table), optmenu_default_account, 1, 2, 
369                                   rowcount, rowcount + 1);
370         optmenu_default_account_menu = gtk_menu_new ();
371
372         account_list = account_get_list();
373         account_index = 0;
374         index = 0;
375         for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
376                 ac_prefs = (PrefsAccount *)cur_ac->data;
377                 MENUITEM_ADD (optmenu_default_account_menu, optmenu_default_account_menuitem,
378                                         ac_prefs->account_name?ac_prefs->account_name : _("Untitled"),
379                                         ac_prefs->account_id);
380                 /* get the index for menu's set_history (sad method?) */
381                 if (ac_prefs->account_id == item->prefs->default_account)
382                         account_index = index;
383                 index++;                        
384         }
385
386         optmenu = GTK_OPTION_MENU(optmenu_default_account);
387         gtk_option_menu_set_menu(optmenu, optmenu_default_account_menu);
388
389         gtk_option_menu_set_history(optmenu, account_index);
390
391         menu = gtk_option_menu_get_menu(optmenu);
392         menuitem = gtk_menu_get_active(GTK_MENU(menu));
393         gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
394
395         SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_account, optmenu_default_account);
396
397         rowcount++;
398
399 #if USE_ASPELL
400         /* Default dictionary */
401         checkbtn_enable_default_dictionary = gtk_check_button_new_with_label(_("Default dictionary: "));
402         gtk_widget_show(checkbtn_enable_default_dictionary);
403         gtk_table_attach(GTK_TABLE(table), checkbtn_enable_default_dictionary, 0, 1,
404                          rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
405         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_default_dictionary),
406                                      item->prefs->enable_default_dictionary);
407
408         optmenu_default_dictionary = gtk_option_menu_new();
409         gtk_widget_show(optmenu_default_dictionary);
410         gtk_table_attach_defaults(GTK_TABLE(table), optmenu_default_dictionary, 1, 2,
411                                 rowcount, rowcount + 1);
412
413         gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu_default_dictionary), 
414                                  gtkaspell_dictionary_option_menu_new(
415                                          prefs_common.aspell_path));
416
417         dictionary = item->prefs->default_dictionary;
418
419         optmenu = GTK_OPTION_MENU(optmenu_default_dictionary);
420
421         menu = gtk_option_menu_get_menu(optmenu);
422         if (dictionary)
423                 gtkaspell_set_dictionary_menu_active_item(optmenu_default_dictionary, dictionary);
424         menuitem = gtk_menu_get_active(GTK_MENU(menu));
425         gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
426
427         SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_dictionary, optmenu_default_dictionary);
428
429         rowcount++;
430 #endif
431
432         page->window = GTK_WIDGET(window);
433         page->table = table;
434         page->checkbtn_request_return_receipt = checkbtn_request_return_receipt;
435         page->checkbtn_save_copy_to_folder = checkbtn_save_copy_to_folder;
436         page->checkbtn_default_to = checkbtn_default_to;
437         page->entry_default_to = entry_default_to;
438         page->checkbtn_default_reply_to = checkbtn_default_reply_to;
439         page->entry_default_reply_to = entry_default_reply_to;
440         page->checkbtn_enable_default_account = checkbtn_enable_default_account;
441         page->optmenu_default_account = optmenu_default_account;
442 #ifdef USE_ASPELL
443         page->checkbtn_enable_default_dictionary = checkbtn_enable_default_dictionary;
444         page->optmenu_default_dictionary = optmenu_default_dictionary;
445 #endif
446
447         address_completion_start(page->window);
448
449         page->page.widget = table;
450 }
451
452 void prefs_folder_item_compose_destroy_widget_func(PrefsPage *_page) 
453 {
454         struct FolderItemComposePage *page = (struct FolderItemComposePage *) _page;
455
456         address_completion_unregister_entry(GTK_ENTRY(page->entry_default_to));
457         address_completion_unregister_entry(GTK_ENTRY(page->entry_default_reply_to));
458         address_completion_end(page->window);
459 }
460
461 void prefs_folder_item_compose_save_func(PrefsPage *_page) 
462 {
463         struct FolderItemComposePage *page = (struct FolderItemComposePage *) _page;
464         FolderItemPrefs *prefs = page->item->prefs;
465         GtkWidget *menu;
466         GtkWidget *menuitem;
467
468         g_return_if_fail(prefs != NULL);
469
470         prefs->request_return_receipt = 
471             gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_request_return_receipt));
472         /* MIGRATION */    
473         page->item->ret_rcpt = prefs->request_return_receipt;
474
475         prefs->save_copy_to_folder = 
476             gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_save_copy_to_folder));
477
478         prefs->enable_default_to = 
479             gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_default_to));
480         ASSIGN_STRING(prefs->default_to,
481             gtk_editable_get_chars(GTK_EDITABLE(page->entry_default_to), 0, -1));
482
483         prefs->enable_default_reply_to = 
484             gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_default_reply_to));
485         ASSIGN_STRING(prefs->default_reply_to,
486             gtk_editable_get_chars(GTK_EDITABLE(page->entry_default_reply_to), 0, -1));
487
488         prefs->enable_default_account = 
489             gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_enable_default_account));
490         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(page->optmenu_default_account));
491         menuitem = gtk_menu_get_active(GTK_MENU(menu));
492         prefs->default_account = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
493
494 #if USE_ASPELL
495         prefs->enable_default_dictionary =
496             gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_enable_default_dictionary));
497         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(page->optmenu_default_dictionary));
498         ASSIGN_STRING(prefs->default_dictionary,
499             gtkaspell_get_dictionary_menu_active_item(menu));
500 #endif
501
502         folder_item_prefs_save_config(page->item);
503 }
504
505 gint prefs_folder_item_chmod_mode(gchar *folder_chmod) 
506 {
507         gint newmode = 0;
508         gchar *tmp;
509
510         if (folder_chmod) {
511                 newmode = strtol(folder_chmod, &tmp, 8);
512                 if (!(*(folder_chmod) && !(*tmp)))
513                         newmode = 0;
514         }
515
516         return newmode;
517 }
518
519 static void folder_color_set_dialog(GtkWidget *widget, gpointer data)
520 {
521         struct FolderItemGeneralPage *page = (struct FolderItemGeneralPage *) data;
522         gint rgbcolor;
523
524         rgbcolor = colorsel_select_color_rgb(_("Pick color for folder"), 
525                                              page->folder_color);
526         gtkut_set_widget_bgcolor_rgb(page->folder_color_btn, rgbcolor);
527         page->folder_color = rgbcolor;
528 }
529
530 struct FolderItemGeneralPage folder_item_general_page;
531
532 static void register_general_page()
533 {
534         folder_item_general_page.page.path = _("General");
535         folder_item_general_page.page.create_widget = prefs_folder_item_general_create_widget_func;
536         folder_item_general_page.page.destroy_widget = prefs_folder_item_general_destroy_widget_func;
537         folder_item_general_page.page.save_page = prefs_folder_item_general_save_func;
538         
539         prefs_folder_item_register_page((PrefsPage *) &folder_item_general_page);
540 }
541
542 struct FolderItemComposePage folder_item_compose_page;
543
544 static void register_compose_page()
545 {
546         folder_item_compose_page.page.path = _("Compose");
547         folder_item_compose_page.page.create_widget = prefs_folder_item_compose_create_widget_func;
548         folder_item_compose_page.page.destroy_widget = prefs_folder_item_compose_destroy_widget_func;
549         folder_item_compose_page.page.save_page = prefs_folder_item_compose_save_func;
550         
551         prefs_folder_item_register_page((PrefsPage *) &folder_item_compose_page);
552 }
553
554 static GSList *prefs_pages = NULL;
555
556 void prefs_folder_item_open(FolderItem *item)
557 {
558         if (prefs_pages == NULL) {
559                 register_general_page();
560                 register_compose_page();
561         }
562
563         prefswindow_open(_("Settings for folder"), prefs_pages, item);
564 }
565
566 void prefs_folder_item_register_page(PrefsPage *page)
567 {
568         prefs_pages = g_slist_append(prefs_pages, page);
569 }
570
571 void prefs_folder_item_unregister_page(PrefsPage *page)
572 {
573         prefs_pages = g_slist_remove(prefs_pages, page);
574 }