* src/prefs.h
[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 #include "intl.h"
25 #include "defs.h"
26 #include "folder.h"
27 #include "prefs_folder_item.h"
28 #include "folderview.h"
29 #include "summaryview.h"
30 #include "menu.h"
31 #include "account.h"
32 #include "prefs.h"
33 #include "manage_window.h"
34 #include "utils.h"
35 #include "addr_compl.h"
36
37 PrefsFolderItem tmp_prefs;
38
39 struct PrefsFolderItemDialog
40 {
41         FolderView *folderview;
42         FolderItem *item;
43         GtkWidget *window;
44         GtkWidget *checkbtn_request_return_receipt;
45         GtkWidget *checkbtn_save_copy_to_folder;
46         GtkWidget *checkbtn_default_to;
47         GtkWidget *entry_default_to;
48         GtkWidget *checkbtn_simplify_subject;
49         GtkWidget *entry_simplify_subject;
50         GtkWidget *checkbtn_folder_chmod;
51         GtkWidget *entry_folder_chmod;
52         GtkWidget *checkbtn_enable_default_account;
53         GtkWidget *optmenu_default_account;
54 };
55
56 static PrefParam param[] = {
57         {"sort_by_number", "FALSE", &tmp_prefs.sort_by_number, P_BOOL,
58          NULL, NULL, NULL},
59         {"sort_by_size", "FALSE", &tmp_prefs.sort_by_size, P_BOOL,
60          NULL, NULL, NULL},
61         {"sort_by_date", "FALSE", &tmp_prefs.sort_by_date, P_BOOL,
62          NULL, NULL, NULL},
63         {"sort_by_from", "FALSE", &tmp_prefs.sort_by_from, P_BOOL,
64          NULL, NULL, NULL},
65         {"sort_by_subject", "FALSE", &tmp_prefs.sort_by_subject, P_BOOL,
66          NULL, NULL, NULL},
67         {"sort_by_score", "FALSE", &tmp_prefs.sort_by_score, P_BOOL,
68          NULL, NULL, NULL},
69         {"sort_descending", "FALSE", &tmp_prefs.sort_descending, P_BOOL,
70          NULL, NULL, NULL},
71         /*{"enable_thread", "TRUE", &tmp_prefs.enable_thread, P_BOOL,
72          NULL, NULL, NULL},*/
73         {"kill_score", "-9999", &tmp_prefs.kill_score, P_INT,
74          NULL, NULL, NULL},
75         {"important_score", "1", &tmp_prefs.important_score, P_INT,
76          NULL, NULL, NULL},
77         /* MIGRATION */  
78         {"request_return_receipt", "", &tmp_prefs.request_return_receipt, P_BOOL,
79          NULL, NULL, NULL},
80         {"enable_default_to", "", &tmp_prefs.enable_default_to, P_BOOL,
81          NULL, NULL, NULL},
82         {"default_to", "", &tmp_prefs.default_to, P_STRING,
83          NULL, NULL, NULL},
84         {"enable_simplify_subject", "", &tmp_prefs.enable_simplify_subject, P_BOOL,
85          NULL, NULL, NULL},
86         {"simplify_subject_regexp", "", &tmp_prefs.simplify_subject_regexp, P_STRING,
87          NULL, NULL, NULL},
88         {"enable_folder_chmod", "", &tmp_prefs.enable_folder_chmod, P_BOOL,
89          NULL, NULL, NULL},
90         {"folder_chmod", "", &tmp_prefs.folder_chmod, P_INT,
91          NULL, NULL, NULL},
92         {"enable_default_account", "", &tmp_prefs.enable_default_account, P_BOOL,
93          NULL, NULL, NULL},
94         {"default_account", NULL, &tmp_prefs.default_account, P_INT,
95          NULL, NULL, NULL},
96         {"save_copy_to_folder", NULL, &tmp_prefs.save_copy_to_folder, P_BOOL,
97          NULL, NULL, NULL},
98         {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
99 };
100
101 void prefs_folder_item_delete_cb                (GtkWidget *widget, GdkEventAny *event, 
102                                                  struct PrefsFolderItemDialog *dialog);
103 void prefs_folder_item_cancel_cb                (GtkWidget *widget, 
104                                                  struct PrefsFolderItemDialog *dialog);
105 void prefs_folder_item_ok_cb                    (GtkWidget *widget, 
106                                                  struct PrefsFolderItemDialog *dialog);
107 gint prefs_folder_item_chmod_mode               (gchar *folder_chmod);
108
109
110 void prefs_folder_item_read_config(FolderItem * item)
111 {
112         gchar * id;
113
114         id = folder_item_get_identifier(item);
115
116         prefs_read_config(param, id, FOLDERITEM_RC);
117         g_free(id);
118
119         *item->prefs = tmp_prefs;
120
121         /* MIGRATION */
122         item->ret_rcpt = tmp_prefs.request_return_receipt ? TRUE : FALSE; 
123 }
124
125 void prefs_folder_item_save_config(FolderItem * item)
126 {       
127         gchar * id;
128
129         tmp_prefs = * item->prefs;
130
131         id = folder_item_get_identifier(item);
132
133         prefs_save_config(param, id, FOLDERITEM_RC);
134         g_free(id);
135
136         /* MIGRATION: make sure migrated items are not saved
137          */
138 }
139
140 void prefs_folder_item_set_config(FolderItem * item,
141                                   int sort_type, gint sort_mode)
142 {
143         tmp_prefs = * item->prefs;
144
145         tmp_prefs.sort_by_number = FALSE;
146         tmp_prefs.sort_by_size = FALSE;
147         tmp_prefs.sort_by_date = FALSE;
148         tmp_prefs.sort_by_from = FALSE;
149         tmp_prefs.sort_by_subject = FALSE;
150         tmp_prefs.sort_by_score = FALSE;
151
152         switch (sort_mode) {
153         case SORT_BY_NUMBER:
154                 tmp_prefs.sort_by_number = TRUE;
155                 break;
156         case SORT_BY_SIZE:
157                 tmp_prefs.sort_by_size = TRUE;
158                 break;
159         case SORT_BY_DATE:
160                 tmp_prefs.sort_by_date = TRUE;
161                 break;
162         case SORT_BY_FROM:
163                 tmp_prefs.sort_by_from = TRUE;
164                 break;
165         case SORT_BY_SUBJECT:
166                 tmp_prefs.sort_by_subject = TRUE;
167                 break;
168         case SORT_BY_SCORE:
169                 tmp_prefs.sort_by_score = TRUE;
170                 break;
171         }
172         tmp_prefs.sort_descending = (sort_type == GTK_SORT_DESCENDING);
173
174         * item->prefs = tmp_prefs;
175 }
176
177 PrefsFolderItem * prefs_folder_item_new(void)
178 {
179         PrefsFolderItem * prefs;
180
181         prefs = g_new0(PrefsFolderItem, 1);
182
183         tmp_prefs.sort_by_number = FALSE;
184         tmp_prefs.sort_by_size = FALSE;
185         tmp_prefs.sort_by_date = FALSE;
186         tmp_prefs.sort_by_from = FALSE;
187         tmp_prefs.sort_by_subject = FALSE;
188         tmp_prefs.sort_by_score = FALSE;
189         tmp_prefs.sort_descending = FALSE;
190         tmp_prefs.kill_score = -9999;
191         tmp_prefs.important_score = 9999;
192
193         tmp_prefs.request_return_receipt = FALSE;
194         tmp_prefs.enable_default_to = FALSE;
195         tmp_prefs.default_to = NULL;
196         tmp_prefs.enable_simplify_subject = FALSE;
197         tmp_prefs.simplify_subject_regexp = NULL;
198         tmp_prefs.enable_folder_chmod = FALSE;
199         tmp_prefs.folder_chmod = 0;
200         tmp_prefs.enable_default_account = FALSE;
201         tmp_prefs.default_account = 0;
202         tmp_prefs.save_copy_to_folder = FALSE;
203
204         * prefs = tmp_prefs;
205         
206         return prefs;
207 }
208
209 void prefs_folder_item_free(PrefsFolderItem * prefs)
210 {
211         if (prefs->default_to) 
212                 g_free(prefs->default_to);
213         if (prefs->scoring != NULL)
214                 prefs_scoring_free(prefs->scoring);
215         g_free(prefs);
216 }
217
218 gint prefs_folder_item_get_sort_mode(FolderItem * item)
219 {
220         tmp_prefs = * item->prefs;
221
222         if (tmp_prefs.sort_by_number)
223                 return SORT_BY_NUMBER;
224         if (tmp_prefs.sort_by_size)
225                 return SORT_BY_SIZE;
226         if (tmp_prefs.sort_by_date)
227                 return SORT_BY_DATE;
228         if (tmp_prefs.sort_by_from)
229                 return SORT_BY_FROM;
230         if (tmp_prefs.sort_by_subject)
231                 return SORT_BY_SUBJECT;
232         if (tmp_prefs.sort_by_score)
233                 return SORT_BY_SCORE;
234         return SORT_BY_NONE;
235 }
236
237 gint prefs_folder_item_get_sort_type(FolderItem * item)
238 {
239         tmp_prefs = * item->prefs;
240
241         if (tmp_prefs.sort_descending)
242                 return GTK_SORT_DESCENDING;
243         else
244                 return GTK_SORT_ASCENDING;
245 }
246
247 #define SAFE_STRING(str) \
248         (str) ? (str) : ""
249
250 void prefs_folder_item_create(void *folderview, FolderItem *item) 
251 {
252         struct PrefsFolderItemDialog *dialog;
253         guint rowcount;
254         gchar *folder_identifier, *infotext;
255
256         GtkWidget *window;
257         GtkWidget *table;
258         GtkWidget *infolabel;
259         GtkWidget *ok_btn;
260         GtkWidget *cancel_btn;
261         GtkWidget *confirm_area;
262         
263         GtkWidget *checkbtn_request_return_receipt;
264         GtkWidget *checkbtn_save_copy_to_folder;
265         GtkWidget *checkbtn_default_to;
266         GtkWidget *entry_default_to;
267         GtkWidget *checkbtn_simplify_subject;
268         GtkWidget *entry_simplify_subject;
269         GtkWidget *checkbtn_folder_chmod;
270         GtkWidget *entry_folder_chmod;
271         GtkWidget *checkbtn_enable_default_account;
272         GtkWidget *optmenu_default_account;
273         GtkWidget *optmenu_default_account_menu;
274         GtkWidget *optmenu_default_account_menuitem;
275         GList *cur_ac;
276         GList *account_list;
277         PrefsAccount *ac_prefs;
278         GtkOptionMenu *optmenu;
279         GtkWidget *menu;
280         GtkWidget *menuitem;
281         gint account_index, index;
282
283         dialog = g_new0(struct PrefsFolderItemDialog, 1);
284         dialog->folderview = folderview;
285         dialog->item       = item;
286
287         /* Window */
288         window = gtk_window_new (GTK_WINDOW_DIALOG);
289         gtk_window_set_title (GTK_WINDOW(window),
290                               _("Folder Property"));
291         gtk_container_set_border_width (GTK_CONTAINER (window), 8);
292         gtk_window_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
293         gtk_window_set_policy (GTK_WINDOW (window), FALSE, TRUE, FALSE);
294         gtk_signal_connect (GTK_OBJECT(window), "delete_event",
295                             GTK_SIGNAL_FUNC(prefs_folder_item_delete_cb), dialog);
296         gtk_signal_connect (GTK_OBJECT(window), "focus_in_event",
297                             GTK_SIGNAL_FUNC(manage_window_focus_in), NULL);
298         gtk_signal_connect (GTK_OBJECT(window), "focus_out_event",
299                             GTK_SIGNAL_FUNC(manage_window_focus_out), NULL);
300
301         /* Table */
302         table = gtk_table_new(4, 2, FALSE);
303         gtk_widget_show(table);
304         gtk_table_set_row_spacings(GTK_TABLE(table), VSPACING_NARROW);
305         gtk_container_add(GTK_CONTAINER (window), table);
306         rowcount = 0;
307
308         /* Label */
309         folder_identifier = folder_item_get_identifier(item);
310         infotext = g_strconcat(_("Folder Property for "), folder_identifier, NULL);
311         infolabel = gtk_label_new(infotext);
312         gtk_table_attach(GTK_TABLE(table), infolabel, 0, 2, rowcount, 
313                          rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
314         gtk_widget_show(infolabel);
315         rowcount++;
316
317         /* Request Return Receipt */
318         checkbtn_request_return_receipt = gtk_check_button_new_with_label
319                 (_("Request Return Receipt"));
320         gtk_widget_show(checkbtn_request_return_receipt);
321         gtk_table_attach(GTK_TABLE(table), checkbtn_request_return_receipt, 
322                          0, 2, rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, 
323                          GTK_SHRINK, 0, 0);
324         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_request_return_receipt),
325                                      item->ret_rcpt ? TRUE : FALSE);
326
327         rowcount++;
328
329         /* Save Copy to Folder */
330         checkbtn_save_copy_to_folder = gtk_check_button_new_with_label
331                 (_("Save copy of outgoing messages to this folder instead of outbox"));
332         gtk_widget_show(checkbtn_save_copy_to_folder);
333         gtk_table_attach(GTK_TABLE(table), checkbtn_save_copy_to_folder, 0, 2, 
334                          rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
335         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_save_copy_to_folder),
336                                      item->prefs->save_copy_to_folder ? TRUE : FALSE);
337
338         rowcount++;
339
340         /* Default To */
341         checkbtn_default_to = gtk_check_button_new_with_label(_("Default To: "));
342         gtk_widget_show(checkbtn_default_to);
343         gtk_table_attach(GTK_TABLE(table), checkbtn_default_to, 0, 1, 
344                          rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
345         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_default_to), 
346                                      item->prefs->enable_default_to);
347
348         entry_default_to = gtk_entry_new();
349         gtk_widget_show(entry_default_to);
350         gtk_table_attach_defaults(GTK_TABLE(table), entry_default_to, 1, 2, rowcount, rowcount + 1);
351         SET_TOGGLE_SENSITIVITY(checkbtn_default_to, entry_default_to);
352         gtk_entry_set_text(GTK_ENTRY(entry_default_to), SAFE_STRING(item->prefs->default_to));
353         address_completion_register_entry(GTK_ENTRY(entry_default_to));
354
355         rowcount++;
356
357         /* Simplify Subject */
358         checkbtn_simplify_subject = gtk_check_button_new_with_label(_("Simplify Subject RegExp: "));
359         gtk_widget_show(checkbtn_simplify_subject);
360         gtk_table_attach(GTK_TABLE(table), checkbtn_simplify_subject, 0, 1, 
361                          rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
362         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_simplify_subject), 
363                                      item->prefs->enable_simplify_subject);
364
365         entry_simplify_subject = gtk_entry_new();
366         gtk_widget_show(entry_simplify_subject);
367         gtk_table_attach_defaults(GTK_TABLE(table), entry_simplify_subject, 1, 2, 
368                                   rowcount, rowcount + 1);
369         SET_TOGGLE_SENSITIVITY(checkbtn_simplify_subject, entry_simplify_subject);
370         gtk_entry_set_text(GTK_ENTRY(entry_simplify_subject), 
371                            SAFE_STRING(item->prefs->simplify_subject_regexp));
372
373         rowcount++;
374
375         /* Folder chmod */
376         checkbtn_folder_chmod = gtk_check_button_new_with_label(_("Folder chmod: "));
377         gtk_widget_show(checkbtn_folder_chmod);
378         gtk_table_attach(GTK_TABLE(table), checkbtn_folder_chmod, 0, 1, 
379                          rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
380
381         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_folder_chmod), 
382                                      item->prefs->enable_folder_chmod);
383
384         entry_folder_chmod = gtk_entry_new();
385         gtk_widget_show(entry_folder_chmod);
386         gtk_table_attach_defaults(GTK_TABLE(table), entry_folder_chmod, 1, 2, 
387                                   rowcount, rowcount + 1);
388         SET_TOGGLE_SENSITIVITY(checkbtn_folder_chmod, entry_folder_chmod);
389         if (item->prefs->folder_chmod) {
390                 gchar *buf;
391
392                 buf = g_strdup_printf("%o", item->prefs->folder_chmod);
393                 gtk_entry_set_text(GTK_ENTRY(entry_folder_chmod), buf);
394                 g_free(buf);
395         }
396         
397         rowcount++;
398
399         /* Default account */
400         checkbtn_enable_default_account = gtk_check_button_new_with_label(_("Default account: "));
401         gtk_widget_show(checkbtn_enable_default_account);
402         gtk_table_attach(GTK_TABLE(table), checkbtn_enable_default_account, 0, 1, 
403                          rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
404         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_default_account), 
405                                      item->prefs->enable_default_account);
406
407         optmenu_default_account = gtk_option_menu_new ();
408         gtk_widget_show (optmenu_default_account);
409         gtk_table_attach_defaults(GTK_TABLE(table), optmenu_default_account, 1, 2, 
410                                   rowcount, rowcount + 1);
411         optmenu_default_account_menu = gtk_menu_new ();
412
413         account_list = account_get_list();
414         account_index = 0;
415         index = 0;
416         for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
417                 ac_prefs = (PrefsAccount *)cur_ac->data;
418                 MENUITEM_ADD (optmenu_default_account_menu, optmenu_default_account_menuitem,
419                                         ac_prefs->account_name?ac_prefs->account_name : _("Untitled"),
420                                         ac_prefs->account_id);
421                 /* get the index for menu's set_history (sad method?) */
422                 if (ac_prefs->account_id == item->prefs->default_account)
423                         account_index = index;
424                 index++;                        
425         }
426
427         dialog->item->prefs->default_account = item->prefs->default_account;
428
429         optmenu=GTK_OPTION_MENU(optmenu_default_account);
430         gtk_option_menu_set_menu(optmenu, optmenu_default_account_menu);
431
432         gtk_option_menu_set_history(optmenu, account_index);
433
434         menu = gtk_option_menu_get_menu(optmenu);
435         menuitem = gtk_menu_get_active(GTK_MENU(menu));
436         gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
437
438         SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_account, optmenu_default_account);
439
440         rowcount++;
441
442         /* Ok and Cancle Buttons */
443         gtkut_button_set_create(&confirm_area, &ok_btn, _("OK"),
444                                 &cancel_btn, _("Cancel"), NULL, NULL);
445         gtk_widget_show(confirm_area);
446         gtk_table_attach_defaults(GTK_TABLE(table), confirm_area, 0, 2, 
447                                   rowcount, rowcount + 1);
448         gtk_widget_grab_default(ok_btn);
449         gtk_signal_connect (GTK_OBJECT(ok_btn), "clicked",
450                             GTK_SIGNAL_FUNC(prefs_folder_item_ok_cb), dialog);
451         gtk_signal_connect (GTK_OBJECT(cancel_btn), "clicked",
452                             GTK_SIGNAL_FUNC(prefs_folder_item_cancel_cb), dialog);
453
454         dialog->window = window;
455         dialog->checkbtn_request_return_receipt = checkbtn_request_return_receipt;
456         dialog->checkbtn_save_copy_to_folder = checkbtn_save_copy_to_folder;
457         dialog->checkbtn_default_to = checkbtn_default_to;
458         dialog->entry_default_to = entry_default_to;
459         dialog->checkbtn_simplify_subject = checkbtn_simplify_subject;
460         dialog->entry_simplify_subject = entry_simplify_subject;
461         dialog->checkbtn_folder_chmod = checkbtn_folder_chmod;
462         dialog->entry_folder_chmod = entry_folder_chmod;
463         dialog->checkbtn_enable_default_account = checkbtn_enable_default_account;
464         dialog->optmenu_default_account = optmenu_default_account;
465
466         g_free(infotext);
467
468         address_completion_start(window);
469
470         gtk_widget_show(window);
471 }
472
473 void prefs_folder_item_destroy(struct PrefsFolderItemDialog *dialog) 
474 {
475         address_completion_unregister_entry(GTK_ENTRY(dialog->entry_default_to));
476         address_completion_end(dialog->window);
477         gtk_widget_destroy(dialog->window);
478         g_free(dialog);
479 }
480
481 void prefs_folder_item_cancel_cb(GtkWidget *widget, 
482                                  struct PrefsFolderItemDialog *dialog) 
483 {
484         prefs_folder_item_destroy(dialog);
485 }
486
487 void prefs_folder_item_delete_cb(GtkWidget *widget, GdkEventAny *event, 
488                                  struct PrefsFolderItemDialog *dialog) 
489 {
490         prefs_folder_item_destroy(dialog);
491 }
492
493 void prefs_folder_item_ok_cb(GtkWidget *widget, 
494                              struct PrefsFolderItemDialog *dialog) 
495 {
496         gchar *buf;
497         PrefsFolderItem *prefs = dialog->item->prefs;
498         GtkWidget *menu;
499         GtkWidget *menuitem;
500         gboolean   old_simplify_val;
501         gchar     *old_simplify_str;
502
503         g_return_if_fail(prefs != NULL);
504
505         old_simplify_val = prefs->enable_simplify_subject;
506         old_simplify_str = prefs->simplify_subject_regexp;
507
508         prefs->request_return_receipt = 
509             gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->checkbtn_request_return_receipt));
510         /* MIGRATION */    
511         dialog->item->ret_rcpt = prefs->request_return_receipt;
512
513         prefs->save_copy_to_folder = 
514             gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->checkbtn_save_copy_to_folder));
515
516         prefs->enable_default_to = 
517             gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->checkbtn_default_to));
518         g_free(prefs->default_to);
519         prefs->default_to = 
520             gtk_editable_get_chars(GTK_EDITABLE(dialog->entry_default_to), 0, -1);
521
522         prefs->enable_simplify_subject =
523             gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->checkbtn_simplify_subject));
524         prefs->simplify_subject_regexp = 
525             gtk_editable_get_chars(GTK_EDITABLE(dialog->entry_simplify_subject), 0, -1);
526         
527         if (dialog->item == dialog->folderview->summaryview->folder_item &&
528             (prefs->enable_simplify_subject != old_simplify_val ||  
529             0 != strcmp2(prefs->simplify_subject_regexp, old_simplify_str))) 
530                 summary_show(dialog->folderview->summaryview, dialog->item, FALSE);
531                 
532         if (old_simplify_str) g_free(old_simplify_str);
533
534         prefs->enable_folder_chmod = 
535             gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->checkbtn_folder_chmod));
536         buf = gtk_editable_get_chars(GTK_EDITABLE(dialog->entry_folder_chmod), 0, -1);
537         prefs->folder_chmod = prefs_folder_item_chmod_mode(buf);
538         g_free(buf);
539
540         prefs->enable_default_account = 
541             gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->checkbtn_enable_default_account));
542         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(dialog->optmenu_default_account));
543         menuitem = gtk_menu_get_active(GTK_MENU(menu));
544         prefs->default_account = GPOINTER_TO_INT(gtk_object_get_user_data(GTK_OBJECT(menuitem)));
545
546
547         prefs_folder_item_save_config(dialog->item);
548         prefs_folder_item_destroy(dialog);
549 }
550
551 gint prefs_folder_item_chmod_mode(gchar *folder_chmod) 
552 {
553         gint newmode = 0;
554         gchar *tmp;
555
556         if (folder_chmod) {
557                 newmode = strtol(folder_chmod, &tmp, 8);
558                 if (!(*(folder_chmod) && !(*tmp)))
559                         newmode = 0;
560         }
561
562         return newmode;
563 }