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