2005-10-06 [colin] 1.9.15cvs16
[claws.git] / src / prefs_summaries.c
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 2005 Colin Leroy <colin@colino.net> & The Sylpheed-Claws 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 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19
20 #ifdef HAVE_CONFIG_H
21 #  include "config.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 #include "prefs_common.h"
35 #include "prefs_gtk.h"
36 #include "prefs_summary_column.h"
37 #include "prefs_folder_column.h"
38
39 #include "gtk/menu.h"
40 #include "gtk/gtkutils.h"
41 #include "gtk/prefswindow.h"
42
43 #include "manage_window.h"
44
45 typedef struct _SummariesPage
46 {
47         PrefsPage page;
48
49         GtkWidget *window;
50
51         GtkWidget *chkbtn_transhdr;
52         GtkWidget *chkbtn_folder_unread;
53         GtkWidget *spinbtn_ng_abbrev_len;
54         GtkWidget *chkbtn_useaddrbook;
55         GtkWidget *chkbtn_threadsubj;
56         GtkWidget *button_datefmt;
57         GtkWidget *entry_datefmt;
58
59         GtkWidget *checkbtn_always_show_msg;
60         GtkWidget *checkbtn_mark_as_read_on_newwin;
61         GtkWidget *checkbtn_openinbox;
62         GtkWidget *checkbtn_immedexec;
63         GtkWidget *checkbtn_ask_mark_all_read;
64         GtkWidget *optmenu_select_on_entry;
65         GtkWidget *optmenu_nextunreadmsgdialog;
66
67 } SummariesPage;
68
69 enum {
70         DATEFMT_FMT,
71         DATEFMT_TXT,
72         N_DATEFMT_COLUMNS
73 };
74
75 static void date_format_ok_btn_clicked          (GtkButton      *button,
76                                                  GtkWidget     **widget);
77 static void date_format_cancel_btn_clicked      (GtkButton      *button,
78                                                  GtkWidget     **widget);
79 static gboolean date_format_key_pressed         (GtkWidget      *keywidget,
80                                                  GdkEventKey    *event,
81                                                  GtkWidget     **widget);
82 static gboolean date_format_on_delete           (GtkWidget      *dialogwidget,
83                                                  GdkEventAny    *event,
84                                                  GtkWidget     **widget);
85 static void date_format_entry_on_change         (GtkEditable    *editable,
86                                                  GtkLabel       *example);
87 static void date_format_select_row              (GtkTreeView *list_view,
88                                                  GtkTreePath *path,
89                                                  GtkTreeViewColumn *column,
90                                                  GtkWidget *date_format);
91
92 static GtkWidget *date_format_create(GtkButton *button, void *data)
93 {
94         static GtkWidget *datefmt_win = NULL;
95
96         GtkWidget *vbox1;
97         GtkWidget *scrolledwindow1;
98         GtkWidget *datefmt_list_view;
99         GtkWidget *table;
100         GtkWidget *label1;
101         GtkWidget *label2;
102         GtkWidget *label3;
103         GtkWidget *confirm_area;
104         GtkWidget *ok_btn;
105         GtkWidget *cancel_btn;
106         GtkWidget *datefmt_entry;
107         GtkListStore *store;
108
109         struct {
110                 gchar *fmt;
111                 gchar *txt;
112         } time_format[] = {
113                 { "%a", NULL },
114                 { "%A", NULL },
115                 { "%b", NULL },
116                 { "%B", NULL },
117                 { "%c", NULL },
118                 { "%C", NULL },
119                 { "%d", NULL },
120                 { "%H", NULL },
121                 { "%I", NULL },
122                 { "%j", NULL },
123                 { "%m", NULL },
124                 { "%M", NULL },
125                 { "%p", NULL },
126                 { "%S", NULL },
127                 { "%w", NULL },
128                 { "%x", NULL },
129                 { "%y", NULL },
130                 { "%Y", NULL },
131                 { "%Z", NULL }
132         };
133
134         gint i;
135         const gint TIME_FORMAT_ELEMS =
136                 sizeof time_format / sizeof time_format[0];
137
138         GtkCellRenderer *renderer;
139         GtkTreeViewColumn *column;
140         GtkTreeSelection *selection;
141
142         time_format[0].txt  = _("the full abbreviated weekday name");
143         time_format[1].txt  = _("the full weekday name");
144         time_format[2].txt  = _("the abbreviated month name");
145         time_format[3].txt  = _("the full month name");
146         time_format[4].txt  = _("the preferred date and time for the current locale");
147         time_format[5].txt  = _("the century number (year/100)");
148         time_format[6].txt  = _("the day of the month as a decimal number");
149         time_format[7].txt  = _("the hour as a decimal number using a 24-hour clock");
150         time_format[8].txt  = _("the hour as a decimal number using a 12-hour clock");
151         time_format[9].txt  = _("the day of the year as a decimal number");
152         time_format[10].txt = _("the month as a decimal number");
153         time_format[11].txt = _("the minute as a decimal number");
154         time_format[12].txt = _("either AM or PM");
155         time_format[13].txt = _("the second as a decimal number");
156         time_format[14].txt = _("the day of the week as a decimal number");
157         time_format[15].txt = _("the preferred date for the current locale");
158         time_format[16].txt = _("the last two digits of a year");
159         time_format[17].txt = _("the year as a decimal number");
160         time_format[18].txt = _("the time zone or name or abbreviation");
161
162         if (datefmt_win) return datefmt_win;
163
164         store = gtk_list_store_new(N_DATEFMT_COLUMNS,
165                                    G_TYPE_STRING,
166                                    G_TYPE_STRING,
167                                    -1);
168
169         for (i = 0; i < TIME_FORMAT_ELEMS; i++) {
170                 GtkTreeIter iter;
171
172                 gtk_list_store_append(store, &iter);
173                 gtk_list_store_set(store, &iter,
174                                    DATEFMT_FMT, time_format[i].fmt,
175                                    DATEFMT_TXT, time_format[i].txt,
176                                    -1);
177         }
178
179         datefmt_win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
180         gtk_container_set_border_width(GTK_CONTAINER(datefmt_win), 8);
181         gtk_window_set_title(GTK_WINDOW(datefmt_win), _("Date format"));
182         gtk_window_set_position(GTK_WINDOW(datefmt_win), GTK_WIN_POS_CENTER);
183         gtk_widget_set_size_request(datefmt_win, 440, 280);
184
185         vbox1 = gtk_vbox_new(FALSE, 10);
186         gtk_widget_show(vbox1);
187         gtk_container_add(GTK_CONTAINER(datefmt_win), vbox1);
188
189         scrolledwindow1 = gtk_scrolled_window_new(NULL, NULL);
190         gtk_scrolled_window_set_policy
191                 (GTK_SCROLLED_WINDOW(scrolledwindow1),
192                  GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
193         gtk_widget_show(scrolledwindow1);
194         gtk_box_pack_start(GTK_BOX(vbox1), scrolledwindow1, TRUE, TRUE, 0);
195
196         datefmt_list_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
197         g_object_unref(G_OBJECT(store));
198         gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(datefmt_list_view),
199                                      prefs_common.enable_rules_hint);
200         gtk_widget_show(datefmt_list_view);
201         gtk_container_add(GTK_CONTAINER(scrolledwindow1), datefmt_list_view);
202
203         renderer = gtk_cell_renderer_text_new();
204         column = gtk_tree_view_column_new_with_attributes
205                         (_("Specifier"), renderer, "text", DATEFMT_FMT,
206                          NULL);
207         gtk_tree_view_append_column(GTK_TREE_VIEW(datefmt_list_view), column);
208         
209         renderer = gtk_cell_renderer_text_new();
210         column = gtk_tree_view_column_new_with_attributes
211                         (_("Description"), renderer, "text", DATEFMT_TXT,
212                          NULL);
213         gtk_tree_view_append_column(GTK_TREE_VIEW(datefmt_list_view), column);
214         
215         /* gtk_clist_set_column_width(GTK_CLIST(datefmt_clist), 0, 80); */
216         selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(datefmt_list_view));
217         gtk_tree_selection_set_mode(selection, GTK_SELECTION_BROWSE);
218
219         g_signal_connect(G_OBJECT(datefmt_list_view), "row_activated", 
220                          G_CALLBACK(date_format_select_row),
221                          datefmt_win);
222         
223         table = gtk_table_new(2, 2, FALSE);
224         gtk_widget_show(table);
225         gtk_box_pack_start(GTK_BOX(vbox1), table, FALSE, FALSE, 0);
226         gtk_table_set_row_spacings(GTK_TABLE(table), 4);
227         gtk_table_set_col_spacings(GTK_TABLE(table), 8);
228
229         label1 = gtk_label_new(_("Date format"));
230         gtk_widget_show(label1);
231         gtk_table_attach(GTK_TABLE(table), label1, 0, 1, 0, 1,
232                          GTK_FILL, 0, 0, 0);
233         gtk_label_set_justify(GTK_LABEL(label1), GTK_JUSTIFY_LEFT);
234         gtk_misc_set_alignment(GTK_MISC(label1), 0, 0.5);
235
236         datefmt_entry = gtk_entry_new();
237         gtk_entry_set_max_length(GTK_ENTRY(datefmt_entry), 256);
238         gtk_widget_show(datefmt_entry);
239         gtk_table_attach(GTK_TABLE(table), datefmt_entry, 1, 2, 0, 1,
240                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
241
242         /* we need the "sample" entry box; add it as data so callbacks can
243          * get the entry box */
244         g_object_set_data(G_OBJECT(datefmt_win), "datefmt_sample",
245                           datefmt_entry);
246
247         label2 = gtk_label_new(_("Example"));
248         gtk_widget_show(label2);
249         gtk_table_attach(GTK_TABLE(table), label2, 0, 1, 1, 2,
250                          GTK_FILL, 0, 0, 0);
251         gtk_label_set_justify(GTK_LABEL(label2), GTK_JUSTIFY_LEFT);
252         gtk_misc_set_alignment(GTK_MISC(label2), 0, 0.5);
253
254         label3 = gtk_label_new("");
255         gtk_widget_show(label3);
256         gtk_table_attach(GTK_TABLE(table), label3, 1, 2, 1, 2,
257                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
258         gtk_label_set_justify(GTK_LABEL(label3), GTK_JUSTIFY_LEFT);
259         gtk_misc_set_alignment(GTK_MISC(label3), 0, 0.5);
260
261         gtkut_stock_button_set_create(&confirm_area, &ok_btn, GTK_STOCK_OK,
262                                 &cancel_btn, GTK_STOCK_CANCEL, NULL, NULL);
263
264         gtk_box_pack_start(GTK_BOX(vbox1), confirm_area, FALSE, FALSE, 0);
265         gtk_widget_show(confirm_area);
266         gtk_widget_grab_default(ok_btn);
267
268         /* set the current format */
269         gtk_entry_set_text(GTK_ENTRY(datefmt_entry), prefs_common.date_format);
270         date_format_entry_on_change(GTK_EDITABLE(datefmt_entry),
271                                     GTK_LABEL(label3));
272
273         g_signal_connect(G_OBJECT(ok_btn), "clicked",
274                          G_CALLBACK(date_format_ok_btn_clicked),
275                          &datefmt_win);
276         g_signal_connect(G_OBJECT(cancel_btn), "clicked",
277                          G_CALLBACK(date_format_cancel_btn_clicked),
278                          &datefmt_win);
279         g_signal_connect(G_OBJECT(datefmt_win), "key_press_event",
280                          G_CALLBACK(date_format_key_pressed),
281                          &datefmt_win);
282         g_signal_connect(G_OBJECT(datefmt_win), "delete_event",
283                          G_CALLBACK(date_format_on_delete),
284                          &datefmt_win);
285         g_signal_connect(G_OBJECT(datefmt_entry), "changed",
286                          G_CALLBACK(date_format_entry_on_change),
287                          label3);
288
289         gtk_window_set_position(GTK_WINDOW(datefmt_win), GTK_WIN_POS_CENTER);
290         gtk_window_set_modal(GTK_WINDOW(datefmt_win), TRUE);
291
292         gtk_widget_show(datefmt_win);
293         manage_window_set_transient(GTK_WINDOW(datefmt_win));
294
295         gtk_widget_grab_focus(ok_btn);
296
297         return datefmt_win;
298 }
299
300 static struct KeybindDialog {
301         GtkWidget *window;
302         GtkWidget *combo;
303 } keybind;
304
305 static void prefs_keybind_select                (void);
306 static gint prefs_keybind_deleted               (GtkWidget      *widget,
307                                                  GdkEventAny    *event,
308                                                  gpointer        data);
309 static gboolean prefs_keybind_key_pressed       (GtkWidget      *widget,
310                                                  GdkEventKey    *event,
311                                                  gpointer        data);
312 static void prefs_keybind_cancel                (void);
313 static void prefs_keybind_apply_clicked         (GtkWidget      *widget);
314
315
316 static void prefs_keybind_select(void)
317 {
318         GtkWidget *window;
319         GtkWidget *vbox1;
320         GtkWidget *hbox1;
321         GtkWidget *label;
322         GtkWidget *combo;
323         GtkWidget *confirm_area;
324         GtkWidget *ok_btn;
325         GtkWidget *cancel_btn;
326
327         window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
328         gtk_container_set_border_width (GTK_CONTAINER (window), 8);
329         gtk_window_set_title (GTK_WINDOW (window), _("Key bindings"));
330         gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
331         gtk_window_set_modal (GTK_WINDOW (window), TRUE);
332         gtk_window_set_resizable(GTK_WINDOW (window), FALSE);
333         manage_window_set_transient (GTK_WINDOW (window));
334
335         vbox1 = gtk_vbox_new (FALSE, VSPACING);
336         gtk_container_add (GTK_CONTAINER (window), vbox1);
337         gtk_container_set_border_width (GTK_CONTAINER (vbox1), 2);
338
339         hbox1 = gtk_hbox_new (FALSE, 8);
340         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
341
342         label = gtk_label_new
343                 (_("Select preset:"));
344         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
345         gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
346
347         hbox1 = gtk_hbox_new (FALSE, 8);
348         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
349
350         combo = gtk_combo_new ();
351         gtk_box_pack_start (GTK_BOX (hbox1), combo, TRUE, TRUE, 0);
352         gtkut_combo_set_items (GTK_COMBO (combo),
353                                _("Default"),
354                                "Mew / Wanderlust",
355                                "Mutt",
356                                _("Old Sylpheed"),
357                                NULL);
358         gtk_editable_set_editable(GTK_EDITABLE(GTK_COMBO (combo)->entry), FALSE);
359
360         hbox1 = gtk_hbox_new (FALSE, 8);
361         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
362
363         label = gtk_label_new
364                 (_("You can also modify each menu shortcut by pressing\n"
365                    "any key(s) when placing the mouse pointer on the item."));
366         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
367         gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
368
369         hbox1 = gtk_hbox_new (FALSE, 8);
370         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
371
372         gtkut_stock_button_set_create (&confirm_area, &ok_btn, GTK_STOCK_OK,
373                                        &cancel_btn, GTK_STOCK_CANCEL,
374                                        NULL, NULL);
375         gtk_box_pack_end (GTK_BOX (hbox1), confirm_area, FALSE, FALSE, 0);
376         gtk_widget_grab_default (ok_btn);
377
378         MANAGE_WINDOW_SIGNALS_CONNECT(window);
379         g_signal_connect (G_OBJECT (window), "delete_event",
380                           G_CALLBACK (prefs_keybind_deleted), NULL);
381         g_signal_connect (G_OBJECT (window), "key_press_event",
382                           G_CALLBACK (prefs_keybind_key_pressed), NULL);
383         g_signal_connect (G_OBJECT (ok_btn), "clicked",
384                           G_CALLBACK (prefs_keybind_apply_clicked),
385                           NULL);
386         g_signal_connect (G_OBJECT (cancel_btn), "clicked",
387                           G_CALLBACK (prefs_keybind_cancel),
388                           NULL);
389
390         gtk_widget_show_all(window);
391
392         keybind.window = window;
393         keybind.combo = combo;
394 }
395
396 static gboolean prefs_keybind_key_pressed(GtkWidget *widget, GdkEventKey *event,
397                                           gpointer data)
398 {
399         if (event && event->keyval == GDK_Escape)
400                 prefs_keybind_cancel();
401         return FALSE;
402 }
403
404 static gint prefs_keybind_deleted(GtkWidget *widget, GdkEventAny *event,
405                                   gpointer data)
406 {
407         prefs_keybind_cancel();
408         return TRUE;
409 }
410
411 static void prefs_keybind_cancel(void)
412 {
413         gtk_widget_destroy(keybind.window);
414         keybind.window = NULL;
415         keybind.combo = NULL;
416 }
417   
418 struct KeyBind {
419         const gchar *accel_path;
420         const gchar *accel_key;
421 };
422
423 static void prefs_keybind_apply(struct KeyBind keybind[], gint num)
424 {
425         gint i;
426         guint key;
427         GdkModifierType mods;
428
429         for (i = 0; i < num; i++) {
430                 const gchar *accel_key
431                         = keybind[i].accel_key ? keybind[i].accel_key : "";
432                 gtk_accelerator_parse(accel_key, &key, &mods);
433                 gtk_accel_map_change_entry(keybind[i].accel_path,
434                                            key, mods, TRUE);
435         }
436 }
437
438 static void prefs_keybind_apply_clicked(GtkWidget *widget)
439 {
440         GtkEntry *entry = GTK_ENTRY(GTK_COMBO(keybind.combo)->entry);
441         const gchar *text;
442         struct KeyBind *menurc;
443         gint n_menurc;
444
445         static struct KeyBind default_menurc[] = {
446                 {"<Main>/File/Empty all Trash folders",         ""},
447                 {"<Main>/File/Save as...",                      "<control>S"},
448                 {"<Main>/File/Print...",                        ""},
449                 {"<Main>/File/Exit",                            "<control>Q"},
450
451                 {"<Main>/Edit/Copy",                            "<control>C"},
452                 {"<Main>/Edit/Select all",                      "<control>A"},
453                 {"<Main>/Edit/Find in current message...",      "<control>F"},
454                 {"<Main>/Edit/Search folder...",                "<shift><control>F"},
455
456                 {"<Main>/View/Show or hide/Message View",       "V"},
457                 {"<Main>/View/Thread view",                     "<control>T"},
458                 {"<Main>/View/Go to/Prev message",              "P"},
459                 {"<Main>/View/Go to/Next message",              "N"},
460                 {"<Main>/View/Go to/Prev unread message",       "<shift>P"},
461                 {"<Main>/View/Go to/Next unread message",       "<shift>N"},
462                 {"<Main>/View/Go to/Other folder...",           "G"},
463                 {"<Main>/View/Open in new window",              "<control><alt>N"},
464                 {"<Main>/View/Message source",                  "<control>U"},
465                 {"<Main>/View/Show all headers",                "<control>H"},
466                 {"<Main>/View/Update summary",                  "<control><alt>U"},
467
468                 {"<Main>/Message/Receive/Get from current account",
469                                                                 "<control>I"},
470                 {"<Main>/Message/Receive/Get from all accounts","<shift><control>I"},
471                 {"<Main>/Message/Compose an email message",     "<control>M"},
472                 {"<Main>/Message/Reply",                        "<control>R"},
473                 {"<Main>/Message/Reply to/all",                 "<shift><control>R"},
474                 {"<Main>/Message/Reply to/sender",              ""},
475                 {"<Main>/Message/Reply to/mailing list",        "<control>L"},
476                 {"<Main>/Message/Forward",                      "<control><alt>F"},
477                 /* {"<Main>/Message/Forward as attachment",      ""}, */
478                 {"<Main>/Message/Move...",                      "<control>O"},
479                 {"<Main>/Message/Copy...",                      "<shift><control>O"},
480                 {"<Main>/Message/Delete",                       "<control>D"},
481                 {"<Main>/Message/Mark/Mark",                    "<shift>asterisk"},
482                 {"<Main>/Message/Mark/Unmark",                  "U"},
483                 {"<Main>/Message/Mark/Mark as unread",          "<shift>exclam"},
484                 {"<Main>/Message/Mark/Mark as read",            ""},
485
486                 {"<Main>/Tools/Address book",                   "<shift><control>A"},
487                 {"<Main>/Tools/Execute",                        "X"},
488                 {"<Main>/Tools/Log window",                     "<shift><control>L"},
489
490                 {"<Compose>/Message/Close",                             "<control>W"},
491                 {"<Compose>/Edit/Select all",                           "<control>A"},
492                 {"<Compose>/Edit/Advanced/Move a word backward",        ""},
493                 {"<Compose>/Edit/Advanced/Move a word forward",         ""},
494                 {"<Compose>/Edit/Advanced/Move to beginning of line",   ""},
495                 {"<Compose>/Edit/Advanced/Delete a word backward",      ""},
496                 {"<Compose>/Edit/Advanced/Delete a word forward",       ""},
497         };
498
499         static struct KeyBind mew_wl_menurc[] = {
500                 {"<Main>/File/Empty all Trash folders",                 "<shift>D"},
501                 {"<Main>/File/Save as...",                      "Y"},
502                 {"<Main>/File/Print...",                        "<shift>numbersign"},
503                 {"<Main>/File/Exit",                            "<shift>Q"},
504
505                 {"<Main>/Edit/Copy",                            "<control>C"},
506                 {"<Main>/Edit/Select all",                      "<control>A"},
507                 {"<Main>/Edit/Find in current message...",      "<control>F"},
508                 {"<Main>/Edit/Search folder...",                "<control>S"},
509
510                 {"<Main>/View/Show or hide/Message View",       ""},
511                 {"<Main>/View/Thread view",                     "<shift>T"},
512                 {"<Main>/View/Go to/Prev message",              "P"},
513                 {"<Main>/View/Go to/Next message",              "N"},
514                 {"<Main>/View/Go to/Prev unread message",       "<shift>P"},
515                 {"<Main>/View/Go to/Next unread message",       "<shift>N"},
516                 {"<Main>/View/Go to/Other folder...",           "G"},
517                 {"<Main>/View/Open in new window",              "<control><alt>N"},
518                 {"<Main>/View/Message source",                  "<control>U"},
519                 {"<Main>/View/Show all headers",                "<shift>H"},
520                 {"<Main>/View/Update summary",                  "<shift>S"},
521
522                 {"<Main>/Message/Receive/Get from current account",
523                                                                 "<control>I"},
524                 {"<Main>/Message/Receive/Get from all accounts","<shift><control>I"},
525                 {"<Main>/Message/Compose an email message",     "W"},
526                 {"<Main>/Message/Reply",                        "<control>R"},
527                 {"<Main>/Message/Reply to/all",                 "<shift>A"},
528                 {"<Main>/Message/Reply to/sender",              ""},
529                 {"<Main>/Message/Reply to/mailing list",        "<control>L"},
530                 {"<Main>/Message/Forward",                      "F"},
531                 /* {"<Main>/Message/Forward as attachment", "<shift>F"}, */
532                 {"<Main>/Message/Move...",                      "O"},
533                 {"<Main>/Message/Copy...",                      "<shift>O"},
534                 {"<Main>/Message/Delete",                       "D"},
535                 {"<Main>/Message/Mark/Mark",                    "<shift>asterisk"},
536                 {"<Main>/Message/Mark/Unmark",                  "U"},
537                 {"<Main>/Message/Mark/Mark as unread",          "<shift>exclam"},
538                 {"<Main>/Message/Mark/Mark as read",            "<shift>R"},
539
540                 {"<Main>/Tools/Address book",                   "<shift><control>A"},
541                 {"<Main>/Tools/Execute",                        "X"},
542                 {"<Main>/Tools/Log window",                     "<shift><control>L"},
543
544                 {"<Compose>/Message/Close",                             "<alt>W"},
545                 {"<Compose>/Edit/Select all",                           ""},
546                 {"<Compose>/Edit/Advanced/Move a word backward,"        "<alt>B"},
547                 {"<Compose>/Edit/Advanced/Move a word forward",         "<alt>F"},
548                 {"<Compose>/Edit/Advanced/Move to beginning of line",   "<control>A"},
549                 {"<Compose>/Edit/Advanced/Delete a word backward",      "<control>W"},
550                 {"<Compose>/Edit/Advanced/Delete a word forward",       "<alt>D"},
551         };
552
553         static struct KeyBind mutt_menurc[] = {
554                 {"<Main>/File/Empty all Trash folders",         ""},
555                 {"<Main>/File/Save as...",                      "S"},
556                 {"<Main>/File/Print...",                        "P"},
557                 {"<Main>/File/Exit",                            "Q"},
558
559                 {"<Main>/Edit/Copy",                            "<control>C"},
560                 {"<Main>/Edit/Select all",                      "<control>A"},
561                 {"<Main>/Edit/Find in current message...",      "<control>F"},
562                 {"<Main>/Edit/Search messages...",              "slash"},
563
564                 {"<Main>/View/Show or hide/Message view",       "V"},
565                 {"<Main>/View/Thread view",                     "<control>T"},
566                 {"<Main>/View/Go to/Prev message",              ""},
567                 {"<Main>/View/Go to/Next message",              ""},
568                 {"<Main>/View/Go to/Prev unread message",       ""},
569                 {"<Main>/View/Go to/Next unread message",       ""},
570                 {"<Main>/View/Go to/Other folder...",           "C"},
571                 {"<Main>/View/Open in new window",              "<control><alt>N"},
572                 {"<Main>/View/Message source",                  "<control>U"},
573                 {"<Main>/View/Show all headers",                "<control>H"},
574                 {"<Main>/View/Update summary",                          "<control><alt>U"},
575
576                 {"<Main>/Message/Receive/Get from current account",
577                                                                 "<control>I"},
578                 {"<Main>/Message/Receive/Get from all accounts","<shift><control>I"},
579                 {"<Main>/Message/Compose an email message",             "M"},
580                 {"<Main>/Message/Reply",                        "R"},
581                 {"<Main>/Message/Reply to/all",                 "G"},
582                 {"<Main>/Message/Reply to/sender",              ""},
583                 {"<Main>/Message/Reply to/mailing list",        "<control>L"},
584                 {"<Main>/Message/Forward",                      "F"},
585                 {"<Main>/Message/Forward as attachment",        ""},
586                 {"<Main>/Message/Move...",                      "<control>O"},
587                 {"<Main>/Message/Copy...",                      "<shift>C"},
588                 {"<Main>/Message/Delete",                       "D"},
589                 {"<Main>/Message/Mark/Mark",                    "<shift>F"},
590                 {"<Main>/Message/Mark/Unmark",                  "U"},
591                 {"<Main>/Message/Mark/Mark as unread",          "<shift>N"},
592                 {"<Main>/Message/Mark/Mark as read",            ""},
593
594                 {"<Main>/Tools/Address book",                   "<shift><control>A"},
595                 {"<Main>/Tools/Execute",                        "X"},
596                 {"<Main>/Tools/Log window",                     "<shift><control>L"},
597
598                 {"<Compose>/Message/Close",                             "<alt>W"},
599                 {"<Compose>/Edit/Select all",                           ""},
600                 {"<Compose>/Edit/Advanced/Move a word backward",        "<alt>B"},
601                 {"<Compose>/Edit/Advanced/Move a word forward",         "<alt>F"},
602                 {"<Compose>/Edit/Advanced/Move to beginning of line",   "<control>A"},
603                 {"<Compose>/Edit/Advanced/Delete a word backward",      "<control>W"},
604                 {"<Compose>/Edit/Advanced/Delete a word forward",       "<alt>D"},
605         };
606
607         static struct KeyBind old_sylpheed_menurc[] = {
608                 {"<Main>/File/Empty all Trash folders",         ""},
609                 {"<Main>/File/Save as...",                      ""},
610                 {"<Main>/File/Print...",                        "<alt>P"},
611                 {"<Main>/File/Exit",                            "<alt>Q"},
612
613                 {"<Main>/Edit/Copy",                            "<control>C"},
614                 {"<Main>/Edit/Select all",                      "<control>A"},
615                 {"<Main>/Edit/Find in current message...",      "<control>F"},
616                 {"<Main>/Edit/Search folder...",                "<control>S"},
617
618                 {"<Main>/View/Show or hide/Message View",       ""},
619                 {"<Main>/View/Thread view",                     "<control>T"},
620                 {"<Main>/View/Go to/Prev message",              "P"},
621                 {"<Main>/View/Go to/Next message",              "N"},
622                 {"<Main>/View/Go to/Prev unread message",       "<shift>P"},
623                 {"<Main>/View/Go to/Next unread message",       "<shift>N"},
624                 {"<Main>/View/Go to/Other folder...",           "<alt>G"},
625                 {"<Main>/View/Open in new window",              "<shift><control>N"},
626                 {"<Main>/View/Message source",                  "<control>U"},
627                 {"<Main>/View/Show all headers",                "<control>H"},
628                 {"<Main>/View/Update summary",                  "<alt>U"},
629
630                 {"<Main>/Message/Receive/Get from current account",
631                                                                 "<alt>I"},
632                 {"<Main>/Message/Receive/Get from all accounts","<shift><alt>I"},
633                 {"<Main>/Message/Compose an email message",     "<alt>N"},
634                 {"<Main>/Message/Reply",                        "<alt>R"},
635                 {"<Main>/Message/Reply to/all",                 "<shift><alt>R"},
636                 {"<Main>/Message/Reply to/sender",              "<control><alt>R"},
637                 {"<Main>/Message/Reply to/mailing list",        "<control>L"},
638                 {"<Main>/Message/Forward",                       "<shift><alt>F"},
639                 /* "(menu-path \"<Main>/Message/Forward as attachment", "<shift><control>F"}, */
640                 {"<Main>/Message/Move...",                      "<alt>O"},
641                 {"<Main>/Message/Copy...",                      ""},
642                 {"<Main>/Message/Delete",                       "<alt>D"},
643                 {"<Main>/Message/Mark/Mark",                    "<shift>asterisk"},
644                 {"<Main>/Message/Mark/Unmark",                  "U"},
645                 {"<Main>/Message/Mark/Mark as unread",          "<shift>exclam"},
646                 {"<Main>/Message/Mark/Mark as read",            ""},
647
648                 {"<Main>/Tools/Address book",                   "<alt>A"},
649                 {"<Main>/Tools/Execute",                        "<alt>X"},
650                 {"<Main>/Tools/Log window",                     "<alt>L"},
651
652                 {"<Compose>/Message/Close",                             "<alt>W"},
653                 {"<Compose>/Edit/Select all",                           ""},
654                 {"<Compose>/Edit/Advanced/Move a word backward",        "<alt>B"},
655                 {"<Compose>/Edit/Advanced/Move a word forward",         "<alt>F"},
656                 {"<Compose>/Edit/Advanced/Move to beginning of line",   "<control>A"},
657                 {"<Compose>/Edit/Advanced/Delete a word backward",      "<control>W"},
658                 {"<Compose>/Edit/Advanced/Delete a word forward",       "<alt>D"},
659         };
660   
661         text = gtk_entry_get_text(entry);
662   
663         if (!strcmp(text, _("Default"))) {
664                 menurc = default_menurc;
665                 n_menurc = G_N_ELEMENTS(default_menurc);
666         } else if (!strcmp(text, "Mew / Wanderlust")) {
667                 menurc = mew_wl_menurc;
668                 n_menurc = G_N_ELEMENTS(mew_wl_menurc);
669         } else if (!strcmp(text, "Mutt")) {
670                 menurc = mutt_menurc;
671                 n_menurc = G_N_ELEMENTS(mutt_menurc);
672         } else if (!strcmp(text, _("Old Sylpheed"))) {
673                 menurc = old_sylpheed_menurc;
674                 n_menurc = G_N_ELEMENTS(old_sylpheed_menurc);
675         } else {
676                 return;
677         }
678
679         /* prefs_keybind_apply(empty_menurc, G_N_ELEMENTS(empty_menurc)); */
680         prefs_keybind_apply(menurc, n_menurc);
681
682         gtk_widget_destroy(keybind.window);
683         keybind.window = NULL;
684         keybind.combo = NULL;
685 }
686
687 void prefs_summaries_create_widget(PrefsPage *_page, GtkWindow *window, 
688                                   gpointer data)
689 {
690         SummariesPage *prefs_summaries = (SummariesPage *) _page;
691         
692         GtkWidget *vbox1;
693         GtkWidget *chkbtn_transhdr;
694         GtkWidget *chkbtn_folder_unread;
695         GtkWidget *hbox1;
696         GtkWidget *label_ng_abbrev;
697         GtkWidget *spinbtn_ng_abbrev_len;
698         GtkObject *spinbtn_ng_abbrev_len_adj;
699         GtkWidget *vbox2;
700         GtkWidget *chkbtn_useaddrbook;
701         GtkWidget *chkbtn_threadsubj;
702         GtkWidget *vbox3;
703         GtkWidget *label_datefmt;
704         GtkWidget *button_datefmt;
705         GtkWidget *entry_datefmt;
706         GtkWidget *hbox_dispitem;
707         GtkWidget *frame_dispitem;
708         GtkWidget *button_dispitem;
709
710         GtkWidget *checkbtn_always_show_msg;
711         GtkWidget *checkbtn_mark_as_read_on_newwin;
712         GtkWidget *checkbtn_openinbox;
713         GtkWidget *checkbtn_immedexec;
714         GtkWidget *checkbtn_ask_mark_all_read;
715         GtkTooltips *immedexec_tooltip;
716         GtkWidget *label;
717         GtkWidget *menu;
718         GtkWidget *menuitem;
719         GtkWidget *button_keybind;
720         GtkWidget *hbox_select_on_entry;
721         GtkWidget *optmenu_select_on_entry;
722         GtkWidget *hbox_nextunreadmsgdialog;
723         GtkWidget *optmenu_nextunreadmsgdialog;
724
725         vbox1 = gtk_vbox_new (FALSE, VSPACING);
726         gtk_widget_show (vbox1);
727         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
728
729         vbox2 = gtk_vbox_new (FALSE, 0);
730         gtk_widget_show (vbox2);
731         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, TRUE, 0);
732
733         PACK_CHECK_BUTTON
734                 (vbox2, chkbtn_transhdr,
735                  _("Translate header name (such as 'From:', 'Subject:')"));
736
737         PACK_CHECK_BUTTON (vbox2, chkbtn_folder_unread,
738                            _("Display unread number next to folder name"));
739
740         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
741
742         hbox1 = gtk_hbox_new (FALSE, 8);
743         gtk_widget_show (hbox1);
744         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
745
746         label_ng_abbrev = gtk_label_new
747                 (_("Abbreviate newsgroup names longer than"));
748         gtk_widget_show (label_ng_abbrev);
749         gtk_box_pack_start (GTK_BOX (hbox1), label_ng_abbrev, FALSE, FALSE, 0);
750
751         spinbtn_ng_abbrev_len_adj = gtk_adjustment_new (16, 0, 999, 1, 10, 10);
752         spinbtn_ng_abbrev_len = gtk_spin_button_new
753                 (GTK_ADJUSTMENT (spinbtn_ng_abbrev_len_adj), 1, 0);
754         gtk_widget_show (spinbtn_ng_abbrev_len);
755         gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_ng_abbrev_len,
756                             FALSE, FALSE, 0);
757         gtk_widget_set_size_request (spinbtn_ng_abbrev_len, 56, -1);
758         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_ng_abbrev_len),
759                                      TRUE);
760
761         label_ng_abbrev = gtk_label_new (_("letters"));
762         gtk_widget_show (label_ng_abbrev);
763         gtk_box_pack_start (GTK_BOX (hbox1), label_ng_abbrev, FALSE, FALSE, 0);
764
765         /* ---- Summary ---- */
766
767         vbox2 = gtk_vbox_new (FALSE, 0);
768         gtk_widget_show (vbox2);
769         gtk_container_add (GTK_CONTAINER (vbox1), vbox2);
770         gtk_container_set_border_width (GTK_CONTAINER (vbox2), 0);
771
772         PACK_CHECK_BUTTON
773                 (vbox2, chkbtn_useaddrbook,
774                  _("Display sender using address book"));
775         PACK_CHECK_BUTTON
776                 (vbox2, chkbtn_threadsubj,
777                  _("Thread using subject in addition to standard headers"));
778
779         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
780
781         hbox1 = gtk_hbox_new (FALSE, 8);
782         gtk_widget_show (hbox1);
783         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
784
785         label_datefmt = gtk_label_new (_("Date format"));
786         gtk_widget_show (label_datefmt);
787         gtk_box_pack_start (GTK_BOX (hbox1), label_datefmt, FALSE, FALSE, 0);
788
789         entry_datefmt = gtk_entry_new ();
790         gtk_widget_show (entry_datefmt);
791         gtk_box_pack_start (GTK_BOX (hbox1), entry_datefmt, TRUE, TRUE, 0);
792
793         button_datefmt = gtk_button_new_with_label (" ... ");
794
795         gtk_widget_show (button_datefmt);
796         gtk_box_pack_start (GTK_BOX (hbox1), button_datefmt, FALSE, FALSE, 0);
797         g_signal_connect (G_OBJECT (button_datefmt), "clicked",
798                           G_CALLBACK (date_format_create), NULL);
799
800         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW);
801
802         PACK_FRAME(vbox2, frame_dispitem, _("Set displayed columns"));
803
804         hbox_dispitem = gtk_hbox_new (FALSE, 8);
805         gtk_widget_show (hbox_dispitem);
806         gtk_container_add (GTK_CONTAINER (frame_dispitem), hbox_dispitem);
807         gtk_container_set_border_width (GTK_CONTAINER (hbox_dispitem), 8);
808
809         button_dispitem = gtk_button_new_with_label
810                 (_(" Folder list... "));
811         gtk_widget_show (button_dispitem);
812         gtk_box_pack_start (GTK_BOX (hbox_dispitem), button_dispitem, FALSE, FALSE, 0);
813         g_signal_connect (G_OBJECT (button_dispitem), "clicked",
814                           G_CALLBACK (prefs_folder_column_open),
815                           NULL);
816         
817         button_dispitem = gtk_button_new_with_label
818                 (_(" Message list... "));
819         gtk_widget_show (button_dispitem);
820         gtk_box_pack_start (GTK_BOX (hbox_dispitem), button_dispitem, FALSE, FALSE, 0);
821         g_signal_connect (G_OBJECT (button_dispitem), "clicked",
822                           G_CALLBACK (prefs_summary_column_open),
823                           NULL);
824
825         vbox2 = gtk_vbox_new (FALSE, 0);
826         gtk_widget_show (vbox2);
827         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
828
829         /* PACK_CHECK_BUTTON (vbox2, checkbtn_emacs,
830                            _("Emulate the behavior of mouse operation of\n"
831                              "Emacs-based mailer"));
832         gtk_label_set_justify (GTK_LABEL (GTK_BIN (checkbtn_emacs)->child),
833                                GTK_JUSTIFY_LEFT);   */
834
835         PACK_CHECK_BUTTON
836                 (vbox2, checkbtn_always_show_msg,
837                  _("Always open message when selected"));
838
839         PACK_CHECK_BUTTON
840                 (vbox2, checkbtn_mark_as_read_on_newwin,
841                  _("Only mark message as read when opened in new window"));
842
843         PACK_CHECK_BUTTON
844                 (vbox2, checkbtn_openinbox,
845                  _("Go to inbox after receiving new mail"));
846
847         vbox3 = gtk_vbox_new (FALSE, 0);
848         gtk_widget_show (vbox3);
849         gtk_box_pack_start (GTK_BOX (vbox2), vbox3, FALSE, FALSE, 0);
850
851         immedexec_tooltip = gtk_tooltips_new();
852
853         PACK_CHECK_BUTTON
854                 (vbox3, checkbtn_immedexec,
855                  _("Execute immediately when moving or deleting messages"));
856         gtk_tooltips_set_tip(GTK_TOOLTIPS(immedexec_tooltip), checkbtn_immedexec,
857                              _("Messages will be marked until execution"
858                                " if this is turned off"),
859                              NULL);
860
861         PACK_CHECK_BUTTON
862                 (vbox3, checkbtn_ask_mark_all_read,
863                  _("Confirm before marking all mails in a folder as read"));
864
865         hbox1 = gtk_hbox_new (FALSE, 0);
866         gtk_widget_show (hbox1);
867         gtk_box_pack_start (GTK_BOX (vbox3), hbox1, FALSE, FALSE, 0);
868
869         hbox_select_on_entry = gtk_hbox_new (FALSE, 8);
870         gtk_widget_show (hbox_select_on_entry);
871         gtk_box_pack_start (GTK_BOX (vbox1), hbox_select_on_entry, FALSE, FALSE, 0);
872
873         label = gtk_label_new (_("When entering a folder"));
874         gtk_widget_show (label);
875         gtk_box_pack_start (GTK_BOX (hbox_select_on_entry), label, FALSE, FALSE, 8);
876
877         optmenu_select_on_entry = gtk_option_menu_new ();
878         gtk_widget_show (optmenu_select_on_entry);
879         gtk_box_pack_start (GTK_BOX (hbox_select_on_entry),
880                             optmenu_select_on_entry, FALSE, FALSE, 8);
881         
882         menu = gtk_menu_new ();
883         MENUITEM_ADD (menu, menuitem, _("Do nothing"), 0);
884         MENUITEM_ADD (menu, menuitem, _("Select first unread (or new) message"),
885                       SELECTONENTRY_UNREAD);
886         MENUITEM_ADD (menu, menuitem, _("Select first new (or unread) message"),
887                       SELECTONENTRY_NEW);
888
889         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_select_on_entry), menu);
890         
891         /* Next Unread Message Dialog */
892         hbox_nextunreadmsgdialog = gtk_hbox_new (FALSE, 8);
893         gtk_widget_show (hbox_nextunreadmsgdialog);
894         gtk_box_pack_start (GTK_BOX (vbox1), hbox_nextunreadmsgdialog, FALSE, FALSE, 0);
895
896         label = gtk_label_new (_("Show \"no unread (or new) message\" dialog"));
897         gtk_widget_show (label);
898         gtk_box_pack_start (GTK_BOX (hbox_nextunreadmsgdialog), label, FALSE, FALSE, 8);
899
900         optmenu_nextunreadmsgdialog = gtk_option_menu_new ();
901         gtk_widget_show (optmenu_nextunreadmsgdialog);
902         gtk_box_pack_start (GTK_BOX (hbox_nextunreadmsgdialog), optmenu_nextunreadmsgdialog, FALSE, FALSE, 8);
903         
904         menu = gtk_menu_new ();
905         MENUITEM_ADD (menu, menuitem, _("Always"), NEXTUNREADMSGDIALOG_ALWAYS);
906         MENUITEM_ADD (menu, menuitem, _("Assume 'Yes'"), 
907                       NEXTUNREADMSGDIALOG_ASSUME_YES);
908         MENUITEM_ADD (menu, menuitem, _("Assume 'No'"), 
909                       NEXTUNREADMSGDIALOG_ASSUME_NO);
910
911         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_nextunreadmsgdialog), menu);
912
913         hbox1 = gtk_hbox_new (FALSE, 8);
914         gtk_widget_show (hbox1);
915         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
916
917         button_keybind = gtk_button_new_with_label (_(" Set key bindings... "));
918         gtk_widget_show (button_keybind);
919         gtk_box_pack_start (GTK_BOX (hbox1), button_keybind, FALSE, FALSE, 0);
920         g_signal_connect (G_OBJECT (button_keybind), "clicked",
921                           G_CALLBACK (prefs_keybind_select), NULL);
922
923
924         prefs_summaries->window                 = GTK_WIDGET(window);
925         
926         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkbtn_transhdr),
927                         prefs_common.trans_hdr);
928         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkbtn_folder_unread),
929                         prefs_common.display_folder_unread);
930         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkbtn_useaddrbook),
931                         prefs_common.use_addr_book);
932         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkbtn_threadsubj),
933                         prefs_common.thread_by_subject);
934         gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_ng_abbrev_len),
935                         prefs_common.ng_abbrev_len);
936         gtk_entry_set_text(GTK_ENTRY(entry_datefmt), 
937                         prefs_common.date_format?prefs_common.date_format:"");  
938
939         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_always_show_msg),
940                         prefs_common.always_show_msg);
941         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_mark_as_read_on_newwin),
942                         prefs_common.mark_as_read_on_new_window);
943         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_openinbox),
944                         prefs_common.open_inbox_on_inc);
945         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_immedexec),
946                         prefs_common.immediate_exec);
947         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_ask_mark_all_read),
948                         prefs_common.ask_mark_all_read);
949
950         gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu_select_on_entry),
951                         prefs_common.select_on_entry);
952         gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu_nextunreadmsgdialog),
953                         prefs_common.next_unread_msg_dialog);
954
955         prefs_summaries->chkbtn_transhdr = chkbtn_transhdr;
956         prefs_summaries->chkbtn_folder_unread = chkbtn_folder_unread;
957         prefs_summaries->spinbtn_ng_abbrev_len = spinbtn_ng_abbrev_len;
958         prefs_summaries->chkbtn_useaddrbook = chkbtn_useaddrbook;
959         prefs_summaries->chkbtn_threadsubj = chkbtn_threadsubj;
960         prefs_summaries->entry_datefmt = entry_datefmt;
961
962         prefs_summaries->checkbtn_always_show_msg = checkbtn_always_show_msg;
963         prefs_summaries->checkbtn_mark_as_read_on_newwin = checkbtn_mark_as_read_on_newwin;
964         prefs_summaries->checkbtn_openinbox = checkbtn_openinbox;
965         prefs_summaries->checkbtn_immedexec = checkbtn_immedexec;
966         prefs_summaries->checkbtn_ask_mark_all_read = checkbtn_ask_mark_all_read;
967         prefs_summaries->optmenu_select_on_entry = optmenu_select_on_entry;
968         prefs_summaries->optmenu_nextunreadmsgdialog = optmenu_nextunreadmsgdialog;
969
970         prefs_summaries->page.widget = vbox1;
971 }
972
973 void prefs_summaries_save(PrefsPage *_page)
974 {
975         SummariesPage *page = (SummariesPage *) _page;
976         GtkWidget *menu;
977         GtkWidget *menuitem;
978
979         prefs_common.trans_hdr = gtk_toggle_button_get_active(
980                         GTK_TOGGLE_BUTTON(page->chkbtn_transhdr));
981         prefs_common.display_folder_unread = gtk_toggle_button_get_active(
982                         GTK_TOGGLE_BUTTON(page->chkbtn_folder_unread));
983         prefs_common.use_addr_book = gtk_toggle_button_get_active(
984                         GTK_TOGGLE_BUTTON(page->chkbtn_useaddrbook));
985         prefs_common.thread_by_subject = gtk_toggle_button_get_active(
986                         GTK_TOGGLE_BUTTON(page->chkbtn_threadsubj));
987         prefs_common.ng_abbrev_len = gtk_spin_button_get_value_as_int(
988                         GTK_SPIN_BUTTON(page->spinbtn_ng_abbrev_len));
989         
990         g_free(prefs_common.date_format); 
991         prefs_common.date_format = gtk_editable_get_chars(
992                         GTK_EDITABLE(page->entry_datefmt), 0, -1);      
993
994         prefs_common.always_show_msg = gtk_toggle_button_get_active(
995                 GTK_TOGGLE_BUTTON(page->checkbtn_always_show_msg));
996         prefs_common.mark_as_read_on_new_window = gtk_toggle_button_get_active(
997                 GTK_TOGGLE_BUTTON(page->checkbtn_mark_as_read_on_newwin));
998         prefs_common.open_inbox_on_inc = gtk_toggle_button_get_active(
999                 GTK_TOGGLE_BUTTON(page->checkbtn_openinbox));
1000         prefs_common.immediate_exec = gtk_toggle_button_get_active(
1001                 GTK_TOGGLE_BUTTON(page->checkbtn_immedexec));
1002         prefs_common.ask_mark_all_read = gtk_toggle_button_get_active(
1003                 GTK_TOGGLE_BUTTON(page->checkbtn_ask_mark_all_read));
1004
1005         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(page->optmenu_select_on_entry));
1006         menuitem = gtk_menu_get_active(GTK_MENU(menu));
1007         prefs_common.select_on_entry = GPOINTER_TO_INT
1008                 (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
1009         
1010         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(page->optmenu_nextunreadmsgdialog));
1011         menuitem = gtk_menu_get_active(GTK_MENU(menu));
1012         prefs_common.next_unread_msg_dialog = GPOINTER_TO_INT
1013                 (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
1014         main_window_reflect_prefs_all();
1015 }
1016
1017 static void prefs_summaries_destroy_widget(PrefsPage *_page)
1018 {
1019 }
1020
1021 SummariesPage *prefs_summaries;
1022
1023 void prefs_summaries_init(void)
1024 {
1025         SummariesPage *page;
1026         static gchar *path[3];
1027
1028         path[0] = _("Display");
1029         path[1] = _("Summaries");
1030         path[2] = NULL;
1031
1032         page = g_new0(SummariesPage, 1);
1033         page->page.path = path;
1034         page->page.create_widget = prefs_summaries_create_widget;
1035         page->page.destroy_widget = prefs_summaries_destroy_widget;
1036         page->page.save_page = prefs_summaries_save;
1037         page->page.weight = 140.0;
1038         prefs_gtk_register_page((PrefsPage *) page);
1039         prefs_summaries = page;
1040 }
1041
1042 void prefs_summaries_done(void)
1043 {
1044         prefs_gtk_unregister_page((PrefsPage *) prefs_summaries);
1045         g_free(prefs_summaries);
1046 }
1047
1048 static void date_format_ok_btn_clicked(GtkButton *button, GtkWidget **widget)
1049 {
1050         GtkWidget *datefmt_sample = NULL;
1051         gchar *text;
1052
1053         g_return_if_fail(widget != NULL);
1054         g_return_if_fail(*widget != NULL);
1055         g_return_if_fail(prefs_summaries->entry_datefmt != NULL);
1056
1057         datefmt_sample = GTK_WIDGET(g_object_get_data
1058                                     (G_OBJECT(*widget), "datefmt_sample"));
1059         g_return_if_fail(datefmt_sample != NULL);
1060
1061         text = gtk_editable_get_chars(GTK_EDITABLE(datefmt_sample), 0, -1);
1062         g_free(prefs_common.date_format);
1063         prefs_common.date_format = text;
1064         gtk_entry_set_text(GTK_ENTRY(prefs_summaries->entry_datefmt), text);
1065
1066         gtk_widget_destroy(*widget);
1067         *widget = NULL;
1068 }
1069
1070 static void date_format_cancel_btn_clicked(GtkButton *button,
1071                                            GtkWidget **widget)
1072 {
1073         g_return_if_fail(widget != NULL);
1074         g_return_if_fail(*widget != NULL);
1075
1076         gtk_widget_destroy(*widget);
1077         *widget = NULL;
1078 }
1079
1080 static gboolean date_format_key_pressed(GtkWidget *keywidget, GdkEventKey *event,
1081                                         GtkWidget **widget)
1082 {
1083         if (event && event->keyval == GDK_Escape)
1084                 date_format_cancel_btn_clicked(NULL, widget);
1085         return FALSE;
1086 }
1087
1088 static gboolean date_format_on_delete(GtkWidget *dialogwidget,
1089                                       GdkEventAny *event, GtkWidget **widget)
1090 {
1091         g_return_val_if_fail(widget != NULL, FALSE);
1092         g_return_val_if_fail(*widget != NULL, FALSE);
1093
1094         *widget = NULL;
1095         return FALSE;
1096 }
1097
1098 static void date_format_entry_on_change(GtkEditable *editable,
1099                                         GtkLabel *example)
1100 {
1101         time_t cur_time;
1102         struct tm *cal_time;
1103         gchar buffer[100];
1104         gchar *text;
1105
1106         cur_time = time(NULL);
1107         cal_time = localtime(&cur_time);
1108         buffer[0] = 0;
1109         text = gtk_editable_get_chars(editable, 0, -1);
1110         if (text)
1111                 strftime(buffer, sizeof buffer, text, cal_time); 
1112         g_free(text);
1113
1114         text = conv_codeset_strdup(buffer,
1115                                    conv_get_locale_charset_str(),
1116                                    CS_UTF_8);
1117         if (!text)
1118                 text = g_strdup(buffer);
1119
1120         gtk_label_set_text(example, text);
1121
1122         g_free(text);
1123 }
1124
1125 static void date_format_select_row(GtkTreeView *list_view,
1126                                    GtkTreePath *path,
1127                                    GtkTreeViewColumn *column,
1128                                    GtkWidget *date_format)
1129 {
1130         gint cur_pos;
1131         gchar *format;
1132         const gchar *old_format;
1133         gchar *new_format;
1134         GtkWidget *datefmt_sample;
1135         GtkTreeIter iter;
1136         GtkTreeModel *model;
1137         
1138         g_return_if_fail(date_format != NULL);
1139
1140         /* only on double click */
1141         datefmt_sample = GTK_WIDGET(g_object_get_data(G_OBJECT(date_format), 
1142                                                       "datefmt_sample"));
1143
1144         g_return_if_fail(datefmt_sample != NULL);
1145
1146         model = gtk_tree_view_get_model(list_view);
1147
1148         /* get format from list */
1149         if (!gtk_tree_model_get_iter(model, &iter, path))
1150                 return;
1151
1152         gtk_tree_model_get(model, &iter, DATEFMT_FMT, &format, -1);             
1153         
1154         cur_pos = gtk_editable_get_position(GTK_EDITABLE(datefmt_sample));
1155         old_format = gtk_entry_get_text(GTK_ENTRY(datefmt_sample));
1156
1157         /* insert the format into the text entry */
1158         new_format = g_malloc(strlen(old_format) + 3);
1159
1160         strncpy(new_format, old_format, cur_pos);
1161         new_format[cur_pos] = '\0';
1162         strcat(new_format, format);
1163         strcat(new_format, &old_format[cur_pos]);
1164
1165         gtk_entry_set_text(GTK_ENTRY(datefmt_sample), new_format);
1166         gtk_editable_set_position(GTK_EDITABLE(datefmt_sample), cur_pos + 2);
1167
1168         g_free(new_format);
1169 }