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