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;
754 vbox1 = gtk_vbox_new (FALSE, VSPACING);
755 gtk_widget_show (vbox1);
756 gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
758 vbox2 = gtk_vbox_new (FALSE, 0);
759 gtk_widget_show (vbox2);
760 gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, TRUE, 0);
763 (vbox2, chkbtn_transhdr,
764 _("Translate header name (such as 'From:', 'Subject:')"));
766 PACK_CHECK_BUTTON (vbox2, chkbtn_folder_unread,
767 _("Display unread number next to folder name"));
769 hbox1 = gtk_hbox_new (FALSE, 8);
770 gtk_widget_show (hbox1);
771 gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
773 label_ng_abbrev = gtk_label_new
774 (_("Abbreviate newsgroup names longer than"));
775 gtk_widget_show (label_ng_abbrev);
776 gtk_box_pack_start (GTK_BOX (hbox1), label_ng_abbrev, FALSE, FALSE, 0);
778 spinbtn_ng_abbrev_len_adj = gtk_adjustment_new (16, 0, 999, 1, 10, 10);
779 spinbtn_ng_abbrev_len = gtk_spin_button_new
780 (GTK_ADJUSTMENT (spinbtn_ng_abbrev_len_adj), 1, 0);
781 gtk_widget_show (spinbtn_ng_abbrev_len);
782 gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_ng_abbrev_len,
784 gtk_widget_set_size_request (spinbtn_ng_abbrev_len, 56, -1);
785 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_ng_abbrev_len),
788 label_ng_abbrev = gtk_label_new (_("letters"));
789 gtk_widget_show (label_ng_abbrev);
790 gtk_box_pack_start (GTK_BOX (hbox1), label_ng_abbrev, FALSE, FALSE, 0);
792 /* ---- Summary ---- */
794 vbox3 = gtk_vbox_new (FALSE, 0);
795 gtk_widget_show (vbox3);
796 gtk_container_add (GTK_CONTAINER (vbox2), vbox3);
797 gtk_container_set_border_width (GTK_CONTAINER (vbox3), 0);
800 (vbox3, chkbtn_useaddrbook,
801 _("Display sender using address book"));
803 (vbox3, chkbtn_threadsubj,
804 _("Thread using subject in addition to standard headers"));
806 hbox1 = gtk_hbox_new (FALSE, 8);
807 gtk_widget_show (hbox1);
808 gtk_box_pack_start (GTK_BOX (vbox3), hbox1, FALSE, TRUE, 0);
810 label_datefmt = gtk_label_new (_("Date format"));
811 gtk_widget_show (label_datefmt);
812 gtk_box_pack_start (GTK_BOX (hbox1), label_datefmt, FALSE, FALSE, 0);
814 entry_datefmt = gtk_entry_new ();
815 gtk_widget_show (entry_datefmt);
816 gtk_box_pack_start (GTK_BOX (hbox1), entry_datefmt, TRUE, TRUE, 0);
818 button_datefmt = gtk_button_new_with_label (" ... ");
820 gtk_widget_show (button_datefmt);
821 gtk_box_pack_start (GTK_BOX (hbox1), button_datefmt, FALSE, FALSE, 0);
822 g_signal_connect (G_OBJECT (button_datefmt), "clicked",
823 G_CALLBACK (date_format_create), NULL);
824 tip_datefmt = gtk_tooltips_new();
825 gtk_tooltips_set_tip(GTK_TOOLTIPS(tip_datefmt),
827 _("Date format help"), NULL);
829 PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW);
831 PACK_FRAME(vbox3, frame_dispitem, _("Set displayed columns"));
833 hbox_dispitem = gtk_hbox_new (FALSE, 8);
834 gtk_widget_show (hbox_dispitem);
835 gtk_container_add (GTK_CONTAINER (frame_dispitem), hbox_dispitem);
836 gtk_container_set_border_width (GTK_CONTAINER (hbox_dispitem), 8);
838 button_dispitem = gtk_button_new_with_label
839 (_(" Folder list... "));
840 gtk_widget_show (button_dispitem);
841 gtk_box_pack_start (GTK_BOX (hbox_dispitem), button_dispitem, FALSE, FALSE, 0);
842 g_signal_connect (G_OBJECT (button_dispitem), "clicked",
843 G_CALLBACK (prefs_folder_column_open),
846 button_dispitem = gtk_button_new_with_label
847 (_(" Message list... "));
848 gtk_widget_show (button_dispitem);
849 gtk_box_pack_start (GTK_BOX (hbox_dispitem), button_dispitem, FALSE, FALSE, 0);
850 g_signal_connect (G_OBJECT (button_dispitem), "clicked",
851 G_CALLBACK (prefs_summary_column_open),
854 vbox4 = gtk_vbox_new (FALSE, 0);
855 gtk_widget_show (vbox4);
856 gtk_box_pack_start (GTK_BOX (vbox1), vbox4, FALSE, FALSE, 0);
858 /* PACK_CHECK_BUTTON (vbox2, checkbtn_emacs,
859 _("Emulate the behavior of mouse operation of\n"
860 "Emacs-based mailer"));
861 gtk_label_set_justify (GTK_LABEL (GTK_BIN (checkbtn_emacs)->child),
862 GTK_JUSTIFY_LEFT); */
864 immedexec_tooltip = gtk_tooltips_new();
867 (vbox4, checkbtn_immedexec,
868 _("Execute immediately when moving or deleting messages"));
869 gtk_tooltips_set_tip(GTK_TOOLTIPS(immedexec_tooltip), checkbtn_immedexec,
870 _("Messages will be marked until execution"
871 " if this is turned off"),
875 (vbox4, checkbtn_ask_mark_all_read,
876 _("Confirm before marking all mails in a folder as read"));
879 (vbox4, checkbtn_always_show_msg,
880 _("Always open message when selected"));
883 (vbox4, checkbtn_mark_as_read_on_newwin,
884 _("Only mark message as read when opened in a new window"));
887 vbox5 = gtk_vbox_new (FALSE, 0);
888 gtk_widget_show (vbox5);
889 gtk_box_pack_start (GTK_BOX (vbox1), vbox5, FALSE, FALSE, 0);
891 table = gtk_table_new(1, 1, FALSE);
892 gtk_widget_show(table);
893 gtk_container_add (GTK_CONTAINER (vbox5), table);
894 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
895 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
897 label = gtk_label_new (_("When entering a folder"));
898 gtk_widget_show (label);
899 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1,
900 (GtkAttachOptions) (GTK_FILL),
901 (GtkAttachOptions) (0), 0, 0);
902 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT);
903 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
905 optmenu_select_on_entry = gtk_option_menu_new ();
906 gtk_widget_show (optmenu_select_on_entry);
908 gtk_table_attach(GTK_TABLE(table), optmenu_select_on_entry, 1, 2, 0, 1,
909 (GtkAttachOptions) (GTK_FILL),
910 (GtkAttachOptions) (0), 0, 0);
912 menu = gtk_menu_new ();
913 MENUITEM_ADD (menu, menuitem, _("Do nothing"), 0);
914 MENUITEM_ADD (menu, menuitem, _("Select first unread (or new) message"),
915 SELECTONENTRY_UNREAD);
916 MENUITEM_ADD (menu, menuitem, _("Select first new (or unread) message"),
919 gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_select_on_entry), menu);
921 /* Next Unread Message Dialog */
922 table = gtk_table_new(1, 1, FALSE);
923 gtk_widget_show(table);
924 gtk_container_add (GTK_CONTAINER (vbox5), table);
925 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
926 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
928 label = gtk_label_new (_("Show \"no unread (or new) message\" dialog"));
929 gtk_widget_show (label);
930 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2,
931 (GtkAttachOptions) (GTK_FILL),
932 (GtkAttachOptions) (0), 0, 0);
933 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT);
934 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
936 optmenu_nextunreadmsgdialog = gtk_option_menu_new ();
937 gtk_widget_show (optmenu_nextunreadmsgdialog);
939 gtk_table_attach(GTK_TABLE(table), optmenu_nextunreadmsgdialog, 1, 2, 1, 2,
940 (GtkAttachOptions) (GTK_FILL),
941 (GtkAttachOptions) (0), 0, 0);
943 menu = gtk_menu_new ();
944 MENUITEM_ADD (menu, menuitem, _("Always"), NEXTUNREADMSGDIALOG_ALWAYS);
945 MENUITEM_ADD (menu, menuitem, _("Assume 'Yes'"),
946 NEXTUNREADMSGDIALOG_ASSUME_YES);
947 MENUITEM_ADD (menu, menuitem, _("Assume 'No'"),
948 NEXTUNREADMSGDIALOG_ASSUME_NO);
950 gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_nextunreadmsgdialog), menu);
952 hbox2 = gtk_hbox_new (FALSE, 8);
953 gtk_widget_show (hbox2);
954 gtk_box_pack_start (GTK_BOX (vbox1), hbox2, FALSE, FALSE, 0);
956 button_keybind = gtk_button_new_with_label (_(" Set key bindings... "));
957 gtk_widget_show (button_keybind);
958 gtk_box_pack_start (GTK_BOX (hbox2), button_keybind, FALSE, FALSE, 0);
959 g_signal_connect (G_OBJECT (button_keybind), "clicked",
960 G_CALLBACK (prefs_keybind_select), NULL);
963 prefs_summaries->window = GTK_WIDGET(window);
965 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkbtn_transhdr),
966 prefs_common.trans_hdr);
967 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkbtn_folder_unread),
968 prefs_common.display_folder_unread);
969 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkbtn_useaddrbook),
970 prefs_common.use_addr_book);
971 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkbtn_threadsubj),
972 prefs_common.thread_by_subject);
973 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_ng_abbrev_len),
974 prefs_common.ng_abbrev_len);
975 gtk_entry_set_text(GTK_ENTRY(entry_datefmt),
976 prefs_common.date_format?prefs_common.date_format:"");
978 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_always_show_msg),
979 prefs_common.always_show_msg);
980 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_mark_as_read_on_newwin),
981 prefs_common.mark_as_read_on_new_window);
982 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_immedexec),
983 prefs_common.immediate_exec);
984 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_ask_mark_all_read),
985 prefs_common.ask_mark_all_read);
987 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu_select_on_entry),
988 prefs_common.select_on_entry);
989 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu_nextunreadmsgdialog),
990 prefs_common.next_unread_msg_dialog);
992 prefs_summaries->chkbtn_transhdr = chkbtn_transhdr;
993 prefs_summaries->chkbtn_folder_unread = chkbtn_folder_unread;
994 prefs_summaries->spinbtn_ng_abbrev_len = spinbtn_ng_abbrev_len;
995 prefs_summaries->chkbtn_useaddrbook = chkbtn_useaddrbook;
996 prefs_summaries->chkbtn_threadsubj = chkbtn_threadsubj;
997 prefs_summaries->entry_datefmt = entry_datefmt;
999 prefs_summaries->checkbtn_always_show_msg = checkbtn_always_show_msg;
1000 prefs_summaries->checkbtn_mark_as_read_on_newwin = checkbtn_mark_as_read_on_newwin;
1001 prefs_summaries->checkbtn_immedexec = checkbtn_immedexec;
1002 prefs_summaries->checkbtn_ask_mark_all_read = checkbtn_ask_mark_all_read;
1003 prefs_summaries->optmenu_select_on_entry = optmenu_select_on_entry;
1004 prefs_summaries->optmenu_nextunreadmsgdialog = optmenu_nextunreadmsgdialog;
1006 prefs_summaries->page.widget = vbox1;
1009 void prefs_summaries_save(PrefsPage *_page)
1011 SummariesPage *page = (SummariesPage *) _page;
1013 GtkWidget *menuitem;
1015 prefs_common.trans_hdr = gtk_toggle_button_get_active(
1016 GTK_TOGGLE_BUTTON(page->chkbtn_transhdr));
1017 prefs_common.display_folder_unread = gtk_toggle_button_get_active(
1018 GTK_TOGGLE_BUTTON(page->chkbtn_folder_unread));
1019 prefs_common.use_addr_book = gtk_toggle_button_get_active(
1020 GTK_TOGGLE_BUTTON(page->chkbtn_useaddrbook));
1021 prefs_common.thread_by_subject = gtk_toggle_button_get_active(
1022 GTK_TOGGLE_BUTTON(page->chkbtn_threadsubj));
1023 prefs_common.ng_abbrev_len = gtk_spin_button_get_value_as_int(
1024 GTK_SPIN_BUTTON(page->spinbtn_ng_abbrev_len));
1026 g_free(prefs_common.date_format);
1027 prefs_common.date_format = gtk_editable_get_chars(
1028 GTK_EDITABLE(page->entry_datefmt), 0, -1);
1030 prefs_common.always_show_msg = gtk_toggle_button_get_active(
1031 GTK_TOGGLE_BUTTON(page->checkbtn_always_show_msg));
1032 prefs_common.mark_as_read_on_new_window = gtk_toggle_button_get_active(
1033 GTK_TOGGLE_BUTTON(page->checkbtn_mark_as_read_on_newwin));
1034 prefs_common.immediate_exec = gtk_toggle_button_get_active(
1035 GTK_TOGGLE_BUTTON(page->checkbtn_immedexec));
1036 prefs_common.ask_mark_all_read = gtk_toggle_button_get_active(
1037 GTK_TOGGLE_BUTTON(page->checkbtn_ask_mark_all_read));
1039 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(page->optmenu_select_on_entry));
1040 menuitem = gtk_menu_get_active(GTK_MENU(menu));
1041 prefs_common.select_on_entry = GPOINTER_TO_INT
1042 (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
1044 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(page->optmenu_nextunreadmsgdialog));
1045 menuitem = gtk_menu_get_active(GTK_MENU(menu));
1046 prefs_common.next_unread_msg_dialog = GPOINTER_TO_INT
1047 (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
1048 main_window_reflect_prefs_all();
1051 static void prefs_summaries_destroy_widget(PrefsPage *_page)
1055 SummariesPage *prefs_summaries;
1057 void prefs_summaries_init(void)
1059 SummariesPage *page;
1060 static gchar *path[3];
1062 path[0] = _("Display");
1063 path[1] = _("Summaries");
1066 page = g_new0(SummariesPage, 1);
1067 page->page.path = path;
1068 page->page.create_widget = prefs_summaries_create_widget;
1069 page->page.destroy_widget = prefs_summaries_destroy_widget;
1070 page->page.save_page = prefs_summaries_save;
1071 page->page.weight = 140.0;
1072 prefs_gtk_register_page((PrefsPage *) page);
1073 prefs_summaries = page;
1076 void prefs_summaries_done(void)
1078 prefs_gtk_unregister_page((PrefsPage *) prefs_summaries);
1079 g_free(prefs_summaries);
1082 static void date_format_ok_btn_clicked(GtkButton *button, GtkWidget **widget)
1084 GtkWidget *datefmt_sample = NULL;
1087 g_return_if_fail(widget != NULL);
1088 g_return_if_fail(*widget != NULL);
1089 g_return_if_fail(prefs_summaries->entry_datefmt != NULL);
1091 datefmt_sample = GTK_WIDGET(g_object_get_data
1092 (G_OBJECT(*widget), "datefmt_sample"));
1093 g_return_if_fail(datefmt_sample != NULL);
1095 text = gtk_editable_get_chars(GTK_EDITABLE(datefmt_sample), 0, -1);
1096 g_free(prefs_common.date_format);
1097 prefs_common.date_format = text;
1098 gtk_entry_set_text(GTK_ENTRY(prefs_summaries->entry_datefmt), text);
1100 gtk_widget_destroy(*widget);
1104 static void date_format_cancel_btn_clicked(GtkButton *button,
1107 g_return_if_fail(widget != NULL);
1108 g_return_if_fail(*widget != NULL);
1110 gtk_widget_destroy(*widget);
1114 static gboolean date_format_key_pressed(GtkWidget *keywidget, GdkEventKey *event,
1117 if (event && event->keyval == GDK_Escape)
1118 date_format_cancel_btn_clicked(NULL, widget);
1122 static gboolean date_format_on_delete(GtkWidget *dialogwidget,
1123 GdkEventAny *event, GtkWidget **widget)
1125 g_return_val_if_fail(widget != NULL, FALSE);
1126 g_return_val_if_fail(*widget != NULL, FALSE);
1132 static void date_format_entry_on_change(GtkEditable *editable,
1136 struct tm *cal_time;
1140 cur_time = time(NULL);
1141 cal_time = localtime(&cur_time);
1143 text = gtk_editable_get_chars(editable, 0, -1);
1145 strftime(buffer, sizeof buffer, text, cal_time);
1148 text = conv_codeset_strdup(buffer,
1149 conv_get_locale_charset_str(),
1152 text = g_strdup(buffer);
1154 gtk_label_set_text(example, text);
1159 static void date_format_select_row(GtkTreeView *list_view,
1161 GtkTreeViewColumn *column,
1162 GtkWidget *date_format)
1166 const gchar *old_format;
1168 GtkWidget *datefmt_sample;
1170 GtkTreeModel *model;
1172 g_return_if_fail(date_format != NULL);
1174 /* only on double click */
1175 datefmt_sample = GTK_WIDGET(g_object_get_data(G_OBJECT(date_format),
1178 g_return_if_fail(datefmt_sample != NULL);
1180 model = gtk_tree_view_get_model(list_view);
1182 /* get format from list */
1183 if (!gtk_tree_model_get_iter(model, &iter, path))
1186 gtk_tree_model_get(model, &iter, DATEFMT_FMT, &format, -1);
1188 cur_pos = gtk_editable_get_position(GTK_EDITABLE(datefmt_sample));
1189 old_format = gtk_entry_get_text(GTK_ENTRY(datefmt_sample));
1191 /* insert the format into the text entry */
1192 new_format = g_malloc(strlen(old_format) + 3);
1194 strncpy(new_format, old_format, cur_pos);
1195 new_format[cur_pos] = '\0';
1196 strcat(new_format, format);
1197 strcat(new_format, &old_format[cur_pos]);
1199 gtk_entry_set_text(GTK_ENTRY(datefmt_sample), new_format);
1200 gtk_editable_set_position(GTK_EDITABLE(datefmt_sample), cur_pos + 2);