2 * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2016 Hiroyuki Yamamoto and the Claws Mail team
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 3 of the License, or
8 * (at your option) any later version.
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.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 /* alfons - all folder item specific settings should migrate into
20 * folderlist.xml!!! the old folderitemrc file will only serve for a few
21 * versions (for compatibility) */
25 #include "claws-features.h"
31 #include <glib/gi18n.h>
33 #include "alertpanel.h"
34 #include "prefs_folder_item.h"
35 #include "folderview.h"
37 #include "summaryview.h"
40 #include "prefs_gtk.h"
41 #include "manage_window.h"
43 #include "addr_compl.h"
44 #include "prefs_common.h"
46 #include "filtering.h"
47 #include "folder_item_prefs.h"
48 #include "gtk/colorsel.h"
49 #include "string_match.h"
50 #include "quote_fmt.h"
52 #include "stock_pixmap.h"
55 #include "gtkaspell.h"
58 #define ASSIGN_STRING(string, value) \
64 typedef struct _FolderItemGeneralPage FolderItemGeneralPage
;
65 typedef struct _FolderItemComposePage FolderItemComposePage
;
66 typedef struct _FolderItemTemplatesPage FolderItemTemplatesPage
;
67 static gboolean can_save
= TRUE
;
69 struct _FolderItemGeneralPage
76 GtkWidget
*no_save_warning
;
77 GtkWidget
*folder_type
;
78 GtkWidget
*checkbtn_simplify_subject
;
79 GtkWidget
*entry_simplify_subject
;
80 GtkWidget
*entry_regexp_test_string
;
81 GtkWidget
*entry_regexp_test_result
;
82 GtkWidget
*checkbtn_folder_chmod
;
83 GtkWidget
*entry_folder_chmod
;
84 GtkWidget
*folder_color_btn
;
85 GtkWidget
*checkbtn_enable_processing
;
86 GtkWidget
*checkbtn_enable_processing_when_opening
;
87 GtkWidget
*checkbtn_newmailcheck
;
88 GtkWidget
*checkbtn_offlinesync
;
89 GtkWidget
*label_offlinesync
;
90 GtkWidget
*entry_offlinesync
;
91 GtkWidget
*label_end_offlinesync
;
92 GtkWidget
*checkbtn_remove_old_offlinesync
;
93 GtkWidget
*promote_html_part
;
95 /* apply to sub folders */
96 GtkWidget
*simplify_subject_rec_checkbtn
;
97 GtkWidget
*folder_chmod_rec_checkbtn
;
98 GtkWidget
*folder_color_rec_checkbtn
;
99 GtkWidget
*enable_processing_rec_checkbtn
;
100 GtkWidget
*enable_processing_when_opening_rec_checkbtn
;
101 GtkWidget
*newmailcheck_rec_checkbtn
;
102 GtkWidget
*offlinesync_rec_checkbtn
;
103 GtkWidget
*promote_html_part_rec_checkbtn
;
108 struct _FolderItemComposePage
116 GtkWidget
*no_save_warning
;
117 GtkWidget
*checkbtn_request_return_receipt
;
118 GtkWidget
*checkbtn_save_copy_to_folder
;
119 GtkWidget
*checkbtn_default_to
;
120 GtkWidget
*entry_default_to
;
121 GtkWidget
*checkbtn_default_reply_to
;
122 GtkWidget
*entry_default_reply_to
;
123 GtkWidget
*checkbtn_default_cc
;
124 GtkWidget
*entry_default_cc
;
125 GtkWidget
*checkbtn_default_bcc
;
126 GtkWidget
*entry_default_bcc
;
127 GtkWidget
*checkbtn_default_replyto
;
128 GtkWidget
*entry_default_replyto
;
129 GtkWidget
*checkbtn_enable_default_account
;
130 GtkWidget
*optmenu_default_account
;
132 GtkWidget
*checkbtn_enable_default_dictionary
;
133 GtkWidget
*checkbtn_enable_default_alt_dictionary
;
134 GtkWidget
*combo_default_dictionary
;
135 GtkWidget
*combo_default_alt_dictionary
;
138 /* apply to sub folders */
139 GtkWidget
*request_return_receipt_rec_checkbtn
;
140 GtkWidget
*save_copy_to_folder_rec_checkbtn
;
141 GtkWidget
*default_to_rec_checkbtn
;
142 GtkWidget
*default_reply_to_rec_checkbtn
;
143 GtkWidget
*default_cc_rec_checkbtn
;
144 GtkWidget
*default_bcc_rec_checkbtn
;
145 GtkWidget
*default_replyto_rec_checkbtn
;
146 GtkWidget
*default_account_rec_checkbtn
;
148 GtkWidget
*default_dictionary_rec_checkbtn
;
149 GtkWidget
*default_alt_dictionary_rec_checkbtn
;
153 struct _FolderItemTemplatesPage
161 GtkWidget
*checkbtn_compose_with_format
;
162 GtkWidget
*compose_override_from_format
;
163 GtkWidget
*compose_subject_format
;
164 GtkWidget
*compose_body_format
;
165 GtkWidget
*checkbtn_reply_with_format
;
166 GtkWidget
*reply_quotemark
;
167 GtkWidget
*reply_override_from_format
;
168 GtkWidget
*reply_body_format
;
169 GtkWidget
*checkbtn_forward_with_format
;
170 GtkWidget
*forward_quotemark
;
171 GtkWidget
*forward_override_from_format
;
172 GtkWidget
*forward_body_format
;
174 /* apply to sub folders */
175 GtkWidget
*new_msg_format_rec_checkbtn
;
176 GtkWidget
*reply_format_rec_checkbtn
;
177 GtkWidget
*forward_format_rec_checkbtn
;
181 static void general_save_folder_prefs(FolderItem
*folder
, FolderItemGeneralPage
*page
);
182 static void compose_save_folder_prefs(FolderItem
*folder
, FolderItemComposePage
*page
);
183 static void templates_save_folder_prefs(FolderItem
*folder
, FolderItemTemplatesPage
*page
);
185 static gboolean
general_save_recurse_func(GNode
*node
, gpointer data
);
186 static gboolean
compose_save_recurse_func(GNode
*node
, gpointer data
);
187 static gboolean
templates_save_recurse_func(GNode
*node
, gpointer data
);
189 static gint
prefs_folder_item_chmod_mode (gchar
*folder_chmod
);
191 static void folder_color_set_dialog(GtkWidget
*widget
, gpointer data
);
192 static void clean_cache_cb(GtkWidget
*widget
, gpointer data
);
193 static void folder_regexp_test_cb(GtkWidget
*widget
, gpointer data
);
194 static void folder_regexp_set_subject_example_cb(GtkWidget
*widget
, gpointer data
);
196 #define SAFE_STRING(str) \
199 static GtkWidget
*prefs_folder_no_save_warning_create_widget() {
204 hbox
= gtk_hbox_new(FALSE
, 0);
206 icon
= stock_pixmap_widget(STOCK_PIXMAP_NOTICE_WARN
);
207 gtk_box_pack_start(GTK_BOX(hbox
), icon
, FALSE
, FALSE
, 8);
209 label
= gtk_label_new(g_strconcat("<i>",
210 _("These preferences will not be saved as this folder "
211 "is a top-level folder.\nHowever, you can set them for the "
212 "whole mailbox tree by using \"Apply to subfolders\"."),
214 gtk_label_set_use_markup(GTK_LABEL(label
), TRUE
);
215 gtk_misc_set_alignment(GTK_MISC(label
), 0.0, 0.5);
216 gtk_box_pack_start(GTK_BOX(hbox
), label
, TRUE
, TRUE
, 0);
221 static void prefs_folder_item_general_create_widget_func(PrefsPage
* page_
,
225 FolderItemGeneralPage
*page
= (FolderItemGeneralPage
*) page_
;
226 FolderItem
*item
= (FolderItem
*) data
;
230 GtkWidget
*hbox
, *hbox2
, *hbox_spc
;
233 GtkListStore
*folder_type_menu
;
234 GtkWidget
*folder_type
;
236 GtkWidget
*dummy_checkbtn
, *clean_cache_btn
;
237 SpecialFolderItemType type
;
238 GtkWidget
*no_save_warning
= NULL
;
240 GtkWidget
*checkbtn_simplify_subject
;
241 GtkWidget
*entry_simplify_subject
;
242 GtkWidget
*label_regexp_test
;
243 GtkWidget
*entry_regexp_test_string
;
244 GtkWidget
*label_regexp_result
;
245 GtkWidget
*entry_regexp_test_result
;
247 GtkWidget
*checkbtn_folder_chmod
;
248 GtkWidget
*entry_folder_chmod
;
249 GtkWidget
*folder_color
;
250 GtkWidget
*folder_color_btn
;
251 GtkWidget
*checkbtn_enable_processing
;
252 GtkWidget
*checkbtn_enable_processing_when_opening
;
253 GtkWidget
*checkbtn_newmailcheck
;
254 GtkWidget
*checkbtn_offlinesync
;
255 GtkWidget
*label_offlinesync
;
256 GtkWidget
*entry_offlinesync
;
257 GtkWidget
*label_end_offlinesync
;
258 GtkWidget
*checkbtn_remove_old_offlinesync
;
259 GtkWidget
*promote_html_part
;
260 GtkListStore
*promote_html_part_menu
;
262 GtkWidget
*simplify_subject_rec_checkbtn
;
264 GtkWidget
*folder_chmod_rec_checkbtn
;
265 GtkWidget
*folder_color_rec_checkbtn
;
266 GtkWidget
*enable_processing_rec_checkbtn
;
267 GtkWidget
*enable_processing_when_opening_rec_checkbtn
;
268 GtkWidget
*newmailcheck_rec_checkbtn
;
269 GtkWidget
*offlinesync_rec_checkbtn
;
270 GtkWidget
*promote_html_part_rec_checkbtn
;
275 table
= gtk_table_new(12, 3, FALSE
);
276 gtk_container_set_border_width (GTK_CONTAINER (table
), VBOX_BORDER
);
277 gtk_table_set_row_spacings(GTK_TABLE(table
), 4);
278 gtk_table_set_col_spacings(GTK_TABLE(table
), 4);
282 no_save_warning
= prefs_folder_no_save_warning_create_widget();
283 gtk_table_attach(GTK_TABLE(table
), no_save_warning
, 0, 3,
284 rowcount
, rowcount
+ 1, GTK_FILL
, 0, 0, 0);
288 /* Apply to subfolders */
289 label
= gtk_label_new(_("Apply to\nsubfolders"));
290 gtk_misc_set_alignment(GTK_MISC(label
), 0.5, 0.5);
291 gtk_table_attach(GTK_TABLE(table
), label
, 2, 3,
292 rowcount
, rowcount
+ 1, GTK_SHRINK
, GTK_SHRINK
, 0, 0);
296 folder_type
= gtkut_sc_combobox_create(NULL
, FALSE
);
297 gtk_widget_show (folder_type
);
300 if (item
->stype
== F_INBOX
)
302 else if (folder_has_parent_of_type(item
, F_OUTBOX
))
304 else if (folder_has_parent_of_type(item
, F_DRAFT
))
306 else if (folder_has_parent_of_type(item
, F_QUEUE
))
308 else if (folder_has_parent_of_type(item
, F_TRASH
))
311 folder_type_menu
= GTK_LIST_STORE(gtk_combo_box_get_model(
312 GTK_COMBO_BOX(folder_type
)));
314 COMBOBOX_ADD (folder_type_menu
, _("Normal"), F_NORMAL
);
315 COMBOBOX_ADD (folder_type_menu
, _("Inbox"), F_INBOX
);
316 COMBOBOX_ADD (folder_type_menu
, _("Outbox"), F_OUTBOX
);
317 COMBOBOX_ADD (folder_type_menu
, _("Drafts"), F_DRAFT
);
318 COMBOBOX_ADD (folder_type_menu
, _("Queue"), F_QUEUE
);
319 COMBOBOX_ADD (folder_type_menu
, _("Trash"), F_TRASH
);
321 combobox_select_by_data(GTK_COMBO_BOX(folder_type
), type
);
323 dummy_checkbtn
= gtk_check_button_new();
324 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dummy_checkbtn
), type
!= F_INBOX
);
325 gtk_widget_set_sensitive(dummy_checkbtn
, FALSE
);
327 if (type
== item
->stype
&& type
== F_NORMAL
)
328 gtk_widget_set_sensitive(folder_type
, TRUE
);
330 gtk_widget_set_sensitive(folder_type
, FALSE
);
332 label
= gtk_label_new(_("Folder type"));
333 gtk_misc_set_alignment(GTK_MISC(label
), 0, 0.5);
334 gtk_table_attach(GTK_TABLE(table
), label
, 0, 1,
335 rowcount
, rowcount
+ 1, GTK_SHRINK
| GTK_FILL
, GTK_FILL
, 0, 0);
336 gtk_table_attach(GTK_TABLE(table
), folder_type
, 1, 2,
337 rowcount
, rowcount
+ 1, GTK_SHRINK
| GTK_FILL
, GTK_FILL
, 0, 0);
338 gtk_table_attach(GTK_TABLE(table
), dummy_checkbtn
, 2, 3,
339 rowcount
, rowcount
+ 1, GTK_SHRINK
, GTK_SHRINK
, 0, 0);
343 /* Simplify Subject */
344 checkbtn_simplify_subject
= gtk_check_button_new_with_label(_("Simplify Subject RegExp"));
345 gtk_table_attach(GTK_TABLE(table
), checkbtn_simplify_subject
, 0, 1,
346 rowcount
, rowcount
+ 1, GTK_SHRINK
| GTK_FILL
, GTK_FILL
, 0, 0);
347 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_simplify_subject
),
348 item
->prefs
->enable_simplify_subject
);
350 g_signal_connect(G_OBJECT(checkbtn_simplify_subject
), "toggled",
351 G_CALLBACK(folder_regexp_set_subject_example_cb
), page
);
353 entry_simplify_subject
= gtk_entry_new();
354 gtk_table_attach(GTK_TABLE(table
), entry_simplify_subject
, 1, 2,
355 rowcount
, rowcount
+ 1, GTK_EXPAND
| GTK_FILL
, GTK_FILL
, 0, 0);
356 SET_TOGGLE_SENSITIVITY(checkbtn_simplify_subject
, entry_simplify_subject
);
357 gtk_entry_set_text(GTK_ENTRY(entry_simplify_subject
),
358 SAFE_STRING(item
->prefs
->simplify_subject_regexp
));
360 g_signal_connect(G_OBJECT(entry_simplify_subject
), "changed",
361 G_CALLBACK(folder_regexp_test_cb
), page
);
363 simplify_subject_rec_checkbtn
= gtk_check_button_new();
364 gtk_table_attach(GTK_TABLE(table
), simplify_subject_rec_checkbtn
, 2, 3,
365 rowcount
, rowcount
+ 1, GTK_SHRINK
, GTK_SHRINK
, 0, 0);
370 label_regexp_test
= gtk_label_new(_("Test string:"));
371 gtk_misc_set_alignment(GTK_MISC(label_regexp_test
), 1, 0.5);
372 gtk_table_attach(GTK_TABLE(table
), label_regexp_test
, 0, 1,
373 rowcount
, rowcount
+ 1, GTK_SHRINK
| GTK_FILL
, GTK_FILL
, 0, 0);
374 SET_TOGGLE_SENSITIVITY(checkbtn_simplify_subject
, label_regexp_test
);
376 entry_regexp_test_string
= gtk_entry_new();
377 gtk_table_attach(GTK_TABLE(table
), entry_regexp_test_string
, 1, 2,
378 rowcount
, rowcount
+ 1, GTK_EXPAND
| GTK_FILL
, GTK_FILL
, 0, 0);
379 SET_TOGGLE_SENSITIVITY(checkbtn_simplify_subject
, entry_regexp_test_string
);
381 g_signal_connect(G_OBJECT(entry_regexp_test_string
), "changed",
382 G_CALLBACK(folder_regexp_test_cb
), page
);
387 label_regexp_result
= gtk_label_new(_("Result:"));
388 gtk_misc_set_alignment(GTK_MISC(label_regexp_result
), 1, 0.5);
389 gtk_table_attach(GTK_TABLE(table
), label_regexp_result
, 0, 1,
390 rowcount
, rowcount
+ 1, GTK_SHRINK
| GTK_FILL
, GTK_FILL
, 0, 0);
391 SET_TOGGLE_SENSITIVITY(checkbtn_simplify_subject
, label_regexp_result
);
393 entry_regexp_test_result
= gtk_entry_new();
394 gtk_table_attach(GTK_TABLE(table
), entry_regexp_test_result
, 1, 2,
395 rowcount
, rowcount
+ 1, GTK_EXPAND
| GTK_FILL
, GTK_FILL
, 0, 0);
396 SET_TOGGLE_SENSITIVITY(checkbtn_simplify_subject
, entry_regexp_test_result
);
397 gtk_editable_set_editable(GTK_EDITABLE(entry_regexp_test_result
), FALSE
);
402 checkbtn_folder_chmod
= gtk_check_button_new_with_label(_("Folder chmod"));
403 gtk_table_attach(GTK_TABLE(table
), checkbtn_folder_chmod
, 0, 1,
404 rowcount
, rowcount
+ 1, GTK_SHRINK
| GTK_FILL
, GTK_FILL
, 0, 0);
406 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_folder_chmod
),
407 item
->prefs
->enable_folder_chmod
);
409 entry_folder_chmod
= gtk_entry_new();
410 gtk_table_attach(GTK_TABLE(table
), entry_folder_chmod
, 1, 2,
411 rowcount
, rowcount
+ 1, GTK_EXPAND
| GTK_FILL
, GTK_FILL
, 0, 0);
412 SET_TOGGLE_SENSITIVITY(checkbtn_folder_chmod
, entry_folder_chmod
);
413 if (item
->prefs
->folder_chmod
) {
416 buf
= g_strdup_printf("%o", item
->prefs
->folder_chmod
);
417 gtk_entry_set_text(GTK_ENTRY(entry_folder_chmod
), buf
);
421 folder_chmod_rec_checkbtn
= gtk_check_button_new();
422 gtk_table_attach(GTK_TABLE(table
), folder_chmod_rec_checkbtn
, 2, 3,
423 rowcount
, rowcount
+ 1, GTK_SHRINK
, GTK_SHRINK
, 0, 0);
428 folder_color
= gtk_label_new(_("Folder color"));
429 gtk_misc_set_alignment(GTK_MISC(folder_color
), 0, 0.5);
430 gtk_table_attach(GTK_TABLE(table
), folder_color
, 0, 1,
431 rowcount
, rowcount
+ 1, GTK_SHRINK
| GTK_FILL
, GTK_FILL
, 0, 0);
433 hbox
= gtk_hbox_new(FALSE
, 0);
434 gtk_table_attach(GTK_TABLE(table
), hbox
, 1, 2,
435 rowcount
, rowcount
+ 1, GTK_EXPAND
| GTK_FILL
, GTK_FILL
, 0, 0);
437 folder_color_btn
= gtk_button_new_with_label("");
438 gtk_widget_set_size_request(folder_color_btn
, 36, 26);
439 gtk_box_pack_start (GTK_BOX(hbox
), folder_color_btn
, FALSE
, FALSE
, 0);
440 CLAWS_SET_TIP(folder_color_btn
,
441 _("Pick color for folder"));
443 page
->folder_color
= item
->prefs
->color
;
445 g_signal_connect(G_OBJECT(folder_color_btn
), "clicked",
446 G_CALLBACK(folder_color_set_dialog
),
449 gtkut_set_widget_bgcolor_rgb(folder_color_btn
, item
->prefs
->color
);
451 folder_color_rec_checkbtn
= gtk_check_button_new();
452 gtk_table_attach(GTK_TABLE(table
), folder_color_rec_checkbtn
, 2, 3,
453 rowcount
, rowcount
+ 1, GTK_SHRINK
, GTK_SHRINK
, 0, 0);
457 /* Enable processing at startup */
458 checkbtn_enable_processing
=
459 gtk_check_button_new_with_label(_("Run Processing rules at start-up"));
460 gtk_table_attach(GTK_TABLE(table
), checkbtn_enable_processing
, 0, 2,
461 rowcount
, rowcount
+ 1, GTK_EXPAND
| GTK_FILL
, GTK_FILL
, 0, 0);
463 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_processing
),
464 item
->prefs
->enable_processing
);
466 enable_processing_rec_checkbtn
= gtk_check_button_new();
467 gtk_table_attach(GTK_TABLE(table
), enable_processing_rec_checkbtn
, 2, 3,
468 rowcount
, rowcount
+ 1, GTK_SHRINK
, GTK_SHRINK
, 0, 0);
472 /* Enable processing rules when opening folder */
473 checkbtn_enable_processing_when_opening
=
474 gtk_check_button_new_with_label(_("Run Processing rules when opening"));
475 gtk_table_attach(GTK_TABLE(table
), checkbtn_enable_processing_when_opening
, 0, 2,
476 rowcount
, rowcount
+ 1, GTK_EXPAND
| GTK_FILL
, GTK_FILL
, 0, 0);
478 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_processing_when_opening
),
479 item
->prefs
->enable_processing_when_opening
);
481 enable_processing_when_opening_rec_checkbtn
= gtk_check_button_new();
482 gtk_table_attach(GTK_TABLE(table
), enable_processing_when_opening_rec_checkbtn
, 2, 3,
483 rowcount
, rowcount
+ 1, GTK_SHRINK
, GTK_SHRINK
, 0, 0);
487 /* Check folder for new mail */
488 checkbtn_newmailcheck
= gtk_check_button_new_with_label(_("Scan for new mail"));
489 CLAWS_SET_TIP(checkbtn_newmailcheck
,
490 _("Turn this option on if mail is delivered directly "
491 "to this folder by server side filtering on IMAP or "
492 "by an external application"));
493 gtk_table_attach(GTK_TABLE(table
), checkbtn_newmailcheck
, 0, 2,
494 rowcount
, rowcount
+1, GTK_EXPAND
| GTK_FILL
, GTK_FILL
, 0, 0);
496 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_newmailcheck
),
497 item
->prefs
->newmailcheck
);
498 newmailcheck_rec_checkbtn
= gtk_check_button_new();
499 gtk_table_attach(GTK_TABLE(table
), newmailcheck_rec_checkbtn
, 2, 3,
500 rowcount
, rowcount
+ 1, GTK_SHRINK
, GTK_SHRINK
, 0, 0);
504 /* Select HTML part by default? */
505 hbox
= gtk_hbox_new (FALSE
, 2);
506 gtk_widget_show (hbox
);
507 gtk_table_attach (GTK_TABLE(table
), hbox
, 0, 2,
508 rowcount
, rowcount
+1, GTK_FILL
, GTK_FILL
, 0, 0);
510 label
= gtk_label_new(_("Select the HTML part of multipart messages"));
511 gtk_widget_show (label
);
512 gtk_box_pack_start (GTK_BOX(hbox
), label
, FALSE
, FALSE
, 0);
514 promote_html_part
= gtkut_sc_combobox_create (NULL
, FALSE
);
515 gtk_widget_show (promote_html_part
);
516 gtk_box_pack_start (GTK_BOX(hbox
), promote_html_part
, FALSE
, FALSE
, 0);
518 promote_html_part_menu
= GTK_LIST_STORE(gtk_combo_box_get_model(
519 GTK_COMBO_BOX(promote_html_part
)));
520 COMBOBOX_ADD (promote_html_part_menu
, _("Default"), HTML_PROMOTE_DEFAULT
);
521 COMBOBOX_ADD (promote_html_part_menu
, _("No"), HTML_PROMOTE_NEVER
);
522 COMBOBOX_ADD (promote_html_part_menu
, _("Yes"), HTML_PROMOTE_ALWAYS
);
524 combobox_select_by_data(GTK_COMBO_BOX(promote_html_part
),
525 item
->prefs
->promote_html_part
);
527 CLAWS_SET_TIP(hbox
, _("\"Default\" will follow global preference (found in /Preferences/"
528 "Message View/Text Options)"));
530 promote_html_part_rec_checkbtn
= gtk_check_button_new();
531 gtk_widget_show (promote_html_part_rec_checkbtn
);
532 gtk_table_attach(GTK_TABLE(table
), promote_html_part_rec_checkbtn
, 2, 3,
533 rowcount
, rowcount
+ 1, GTK_SHRINK
, GTK_SHRINK
, 0, 0);
536 /* Synchronise folder for offline use */
537 checkbtn_offlinesync
= gtk_check_button_new_with_label(_("Synchronise for offline use"));
538 gtk_table_attach(GTK_TABLE(table
), checkbtn_offlinesync
, 0, 2,
539 rowcount
, rowcount
+1, GTK_EXPAND
| GTK_FILL
, GTK_FILL
, 0, 0);
541 offlinesync_rec_checkbtn
= gtk_check_button_new();
542 gtk_table_attach(GTK_TABLE(table
), offlinesync_rec_checkbtn
, 2, 3,
543 rowcount
, rowcount
+ 1, GTK_SHRINK
, GTK_SHRINK
, 0, 0);
547 hbox
= gtk_hbox_new (FALSE
, 8);
548 gtk_widget_show (hbox
);
549 gtk_table_attach(GTK_TABLE(table
), hbox
, 0, 3,
550 rowcount
, rowcount
+1, GTK_EXPAND
| GTK_FILL
, GTK_FILL
, 0, 0);
553 hbox_spc
= gtk_hbox_new (FALSE
, 0);
554 gtk_widget_show (hbox_spc
);
555 gtk_box_pack_start (GTK_BOX (hbox
), hbox_spc
, FALSE
, FALSE
, 0);
556 gtk_widget_set_size_request (hbox_spc
, 12, -1);
558 label_offlinesync
= gtk_label_new(_("Fetch message bodies from the last"));
559 gtk_widget_show (label_offlinesync
);
560 gtk_box_pack_start (GTK_BOX (hbox
), label_offlinesync
, FALSE
, FALSE
, 0);
562 entry_offlinesync
= gtk_entry_new();
563 gtk_widget_set_size_request (entry_offlinesync
, 64, -1);
564 gtk_widget_show (entry_offlinesync
);
565 CLAWS_SET_TIP(entry_offlinesync
, _("0: all bodies"));
566 gtk_box_pack_start (GTK_BOX (hbox
), entry_offlinesync
, FALSE
, FALSE
, 0);
568 label_end_offlinesync
= gtk_label_new(_("days"));
569 gtk_widget_show (label_end_offlinesync
);
570 gtk_box_pack_start (GTK_BOX (hbox
), label_end_offlinesync
, FALSE
, FALSE
, 0);
572 checkbtn_remove_old_offlinesync
= gtk_check_button_new_with_label(
573 _("Remove older messages bodies"));
575 hbox2
= gtk_hbox_new (FALSE
, 8);
576 gtk_widget_show (hbox2
);
577 gtk_table_attach(GTK_TABLE(table
), hbox2
, 0, 3,
578 rowcount
, rowcount
+1, GTK_EXPAND
| GTK_FILL
, GTK_FILL
, 0, 0);
581 hbox_spc
= gtk_hbox_new (FALSE
, 0);
582 gtk_widget_show (hbox_spc
);
583 gtk_box_pack_start (GTK_BOX (hbox2
), hbox_spc
, FALSE
, FALSE
, 0);
584 gtk_widget_set_size_request (hbox_spc
, 12, -1);
585 gtk_box_pack_start (GTK_BOX (hbox2
), checkbtn_remove_old_offlinesync
, FALSE
, FALSE
, 0);
587 SET_TOGGLE_SENSITIVITY (checkbtn_offlinesync
, hbox
);
588 SET_TOGGLE_SENSITIVITY (checkbtn_offlinesync
, hbox2
);
590 clean_cache_btn
= gtk_button_new_with_label(_("Discard folder cache"));
591 gtk_widget_show (clean_cache_btn
);
592 gtk_table_attach(GTK_TABLE(table
), clean_cache_btn
, 0, 1,
593 rowcount
, rowcount
+1, GTK_EXPAND
| GTK_FILL
, GTK_FILL
, 0, 0);
594 g_signal_connect(G_OBJECT(clean_cache_btn
), "clicked",
595 G_CALLBACK(clean_cache_cb
),
598 gtk_widget_show_all(table
);
600 if (item
->folder
&& (item
->folder
->klass
->type
!= F_IMAP
&&
601 item
->folder
->klass
->type
!= F_NEWS
)) {
602 item
->prefs
->offlinesync
= TRUE
;
603 item
->prefs
->offlinesync_days
= 0;
604 item
->prefs
->remove_old_bodies
= FALSE
;
606 gtk_widget_set_sensitive(GTK_WIDGET(checkbtn_offlinesync
),
608 gtk_widget_set_sensitive(GTK_WIDGET(offlinesync_rec_checkbtn
),
610 gtk_widget_hide(GTK_WIDGET(checkbtn_offlinesync
));
611 gtk_widget_hide(GTK_WIDGET(hbox
));
612 gtk_widget_hide(GTK_WIDGET(hbox2
));
613 gtk_widget_hide(GTK_WIDGET(offlinesync_rec_checkbtn
));
614 gtk_widget_hide(GTK_WIDGET(clean_cache_btn
));
617 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_offlinesync
),
618 item
->prefs
->offlinesync
);
619 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_remove_old_offlinesync
),
620 item
->prefs
->remove_old_bodies
);
621 gtk_entry_set_text(GTK_ENTRY(entry_offlinesync
), itos(item
->prefs
->offlinesync_days
));
624 page
->folder_type
= folder_type
;
625 page
->no_save_warning
= no_save_warning
;
627 page
->checkbtn_simplify_subject
= checkbtn_simplify_subject
;
628 page
->entry_simplify_subject
= entry_simplify_subject
;
629 page
->entry_regexp_test_string
= entry_regexp_test_string
;
630 page
->entry_regexp_test_result
= entry_regexp_test_result
;
632 page
->checkbtn_folder_chmod
= checkbtn_folder_chmod
;
633 page
->entry_folder_chmod
= entry_folder_chmod
;
634 page
->folder_color_btn
= folder_color_btn
;
635 page
->checkbtn_enable_processing
= checkbtn_enable_processing
;
636 page
->checkbtn_enable_processing_when_opening
= checkbtn_enable_processing_when_opening
;
637 page
->checkbtn_newmailcheck
= checkbtn_newmailcheck
;
638 page
->checkbtn_offlinesync
= checkbtn_offlinesync
;
639 page
->label_offlinesync
= label_offlinesync
;
640 page
->entry_offlinesync
= entry_offlinesync
;
641 page
->label_end_offlinesync
= label_end_offlinesync
;
642 page
->checkbtn_remove_old_offlinesync
= checkbtn_remove_old_offlinesync
;
643 page
->promote_html_part
= promote_html_part
;
646 page
->simplify_subject_rec_checkbtn
= simplify_subject_rec_checkbtn
;
648 page
->folder_chmod_rec_checkbtn
= folder_chmod_rec_checkbtn
;
649 page
->folder_color_rec_checkbtn
= folder_color_rec_checkbtn
;
650 page
->enable_processing_rec_checkbtn
= enable_processing_rec_checkbtn
;
651 page
->enable_processing_when_opening_rec_checkbtn
= enable_processing_when_opening_rec_checkbtn
;
652 page
->newmailcheck_rec_checkbtn
= newmailcheck_rec_checkbtn
;
653 page
->offlinesync_rec_checkbtn
= offlinesync_rec_checkbtn
;
654 page
->promote_html_part_rec_checkbtn
= promote_html_part_rec_checkbtn
;
656 page
->page
.widget
= table
;
658 folder_regexp_set_subject_example_cb(NULL
, page
);
661 static void prefs_folder_item_general_destroy_widget_func(PrefsPage
*page_
)
663 /* FolderItemGeneralPage *page = (FolderItemGeneralPage *) page_; */
666 /** \brief Save the prefs in page to folder.
668 * If the folder is not the one specified in page->item, then only those properties
669 * that have the relevant 'apply to sub folders' button checked are saved
671 static void general_save_folder_prefs(FolderItem
*folder
, FolderItemGeneralPage
*page
)
673 FolderItemPrefs
*prefs
= folder
->prefs
;
675 gboolean all
= FALSE
, summary_update_needed
= FALSE
;
676 SpecialFolderItemType type
= F_NORMAL
;
677 FolderView
*folderview
= mainwindow_get_mainwindow()->folderview
;
678 HTMLPromoteType promote_html_part
= HTML_PROMOTE_DEFAULT
;
680 if (folder
->path
== NULL
)
683 cm_return_if_fail(prefs
!= NULL
);
685 if (page
->item
== folder
)
688 type
= combobox_get_active_data(GTK_COMBO_BOX(page
->folder_type
));
689 if (all
&& folder
->stype
!= type
&& page
->item
->parent_stype
== F_NORMAL
) {
690 folder_item_change_type(folder
, type
);
691 summary_update_needed
= TRUE
;
695 combobox_get_active_data(GTK_COMBO_BOX(page
->promote_html_part
));
696 if (all
|| gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->promote_html_part_rec_checkbtn
)))
697 prefs
->promote_html_part
= promote_html_part
;
699 if (all
|| gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->simplify_subject_rec_checkbtn
))) {
700 gboolean old_simplify_subject
= prefs
->enable_simplify_subject
;
701 int regexp_diffs
= strcmp2(prefs
->simplify_subject_regexp
, gtk_editable_get_chars(
702 GTK_EDITABLE(page
->entry_simplify_subject
), 0, -1));
703 prefs
->enable_simplify_subject
=
704 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->checkbtn_simplify_subject
));
705 ASSIGN_STRING(prefs
->simplify_subject_regexp
,
706 gtk_editable_get_chars(GTK_EDITABLE(page
->entry_simplify_subject
), 0, -1));
707 if (old_simplify_subject
!= prefs
->enable_simplify_subject
|| regexp_diffs
!= 0)
708 summary_update_needed
= TRUE
;
711 if (all
|| gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->folder_chmod_rec_checkbtn
))) {
712 prefs
->enable_folder_chmod
=
713 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->checkbtn_folder_chmod
));
714 buf
= gtk_editable_get_chars(GTK_EDITABLE(page
->entry_folder_chmod
), 0, -1);
715 prefs
->folder_chmod
= prefs_folder_item_chmod_mode(buf
);
719 if (all
|| gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->folder_color_rec_checkbtn
))) {
720 int old_color
= prefs
->color
;
721 prefs
->color
= page
->folder_color
;
723 /* update folder view */
724 if (prefs
->color
!= old_color
)
725 folder_item_update(folder
, F_ITEM_UPDATE_MSGCNT
);
728 if (all
|| gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->enable_processing_rec_checkbtn
))) {
729 prefs
->enable_processing
=
730 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->checkbtn_enable_processing
));
733 if (all
|| gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->enable_processing_when_opening_rec_checkbtn
))) {
734 prefs
->enable_processing_when_opening
=
735 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->checkbtn_enable_processing_when_opening
));
738 if (all
|| gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->newmailcheck_rec_checkbtn
))) {
739 prefs
->newmailcheck
=
740 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->checkbtn_newmailcheck
));
743 if (all
|| gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->offlinesync_rec_checkbtn
))) {
745 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->checkbtn_offlinesync
));
746 prefs
->offlinesync_days
=
747 atoi(gtk_entry_get_text(GTK_ENTRY(page
->entry_offlinesync
)));
748 prefs
->remove_old_bodies
=
749 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->checkbtn_remove_old_offlinesync
));
752 folder_item_prefs_save_config(folder
);
754 if (folder
->opened
&& summary_update_needed
) {
755 summary_set_prefs_from_folderitem(folderview
->summaryview
, folder
);
756 summary_show(folderview
->summaryview
, folder
);
760 static gboolean
general_save_recurse_func(GNode
*node
, gpointer data
)
762 FolderItem
*item
= (FolderItem
*) node
->data
;
763 FolderItemGeneralPage
*page
= (FolderItemGeneralPage
*) data
;
765 cm_return_val_if_fail(item
!= NULL
, TRUE
);
766 cm_return_val_if_fail(page
!= NULL
, TRUE
);
768 general_save_folder_prefs(item
, page
);
770 /* optimise by not continuing if none of the 'apply to sub folders'
771 check boxes are selected - and optimise the checking by only doing
773 if ((node
== page
->item
->node
) &&
775 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->simplify_subject_rec_checkbtn
)) ||
776 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->folder_chmod_rec_checkbtn
)) ||
777 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->folder_color_rec_checkbtn
)) ||
778 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->enable_processing_rec_checkbtn
)) ||
779 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->enable_processing_when_opening_rec_checkbtn
)) ||
780 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->newmailcheck_rec_checkbtn
)) ||
781 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->offlinesync_rec_checkbtn
)) ||
782 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->promote_html_part_rec_checkbtn
))
789 static void prefs_folder_item_general_save_func(PrefsPage
*page_
)
791 FolderItemGeneralPage
*page
= (FolderItemGeneralPage
*) page_
;
793 g_node_traverse(page
->item
->node
, G_PRE_ORDER
, G_TRAVERSE_ALL
,
794 -1, general_save_recurse_func
, page
);
796 main_window_set_menu_sensitive(mainwindow_get_mainwindow());
800 static RecvProtocol
item_protocol(FolderItem
*item
)
806 if (!item
->folder
->account
)
808 return item
->folder
->account
->protocol
;
811 static void prefs_folder_item_compose_create_widget_func(PrefsPage
* page_
,
815 FolderItemComposePage
*page
= (FolderItemComposePage
*) page_
;
816 FolderItem
*item
= (FolderItem
*) data
;
823 GtkWidget
*no_save_warning
= NULL
;
824 GtkWidget
*checkbtn_request_return_receipt
= NULL
;
825 GtkWidget
*checkbtn_save_copy_to_folder
= NULL
;
826 GtkWidget
*checkbtn_default_to
= NULL
;
827 GtkWidget
*entry_default_to
= NULL
;
828 GtkWidget
*checkbtn_default_reply_to
= NULL
;
829 GtkWidget
*entry_default_reply_to
= NULL
;
830 GtkWidget
*checkbtn_default_cc
= NULL
;
831 GtkWidget
*entry_default_cc
= NULL
;
832 GtkWidget
*checkbtn_default_bcc
= NULL
;
833 GtkWidget
*entry_default_bcc
= NULL
;
834 GtkWidget
*checkbtn_default_replyto
= NULL
;
835 GtkWidget
*entry_default_replyto
= NULL
;
836 GtkWidget
*checkbtn_enable_default_account
= NULL
;
837 GtkWidget
*optmenu_default_account
= NULL
;
838 GtkListStore
*optmenu_default_account_menu
= NULL
;
841 GtkWidget
*checkbtn_enable_default_dictionary
= NULL
;
842 GtkWidget
*combo_default_dictionary
= NULL
;
843 GtkWidget
*checkbtn_enable_default_alt_dictionary
= NULL
;
844 GtkWidget
*combo_default_alt_dictionary
= NULL
;
845 GtkWidget
*default_dictionary_rec_checkbtn
= NULL
;
846 GtkWidget
*default_alt_dictionary_rec_checkbtn
= NULL
;
849 GtkWidget
*request_return_receipt_rec_checkbtn
= NULL
;
850 GtkWidget
*save_copy_to_folder_rec_checkbtn
= NULL
;
851 GtkWidget
*default_to_rec_checkbtn
= NULL
;
852 GtkWidget
*default_reply_to_rec_checkbtn
= NULL
;
853 GtkWidget
*default_cc_rec_checkbtn
= NULL
;
854 GtkWidget
*default_bcc_rec_checkbtn
= NULL
;
855 GtkWidget
*default_replyto_rec_checkbtn
= NULL
;
856 GtkWidget
*default_account_rec_checkbtn
= NULL
;
860 PrefsAccount
*ac_prefs
;
861 gboolean default_account_set
= FALSE
;
867 # define TABLEHEIGHT 7
869 # define TABLEHEIGHT 6
871 table
= gtk_table_new(TABLEHEIGHT
, 3, FALSE
);
872 gtk_container_set_border_width (GTK_CONTAINER (table
), VBOX_BORDER
);
873 gtk_table_set_row_spacings(GTK_TABLE(table
), 4);
874 gtk_table_set_col_spacings(GTK_TABLE(table
), 4);
878 no_save_warning
= prefs_folder_no_save_warning_create_widget();
879 gtk_table_attach(GTK_TABLE(table
), no_save_warning
, 0, 3,
880 rowcount
, rowcount
+ 1, GTK_FILL
, 0, 0, 0);
884 /* Apply to subfolders */
885 label
= gtk_label_new(_("Apply to\nsubfolders"));
886 gtk_misc_set_alignment(GTK_MISC(label
), 0.5, 0.5);
887 gtk_table_attach(GTK_TABLE(table
), label
, 2, 3,
888 rowcount
, rowcount
+ 1, GTK_SHRINK
, GTK_SHRINK
, 0, 0);
891 if (item_protocol(item
) != A_NNTP
) {
892 /* Request Return Receipt */
893 checkbtn_request_return_receipt
= gtk_check_button_new_with_label
894 (_("Request Return Receipt"));
895 gtk_table_attach(GTK_TABLE(table
), checkbtn_request_return_receipt
,
896 0, 2, rowcount
, rowcount
+ 1, GTK_SHRINK
| GTK_FILL
,
898 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_request_return_receipt
),
899 item
->ret_rcpt
? TRUE
: FALSE
);
901 request_return_receipt_rec_checkbtn
= gtk_check_button_new();
902 gtk_table_attach(GTK_TABLE(table
), request_return_receipt_rec_checkbtn
, 2, 3,
903 rowcount
, rowcount
+ 1, GTK_SHRINK
, GTK_SHRINK
, 0, 0);
907 /* Save Copy to Folder */
908 checkbtn_save_copy_to_folder
= gtk_check_button_new_with_label
909 (_("Save copy of outgoing messages to this folder instead of Sent"));
910 gtk_table_attach(GTK_TABLE(table
), checkbtn_save_copy_to_folder
, 0, 2,
911 rowcount
, rowcount
+ 1, GTK_SHRINK
| GTK_FILL
, GTK_FILL
, 0, 0);
912 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_save_copy_to_folder
),
913 item
->prefs
->save_copy_to_folder
? TRUE
: FALSE
);
915 save_copy_to_folder_rec_checkbtn
= gtk_check_button_new();
916 gtk_table_attach(GTK_TABLE(table
), save_copy_to_folder_rec_checkbtn
, 2, 3,
917 rowcount
, rowcount
+ 1, GTK_SHRINK
, GTK_SHRINK
, 0, 0);
922 text
= g_strconcat(_("Default "), prefs_common_translated_header_name("To:"), NULL
);
923 checkbtn_default_to
= gtk_check_button_new_with_label(text
);
924 gtk_table_attach(GTK_TABLE(table
), checkbtn_default_to
, 0, 1,
925 rowcount
, rowcount
+ 1, GTK_SHRINK
| GTK_FILL
, GTK_SHRINK
, 0, 0);
926 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_default_to
),
927 item
->prefs
->enable_default_to
);
930 entry_default_to
= gtk_entry_new();
931 gtk_table_attach(GTK_TABLE(table
), entry_default_to
, 1, 2,
932 rowcount
, rowcount
+ 1, GTK_EXPAND
| GTK_FILL
, GTK_SHRINK
, 0, 0);
933 SET_TOGGLE_SENSITIVITY(checkbtn_default_to
, entry_default_to
);
934 gtk_entry_set_text(GTK_ENTRY(entry_default_to
), SAFE_STRING(item
->prefs
->default_to
));
935 address_completion_register_entry(GTK_ENTRY(entry_default_to
),
938 default_to_rec_checkbtn
= gtk_check_button_new();
939 gtk_table_attach(GTK_TABLE(table
), default_to_rec_checkbtn
, 2, 3,
940 rowcount
, rowcount
+ 1, GTK_SHRINK
, GTK_SHRINK
, 0, 0);
944 /* Default address to reply to */
945 text
= g_strconcat(_("Default "), prefs_common_translated_header_name("To:"),
946 _(" for replies"), NULL
);
947 checkbtn_default_reply_to
= gtk_check_button_new_with_label(text
);
948 gtk_table_attach(GTK_TABLE(table
), checkbtn_default_reply_to
, 0, 1,
949 rowcount
, rowcount
+ 1, GTK_SHRINK
| GTK_FILL
, GTK_SHRINK
, 0, 0);
950 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_default_reply_to
),
951 item
->prefs
->enable_default_reply_to
);
954 entry_default_reply_to
= gtk_entry_new();
955 gtk_table_attach(GTK_TABLE(table
), entry_default_reply_to
, 1, 2,
956 rowcount
, rowcount
+ 1, GTK_EXPAND
| GTK_FILL
, GTK_SHRINK
, 0, 0);
957 SET_TOGGLE_SENSITIVITY(checkbtn_default_reply_to
, entry_default_reply_to
);
958 gtk_entry_set_text(GTK_ENTRY(entry_default_reply_to
), SAFE_STRING(item
->prefs
->default_reply_to
));
959 address_completion_register_entry(
960 GTK_ENTRY(entry_default_reply_to
), TRUE
);
962 default_reply_to_rec_checkbtn
= gtk_check_button_new();
963 gtk_table_attach(GTK_TABLE(table
), default_reply_to_rec_checkbtn
, 2, 3,
964 rowcount
, rowcount
+ 1, GTK_SHRINK
, GTK_SHRINK
, 0, 0);
969 text
= g_strconcat(_("Default "), prefs_common_translated_header_name("Cc:"), NULL
);
970 checkbtn_default_cc
= gtk_check_button_new_with_label(text
);
971 gtk_table_attach(GTK_TABLE(table
), checkbtn_default_cc
, 0, 1,
972 rowcount
, rowcount
+ 1, GTK_SHRINK
| GTK_FILL
, GTK_SHRINK
, 0, 0);
973 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_default_cc
),
974 item
->prefs
->enable_default_cc
);
977 entry_default_cc
= gtk_entry_new();
978 gtk_table_attach(GTK_TABLE(table
), entry_default_cc
, 1, 2,
979 rowcount
, rowcount
+ 1, GTK_EXPAND
| GTK_FILL
, GTK_SHRINK
, 0, 0);
980 SET_TOGGLE_SENSITIVITY(checkbtn_default_cc
, entry_default_cc
);
981 gtk_entry_set_text(GTK_ENTRY(entry_default_cc
), SAFE_STRING(item
->prefs
->default_cc
));
982 address_completion_register_entry(GTK_ENTRY(entry_default_cc
),
985 default_cc_rec_checkbtn
= gtk_check_button_new();
986 gtk_table_attach(GTK_TABLE(table
), default_cc_rec_checkbtn
, 2, 3,
987 rowcount
, rowcount
+ 1, GTK_SHRINK
, GTK_SHRINK
, 0, 0);
992 text
= g_strconcat(_("Default "), prefs_common_translated_header_name("Bcc:"), NULL
);
993 checkbtn_default_bcc
= gtk_check_button_new_with_label(text
);
994 gtk_table_attach(GTK_TABLE(table
), checkbtn_default_bcc
, 0, 1,
995 rowcount
, rowcount
+ 1, GTK_SHRINK
| GTK_FILL
, GTK_SHRINK
, 0, 0);
996 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_default_bcc
),
997 item
->prefs
->enable_default_bcc
);
1000 entry_default_bcc
= gtk_entry_new();
1001 gtk_table_attach(GTK_TABLE(table
), entry_default_bcc
, 1, 2,
1002 rowcount
, rowcount
+ 1, GTK_EXPAND
| GTK_FILL
, GTK_SHRINK
, 0, 0);
1003 SET_TOGGLE_SENSITIVITY(checkbtn_default_bcc
, entry_default_bcc
);
1004 gtk_entry_set_text(GTK_ENTRY(entry_default_bcc
), SAFE_STRING(item
->prefs
->default_bcc
));
1005 address_completion_register_entry(GTK_ENTRY(entry_default_bcc
),
1008 default_bcc_rec_checkbtn
= gtk_check_button_new();
1009 gtk_table_attach(GTK_TABLE(table
), default_bcc_rec_checkbtn
, 2, 3,
1010 rowcount
, rowcount
+ 1, GTK_SHRINK
, GTK_SHRINK
, 0, 0);
1014 /* Default Reply-to */
1015 text
= g_strconcat(_("Default "), prefs_common_translated_header_name("Reply-To:"), NULL
);
1016 checkbtn_default_replyto
= gtk_check_button_new_with_label(text
);
1017 gtk_table_attach(GTK_TABLE(table
), checkbtn_default_replyto
, 0, 1,
1018 rowcount
, rowcount
+ 1, GTK_SHRINK
| GTK_FILL
, GTK_SHRINK
, 0, 0);
1019 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_default_replyto
),
1020 item
->prefs
->enable_default_replyto
);
1023 entry_default_replyto
= gtk_entry_new();
1024 gtk_table_attach(GTK_TABLE(table
), entry_default_replyto
, 1, 2,
1025 rowcount
, rowcount
+ 1, GTK_EXPAND
| GTK_FILL
, GTK_SHRINK
, 0, 0);
1026 SET_TOGGLE_SENSITIVITY(checkbtn_default_replyto
, entry_default_replyto
);
1027 gtk_entry_set_text(GTK_ENTRY(entry_default_replyto
), SAFE_STRING(item
->prefs
->default_replyto
));
1028 address_completion_register_entry(GTK_ENTRY(entry_default_replyto
),
1031 default_replyto_rec_checkbtn
= gtk_check_button_new();
1032 gtk_table_attach(GTK_TABLE(table
), default_replyto_rec_checkbtn
, 2, 3,
1033 rowcount
, rowcount
+ 1, GTK_SHRINK
, GTK_SHRINK
, 0, 0);
1037 /* Default account */
1038 checkbtn_enable_default_account
= gtk_check_button_new_with_label(_("Default account"));
1039 gtk_table_attach(GTK_TABLE(table
), checkbtn_enable_default_account
, 0, 1,
1040 rowcount
, rowcount
+ 1, GTK_SHRINK
| GTK_FILL
, GTK_SHRINK
, 0, 0);
1041 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_default_account
),
1042 item
->prefs
->enable_default_account
);
1044 optmenu_default_account
= gtkut_sc_combobox_create(NULL
, FALSE
);
1045 gtk_table_attach(GTK_TABLE(table
), optmenu_default_account
, 1, 2,
1046 rowcount
, rowcount
+ 1, GTK_EXPAND
| GTK_FILL
, GTK_SHRINK
, 0, 0);
1047 optmenu_default_account_menu
= GTK_LIST_STORE(
1048 gtk_combo_box_get_model(GTK_COMBO_BOX(optmenu_default_account
)));
1050 account_list
= account_get_list();
1051 for (cur_ac
= account_list
; cur_ac
!= NULL
; cur_ac
= cur_ac
->next
) {
1052 ac_prefs
= (PrefsAccount
*)cur_ac
->data
;
1053 if (item
->folder
->account
&&
1054 ( (item_protocol(item
) == A_NNTP
&& ac_prefs
->protocol
!= A_NNTP
)
1055 ||(item_protocol(item
) != A_NNTP
&& ac_prefs
->protocol
== A_NNTP
)))
1058 if (item
->folder
->klass
->type
!= F_NEWS
&& ac_prefs
->protocol
== A_NNTP
)
1061 COMBOBOX_ADD_ESCAPED (optmenu_default_account_menu
,
1062 ac_prefs
->account_name
?ac_prefs
->account_name
: _("Untitled"),
1063 ac_prefs
->account_id
);
1065 /* Set combobox to current default account id */
1066 if (ac_prefs
->account_id
== item
->prefs
->default_account
) {
1067 combobox_select_by_data(GTK_COMBO_BOX(optmenu_default_account
),
1068 ac_prefs
->account_id
);
1069 default_account_set
= TRUE
;
1073 /* If nothing has been set (folder doesn't have a default account set),
1074 * pre-select global default account, since that's what actually used
1075 * anyway. We don't want nothing selected in combobox. */
1076 if( !default_account_set
)
1077 combobox_select_by_data(GTK_COMBO_BOX(optmenu_default_account
),
1078 account_get_default()->account_id
);
1080 SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_account
, optmenu_default_account
);
1082 default_account_rec_checkbtn
= gtk_check_button_new();
1083 gtk_table_attach(GTK_TABLE(table
), default_account_rec_checkbtn
, 2, 3,
1084 rowcount
, rowcount
+ 1, GTK_SHRINK
, GTK_SHRINK
, 0, 0);
1088 /* Default dictionary */
1089 checkbtn_enable_default_dictionary
= gtk_check_button_new_with_label(_("Default dictionary"));
1090 gtk_table_attach(GTK_TABLE(table
), checkbtn_enable_default_dictionary
, 0, 1,
1091 rowcount
, rowcount
+ 1, GTK_SHRINK
| GTK_FILL
, GTK_SHRINK
, 0, 0);
1092 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_default_dictionary
),
1093 item
->prefs
->enable_default_dictionary
);
1095 combo_default_dictionary
= gtkaspell_dictionary_combo_new(TRUE
);
1096 gtk_table_attach(GTK_TABLE(table
), combo_default_dictionary
, 1, 2,
1097 rowcount
, rowcount
+ 1, GTK_EXPAND
| GTK_FILL
, GTK_SHRINK
, 0, 0);
1099 dictionary
= item
->prefs
->default_dictionary
;
1100 if (dictionary
&& strrchr(dictionary
, '/')) {
1101 gchar
*tmp
= g_strdup(strrchr(dictionary
, '/')+1);
1102 g_free(item
->prefs
->default_dictionary
);
1103 item
->prefs
->default_dictionary
= tmp
;
1104 dictionary
= item
->prefs
->default_dictionary
;
1106 if (item
->prefs
->default_dictionary
&&
1107 strchr(item
->prefs
->default_dictionary
, '-')) {
1108 *(strchr(item
->prefs
->default_dictionary
, '-')) = '\0';
1111 gtkaspell_set_dictionary_menu_active_item(
1112 GTK_COMBO_BOX(combo_default_dictionary
), dictionary
);
1114 SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_dictionary
, combo_default_dictionary
);
1116 default_dictionary_rec_checkbtn
= gtk_check_button_new();
1117 gtk_table_attach(GTK_TABLE(table
), default_dictionary_rec_checkbtn
, 2, 3,
1118 rowcount
, rowcount
+ 1, GTK_SHRINK
, GTK_SHRINK
, 0, 0);
1122 /* Default dictionary */
1123 checkbtn_enable_default_alt_dictionary
= gtk_check_button_new_with_label(_("Default alternate dictionary"));
1124 gtk_table_attach(GTK_TABLE(table
), checkbtn_enable_default_alt_dictionary
, 0, 1,
1125 rowcount
, rowcount
+ 1, GTK_SHRINK
| GTK_FILL
, GTK_SHRINK
, 0, 0);
1126 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_default_alt_dictionary
),
1127 item
->prefs
->enable_default_alt_dictionary
);
1129 combo_default_alt_dictionary
= gtkaspell_dictionary_combo_new(FALSE
);
1130 gtk_table_attach(GTK_TABLE(table
), combo_default_alt_dictionary
, 1, 2,
1131 rowcount
, rowcount
+ 1, GTK_EXPAND
| GTK_FILL
, GTK_SHRINK
, 0, 0);
1133 dictionary
= item
->prefs
->default_alt_dictionary
;
1134 if (dictionary
&& strrchr(dictionary
, '/')) {
1135 gchar
*tmp
= g_strdup(strrchr(dictionary
, '/')+1);
1136 g_free(item
->prefs
->default_alt_dictionary
);
1137 item
->prefs
->default_alt_dictionary
= tmp
;
1138 dictionary
= item
->prefs
->default_alt_dictionary
;
1140 if (item
->prefs
->default_alt_dictionary
&&
1141 strchr(item
->prefs
->default_alt_dictionary
, '-')) {
1142 *(strchr(item
->prefs
->default_alt_dictionary
, '-')) = '\0';
1145 gtkaspell_set_dictionary_menu_active_item(
1146 GTK_COMBO_BOX(combo_default_alt_dictionary
), dictionary
);
1148 SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_alt_dictionary
, combo_default_alt_dictionary
);
1150 default_alt_dictionary_rec_checkbtn
= gtk_check_button_new();
1151 gtk_table_attach(GTK_TABLE(table
), default_alt_dictionary_rec_checkbtn
, 2, 3,
1152 rowcount
, rowcount
+ 1, GTK_SHRINK
, GTK_SHRINK
, 0, 0);
1157 gtk_widget_show_all(table
);
1159 page
->window
= GTK_WIDGET(window
);
1160 page
->table
= table
;
1161 page
->no_save_warning
= no_save_warning
;
1162 page
->checkbtn_request_return_receipt
= checkbtn_request_return_receipt
;
1163 page
->checkbtn_save_copy_to_folder
= checkbtn_save_copy_to_folder
;
1164 page
->checkbtn_default_to
= checkbtn_default_to
;
1165 page
->entry_default_to
= entry_default_to
;
1166 page
->checkbtn_default_reply_to
= checkbtn_default_reply_to
;
1167 page
->entry_default_reply_to
= entry_default_reply_to
;
1168 page
->checkbtn_default_cc
= checkbtn_default_cc
;
1169 page
->entry_default_cc
= entry_default_cc
;
1170 page
->checkbtn_default_bcc
= checkbtn_default_bcc
;
1171 page
->entry_default_bcc
= entry_default_bcc
;
1172 page
->checkbtn_default_replyto
= checkbtn_default_replyto
;
1173 page
->entry_default_replyto
= entry_default_replyto
;
1174 page
->checkbtn_enable_default_account
= checkbtn_enable_default_account
;
1175 page
->optmenu_default_account
= optmenu_default_account
;
1177 page
->checkbtn_enable_default_dictionary
= checkbtn_enable_default_dictionary
;
1178 page
->combo_default_dictionary
= combo_default_dictionary
;
1179 page
->checkbtn_enable_default_alt_dictionary
= checkbtn_enable_default_alt_dictionary
;
1180 page
->combo_default_alt_dictionary
= combo_default_alt_dictionary
;
1183 page
->request_return_receipt_rec_checkbtn
= request_return_receipt_rec_checkbtn
;
1184 page
->save_copy_to_folder_rec_checkbtn
= save_copy_to_folder_rec_checkbtn
;
1185 page
->default_to_rec_checkbtn
= default_to_rec_checkbtn
;
1186 page
->default_reply_to_rec_checkbtn
= default_reply_to_rec_checkbtn
;
1187 page
->default_cc_rec_checkbtn
= default_cc_rec_checkbtn
;
1188 page
->default_bcc_rec_checkbtn
= default_bcc_rec_checkbtn
;
1189 page
->default_replyto_rec_checkbtn
= default_replyto_rec_checkbtn
;
1190 page
->default_account_rec_checkbtn
= default_account_rec_checkbtn
;
1192 page
->default_dictionary_rec_checkbtn
= default_dictionary_rec_checkbtn
;
1193 page
->default_alt_dictionary_rec_checkbtn
= default_alt_dictionary_rec_checkbtn
;
1196 page
->page
.widget
= table
;
1199 static void prefs_folder_item_compose_destroy_widget_func(PrefsPage
*page_
)
1201 FolderItemComposePage
*page
= (FolderItemComposePage
*) page_
;
1203 if (page
->entry_default_to
)
1204 address_completion_unregister_entry(GTK_ENTRY(page
->entry_default_to
));
1205 if (page
->entry_default_reply_to
)
1206 address_completion_unregister_entry(GTK_ENTRY(page
->entry_default_reply_to
));
1207 if (page
->entry_default_cc
)
1208 address_completion_unregister_entry(GTK_ENTRY(page
->entry_default_cc
));
1209 if (page
->entry_default_bcc
)
1210 address_completion_unregister_entry(GTK_ENTRY(page
->entry_default_bcc
));
1211 if (page
->entry_default_replyto
)
1212 address_completion_unregister_entry(GTK_ENTRY(page
->entry_default_replyto
));
1215 /** \brief Save the prefs in page to folder.
1217 * If the folder is not the one specified in page->item, then only those properties
1218 * that have the relevant 'apply to sub folders' button checked are saved
1220 static void compose_save_folder_prefs(FolderItem
*folder
, FolderItemComposePage
*page
)
1222 FolderItemPrefs
*prefs
= folder
->prefs
;
1224 gboolean all
= FALSE
;
1226 if (folder
->path
== NULL
)
1229 if (page
->item
== folder
)
1232 cm_return_if_fail(prefs
!= NULL
);
1234 if (item_protocol(folder
) != A_NNTP
) {
1235 if (all
|| gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->request_return_receipt_rec_checkbtn
))) {
1236 prefs
->request_return_receipt
=
1237 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->checkbtn_request_return_receipt
));
1239 folder
->ret_rcpt
= prefs
->request_return_receipt
;
1242 if (all
|| gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->save_copy_to_folder_rec_checkbtn
))) {
1243 prefs
->save_copy_to_folder
=
1244 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->checkbtn_save_copy_to_folder
));
1247 if (all
|| gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->default_to_rec_checkbtn
))) {
1249 prefs
->enable_default_to
=
1250 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->checkbtn_default_to
));
1251 ASSIGN_STRING(prefs
->default_to
,
1252 gtk_editable_get_chars(GTK_EDITABLE(page
->entry_default_to
), 0, -1));
1255 if (all
|| gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->default_reply_to_rec_checkbtn
))) {
1256 prefs
->enable_default_reply_to
=
1257 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->checkbtn_default_reply_to
));
1258 ASSIGN_STRING(prefs
->default_reply_to
,
1259 gtk_editable_get_chars(GTK_EDITABLE(page
->entry_default_reply_to
), 0, -1));
1262 if (all
|| gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->default_cc_rec_checkbtn
))) {
1264 prefs
->enable_default_cc
=
1265 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->checkbtn_default_cc
));
1266 ASSIGN_STRING(prefs
->default_cc
,
1267 gtk_editable_get_chars(GTK_EDITABLE(page
->entry_default_cc
), 0, -1));
1270 if (all
|| gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->default_bcc_rec_checkbtn
))) {
1272 prefs
->enable_default_bcc
=
1273 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->checkbtn_default_bcc
));
1274 ASSIGN_STRING(prefs
->default_bcc
,
1275 gtk_editable_get_chars(GTK_EDITABLE(page
->entry_default_bcc
), 0, -1));
1278 if (all
|| gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->default_replyto_rec_checkbtn
))) {
1280 prefs
->enable_default_replyto
=
1281 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->checkbtn_default_replyto
));
1282 ASSIGN_STRING(prefs
->default_replyto
,
1283 gtk_editable_get_chars(GTK_EDITABLE(page
->entry_default_replyto
), 0, -1));
1287 prefs
->request_return_receipt
= FALSE
;
1288 prefs
->save_copy_to_folder
= FALSE
;
1289 prefs
->enable_default_to
= FALSE
;
1290 prefs
->enable_default_reply_to
= FALSE
;
1291 prefs
->enable_default_cc
= FALSE
;
1292 prefs
->enable_default_bcc
= FALSE
;
1293 prefs
->enable_default_replyto
= FALSE
;
1296 if (all
|| gtk_toggle_button_get_active(
1297 GTK_TOGGLE_BUTTON(page
->default_account_rec_checkbtn
))) {
1298 prefs
->enable_default_account
=
1299 gtk_toggle_button_get_active(
1300 GTK_TOGGLE_BUTTON(page
->checkbtn_enable_default_account
));
1301 prefs
->default_account
= combobox_get_active_data(
1302 GTK_COMBO_BOX(page
->optmenu_default_account
));
1306 if (all
|| gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->default_dictionary_rec_checkbtn
))) {
1307 prefs
->enable_default_dictionary
=
1308 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->checkbtn_enable_default_dictionary
));
1309 ASSIGN_STRING(prefs
->default_dictionary
,
1310 gtkaspell_get_dictionary_menu_active_item(
1311 GTK_COMBO_BOX(page
->combo_default_dictionary
)));
1313 if (all
|| gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->default_alt_dictionary_rec_checkbtn
))) {
1314 prefs
->enable_default_alt_dictionary
=
1315 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->checkbtn_enable_default_alt_dictionary
));
1316 ASSIGN_STRING(prefs
->default_alt_dictionary
,
1317 gtkaspell_get_dictionary_menu_active_item(
1318 GTK_COMBO_BOX(page
->combo_default_alt_dictionary
)));
1322 folder_item_prefs_save_config(folder
);
1325 static gboolean
compose_save_recurse_func(GNode
*node
, gpointer data
)
1327 FolderItem
*item
= (FolderItem
*) node
->data
;
1328 FolderItemComposePage
*page
= (FolderItemComposePage
*) data
;
1330 cm_return_val_if_fail(item
!= NULL
, TRUE
);
1331 cm_return_val_if_fail(page
!= NULL
, TRUE
);
1333 compose_save_folder_prefs(item
, page
);
1335 /* optimise by not continuing if none of the 'apply to sub folders'
1336 check boxes are selected - and optimise the checking by only doing
1338 if ((node
== page
->item
->node
) && item_protocol(item
) != A_NNTP
&&
1339 !(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->request_return_receipt_rec_checkbtn
)) ||
1340 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->save_copy_to_folder_rec_checkbtn
)) ||
1341 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->default_to_rec_checkbtn
)) ||
1342 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->default_account_rec_checkbtn
)) ||
1343 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->default_cc_rec_checkbtn
)) ||
1344 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->default_bcc_rec_checkbtn
)) ||
1345 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->default_replyto_rec_checkbtn
)) ||
1347 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->default_dictionary_rec_checkbtn
)) ||
1348 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->default_alt_dictionary_rec_checkbtn
)) ||
1350 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->default_reply_to_rec_checkbtn
))
1353 else if ((node
== page
->item
->node
) && item_protocol(item
) == A_NNTP
&&
1354 !(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->default_account_rec_checkbtn
))
1356 || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->default_dictionary_rec_checkbtn
))
1357 || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->default_alt_dictionary_rec_checkbtn
))
1365 static void prefs_folder_item_compose_save_func(PrefsPage
*page_
)
1367 FolderItemComposePage
*page
= (FolderItemComposePage
*) page_
;
1369 g_node_traverse(page
->item
->node
, G_PRE_ORDER
, G_TRAVERSE_ALL
,
1370 -1, compose_save_recurse_func
, page
);
1374 static void prefs_folder_item_templates_create_widget_func(PrefsPage
* page_
,
1378 FolderItemTemplatesPage
*page
= (FolderItemTemplatesPage
*) page_
;
1379 FolderItem
*item
= (FolderItem
*) data
;
1381 GtkWidget
*notebook
;
1383 GtkWidget
*page_vbox
;
1384 GtkWidget
*no_save_warning
;
1385 GtkWidget
*new_msg_format_rec_checkbtn
;
1386 GtkWidget
*reply_format_rec_checkbtn
;
1387 GtkWidget
*forward_format_rec_checkbtn
;
1389 GtkWidget
*vbox_format
;
1393 page_vbox
= gtk_vbox_new (FALSE
, 0);
1394 gtk_container_set_border_width (GTK_CONTAINER (page_vbox
), VBOX_BORDER
);
1395 gtk_widget_show (page_vbox
);
1398 no_save_warning
= prefs_folder_no_save_warning_create_widget();
1399 gtk_box_pack_start(GTK_BOX(page_vbox
),
1400 no_save_warning
, FALSE
, FALSE
, 0);
1404 notebook
= gtk_notebook_new();
1405 gtk_widget_show(notebook
);
1406 gtk_box_pack_start(GTK_BOX(page_vbox
), notebook
, TRUE
, TRUE
, 4);
1408 /* compose format */
1409 vbox
= gtk_vbox_new (FALSE
, VSPACING
);
1410 gtk_widget_show (vbox
);
1411 gtk_container_set_border_width (GTK_CONTAINER (vbox
), VBOX_BORDER
);
1413 quotefmt_create_new_msg_fmt_widgets(
1416 &page
->checkbtn_compose_with_format
,
1417 &page
->compose_override_from_format
,
1418 &page
->compose_subject_format
,
1419 &page
->compose_body_format
,
1421 address_completion_register_entry(GTK_ENTRY(page
->compose_override_from_format
),
1424 vbox_format
= gtk_widget_get_parent(
1425 gtk_widget_get_parent(page
->compose_body_format
));
1427 hbox
= gtk_hbox_new (FALSE
, 0);
1428 gtk_box_pack_end (GTK_BOX(vbox_format
), hbox
, FALSE
, FALSE
, 0);
1429 quotefmt_add_info_button(window
, hbox
);
1431 new_msg_format_rec_checkbtn
= gtk_check_button_new_with_label(
1432 _("Apply to subfolders"));
1433 gtk_box_pack_end (GTK_BOX(hbox
), new_msg_format_rec_checkbtn
, FALSE
, FALSE
, 0);
1434 gtk_notebook_append_page(GTK_NOTEBOOK(notebook
), vbox
, gtk_label_new(_("Compose")));
1437 vbox
= gtk_vbox_new (FALSE
, VSPACING
);
1438 gtk_widget_show (vbox
);
1439 gtk_container_set_border_width (GTK_CONTAINER (vbox
), VBOX_BORDER
);
1441 quotefmt_create_reply_fmt_widgets(
1444 &page
->checkbtn_reply_with_format
,
1445 &page
->reply_override_from_format
,
1446 &page
->reply_quotemark
,
1447 &page
->reply_body_format
,
1449 address_completion_register_entry(GTK_ENTRY(page
->reply_override_from_format
),
1452 vbox_format
= gtk_widget_get_parent(
1453 gtk_widget_get_parent(page
->reply_body_format
));
1455 hbox
= gtk_hbox_new (FALSE
, 0);
1456 gtk_box_pack_end (GTK_BOX(vbox_format
), hbox
, FALSE
, FALSE
, 0);
1457 quotefmt_add_info_button(window
, hbox
);
1459 reply_format_rec_checkbtn
= gtk_check_button_new_with_label(
1460 _("Apply to subfolders"));
1461 gtk_box_pack_end (GTK_BOX(hbox
), reply_format_rec_checkbtn
, FALSE
, FALSE
, 0);
1462 gtk_notebook_append_page(GTK_NOTEBOOK(notebook
), vbox
, gtk_label_new(_("Reply")));
1464 /* forward format */
1465 vbox
= gtk_vbox_new (FALSE
, VSPACING
);
1466 gtk_widget_show (vbox
);
1467 gtk_container_set_border_width (GTK_CONTAINER (vbox
), VBOX_BORDER
);
1469 quotefmt_create_forward_fmt_widgets(
1472 &page
->checkbtn_forward_with_format
,
1473 &page
->forward_override_from_format
,
1474 &page
->forward_quotemark
,
1475 &page
->forward_body_format
,
1477 address_completion_register_entry(GTK_ENTRY(page
->forward_override_from_format
),
1480 vbox_format
= gtk_widget_get_parent(
1481 gtk_widget_get_parent(page
->forward_body_format
));
1483 hbox
= gtk_hbox_new (FALSE
, 0);
1484 gtk_box_pack_end (GTK_BOX(vbox_format
), hbox
, FALSE
, FALSE
, 0);
1485 quotefmt_add_info_button(window
, hbox
);
1487 forward_format_rec_checkbtn
= gtk_check_button_new_with_label(
1488 _("Apply to subfolders"));
1489 gtk_box_pack_end (GTK_BOX(hbox
), forward_format_rec_checkbtn
, FALSE
, FALSE
, 0);
1490 gtk_notebook_append_page(GTK_NOTEBOOK(notebook
), vbox
, gtk_label_new(_("Forward")));
1492 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(page
->checkbtn_compose_with_format
),
1493 item
->prefs
->compose_with_format
);
1494 pref_set_entry_from_pref(GTK_ENTRY(page
->compose_override_from_format
),
1495 item
->prefs
->compose_override_from_format
);
1496 pref_set_entry_from_pref(GTK_ENTRY(page
->compose_subject_format
),
1497 item
->prefs
->compose_subject_format
);
1498 pref_set_textview_from_pref(GTK_TEXT_VIEW(page
->compose_body_format
),
1499 item
->prefs
->compose_body_format
);
1501 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(page
->checkbtn_reply_with_format
),
1502 item
->prefs
->reply_with_format
);
1503 pref_set_entry_from_pref(GTK_ENTRY(page
->reply_quotemark
),
1504 item
->prefs
->reply_quotemark
);
1505 pref_set_entry_from_pref(GTK_ENTRY(page
->reply_override_from_format
),
1506 item
->prefs
->reply_override_from_format
);
1507 pref_set_textview_from_pref(GTK_TEXT_VIEW(page
->reply_body_format
),
1508 item
->prefs
->reply_body_format
);
1510 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(page
->checkbtn_forward_with_format
),
1511 item
->prefs
->forward_with_format
);
1512 pref_set_entry_from_pref(GTK_ENTRY(page
->forward_quotemark
),
1513 item
->prefs
->forward_quotemark
);
1514 pref_set_entry_from_pref(GTK_ENTRY(page
->forward_override_from_format
),
1515 item
->prefs
->forward_override_from_format
);
1516 pref_set_textview_from_pref(GTK_TEXT_VIEW(page
->forward_body_format
),
1517 item
->prefs
->forward_body_format
);
1519 gtk_widget_show_all(page_vbox
);
1521 page
->window
= GTK_WIDGET(window
);
1523 page
->new_msg_format_rec_checkbtn
= new_msg_format_rec_checkbtn
;
1524 page
->reply_format_rec_checkbtn
= reply_format_rec_checkbtn
;
1525 page
->forward_format_rec_checkbtn
= forward_format_rec_checkbtn
;
1527 page
->page
.widget
= page_vbox
;
1530 static void prefs_folder_item_templates_destroy_widget_func(PrefsPage
*page_
)
1532 FolderItemTemplatesPage
*page
= (FolderItemTemplatesPage
*) page_
;
1534 if (page
->compose_override_from_format
)
1535 address_completion_unregister_entry(GTK_ENTRY(page
->compose_override_from_format
));
1536 if (page
->reply_override_from_format
)
1537 address_completion_unregister_entry(GTK_ENTRY(page
->reply_override_from_format
));
1538 if (page
->forward_override_from_format
)
1539 address_completion_unregister_entry(GTK_ENTRY(page
->forward_override_from_format
));
1542 /** \brief Save the prefs in page to folder.
1544 * If the folder is not the one specified in page->item, then only those properties
1545 * that have the relevant 'apply to sub folders' button checked are saved
1547 static void templates_save_folder_prefs(FolderItem
*folder
, FolderItemTemplatesPage
*page
)
1549 FolderItemPrefs
*prefs
= folder
->prefs
;
1550 gboolean all
= FALSE
;
1552 if (folder
->path
== NULL
)
1555 if (page
->item
== folder
)
1558 cm_return_if_fail(prefs
!= NULL
);
1560 /* save and check formats */
1562 if (all
|| gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->new_msg_format_rec_checkbtn
))) {
1564 prefs
->compose_with_format
=
1565 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->checkbtn_compose_with_format
));
1566 prefs
->compose_override_from_format
= pref_get_pref_from_entry(
1567 GTK_ENTRY(page
->compose_override_from_format
));
1568 prefs
->compose_subject_format
= pref_get_pref_from_entry(
1569 GTK_ENTRY(page
->compose_subject_format
));
1570 prefs
->compose_body_format
= pref_get_pref_from_textview(
1571 GTK_TEXT_VIEW(page
->compose_body_format
));
1572 quotefmt_check_new_msg_formats(prefs
->compose_with_format
,
1573 prefs
->compose_override_from_format
,
1574 prefs
->compose_subject_format
,
1575 prefs
->compose_body_format
);
1578 if (all
|| gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->reply_format_rec_checkbtn
))) {
1579 prefs
->reply_with_format
=
1580 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->checkbtn_reply_with_format
));
1581 prefs
->reply_quotemark
= gtk_editable_get_chars(
1582 GTK_EDITABLE(page
->reply_quotemark
), 0, -1);
1583 prefs
->reply_override_from_format
= pref_get_pref_from_entry(
1584 GTK_ENTRY(page
->reply_override_from_format
));
1585 prefs
->reply_body_format
= pref_get_pref_from_textview(
1586 GTK_TEXT_VIEW(page
->reply_body_format
));
1587 quotefmt_check_reply_formats(prefs
->reply_with_format
,
1588 prefs
->reply_override_from_format
,
1589 prefs
->reply_quotemark
,
1590 prefs
->reply_body_format
);
1593 if (all
|| gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->forward_format_rec_checkbtn
))) {
1594 prefs
->forward_with_format
=
1595 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->checkbtn_forward_with_format
));
1596 prefs
->forward_quotemark
= gtk_editable_get_chars(
1597 GTK_EDITABLE(page
->forward_quotemark
), 0, -1);
1598 prefs
->forward_override_from_format
= pref_get_pref_from_entry(
1599 GTK_ENTRY(page
->forward_override_from_format
));
1600 prefs
->forward_body_format
= pref_get_pref_from_textview(
1601 GTK_TEXT_VIEW(page
->forward_body_format
));
1602 quotefmt_check_forward_formats(prefs
->forward_with_format
,
1603 prefs
->forward_override_from_format
,
1604 prefs
->forward_quotemark
,
1605 prefs
->forward_body_format
);
1608 folder_item_prefs_save_config(folder
);
1611 static gboolean
templates_save_recurse_func(GNode
*node
, gpointer data
)
1613 FolderItem
*item
= (FolderItem
*) node
->data
;
1614 FolderItemTemplatesPage
*page
= (FolderItemTemplatesPage
*) data
;
1616 cm_return_val_if_fail(item
!= NULL
, TRUE
);
1617 cm_return_val_if_fail(page
!= NULL
, TRUE
);
1619 templates_save_folder_prefs(item
, page
);
1621 /* optimise by not continuing if none of the 'apply to sub folders'
1622 check boxes are selected - and optimise the checking by only doing
1624 if ((node
== page
->item
->node
) &&
1625 !(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->new_msg_format_rec_checkbtn
)) ||
1626 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->reply_format_rec_checkbtn
)) ||
1627 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->forward_format_rec_checkbtn
))))
1635 static void prefs_folder_item_templates_save_func(PrefsPage
*page_
)
1637 FolderItemTemplatesPage
*page
= (FolderItemTemplatesPage
*) page_
;
1639 g_node_traverse(page
->item
->node
, G_PRE_ORDER
, G_TRAVERSE_ALL
,
1640 -1, templates_save_recurse_func
, page
);
1644 static gint
prefs_folder_item_chmod_mode(gchar
*folder_chmod
)
1650 newmode
= strtol(folder_chmod
, &tmp
, 8);
1651 if (!(*(folder_chmod
) && !(*tmp
)))
1658 static void folder_color_set_dialog(GtkWidget
*widget
, gpointer data
)
1660 FolderItemGeneralPage
*page
= (FolderItemGeneralPage
*) data
;
1663 rgbcolor
= colorsel_select_color_rgb(_("Pick color for folder"),
1664 page
->folder_color
);
1665 gtkut_set_widget_bgcolor_rgb(page
->folder_color_btn
, rgbcolor
);
1666 page
->folder_color
= rgbcolor
;
1669 static void clean_cache_cb(GtkWidget
*widget
, gpointer data
)
1671 FolderItemGeneralPage
*page
= (FolderItemGeneralPage
*) data
;
1672 FolderItem
*item
= page
->item
;
1673 gboolean was_open
= FALSE
;
1674 FolderView
*folderview
= NULL
;
1676 if (alertpanel_full(_("Discard cache"),
1677 _("Do you really want to discard the local cached "
1678 "data for this folder?"),
1679 GTK_STOCK_CANCEL
, g_strconcat("+", _("Discard"), NULL
),
1680 NULL
, FALSE
, NULL
, ALERT_WARNING
, G_ALERTDEFAULT
)
1681 != G_ALERTALTERNATE
)
1684 if (mainwindow_get_mainwindow())
1685 folderview
= mainwindow_get_mainwindow()->folderview
;
1687 if (folderview
&& item
->opened
) {
1688 folderview_close_opened(folderview
, FALSE
);
1691 folder_item_discard_cache(item
);
1693 folderview_select(folderview
,item
);
1696 static regex_t
*summary_compile_simplify_regexp(gchar
*simplify_subject_regexp
)
1699 gchar buf
[BUFFSIZE
];
1700 regex_t
*preg
= NULL
;
1702 preg
= g_new0(regex_t
, 1);
1704 err
= string_match_precompile(simplify_subject_regexp
,
1705 preg
, REG_EXTENDED
);
1707 regerror(err
, preg
, buf
, BUFFSIZE
);
1715 static void folder_regexp_test_cb(GtkWidget
*widget
, gpointer data
)
1717 #if !GTK_CHECK_VERSION(3, 0, 0)
1718 static GdkColor red
;
1719 static gboolean colors_initialised
= FALSE
;
1721 static GdkColor red
= { (guint32
)0, (guint16
)0xff, (guint16
)0x70, (guint16
)0x70 };
1723 static gchar buf
[BUFFSIZE
];
1724 FolderItemGeneralPage
*page
= (FolderItemGeneralPage
*)data
;
1725 gchar
*test_string
, *regexp
;
1728 regexp
= g_strdup(gtk_entry_get_text(GTK_ENTRY(page
->entry_simplify_subject
)));
1729 test_string
= g_strdup(gtk_entry_get_text(GTK_ENTRY(page
->entry_regexp_test_string
)));
1731 if (!regexp
|| !regexp
[0]) {
1732 gtk_widget_modify_base(page
->entry_simplify_subject
,
1733 GTK_STATE_NORMAL
, NULL
);
1735 gtk_entry_set_text(GTK_ENTRY(page
->entry_regexp_test_result
), test_string
);
1737 g_free(test_string
);
1742 if (!test_string
|| !test_string
[0]) {
1743 g_free(test_string
);
1748 #if !GTK_CHECK_VERSION(3, 0, 0)
1749 if (!colors_initialised
) {
1750 gdk_color_parse("#ff7070", &red
);
1751 colors_initialised
= gdk_colormap_alloc_color(
1752 gdk_colormap_get_system(), &red
, FALSE
, TRUE
);
1756 preg
= summary_compile_simplify_regexp(regexp
);
1757 #if !GTK_CHECK_VERSION(3, 0, 0)
1758 if (colors_initialised
)
1759 gtk_widget_modify_base(page
->entry_simplify_subject
,
1760 GTK_STATE_NORMAL
, preg
? NULL
: &red
);
1764 string_remove_match(buf
, BUFFSIZE
, test_string
, preg
);
1766 gtk_entry_set_text(GTK_ENTRY(page
->entry_regexp_test_result
), buf
);
1772 g_free(test_string
);
1776 static gchar
*folder_regexp_get_subject_example(void)
1778 MsgInfo
*msginfo_selected
;
1779 SummaryView
*summaryview
= NULL
;
1781 if (!mainwindow_get_mainwindow())
1783 summaryview
= mainwindow_get_mainwindow()->summaryview
;
1785 msginfo_selected
= summary_get_selected_msg(summaryview
);
1786 return msginfo_selected
? g_strdup(msginfo_selected
->subject
) : NULL
;
1789 static void folder_regexp_set_subject_example_cb(GtkWidget
*widget
, gpointer data
)
1791 FolderItemGeneralPage
*page
= (FolderItemGeneralPage
*)data
;
1793 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->checkbtn_simplify_subject
))) {
1794 gchar
*subject
= folder_regexp_get_subject_example();
1796 gtk_entry_set_text(GTK_ENTRY(page
->entry_regexp_test_string
), subject
);
1802 static void register_general_page()
1804 static gchar
*pfi_general_path
[2];
1805 static FolderItemGeneralPage folder_item_general_page
;
1807 pfi_general_path
[0] = _("General");
1808 pfi_general_path
[1] = NULL
;
1810 folder_item_general_page
.page
.path
= pfi_general_path
;
1811 folder_item_general_page
.page
.create_widget
= prefs_folder_item_general_create_widget_func
;
1812 folder_item_general_page
.page
.destroy_widget
= prefs_folder_item_general_destroy_widget_func
;
1813 folder_item_general_page
.page
.save_page
= prefs_folder_item_general_save_func
;
1815 prefs_folder_item_register_page((PrefsPage
*) &folder_item_general_page
, NULL
);
1819 static void register_compose_page(void)
1821 static gchar
*pfi_compose_path
[2];
1822 static FolderItemComposePage folder_item_compose_page
;
1824 pfi_compose_path
[0] = _("Compose");
1825 pfi_compose_path
[1] = NULL
;
1827 folder_item_compose_page
.page
.path
= pfi_compose_path
;
1828 folder_item_compose_page
.page
.create_widget
= prefs_folder_item_compose_create_widget_func
;
1829 folder_item_compose_page
.page
.destroy_widget
= prefs_folder_item_compose_destroy_widget_func
;
1830 folder_item_compose_page
.page
.save_page
= prefs_folder_item_compose_save_func
;
1832 prefs_folder_item_register_page((PrefsPage
*) &folder_item_compose_page
, NULL
);
1835 static void register_templates_page(void)
1837 static gchar
*pfi_templates_path
[2];
1838 static FolderItemTemplatesPage folder_item_templates_page
;
1840 pfi_templates_path
[0] = _("Templates");
1841 pfi_templates_path
[1] = NULL
;
1843 folder_item_templates_page
.page
.path
= pfi_templates_path
;
1844 folder_item_templates_page
.page
.create_widget
= prefs_folder_item_templates_create_widget_func
;
1845 folder_item_templates_page
.page
.destroy_widget
= prefs_folder_item_templates_destroy_widget_func
;
1846 folder_item_templates_page
.page
.save_page
= prefs_folder_item_templates_save_func
;
1848 prefs_folder_item_register_page((PrefsPage
*) &folder_item_templates_page
, NULL
);
1851 static GSList
*prefs_pages
= NULL
;
1853 static void prefs_folder_item_address_completion_start(PrefsWindow
*window
)
1855 address_completion_start(window
->window
);
1858 static void prefs_folder_item_address_completion_end(PrefsWindow
*window
)
1860 address_completion_end(window
->window
);
1863 void prefs_folder_item_open(FolderItem
*item
)
1868 if (prefs_pages
== NULL
) {
1869 register_general_page();
1870 register_compose_page();
1871 register_templates_page();
1875 id
= folder_item_get_identifier (item
);
1878 id
= g_strdup(item
->name
);
1882 pages
= g_slist_concat(
1883 g_slist_copy(prefs_pages
),
1884 g_slist_copy(item
->folder
->klass
->prefs_pages
));
1886 title
= g_strdup_printf (_("Properties for folder %s"), id
);
1888 prefswindow_open(title
, pages
, item
,
1889 &prefs_common
.folderitemwin_width
, &prefs_common
.folderitemwin_height
,
1890 prefs_folder_item_address_completion_start
,
1892 prefs_folder_item_address_completion_end
);
1894 g_slist_free(pages
);
1898 void prefs_folder_item_register_page(PrefsPage
*page
, FolderClass
*klass
)
1901 klass
->prefs_pages
= g_slist_append(klass
->prefs_pages
, page
);
1903 prefs_pages
= g_slist_append(prefs_pages
, page
);
1906 void prefs_folder_item_unregister_page(PrefsPage
*page
, FolderClass
*klass
)
1909 klass
->prefs_pages
= g_slist_remove(klass
->prefs_pages
, page
);
1911 prefs_pages
= g_slist_remove(prefs_pages
, page
);