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