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
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.
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.
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.
30 #include <glib/gi18n.h>
32 #include <gdk/gdkkeysyms.h>
34 #include "prefs_common.h"
35 #include "prefs_gtk.h"
36 #include "prefs_summary_column.h"
37 #include "prefs_folder_column.h"
40 #include "gtk/gtkutils.h"
41 #include "gtk/prefswindow.h"
43 #include "manage_window.h"
45 typedef struct _SummariesPage
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;
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;
74 static void date_format_ok_btn_clicked (GtkButton *button,
76 static void date_format_cancel_btn_clicked (GtkButton *button,
78 static gboolean date_format_key_pressed (GtkWidget *keywidget,
81 static gboolean date_format_on_delete (GtkWidget *dialogwidget,
84 static void date_format_entry_on_change (GtkEditable *editable,
86 static void date_format_select_row (GtkTreeView *list_view,
88 GtkTreeViewColumn *column,
89 GtkWidget *date_format);
91 static GtkWidget *date_format_create(GtkButton *button, void *data)
93 static GtkWidget *datefmt_win = NULL;
96 GtkWidget *scrolledwindow1;
97 GtkWidget *datefmt_list_view;
102 GtkWidget *confirm_area;
104 GtkWidget *cancel_btn;
105 GtkWidget *datefmt_entry;
134 const gint TIME_FORMAT_ELEMS =
135 sizeof time_format / sizeof time_format[0];
137 GtkCellRenderer *renderer;
138 GtkTreeViewColumn *column;
139 GtkTreeSelection *selection;
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");
161 if (datefmt_win) return datefmt_win;
163 store = gtk_list_store_new(N_DATEFMT_COLUMNS,
168 for (i = 0; i < TIME_FORMAT_ELEMS; i++) {
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,
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);
184 vbox1 = gtk_vbox_new(FALSE, 10);
185 gtk_widget_show(vbox1);
186 gtk_container_add(GTK_CONTAINER(datefmt_win), vbox1);
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);
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);
202 renderer = gtk_cell_renderer_text_new();
203 column = gtk_tree_view_column_new_with_attributes
204 (_("Specifier"), renderer, "text", DATEFMT_FMT,
206 gtk_tree_view_append_column(GTK_TREE_VIEW(datefmt_list_view), column);
208 renderer = gtk_cell_renderer_text_new();
209 column = gtk_tree_view_column_new_with_attributes
210 (_("Description"), renderer, "text", DATEFMT_TXT,
212 gtk_tree_view_append_column(GTK_TREE_VIEW(datefmt_list_view), column);
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);
218 g_signal_connect(G_OBJECT(datefmt_list_view), "row_activated",
219 G_CALLBACK(date_format_select_row),
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);
228 label1 = gtk_label_new(_("Date format"));
229 gtk_widget_show(label1);
230 gtk_table_attach(GTK_TABLE(table), label1, 0, 1, 0, 1,
232 gtk_label_set_justify(GTK_LABEL(label1), GTK_JUSTIFY_LEFT);
233 gtk_misc_set_alignment(GTK_MISC(label1), 0, 0.5);
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);
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",
246 label2 = gtk_label_new(_("Example"));
247 gtk_widget_show(label2);
248 gtk_table_attach(GTK_TABLE(table), label2, 0, 1, 1, 2,
250 gtk_label_set_justify(GTK_LABEL(label2), GTK_JUSTIFY_LEFT);
251 gtk_misc_set_alignment(GTK_MISC(label2), 0, 0.5);
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);
260 gtkut_stock_button_set_create(&confirm_area, &cancel_btn, GTK_STOCK_CANCEL,
261 &ok_btn, GTK_STOCK_OK, NULL, NULL);
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);
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),
272 g_signal_connect(G_OBJECT(ok_btn), "clicked",
273 G_CALLBACK(date_format_ok_btn_clicked),
275 g_signal_connect(G_OBJECT(cancel_btn), "clicked",
276 G_CALLBACK(date_format_cancel_btn_clicked),
278 g_signal_connect(G_OBJECT(datefmt_win), "key_press_event",
279 G_CALLBACK(date_format_key_pressed),
281 g_signal_connect(G_OBJECT(datefmt_win), "delete_event",
282 G_CALLBACK(date_format_on_delete),
284 g_signal_connect(G_OBJECT(datefmt_entry), "changed",
285 G_CALLBACK(date_format_entry_on_change),
288 gtk_window_set_position(GTK_WINDOW(datefmt_win), GTK_WIN_POS_CENTER);
289 gtk_window_set_modal(GTK_WINDOW(datefmt_win), TRUE);
291 gtk_widget_show(datefmt_win);
292 manage_window_set_transient(GTK_WINDOW(datefmt_win));
294 gtk_widget_grab_focus(ok_btn);
299 static struct KeybindDialog {
304 static void prefs_keybind_select (void);
305 static gint prefs_keybind_deleted (GtkWidget *widget,
308 static gboolean prefs_keybind_key_pressed (GtkWidget *widget,
311 static void prefs_keybind_cancel (void);
312 static void prefs_keybind_apply_clicked (GtkWidget *widget);
315 static void prefs_keybind_select(void)
322 GtkWidget *confirm_area;
324 GtkWidget *cancel_btn;
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));
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);
338 hbox1 = gtk_hbox_new (FALSE, 8);
339 gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
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);
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),
354 gtk_editable_set_editable(GTK_EDITABLE(GTK_COMBO (combo)->entry), FALSE);
356 hbox1 = gtk_hbox_new (FALSE, 8);
357 gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
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);
367 hbox1 = gtk_hbox_new (FALSE, 8);
368 gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
370 gtkut_stock_button_set_create (&confirm_area, &cancel_btn, GTK_STOCK_CANCEL,
371 &ok_btn, GTK_STOCK_OK,
373 gtk_box_pack_end (GTK_BOX (hbox1), confirm_area, FALSE, FALSE, 0);
374 gtk_widget_grab_focus (ok_btn);
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),
384 g_signal_connect (G_OBJECT (cancel_btn), "clicked",
385 G_CALLBACK (prefs_keybind_cancel),
388 gtk_widget_show_all(window);
390 keybind.window = window;
391 keybind.combo = combo;
394 static gboolean prefs_keybind_key_pressed(GtkWidget *widget, GdkEventKey *event,
397 if (event && event->keyval == GDK_Escape)
398 prefs_keybind_cancel();
402 static gint prefs_keybind_deleted(GtkWidget *widget, GdkEventAny *event,
405 prefs_keybind_cancel();
409 static void prefs_keybind_cancel(void)
411 gtk_widget_destroy(keybind.window);
412 keybind.window = NULL;
413 keybind.combo = NULL;
417 const gchar *accel_path;
418 const gchar *accel_key;
421 static void prefs_keybind_apply(struct KeyBind keybind[], gint num)
425 GdkModifierType mods;
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,
436 static void prefs_keybind_apply_clicked(GtkWidget *widget)
438 GtkEntry *entry = GTK_ENTRY(GTK_COMBO(keybind.combo)->entry);
440 struct KeyBind *menurc;
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"},
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"},
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/Show all headers", "<control>H"},
467 {"<Main>/View/Update summary", "<control><alt>U"},
469 {"<Main>/Message/Receive/Get from current account",
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", ""},
487 {"<Main>/Tools/Address book", "<shift><control>A"},
488 {"<Main>/Tools/Execute", "X"},
489 {"<Main>/Tools/Log window", "<shift><control>L"},
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"},
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"},
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"},
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/Show all headers", "<shift>H"},
547 {"<Main>/View/Update summary", "<shift>S"},
549 {"<Main>/Message/Receive/Get from current account",
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"},
567 {"<Main>/Tools/Address book", "<shift><control>A"},
568 {"<Main>/Tools/Execute", "X"},
569 {"<Main>/Tools/Log window", "<shift><control>L"},
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"},
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"},
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"},
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/Show all headers", "<control>H"},
601 {"<Main>/View/Update summary", "<control><alt>U"},
603 {"<Main>/Message/Receive/Get from current account",
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", ""},
621 {"<Main>/Tools/Address book", "<shift><control>A"},
622 {"<Main>/Tools/Execute", "X"},
623 {"<Main>/Tools/Log window", "<shift><control>L"},
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"},
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"},
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"},
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/Show all headers", "<control>H"},
655 {"<Main>/View/Update summary", "<alt>U"},
657 {"<Main>/Message/Receive/Get from current account",
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", ""},
675 {"<Main>/Tools/Address book", "<alt>A"},
676 {"<Main>/Tools/Execute", "<alt>X"},
677 {"<Main>/Tools/Log window", "<alt>L"},
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"},
688 text = gtk_entry_get_text(entry);
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);
706 /* prefs_keybind_apply(empty_menurc, G_N_ELEMENTS(empty_menurc)); */
707 prefs_keybind_apply(menurc, n_menurc);
709 gtk_widget_destroy(keybind.window);
710 keybind.window = NULL;
711 keybind.combo = NULL;
714 void prefs_summaries_create_widget(PrefsPage *_page, GtkWindow *window,
717 SummariesPage *prefs_summaries = (SummariesPage *) _page;
720 GtkWidget *chkbtn_transhdr;
721 GtkWidget *chkbtn_folder_unread;
723 GtkWidget *label_ng_abbrev;
724 GtkWidget *spinbtn_ng_abbrev_len;
725 GtkObject *spinbtn_ng_abbrev_len_adj;
727 GtkWidget *chkbtn_useaddrbook;
728 GtkWidget *chkbtn_threadsubj;
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;
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;
748 GtkWidget *button_keybind;
749 GtkWidget *optmenu_select_on_entry;
750 GtkWidget *optmenu_nextunreadmsgdialog;
753 GtkTooltips *tooltips;
755 tooltips = gtk_tooltips_new();
757 vbox1 = gtk_vbox_new (FALSE, VSPACING);
758 gtk_widget_show (vbox1);
759 gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
761 vbox2 = gtk_vbox_new (FALSE, 0);
762 gtk_widget_show (vbox2);
763 gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, TRUE, 0);
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);
772 PACK_CHECK_BUTTON (vbox2, chkbtn_folder_unread,
773 _("Display unread number next to folder name"));
775 hbox1 = gtk_hbox_new (FALSE, 8);
776 gtk_widget_show (hbox1);
777 gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
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);
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,
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),
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);
798 /* ---- Summary ---- */
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);
806 (vbox3, chkbtn_useaddrbook,
807 _("Display sender using address book"));
809 (vbox3, chkbtn_threadsubj,
810 _("Thread using subject in addition to standard headers"));
812 hbox1 = gtk_hbox_new (FALSE, 8);
813 gtk_widget_show (hbox1);
814 gtk_box_pack_start (GTK_BOX (vbox3), hbox1, FALSE, TRUE, 0);
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);
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);
824 button_datefmt = gtk_button_new_with_label (" ... ");
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),
833 _("Date format help"), NULL);
835 PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW);
837 PACK_FRAME(vbox3, frame_dispitem, _("Set displayed columns"));
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);
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),
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),
860 vbox4 = gtk_vbox_new (FALSE, 0);
861 gtk_widget_show (vbox4);
862 gtk_box_pack_start (GTK_BOX (vbox1), vbox4, FALSE, FALSE, 0);
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); */
870 immedexec_tooltip = gtk_tooltips_new();
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"),
881 (vbox4, checkbtn_ask_mark_all_read,
882 _("Confirm before marking all mails in a folder as read"));
885 (vbox4, checkbtn_always_show_msg,
886 _("Always open message when selected"));
889 (vbox4, checkbtn_mark_as_read_on_newwin,
890 _("Only mark message as read when opened in a new window"));
893 vbox5 = gtk_vbox_new (FALSE, 0);
894 gtk_widget_show (vbox5);
895 gtk_box_pack_start (GTK_BOX (vbox1), vbox5, FALSE, FALSE, 0);
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);
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);
911 optmenu_select_on_entry = gtk_option_menu_new ();
912 gtk_widget_show (optmenu_select_on_entry);
914 gtk_table_attach(GTK_TABLE(table), optmenu_select_on_entry, 1, 2, 0, 1,
915 (GtkAttachOptions) (GTK_FILL),
916 (GtkAttachOptions) (0), 0, 0);
918 menu = gtk_menu_new ();
919 MENUITEM_ADD (menu, menuitem, _("Do nothing"), 0);
920 MENUITEM_ADD (menu, menuitem, _("Select first unread (or new) message"),
921 SELECTONENTRY_UNREAD);
922 MENUITEM_ADD (menu, menuitem, _("Select first new (or unread) message"),
925 gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_select_on_entry), menu);
927 /* Next Unread Message Dialog */
928 table = gtk_table_new(1, 1, FALSE);
929 gtk_widget_show(table);
930 gtk_container_add (GTK_CONTAINER (vbox5), table);
931 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
932 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
934 label = gtk_label_new (_("Show \"no unread (or new) message\" dialog"));
935 gtk_widget_show (label);
936 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2,
937 (GtkAttachOptions) (GTK_FILL),
938 (GtkAttachOptions) (0), 0, 0);
939 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT);
940 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
942 optmenu_nextunreadmsgdialog = gtk_option_menu_new ();
943 gtk_widget_show (optmenu_nextunreadmsgdialog);
945 gtk_table_attach(GTK_TABLE(table), optmenu_nextunreadmsgdialog, 1, 2, 1, 2,
946 (GtkAttachOptions) (GTK_FILL),
947 (GtkAttachOptions) (0), 0, 0);
949 menu = gtk_menu_new ();
950 MENUITEM_ADD (menu, menuitem, _("Always"), NEXTUNREADMSGDIALOG_ALWAYS);
951 MENUITEM_ADD (menu, menuitem, _("Assume 'Yes'"),
952 NEXTUNREADMSGDIALOG_ASSUME_YES);
953 MENUITEM_ADD (menu, menuitem, _("Assume 'No'"),
954 NEXTUNREADMSGDIALOG_ASSUME_NO);
956 gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_nextunreadmsgdialog), menu);
958 hbox2 = gtk_hbox_new (FALSE, 8);
959 gtk_widget_show (hbox2);
960 gtk_box_pack_start (GTK_BOX (vbox1), hbox2, FALSE, FALSE, 0);
962 button_keybind = gtk_button_new_with_label (_(" Set key bindings... "));
963 gtk_widget_show (button_keybind);
964 gtk_box_pack_start (GTK_BOX (hbox2), button_keybind, FALSE, FALSE, 0);
965 g_signal_connect (G_OBJECT (button_keybind), "clicked",
966 G_CALLBACK (prefs_keybind_select), NULL);
969 prefs_summaries->window = GTK_WIDGET(window);
971 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkbtn_transhdr),
972 prefs_common.trans_hdr);
973 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkbtn_folder_unread),
974 prefs_common.display_folder_unread);
975 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkbtn_useaddrbook),
976 prefs_common.use_addr_book);
977 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkbtn_threadsubj),
978 prefs_common.thread_by_subject);
979 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_ng_abbrev_len),
980 prefs_common.ng_abbrev_len);
981 gtk_entry_set_text(GTK_ENTRY(entry_datefmt),
982 prefs_common.date_format?prefs_common.date_format:"");
984 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_always_show_msg),
985 prefs_common.always_show_msg);
986 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_mark_as_read_on_newwin),
987 prefs_common.mark_as_read_on_new_window);
988 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_immedexec),
989 prefs_common.immediate_exec);
990 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_ask_mark_all_read),
991 prefs_common.ask_mark_all_read);
993 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu_select_on_entry),
994 prefs_common.select_on_entry);
995 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu_nextunreadmsgdialog),
996 prefs_common.next_unread_msg_dialog);
998 prefs_summaries->chkbtn_transhdr = chkbtn_transhdr;
999 prefs_summaries->chkbtn_folder_unread = chkbtn_folder_unread;
1000 prefs_summaries->spinbtn_ng_abbrev_len = spinbtn_ng_abbrev_len;
1001 prefs_summaries->chkbtn_useaddrbook = chkbtn_useaddrbook;
1002 prefs_summaries->chkbtn_threadsubj = chkbtn_threadsubj;
1003 prefs_summaries->entry_datefmt = entry_datefmt;
1005 prefs_summaries->checkbtn_always_show_msg = checkbtn_always_show_msg;
1006 prefs_summaries->checkbtn_mark_as_read_on_newwin = checkbtn_mark_as_read_on_newwin;
1007 prefs_summaries->checkbtn_immedexec = checkbtn_immedexec;
1008 prefs_summaries->checkbtn_ask_mark_all_read = checkbtn_ask_mark_all_read;
1009 prefs_summaries->optmenu_select_on_entry = optmenu_select_on_entry;
1010 prefs_summaries->optmenu_nextunreadmsgdialog = optmenu_nextunreadmsgdialog;
1012 prefs_summaries->page.widget = vbox1;
1015 void prefs_summaries_save(PrefsPage *_page)
1017 SummariesPage *page = (SummariesPage *) _page;
1019 GtkWidget *menuitem;
1021 prefs_common.trans_hdr = gtk_toggle_button_get_active(
1022 GTK_TOGGLE_BUTTON(page->chkbtn_transhdr));
1023 prefs_common.display_folder_unread = gtk_toggle_button_get_active(
1024 GTK_TOGGLE_BUTTON(page->chkbtn_folder_unread));
1025 prefs_common.use_addr_book = gtk_toggle_button_get_active(
1026 GTK_TOGGLE_BUTTON(page->chkbtn_useaddrbook));
1027 prefs_common.thread_by_subject = gtk_toggle_button_get_active(
1028 GTK_TOGGLE_BUTTON(page->chkbtn_threadsubj));
1029 prefs_common.ng_abbrev_len = gtk_spin_button_get_value_as_int(
1030 GTK_SPIN_BUTTON(page->spinbtn_ng_abbrev_len));
1032 g_free(prefs_common.date_format);
1033 prefs_common.date_format = gtk_editable_get_chars(
1034 GTK_EDITABLE(page->entry_datefmt), 0, -1);
1036 prefs_common.always_show_msg = gtk_toggle_button_get_active(
1037 GTK_TOGGLE_BUTTON(page->checkbtn_always_show_msg));
1038 prefs_common.mark_as_read_on_new_window = gtk_toggle_button_get_active(
1039 GTK_TOGGLE_BUTTON(page->checkbtn_mark_as_read_on_newwin));
1040 prefs_common.immediate_exec = gtk_toggle_button_get_active(
1041 GTK_TOGGLE_BUTTON(page->checkbtn_immedexec));
1042 prefs_common.ask_mark_all_read = gtk_toggle_button_get_active(
1043 GTK_TOGGLE_BUTTON(page->checkbtn_ask_mark_all_read));
1045 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(page->optmenu_select_on_entry));
1046 menuitem = gtk_menu_get_active(GTK_MENU(menu));
1047 prefs_common.select_on_entry = GPOINTER_TO_INT
1048 (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
1050 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(page->optmenu_nextunreadmsgdialog));
1051 menuitem = gtk_menu_get_active(GTK_MENU(menu));
1052 prefs_common.next_unread_msg_dialog = GPOINTER_TO_INT
1053 (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
1054 main_window_reflect_prefs_all();
1057 static void prefs_summaries_destroy_widget(PrefsPage *_page)
1061 SummariesPage *prefs_summaries;
1063 void prefs_summaries_init(void)
1065 SummariesPage *page;
1066 static gchar *path[3];
1068 path[0] = _("Display");
1069 path[1] = _("Summaries");
1072 page = g_new0(SummariesPage, 1);
1073 page->page.path = path;
1074 page->page.create_widget = prefs_summaries_create_widget;
1075 page->page.destroy_widget = prefs_summaries_destroy_widget;
1076 page->page.save_page = prefs_summaries_save;
1077 page->page.weight = 140.0;
1078 prefs_gtk_register_page((PrefsPage *) page);
1079 prefs_summaries = page;
1082 void prefs_summaries_done(void)
1084 prefs_gtk_unregister_page((PrefsPage *) prefs_summaries);
1085 g_free(prefs_summaries);
1088 static void date_format_ok_btn_clicked(GtkButton *button, GtkWidget **widget)
1090 GtkWidget *datefmt_sample = NULL;
1093 g_return_if_fail(widget != NULL);
1094 g_return_if_fail(*widget != NULL);
1095 g_return_if_fail(prefs_summaries->entry_datefmt != NULL);
1097 datefmt_sample = GTK_WIDGET(g_object_get_data
1098 (G_OBJECT(*widget), "datefmt_sample"));
1099 g_return_if_fail(datefmt_sample != NULL);
1101 text = gtk_editable_get_chars(GTK_EDITABLE(datefmt_sample), 0, -1);
1102 g_free(prefs_common.date_format);
1103 prefs_common.date_format = text;
1104 gtk_entry_set_text(GTK_ENTRY(prefs_summaries->entry_datefmt), text);
1106 gtk_widget_destroy(*widget);
1110 static void date_format_cancel_btn_clicked(GtkButton *button,
1113 g_return_if_fail(widget != NULL);
1114 g_return_if_fail(*widget != NULL);
1116 gtk_widget_destroy(*widget);
1120 static gboolean date_format_key_pressed(GtkWidget *keywidget, GdkEventKey *event,
1123 if (event && event->keyval == GDK_Escape)
1124 date_format_cancel_btn_clicked(NULL, widget);
1128 static gboolean date_format_on_delete(GtkWidget *dialogwidget,
1129 GdkEventAny *event, GtkWidget **widget)
1131 g_return_val_if_fail(widget != NULL, FALSE);
1132 g_return_val_if_fail(*widget != NULL, FALSE);
1138 static void date_format_entry_on_change(GtkEditable *editable,
1142 struct tm *cal_time;
1146 cur_time = time(NULL);
1147 cal_time = localtime(&cur_time);
1149 text = gtk_editable_get_chars(editable, 0, -1);
1151 strftime(buffer, sizeof buffer, text, cal_time);
1154 text = conv_codeset_strdup(buffer,
1155 conv_get_locale_charset_str(),
1158 text = g_strdup(buffer);
1160 gtk_label_set_text(example, text);
1165 static void date_format_select_row(GtkTreeView *list_view,
1167 GtkTreeViewColumn *column,
1168 GtkWidget *date_format)
1172 const gchar *old_format;
1174 GtkWidget *datefmt_sample;
1176 GtkTreeModel *model;
1178 g_return_if_fail(date_format != NULL);
1180 /* only on double click */
1181 datefmt_sample = GTK_WIDGET(g_object_get_data(G_OBJECT(date_format),
1184 g_return_if_fail(datefmt_sample != NULL);
1186 model = gtk_tree_view_get_model(list_view);
1188 /* get format from list */
1189 if (!gtk_tree_model_get_iter(model, &iter, path))
1192 gtk_tree_model_get(model, &iter, DATEFMT_FMT, &format, -1);
1194 cur_pos = gtk_editable_get_position(GTK_EDITABLE(datefmt_sample));
1195 old_format = gtk_entry_get_text(GTK_ENTRY(datefmt_sample));
1197 /* insert the format into the text entry */
1198 new_format = g_malloc(strlen(old_format) + 3);
1200 strncpy(new_format, old_format, cur_pos);
1201 new_format[cur_pos] = '\0';
1202 strcat(new_format, format);
1203 strcat(new_format, &old_format[cur_pos]);
1205 gtk_entry_set_text(GTK_ENTRY(datefmt_sample), new_format);
1206 gtk_editable_set_position(GTK_EDITABLE(datefmt_sample), cur_pos + 2);