575617069bb9dc54a742cf18c0f6d4bce380c7bb
[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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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
38 #include "gtk/menu.h"
39 #include "gtk/gtkutils.h"
40 #include "gtk/prefswindow.h"
41
42 #include "manage_window.h"
43
44 typedef struct _SummariesPage
45 {
46         PrefsPage page;
47
48         GtkWidget *window;
49
50         GtkWidget *chkbtn_transhdr;
51         GtkWidget *chkbtn_folder_unread;
52         GtkWidget *spinbtn_ng_abbrev_len;
53         GtkWidget *chkbtn_swapfrom;
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 *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.enable_rules_hint);
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, &ok_btn, GTK_STOCK_OK,
261                                 &cancel_btn, GTK_STOCK_CANCEL, 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), _("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         hbox1 = gtk_hbox_new (FALSE, 8);
347         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
348
349         combo = gtk_combo_new ();
350         gtk_box_pack_start (GTK_BOX (hbox1), combo, TRUE, TRUE, 0);
351         gtkut_combo_set_items (GTK_COMBO (combo),
352                                _("Default"),
353                                "Mew / Wanderlust",
354                                "Mutt",
355                                _("Old Sylpheed"),
356                                NULL);
357         gtk_editable_set_editable(GTK_EDITABLE(GTK_COMBO (combo)->entry), FALSE);
358
359         hbox1 = gtk_hbox_new (FALSE, 8);
360         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
361
362         label = gtk_label_new
363                 (_("You can also modify each menu shortcut by pressing\n"
364                    "any key(s) when placing the mouse pointer on the item."));
365         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
366         gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
367
368         hbox1 = gtk_hbox_new (FALSE, 8);
369         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
370
371         gtkut_stock_button_set_create (&confirm_area, &ok_btn, GTK_STOCK_OK,
372                                        &cancel_btn, GTK_STOCK_CANCEL,
373                                        NULL, NULL);
374         gtk_box_pack_end (GTK_BOX (hbox1), confirm_area, FALSE, FALSE, 0);
375         gtk_widget_grab_default (ok_btn);
376
377         MANAGE_WINDOW_SIGNALS_CONNECT(window);
378         g_signal_connect (G_OBJECT (window), "delete_event",
379                           G_CALLBACK (prefs_keybind_deleted), NULL);
380         g_signal_connect (G_OBJECT (window), "key_press_event",
381                           G_CALLBACK (prefs_keybind_key_pressed), NULL);
382         g_signal_connect (G_OBJECT (ok_btn), "clicked",
383                           G_CALLBACK (prefs_keybind_apply_clicked),
384                           NULL);
385         g_signal_connect (G_OBJECT (cancel_btn), "clicked",
386                           G_CALLBACK (prefs_keybind_cancel),
387                           NULL);
388
389         gtk_widget_show_all(window);
390
391         keybind.window = window;
392         keybind.combo = combo;
393 }
394
395 static gboolean prefs_keybind_key_pressed(GtkWidget *widget, GdkEventKey *event,
396                                           gpointer data)
397 {
398         if (event && event->keyval == GDK_Escape)
399                 prefs_keybind_cancel();
400         return FALSE;
401 }
402
403 static gint prefs_keybind_deleted(GtkWidget *widget, GdkEventAny *event,
404                                   gpointer data)
405 {
406         prefs_keybind_cancel();
407         return TRUE;
408 }
409
410 static void prefs_keybind_cancel(void)
411 {
412         gtk_widget_destroy(keybind.window);
413         keybind.window = NULL;
414         keybind.combo = NULL;
415 }
416   
417 struct KeyBind {
418         const gchar *accel_path;
419         const gchar *accel_key;
420 };
421
422 static void prefs_keybind_apply(struct KeyBind keybind[], gint num)
423 {
424         gint i;
425         guint key;
426         GdkModifierType mods;
427
428         for (i = 0; i < num; i++) {
429                 const gchar *accel_key
430                         = keybind[i].accel_key ? keybind[i].accel_key : "";
431                 gtk_accelerator_parse(accel_key, &key, &mods);
432                 gtk_accel_map_change_entry(keybind[i].accel_path,
433                                            key, mods, TRUE);
434         }
435 }
436
437 static void prefs_keybind_apply_clicked(GtkWidget *widget)
438 {
439         GtkEntry *entry = GTK_ENTRY(GTK_COMBO(keybind.combo)->entry);
440         const gchar *text;
441         struct KeyBind *menurc;
442         gint n_menurc;
443
444         static struct KeyBind default_menurc[] = {
445                 {"<Main>/File/Empty all Trash folders",         ""},
446                 {"<Main>/File/Save as...",                      "<control>S"},
447                 {"<Main>/File/Print...",                        ""},
448                 {"<Main>/File/Exit",                            "<control>Q"},
449
450                 {"<Main>/Edit/Copy",                            "<control>C"},
451                 {"<Main>/Edit/Select all",                      "<control>A"},
452                 {"<Main>/Edit/Find in current message...",      "<control>F"},
453                 {"<Main>/Edit/Search folder...",                "<shift><control>F"},
454
455                 {"<Main>/View/Show or hide/Message View",       "V"},
456                 {"<Main>/View/Thread view",                     "<control>T"},
457                 {"<Main>/View/Go to/Prev message",              "P"},
458                 {"<Main>/View/Go to/Next message",              "N"},
459                 {"<Main>/View/Go to/Prev unread message",       "<shift>P"},
460                 {"<Main>/View/Go to/Next unread message",       "<shift>N"},
461                 {"<Main>/View/Go to/Other folder...",           "G"},
462                 {"<Main>/View/Open in new window",              "<control><alt>N"},
463                 {"<Main>/View/Message source",                  "<control>U"},
464                 {"<Main>/View/Show all headers",                "<control>H"},
465                 {"<Main>/View/Update summary",                  "<control><alt>U"},
466
467                 {"<Main>/Message/Receive/Get from current account",
468                                                                 "<control>I"},
469                 {"<Main>/Message/Receive/Get from all accounts","<shift><control>I"},
470                 {"<Main>/Message/Compose an email message",     "<control>M"},
471                 {"<Main>/Message/Reply",                        "<control>R"},
472                 {"<Main>/Message/Reply to/all",                 "<shift><control>R"},
473                 {"<Main>/Message/Reply to/sender",              ""},
474                 {"<Main>/Message/Reply to/mailing list",        "<control>L"},
475                 {"<Main>/Message/Forward",                      "<control><alt>F"},
476                 /* {"<Main>/Message/Forward as attachment",      ""}, */
477                 {"<Main>/Message/Move...",                      "<control>O"},
478                 {"<Main>/Message/Copy...",                      "<shift><control>O"},
479                 {"<Main>/Message/Delete",                       "<control>D"},
480                 {"<Main>/Message/Mark/Mark",                    "<shift>asterisk"},
481                 {"<Main>/Message/Mark/Unmark",                  "U"},
482                 {"<Main>/Message/Mark/Mark as unread",          "<shift>exclam"},
483                 {"<Main>/Message/Mark/Mark as read",            ""},
484
485                 {"<Main>/Tools/Address book",                   "<shift><control>A"},
486                 {"<Main>/Tools/Execute",                        "X"},
487                 {"<Main>/Tools/Log window",                     "<shift><control>L"},
488
489                 {"<Compose>/Message/Close",                             "<control>W"},
490                 {"<Compose>/Edit/Select all",                           "<control>A"},
491                 {"<Compose>/Edit/Advanced/Move a word backward",        ""},
492                 {"<Compose>/Edit/Advanced/Move a word forward",         ""},
493                 {"<Compose>/Edit/Advanced/Move to beginning of line",   ""},
494                 {"<Compose>/Edit/Advanced/Delete a word backward",      ""},
495                 {"<Compose>/Edit/Advanced/Delete a word forward",       ""},
496         };
497
498         static struct KeyBind mew_wl_menurc[] = {
499                 {"<Main>/File/Empty all Trash folders",                 "<shift>D"},
500                 {"<Main>/File/Save as...",                      "Y"},
501                 {"<Main>/File/Print...",                        "<shift>numbersign"},
502                 {"<Main>/File/Exit",                            "<shift>Q"},
503
504                 {"<Main>/Edit/Copy",                            "<control>C"},
505                 {"<Main>/Edit/Select all",                      "<control>A"},
506                 {"<Main>/Edit/Find in current message...",      "<control>F"},
507                 {"<Main>/Edit/Search folder...",                "<control>S"},
508
509                 {"<Main>/View/Show or hide/Message View",       ""},
510                 {"<Main>/View/Thread view",                     "<shift>T"},
511                 {"<Main>/View/Go to/Prev message",              "P"},
512                 {"<Main>/View/Go to/Next message",              "N"},
513                 {"<Main>/View/Go to/Prev unread message",       "<shift>P"},
514                 {"<Main>/View/Go to/Next unread message",       "<shift>N"},
515                 {"<Main>/View/Go to/Other folder...",           "G"},
516                 {"<Main>/View/Open in new window",              "<control><alt>N"},
517                 {"<Main>/View/Message source",                  "<control>U"},
518                 {"<Main>/View/Show all headers",                "<shift>H"},
519                 {"<Main>/View/Update summary",                  "<shift>S"},
520
521                 {"<Main>/Message/Receive/Get from current account",
522                                                                 "<control>I"},
523                 {"<Main>/Message/Receive/Get from all accounts","<shift><control>I"},
524                 {"<Main>/Message/Compose an email message",     "W"},
525                 {"<Main>/Message/Reply",                        "<control>R"},
526                 {"<Main>/Message/Reply to/all",                 "<shift>A"},
527                 {"<Main>/Message/Reply to/sender",              ""},
528                 {"<Main>/Message/Reply to/mailing list",        "<control>L"},
529                 {"<Main>/Message/Forward",                      "F"},
530                 /* {"<Main>/Message/Forward as attachment", "<shift>F"}, */
531                 {"<Main>/Message/Move...",                      "O"},
532                 {"<Main>/Message/Copy...",                      "<shift>O"},
533                 {"<Main>/Message/Delete",                       "D"},
534                 {"<Main>/Message/Mark/Mark",                    "<shift>asterisk"},
535                 {"<Main>/Message/Mark/Unmark",                  "U"},
536                 {"<Main>/Message/Mark/Mark as unread",          "<shift>exclam"},
537                 {"<Main>/Message/Mark/Mark as read",            "<shift>R"},
538
539                 {"<Main>/Tools/Address book",                   "<shift><control>A"},
540                 {"<Main>/Tools/Execute",                        "X"},
541                 {"<Main>/Tools/Log window",                     "<shift><control>L"},
542
543                 {"<Compose>/Message/Close",                             "<alt>W"},
544                 {"<Compose>/Edit/Select all",                           ""},
545                 {"<Compose>/Edit/Advanced/Move a word backward,"        "<alt>B"},
546                 {"<Compose>/Edit/Advanced/Move a word forward",         "<alt>F"},
547                 {"<Compose>/Edit/Advanced/Move to beginning of line",   "<control>A"},
548                 {"<Compose>/Edit/Advanced/Delete a word backward",      "<control>W"},
549                 {"<Compose>/Edit/Advanced/Delete a word forward",       "<alt>D"},
550         };
551
552         static struct KeyBind mutt_menurc[] = {
553                 {"<Main>/File/Empty all Trash folders",         ""},
554                 {"<Main>/File/Save as...",                      "S"},
555                 {"<Main>/File/Print...",                        "P"},
556                 {"<Main>/File/Exit",                            "Q"},
557
558                 {"<Main>/Edit/Copy",                            "<control>C"},
559                 {"<Main>/Edit/Select all",                      "<control>A"},
560                 {"<Main>/Edit/Find in current message...",      "<control>F"},
561                 {"<Main>/Edit/Search messages...",              "slash"},
562
563                 {"<Main>/View/Show or hide/Message view",       "V"},
564                 {"<Main>/View/Thread view",                     "<control>T"},
565                 {"<Main>/View/Go to/Prev message",              ""},
566                 {"<Main>/View/Go to/Next message",              ""},
567                 {"<Main>/View/Go to/Prev unread message",       ""},
568                 {"<Main>/View/Go to/Next unread message",       ""},
569                 {"<Main>/View/Go to/Other folder...",           "C"},
570                 {"<Main>/View/Open in new window",              "<control><alt>N"},
571                 {"<Main>/View/Message source",                  "<control>U"},
572                 {"<Main>/View/Show all headers",                "<control>H"},
573                 {"<Main>/View/Update summary",                          "<control><alt>U"},
574
575                 {"<Main>/Message/Receive/Get from current account",
576                                                                 "<control>I"},
577                 {"<Main>/Message/Receive/Get from all accounts","<shift><control>I"},
578                 {"<Main>/Message/Compose an email message",             "M"},
579                 {"<Main>/Message/Reply",                        "R"},
580                 {"<Main>/Message/Reply to/all",                 "G"},
581                 {"<Main>/Message/Reply to/sender",              ""},
582                 {"<Main>/Message/Reply to/mailing list",        "<control>L"},
583                 {"<Main>/Message/Forward",                      "F"},
584                 {"<Main>/Message/Forward as attachment",        ""},
585                 {"<Main>/Message/Move...",                      "<control>O"},
586                 {"<Main>/Message/Copy...",                      "<shift>C"},
587                 {"<Main>/Message/Delete",                       "D"},
588                 {"<Main>/Message/Mark/Mark",                    "<shift>F"},
589                 {"<Main>/Message/Mark/Unmark",                  "U"},
590                 {"<Main>/Message/Mark/Mark as unread",          "<shift>N"},
591                 {"<Main>/Message/Mark/Mark as read",            ""},
592
593                 {"<Main>/Tools/Address book",                   "<shift><control>A"},
594                 {"<Main>/Tools/Execute",                        "X"},
595                 {"<Main>/Tools/Log window",                     "<shift><control>L"},
596
597                 {"<Compose>/Message/Close",                             "<alt>W"},
598                 {"<Compose>/Edit/Select all",                           ""},
599                 {"<Compose>/Edit/Advanced/Move a word backward",        "<alt>B"},
600                 {"<Compose>/Edit/Advanced/Move a word forward",         "<alt>F"},
601                 {"<Compose>/Edit/Advanced/Move to beginning of line",   "<control>A"},
602                 {"<Compose>/Edit/Advanced/Delete a word backward",      "<control>W"},
603                 {"<Compose>/Edit/Advanced/Delete a word forward",       "<alt>D"},
604         };
605
606         static struct KeyBind old_sylpheed_menurc[] = {
607                 {"<Main>/File/Empty all Trash folders",         ""},
608                 {"<Main>/File/Save as...",                      ""},
609                 {"<Main>/File/Print...",                        "<alt>P"},
610                 {"<Main>/File/Exit",                            "<alt>Q"},
611
612                 {"<Main>/Edit/Copy",                            "<control>C"},
613                 {"<Main>/Edit/Select all",                      "<control>A"},
614                 {"<Main>/Edit/Find in current message...",      "<control>F"},
615                 {"<Main>/Edit/Search folder...",                "<control>S"},
616
617                 {"<Main>/View/Show or hide/Message View",       ""},
618                 {"<Main>/View/Thread view",                     "<control>T"},
619                 {"<Main>/View/Go to/Prev message",              "P"},
620                 {"<Main>/View/Go to/Next message",              "N"},
621                 {"<Main>/View/Go to/Prev unread message",       "<shift>P"},
622                 {"<Main>/View/Go to/Next unread message",       "<shift>N"},
623                 {"<Main>/View/Go to/Other folder...",           "<alt>G"},
624                 {"<Main>/View/Open in new window",              "<shift><control>N"},
625                 {"<Main>/View/Message source",                  "<control>U"},
626                 {"<Main>/View/Show all headers",                "<control>H"},
627                 {"<Main>/View/Update summary",                  "<alt>U"},
628
629                 {"<Main>/Message/Receive/Get from current account",
630                                                                 "<alt>I"},
631                 {"<Main>/Message/Receive/Get from all accounts","<shift><alt>I"},
632                 {"<Main>/Message/Compose an email message",     "<alt>N"},
633                 {"<Main>/Message/Reply",                        "<alt>R"},
634                 {"<Main>/Message/Reply to/all",                 "<shift><alt>R"},
635                 {"<Main>/Message/Reply to/sender",              "<control><alt>R"},
636                 {"<Main>/Message/Reply to/mailing list",        "<control>L"},
637                 {"<Main>/Message/Forward",                       "<shift><alt>F"},
638                 /* "(menu-path \"<Main>/Message/Forward as attachment", "<shift><control>F"}, */
639                 {"<Main>/Message/Move...",                      "<alt>O"},
640                 {"<Main>/Message/Copy...",                      ""},
641                 {"<Main>/Message/Delete",                       "<alt>D"},
642                 {"<Main>/Message/Mark/Mark",                    "<shift>asterisk"},
643                 {"<Main>/Message/Mark/Unmark",                  "U"},
644                 {"<Main>/Message/Mark/Mark as unread",          "<shift>exclam"},
645                 {"<Main>/Message/Mark/Mark as read",            ""},
646
647                 {"<Main>/Tools/Address book",                   "<alt>A"},
648                 {"<Main>/Tools/Execute",                        "<alt>X"},
649                 {"<Main>/Tools/Log window",                     "<alt>L"},
650
651                 {"<Compose>/Message/Close",                             "<alt>W"},
652                 {"<Compose>/Edit/Select all",                           ""},
653                 {"<Compose>/Edit/Advanced/Move a word backward",        "<alt>B"},
654                 {"<Compose>/Edit/Advanced/Move a word forward",         "<alt>F"},
655                 {"<Compose>/Edit/Advanced/Move to beginning of line",   "<control>A"},
656                 {"<Compose>/Edit/Advanced/Delete a word backward",      "<control>W"},
657                 {"<Compose>/Edit/Advanced/Delete a word forward",       "<alt>D"},
658         };
659   
660         text = gtk_entry_get_text(entry);
661   
662         if (!strcmp(text, _("Default"))) {
663                 menurc = default_menurc;
664                 n_menurc = G_N_ELEMENTS(default_menurc);
665         } else if (!strcmp(text, "Mew / Wanderlust")) {
666                 menurc = mew_wl_menurc;
667                 n_menurc = G_N_ELEMENTS(mew_wl_menurc);
668         } else if (!strcmp(text, "Mutt")) {
669                 menurc = mutt_menurc;
670                 n_menurc = G_N_ELEMENTS(mutt_menurc);
671         } else if (!strcmp(text, _("Old Sylpheed"))) {
672                 menurc = old_sylpheed_menurc;
673                 n_menurc = G_N_ELEMENTS(old_sylpheed_menurc);
674         } else {
675                 return;
676         }
677
678         /* prefs_keybind_apply(empty_menurc, G_N_ELEMENTS(empty_menurc)); */
679         prefs_keybind_apply(menurc, n_menurc);
680
681         gtk_widget_destroy(keybind.window);
682         keybind.window = NULL;
683         keybind.combo = NULL;
684 }
685
686 void prefs_summaries_create_widget(PrefsPage *_page, GtkWindow *window, 
687                                   gpointer data)
688 {
689         SummariesPage *prefs_summaries = (SummariesPage *) _page;
690         
691         GtkWidget *vbox1;
692         GtkWidget *chkbtn_transhdr;
693         GtkWidget *chkbtn_folder_unread;
694         GtkWidget *hbox1;
695         GtkWidget *label_ng_abbrev;
696         GtkWidget *spinbtn_ng_abbrev_len;
697         GtkObject *spinbtn_ng_abbrev_len_adj;
698         GtkWidget *frame_summary;
699         GtkWidget *vbox2;
700         GtkWidget *chkbtn_swapfrom;
701         GtkWidget *chkbtn_useaddrbook;
702         GtkWidget *chkbtn_threadsubj;
703         GtkWidget *vbox3;
704         GtkWidget *label_datefmt;
705         GtkWidget *button_datefmt;
706         GtkWidget *entry_datefmt;
707         GtkWidget *button_dispitem;
708
709         GtkWidget *checkbtn_always_show_msg;
710         GtkWidget *checkbtn_mark_as_read_on_newwin;
711         GtkWidget *checkbtn_openinbox;
712         GtkWidget *checkbtn_immedexec;
713         GtkTooltips *immedexec_tooltip;
714         GtkWidget *label;
715         GtkWidget *menu;
716         GtkWidget *menuitem;
717         GtkWidget *button_keybind;
718         GtkWidget *hbox_select_on_entry;
719         GtkWidget *optmenu_select_on_entry;
720         GtkWidget *hbox_nextunreadmsgdialog;
721         GtkWidget *optmenu_nextunreadmsgdialog;
722
723         vbox1 = gtk_vbox_new (FALSE, VSPACING);
724         gtk_widget_show (vbox1);
725         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
726
727         vbox2 = gtk_vbox_new (FALSE, 0);
728         gtk_widget_show (vbox2);
729         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, TRUE, 0);
730
731         PACK_CHECK_BUTTON
732                 (vbox2, chkbtn_transhdr,
733                  _("Translate header name (such as 'From:', 'Subject:')"));
734
735         PACK_CHECK_BUTTON (vbox2, chkbtn_folder_unread,
736                            _("Display unread number next to folder name"));
737
738         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
739
740         hbox1 = gtk_hbox_new (FALSE, 8);
741         gtk_widget_show (hbox1);
742         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
743
744         label_ng_abbrev = gtk_label_new
745                 (_("Abbreviate newsgroup names longer than"));
746         gtk_widget_show (label_ng_abbrev);
747         gtk_box_pack_start (GTK_BOX (hbox1), label_ng_abbrev, FALSE, FALSE, 0);
748
749         spinbtn_ng_abbrev_len_adj = gtk_adjustment_new (16, 0, 999, 1, 10, 10);
750         spinbtn_ng_abbrev_len = gtk_spin_button_new
751                 (GTK_ADJUSTMENT (spinbtn_ng_abbrev_len_adj), 1, 0);
752         gtk_widget_show (spinbtn_ng_abbrev_len);
753         gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_ng_abbrev_len,
754                             FALSE, FALSE, 0);
755         gtk_widget_set_size_request (spinbtn_ng_abbrev_len, 56, -1);
756         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_ng_abbrev_len),
757                                      TRUE);
758
759         label_ng_abbrev = gtk_label_new
760                 (_("letters"));
761         gtk_widget_show (label_ng_abbrev);
762         gtk_box_pack_start (GTK_BOX (hbox1), label_ng_abbrev, FALSE, FALSE, 0);
763
764         /* ---- Summary ---- */
765
766         PACK_FRAME(vbox1, frame_summary, _("Summary View"));
767
768         vbox2 = gtk_vbox_new (FALSE, 0);
769         gtk_widget_show (vbox2);
770         gtk_container_add (GTK_CONTAINER (frame_summary), vbox2);
771         gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
772
773         PACK_CHECK_BUTTON
774                 (vbox2, chkbtn_swapfrom,
775                  _("Display recipient in 'From' column if sender is yourself"));
776         PACK_CHECK_BUTTON
777                 (vbox2, chkbtn_useaddrbook,
778                  _("Display sender using address book"));
779         PACK_CHECK_BUTTON
780                 (vbox2, chkbtn_threadsubj,
781                  _("Thread using subject in addition to standard headers"));
782
783         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
784
785         hbox1 = gtk_hbox_new (FALSE, 8);
786         gtk_widget_show (hbox1);
787         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
788
789         label_datefmt = gtk_label_new (_("Date format"));
790         gtk_widget_show (label_datefmt);
791         gtk_box_pack_start (GTK_BOX (hbox1), label_datefmt, FALSE, FALSE, 0);
792
793         entry_datefmt = gtk_entry_new ();
794         gtk_widget_show (entry_datefmt);
795         gtk_box_pack_start (GTK_BOX (hbox1), entry_datefmt, TRUE, TRUE, 0);
796
797         button_datefmt = gtk_button_new_with_label (" ... ");
798
799         gtk_widget_show (button_datefmt);
800         gtk_box_pack_start (GTK_BOX (hbox1), button_datefmt, FALSE, FALSE, 0);
801         g_signal_connect (G_OBJECT (button_datefmt), "clicked",
802                           G_CALLBACK (date_format_create), NULL);
803
804         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW);
805
806         hbox1 = gtk_hbox_new (FALSE, 8);
807         gtk_widget_show (hbox1);
808         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
809
810         button_dispitem = gtk_button_new_with_label
811                 (_(" Set displayed items in summary... "));
812         gtk_widget_show (button_dispitem);
813         gtk_box_pack_start (GTK_BOX (hbox1), button_dispitem, FALSE, TRUE, 0);
814         g_signal_connect (G_OBJECT (button_dispitem), "clicked",
815                           G_CALLBACK (prefs_summary_column_open),
816                           NULL);
817
818         vbox2 = gtk_vbox_new (FALSE, 0);
819         gtk_widget_show (vbox2);
820         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
821
822         /* PACK_CHECK_BUTTON (vbox2, checkbtn_emacs,
823                            _("Emulate the behavior of mouse operation of\n"
824                              "Emacs-based mailer"));
825         gtk_label_set_justify (GTK_LABEL (GTK_BIN (checkbtn_emacs)->child),
826                                GTK_JUSTIFY_LEFT);   */
827
828         PACK_CHECK_BUTTON
829                 (vbox2, checkbtn_always_show_msg,
830                  _("Always open message when selected"));
831
832         PACK_CHECK_BUTTON
833                 (vbox2, checkbtn_mark_as_read_on_newwin,
834                  _("Only mark message as read when opened in new window"));
835
836         PACK_CHECK_BUTTON
837                 (vbox2, checkbtn_openinbox,
838                  _("Go to inbox after receiving new mail"));
839
840         vbox3 = gtk_vbox_new (FALSE, 0);
841         gtk_widget_show (vbox3);
842         gtk_box_pack_start (GTK_BOX (vbox2), vbox3, FALSE, FALSE, 0);
843
844         immedexec_tooltip = gtk_tooltips_new();
845
846         PACK_CHECK_BUTTON
847                 (vbox3, checkbtn_immedexec,
848                  _("Execute immediately when moving or deleting messages"));
849         gtk_tooltips_set_tip(GTK_TOOLTIPS(immedexec_tooltip), checkbtn_immedexec,
850                              _("Messages will be marked until execution"
851                                " if this is turned off"),
852                              NULL);
853
854         hbox1 = gtk_hbox_new (FALSE, 0);
855         gtk_widget_show (hbox1);
856         gtk_box_pack_start (GTK_BOX (vbox3), hbox1, FALSE, FALSE, 0);
857
858         hbox_select_on_entry = gtk_hbox_new (FALSE, 8);
859         gtk_widget_show (hbox_select_on_entry);
860         gtk_box_pack_start (GTK_BOX (vbox1), hbox_select_on_entry, FALSE, FALSE, 0);
861
862         label = gtk_label_new (_("When entering a folder"));
863         gtk_widget_show (label);
864         gtk_box_pack_start (GTK_BOX (hbox_select_on_entry), label, FALSE, FALSE, 8);
865
866         optmenu_select_on_entry = gtk_option_menu_new ();
867         gtk_widget_show (optmenu_select_on_entry);
868         gtk_box_pack_start (GTK_BOX (hbox_select_on_entry),
869                             optmenu_select_on_entry, FALSE, FALSE, 8);
870         
871         menu = gtk_menu_new ();
872         MENUITEM_ADD (menu, menuitem, _("Do nothing"), 0);
873         MENUITEM_ADD (menu, menuitem, _("Select first unread message"),
874                       SELECTONENTRY_UNREAD);
875         MENUITEM_ADD (menu, menuitem, _("Select first new message"),
876                       SELECTONENTRY_NEW);
877
878         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_select_on_entry), menu);
879         
880         /* Next Unread Message Dialog */
881         hbox_nextunreadmsgdialog = gtk_hbox_new (FALSE, 8);
882         gtk_widget_show (hbox_nextunreadmsgdialog);
883         gtk_box_pack_start (GTK_BOX (vbox1), hbox_nextunreadmsgdialog, FALSE, FALSE, 0);
884
885         label = gtk_label_new (_("Show no-unread-message dialog"));
886         gtk_widget_show (label);
887         gtk_box_pack_start (GTK_BOX (hbox_nextunreadmsgdialog), label, FALSE, FALSE, 8);
888
889         optmenu_nextunreadmsgdialog = gtk_option_menu_new ();
890         gtk_widget_show (optmenu_nextunreadmsgdialog);
891         gtk_box_pack_start (GTK_BOX (hbox_nextunreadmsgdialog), optmenu_nextunreadmsgdialog, FALSE, FALSE, 8);
892         
893         menu = gtk_menu_new ();
894         MENUITEM_ADD (menu, menuitem, _("Always"), NEXTUNREADMSGDIALOG_ALWAYS);
895         MENUITEM_ADD (menu, menuitem, _("Assume 'Yes'"), 
896                       NEXTUNREADMSGDIALOG_ASSUME_YES);
897         MENUITEM_ADD (menu, menuitem, _("Assume 'No'"), 
898                       NEXTUNREADMSGDIALOG_ASSUME_NO);
899
900         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_nextunreadmsgdialog), menu);
901
902         hbox1 = gtk_hbox_new (FALSE, 8);
903         gtk_widget_show (hbox1);
904         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
905
906         button_keybind = gtk_button_new_with_label (_(" Set key bindings... "));
907         gtk_widget_show (button_keybind);
908         gtk_box_pack_start (GTK_BOX (hbox1), button_keybind, FALSE, FALSE, 0);
909         g_signal_connect (G_OBJECT (button_keybind), "clicked",
910                           G_CALLBACK (prefs_keybind_select), NULL);
911
912
913         prefs_summaries->window                 = GTK_WIDGET(window);
914         
915         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkbtn_transhdr),
916                         prefs_common.trans_hdr);
917         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkbtn_folder_unread),
918                         prefs_common.display_folder_unread);
919         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkbtn_swapfrom),
920                         prefs_common.swap_from);
921         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkbtn_useaddrbook),
922                         prefs_common.use_addr_book);
923         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkbtn_threadsubj),
924                         prefs_common.thread_by_subject);
925         gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_ng_abbrev_len),
926                         prefs_common.ng_abbrev_len);
927         gtk_entry_set_text(GTK_ENTRY(entry_datefmt), 
928                         prefs_common.date_format?prefs_common.date_format:"");  
929
930         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_always_show_msg),
931                         prefs_common.always_show_msg);
932         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_mark_as_read_on_newwin),
933                         prefs_common.mark_as_read_on_new_window);
934         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_openinbox),
935                         prefs_common.open_inbox_on_inc);
936         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_immedexec),
937                         prefs_common.immediate_exec);
938
939         gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu_select_on_entry),
940                         prefs_common.select_on_entry);
941         gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu_nextunreadmsgdialog),
942                         prefs_common.next_unread_msg_dialog);
943
944         prefs_summaries->chkbtn_transhdr = chkbtn_transhdr;
945         prefs_summaries->chkbtn_folder_unread = chkbtn_folder_unread;
946         prefs_summaries->spinbtn_ng_abbrev_len = spinbtn_ng_abbrev_len;
947         prefs_summaries->chkbtn_swapfrom = chkbtn_swapfrom;
948         prefs_summaries->chkbtn_useaddrbook = chkbtn_useaddrbook;
949         prefs_summaries->chkbtn_threadsubj = chkbtn_threadsubj;
950         prefs_summaries->entry_datefmt = entry_datefmt;
951
952         prefs_summaries->checkbtn_always_show_msg = checkbtn_always_show_msg;
953         prefs_summaries->checkbtn_mark_as_read_on_newwin = checkbtn_mark_as_read_on_newwin;
954         prefs_summaries->checkbtn_openinbox = checkbtn_openinbox;
955         prefs_summaries->checkbtn_immedexec = checkbtn_immedexec;
956         prefs_summaries->optmenu_select_on_entry = optmenu_select_on_entry;
957         prefs_summaries->optmenu_nextunreadmsgdialog = optmenu_nextunreadmsgdialog;
958
959         prefs_summaries->page.widget = vbox1;
960 }
961
962 void prefs_summaries_save(PrefsPage *_page)
963 {
964         SummariesPage *page = (SummariesPage *) _page;
965         GtkWidget *menu;
966         GtkWidget *menuitem;
967
968         prefs_common.trans_hdr = gtk_toggle_button_get_active(
969                         GTK_TOGGLE_BUTTON(page->chkbtn_transhdr));
970         prefs_common.display_folder_unread = gtk_toggle_button_get_active(
971                         GTK_TOGGLE_BUTTON(page->chkbtn_folder_unread));
972         prefs_common.swap_from = gtk_toggle_button_get_active(
973                         GTK_TOGGLE_BUTTON(page->chkbtn_swapfrom));
974         prefs_common.use_addr_book = gtk_toggle_button_get_active(
975                         GTK_TOGGLE_BUTTON(page->chkbtn_useaddrbook));
976         prefs_common.thread_by_subject = gtk_toggle_button_get_active(
977                         GTK_TOGGLE_BUTTON(page->chkbtn_threadsubj));
978         prefs_common.ng_abbrev_len = gtk_spin_button_get_value_as_int(
979                         GTK_SPIN_BUTTON(page->spinbtn_ng_abbrev_len));
980         
981         g_free(prefs_common.date_format); 
982         prefs_common.date_format = gtk_editable_get_chars(
983                         GTK_EDITABLE(page->entry_datefmt), 0, -1);      
984
985         prefs_common.always_show_msg = gtk_toggle_button_get_active(
986                 GTK_TOGGLE_BUTTON(page->checkbtn_always_show_msg));
987         prefs_common.mark_as_read_on_new_window = gtk_toggle_button_get_active(
988                 GTK_TOGGLE_BUTTON(page->checkbtn_mark_as_read_on_newwin));
989         prefs_common.open_inbox_on_inc = gtk_toggle_button_get_active(
990                 GTK_TOGGLE_BUTTON(page->checkbtn_openinbox));
991         prefs_common.immediate_exec = gtk_toggle_button_get_active(
992                 GTK_TOGGLE_BUTTON(page->checkbtn_immedexec));
993
994         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(page->optmenu_select_on_entry));
995         menuitem = gtk_menu_get_active(GTK_MENU(menu));
996         prefs_common.select_on_entry = GPOINTER_TO_INT
997                 (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
998         
999         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(page->optmenu_nextunreadmsgdialog));
1000         menuitem = gtk_menu_get_active(GTK_MENU(menu));
1001         prefs_common.next_unread_msg_dialog = GPOINTER_TO_INT
1002                 (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
1003         main_window_reflect_prefs_all();
1004 }
1005
1006 static void prefs_summaries_destroy_widget(PrefsPage *_page)
1007 {
1008 }
1009
1010 SummariesPage *prefs_summaries;
1011
1012 void prefs_summaries_init(void)
1013 {
1014         SummariesPage *page;
1015         static gchar *path[3];
1016
1017         path[0] = _("Display");
1018         path[1] = _("Summaries");
1019         path[2] = NULL;
1020
1021         page = g_new0(SummariesPage, 1);
1022         page->page.path = path;
1023         page->page.create_widget = prefs_summaries_create_widget;
1024         page->page.destroy_widget = prefs_summaries_destroy_widget;
1025         page->page.save_page = prefs_summaries_save;
1026         page->page.weight = 140.0;
1027         prefs_gtk_register_page((PrefsPage *) page);
1028         prefs_summaries = page;
1029 }
1030
1031 void prefs_summaries_done(void)
1032 {
1033         prefs_gtk_unregister_page((PrefsPage *) prefs_summaries);
1034         g_free(prefs_summaries);
1035 }
1036
1037 static void date_format_ok_btn_clicked(GtkButton *button, GtkWidget **widget)
1038 {
1039         GtkWidget *datefmt_sample = NULL;
1040         gchar *text;
1041
1042         g_return_if_fail(widget != NULL);
1043         g_return_if_fail(*widget != NULL);
1044         g_return_if_fail(prefs_summaries->entry_datefmt != NULL);
1045
1046         datefmt_sample = GTK_WIDGET(g_object_get_data
1047                                     (G_OBJECT(*widget), "datefmt_sample"));
1048         g_return_if_fail(datefmt_sample != NULL);
1049
1050         text = gtk_editable_get_chars(GTK_EDITABLE(datefmt_sample), 0, -1);
1051         g_free(prefs_common.date_format);
1052         prefs_common.date_format = text;
1053         gtk_entry_set_text(GTK_ENTRY(prefs_summaries->entry_datefmt), text);
1054
1055         gtk_widget_destroy(*widget);
1056         *widget = NULL;
1057 }
1058
1059 static void date_format_cancel_btn_clicked(GtkButton *button,
1060                                            GtkWidget **widget)
1061 {
1062         g_return_if_fail(widget != NULL);
1063         g_return_if_fail(*widget != NULL);
1064
1065         gtk_widget_destroy(*widget);
1066         *widget = NULL;
1067 }
1068
1069 static gboolean date_format_key_pressed(GtkWidget *keywidget, GdkEventKey *event,
1070                                         GtkWidget **widget)
1071 {
1072         if (event && event->keyval == GDK_Escape)
1073                 date_format_cancel_btn_clicked(NULL, widget);
1074         return FALSE;
1075 }
1076
1077 static gboolean date_format_on_delete(GtkWidget *dialogwidget,
1078                                       GdkEventAny *event, GtkWidget **widget)
1079 {
1080         g_return_val_if_fail(widget != NULL, FALSE);
1081         g_return_val_if_fail(*widget != NULL, FALSE);
1082
1083         *widget = NULL;
1084         return FALSE;
1085 }
1086
1087 static void date_format_entry_on_change(GtkEditable *editable,
1088                                         GtkLabel *example)
1089 {
1090         time_t cur_time;
1091         struct tm *cal_time;
1092         gchar buffer[100];
1093         gchar *text;
1094
1095         cur_time = time(NULL);
1096         cal_time = localtime(&cur_time);
1097         buffer[0] = 0;
1098         text = gtk_editable_get_chars(editable, 0, -1);
1099         if (text)
1100                 strftime(buffer, sizeof buffer, text, cal_time); 
1101         g_free(text);
1102
1103         text = conv_codeset_strdup(buffer,
1104                                    conv_get_locale_charset_str(),
1105                                    CS_UTF_8);
1106         if (!text)
1107                 text = g_strdup(buffer);
1108
1109         gtk_label_set_text(example, text);
1110
1111         g_free(text);
1112 }
1113
1114 static void date_format_select_row(GtkTreeView *list_view,
1115                                    GtkTreePath *path,
1116                                    GtkTreeViewColumn *column,
1117                                    GtkWidget *date_format)
1118 {
1119         gint cur_pos;
1120         gchar *format;
1121         const gchar *old_format;
1122         gchar *new_format;
1123         GtkWidget *datefmt_sample;
1124         GtkTreeIter iter;
1125         GtkTreeModel *model;
1126         
1127         g_return_if_fail(date_format != NULL);
1128
1129         /* only on double click */
1130         datefmt_sample = GTK_WIDGET(g_object_get_data(G_OBJECT(date_format), 
1131                                                       "datefmt_sample"));
1132
1133         g_return_if_fail(datefmt_sample != NULL);
1134
1135         model = gtk_tree_view_get_model(list_view);
1136
1137         /* get format from list */
1138         if (!gtk_tree_model_get_iter(model, &iter, path))
1139                 return;
1140
1141         gtk_tree_model_get(model, &iter, DATEFMT_FMT, &format, -1);             
1142         
1143         cur_pos = gtk_editable_get_position(GTK_EDITABLE(datefmt_sample));
1144         old_format = gtk_entry_get_text(GTK_ENTRY(datefmt_sample));
1145
1146         /* insert the format into the text entry */
1147         new_format = g_malloc(strlen(old_format) + 3);
1148
1149         strncpy(new_format, old_format, cur_pos);
1150         new_format[cur_pos] = '\0';
1151         strcat(new_format, format);
1152         strcat(new_format, &old_format[cur_pos]);
1153
1154         gtk_entry_set_text(GTK_ENTRY(datefmt_sample), new_format);
1155         gtk_editable_set_position(GTK_EDITABLE(datefmt_sample), cur_pos + 2);
1156
1157         g_free(new_format);
1158 }