3ecc8d039ef2b77425c130dc4a27599b053567b5
[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         MANAGE_WINDOW_SIGNALS_CONNECT (window);
301
302         /* Table */
303         table = gtk_table_new(4, 2, FALSE);
304         gtk_widget_show(table);
305         gtk_table_set_row_spacings(GTK_TABLE(table), VSPACING_NARROW);
306         gtk_container_add(GTK_CONTAINER (window), table);
307         rowcount = 0;
308
309         /* Label */
310         folder_identifier = folder_item_get_identifier(item);
311         infotext = g_strconcat(_("Folder Property for "), folder_identifier, NULL);
312         infolabel = gtk_label_new(infotext);
313         gtk_table_attach(GTK_TABLE(table), infolabel, 0, 2, rowcount, 
314                          rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
315         gtk_widget_show(infolabel);
316         rowcount++;
317
318         /* Request Return Receipt */
319         checkbtn_request_return_receipt = gtk_check_button_new_with_label
320                 (_("Request Return Receipt"));
321         gtk_widget_show(checkbtn_request_return_receipt);
322         gtk_table_attach(GTK_TABLE(table), checkbtn_request_return_receipt, 
323                          0, 2, rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, 
324                          GTK_SHRINK, 0, 0);
325         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_request_return_receipt),
326                                      item->ret_rcpt ? TRUE : FALSE);
327
328         rowcount++;
329
330         /* Save Copy to Folder */
331         checkbtn_save_copy_to_folder = gtk_check_button_new_with_label
332                 (_("Save copy of outgoing messages to this folder instead of outbox"));
333         gtk_widget_show(checkbtn_save_copy_to_folder);
334         gtk_table_attach(GTK_TABLE(table), checkbtn_save_copy_to_folder, 0, 2, 
335                          rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
336         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_save_copy_to_folder),
337                                      item->prefs->save_copy_to_folder ? TRUE : FALSE);
338
339         rowcount++;
340
341         /* Default To */
342         checkbtn_default_to = gtk_check_button_new_with_label(_("Default To: "));
343         gtk_widget_show(checkbtn_default_to);
344         gtk_table_attach(GTK_TABLE(table), checkbtn_default_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_to), 
347                                      item->prefs->enable_default_to);
348
349         entry_default_to = gtk_entry_new();
350         gtk_widget_show(entry_default_to);
351         gtk_table_attach_defaults(GTK_TABLE(table), entry_default_to, 1, 2, rowcount, rowcount + 1);
352         SET_TOGGLE_SENSITIVITY(checkbtn_default_to, entry_default_to);
353         gtk_entry_set_text(GTK_ENTRY(entry_default_to), SAFE_STRING(item->prefs->default_to));
354         address_completion_register_entry(GTK_ENTRY(entry_default_to));
355
356         rowcount++;
357
358         /* Simplify Subject */
359         checkbtn_simplify_subject = gtk_check_button_new_with_label(_("Simplify Subject RegExp: "));
360         gtk_widget_show(checkbtn_simplify_subject);
361         gtk_table_attach(GTK_TABLE(table), checkbtn_simplify_subject, 0, 1, 
362                          rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
363         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_simplify_subject), 
364                                      item->prefs->enable_simplify_subject);
365
366         entry_simplify_subject = gtk_entry_new();
367         gtk_widget_show(entry_simplify_subject);
368         gtk_table_attach_defaults(GTK_TABLE(table), entry_simplify_subject, 1, 2, 
369                                   rowcount, rowcount + 1);
370         SET_TOGGLE_SENSITIVITY(checkbtn_simplify_subject, entry_simplify_subject);
371         gtk_entry_set_text(GTK_ENTRY(entry_simplify_subject), 
372                            SAFE_STRING(item->prefs->simplify_subject_regexp));
373
374         rowcount++;
375
376         /* Folder chmod */
377         checkbtn_folder_chmod = gtk_check_button_new_with_label(_("Folder chmod: "));
378         gtk_widget_show(checkbtn_folder_chmod);
379         gtk_table_attach(GTK_TABLE(table), checkbtn_folder_chmod, 0, 1, 
380                          rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
381
382         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_folder_chmod), 
383                                      item->prefs->enable_folder_chmod);
384
385         entry_folder_chmod = gtk_entry_new();
386         gtk_widget_show(entry_folder_chmod);
387         gtk_table_attach_defaults(GTK_TABLE(table), entry_folder_chmod, 1, 2, 
388                                   rowcount, rowcount + 1);
389         SET_TOGGLE_SENSITIVITY(checkbtn_folder_chmod, entry_folder_chmod);
390         if (item->prefs->folder_chmod) {
391                 gchar *buf;
392
393                 buf = g_strdup_printf("%o", item->prefs->folder_chmod);
394                 gtk_entry_set_text(GTK_ENTRY(entry_folder_chmod), buf);
395                 g_free(buf);
396         }
397         
398         rowcount++;
399
400         /* Default account */
401         checkbtn_enable_default_account = gtk_check_button_new_with_label(_("Default account: "));
402         gtk_widget_show(checkbtn_enable_default_account);
403         gtk_table_attach(GTK_TABLE(table), checkbtn_enable_default_account, 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_account), 
406                                      item->prefs->enable_default_account);
407
408         optmenu_default_account = gtk_option_menu_new ();
409         gtk_widget_show (optmenu_default_account);
410         gtk_table_attach_defaults(GTK_TABLE(table), optmenu_default_account, 1, 2, 
411                                   rowcount, rowcount + 1);
412         optmenu_default_account_menu = gtk_menu_new ();
413
414         account_list = account_get_list();
415         account_index = 0;
416         index = 0;
417         for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
418                 ac_prefs = (PrefsAccount *)cur_ac->data;
419                 MENUITEM_ADD (optmenu_default_account_menu, optmenu_default_account_menuitem,
420                                         ac_prefs->account_name?ac_prefs->account_name : _("Untitled"),
421                                         ac_prefs->account_id);
422                 /* get the index for menu's set_history (sad method?) */
423                 if (ac_prefs->account_id == item->prefs->default_account)
424                         account_index = index;
425                 index++;                        
426         }
427
428         dialog->item->prefs->default_account = item->prefs->default_account;
429
430         optmenu=GTK_OPTION_MENU(optmenu_default_account);
431         gtk_option_menu_set_menu(optmenu, optmenu_default_account_menu);
432
433         gtk_option_menu_set_history(optmenu, account_index);
434
435         menu = gtk_option_menu_get_menu(optmenu);
436         menuitem = gtk_menu_get_active(GTK_MENU(menu));
437         gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
438
439         SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_account, optmenu_default_account);
440
441         rowcount++;
442
443         /* Ok and Cancle Buttons */
444         gtkut_button_set_create(&confirm_area, &ok_btn, _("OK"),
445                                 &cancel_btn, _("Cancel"), NULL, NULL);
446         gtk_widget_show(confirm_area);
447         gtk_table_attach_defaults(GTK_TABLE(table), confirm_area, 0, 2, 
448                                   rowcount, rowcount + 1);
449         gtk_widget_grab_default(ok_btn);
450         gtk_signal_connect (GTK_OBJECT(ok_btn), "clicked",
451                             GTK_SIGNAL_FUNC(prefs_folder_item_ok_cb), dialog);
452         gtk_signal_connect (GTK_OBJECT(cancel_btn), "clicked",
453                             GTK_SIGNAL_FUNC(prefs_folder_item_cancel_cb), dialog);
454
455         dialog->window = window;
456         dialog->checkbtn_request_return_receipt = checkbtn_request_return_receipt;
457         dialog->checkbtn_save_copy_to_folder = checkbtn_save_copy_to_folder;
458         dialog->checkbtn_default_to = checkbtn_default_to;
459         dialog->entry_default_to = entry_default_to;
460         dialog->checkbtn_simplify_subject = checkbtn_simplify_subject;
461         dialog->entry_simplify_subject = entry_simplify_subject;
462         dialog->checkbtn_folder_chmod = checkbtn_folder_chmod;
463         dialog->entry_folder_chmod = entry_folder_chmod;
464         dialog->checkbtn_enable_default_account = checkbtn_enable_default_account;
465         dialog->optmenu_default_account = optmenu_default_account;
466
467         g_free(infotext);
468
469         address_completion_start(window);
470
471         gtk_widget_show(window);
472 }
473
474 void prefs_folder_item_destroy(struct PrefsFolderItemDialog *dialog) 
475 {
476         address_completion_unregister_entry(GTK_ENTRY(dialog->entry_default_to));
477         address_completion_end(dialog->window);
478         gtk_widget_destroy(dialog->window);
479         g_free(dialog);
480 }
481
482 void prefs_folder_item_cancel_cb(GtkWidget *widget, 
483                                  struct PrefsFolderItemDialog *dialog) 
484 {
485         prefs_folder_item_destroy(dialog);
486 }
487
488 void prefs_folder_item_delete_cb(GtkWidget *widget, GdkEventAny *event, 
489                                  struct PrefsFolderItemDialog *dialog) 
490 {
491         prefs_folder_item_destroy(dialog);
492 }
493
494 void prefs_folder_item_ok_cb(GtkWidget *widget, 
495                              struct PrefsFolderItemDialog *dialog) 
496 {
497         gchar *buf;
498         PrefsFolderItem *prefs = dialog->item->prefs;
499         GtkWidget *menu;
500         GtkWidget *menuitem;
501         gboolean   old_simplify_val;
502         gchar     *old_simplify_str;
503
504         g_return_if_fail(prefs != NULL);
505
506         old_simplify_val = prefs->enable_simplify_subject;
507         old_simplify_str = prefs->simplify_subject_regexp;
508
509         prefs->request_return_receipt = 
510             gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->checkbtn_request_return_receipt));
511         /* MIGRATION */    
512         dialog->item->ret_rcpt = prefs->request_return_receipt;
513
514         prefs->save_copy_to_folder = 
515             gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->checkbtn_save_copy_to_folder));
516
517         prefs->enable_default_to = 
518             gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->checkbtn_default_to));
519         g_free(prefs->default_to);
520         prefs->default_to = 
521             gtk_editable_get_chars(GTK_EDITABLE(dialog->entry_default_to), 0, -1);
522
523         prefs->enable_simplify_subject =
524             gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->checkbtn_simplify_subject));
525         prefs->simplify_subject_regexp = 
526             gtk_editable_get_chars(GTK_EDITABLE(dialog->entry_simplify_subject), 0, -1);
527         
528         if (dialog->item == dialog->folderview->summaryview->folder_item &&
529             (prefs->enable_simplify_subject != old_simplify_val ||  
530             0 != strcmp2(prefs->simplify_subject_regexp, old_simplify_str))) 
531                 summary_show(dialog->folderview->summaryview, dialog->item, FALSE);
532                 
533         if (old_simplify_str) g_free(old_simplify_str);
534
535         prefs->enable_folder_chmod = 
536             gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->checkbtn_folder_chmod));
537         buf = gtk_editable_get_chars(GTK_EDITABLE(dialog->entry_folder_chmod), 0, -1);
538         prefs->folder_chmod = prefs_folder_item_chmod_mode(buf);
539         g_free(buf);
540
541         prefs->enable_default_account = 
542             gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->checkbtn_enable_default_account));
543         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(dialog->optmenu_default_account));
544         menuitem = gtk_menu_get_active(GTK_MENU(menu));
545         prefs->default_account = GPOINTER_TO_INT(gtk_object_get_user_data(GTK_OBJECT(menuitem)));
546
547
548         prefs_folder_item_save_config(dialog->item);
549         prefs_folder_item_destroy(dialog);
550 }
551
552 gint prefs_folder_item_chmod_mode(gchar *folder_chmod) 
553 {
554         gint newmode = 0;
555         gchar *tmp;
556
557         if (folder_chmod) {
558                 newmode = strtol(folder_chmod, &tmp, 8);
559                 if (!(*(folder_chmod) && !(*tmp)))
560                         newmode = 0;
561         }
562
563         return newmode;
564 }