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