move 'msg selection when entering a folder" button to Message List page
[claws.git] / src / prefs_summaries.c
1 /*
2  * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 2005-2018 Colin Leroy 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 #ifdef HAVE_CONFIG_H
20 #  include "config.h"
21 #include "claws-features.h"
22 #endif
23
24 #include "defs.h"
25
26 #include <stdio.h>
27 #include <stdlib.h>
28
29 #include <glib.h>
30 #include <glib/gi18n.h>
31 #include <gtk/gtk.h>
32 #include <gdk/gdkkeysyms.h>
33
34 #ifdef G_OS_WIN32
35 #  include <w32lib.h>
36 #endif
37
38 #include "prefs_common.h"
39 #include "prefs_gtk.h"
40 #include "prefs_summary_open.h"
41 #include "prefs_summary_column.h"
42 #include "prefs_folder_column.h"
43
44 #include "gtk/menu.h"
45 #include "gtk/gtkutils.h"
46 #include "gtk/prefswindow.h"
47 #include "gtk/combobox.h"
48
49 #include "manage_window.h"
50
51 typedef struct _SummariesPage
52 {
53         PrefsPage page;
54
55         GtkWidget *window;
56
57         GtkWidget *optmenu_folder_unread;
58         GtkWidget *spinbtn_ng_abbrev_len;
59         GtkWidget *checkbtn_useaddrbook;
60         GtkWidget *checkbtn_show_tooltips;
61         GtkWidget *checkbtn_threadsubj;
62         GtkWidget *button_datefmt;
63         GtkWidget *entry_datefmt;
64
65         GtkWidget *checkbtn_reopen_last_folder;
66         GtkWidget *checkbtn_always_show_msg;
67         GtkWidget *checkbtn_show_on_folder_open;
68         GtkWidget *checkbtn_show_on_search_results;
69         GtkWidget *checkbtn_show_on_prevnext;
70         GtkWidget *checkbtn_show_on_deletemove;
71         GtkWidget *checkbtn_show_on_directional;
72         GtkWidget *checkbtn_mark_as_read_on_newwin;
73         GtkWidget *spinbtn_mark_as_read_delay;
74         GtkWidget *checkbtn_immedexec;
75         GtkWidget *checkbtn_ask_mark_all_read;
76         GtkWidget *checkbtn_ask_override_colorlabel;
77         GtkWidget *optmenu_sort_key;
78         GtkWidget *optmenu_sort_type;
79         GtkWidget *optmenu_nextunreadmsgdialog;
80         GtkWidget *checkbtn_folder_default_thread;
81         GtkWidget *checkbtn_folder_default_thread_collapsed;
82         GtkWidget *checkbtn_folder_default_hide_read_threads;
83         GtkWidget *checkbtn_folder_default_hide_read_msgs;
84         GtkWidget *checkbtn_folder_default_hide_del_msgs;
85
86 } SummariesPage;
87
88 enum {
89         DATEFMT_FMT,
90         DATEFMT_TXT,
91         N_DATEFMT_COLUMNS
92 };
93
94 static void date_format_ok_btn_clicked          (GtkButton      *button,
95                                                  GtkWidget     **widget);
96 static void date_format_cancel_btn_clicked      (GtkButton      *button,
97                                                  GtkWidget     **widget);
98 static gboolean date_format_key_pressed         (GtkWidget      *keywidget,
99                                                  GdkEventKey    *event,
100                                                  GtkWidget     **widget);
101 static gboolean date_format_on_delete           (GtkWidget      *dialogwidget,
102                                                  GdkEventAny    *event,
103                                                  GtkWidget     **widget);
104 static void date_format_entry_on_change         (GtkEditable    *editable,
105                                                  GtkLabel       *example);
106 static void date_format_select_row              (GtkTreeView *list_view,
107                                                  GtkTreePath *path,
108                                                  GtkTreeViewColumn *column,
109                                                  GtkWidget *date_format);
110 static void mark_as_read_toggled                (GtkToggleButton *button,
111                                                  GtkWidget *spinbtn);
112 static void always_show_msg_toggled             (GtkToggleButton *button,
113                                                  gpointer user_data);
114
115 static GtkWidget *date_format_create(GtkButton *button, void *data)
116 {
117         static GtkWidget *datefmt_win = NULL;
118
119         GtkWidget *vbox1;
120         GtkWidget *scrolledwindow1;
121         GtkWidget *datefmt_list_view;
122         GtkWidget *table;
123         GtkWidget *label1;
124         GtkWidget *label2;
125         GtkWidget *label3;
126         GtkWidget *confirm_area;
127         GtkWidget *ok_btn;
128         GtkWidget *cancel_btn;
129         GtkWidget *datefmt_entry;
130         GtkListStore *store;
131
132         struct {
133                 gchar *fmt;
134                 gchar *txt;
135         } time_format[] = {
136                 { "%a", NULL },
137                 { "%A", NULL },
138                 { "%b", NULL },
139                 { "%B", NULL },
140                 { "%c", NULL },
141                 { "%C", NULL },
142                 { "%d", NULL },
143                 { "%H", NULL },
144                 { "%I", NULL },
145                 { "%j", NULL },
146                 { "%m", NULL },
147                 { "%M", NULL },
148                 { "%p", NULL },
149                 { "%S", NULL },
150                 { "%w", NULL },
151                 { "%x", NULL },
152                 { "%y", NULL },
153                 { "%Y", NULL },
154                 { "%Z", NULL }
155         };
156
157         gint i;
158         const gint TIME_FORMAT_ELEMS =
159                 sizeof time_format / sizeof time_format[0];
160
161         GtkCellRenderer *renderer;
162         GtkTreeViewColumn *column;
163         GtkTreeSelection *selection;
164
165         time_format[0].txt  = _("the abbreviated weekday name");
166         time_format[1].txt  = _("the full weekday name");
167         time_format[2].txt  = _("the abbreviated month name");
168         time_format[3].txt  = _("the full month name");
169         time_format[4].txt  = _("the preferred date and time for the current locale");
170         time_format[5].txt  = _("the century number (year/100)");
171         time_format[6].txt  = _("the day of the month as a decimal number");
172         time_format[7].txt  = _("the hour as a decimal number using a 24-hour clock");
173         time_format[8].txt  = _("the hour as a decimal number using a 12-hour clock");
174         time_format[9].txt  = _("the day of the year as a decimal number");
175         time_format[10].txt = _("the month as a decimal number");
176         time_format[11].txt = _("the minute as a decimal number");
177         time_format[12].txt = _("either AM or PM");
178         time_format[13].txt = _("the second as a decimal number");
179         time_format[14].txt = _("the day of the week as a decimal number");
180         time_format[15].txt = _("the preferred date for the current locale");
181         time_format[16].txt = _("the last two digits of a year");
182         time_format[17].txt = _("the year as a decimal number");
183         time_format[18].txt = _("the time zone or name or abbreviation");
184
185         if (datefmt_win) return datefmt_win;
186
187         store = gtk_list_store_new(N_DATEFMT_COLUMNS,
188                                    G_TYPE_STRING,
189                                    G_TYPE_STRING,
190                                    -1);
191
192         for (i = 0; i < TIME_FORMAT_ELEMS; i++) {
193                 GtkTreeIter iter;
194
195                 gtk_list_store_append(store, &iter);
196                 gtk_list_store_set(store, &iter,
197                                    DATEFMT_FMT, time_format[i].fmt,
198                                    DATEFMT_TXT, time_format[i].txt,
199                                    -1);
200         }
201
202         datefmt_win = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "prefs_summaries");
203         gtk_container_set_border_width(GTK_CONTAINER(datefmt_win), 8);
204         gtk_window_set_title(GTK_WINDOW(datefmt_win), _("Date format"));
205         gtk_window_set_position(GTK_WINDOW(datefmt_win), GTK_WIN_POS_CENTER);
206         gtk_widget_set_size_request(datefmt_win, 440, 280);
207
208         vbox1 = gtk_vbox_new(FALSE, 10);
209         gtk_widget_show(vbox1);
210         gtk_container_add(GTK_CONTAINER(datefmt_win), vbox1);
211
212         scrolledwindow1 = gtk_scrolled_window_new(NULL, NULL);
213         gtk_scrolled_window_set_policy
214                 (GTK_SCROLLED_WINDOW(scrolledwindow1),
215                  GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
216         gtk_widget_show(scrolledwindow1);
217         gtk_box_pack_start(GTK_BOX(vbox1), scrolledwindow1, TRUE, TRUE, 0);
218
219         datefmt_list_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
220         g_object_unref(G_OBJECT(store));
221         gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(datefmt_list_view),
222                                      prefs_common.use_stripes_everywhere);
223         gtk_widget_show(datefmt_list_view);
224         gtk_container_add(GTK_CONTAINER(scrolledwindow1), datefmt_list_view);
225
226         renderer = gtk_cell_renderer_text_new();
227         column = gtk_tree_view_column_new_with_attributes
228                         (_("Specifier"), renderer, "text", DATEFMT_FMT,
229                          NULL);
230         gtk_tree_view_append_column(GTK_TREE_VIEW(datefmt_list_view), column);
231         
232         renderer = gtk_cell_renderer_text_new();
233         column = gtk_tree_view_column_new_with_attributes
234                         (_("Description"), renderer, "text", DATEFMT_TXT,
235                          NULL);
236         gtk_tree_view_append_column(GTK_TREE_VIEW(datefmt_list_view), column);
237         
238         /* gtk_cmclist_set_column_width(GTK_CMCLIST(datefmt_clist), 0, 80); */
239         selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(datefmt_list_view));
240         gtk_tree_selection_set_mode(selection, GTK_SELECTION_BROWSE);
241
242         g_signal_connect(G_OBJECT(datefmt_list_view), "row_activated", 
243                          G_CALLBACK(date_format_select_row),
244                          datefmt_win);
245         
246         table = gtk_table_new(2, 2, FALSE);
247         gtk_widget_show(table);
248         gtk_box_pack_start(GTK_BOX(vbox1), table, FALSE, FALSE, 0);
249         gtk_table_set_row_spacings(GTK_TABLE(table), 4);
250         gtk_table_set_col_spacings(GTK_TABLE(table), 8);
251
252         label1 = gtk_label_new(_("Date format"));
253         gtk_widget_show(label1);
254         gtk_table_attach(GTK_TABLE(table), label1, 0, 1, 0, 1,
255                          GTK_FILL, 0, 0, 0);
256         gtk_label_set_justify(GTK_LABEL(label1), GTK_JUSTIFY_LEFT);
257         gtk_misc_set_alignment(GTK_MISC(label1), 0, 0.5);
258
259         datefmt_entry = gtk_entry_new();
260         gtk_entry_set_max_length(GTK_ENTRY(datefmt_entry), 256);
261         gtk_widget_show(datefmt_entry);
262         gtk_table_attach(GTK_TABLE(table), datefmt_entry, 1, 2, 0, 1,
263                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
264
265         /* we need the "sample" entry box; add it as data so callbacks can
266          * get the entry box */
267         g_object_set_data(G_OBJECT(datefmt_win), "datefmt_sample",
268                           datefmt_entry);
269
270         label2 = gtk_label_new(_("Example"));
271         gtk_widget_show(label2);
272         gtk_table_attach(GTK_TABLE(table), label2, 0, 1, 1, 2,
273                          GTK_FILL, 0, 0, 0);
274         gtk_label_set_justify(GTK_LABEL(label2), GTK_JUSTIFY_LEFT);
275         gtk_misc_set_alignment(GTK_MISC(label2), 0, 0.5);
276
277         label3 = gtk_label_new("");
278         gtk_widget_show(label3);
279         gtk_table_attach(GTK_TABLE(table), label3, 1, 2, 1, 2,
280                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
281         gtk_label_set_justify(GTK_LABEL(label3), GTK_JUSTIFY_LEFT);
282         gtk_misc_set_alignment(GTK_MISC(label3), 0, 0.5);
283
284         gtkut_stock_button_set_create(&confirm_area, &cancel_btn, GTK_STOCK_CANCEL,
285                                       &ok_btn, GTK_STOCK_OK, NULL, NULL);
286
287         gtk_box_pack_start(GTK_BOX(vbox1), confirm_area, FALSE, FALSE, 0);
288         gtk_widget_show(confirm_area);
289         gtk_widget_grab_default(ok_btn);
290
291         /* set the current format */
292         gtk_entry_set_text(GTK_ENTRY(datefmt_entry), prefs_common.date_format);
293         date_format_entry_on_change(GTK_EDITABLE(datefmt_entry),
294                                     GTK_LABEL(label3));
295
296         g_signal_connect(G_OBJECT(ok_btn), "clicked",
297                          G_CALLBACK(date_format_ok_btn_clicked),
298                          &datefmt_win);
299         g_signal_connect(G_OBJECT(cancel_btn), "clicked",
300                          G_CALLBACK(date_format_cancel_btn_clicked),
301                          &datefmt_win);
302         g_signal_connect(G_OBJECT(datefmt_win), "key_press_event",
303                          G_CALLBACK(date_format_key_pressed),
304                          &datefmt_win);
305         g_signal_connect(G_OBJECT(datefmt_win), "delete_event",
306                          G_CALLBACK(date_format_on_delete),
307                          &datefmt_win);
308         g_signal_connect(G_OBJECT(datefmt_entry), "changed",
309                          G_CALLBACK(date_format_entry_on_change),
310                          label3);
311
312         gtk_widget_show(datefmt_win);
313         manage_window_set_transient(GTK_WINDOW(datefmt_win));
314         gtk_window_set_modal(GTK_WINDOW(datefmt_win), TRUE);
315
316         gtk_widget_grab_focus(ok_btn);
317
318         return datefmt_win;
319 }
320
321 static void prefs_summaries_create_widget(PrefsPage *_page, GtkWindow *window, 
322                                   gpointer data)
323 {
324         SummariesPage *prefs_summaries = (SummariesPage *) _page;
325         
326         GtkWidget *notebook;
327         GtkWidget *hbox0, *hbox1, *hbox2;
328         GtkWidget *vbox1, *vbox2, *vbox3, *vbox4;
329         GtkWidget *frame_new_folders;
330         GtkWidget *optmenu_folder_unread;
331         GtkWidget *label_ng_abbrev;
332         GtkWidget *spinbtn_ng_abbrev_len;
333         GtkAdjustment *spinbtn_ng_abbrev_len_adj;
334         GtkWidget *checkbtn_useaddrbook;
335         GtkWidget *checkbtn_show_tooltips;
336         GtkWidget *checkbtn_threadsubj;
337         GtkWidget *label_datefmt;
338         GtkWidget *button_datefmt;
339         GtkWidget *entry_datefmt;
340         GtkWidget *hbox_dispitem;
341         GtkWidget *button_dispitem;
342         GtkWidget *checkbtn_reopen_last_folder;
343         GtkWidget *checkbtn_always_show_msg;
344         GtkWidget *checkbtn_show_on_folder_open;
345         GtkWidget *checkbtn_show_on_search_results;
346         GtkWidget *checkbtn_show_on_prevnext;
347         GtkWidget *checkbtn_show_on_deletemove;
348         GtkWidget *checkbtn_show_on_directional;
349         GtkWidget *spinbtn_mark_as_read_delay;
350         GtkAdjustment *spinbtn_mark_as_read_delay_adj;
351         GtkWidget *checkbtn_immedexec;
352         GtkWidget *checkbtn_ask_mark_all_read;
353         GtkWidget *checkbtn_ask_override_colorlabel;
354         GtkWidget *label, *label_fill;
355         GtkListStore *menu;
356         GtkTreeIter iter;
357         GtkWidget *optmenu_nextunreadmsgdialog;
358         GtkWidget *button_edit_actions;
359         GtkWidget *radio_mark_as_read_on_select;
360         GtkWidget *radio_mark_as_read_on_new_win;
361         GtkWidget *optmenu_sort_key;
362         GtkWidget *optmenu_sort_type;
363         GtkWidget *checkbtn_folder_default_thread;
364         GtkWidget *checkbtn_folder_default_thread_collapsed;
365         GtkWidget *checkbtn_folder_default_hide_read_threads;
366         GtkWidget *checkbtn_folder_default_hide_read_msgs;
367         GtkWidget *checkbtn_folder_default_hide_del_msgs;
368
369         notebook = gtk_notebook_new();
370         gtk_widget_show(notebook);
371
372         vbox1 = gtk_vbox_new (FALSE, VSPACING);
373         gtk_widget_show (vbox1);
374         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
375         gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox1,
376                                  gtk_label_new(_("Folder list")));
377         
378         hbox_dispitem = gtk_hbox_new (FALSE, 8);
379         gtk_widget_show (hbox_dispitem);
380         gtk_box_pack_start(GTK_BOX(vbox1), hbox_dispitem, FALSE, TRUE, 0);
381
382         label = gtk_label_new(_("Displayed columns"));
383         gtk_widget_show(label);
384         gtk_box_pack_start(GTK_BOX(hbox_dispitem), label, FALSE, FALSE, 0);
385         button_dispitem = gtk_button_new_from_stock(GTK_STOCK_EDIT);
386         gtk_widget_show (button_dispitem);
387         gtk_box_pack_start (GTK_BOX (hbox_dispitem), button_dispitem, FALSE, FALSE, 0);
388         g_signal_connect (G_OBJECT (button_dispitem), "clicked",
389                           G_CALLBACK (prefs_folder_column_open),
390                           NULL);
391
392         hbox0 = gtk_hbox_new (FALSE, 8);
393         gtk_widget_show (hbox0);
394         gtk_box_pack_start(GTK_BOX (vbox1), hbox0, FALSE, FALSE, 0);
395
396         label = gtk_label_new (_("Display message count next to folder name"));
397         gtk_widget_show (label);
398         gtk_box_pack_start(GTK_BOX(hbox0), label, FALSE, FALSE, 0);
399
400         optmenu_folder_unread = gtkut_sc_combobox_create(NULL, FALSE);
401         menu = GTK_LIST_STORE(gtk_combo_box_get_model(
402                                 GTK_COMBO_BOX(optmenu_folder_unread)));
403         gtk_widget_show (optmenu_folder_unread);
404         
405         COMBOBOX_ADD (menu, _("No"), 0);
406         COMBOBOX_ADD (menu, _("Unread messages"), 1);
407         COMBOBOX_ADD (menu, _("Unread and Total messages"), 2);
408
409         gtk_box_pack_start(GTK_BOX(hbox0), optmenu_folder_unread, FALSE, FALSE, 0);
410
411         PACK_CHECK_BUTTON
412                 (vbox1, checkbtn_reopen_last_folder,
413                  _("Open last opened folder at start-up"));
414
415         hbox1 = gtk_hbox_new (FALSE, 8);
416         gtk_widget_show (hbox1);
417         gtk_box_pack_start(GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
418
419         label_ng_abbrev = gtk_label_new
420                 (_("Abbreviate newsgroup names longer than"));
421         gtk_widget_show (label_ng_abbrev);
422         gtk_box_pack_start (GTK_BOX (hbox1), label_ng_abbrev, FALSE, FALSE, 0);
423
424         spinbtn_ng_abbrev_len_adj = GTK_ADJUSTMENT(gtk_adjustment_new (16, 0, 999, 1, 10, 0));
425         spinbtn_ng_abbrev_len = gtk_spin_button_new
426                 (GTK_ADJUSTMENT (spinbtn_ng_abbrev_len_adj), 1, 0);
427         gtk_widget_show (spinbtn_ng_abbrev_len);
428         gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_ng_abbrev_len,
429                             FALSE, FALSE, 0);
430         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_ng_abbrev_len),
431                                      TRUE);
432
433         label_ng_abbrev = gtk_label_new (_("letters"));
434         gtk_widget_show (label_ng_abbrev);
435         gtk_box_pack_start (GTK_BOX (hbox1), label_ng_abbrev, FALSE, FALSE, 0);
436
437         vbox1 = gtk_vbox_new (FALSE, VSPACING);
438         gtk_widget_show (vbox1);
439         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
440         gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox1,
441                                  gtk_label_new(_("Message list")));
442
443         hbox_dispitem = gtk_hbox_new (FALSE, 8);
444         gtk_widget_show (hbox_dispitem);
445         gtk_box_pack_start(GTK_BOX(vbox1), hbox_dispitem, FALSE, TRUE, 0);
446         
447         label = gtk_label_new(_("Displayed columns"));
448         gtk_widget_show(label);
449         gtk_box_pack_start(GTK_BOX(hbox_dispitem), label, FALSE, FALSE, 0);
450         button_dispitem = gtk_button_new_from_stock(GTK_STOCK_EDIT);
451         gtk_widget_show (button_dispitem);
452         gtk_box_pack_start (GTK_BOX (hbox_dispitem), button_dispitem, FALSE, FALSE, 0);
453         g_signal_connect (G_OBJECT (button_dispitem), "clicked",
454                           G_CALLBACK (prefs_summary_column_open),
455                           NULL);
456
457         hbox2 = gtk_hbox_new (FALSE, 8);
458         gtk_widget_show (hbox2);
459         gtk_box_pack_start (GTK_BOX (vbox1), hbox2, FALSE, TRUE, 0);
460
461         label_datefmt = gtk_label_new (_("Date format"));
462         gtk_widget_show (label_datefmt);
463         gtk_box_pack_start (GTK_BOX (hbox2), label_datefmt, FALSE, FALSE, 0);
464
465         entry_datefmt = gtk_entry_new ();
466         gtk_widget_show (entry_datefmt);
467         gtk_box_pack_start (GTK_BOX (hbox2), entry_datefmt, FALSE, FALSE, 0);
468
469         button_datefmt = gtk_button_new_from_stock(GTK_STOCK_INFO);
470
471         gtk_widget_show (button_datefmt);
472         gtk_box_pack_start (GTK_BOX (hbox2), button_datefmt, FALSE, FALSE, 0);
473         g_signal_connect (G_OBJECT (button_datefmt), "clicked",
474                           G_CALLBACK (date_format_create), NULL);
475
476         label_fill = gtk_label_new(" ");
477         gtk_box_pack_start(GTK_BOX(hbox2), label_fill, TRUE, FALSE, 0);
478
479         CLAWS_SET_TIP(button_datefmt,
480                              _("Date format help"));
481
482         hbox1 = gtk_hbox_new (FALSE, 10);
483         gtk_widget_show (hbox1);
484         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, TRUE, 0);
485
486         button_edit_actions = gtk_button_new_with_label(_("Set message selection when entering a folder"));
487         gtk_widget_show (button_edit_actions);
488         gtk_box_pack_start (GTK_BOX (hbox1), button_edit_actions,
489                           FALSE, TRUE, 0);
490         g_signal_connect (G_OBJECT (button_edit_actions), "clicked",
491                           G_CALLBACK (prefs_summary_open_open),
492                           NULL);
493
494         /* Open message on select policy */
495         vbox4 = gtkut_get_options_frame(vbox1, NULL, _("Open message when selected"));
496
497         PACK_CHECK_BUTTON(vbox4, checkbtn_always_show_msg,
498                         _("Always"));
499         PACK_CHECK_BUTTON(vbox4, checkbtn_show_on_folder_open,
500                         _("When opening a folder"));
501         PACK_CHECK_BUTTON(vbox4, checkbtn_show_on_search_results,
502                         _("When displaying search results"));
503         PACK_CHECK_BUTTON(vbox4, checkbtn_show_on_prevnext,
504                         _("When selecting next or previous message using shortcuts"));
505         PACK_CHECK_BUTTON(vbox4, checkbtn_show_on_deletemove,
506                         _("When deleting or moving messages"));
507         PACK_CHECK_BUTTON(vbox4, checkbtn_show_on_directional,
508                         _("When using directional keys"));
509
510         vbox3 = gtkut_get_options_frame(vbox1, NULL, _("Mark message as read"));
511
512         radio_mark_as_read_on_select = gtk_radio_button_new_with_label(NULL,
513                         _("when selected, after"));
514
515         hbox1 = gtk_hbox_new (FALSE, 8);
516         gtk_box_pack_start (GTK_BOX (hbox1), radio_mark_as_read_on_select, FALSE, FALSE, 0);
517
518         spinbtn_mark_as_read_delay_adj = GTK_ADJUSTMENT(gtk_adjustment_new (0, 0, 60, 1, 10, 0));
519         spinbtn_mark_as_read_delay = gtk_spin_button_new
520                         (GTK_ADJUSTMENT (spinbtn_mark_as_read_delay_adj), 1, 0);
521         gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_mark_as_read_delay,
522                             FALSE, FALSE, 0);
523         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_mark_as_read_delay),
524                                      TRUE);
525         gtk_box_pack_start (GTK_BOX (hbox1), gtk_label_new
526                         (_("seconds")), FALSE, FALSE, 0);
527
528         gtk_box_pack_start (GTK_BOX (vbox3), hbox1, FALSE, FALSE, 0);
529
530         radio_mark_as_read_on_new_win = gtk_radio_button_new_with_label_from_widget(
531                         GTK_RADIO_BUTTON(radio_mark_as_read_on_select),
532                         _("only when opened in a new window, or replied to"));
533         gtk_box_pack_start (GTK_BOX (vbox3), radio_mark_as_read_on_new_win,
534                         FALSE, FALSE, 0);
535         gtk_widget_show_all(vbox3);
536
537         /* Next Unread Message Dialog */
538         hbox1 = gtk_hbox_new (FALSE, 10);
539         gtk_widget_show (hbox1);
540         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
541
542         label = gtk_label_new (_("Show \"no unread (or new) message\" dialog"));
543         gtk_widget_show (label);
544         gtk_box_pack_start(GTK_BOX(hbox1), label, FALSE, FALSE, 0);
545         
546         optmenu_nextunreadmsgdialog = gtkut_sc_combobox_create(NULL, FALSE);
547         menu = GTK_LIST_STORE(gtk_combo_box_get_model(
548                                 GTK_COMBO_BOX(optmenu_nextunreadmsgdialog)));
549         gtk_widget_show (optmenu_nextunreadmsgdialog);
550
551         COMBOBOX_ADD (menu, _("Always"), NEXTUNREADMSGDIALOG_ALWAYS);
552         COMBOBOX_ADD (menu, _("Assume 'Yes'"), NEXTUNREADMSGDIALOG_ASSUME_YES);
553         COMBOBOX_ADD (menu, _("Assume 'No'"), NEXTUNREADMSGDIALOG_ASSUME_NO);
554
555         gtk_box_pack_start(GTK_BOX(hbox1), optmenu_nextunreadmsgdialog, FALSE, FALSE, 0);
556
557         PACK_CHECK_BUTTON
558                 (vbox1, checkbtn_useaddrbook,
559                  _("Display sender using address book"));
560
561         PACK_CHECK_BUTTON
562                 (vbox1, checkbtn_threadsubj,
563                  _("Thread using subject in addition to standard headers"));
564
565         PACK_CHECK_BUTTON
566                 (vbox1, checkbtn_immedexec,
567                  _("Execute immediately when moving or deleting messages"));
568         CLAWS_SET_TIP(checkbtn_immedexec,
569                              _("When unchecked moving, copying and deleting of messages"
570                                " is deferred until you use 'Tools/Execute'"));
571
572         PACK_CHECK_BUTTON
573                 (vbox1, checkbtn_ask_mark_all_read,
574                  _("Confirm when marking all messages as read or unread"));
575         PACK_CHECK_BUTTON
576                 (vbox1, checkbtn_ask_override_colorlabel,
577                  _("Confirm when changing color labels"));
578         
579         PACK_CHECK_BUTTON
580                 (vbox1, checkbtn_show_tooltips,
581                  _("Show tooltips"));
582
583         hbox2 = gtk_hbox_new (FALSE, 8);
584         gtk_widget_show (hbox2);
585         gtk_box_pack_start (GTK_BOX (vbox1), hbox2, FALSE, FALSE, 0);
586
587         vbox1 = gtk_vbox_new (FALSE, VSPACING);
588         gtk_widget_show (vbox1);
589         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
590         gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox1,
591                                  gtk_label_new(_("Defaults")));
592
593         vbox2 = gtkut_get_options_frame(vbox1, &frame_new_folders, _("New folders"));
594
595         hbox1 = gtk_hbox_new(FALSE, 10);
596         gtk_widget_show(hbox1);
597         gtk_box_pack_start(GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
598
599         label = gtk_label_new(_("Sort by"));
600         gtk_widget_show(label);
601         gtk_box_pack_start(GTK_BOX(hbox1), label, FALSE, FALSE, 0);
602
603         optmenu_sort_key = gtkut_sc_combobox_create(NULL, FALSE);
604         menu = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(optmenu_sort_key)));
605         gtk_widget_show(optmenu_sort_key);
606
607         COMBOBOX_ADD(menu, _("Number"), SORT_BY_NUMBER);
608         COMBOBOX_ADD(menu, _("Size"), SORT_BY_SIZE);
609         COMBOBOX_ADD(menu, _("Date"), SORT_BY_DATE);
610         COMBOBOX_ADD(menu, _("Thread date"), SORT_BY_THREAD_DATE);
611         COMBOBOX_ADD(menu, _("From"), SORT_BY_FROM);
612         COMBOBOX_ADD(menu, _("To"), SORT_BY_TO);
613         COMBOBOX_ADD(menu, _("Subject"), SORT_BY_SUBJECT);
614         COMBOBOX_ADD(menu, _("Color label"), SORT_BY_LABEL);
615         COMBOBOX_ADD(menu, _("Tag"), SORT_BY_TAGS);
616         COMBOBOX_ADD(menu, _("Mark"), SORT_BY_MARK);
617         COMBOBOX_ADD(menu, _("Status"), SORT_BY_STATUS);
618         COMBOBOX_ADD(menu, _("Attachment"), SORT_BY_MIME);
619         COMBOBOX_ADD(menu, _("Score"), SORT_BY_SCORE);
620         COMBOBOX_ADD(menu, _("Locked"), SORT_BY_LOCKED);
621         COMBOBOX_ADD(menu, _("Don't sort"), SORT_BY_NONE);
622
623         gtk_box_pack_start(GTK_BOX(hbox1), optmenu_sort_key, FALSE, FALSE, 0);
624
625         optmenu_sort_type = gtkut_sc_combobox_create(NULL, FALSE);
626         menu = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(optmenu_sort_type)));
627         gtk_widget_show(optmenu_sort_type);
628
629         COMBOBOX_ADD(menu, _("Ascending"), SORT_ASCENDING);
630         COMBOBOX_ADD(menu, _("Descending"), SORT_DESCENDING);
631
632         gtk_box_pack_start(GTK_BOX(hbox1), optmenu_sort_type, FALSE, FALSE, 0);
633
634         PACK_CHECK_BUTTON
635                 (vbox2, checkbtn_folder_default_thread,
636                  _("Enable threads"));
637         PACK_CHECK_BUTTON
638                 (vbox2, checkbtn_folder_default_thread_collapsed,
639                  _("Collapse threads"));
640         PACK_CHECK_BUTTON
641                 (vbox2, checkbtn_folder_default_hide_read_threads,
642                  _("Hide read threads"));
643         PACK_CHECK_BUTTON
644                 (vbox2, checkbtn_folder_default_hide_read_msgs,
645                  _("Hide read messages"));
646         PACK_CHECK_BUTTON
647                 (vbox2, checkbtn_folder_default_hide_del_msgs,
648                  _("Hide deleted messages"));
649
650         prefs_summaries->optmenu_folder_unread = optmenu_folder_unread;
651         prefs_summaries->spinbtn_ng_abbrev_len = spinbtn_ng_abbrev_len;
652         prefs_summaries->checkbtn_useaddrbook = checkbtn_useaddrbook;
653         prefs_summaries->checkbtn_show_tooltips = checkbtn_show_tooltips;
654         prefs_summaries->checkbtn_threadsubj = checkbtn_threadsubj;
655         prefs_summaries->entry_datefmt = entry_datefmt;
656         prefs_summaries->checkbtn_reopen_last_folder = checkbtn_reopen_last_folder;
657
658         prefs_summaries->checkbtn_always_show_msg = checkbtn_always_show_msg;
659         prefs_summaries->checkbtn_show_on_folder_open = checkbtn_show_on_folder_open;
660         prefs_summaries->checkbtn_show_on_search_results = checkbtn_show_on_search_results;
661         prefs_summaries->checkbtn_show_on_prevnext = checkbtn_show_on_prevnext;
662         prefs_summaries->checkbtn_show_on_deletemove = checkbtn_show_on_deletemove;
663         prefs_summaries->checkbtn_show_on_directional = checkbtn_show_on_directional;
664
665         prefs_summaries->checkbtn_mark_as_read_on_newwin = radio_mark_as_read_on_new_win;
666         prefs_summaries->spinbtn_mark_as_read_delay = spinbtn_mark_as_read_delay;
667         prefs_summaries->checkbtn_immedexec = checkbtn_immedexec;
668         prefs_summaries->checkbtn_ask_mark_all_read = checkbtn_ask_mark_all_read;
669         prefs_summaries->checkbtn_ask_override_colorlabel = checkbtn_ask_override_colorlabel;
670         prefs_summaries->optmenu_sort_key = optmenu_sort_key;
671         prefs_summaries->optmenu_sort_type = optmenu_sort_type;
672         prefs_summaries->optmenu_nextunreadmsgdialog = optmenu_nextunreadmsgdialog;
673
674         prefs_summaries->checkbtn_folder_default_thread = checkbtn_folder_default_thread;
675         prefs_summaries->checkbtn_folder_default_thread_collapsed = checkbtn_folder_default_thread_collapsed;
676         prefs_summaries->checkbtn_folder_default_hide_read_threads = checkbtn_folder_default_hide_read_threads;
677         prefs_summaries->checkbtn_folder_default_hide_read_msgs = checkbtn_folder_default_hide_read_msgs;
678         prefs_summaries->checkbtn_folder_default_hide_del_msgs = checkbtn_folder_default_hide_del_msgs;
679
680         prefs_summaries->page.widget = vbox1;
681         g_signal_connect(G_OBJECT(checkbtn_always_show_msg), "toggled",
682                         G_CALLBACK(always_show_msg_toggled), prefs_summaries);
683
684         g_signal_connect(G_OBJECT(radio_mark_as_read_on_select), "toggled",
685                          G_CALLBACK(mark_as_read_toggled),
686                          spinbtn_mark_as_read_delay);
687
688         prefs_summaries->window                 = GTK_WIDGET(window);
689         
690         combobox_select_by_data(GTK_COMBO_BOX(optmenu_folder_unread),
691                         prefs_common.display_folder_unread);
692         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_useaddrbook),
693                         prefs_common.use_addr_book);
694         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_show_tooltips),
695                         prefs_common.show_tooltips);
696         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_threadsubj),
697                         prefs_common.thread_by_subject);
698         gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_ng_abbrev_len),
699                         prefs_common.ng_abbrev_len);
700         gtk_entry_set_text(GTK_ENTRY(entry_datefmt), 
701                         prefs_common.date_format?prefs_common.date_format:"");  
702         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_reopen_last_folder),
703                         prefs_common.goto_last_folder_on_startup);
704
705         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_always_show_msg),
706                         prefs_common.always_show_msg);
707         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_show_on_folder_open),
708                         prefs_common.open_selected_on_folder_open);
709         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_show_on_search_results),
710                         prefs_common.open_selected_on_search_results);
711         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_show_on_prevnext),
712                         prefs_common.open_selected_on_prevnext);
713         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_show_on_deletemove),
714                         prefs_common.open_selected_on_deletemove);
715         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_show_on_directional),
716                         prefs_common.open_selected_on_directional);
717
718         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio_mark_as_read_on_new_win),
719                         prefs_common.mark_as_read_on_new_window);
720         gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_mark_as_read_delay),
721                         prefs_common.mark_as_read_delay);
722         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_immedexec),
723                         prefs_common.immediate_exec);
724         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_ask_mark_all_read),
725                         prefs_common.ask_mark_all_read);
726         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_ask_override_colorlabel),
727                         prefs_common.ask_override_colorlabel);
728
729         combobox_select_by_data(GTK_COMBO_BOX(optmenu_sort_key),
730                         prefs_common.default_sort_key);
731         combobox_select_by_data(GTK_COMBO_BOX(optmenu_sort_type),
732                         prefs_common.default_sort_type);
733
734         combobox_select_by_data(GTK_COMBO_BOX(optmenu_nextunreadmsgdialog),
735                         prefs_common.next_unread_msg_dialog);
736
737         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_folder_default_thread),
738                         prefs_common.folder_default_thread);
739         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_folder_default_thread_collapsed),
740                         prefs_common.folder_default_thread_collapsed);
741         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_folder_default_hide_read_threads),
742                         prefs_common.folder_default_hide_read_threads);
743         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_folder_default_hide_read_msgs),
744                         prefs_common.folder_default_hide_read_msgs);
745         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_folder_default_hide_del_msgs),
746                         prefs_common.folder_default_hide_del_msgs);
747
748         gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 0);
749                 
750         prefs_summaries->page.widget = notebook;
751 }
752
753 static void prefs_summaries_save(PrefsPage *_page)
754 {
755         SummariesPage *page = (SummariesPage *) _page;
756
757         prefs_common.display_folder_unread = combobox_get_active_data(
758                         GTK_COMBO_BOX(page->optmenu_folder_unread));
759
760         prefs_common.use_addr_book = gtk_toggle_button_get_active(
761                         GTK_TOGGLE_BUTTON(page->checkbtn_useaddrbook));
762         prefs_common.show_tooltips = gtk_toggle_button_get_active(
763                         GTK_TOGGLE_BUTTON(page->checkbtn_show_tooltips));
764         prefs_common.thread_by_subject = gtk_toggle_button_get_active(
765                         GTK_TOGGLE_BUTTON(page->checkbtn_threadsubj));
766         prefs_common.ng_abbrev_len = gtk_spin_button_get_value_as_int(
767                         GTK_SPIN_BUTTON(page->spinbtn_ng_abbrev_len));
768         
769         g_free(prefs_common.date_format); 
770         prefs_common.date_format = gtk_editable_get_chars(
771                         GTK_EDITABLE(page->entry_datefmt), 0, -1);      
772
773         prefs_common.goto_last_folder_on_startup = gtk_toggle_button_get_active(
774                 GTK_TOGGLE_BUTTON(page->checkbtn_reopen_last_folder));
775
776         prefs_common.always_show_msg = gtk_toggle_button_get_active(
777                 GTK_TOGGLE_BUTTON(page->checkbtn_always_show_msg));
778         prefs_common.open_selected_on_folder_open = gtk_toggle_button_get_active(
779                 GTK_TOGGLE_BUTTON(page->checkbtn_show_on_folder_open));
780         prefs_common.open_selected_on_search_results = gtk_toggle_button_get_active(
781                 GTK_TOGGLE_BUTTON(page->checkbtn_show_on_search_results));
782         prefs_common.open_selected_on_prevnext = gtk_toggle_button_get_active(
783                 GTK_TOGGLE_BUTTON(page->checkbtn_show_on_prevnext));
784         prefs_common.open_selected_on_deletemove = gtk_toggle_button_get_active(
785                 GTK_TOGGLE_BUTTON(page->checkbtn_show_on_deletemove));
786         prefs_common.open_selected_on_directional = gtk_toggle_button_get_active(
787                 GTK_TOGGLE_BUTTON(page->checkbtn_show_on_directional));
788
789         prefs_common.mark_as_read_on_new_window = gtk_toggle_button_get_active(
790                 GTK_TOGGLE_BUTTON(page->checkbtn_mark_as_read_on_newwin));
791         prefs_common.immediate_exec = gtk_toggle_button_get_active(
792                 GTK_TOGGLE_BUTTON(page->checkbtn_immedexec));
793         prefs_common.ask_mark_all_read = gtk_toggle_button_get_active(
794                 GTK_TOGGLE_BUTTON(page->checkbtn_ask_mark_all_read));
795         prefs_common.ask_override_colorlabel = gtk_toggle_button_get_active(
796                 GTK_TOGGLE_BUTTON(page->checkbtn_ask_override_colorlabel));
797         prefs_common.mark_as_read_delay = gtk_spin_button_get_value_as_int(
798                         GTK_SPIN_BUTTON(page->spinbtn_mark_as_read_delay));
799
800         prefs_common.default_sort_key = combobox_get_active_data(
801                         GTK_COMBO_BOX(page->optmenu_sort_key));
802         prefs_common.default_sort_type = combobox_get_active_data(
803                         GTK_COMBO_BOX(page->optmenu_sort_type));
804         prefs_common.next_unread_msg_dialog = combobox_get_active_data(
805                         GTK_COMBO_BOX(page->optmenu_nextunreadmsgdialog));
806         main_window_reflect_prefs_all();
807 }
808
809 static void prefs_summaries_destroy_widget(PrefsPage *_page)
810 {
811 }
812
813 SummariesPage *prefs_summaries;
814
815 void prefs_summaries_init(void)
816 {
817         SummariesPage *page;
818         static gchar *path[3];
819
820         path[0] = _("Display");
821         path[1] = _("Summaries");
822         path[2] = NULL;
823
824         page = g_new0(SummariesPage, 1);
825         page->page.path = path;
826         page->page.create_widget = prefs_summaries_create_widget;
827         page->page.destroy_widget = prefs_summaries_destroy_widget;
828         page->page.save_page = prefs_summaries_save;
829         page->page.weight = 140.0;
830         prefs_gtk_register_page((PrefsPage *) page);
831         prefs_summaries = page;
832 }
833
834 void prefs_summaries_done(void)
835 {
836         prefs_gtk_unregister_page((PrefsPage *) prefs_summaries);
837         g_free(prefs_summaries);
838 }
839
840 static void date_format_ok_btn_clicked(GtkButton *button, GtkWidget **widget)
841 {
842         GtkWidget *datefmt_sample = NULL;
843         gchar *text;
844
845         cm_return_if_fail(widget != NULL);
846         cm_return_if_fail(*widget != NULL);
847         cm_return_if_fail(prefs_summaries->entry_datefmt != NULL);
848
849         datefmt_sample = GTK_WIDGET(g_object_get_data
850                                     (G_OBJECT(*widget), "datefmt_sample"));
851         cm_return_if_fail(datefmt_sample != NULL);
852
853         text = gtk_editable_get_chars(GTK_EDITABLE(datefmt_sample), 0, -1);
854         g_free(prefs_common.date_format);
855         prefs_common.date_format = text;
856         gtk_entry_set_text(GTK_ENTRY(prefs_summaries->entry_datefmt), text);
857
858         gtk_widget_destroy(*widget);
859         *widget = NULL;
860 }
861
862 static void date_format_cancel_btn_clicked(GtkButton *button,
863                                            GtkWidget **widget)
864 {
865         cm_return_if_fail(widget != NULL);
866         cm_return_if_fail(*widget != NULL);
867
868         gtk_widget_destroy(*widget);
869         *widget = NULL;
870 }
871
872 static gboolean date_format_key_pressed(GtkWidget *keywidget, GdkEventKey *event,
873                                         GtkWidget **widget)
874 {
875         if (event && event->keyval == GDK_KEY_Escape)
876                 date_format_cancel_btn_clicked(NULL, widget);
877         return FALSE;
878 }
879
880 static gboolean date_format_on_delete(GtkWidget *dialogwidget,
881                                       GdkEventAny *event, GtkWidget **widget)
882 {
883         cm_return_val_if_fail(widget != NULL, FALSE);
884         cm_return_val_if_fail(*widget != NULL, FALSE);
885
886         *widget = NULL;
887         return FALSE;
888 }
889
890 static void date_format_entry_on_change(GtkEditable *editable,
891                                         GtkLabel *example)
892 {
893         time_t cur_time;
894         struct tm *cal_time;
895         gchar buffer[100];
896         gchar *text;
897         struct tm lt;
898
899         cur_time = time(NULL);
900         cal_time = localtime_r(&cur_time, &lt);
901         buffer[0] = 0;
902         text = gtk_editable_get_chars(editable, 0, -1);
903         if (text)
904                 fast_strftime(buffer, sizeof buffer, text, cal_time); 
905
906         gtk_label_set_text(example, buffer);
907
908         g_free(text);
909 }
910
911 static void date_format_select_row(GtkTreeView *list_view,
912                                    GtkTreePath *path,
913                                    GtkTreeViewColumn *column,
914                                    GtkWidget *date_format)
915 {
916         gint cur_pos;
917         gchar *format;
918         const gchar *old_format;
919         gchar *new_format;
920         GtkWidget *datefmt_sample;
921         GtkTreeIter iter;
922         GtkTreeModel *model;
923         
924         cm_return_if_fail(date_format != NULL);
925
926         /* only on double click */
927         datefmt_sample = GTK_WIDGET(g_object_get_data(G_OBJECT(date_format), 
928                                                       "datefmt_sample"));
929
930         cm_return_if_fail(datefmt_sample != NULL);
931
932         model = gtk_tree_view_get_model(list_view);
933
934         /* get format from list */
935         if (!gtk_tree_model_get_iter(model, &iter, path))
936                 return;
937
938         gtk_tree_model_get(model, &iter, DATEFMT_FMT, &format, -1);             
939         
940         cur_pos = gtk_editable_get_position(GTK_EDITABLE(datefmt_sample));
941         old_format = gtk_entry_get_text(GTK_ENTRY(datefmt_sample));
942
943         /* insert the format into the text entry */
944         new_format = g_malloc(strlen(old_format) + 3);
945
946         strncpy(new_format, old_format, cur_pos);
947         new_format[cur_pos] = '\0';
948         strcat(new_format, format);
949         g_free(format);
950         strcat(new_format, &old_format[cur_pos]);
951
952         gtk_entry_set_text(GTK_ENTRY(datefmt_sample), new_format);
953         gtk_editable_set_position(GTK_EDITABLE(datefmt_sample), cur_pos + 2);
954
955         g_free(new_format);
956 }
957
958 static void always_show_msg_toggled(GtkToggleButton *button,
959                 gpointer user_data)
960 {
961         const SummariesPage *prefs_summaries = (SummariesPage *)user_data;
962         gboolean state;
963
964         cm_return_if_fail(prefs_summaries != NULL);
965
966         state = gtk_toggle_button_get_active(button);
967
968         gtk_widget_set_sensitive(prefs_summaries->checkbtn_show_on_folder_open, !state);
969         gtk_widget_set_sensitive(prefs_summaries->checkbtn_show_on_search_results, !state);
970         gtk_widget_set_sensitive(prefs_summaries->checkbtn_show_on_prevnext, !state);
971         gtk_widget_set_sensitive(prefs_summaries->checkbtn_show_on_deletemove, !state);
972         gtk_widget_set_sensitive(prefs_summaries->checkbtn_show_on_directional, !state);
973 }
974
975 static void mark_as_read_toggled(GtkToggleButton *button, GtkWidget *spinbtn)
976 {
977        gtk_widget_set_sensitive(spinbtn,
978                gtk_toggle_button_get_active(button));
979 }
980