1 /*
2 * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2016 Hiroyuki Yamamoto and the Claws Mail team
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 3 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, see <http://www.gnu.org/licenses/>.
17 */
18
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) */
22
23 #ifdef HAVE_CONFIG_H
24 # include "config.h"
25 #include "claws-features.h"
26 #endif
27
28 #include "defs.h"
29
30 #include <glib.h>
31 #include <glib/gi18n.h>
32 #include "folder.h"
33 #include "alertpanel.h"
34 #include "prefs_folder_item.h"
35 #include "folderview.h"
36 #include "folder.h"
37 #include "summaryview.h"
38 #include "menu.h"
39 #include "account.h"
40 #include "prefs_gtk.h"
41 #include "manage_window.h"
42 #include "utils.h"
43 #include "addr_compl.h"
44 #include "prefs_common.h"
45 #include "gtkutils.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"
51 #include "combobox.h"
52 #include "stock_pixmap.h"
53
54 #if USE_ENCHANT
55 #include "gtkaspell.h"
56 #endif
57
58 #define ASSIGN_STRING(string, value) \
59 { \
60 g_free(string); \
61 string = (value); \
62 }
63
64 typedef struct _FolderItemGeneralPage FolderItemGeneralPage;
65 typedef struct _FolderItemComposePage FolderItemComposePage;
66 typedef struct _FolderItemTemplatesPage FolderItemTemplatesPage;
67 static gboolean can_save = TRUE;
68
69 struct _FolderItemGeneralPage
70 {
71 PrefsPage page;
72
73 FolderItem *item;
74
75 GtkWidget *table;
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;
94
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;
104
105 gint folder_color;
106 };
107
108 struct _FolderItemComposePage
109 {
110 PrefsPage page;
111
112 FolderItem *item;
113
114 GtkWidget *window;
115 GtkWidget *table;
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;
131 #if USE_ENCHANT
132 GtkWidget *checkbtn_enable_default_dictionary;
133 GtkWidget *checkbtn_enable_default_alt_dictionary;
134 GtkWidget *combo_default_dictionary;
135 GtkWidget *combo_default_alt_dictionary;
136 #endif
137 GtkWidget *always_sign;
138 GtkWidget *always_encrypt;
139
140 /* apply to sub folders */
141 GtkWidget *request_return_receipt_rec_checkbtn;
142 GtkWidget *save_copy_to_folder_rec_checkbtn;
143 GtkWidget *default_to_rec_checkbtn;
144 GtkWidget *default_reply_to_rec_checkbtn;
145 GtkWidget *default_cc_rec_checkbtn;
146 GtkWidget *default_bcc_rec_checkbtn;
147 GtkWidget *default_replyto_rec_checkbtn;
148 GtkWidget *default_account_rec_checkbtn;
149 #if USE_ENCHANT
150 GtkWidget *default_dictionary_rec_checkbtn;
151 GtkWidget *default_alt_dictionary_rec_checkbtn;
152 #endif
153 GtkWidget *always_sign_rec_checkbtn;
154 GtkWidget *always_encrypt_rec_checkbtn;
155 };
156
157 struct _FolderItemTemplatesPage
158 {
159 PrefsPage page;
160
161 FolderItem *item;
162
163 GtkWidget *window;
164 GtkWidget *table;
165 GtkWidget *checkbtn_compose_with_format;
166 GtkWidget *compose_override_from_format;
167 GtkWidget *compose_subject_format;
168 GtkWidget *compose_body_format;
169 GtkWidget *checkbtn_reply_with_format;
170 GtkWidget *reply_quotemark;
171 GtkWidget *reply_override_from_format;
172 GtkWidget *reply_body_format;
173 GtkWidget *checkbtn_forward_with_format;
174 GtkWidget *forward_quotemark;
175 GtkWidget *forward_override_from_format;
176 GtkWidget *forward_body_format;
177
178 /* apply to sub folders */
179 GtkWidget *new_msg_format_rec_checkbtn;
180 GtkWidget *reply_format_rec_checkbtn;
181 GtkWidget *forward_format_rec_checkbtn;
182 };
183
184
185 static void general_save_folder_prefs(FolderItem *folder, FolderItemGeneralPage *page);
186 static void compose_save_folder_prefs(FolderItem *folder, FolderItemComposePage *page);
187 static void templates_save_folder_prefs(FolderItem *folder, FolderItemTemplatesPage *page);
188
189 static gboolean general_save_recurse_func(GNode *node, gpointer data);
190 static gboolean compose_save_recurse_func(GNode *node, gpointer data);
191 static gboolean templates_save_recurse_func(GNode *node, gpointer data);
192
193 static gint prefs_folder_item_chmod_mode (gchar *folder_chmod);
194
195 static void folder_color_set_dialog(GtkWidget *widget, gpointer data);
196 static void clean_cache_cb(GtkWidget *widget, gpointer data);
197 static void folder_regexp_test_cb(GtkWidget *widget, gpointer data);
198 static void folder_regexp_set_subject_example_cb(GtkWidget *widget, gpointer data);
199
200 #define SAFE_STRING(str) \
201 (str) ? (str) : ""
202
prefs_folder_no_save_warning_create_widget()203 static GtkWidget *prefs_folder_no_save_warning_create_widget() {
204 GtkWidget *hbox;
205 GtkWidget *icon;
206 GtkWidget *label;
207
208 hbox = gtk_hbox_new(FALSE, 0);
209
210 icon = stock_pixmap_widget(STOCK_PIXMAP_NOTICE_WARN);
211 gtk_box_pack_start(GTK_BOX(hbox), icon, FALSE, FALSE, 8);
212
213 label = gtk_label_new(g_strconcat("<i>",
214 _("These preferences will not be saved as this folder "
215 "is a top-level folder.\nHowever, you can set them for the "
216 "whole mailbox tree by using \"Apply to subfolders\"."),
217 "</i>", NULL));
218 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
219 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
220 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
221
222 return hbox;
223 }
224
prefs_folder_item_general_create_widget_func(PrefsPage * page_,GtkWindow * window,gpointer data)225 static void prefs_folder_item_general_create_widget_func(PrefsPage * page_,
226 GtkWindow * window,
227 gpointer data)
228 {
229 FolderItemGeneralPage *page = (FolderItemGeneralPage *) page_;
230 FolderItem *item = (FolderItem *) data;
231 guint rowcount;
232
233 GtkWidget *table;
234 GtkWidget *hbox, *hbox2, *hbox_spc;
235 GtkWidget *label;
236
237 GtkListStore *folder_type_menu;
238 GtkWidget *folder_type;
239 GtkTreeIter iter;
240 GtkWidget *dummy_checkbtn, *clean_cache_btn;
241 SpecialFolderItemType type;
242 GtkWidget *no_save_warning = NULL;
243
244 GtkWidget *checkbtn_simplify_subject;
245 GtkWidget *entry_simplify_subject;
246 GtkWidget *label_regexp_test;
247 GtkWidget *entry_regexp_test_string;
248 GtkWidget *label_regexp_result;
249 GtkWidget *entry_regexp_test_result;
250
251 GtkWidget *checkbtn_folder_chmod;
252 GtkWidget *entry_folder_chmod;
253 GtkWidget *folder_color;
254 GtkWidget *folder_color_btn;
255 GtkWidget *checkbtn_enable_processing;
256 GtkWidget *checkbtn_enable_processing_when_opening;
257 GtkWidget *checkbtn_newmailcheck;
258 GtkWidget *checkbtn_offlinesync;
259 GtkWidget *label_offlinesync;
260 GtkWidget *entry_offlinesync;
261 GtkWidget *label_end_offlinesync;
262 GtkWidget *checkbtn_remove_old_offlinesync;
263 GtkWidget *promote_html_part;
264 GtkListStore *promote_html_part_menu;
265
266 GtkWidget *simplify_subject_rec_checkbtn;
267
268 GtkWidget *folder_chmod_rec_checkbtn;
269 GtkWidget *folder_color_rec_checkbtn;
270 GtkWidget *enable_processing_rec_checkbtn;
271 GtkWidget *enable_processing_when_opening_rec_checkbtn;
272 GtkWidget *newmailcheck_rec_checkbtn;
273 GtkWidget *offlinesync_rec_checkbtn;
274 GtkWidget *promote_html_part_rec_checkbtn;
275
276 page->item = item;
277
278 /* Table */
279 table = gtk_table_new(12, 3, FALSE);
280 gtk_container_set_border_width (GTK_CONTAINER (table), VBOX_BORDER);
281 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
282 gtk_table_set_col_spacings(GTK_TABLE(table), 4);
283 rowcount = 0;
284
285 if (!can_save) {
286 no_save_warning = prefs_folder_no_save_warning_create_widget();
287 gtk_table_attach(GTK_TABLE(table), no_save_warning, 0, 3,
288 rowcount, rowcount + 1, GTK_FILL, 0, 0, 0);
289 rowcount++;
290 }
291
292 /* Apply to subfolders */
293 label = gtk_label_new(_("Apply to\nsubfolders"));
294 gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.5);
295 gtk_table_attach(GTK_TABLE(table), label, 2, 3,
296 rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
297 rowcount++;
298
299 /* folder_type */
300 folder_type = gtkut_sc_combobox_create(NULL, FALSE);
301 gtk_widget_show (folder_type);
302
303 type = F_NORMAL;
304 if (item->stype == F_INBOX)
305 type = F_INBOX;
306 else if (folder_has_parent_of_type(item, F_OUTBOX))
307 type = F_OUTBOX;
308 else if (folder_has_parent_of_type(item, F_DRAFT))
309 type = F_DRAFT;
310 else if (folder_has_parent_of_type(item, F_QUEUE))
311 type = F_QUEUE;
312 else if (folder_has_parent_of_type(item, F_TRASH))
313 type = F_TRASH;
314
315 folder_type_menu = GTK_LIST_STORE(gtk_combo_box_get_model(
316 GTK_COMBO_BOX(folder_type)));
317
318 COMBOBOX_ADD (folder_type_menu, _("Normal"), F_NORMAL);
319 COMBOBOX_ADD (folder_type_menu, _("Inbox"), F_INBOX);
320 COMBOBOX_ADD (folder_type_menu, _("Outbox"), F_OUTBOX);
321 COMBOBOX_ADD (folder_type_menu, _("Drafts"), F_DRAFT);
322 COMBOBOX_ADD (folder_type_menu, _("Queue"), F_QUEUE);
323 COMBOBOX_ADD (folder_type_menu, _("Trash"), F_TRASH);
324
325 combobox_select_by_data(GTK_COMBO_BOX(folder_type), type);
326
327 dummy_checkbtn = gtk_check_button_new();
328 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dummy_checkbtn), type != F_INBOX);
329 gtk_widget_set_sensitive(dummy_checkbtn, FALSE);
330
331 if (type == item->stype && type == F_NORMAL)
332 gtk_widget_set_sensitive(folder_type, TRUE);
333 else
334 gtk_widget_set_sensitive(folder_type, FALSE);
335
336 label = gtk_label_new(_("Folder type"));
337 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
338 gtk_table_attach(GTK_TABLE(table), label, 0, 1,
339 rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0);
340 gtk_table_attach(GTK_TABLE(table), folder_type, 1, 2,
341 rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0);
342 gtk_table_attach(GTK_TABLE(table), dummy_checkbtn, 2, 3,
343 rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
344
345 rowcount++;
346
347 /* Simplify Subject */
348 checkbtn_simplify_subject = gtk_check_button_new_with_label(_("Simplify Subject RegExp"));
349 gtk_table_attach(GTK_TABLE(table), checkbtn_simplify_subject, 0, 1,
350 rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0);
351 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_simplify_subject),
352 item->prefs->enable_simplify_subject);
353
354 g_signal_connect(G_OBJECT(checkbtn_simplify_subject), "toggled",
355 G_CALLBACK(folder_regexp_set_subject_example_cb), page);
356
357 entry_simplify_subject = gtk_entry_new();
358 gtk_table_attach(GTK_TABLE(table), entry_simplify_subject, 1, 2,
359 rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
360 SET_TOGGLE_SENSITIVITY(checkbtn_simplify_subject, entry_simplify_subject);
361 gtk_entry_set_text(GTK_ENTRY(entry_simplify_subject),
362 SAFE_STRING(item->prefs->simplify_subject_regexp));
363
364 g_signal_connect(G_OBJECT(entry_simplify_subject), "changed",
365 G_CALLBACK(folder_regexp_test_cb), page);
366
367 simplify_subject_rec_checkbtn = gtk_check_button_new();
368 gtk_table_attach(GTK_TABLE(table), simplify_subject_rec_checkbtn, 2, 3,
369 rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
370
371 rowcount++;
372
373 /* Test string */
374 label_regexp_test = gtk_label_new(_("Test string"));
375 gtk_misc_set_alignment(GTK_MISC(label_regexp_test), 1, 0.5);
376 gtk_table_attach(GTK_TABLE(table), label_regexp_test, 0, 1,
377 rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0);
378 SET_TOGGLE_SENSITIVITY(checkbtn_simplify_subject, label_regexp_test);
379
380 entry_regexp_test_string = gtk_entry_new();
381 gtk_table_attach(GTK_TABLE(table), entry_regexp_test_string, 1, 2,
382 rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
383 SET_TOGGLE_SENSITIVITY(checkbtn_simplify_subject, entry_regexp_test_string);
384
385 g_signal_connect(G_OBJECT(entry_regexp_test_string), "changed",
386 G_CALLBACK(folder_regexp_test_cb), page);
387
388 rowcount++;
389
390 /* Test result */
391 label_regexp_result = gtk_label_new(_("Result"));
392 gtk_misc_set_alignment(GTK_MISC(label_regexp_result), 1, 0.5);
393 gtk_table_attach(GTK_TABLE(table), label_regexp_result, 0, 1,
394 rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0);
395 SET_TOGGLE_SENSITIVITY(checkbtn_simplify_subject, label_regexp_result);
396
397 entry_regexp_test_result = gtk_entry_new();
398 gtk_table_attach(GTK_TABLE(table), entry_regexp_test_result, 1, 2,
399 rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
400 SET_TOGGLE_SENSITIVITY(checkbtn_simplify_subject, entry_regexp_test_result);
401 gtk_editable_set_editable(GTK_EDITABLE(entry_regexp_test_result), FALSE);
402
403 rowcount++;
404
405 /* Folder chmod */
406 checkbtn_folder_chmod = gtk_check_button_new_with_label(_("Folder chmod"));
407 gtk_table_attach(GTK_TABLE(table), checkbtn_folder_chmod, 0, 1,
408 rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0);
409
410 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_folder_chmod),
411 item->prefs->enable_folder_chmod);
412
413 entry_folder_chmod = gtk_entry_new();
414 gtk_table_attach(GTK_TABLE(table), entry_folder_chmod, 1, 2,
415 rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
416 SET_TOGGLE_SENSITIVITY(checkbtn_folder_chmod, entry_folder_chmod);
417 if (item->prefs->folder_chmod) {
418 gchar *buf;
419
420 buf = g_strdup_printf("%o", item->prefs->folder_chmod);
421 gtk_entry_set_text(GTK_ENTRY(entry_folder_chmod), buf);
422 g_free(buf);
423 }
424
425 folder_chmod_rec_checkbtn = gtk_check_button_new();
426 gtk_table_attach(GTK_TABLE(table), folder_chmod_rec_checkbtn, 2, 3,
427 rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
428
429 rowcount++;
430
431 /* Folder color */
432 folder_color = gtk_label_new(_("Folder color"));
433 gtk_misc_set_alignment(GTK_MISC(folder_color), 0, 0.5);
434 gtk_table_attach(GTK_TABLE(table), folder_color, 0, 1,
435 rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0);
436
437 hbox = gtk_hbox_new(FALSE, 0);
438 gtk_table_attach(GTK_TABLE(table), hbox, 1, 2,
439 rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
440
441 folder_color_btn = GTKUT_COLOR_BUTTON();
442 gtk_box_pack_start (GTK_BOX(hbox), folder_color_btn, FALSE, FALSE, 0);
443 CLAWS_SET_TIP(folder_color_btn,
444 _("Pick color for folder"));
445
446 page->folder_color = item->prefs->color;
447
448 g_signal_connect(G_OBJECT(folder_color_btn), "clicked",
449 G_CALLBACK(folder_color_set_dialog),
450 page);
451
452 gtkut_set_widget_bgcolor_rgb(folder_color_btn, item->prefs->color);
453
454 folder_color_rec_checkbtn = gtk_check_button_new();
455 gtk_table_attach(GTK_TABLE(table), folder_color_rec_checkbtn, 2, 3,
456 rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
457
458 rowcount++;
459
460 /* Enable processing at startup */
461 checkbtn_enable_processing =
462 gtk_check_button_new_with_label(_("Run Processing rules at start-up"));
463 gtk_table_attach(GTK_TABLE(table), checkbtn_enable_processing, 0, 2,
464 rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
465
466 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_processing),
467 item->prefs->enable_processing);
468
469 enable_processing_rec_checkbtn = gtk_check_button_new();
470 gtk_table_attach(GTK_TABLE(table), enable_processing_rec_checkbtn, 2, 3,
471 rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
472
473 rowcount++;
474
475 /* Enable processing rules when opening folder */
476 checkbtn_enable_processing_when_opening =
477 gtk_check_button_new_with_label(_("Run Processing rules when opening"));
478 gtk_table_attach(GTK_TABLE(table), checkbtn_enable_processing_when_opening, 0, 2,
479 rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
480
481 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_processing_when_opening),
482 item->prefs->enable_processing_when_opening);
483
484 enable_processing_when_opening_rec_checkbtn = gtk_check_button_new();
485 gtk_table_attach(GTK_TABLE(table), enable_processing_when_opening_rec_checkbtn, 2, 3,
486 rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
487
488 rowcount++;
489
490 /* Check folder for new mail */
491 checkbtn_newmailcheck = gtk_check_button_new_with_label(_("Scan for new mail"));
492 CLAWS_SET_TIP(checkbtn_newmailcheck,
493 _("Turn this option on if mail is delivered directly "
494 "to this folder by server side filtering on IMAP or "
495 "by an external application"));
496 gtk_table_attach(GTK_TABLE(table), checkbtn_newmailcheck, 0, 2,
497 rowcount, rowcount+1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
498
499 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_newmailcheck),
500 item->prefs->newmailcheck);
501 newmailcheck_rec_checkbtn = gtk_check_button_new();
502 gtk_table_attach(GTK_TABLE(table), newmailcheck_rec_checkbtn, 2, 3,
503 rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
504
505 rowcount++;
506
507 /* Select HTML part by default? */
508 hbox = gtk_hbox_new (FALSE, 2);
509 gtk_widget_show (hbox);
510 gtk_table_attach (GTK_TABLE(table), hbox, 0, 2,
511 rowcount, rowcount+1, GTK_FILL, GTK_FILL, 0, 0);
512
513 label = gtk_label_new(_("Select the HTML part of multipart messages"));
514 gtk_widget_show (label);
515 gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 0);
516
517 promote_html_part = gtkut_sc_combobox_create (NULL, FALSE);
518 gtk_widget_show (promote_html_part);
519 gtk_box_pack_start (GTK_BOX(hbox), promote_html_part, FALSE, FALSE, 0);
520
521 promote_html_part_menu = GTK_LIST_STORE(gtk_combo_box_get_model(
522 GTK_COMBO_BOX(promote_html_part)));
523 COMBOBOX_ADD (promote_html_part_menu, _("Default"), HTML_PROMOTE_DEFAULT);
524 COMBOBOX_ADD (promote_html_part_menu, _("No"), HTML_PROMOTE_NEVER);
525 COMBOBOX_ADD (promote_html_part_menu, _("Yes"), HTML_PROMOTE_ALWAYS);
526
527 combobox_select_by_data(GTK_COMBO_BOX(promote_html_part),
528 item->prefs->promote_html_part);
529
530 CLAWS_SET_TIP(hbox, _("\"Default\" will follow global preference (found in /Preferences/"
531 "Message View/Text Options)"));
532
533 promote_html_part_rec_checkbtn = gtk_check_button_new();
534 gtk_widget_show (promote_html_part_rec_checkbtn);
535 gtk_table_attach(GTK_TABLE(table), promote_html_part_rec_checkbtn, 2, 3,
536 rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
537 rowcount++;
538
539 /* Synchronise folder for offline use */
540 checkbtn_offlinesync = gtk_check_button_new_with_label(_("Synchronise for offline use"));
541 gtk_table_attach(GTK_TABLE(table), checkbtn_offlinesync, 0, 2,
542 rowcount, rowcount+1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
543
544 offlinesync_rec_checkbtn = gtk_check_button_new();
545 gtk_table_attach(GTK_TABLE(table), offlinesync_rec_checkbtn, 2, 3,
546 rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
547
548 rowcount++;
549
550 hbox = gtk_hbox_new (FALSE, 8);
551 gtk_widget_show (hbox);
552 gtk_table_attach(GTK_TABLE(table), hbox, 0, 3,
553 rowcount, rowcount+1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
554 rowcount++;
555
556 hbox_spc = gtk_hbox_new (FALSE, 0);
557 gtk_widget_show (hbox_spc);
558 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
559 gtk_widget_set_size_request (hbox_spc, 12, -1);
560
561 label_offlinesync = gtk_label_new(_("Fetch message bodies from the last"));
562 gtk_widget_show (label_offlinesync);
563 gtk_box_pack_start (GTK_BOX (hbox), label_offlinesync, FALSE, FALSE, 0);
564
565 entry_offlinesync = gtk_entry_new();
566 gtk_widget_set_size_request (entry_offlinesync, 64, -1);
567 gtk_widget_show (entry_offlinesync);
568 CLAWS_SET_TIP(entry_offlinesync, _("0: all bodies"));
569 gtk_box_pack_start (GTK_BOX (hbox), entry_offlinesync, FALSE, FALSE, 0);
570
571 label_end_offlinesync = gtk_label_new(_("days"));
572 gtk_widget_show (label_end_offlinesync);
573 gtk_box_pack_start (GTK_BOX (hbox), label_end_offlinesync, FALSE, FALSE, 0);
574
575 checkbtn_remove_old_offlinesync = gtk_check_button_new_with_label(
576 _("Remove older messages bodies"));
577
578 hbox2 = gtk_hbox_new (FALSE, 8);
579 gtk_widget_show (hbox2);
580 gtk_table_attach(GTK_TABLE(table), hbox2, 0, 3,
581 rowcount, rowcount+1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
582 rowcount++;
583
584 hbox_spc = gtk_hbox_new (FALSE, 0);
585 gtk_widget_show (hbox_spc);
586 gtk_box_pack_start (GTK_BOX (hbox2), hbox_spc, FALSE, FALSE, 0);
587 gtk_widget_set_size_request (hbox_spc, 12, -1);
588 gtk_box_pack_start (GTK_BOX (hbox2), checkbtn_remove_old_offlinesync, FALSE, FALSE, 0);
589
590 SET_TOGGLE_SENSITIVITY (checkbtn_offlinesync, hbox);
591 SET_TOGGLE_SENSITIVITY (checkbtn_offlinesync, hbox2);
592
593 clean_cache_btn = gtk_button_new_with_label(_("Discard folder cache"));
594 gtk_widget_show (clean_cache_btn);
595 gtk_table_attach(GTK_TABLE(table), clean_cache_btn, 0, 1,
596 rowcount, rowcount+1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
597 g_signal_connect(G_OBJECT(clean_cache_btn), "clicked",
598 G_CALLBACK(clean_cache_cb),
599 page);
600
601 gtk_widget_show_all(table);
602
603 if (item->folder && (item->folder->klass->type != F_IMAP &&
604 item->folder->klass->type != F_NEWS)) {
605 item->prefs->offlinesync = TRUE;
606 item->prefs->offlinesync_days = 0;
607 item->prefs->remove_old_bodies = FALSE;
608
609 gtk_widget_set_sensitive(GTK_WIDGET(checkbtn_offlinesync),
610 FALSE);
611 gtk_widget_set_sensitive(GTK_WIDGET(offlinesync_rec_checkbtn),
612 FALSE);
613 gtk_widget_hide(GTK_WIDGET(checkbtn_offlinesync));
614 gtk_widget_hide(GTK_WIDGET(hbox));
615 gtk_widget_hide(GTK_WIDGET(hbox2));
616 gtk_widget_hide(GTK_WIDGET(offlinesync_rec_checkbtn));
617 gtk_widget_hide(GTK_WIDGET(clean_cache_btn));
618
619 }
620 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_offlinesync),
621 item->prefs->offlinesync);
622 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_remove_old_offlinesync),
623 item->prefs->remove_old_bodies);
624 gtk_entry_set_text(GTK_ENTRY(entry_offlinesync), itos(item->prefs->offlinesync_days));
625
626 page->table = table;
627 page->folder_type = folder_type;
628 page->no_save_warning = no_save_warning;
629
630 page->checkbtn_simplify_subject = checkbtn_simplify_subject;
631 page->entry_simplify_subject = entry_simplify_subject;
632 page->entry_regexp_test_string = entry_regexp_test_string;
633 page->entry_regexp_test_result = entry_regexp_test_result;
634
635 page->checkbtn_folder_chmod = checkbtn_folder_chmod;
636 page->entry_folder_chmod = entry_folder_chmod;
637 page->folder_color_btn = folder_color_btn;
638 page->checkbtn_enable_processing = checkbtn_enable_processing;
639 page->checkbtn_enable_processing_when_opening = checkbtn_enable_processing_when_opening;
640 page->checkbtn_newmailcheck = checkbtn_newmailcheck;
641 page->checkbtn_offlinesync = checkbtn_offlinesync;
642 page->label_offlinesync = label_offlinesync;
643 page->entry_offlinesync = entry_offlinesync;
644 page->label_end_offlinesync = label_end_offlinesync;
645 page->checkbtn_remove_old_offlinesync = checkbtn_remove_old_offlinesync;
646 page->promote_html_part = promote_html_part;
647
648
649 page->simplify_subject_rec_checkbtn = simplify_subject_rec_checkbtn;
650
651 page->folder_chmod_rec_checkbtn = folder_chmod_rec_checkbtn;
652 page->folder_color_rec_checkbtn = folder_color_rec_checkbtn;
653 page->enable_processing_rec_checkbtn = enable_processing_rec_checkbtn;
654 page->enable_processing_when_opening_rec_checkbtn = enable_processing_when_opening_rec_checkbtn;
655 page->newmailcheck_rec_checkbtn = newmailcheck_rec_checkbtn;
656 page->offlinesync_rec_checkbtn = offlinesync_rec_checkbtn;
657 page->promote_html_part_rec_checkbtn = promote_html_part_rec_checkbtn;
658
659 page->page.widget = table;
660
661 folder_regexp_set_subject_example_cb(NULL, page);
662 }
663
prefs_folder_item_general_destroy_widget_func(PrefsPage * page_)664 static void prefs_folder_item_general_destroy_widget_func(PrefsPage *page_)
665 {
666 /* FolderItemGeneralPage *page = (FolderItemGeneralPage *) page_; */
667 }
668
669 /** \brief Save the prefs in page to folder.
670 *
671 * If the folder is not the one specified in page->item, then only those properties
672 * that have the relevant 'apply to sub folders' button checked are saved
673 */
general_save_folder_prefs(FolderItem * folder,FolderItemGeneralPage * page)674 static void general_save_folder_prefs(FolderItem *folder, FolderItemGeneralPage *page)
675 {
676 FolderItemPrefs *prefs = folder->prefs;
677 gchar *buf;
678 gboolean all = FALSE, summary_update_needed = FALSE;
679 SpecialFolderItemType type = F_NORMAL;
680 FolderView *folderview = mainwindow_get_mainwindow()->folderview;
681 HTMLPromoteType promote_html_part = HTML_PROMOTE_DEFAULT;
682
683 if (folder->path == NULL)
684 return;
685
686 cm_return_if_fail(prefs != NULL);
687
688 if (page->item == folder)
689 all = TRUE;
690
691 type = combobox_get_active_data(GTK_COMBO_BOX(page->folder_type));
692 if (all && folder->stype != type && page->item->parent_stype == F_NORMAL) {
693 folder_item_change_type(folder, type);
694 summary_update_needed = TRUE;
695 }
696
697 promote_html_part =
698 combobox_get_active_data(GTK_COMBO_BOX(page->promote_html_part));
699 if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->promote_html_part_rec_checkbtn)))
700 prefs->promote_html_part = promote_html_part;
701
702 if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->simplify_subject_rec_checkbtn))) {
703 gboolean old_simplify_subject = prefs->enable_simplify_subject;
704 int regexp_diffs = g_strcmp0(prefs->simplify_subject_regexp, gtk_editable_get_chars(
705 GTK_EDITABLE(page->entry_simplify_subject), 0, -1));
706 prefs->enable_simplify_subject =
707 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_simplify_subject));
708 ASSIGN_STRING(prefs->simplify_subject_regexp,
709 gtk_editable_get_chars(GTK_EDITABLE(page->entry_simplify_subject), 0, -1));
710 if (old_simplify_subject != prefs->enable_simplify_subject || regexp_diffs != 0)
711 summary_update_needed = TRUE;
712 }
713
714 if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->folder_chmod_rec_checkbtn))) {
715 prefs->enable_folder_chmod =
716 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_folder_chmod));
717 buf = gtk_editable_get_chars(GTK_EDITABLE(page->entry_folder_chmod), 0, -1);
718 prefs->folder_chmod = prefs_folder_item_chmod_mode(buf);
719 g_free(buf);
720 }
721
722 if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->folder_color_rec_checkbtn))) {
723 int old_color = prefs->color;
724 prefs->color = page->folder_color;
725
726 /* update folder view */
727 if (prefs->color != old_color)
728 folder_item_update(folder, F_ITEM_UPDATE_MSGCNT);
729 }
730
731 if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->enable_processing_rec_checkbtn))) {
732 prefs->enable_processing =
733 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_enable_processing));
734 }
735
736 if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->enable_processing_when_opening_rec_checkbtn))) {
737 prefs->enable_processing_when_opening =
738 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_enable_processing_when_opening));
739 }
740
741 if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->newmailcheck_rec_checkbtn))) {
742 prefs->newmailcheck =
743 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_newmailcheck));
744 }
745
746 if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->offlinesync_rec_checkbtn))) {
747 prefs->offlinesync =
748 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_offlinesync));
749 prefs->offlinesync_days =
750 atoi(gtk_entry_get_text(GTK_ENTRY(page->entry_offlinesync)));
751 prefs->remove_old_bodies =
752 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_remove_old_offlinesync));
753 }
754
755 folder_item_prefs_save_config(folder);
756
757 if (folder->opened && summary_update_needed) {
758 summary_set_prefs_from_folderitem(folderview->summaryview, folder);
759 summary_show(folderview->summaryview, folder, FALSE);
760 }
761 }
762
general_save_recurse_func(GNode * node,gpointer data)763 static gboolean general_save_recurse_func(GNode *node, gpointer data)
764 {
765 FolderItem *item = (FolderItem *) node->data;
766 FolderItemGeneralPage *page = (FolderItemGeneralPage *) data;
767
768 cm_return_val_if_fail(item != NULL, TRUE);
769 cm_return_val_if_fail(page != NULL, TRUE);
770
771 general_save_folder_prefs(item, page);
772
773 /* optimise by not continuing if none of the 'apply to sub folders'
774 check boxes are selected - and optimise the checking by only doing
775 it once */
776 if ((node == page->item->node) &&
777 !(
778 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->simplify_subject_rec_checkbtn)) ||
779 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->folder_chmod_rec_checkbtn)) ||
780 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->folder_color_rec_checkbtn)) ||
781 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->enable_processing_rec_checkbtn)) ||
782 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->enable_processing_when_opening_rec_checkbtn)) ||
783 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->newmailcheck_rec_checkbtn)) ||
784 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->offlinesync_rec_checkbtn)) ||
785 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->promote_html_part_rec_checkbtn))
786 ))
787 return TRUE;
788 else
789 return FALSE;
790 }
791
prefs_folder_item_general_save_func(PrefsPage * page_)792 static void prefs_folder_item_general_save_func(PrefsPage *page_)
793 {
794 FolderItemGeneralPage *page = (FolderItemGeneralPage *) page_;
795
796 g_node_traverse(page->item->node, G_PRE_ORDER, G_TRAVERSE_ALL,
797 -1, general_save_recurse_func, page);
798
799 main_window_set_menu_sensitive(mainwindow_get_mainwindow());
800
801 }
802
item_protocol(FolderItem * item)803 static RecvProtocol item_protocol(FolderItem *item)
804 {
805 if (!item)
806 return A_NONE;
807 if (!item->folder)
808 return A_NONE;
809 if (!item->folder->account)
810 return A_NONE;
811 return item->folder->account->protocol;
812 }
813
prefs_folder_item_compose_create_widget_func(PrefsPage * page_,GtkWindow * window,gpointer data)814 static void prefs_folder_item_compose_create_widget_func(PrefsPage * page_,
815 GtkWindow * window,
816 gpointer data)
817 {
818 FolderItemComposePage *page = (FolderItemComposePage *) page_;
819 FolderItem *item = (FolderItem *) data;
820 guint rowcount;
821 gchar *text = NULL;
822 gchar *tr = NULL;
823
824 GtkWidget *table;
825 GtkWidget *hbox;
826 GtkWidget *label;
827
828 GtkWidget *no_save_warning = NULL;
829 GtkWidget *checkbtn_request_return_receipt = NULL;
830 GtkWidget *checkbtn_save_copy_to_folder = NULL;
831 GtkWidget *checkbtn_default_to = NULL;
832 GtkWidget *entry_default_to = NULL;
833 GtkWidget *checkbtn_default_reply_to = NULL;
834 GtkWidget *entry_default_reply_to = NULL;
835 GtkWidget *checkbtn_default_cc = NULL;
836 GtkWidget *entry_default_cc = NULL;
837 GtkWidget *checkbtn_default_bcc = NULL;
838 GtkWidget *entry_default_bcc = NULL;
839 GtkWidget *checkbtn_default_replyto = NULL;
840 GtkWidget *entry_default_replyto = NULL;
841 GtkWidget *checkbtn_enable_default_account = NULL;
842 GtkWidget *optmenu_default_account = NULL;
843 GtkListStore *optmenu_default_account_menu = NULL;
844 GtkTreeIter iter;
845 #if USE_ENCHANT
846 GtkWidget *checkbtn_enable_default_dictionary = NULL;
847 GtkWidget *combo_default_dictionary = NULL;
848 GtkWidget *checkbtn_enable_default_alt_dictionary = NULL;
849 GtkWidget *combo_default_alt_dictionary = NULL;
850 GtkWidget *default_dictionary_rec_checkbtn = NULL;
851 GtkWidget *default_alt_dictionary_rec_checkbtn = NULL;
852 gchar *dictionary;
853 #endif
854 GtkWidget *always_sign;
855 GtkListStore *always_sign_menu;
856 GtkWidget *always_encrypt;
857 GtkListStore *always_encrypt_menu;
858 GtkWidget *request_return_receipt_rec_checkbtn = NULL;
859 GtkWidget *save_copy_to_folder_rec_checkbtn = NULL;
860 GtkWidget *default_to_rec_checkbtn = NULL;
861 GtkWidget *default_reply_to_rec_checkbtn = NULL;
862 GtkWidget *default_cc_rec_checkbtn = NULL;
863 GtkWidget *default_bcc_rec_checkbtn = NULL;
864 GtkWidget *default_replyto_rec_checkbtn = NULL;
865 GtkWidget *default_account_rec_checkbtn = NULL;
866 GtkWidget *always_sign_rec_checkbtn = NULL;
867 GtkWidget *always_encrypt_rec_checkbtn = NULL;
868
869 GList *cur_ac;
870 GList *account_list;
871 PrefsAccount *ac_prefs;
872 gboolean default_account_set = FALSE;
873
874 page->item = item;
875
876 /* Table */
877 #if USE_ENCHANT
878 # define TABLEHEIGHT 7
879 #else
880 # define TABLEHEIGHT 6
881 #endif
882 table = gtk_table_new(TABLEHEIGHT, 3, FALSE);
883 gtk_container_set_border_width (GTK_CONTAINER (table), VBOX_BORDER);
884 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
885 gtk_table_set_col_spacings(GTK_TABLE(table), 4);
886 rowcount = 0;
887
888 if (!can_save) {
889 no_save_warning = prefs_folder_no_save_warning_create_widget();
890 gtk_table_attach(GTK_TABLE(table), no_save_warning, 0, 3,
891 rowcount, rowcount + 1, GTK_FILL, 0, 0, 0);
892 rowcount++;
893 }
894
895 /* Apply to subfolders */
896 label = gtk_label_new(_("Apply to\nsubfolders"));
897 gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.5);
898 gtk_table_attach(GTK_TABLE(table), label, 2, 3,
899 rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
900 rowcount++;
901
902 if (item_protocol(item) != A_NNTP) {
903 /* Request Return Receipt */
904 checkbtn_request_return_receipt = gtk_check_button_new_with_label
905 (_("Request Return Receipt"));
906 gtk_table_attach(GTK_TABLE(table), checkbtn_request_return_receipt,
907 0, 2, rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL,
908 GTK_FILL, 0, 0);
909 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_request_return_receipt),
910 item->ret_rcpt ? TRUE : FALSE);
911
912 request_return_receipt_rec_checkbtn = gtk_check_button_new();
913 gtk_table_attach(GTK_TABLE(table), request_return_receipt_rec_checkbtn, 2, 3,
914 rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
915
916 rowcount++;
917
918 /* Save Copy to Folder */
919 checkbtn_save_copy_to_folder = gtk_check_button_new_with_label
920 (_("Save copy of outgoing messages to this folder instead of Sent"));
921 gtk_table_attach(GTK_TABLE(table), checkbtn_save_copy_to_folder, 0, 2,
922 rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0);
923 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_save_copy_to_folder),
924 item->prefs->save_copy_to_folder ? TRUE : FALSE);
925
926 save_copy_to_folder_rec_checkbtn = gtk_check_button_new();
927 gtk_table_attach(GTK_TABLE(table), save_copy_to_folder_rec_checkbtn, 2, 3,
928 rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
929
930 rowcount++;
931
932 /* Default To */
933 tr = g_strdup(C_("folder properties: %s stands for a header name",
934 "Default %s"));
935 text = g_strdup_printf(tr, prefs_common_translated_header_name("To:"));
936 checkbtn_default_to = gtk_check_button_new_with_label(text);
937 gtk_table_attach(GTK_TABLE(table), checkbtn_default_to, 0, 1,
938 rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
939 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_default_to),
940 item->prefs->enable_default_to);
941 g_free(text);
942 g_free(tr);
943
944 entry_default_to = gtk_entry_new();
945 gtk_table_attach(GTK_TABLE(table), entry_default_to, 1, 2,
946 rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
947 SET_TOGGLE_SENSITIVITY(checkbtn_default_to, entry_default_to);
948 gtk_entry_set_text(GTK_ENTRY(entry_default_to), SAFE_STRING(item->prefs->default_to));
949 address_completion_register_entry(GTK_ENTRY(entry_default_to),
950 TRUE);
951
952 default_to_rec_checkbtn = gtk_check_button_new();
953 gtk_table_attach(GTK_TABLE(table), default_to_rec_checkbtn, 2, 3,
954 rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
955
956 rowcount++;
957
958 /* Default address to reply to */
959 tr = g_strdup(C_("folder properties: %s stands for a header name",
960 "Default %s for replies"));
961 text = g_strdup_printf(tr, prefs_common_translated_header_name("To:"));
962 checkbtn_default_reply_to = gtk_check_button_new_with_label(text);
963 gtk_table_attach(GTK_TABLE(table), checkbtn_default_reply_to, 0, 1,
964 rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
965 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_default_reply_to),
966 item->prefs->enable_default_reply_to);
967 g_free(text);
968 g_free(tr);
969
970 entry_default_reply_to = gtk_entry_new();
971 gtk_table_attach(GTK_TABLE(table), entry_default_reply_to, 1, 2,
972 rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
973 SET_TOGGLE_SENSITIVITY(checkbtn_default_reply_to, entry_default_reply_to);
974 gtk_entry_set_text(GTK_ENTRY(entry_default_reply_to), SAFE_STRING(item->prefs->default_reply_to));
975 address_completion_register_entry(
976 GTK_ENTRY(entry_default_reply_to), TRUE);
977
978 default_reply_to_rec_checkbtn = gtk_check_button_new();
979 gtk_table_attach(GTK_TABLE(table), default_reply_to_rec_checkbtn, 2, 3,
980 rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
981
982 rowcount++;
983
984 /* Default Cc */
985 tr = g_strdup(C_("folder properties: %s stands for a header name",
986 "Default %s"));
987 text = g_strdup_printf(tr, prefs_common_translated_header_name("Cc:"));
988 checkbtn_default_cc = gtk_check_button_new_with_label(text);
989 gtk_table_attach(GTK_TABLE(table), checkbtn_default_cc, 0, 1,
990 rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
991 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_default_cc),
992 item->prefs->enable_default_cc);
993 g_free(text);
994 g_free(tr);
995
996 entry_default_cc = gtk_entry_new();
997 gtk_table_attach(GTK_TABLE(table), entry_default_cc, 1, 2,
998 rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
999 SET_TOGGLE_SENSITIVITY(checkbtn_default_cc, entry_default_cc);
1000 gtk_entry_set_text(GTK_ENTRY(entry_default_cc), SAFE_STRING(item->prefs->default_cc));
1001 address_completion_register_entry(GTK_ENTRY(entry_default_cc),
1002 TRUE);
1003
1004 default_cc_rec_checkbtn = gtk_check_button_new();
1005 gtk_table_attach(GTK_TABLE(table), default_cc_rec_checkbtn, 2, 3,
1006 rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
1007
1008 rowcount++;
1009
1010 /* Default Bcc */
1011 tr = g_strdup(C_("folder properties: %s stands for a header name",
1012 "Default %s"));
1013 text = g_strdup_printf(tr, prefs_common_translated_header_name("Bcc:"));
1014 checkbtn_default_bcc = gtk_check_button_new_with_label(text);
1015 gtk_table_attach(GTK_TABLE(table), checkbtn_default_bcc, 0, 1,
1016 rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
1017 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_default_bcc),
1018 item->prefs->enable_default_bcc);
1019 g_free(text);
1020 g_free(tr);
1021
1022 entry_default_bcc = gtk_entry_new();
1023 gtk_table_attach(GTK_TABLE(table), entry_default_bcc, 1, 2,
1024 rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
1025 SET_TOGGLE_SENSITIVITY(checkbtn_default_bcc, entry_default_bcc);
1026 gtk_entry_set_text(GTK_ENTRY(entry_default_bcc), SAFE_STRING(item->prefs->default_bcc));
1027 address_completion_register_entry(GTK_ENTRY(entry_default_bcc),
1028 TRUE);
1029
1030 default_bcc_rec_checkbtn = gtk_check_button_new();
1031 gtk_table_attach(GTK_TABLE(table), default_bcc_rec_checkbtn, 2, 3,
1032 rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
1033
1034 rowcount++;
1035
1036 /* Default Reply-to */
1037 tr = g_strdup(C_("folder properties: %s stands for a header name",
1038 "Default %s"));
1039 text = g_strdup_printf(tr, prefs_common_translated_header_name("Reply-To:"));
1040 checkbtn_default_replyto = gtk_check_button_new_with_label(text);
1041 gtk_table_attach(GTK_TABLE(table), checkbtn_default_replyto, 0, 1,
1042 rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
1043 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_default_replyto),
1044 item->prefs->enable_default_replyto);
1045 g_free(text);
1046 g_free(tr);
1047
1048 entry_default_replyto = gtk_entry_new();
1049 gtk_table_attach(GTK_TABLE(table), entry_default_replyto, 1, 2,
1050 rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
1051 SET_TOGGLE_SENSITIVITY(checkbtn_default_replyto, entry_default_replyto);
1052 gtk_entry_set_text(GTK_ENTRY(entry_default_replyto), SAFE_STRING(item->prefs->default_replyto));
1053 address_completion_register_entry(GTK_ENTRY(entry_default_replyto),
1054 TRUE);
1055
1056 default_replyto_rec_checkbtn = gtk_check_button_new();
1057 gtk_table_attach(GTK_TABLE(table), default_replyto_rec_checkbtn, 2, 3,
1058 rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
1059
1060 rowcount++;
1061 }
1062 /* Default account */
1063 checkbtn_enable_default_account = gtk_check_button_new_with_label(_("Default account"));
1064 gtk_table_attach(GTK_TABLE(table), checkbtn_enable_default_account, 0, 1,
1065 rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
1066 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_default_account),
1067 item->prefs->enable_default_account);
1068
1069 optmenu_default_account = gtkut_sc_combobox_create(NULL, FALSE);
1070 gtk_table_attach(GTK_TABLE(table), optmenu_default_account, 1, 2,
1071 rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
1072 optmenu_default_account_menu = GTK_LIST_STORE(
1073 gtk_combo_box_get_model(GTK_COMBO_BOX(optmenu_default_account)));
1074
1075 account_list = account_get_list();
1076 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1077 ac_prefs = (PrefsAccount *)cur_ac->data;
1078 if (item->folder->account &&
1079 ( (item_protocol(item) == A_NNTP && ac_prefs->protocol != A_NNTP)
1080 ||(item_protocol(item) != A_NNTP && ac_prefs->protocol == A_NNTP)))
1081 continue;
1082
1083 if (item->folder->klass->type != F_NEWS && ac_prefs->protocol == A_NNTP)
1084 continue;
1085
1086 COMBOBOX_ADD_ESCAPED (optmenu_default_account_menu,
1087 ac_prefs->account_name?ac_prefs->account_name : _("Untitled"),
1088 ac_prefs->account_id);
1089
1090 /* Set combobox to current default account id */
1091 if (ac_prefs->account_id == item->prefs->default_account) {
1092 combobox_select_by_data(GTK_COMBO_BOX(optmenu_default_account),
1093 ac_prefs->account_id);
1094 default_account_set = TRUE;
1095 }
1096 }
1097
1098 /* If nothing has been set (folder doesn't have a default account set),
1099 * pre-select global default account, since that's what actually used
1100 * anyway. We don't want nothing selected in combobox. */
1101 if( !default_account_set )
1102 combobox_select_by_data(GTK_COMBO_BOX(optmenu_default_account),
1103 account_get_default()->account_id);
1104
1105 SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_account, optmenu_default_account);
1106
1107 default_account_rec_checkbtn = gtk_check_button_new();
1108 gtk_table_attach(GTK_TABLE(table), default_account_rec_checkbtn, 2, 3,
1109 rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
1110 rowcount++;
1111
1112 #if USE_ENCHANT
1113 /* Default dictionary */
1114 checkbtn_enable_default_dictionary = gtk_check_button_new_with_label(_("Default dictionary"));
1115 gtk_table_attach(GTK_TABLE(table), checkbtn_enable_default_dictionary, 0, 1,
1116 rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
1117 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_default_dictionary),
1118 item->prefs->enable_default_dictionary);
1119
1120 combo_default_dictionary = gtkaspell_dictionary_combo_new(TRUE);
1121 gtk_table_attach(GTK_TABLE(table), combo_default_dictionary, 1, 2,
1122 rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
1123
1124 dictionary = item->prefs->default_dictionary;
1125 if (dictionary && strrchr(dictionary, '/')) {
1126 gchar *tmp = g_strdup(strrchr(dictionary, '/')+1);
1127 g_free(item->prefs->default_dictionary);
1128 item->prefs->default_dictionary = tmp;
1129 dictionary = item->prefs->default_dictionary;
1130 }
1131 if (item->prefs->default_dictionary &&
1132 strchr(item->prefs->default_dictionary, '-')) {
1133 *(strchr(item->prefs->default_dictionary, '-')) = '\0';
1134 }
1135 if (dictionary)
1136 gtkaspell_set_dictionary_menu_active_item(
1137 GTK_COMBO_BOX(combo_default_dictionary), dictionary);
1138
1139 SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_dictionary, combo_default_dictionary);
1140
1141 default_dictionary_rec_checkbtn = gtk_check_button_new();
1142 gtk_table_attach(GTK_TABLE(table), default_dictionary_rec_checkbtn, 2, 3,
1143 rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
1144
1145 rowcount++;
1146
1147 /* Default alternate dictionary */
1148 checkbtn_enable_default_alt_dictionary = gtk_check_button_new_with_label(_("Default alternate dictionary"));
1149 gtk_table_attach(GTK_TABLE(table), checkbtn_enable_default_alt_dictionary, 0, 1,
1150 rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
1151 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_default_alt_dictionary),
1152 item->prefs->enable_default_alt_dictionary);
1153
1154 combo_default_alt_dictionary = gtkaspell_dictionary_combo_new(FALSE);
1155 gtk_table_attach(GTK_TABLE(table), combo_default_alt_dictionary, 1, 2,
1156 rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
1157
1158 dictionary = item->prefs->default_alt_dictionary;
1159 if (dictionary && strrchr(dictionary, '/')) {
1160 gchar *tmp = g_strdup(strrchr(dictionary, '/')+1);
1161 g_free(item->prefs->default_alt_dictionary);
1162 item->prefs->default_alt_dictionary = tmp;
1163 dictionary = item->prefs->default_alt_dictionary;
1164 }
1165 if (item->prefs->default_alt_dictionary &&
1166 strchr(item->prefs->default_alt_dictionary, '-')) {
1167 *(strchr(item->prefs->default_alt_dictionary, '-')) = '\0';
1168 }
1169 if (dictionary)
1170 gtkaspell_set_dictionary_menu_active_item(
1171 GTK_COMBO_BOX(combo_default_alt_dictionary), dictionary);
1172
1173 SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_alt_dictionary, combo_default_alt_dictionary);
1174
1175 default_alt_dictionary_rec_checkbtn = gtk_check_button_new();
1176 gtk_table_attach(GTK_TABLE(table), default_alt_dictionary_rec_checkbtn, 2, 3,
1177 rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
1178
1179 rowcount++;
1180 #endif
1181
1182 /* PGP sign? */
1183 hbox = gtk_hbox_new (FALSE, 2);
1184 gtk_widget_show (hbox);
1185 gtk_table_attach (GTK_TABLE(table), hbox, 0, 2,
1186 rowcount, rowcount+1, GTK_FILL, GTK_FILL, 0, 0);
1187
1188 label = gtk_label_new(_("Always sign messages"));
1189 gtk_widget_show (label);
1190 gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 0);
1191
1192 always_sign = gtkut_sc_combobox_create (NULL, FALSE);
1193 gtk_widget_show (always_sign);
1194 gtk_box_pack_start (GTK_BOX(hbox), always_sign, FALSE, FALSE, 0);
1195
1196 always_sign_menu = GTK_LIST_STORE(gtk_combo_box_get_model(
1197 GTK_COMBO_BOX(always_sign)));
1198 COMBOBOX_ADD (always_sign_menu, _("Default"), SIGN_OR_ENCRYPT_DEFAULT);
1199 COMBOBOX_ADD (always_sign_menu, _("No"), SIGN_OR_ENCRYPT_NEVER);
1200 COMBOBOX_ADD (always_sign_menu, _("Yes"), SIGN_OR_ENCRYPT_ALWAYS);
1201
1202 combobox_select_by_data(GTK_COMBO_BOX(always_sign),
1203 item->prefs->always_sign);
1204
1205 CLAWS_SET_TIP(hbox, _("\"Default\" will follow the applicable account preference"));
1206
1207 always_sign_rec_checkbtn = gtk_check_button_new();
1208 gtk_widget_show (always_sign_rec_checkbtn);
1209 gtk_table_attach(GTK_TABLE(table), always_sign_rec_checkbtn, 2, 3,
1210 rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
1211
1212 rowcount++;
1213
1214 /* PGP encrypt? */
1215 hbox = gtk_hbox_new (FALSE, 2);
1216 gtk_widget_show (hbox);
1217 gtk_table_attach (GTK_TABLE(table), hbox, 0, 2,
1218 rowcount, rowcount+1, GTK_FILL, GTK_FILL, 0, 0);
1219
1220 label = gtk_label_new(_("Always encrypt messages"));
1221 gtk_widget_show (label);
1222 gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 0);
1223
1224 always_encrypt = gtkut_sc_combobox_create (NULL, FALSE);
1225 gtk_widget_show (always_encrypt);
1226 gtk_box_pack_start (GTK_BOX(hbox), always_encrypt, FALSE, FALSE, 0);
1227
1228 always_encrypt_menu = GTK_LIST_STORE(gtk_combo_box_get_model(
1229 GTK_COMBO_BOX(always_encrypt)));
1230 COMBOBOX_ADD (always_encrypt_menu, _("Default"), SIGN_OR_ENCRYPT_DEFAULT);
1231 COMBOBOX_ADD (always_encrypt_menu, _("No"), SIGN_OR_ENCRYPT_NEVER);
1232 COMBOBOX_ADD (always_encrypt_menu, _("Yes"), SIGN_OR_ENCRYPT_ALWAYS);
1233
1234 combobox_select_by_data(GTK_COMBO_BOX(always_encrypt),
1235 item->prefs->always_encrypt);
1236
1237 CLAWS_SET_TIP(hbox, _("\"Default\" will follow the applicable account preference"));
1238
1239 always_encrypt_rec_checkbtn = gtk_check_button_new();
1240 gtk_widget_show (always_encrypt_rec_checkbtn);
1241 gtk_table_attach(GTK_TABLE(table), always_encrypt_rec_checkbtn, 2, 3,
1242 rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
1243
1244 rowcount++;
1245
1246 gtk_widget_show_all(table);
1247
1248 page->window = GTK_WIDGET(window);
1249 page->table = table;
1250 page->no_save_warning = no_save_warning;
1251 page->checkbtn_request_return_receipt = checkbtn_request_return_receipt;
1252 page->checkbtn_save_copy_to_folder = checkbtn_save_copy_to_folder;
1253 page->checkbtn_default_to = checkbtn_default_to;
1254 page->entry_default_to = entry_default_to;
1255 page->checkbtn_default_reply_to = checkbtn_default_reply_to;
1256 page->entry_default_reply_to = entry_default_reply_to;
1257 page->checkbtn_default_cc = checkbtn_default_cc;
1258 page->entry_default_cc = entry_default_cc;
1259 page->checkbtn_default_bcc = checkbtn_default_bcc;
1260 page->entry_default_bcc = entry_default_bcc;
1261 page->checkbtn_default_replyto = checkbtn_default_replyto;
1262 page->entry_default_replyto = entry_default_replyto;
1263 page->checkbtn_enable_default_account = checkbtn_enable_default_account;
1264 page->optmenu_default_account = optmenu_default_account;
1265 #ifdef USE_ENCHANT
1266 page->checkbtn_enable_default_dictionary = checkbtn_enable_default_dictionary;
1267 page->combo_default_dictionary = combo_default_dictionary;
1268 page->checkbtn_enable_default_alt_dictionary = checkbtn_enable_default_alt_dictionary;
1269 page->combo_default_alt_dictionary = combo_default_alt_dictionary;
1270 #endif
1271 page->always_sign = always_sign;
1272 page->always_encrypt = always_encrypt;
1273
1274 page->request_return_receipt_rec_checkbtn = request_return_receipt_rec_checkbtn;
1275 page->save_copy_to_folder_rec_checkbtn = save_copy_to_folder_rec_checkbtn;
1276 page->default_to_rec_checkbtn = default_to_rec_checkbtn;
1277 page->default_reply_to_rec_checkbtn = default_reply_to_rec_checkbtn;
1278 page->default_cc_rec_checkbtn = default_cc_rec_checkbtn;
1279 page->default_bcc_rec_checkbtn = default_bcc_rec_checkbtn;
1280 page->default_replyto_rec_checkbtn = default_replyto_rec_checkbtn;
1281 page->default_account_rec_checkbtn = default_account_rec_checkbtn;
1282 #if USE_ENCHANT
1283 page->default_dictionary_rec_checkbtn = default_dictionary_rec_checkbtn;
1284 page->default_alt_dictionary_rec_checkbtn = default_alt_dictionary_rec_checkbtn;
1285 #endif
1286 page->always_sign_rec_checkbtn = always_sign_rec_checkbtn;
1287 page->always_encrypt_rec_checkbtn = always_encrypt_rec_checkbtn;
1288
1289 page->page.widget = table;
1290 }
1291
prefs_folder_item_compose_destroy_widget_func(PrefsPage * page_)1292 static void prefs_folder_item_compose_destroy_widget_func(PrefsPage *page_)
1293 {
1294 FolderItemComposePage *page = (FolderItemComposePage *) page_;
1295
1296 if (page->entry_default_to)
1297 address_completion_unregister_entry(GTK_ENTRY(page->entry_default_to));
1298 if (page->entry_default_reply_to)
1299 address_completion_unregister_entry(GTK_ENTRY(page->entry_default_reply_to));
1300 if (page->entry_default_cc)
1301 address_completion_unregister_entry(GTK_ENTRY(page->entry_default_cc));
1302 if (page->entry_default_bcc)
1303 address_completion_unregister_entry(GTK_ENTRY(page->entry_default_bcc));
1304 if (page->entry_default_replyto)
1305 address_completion_unregister_entry(GTK_ENTRY(page->entry_default_replyto));
1306 }
1307
1308 /** \brief Save the prefs in page to folder.
1309 *
1310 * If the folder is not the one specified in page->item, then only those properties
1311 * that have the relevant 'apply to sub folders' button checked are saved
1312 */
compose_save_folder_prefs(FolderItem * folder,FolderItemComposePage * page)1313 static void compose_save_folder_prefs(FolderItem *folder, FolderItemComposePage *page)
1314 {
1315 FolderItemPrefs *prefs = folder->prefs;
1316
1317 gboolean all = FALSE;
1318
1319 if (folder->path == NULL)
1320 return;
1321
1322 if (page->item == folder)
1323 all = TRUE;
1324
1325 cm_return_if_fail(prefs != NULL);
1326
1327 if (item_protocol(folder) != A_NNTP) {
1328 if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->request_return_receipt_rec_checkbtn))) {
1329 prefs->request_return_receipt =
1330 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_request_return_receipt));
1331 /* MIGRATION */
1332 folder->ret_rcpt = prefs->request_return_receipt;
1333 }
1334
1335 if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->save_copy_to_folder_rec_checkbtn))) {
1336 prefs->save_copy_to_folder =
1337 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_save_copy_to_folder));
1338 }
1339
1340 if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_to_rec_checkbtn))) {
1341
1342 prefs->enable_default_to =
1343 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_default_to));
1344 ASSIGN_STRING(prefs->default_to,
1345 gtk_editable_get_chars(GTK_EDITABLE(page->entry_default_to), 0, -1));
1346 }
1347
1348 if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_reply_to_rec_checkbtn))) {
1349 prefs->enable_default_reply_to =
1350 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_default_reply_to));
1351 ASSIGN_STRING(prefs->default_reply_to,
1352 gtk_editable_get_chars(GTK_EDITABLE(page->entry_default_reply_to), 0, -1));
1353 }
1354
1355 if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_cc_rec_checkbtn))) {
1356
1357 prefs->enable_default_cc =
1358 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_default_cc));
1359 ASSIGN_STRING(prefs->default_cc,
1360 gtk_editable_get_chars(GTK_EDITABLE(page->entry_default_cc), 0, -1));
1361 }
1362
1363 if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_bcc_rec_checkbtn))) {
1364
1365 prefs->enable_default_bcc =
1366 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_default_bcc));
1367 ASSIGN_STRING(prefs->default_bcc,
1368 gtk_editable_get_chars(GTK_EDITABLE(page->entry_default_bcc), 0, -1));
1369 }
1370
1371 if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_replyto_rec_checkbtn))) {
1372
1373 prefs->enable_default_replyto =
1374 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_default_replyto));
1375 ASSIGN_STRING(prefs->default_replyto,
1376 gtk_editable_get_chars(GTK_EDITABLE(page->entry_default_replyto), 0, -1));
1377 }
1378
1379 } else {
1380 prefs->request_return_receipt = FALSE;
1381 prefs->save_copy_to_folder = FALSE;
1382 prefs->enable_default_to = FALSE;
1383 prefs->enable_default_reply_to = FALSE;
1384 prefs->enable_default_cc = FALSE;
1385 prefs->enable_default_bcc = FALSE;
1386 prefs->enable_default_replyto = FALSE;
1387 }
1388
1389 if (all || gtk_toggle_button_get_active(
1390 GTK_TOGGLE_BUTTON(page->default_account_rec_checkbtn))) {
1391 prefs->enable_default_account =
1392 gtk_toggle_button_get_active(
1393 GTK_TOGGLE_BUTTON(page->checkbtn_enable_default_account));
1394 prefs->default_account = combobox_get_active_data(
1395 GTK_COMBO_BOX(page->optmenu_default_account));
1396 }
1397
1398 #if USE_ENCHANT
1399 if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_dictionary_rec_checkbtn))) {
1400 prefs->enable_default_dictionary =
1401 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_enable_default_dictionary));
1402 ASSIGN_STRING(prefs->default_dictionary,
1403 gtkaspell_get_dictionary_menu_active_item(
1404 GTK_COMBO_BOX(page->combo_default_dictionary)));
1405 }
1406 if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_alt_dictionary_rec_checkbtn))) {
1407 prefs->enable_default_alt_dictionary =
1408 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_enable_default_alt_dictionary));
1409 ASSIGN_STRING(prefs->default_alt_dictionary,
1410 gtkaspell_get_dictionary_menu_active_item(
1411 GTK_COMBO_BOX(page->combo_default_alt_dictionary)));
1412 }
1413 #endif
1414 if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->always_sign_rec_checkbtn))) {
1415 prefs->always_sign =
1416 combobox_get_active_data(GTK_COMBO_BOX(page->always_sign));
1417 }
1418 if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->always_encrypt_rec_checkbtn))) {
1419 prefs->always_encrypt =
1420 combobox_get_active_data(GTK_COMBO_BOX(page->always_encrypt));
1421 }
1422
1423 folder_item_prefs_save_config(folder);
1424 }
1425
compose_save_recurse_func(GNode * node,gpointer data)1426 static gboolean compose_save_recurse_func(GNode *node, gpointer data)
1427 {
1428 FolderItem *item = (FolderItem *) node->data;
1429 FolderItemComposePage *page = (FolderItemComposePage *) data;
1430
1431 cm_return_val_if_fail(item != NULL, TRUE);
1432 cm_return_val_if_fail(page != NULL, TRUE);
1433
1434 compose_save_folder_prefs(item, page);
1435
1436 /* optimise by not continuing if none of the 'apply to sub folders'
1437 check boxes are selected - and optimise the checking by only doing
1438 it once */
1439 if ((node == page->item->node) && item_protocol(item) != A_NNTP &&
1440 !(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->request_return_receipt_rec_checkbtn)) ||
1441 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->save_copy_to_folder_rec_checkbtn)) ||
1442 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_to_rec_checkbtn)) ||
1443 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_account_rec_checkbtn)) ||
1444 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_cc_rec_checkbtn)) ||
1445 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_bcc_rec_checkbtn)) ||
1446 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_replyto_rec_checkbtn)) ||
1447 #if USE_ENCHANT
1448 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_dictionary_rec_checkbtn)) ||
1449 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_alt_dictionary_rec_checkbtn)) ||
1450 #endif
1451 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->always_sign_rec_checkbtn)) ||
1452 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->always_encrypt_rec_checkbtn)) ||
1453 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_reply_to_rec_checkbtn))
1454 ))
1455 return TRUE;
1456 else if ((node == page->item->node) && item_protocol(item) == A_NNTP &&
1457 !(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_account_rec_checkbtn))
1458 #if USE_ENCHANT
1459 || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_dictionary_rec_checkbtn))
1460 || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_alt_dictionary_rec_checkbtn))
1461 #endif
1462 || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->always_sign_rec_checkbtn))
1463 || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->always_encrypt_rec_checkbtn))
1464 ))
1465 return TRUE;
1466 else
1467 return FALSE;
1468 }
1469
prefs_folder_item_compose_save_func(PrefsPage * page_)1470 static void prefs_folder_item_compose_save_func(PrefsPage *page_)
1471 {
1472 FolderItemComposePage *page = (FolderItemComposePage *) page_;
1473
1474 g_node_traverse(page->item->node, G_PRE_ORDER, G_TRAVERSE_ALL,
1475 -1, compose_save_recurse_func, page);
1476
1477 }
1478
prefs_folder_item_templates_create_widget_func(PrefsPage * page_,GtkWindow * window,gpointer data)1479 static void prefs_folder_item_templates_create_widget_func(PrefsPage * page_,
1480 GtkWindow * window,
1481 gpointer data)
1482 {
1483 FolderItemTemplatesPage *page = (FolderItemTemplatesPage *) page_;
1484 FolderItem *item = (FolderItem *) data;
1485
1486 GtkWidget *notebook;
1487 GtkWidget *vbox;
1488 GtkWidget *page_vbox;
1489 GtkWidget *no_save_warning;
1490 GtkWidget *new_msg_format_rec_checkbtn;
1491 GtkWidget *reply_format_rec_checkbtn;
1492 GtkWidget *forward_format_rec_checkbtn;
1493 GtkWidget *hbox;
1494 GtkWidget *vbox_format;
1495
1496 page->item = item;
1497
1498 page_vbox = gtk_vbox_new (FALSE, 0);
1499 gtk_container_set_border_width (GTK_CONTAINER (page_vbox), VBOX_BORDER);
1500 gtk_widget_show (page_vbox);
1501
1502 if (!can_save) {
1503 no_save_warning = prefs_folder_no_save_warning_create_widget();
1504 gtk_box_pack_start(GTK_BOX(page_vbox),
1505 no_save_warning, FALSE, FALSE, 0);
1506 }
1507
1508 /* Notebook */
1509 notebook = gtk_notebook_new();
1510 gtk_widget_show(notebook);
1511 gtk_box_pack_start(GTK_BOX(page_vbox), notebook, TRUE, TRUE, 4);
1512
1513 /* compose format */
1514 vbox = gtk_vbox_new (FALSE, VSPACING);
1515 gtk_widget_show (vbox);
1516 gtk_container_set_border_width (GTK_CONTAINER (vbox), VBOX_BORDER);
1517
1518 quotefmt_create_new_msg_fmt_widgets(
1519 window,
1520 vbox,
1521 &page->checkbtn_compose_with_format,
1522 &page->compose_override_from_format,
1523 &page->compose_subject_format,
1524 &page->compose_body_format,
1525 FALSE, FALSE);
1526 address_completion_register_entry(GTK_ENTRY(page->compose_override_from_format),
1527 TRUE);
1528
1529 vbox_format = gtk_widget_get_parent(
1530 gtk_widget_get_parent(page->compose_body_format));
1531
1532 hbox = gtk_hbox_new (FALSE, 0);
1533 gtk_box_pack_end (GTK_BOX(vbox_format), hbox, FALSE, FALSE, 0);
1534 quotefmt_add_info_button(window, hbox);
1535
1536 new_msg_format_rec_checkbtn = gtk_check_button_new_with_label(
1537 _("Apply to subfolders"));
1538 gtk_box_pack_end (GTK_BOX(hbox), new_msg_format_rec_checkbtn, FALSE, FALSE, 0);
1539 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, gtk_label_new(_("Compose")));
1540
1541 /* reply format */
1542 vbox = gtk_vbox_new (FALSE, VSPACING);
1543 gtk_widget_show (vbox);
1544 gtk_container_set_border_width (GTK_CONTAINER (vbox), VBOX_BORDER);
1545
1546 quotefmt_create_reply_fmt_widgets(
1547 window,
1548 vbox,
1549 &page->checkbtn_reply_with_format,
1550 &page->reply_override_from_format,
1551 &page->reply_quotemark,
1552 &page->reply_body_format,
1553 FALSE, FALSE);
1554 address_completion_register_entry(GTK_ENTRY(page->reply_override_from_format),
1555 TRUE);
1556
1557 vbox_format = gtk_widget_get_parent(
1558 gtk_widget_get_parent(page->reply_body_format));
1559
1560 hbox = gtk_hbox_new (FALSE, 0);
1561 gtk_box_pack_end (GTK_BOX(vbox_format), hbox, FALSE, FALSE, 0);
1562 quotefmt_add_info_button(window, hbox);
1563
1564 reply_format_rec_checkbtn = gtk_check_button_new_with_label(
1565 _("Apply to subfolders"));
1566 gtk_box_pack_end (GTK_BOX(hbox), reply_format_rec_checkbtn, FALSE, FALSE, 0);
1567 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, gtk_label_new(_("Reply")));
1568
1569 /* forward format */
1570 vbox = gtk_vbox_new (FALSE, VSPACING);
1571 gtk_widget_show (vbox);
1572 gtk_container_set_border_width (GTK_CONTAINER (vbox), VBOX_BORDER);
1573
1574 quotefmt_create_forward_fmt_widgets(
1575 window,
1576 vbox,
1577 &page->checkbtn_forward_with_format,
1578 &page->forward_override_from_format,
1579 &page->forward_quotemark,
1580 &page->forward_body_format,
1581 FALSE, FALSE);
1582 address_completion_register_entry(GTK_ENTRY(page->forward_override_from_format),
1583 TRUE);
1584
1585 vbox_format = gtk_widget_get_parent(
1586 gtk_widget_get_parent(page->forward_body_format));
1587
1588 hbox = gtk_hbox_new (FALSE, 0);
1589 gtk_box_pack_end (GTK_BOX(vbox_format), hbox, FALSE, FALSE, 0);
1590 quotefmt_add_info_button(window, hbox);
1591
1592 forward_format_rec_checkbtn = gtk_check_button_new_with_label(
1593 _("Apply to subfolders"));
1594 gtk_box_pack_end (GTK_BOX(hbox), forward_format_rec_checkbtn, FALSE, FALSE, 0);
1595 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, gtk_label_new(_("Forward")));
1596
1597 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(page->checkbtn_compose_with_format),
1598 item->prefs->compose_with_format);
1599 pref_set_entry_from_pref(GTK_ENTRY(page->compose_override_from_format),
1600 item->prefs->compose_override_from_format);
1601 pref_set_entry_from_pref(GTK_ENTRY(page->compose_subject_format),
1602 item->prefs->compose_subject_format);
1603 pref_set_textview_from_pref(GTK_TEXT_VIEW(page->compose_body_format),
1604 item->prefs->compose_body_format);
1605
1606 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(page->checkbtn_reply_with_format),
1607 item->prefs->reply_with_format);
1608 pref_set_entry_from_pref(GTK_ENTRY(page->reply_quotemark),
1609 item->prefs->reply_quotemark);
1610 pref_set_entry_from_pref(GTK_ENTRY(page->reply_override_from_format),
1611 item->prefs->reply_override_from_format);
1612 pref_set_textview_from_pref(GTK_TEXT_VIEW(page->reply_body_format),
1613 item->prefs->reply_body_format);
1614
1615 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(page->checkbtn_forward_with_format),
1616 item->prefs->forward_with_format);
1617 pref_set_entry_from_pref(GTK_ENTRY(page->forward_quotemark),
1618 item->prefs->forward_quotemark);
1619 pref_set_entry_from_pref(GTK_ENTRY(page->forward_override_from_format),
1620 item->prefs->forward_override_from_format);
1621 pref_set_textview_from_pref(GTK_TEXT_VIEW(page->forward_body_format),
1622 item->prefs->forward_body_format);
1623
1624 gtk_widget_show_all(page_vbox);
1625
1626 page->window = GTK_WIDGET(window);
1627
1628 page->new_msg_format_rec_checkbtn = new_msg_format_rec_checkbtn;
1629 page->reply_format_rec_checkbtn = reply_format_rec_checkbtn;
1630 page->forward_format_rec_checkbtn = forward_format_rec_checkbtn;
1631
1632 page->page.widget = page_vbox;
1633 }
1634
prefs_folder_item_templates_destroy_widget_func(PrefsPage * page_)1635 static void prefs_folder_item_templates_destroy_widget_func(PrefsPage *page_)
1636 {
1637 FolderItemTemplatesPage *page = (FolderItemTemplatesPage *) page_;
1638
1639 if (page->compose_override_from_format)
1640 address_completion_unregister_entry(GTK_ENTRY(page->compose_override_from_format));
1641 if (page->reply_override_from_format)
1642 address_completion_unregister_entry(GTK_ENTRY(page->reply_override_from_format));
1643 if (page->forward_override_from_format)
1644 address_completion_unregister_entry(GTK_ENTRY(page->forward_override_from_format));
1645 }
1646
1647 /** \brief Save the prefs in page to folder.
1648 *
1649 * If the folder is not the one specified in page->item, then only those properties
1650 * that have the relevant 'apply to sub folders' button checked are saved
1651 */
templates_save_folder_prefs(FolderItem * folder,FolderItemTemplatesPage * page)1652 static void templates_save_folder_prefs(FolderItem *folder, FolderItemTemplatesPage *page)
1653 {
1654 FolderItemPrefs *prefs = folder->prefs;
1655 gboolean all = FALSE;
1656
1657 if (folder->path == NULL)
1658 return;
1659
1660 if (page->item == folder)
1661 all = TRUE;
1662
1663 cm_return_if_fail(prefs != NULL);
1664
1665 /* save and check formats */
1666
1667 if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->new_msg_format_rec_checkbtn))) {
1668
1669 prefs->compose_with_format =
1670 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_compose_with_format));
1671 prefs->compose_override_from_format = pref_get_pref_from_entry(
1672 GTK_ENTRY(page->compose_override_from_format));
1673 prefs->compose_subject_format = pref_get_pref_from_entry(
1674 GTK_ENTRY(page->compose_subject_format));
1675 prefs->compose_body_format = pref_get_pref_from_textview(
1676 GTK_TEXT_VIEW(page->compose_body_format));
1677 quotefmt_check_new_msg_formats(prefs->compose_with_format,
1678 prefs->compose_override_from_format,
1679 prefs->compose_subject_format,
1680 prefs->compose_body_format);
1681 }
1682
1683 if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->reply_format_rec_checkbtn))) {
1684 prefs->reply_with_format =
1685 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_reply_with_format));
1686 prefs->reply_quotemark = gtk_editable_get_chars(
1687 GTK_EDITABLE(page->reply_quotemark), 0, -1);
1688 prefs->reply_override_from_format = pref_get_pref_from_entry(
1689 GTK_ENTRY(page->reply_override_from_format));
1690 prefs->reply_body_format = pref_get_pref_from_textview(
1691 GTK_TEXT_VIEW(page->reply_body_format));
1692 quotefmt_check_reply_formats(prefs->reply_with_format,
1693 prefs->reply_override_from_format,
1694 prefs->reply_quotemark,
1695 prefs->reply_body_format);
1696 }
1697
1698 if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->forward_format_rec_checkbtn))) {
1699 prefs->forward_with_format =
1700 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_forward_with_format));
1701 prefs->forward_quotemark = gtk_editable_get_chars(
1702 GTK_EDITABLE(page->forward_quotemark), 0, -1);
1703 prefs->forward_override_from_format = pref_get_pref_from_entry(
1704 GTK_ENTRY(page->forward_override_from_format));
1705 prefs->forward_body_format = pref_get_pref_from_textview(
1706 GTK_TEXT_VIEW(page->forward_body_format));
1707 quotefmt_check_forward_formats(prefs->forward_with_format,
1708 prefs->forward_override_from_format,
1709 prefs->forward_quotemark,
1710 prefs->forward_body_format);
1711 }
1712
1713 folder_item_prefs_save_config(folder);
1714 }
1715
templates_save_recurse_func(GNode * node,gpointer data)1716 static gboolean templates_save_recurse_func(GNode *node, gpointer data)
1717 {
1718 FolderItem *item = (FolderItem *) node->data;
1719 FolderItemTemplatesPage *page = (FolderItemTemplatesPage *) data;
1720
1721 cm_return_val_if_fail(item != NULL, TRUE);
1722 cm_return_val_if_fail(page != NULL, TRUE);
1723
1724 templates_save_folder_prefs(item, page);
1725
1726 /* optimise by not continuing if none of the 'apply to sub folders'
1727 check boxes are selected - and optimise the checking by only doing
1728 it once */
1729 if ((node == page->item->node) &&
1730 !(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->new_msg_format_rec_checkbtn)) ||
1731 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->reply_format_rec_checkbtn)) ||
1732 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->forward_format_rec_checkbtn))))
1733 return TRUE;
1734 else
1735 return FALSE;
1736
1737 return FALSE;
1738 }
1739
prefs_folder_item_templates_save_func(PrefsPage * page_)1740 static void prefs_folder_item_templates_save_func(PrefsPage *page_)
1741 {
1742 FolderItemTemplatesPage *page = (FolderItemTemplatesPage *) page_;
1743
1744 g_node_traverse(page->item->node, G_PRE_ORDER, G_TRAVERSE_ALL,
1745 -1, templates_save_recurse_func, page);
1746
1747 }
1748
prefs_folder_item_chmod_mode(gchar * folder_chmod)1749 static gint prefs_folder_item_chmod_mode(gchar *folder_chmod)
1750 {
1751 gint newmode = 0;
1752 gchar *tmp;
1753
1754 if (folder_chmod) {
1755 newmode = strtol(folder_chmod, &tmp, 8);
1756 if (!(*(folder_chmod) && !(*tmp)))
1757 newmode = 0;
1758 }
1759
1760 return newmode;
1761 }
1762
folder_color_set_dialog(GtkWidget * widget,gpointer data)1763 static void folder_color_set_dialog(GtkWidget *widget, gpointer data)
1764 {
1765 FolderItemGeneralPage *page = (FolderItemGeneralPage *) data;
1766 gint rgbcolor;
1767
1768 rgbcolor = colorsel_select_color_rgb(_("Pick color for folder"),
1769 page->folder_color);
1770 gtkut_set_widget_bgcolor_rgb(page->folder_color_btn, rgbcolor);
1771 page->folder_color = rgbcolor;
1772 }
1773
clean_cache_cb(GtkWidget * widget,gpointer data)1774 static void clean_cache_cb(GtkWidget *widget, gpointer data)
1775 {
1776 FolderItemGeneralPage *page = (FolderItemGeneralPage *) data;
1777 FolderItem *item = page->item;
1778 gboolean was_open = FALSE;
1779 FolderView *folderview = NULL;
1780
1781 if (alertpanel_full(_("Discard cache"),
1782 _("Do you really want to discard the local cached "
1783 "data for this folder?"),
1784 GTK_STOCK_CANCEL, _("Discard"), NULL, ALERTFOCUS_SECOND,
1785 FALSE, NULL, ALERT_WARNING)
1786 != G_ALERTALTERNATE)
1787 return;
1788
1789 if (mainwindow_get_mainwindow())
1790 folderview = mainwindow_get_mainwindow()->folderview;
1791
1792 if (folderview && item->opened) {
1793 folderview_close_opened(folderview, FALSE);
1794 was_open = TRUE;
1795 }
1796 folder_item_discard_cache(item);
1797 if (was_open)
1798 folderview_select(folderview,item);
1799 }
1800
summary_compile_simplify_regexp(gchar * simplify_subject_regexp)1801 static regex_t *summary_compile_simplify_regexp(gchar *simplify_subject_regexp)
1802 {
1803 int err;
1804 gchar buf[BUFFSIZE];
1805 regex_t *preg = NULL;
1806
1807 preg = g_new0(regex_t, 1);
1808
1809 err = string_match_precompile(simplify_subject_regexp,
1810 preg, REG_EXTENDED);
1811 if (err) {
1812 regerror(err, preg, buf, BUFFSIZE);
1813 g_free(preg);
1814 preg = NULL;
1815 }
1816
1817 return preg;
1818 }
1819
folder_regexp_test_cb(GtkWidget * widget,gpointer data)1820 static void folder_regexp_test_cb(GtkWidget *widget, gpointer data)
1821 {
1822 static GdkColor red;
1823 static gboolean colors_initialised = FALSE;
1824 static gchar buf[BUFFSIZE];
1825 FolderItemGeneralPage *page = (FolderItemGeneralPage *)data;
1826 gchar *test_string, *regexp;
1827 regex_t *preg;
1828
1829 regexp = g_strdup(gtk_entry_get_text(GTK_ENTRY(page->entry_simplify_subject)));
1830 test_string = g_strdup(gtk_entry_get_text(GTK_ENTRY(page->entry_regexp_test_string)));
1831
1832 if (!regexp || !regexp[0]) {
1833 gtk_widget_modify_base(page->entry_simplify_subject,
1834 GTK_STATE_NORMAL, NULL);
1835 if (test_string)
1836 gtk_entry_set_text(GTK_ENTRY(page->entry_regexp_test_result), test_string);
1837
1838 g_free(test_string);
1839 g_free(regexp);
1840 return;
1841 }
1842
1843 if (!test_string || !test_string[0]) {
1844 g_free(test_string);
1845 g_free(regexp);
1846 return;
1847 }
1848
1849 if (!colors_initialised) {
1850 if (!gdk_color_parse("#ff7070", &red)) {
1851 g_warning("color parse failed: red");
1852 return;
1853 }
1854 colors_initialised = gdk_colormap_alloc_color(
1855 gdk_colormap_get_system(), &red, FALSE, TRUE);
1856 }
1857
1858 preg = summary_compile_simplify_regexp(regexp);
1859 if (colors_initialised)
1860 gtk_widget_modify_base(page->entry_simplify_subject,
1861 GTK_STATE_NORMAL, preg ? NULL : &red);
1862
1863 if (preg != NULL) {
1864 string_remove_match(buf, BUFFSIZE, test_string, preg);
1865
1866 gtk_entry_set_text(GTK_ENTRY(page->entry_regexp_test_result), buf);
1867
1868 regfree(preg);
1869 g_free(preg);
1870 }
1871
1872 g_free(test_string);
1873 g_free(regexp);
1874 }
1875
folder_regexp_get_subject_example(void)1876 static gchar *folder_regexp_get_subject_example(void)
1877 {
1878 MsgInfo *msginfo_selected;
1879 SummaryView *summaryview = NULL;
1880
1881 if (!mainwindow_get_mainwindow())
1882 return NULL;
1883 summaryview = mainwindow_get_mainwindow()->summaryview;
1884
1885 msginfo_selected = summary_get_selected_msg(summaryview);
1886 return msginfo_selected ? g_strdup(msginfo_selected->subject) : NULL;
1887 }
1888
folder_regexp_set_subject_example_cb(GtkWidget * widget,gpointer data)1889 static void folder_regexp_set_subject_example_cb(GtkWidget *widget, gpointer data)
1890 {
1891 FolderItemGeneralPage *page = (FolderItemGeneralPage *)data;
1892
1893 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_simplify_subject))) {
1894 gchar *subject = folder_regexp_get_subject_example();
1895 if (subject) {
1896 gtk_entry_set_text(GTK_ENTRY(page->entry_regexp_test_string), subject);
1897 g_free(subject);
1898 }
1899 }
1900 }
1901
register_general_page()1902 static void register_general_page()
1903 {
1904 static gchar *pfi_general_path[2];
1905 static FolderItemGeneralPage folder_item_general_page;
1906
1907 pfi_general_path[0] = _("General");
1908 pfi_general_path[1] = NULL;
1909
1910 folder_item_general_page.page.path = pfi_general_path;
1911 folder_item_general_page.page.create_widget = prefs_folder_item_general_create_widget_func;
1912 folder_item_general_page.page.destroy_widget = prefs_folder_item_general_destroy_widget_func;
1913 folder_item_general_page.page.save_page = prefs_folder_item_general_save_func;
1914
1915 prefs_folder_item_register_page((PrefsPage *) &folder_item_general_page, NULL);
1916 }
1917
1918
register_compose_page(void)1919 static void register_compose_page(void)
1920 {
1921 static gchar *pfi_compose_path[2];
1922 static FolderItemComposePage folder_item_compose_page;
1923
1924 pfi_compose_path[0] = _("Compose");
1925 pfi_compose_path[1] = NULL;
1926
1927 folder_item_compose_page.page.path = pfi_compose_path;
1928 folder_item_compose_page.page.create_widget = prefs_folder_item_compose_create_widget_func;
1929 folder_item_compose_page.page.destroy_widget = prefs_folder_item_compose_destroy_widget_func;
1930 folder_item_compose_page.page.save_page = prefs_folder_item_compose_save_func;
1931
1932 prefs_folder_item_register_page((PrefsPage *) &folder_item_compose_page, NULL);
1933 }
1934
register_templates_page(void)1935 static void register_templates_page(void)
1936 {
1937 static gchar *pfi_templates_path[2];
1938 static FolderItemTemplatesPage folder_item_templates_page;
1939
1940 pfi_templates_path[0] = _("Templates");
1941 pfi_templates_path[1] = NULL;
1942
1943 folder_item_templates_page.page.path = pfi_templates_path;
1944 folder_item_templates_page.page.create_widget = prefs_folder_item_templates_create_widget_func;
1945 folder_item_templates_page.page.destroy_widget = prefs_folder_item_templates_destroy_widget_func;
1946 folder_item_templates_page.page.save_page = prefs_folder_item_templates_save_func;
1947
1948 prefs_folder_item_register_page((PrefsPage *) &folder_item_templates_page, NULL);
1949 }
1950
1951 static GSList *prefs_pages = NULL;
1952
prefs_folder_item_address_completion_start(PrefsWindow * window)1953 static void prefs_folder_item_address_completion_start(PrefsWindow *window)
1954 {
1955 address_completion_start(window->window);
1956 }
1957
prefs_folder_item_address_completion_end(PrefsWindow * window)1958 static void prefs_folder_item_address_completion_end(PrefsWindow *window)
1959 {
1960 address_completion_end(window->window);
1961 }
1962
prefs_folder_item_open(FolderItem * item)1963 void prefs_folder_item_open(FolderItem *item)
1964 {
1965 gchar *id, *title;
1966 GSList *pages;
1967
1968 if (prefs_pages == NULL) {
1969 register_general_page();
1970 register_compose_page();
1971 register_templates_page();
1972 }
1973
1974 if (item->path) {
1975 id = folder_item_get_identifier (item);
1976 can_save = TRUE;
1977 } else {
1978 id = g_strdup(item->name);
1979 can_save = FALSE;
1980 }
1981
1982 pages = g_slist_concat(
1983 g_slist_copy(prefs_pages),
1984 g_slist_copy(item->folder->klass->prefs_pages));
1985
1986 title = g_strdup_printf (_("Properties for folder %s"), id);
1987 g_free (id);
1988 prefswindow_open(title, pages, item,
1989 &prefs_common.folderitemwin_width, &prefs_common.folderitemwin_height,
1990 prefs_folder_item_address_completion_start,
1991 NULL,
1992 prefs_folder_item_address_completion_end);
1993
1994 g_slist_free(pages);
1995 g_free (title);
1996 }
1997
prefs_folder_item_register_page(PrefsPage * page,FolderClass * klass)1998 void prefs_folder_item_register_page(PrefsPage *page, FolderClass *klass)
1999 {
2000 if (klass != NULL)
2001 klass->prefs_pages = g_slist_append(klass->prefs_pages, page);
2002 else
2003 prefs_pages = g_slist_append(prefs_pages, page);
2004 }
2005
prefs_folder_item_unregister_page(PrefsPage * page,FolderClass * klass)2006 void prefs_folder_item_unregister_page(PrefsPage *page, FolderClass *klass)
2007 {
2008 if (klass != NULL)
2009 klass->prefs_pages = g_slist_remove(klass->prefs_pages, page);
2010 else
2011 prefs_pages = g_slist_remove(prefs_pages, page);
2012 }
2013