2 * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2005-2015 Colin Leroy and The Claws Mail 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 3 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, see <http://www.gnu.org/licenses/>.
21 #include "claws-features.h"
30 #include <glib/gi18n.h>
32 #include <gdk/gdkkeysyms.h>
38 #include "prefs_common.h"
39 #include "prefs_gtk.h"
40 #include "prefs_summary_open.h"
41 #include "prefs_summary_column.h"
42 #include "prefs_folder_column.h"
45 #include "gtk/gtkutils.h"
46 #include "gtk/prefswindow.h"
47 #include "gtk/combobox.h"
49 #include "manage_window.h"
51 typedef struct _SummariesPage
57 GtkWidget
*checkbtn_transhdr
;
58 GtkWidget
*optmenu_folder_unread
;
59 GtkWidget
*spinbtn_ng_abbrev_len
;
60 GtkWidget
*checkbtn_useaddrbook
;
61 GtkWidget
*checkbtn_show_tooltips
;
62 GtkWidget
*checkbtn_threadsubj
;
63 GtkWidget
*button_datefmt
;
64 GtkWidget
*entry_datefmt
;
66 GtkWidget
*checkbtn_reopen_last_folder
;
67 GtkWidget
*optmenu_always_show_msg
;
68 GtkWidget
*checkbtn_mark_as_read_on_newwin
;
69 GtkWidget
*spinbtn_mark_as_read_delay
;
70 GtkWidget
*checkbtn_immedexec
;
71 GtkWidget
*checkbtn_ask_mark_all_read
;
72 GtkWidget
*optmenu_sort_key
;
73 GtkWidget
*optmenu_sort_type
;
74 GtkWidget
*optmenu_nextunreadmsgdialog
;
84 static void date_format_ok_btn_clicked (GtkButton
*button
,
86 static void date_format_cancel_btn_clicked (GtkButton
*button
,
88 static gboolean
date_format_key_pressed (GtkWidget
*keywidget
,
91 static gboolean
date_format_on_delete (GtkWidget
*dialogwidget
,
94 static void date_format_entry_on_change (GtkEditable
*editable
,
96 static void date_format_select_row (GtkTreeView
*list_view
,
98 GtkTreeViewColumn
*column
,
99 GtkWidget
*date_format
);
100 static void mark_as_read_toggled (GtkToggleButton
*button
,
103 static GtkWidget
*date_format_create(GtkButton
*button
, void *data
)
105 static GtkWidget
*datefmt_win
= NULL
;
108 GtkWidget
*scrolledwindow1
;
109 GtkWidget
*datefmt_list_view
;
114 GtkWidget
*confirm_area
;
116 GtkWidget
*cancel_btn
;
117 GtkWidget
*datefmt_entry
;
146 const gint TIME_FORMAT_ELEMS
=
147 sizeof time_format
/ sizeof time_format
[0];
149 GtkCellRenderer
*renderer
;
150 GtkTreeViewColumn
*column
;
151 GtkTreeSelection
*selection
;
153 time_format
[0].txt
= _("the abbreviated weekday name");
154 time_format
[1].txt
= _("the full weekday name");
155 time_format
[2].txt
= _("the abbreviated month name");
156 time_format
[3].txt
= _("the full month name");
157 time_format
[4].txt
= _("the preferred date and time for the current locale");
158 time_format
[5].txt
= _("the century number (year/100)");
159 time_format
[6].txt
= _("the day of the month as a decimal number");
160 time_format
[7].txt
= _("the hour as a decimal number using a 24-hour clock");
161 time_format
[8].txt
= _("the hour as a decimal number using a 12-hour clock");
162 time_format
[9].txt
= _("the day of the year as a decimal number");
163 time_format
[10].txt
= _("the month as a decimal number");
164 time_format
[11].txt
= _("the minute as a decimal number");
165 time_format
[12].txt
= _("either AM or PM");
166 time_format
[13].txt
= _("the second as a decimal number");
167 time_format
[14].txt
= _("the day of the week as a decimal number");
168 time_format
[15].txt
= _("the preferred date for the current locale");
169 time_format
[16].txt
= _("the last two digits of a year");
170 time_format
[17].txt
= _("the year as a decimal number");
171 time_format
[18].txt
= _("the time zone or name or abbreviation");
173 if (datefmt_win
) return datefmt_win
;
175 store
= gtk_list_store_new(N_DATEFMT_COLUMNS
,
180 for (i
= 0; i
< TIME_FORMAT_ELEMS
; i
++) {
183 gtk_list_store_append(store
, &iter
);
184 gtk_list_store_set(store
, &iter
,
185 DATEFMT_FMT
, time_format
[i
].fmt
,
186 DATEFMT_TXT
, time_format
[i
].txt
,
190 datefmt_win
= gtkut_window_new(GTK_WINDOW_TOPLEVEL
, "prefs_summaries");
191 gtk_container_set_border_width(GTK_CONTAINER(datefmt_win
), 8);
192 gtk_window_set_title(GTK_WINDOW(datefmt_win
), _("Date format"));
193 gtk_window_set_position(GTK_WINDOW(datefmt_win
), GTK_WIN_POS_CENTER
);
194 gtk_widget_set_size_request(datefmt_win
, 440, 280);
196 vbox1
= gtk_vbox_new(FALSE
, 10);
197 gtk_widget_show(vbox1
);
198 gtk_container_add(GTK_CONTAINER(datefmt_win
), vbox1
);
200 scrolledwindow1
= gtk_scrolled_window_new(NULL
, NULL
);
201 gtk_scrolled_window_set_policy
202 (GTK_SCROLLED_WINDOW(scrolledwindow1
),
203 GTK_POLICY_AUTOMATIC
, GTK_POLICY_AUTOMATIC
);
204 gtk_widget_show(scrolledwindow1
);
205 gtk_box_pack_start(GTK_BOX(vbox1
), scrolledwindow1
, TRUE
, TRUE
, 0);
207 datefmt_list_view
= gtk_tree_view_new_with_model(GTK_TREE_MODEL(store
));
208 g_object_unref(G_OBJECT(store
));
209 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(datefmt_list_view
),
210 prefs_common
.use_stripes_everywhere
);
211 gtk_widget_show(datefmt_list_view
);
212 gtk_container_add(GTK_CONTAINER(scrolledwindow1
), datefmt_list_view
);
214 renderer
= gtk_cell_renderer_text_new();
215 column
= gtk_tree_view_column_new_with_attributes
216 (_("Specifier"), renderer
, "text", DATEFMT_FMT
,
218 gtk_tree_view_append_column(GTK_TREE_VIEW(datefmt_list_view
), column
);
220 renderer
= gtk_cell_renderer_text_new();
221 column
= gtk_tree_view_column_new_with_attributes
222 (_("Description"), renderer
, "text", DATEFMT_TXT
,
224 gtk_tree_view_append_column(GTK_TREE_VIEW(datefmt_list_view
), column
);
226 /* gtk_cmclist_set_column_width(GTK_CMCLIST(datefmt_clist), 0, 80); */
227 selection
= gtk_tree_view_get_selection(GTK_TREE_VIEW(datefmt_list_view
));
228 gtk_tree_selection_set_mode(selection
, GTK_SELECTION_BROWSE
);
230 g_signal_connect(G_OBJECT(datefmt_list_view
), "row_activated",
231 G_CALLBACK(date_format_select_row
),
234 table
= gtk_table_new(2, 2, FALSE
);
235 gtk_widget_show(table
);
236 gtk_box_pack_start(GTK_BOX(vbox1
), table
, FALSE
, FALSE
, 0);
237 gtk_table_set_row_spacings(GTK_TABLE(table
), 4);
238 gtk_table_set_col_spacings(GTK_TABLE(table
), 8);
240 label1
= gtk_label_new(_("Date format"));
241 gtk_widget_show(label1
);
242 gtk_table_attach(GTK_TABLE(table
), label1
, 0, 1, 0, 1,
244 gtk_label_set_justify(GTK_LABEL(label1
), GTK_JUSTIFY_LEFT
);
245 gtk_misc_set_alignment(GTK_MISC(label1
), 0, 0.5);
247 datefmt_entry
= gtk_entry_new();
248 gtk_entry_set_max_length(GTK_ENTRY(datefmt_entry
), 256);
249 gtk_widget_show(datefmt_entry
);
250 gtk_table_attach(GTK_TABLE(table
), datefmt_entry
, 1, 2, 0, 1,
251 (GTK_EXPAND
| GTK_FILL
), 0, 0, 0);
253 /* we need the "sample" entry box; add it as data so callbacks can
254 * get the entry box */
255 g_object_set_data(G_OBJECT(datefmt_win
), "datefmt_sample",
258 label2
= gtk_label_new(_("Example"));
259 gtk_widget_show(label2
);
260 gtk_table_attach(GTK_TABLE(table
), label2
, 0, 1, 1, 2,
262 gtk_label_set_justify(GTK_LABEL(label2
), GTK_JUSTIFY_LEFT
);
263 gtk_misc_set_alignment(GTK_MISC(label2
), 0, 0.5);
265 label3
= gtk_label_new("");
266 gtk_widget_show(label3
);
267 gtk_table_attach(GTK_TABLE(table
), label3
, 1, 2, 1, 2,
268 (GTK_EXPAND
| GTK_FILL
), 0, 0, 0);
269 gtk_label_set_justify(GTK_LABEL(label3
), GTK_JUSTIFY_LEFT
);
270 gtk_misc_set_alignment(GTK_MISC(label3
), 0, 0.5);
272 gtkut_stock_button_set_create(&confirm_area
, &cancel_btn
, GTK_STOCK_CANCEL
,
273 &ok_btn
, GTK_STOCK_OK
, NULL
, NULL
);
275 gtk_box_pack_start(GTK_BOX(vbox1
), confirm_area
, FALSE
, FALSE
, 0);
276 gtk_widget_show(confirm_area
);
277 gtk_widget_grab_default(ok_btn
);
279 /* set the current format */
280 gtk_entry_set_text(GTK_ENTRY(datefmt_entry
), prefs_common
.date_format
);
281 date_format_entry_on_change(GTK_EDITABLE(datefmt_entry
),
284 g_signal_connect(G_OBJECT(ok_btn
), "clicked",
285 G_CALLBACK(date_format_ok_btn_clicked
),
287 g_signal_connect(G_OBJECT(cancel_btn
), "clicked",
288 G_CALLBACK(date_format_cancel_btn_clicked
),
290 g_signal_connect(G_OBJECT(datefmt_win
), "key_press_event",
291 G_CALLBACK(date_format_key_pressed
),
293 g_signal_connect(G_OBJECT(datefmt_win
), "delete_event",
294 G_CALLBACK(date_format_on_delete
),
296 g_signal_connect(G_OBJECT(datefmt_entry
), "changed",
297 G_CALLBACK(date_format_entry_on_change
),
300 gtk_window_set_position(GTK_WINDOW(datefmt_win
), GTK_WIN_POS_CENTER
);
302 gtk_widget_show(datefmt_win
);
303 manage_window_set_transient(GTK_WINDOW(datefmt_win
));
304 gtk_window_set_modal(GTK_WINDOW(datefmt_win
), TRUE
);
306 gtk_widget_grab_focus(ok_btn
);
311 static void prefs_summaries_create_widget(PrefsPage
*_page
, GtkWindow
*window
,
314 SummariesPage
*prefs_summaries
= (SummariesPage
*) _page
;
317 GtkWidget
*checkbtn_transhdr
;
319 GtkWidget
*optmenu_folder_unread
;
321 GtkWidget
*label_ng_abbrev
;
322 GtkWidget
*spinbtn_ng_abbrev_len
;
323 GtkAdjustment
*spinbtn_ng_abbrev_len_adj
;
326 GtkWidget
*checkbtn_useaddrbook
;
327 GtkWidget
*checkbtn_show_tooltips
;
328 GtkWidget
*checkbtn_threadsubj
;
329 GtkWidget
*label_datefmt
;
330 GtkWidget
*button_datefmt
;
331 GtkWidget
*entry_datefmt
;
332 GtkWidget
*hbox_dispitem
;
333 GtkWidget
*button_dispitem
;
335 GtkWidget
*checkbtn_reopen_last_folder
;
336 GtkWidget
*optmenu_always_show_msg
;
337 GtkWidget
*spinbtn_mark_as_read_delay
;
338 GtkAdjustment
*spinbtn_mark_as_read_delay_adj
;
339 GtkWidget
*checkbtn_immedexec
;
340 GtkWidget
*checkbtn_ask_mark_all_read
;
341 GtkWidget
*label
, *label_fill
;
344 GtkWidget
*optmenu_nextunreadmsgdialog
;
345 GtkWidget
*folderview_frame
;
346 GtkWidget
*summaryview_frame
;
347 GtkWidget
*button_edit_actions
;
348 GtkWidget
*radio_mark_as_read_on_select
;
349 GtkWidget
*radio_mark_as_read_on_new_win
;
350 GtkWidget
*optmenu_sort_key
;
351 GtkWidget
*optmenu_sort_type
;
353 vbox1
= gtk_vbox_new (FALSE
, VSPACING
);
354 gtk_widget_show (vbox1
);
355 gtk_container_set_border_width (GTK_CONTAINER (vbox1
), VBOX_BORDER
);
357 vbox2
= gtkut_get_options_frame(vbox1
, &folderview_frame
, _("Folder list"));
359 hbox0
= gtk_hbox_new (FALSE
, 8);
360 gtk_widget_show (hbox0
);
361 gtk_box_pack_start(GTK_BOX (vbox2
), hbox0
, FALSE
, FALSE
, 0);
363 label
= gtk_label_new (_("Display message count next to folder name"));
364 gtk_widget_show (label
);
365 gtk_box_pack_start(GTK_BOX(hbox0
), label
, FALSE
, FALSE
, 0);
367 optmenu_folder_unread
= gtkut_sc_combobox_create(NULL
, FALSE
);
368 menu
= GTK_LIST_STORE(gtk_combo_box_get_model(
369 GTK_COMBO_BOX(optmenu_folder_unread
)));
370 gtk_widget_show (optmenu_folder_unread
);
372 COMBOBOX_ADD (menu
, _("No"), 0);
373 COMBOBOX_ADD (menu
, _("Unread messages"), 1);
374 COMBOBOX_ADD (menu
, _("Unread and Total messages"), 2);
376 gtk_box_pack_start(GTK_BOX(hbox0
), optmenu_folder_unread
, FALSE
, FALSE
, 0);
378 hbox1
= gtk_hbox_new (FALSE
, 8);
379 gtk_widget_show (hbox1
);
380 gtk_box_pack_start(GTK_BOX (vbox2
), hbox1
, FALSE
, FALSE
, 0);
383 (vbox2
, checkbtn_reopen_last_folder
,
384 _("Open last opened folder at start-up"));
386 label_ng_abbrev
= gtk_label_new
387 (_("Abbreviate newsgroup names longer than"));
388 gtk_widget_show (label_ng_abbrev
);
389 gtk_box_pack_start (GTK_BOX (hbox1
), label_ng_abbrev
, FALSE
, FALSE
, 0);
391 spinbtn_ng_abbrev_len_adj
= GTK_ADJUSTMENT(gtk_adjustment_new (16, 0, 999, 1, 10, 0));
392 spinbtn_ng_abbrev_len
= gtk_spin_button_new
393 (GTK_ADJUSTMENT (spinbtn_ng_abbrev_len_adj
), 1, 0);
394 gtk_widget_show (spinbtn_ng_abbrev_len
);
395 gtk_box_pack_start (GTK_BOX (hbox1
), spinbtn_ng_abbrev_len
,
397 gtk_widget_set_size_request (spinbtn_ng_abbrev_len
, 56, -1);
398 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_ng_abbrev_len
),
401 label_ng_abbrev
= gtk_label_new (_("letters"));
402 gtk_widget_show (label_ng_abbrev
);
403 gtk_box_pack_start (GTK_BOX (hbox1
), label_ng_abbrev
, FALSE
, FALSE
, 0);
405 hbox_dispitem
= gtk_hbox_new (FALSE
, 8);
406 gtk_widget_show (hbox_dispitem
);
407 gtk_box_pack_start(GTK_BOX(vbox2
), hbox_dispitem
, FALSE
, TRUE
, 0);
409 label
= gtk_label_new(_("Displayed columns"));
410 gtk_widget_show(label
);
411 gtk_box_pack_start(GTK_BOX(hbox_dispitem
), label
, FALSE
, FALSE
, 0);
412 button_dispitem
= gtk_button_new_from_stock(GTK_STOCK_EDIT
);
413 gtk_widget_show (button_dispitem
);
414 gtk_box_pack_start (GTK_BOX (hbox_dispitem
), button_dispitem
, FALSE
, FALSE
, 0);
415 g_signal_connect (G_OBJECT (button_dispitem
), "clicked",
416 G_CALLBACK (prefs_folder_column_open
),
419 vbox2
= gtkut_get_options_frame(vbox1
, &summaryview_frame
, _("Message list"));
421 hbox1
= gtk_hbox_new(FALSE
, 10);
422 gtk_widget_show(hbox1
);
423 gtk_box_pack_start(GTK_BOX (vbox2
), hbox1
, FALSE
, FALSE
, 0);
425 label
= gtk_label_new(_("Sort new folders by"));
426 gtk_widget_show(label
);
427 gtk_box_pack_start(GTK_BOX(hbox1
), label
, FALSE
, FALSE
, 0);
429 optmenu_sort_key
= gtkut_sc_combobox_create(NULL
, FALSE
);
430 menu
= GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(optmenu_sort_key
)));
431 gtk_widget_show(optmenu_sort_key
);
433 COMBOBOX_ADD(menu
, _("Number"), SORT_BY_NUMBER
);
434 COMBOBOX_ADD(menu
, _("Size"), SORT_BY_SIZE
);
435 COMBOBOX_ADD(menu
, _("Date"), SORT_BY_DATE
);
436 COMBOBOX_ADD(menu
, _("Thread date"), SORT_BY_THREAD_DATE
);
437 COMBOBOX_ADD(menu
, _("From"), SORT_BY_FROM
);
438 COMBOBOX_ADD(menu
, _("To"), SORT_BY_TO
);
439 COMBOBOX_ADD(menu
, _("Subject"), SORT_BY_SUBJECT
);
440 COMBOBOX_ADD(menu
, _("Color label"), SORT_BY_LABEL
);
441 COMBOBOX_ADD(menu
, _("Tag"), SORT_BY_TAGS
);
442 COMBOBOX_ADD(menu
, _("Mark"), SORT_BY_MARK
);
443 COMBOBOX_ADD(menu
, _("Status"), SORT_BY_STATUS
);
444 COMBOBOX_ADD(menu
, _("Attachment"), SORT_BY_MIME
);
445 COMBOBOX_ADD(menu
, _("Score"), SORT_BY_SCORE
);
446 COMBOBOX_ADD(menu
, _("Locked"), SORT_BY_LOCKED
);
447 COMBOBOX_ADD(menu
, _("Don't sort"), SORT_BY_NONE
);
449 gtk_box_pack_start(GTK_BOX(hbox1
), optmenu_sort_key
, FALSE
, FALSE
, 0);
451 optmenu_sort_type
= gtkut_sc_combobox_create(NULL
, FALSE
);
452 menu
= GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(optmenu_sort_type
)));
453 gtk_widget_show(optmenu_sort_type
);
455 COMBOBOX_ADD(menu
, _("Ascending"), SORT_ASCENDING
);
456 COMBOBOX_ADD(menu
, _("Descending"), SORT_DESCENDING
);
458 gtk_box_pack_start(GTK_BOX(hbox1
), optmenu_sort_type
, FALSE
, FALSE
, 0);
460 hbox1
= gtk_hbox_new (FALSE
, 10);
461 gtk_widget_show (hbox1
);
462 gtk_box_pack_start (GTK_BOX (vbox2
), hbox1
, FALSE
, TRUE
, 0);
464 button_edit_actions
= gtk_button_new_with_label(_("Set default selection when entering a folder"));
465 gtk_widget_show (button_edit_actions
);
466 gtk_box_pack_start (GTK_BOX (hbox1
), button_edit_actions
,
468 g_signal_connect (G_OBJECT (button_edit_actions
), "clicked",
469 G_CALLBACK (prefs_summary_open_open
),
472 /* Next Unread Message Dialog */
473 hbox1
= gtk_hbox_new (FALSE
, 10);
474 gtk_widget_show (hbox1
);
475 gtk_box_pack_start (GTK_BOX (vbox2
), hbox1
, FALSE
, FALSE
, 0);
477 label
= gtk_label_new (_("Show \"no unread (or new) message\" dialog"));
478 gtk_widget_show (label
);
479 gtk_box_pack_start(GTK_BOX(hbox1
), label
, FALSE
, FALSE
, 0);
481 optmenu_nextunreadmsgdialog
= gtkut_sc_combobox_create(NULL
, FALSE
);
482 menu
= GTK_LIST_STORE(gtk_combo_box_get_model(
483 GTK_COMBO_BOX(optmenu_nextunreadmsgdialog
)));
484 gtk_widget_show (optmenu_nextunreadmsgdialog
);
486 COMBOBOX_ADD (menu
, _("Always"), NEXTUNREADMSGDIALOG_ALWAYS
);
487 COMBOBOX_ADD (menu
, _("Assume 'Yes'"), NEXTUNREADMSGDIALOG_ASSUME_YES
);
488 COMBOBOX_ADD (menu
, _("Assume 'No'"), NEXTUNREADMSGDIALOG_ASSUME_NO
);
490 gtk_box_pack_start(GTK_BOX(hbox1
), optmenu_nextunreadmsgdialog
, FALSE
, FALSE
, 0);
492 /* Open message on select policy */
493 hbox1
= gtk_hbox_new (FALSE
, 10);
494 gtk_widget_show (hbox1
);
495 gtk_box_pack_start (GTK_BOX (vbox2
), hbox1
, FALSE
, FALSE
, 0);
496 label
= gtk_label_new (_("Open message when selected"));
497 gtk_widget_show (label
);
498 gtk_box_pack_start(GTK_BOX(hbox1
), label
, FALSE
, FALSE
, 0);
500 optmenu_always_show_msg
= gtkut_sc_combobox_create(NULL
, FALSE
);
501 menu
= GTK_LIST_STORE(gtk_combo_box_get_model(
502 GTK_COMBO_BOX(optmenu_always_show_msg
)));
503 gtk_widget_show (optmenu_always_show_msg
);
504 COMBOBOX_ADD (menu
, _("No"), OPENMSG_NO
);
505 COMBOBOX_ADD (menu
, _("Yes"), OPENMSG_YES
);
506 COMBOBOX_ADD (menu
, _("Only when message view is visible"),
507 OPENMSG_WHEN_VIEW_VISIBLE
);
508 gtk_box_pack_start(GTK_BOX(hbox1
), optmenu_always_show_msg
, FALSE
, FALSE
, 0);
511 (vbox2
, checkbtn_threadsubj
,
512 _("Thread using subject in addition to standard headers"));
515 (vbox2
, checkbtn_immedexec
,
516 _("Execute immediately when moving or deleting messages"));
517 CLAWS_SET_TIP(checkbtn_immedexec
,
518 _("Defers moving, copying and deleting of messages"
519 " until you choose 'Tools/Execute'"));
521 vbox3
= gtkut_get_options_frame(vbox2
, NULL
, _("Mark message as read"));
523 radio_mark_as_read_on_select
= gtk_radio_button_new_with_label(NULL
,
524 _("when selected, after"));
526 hbox1
= gtk_hbox_new (FALSE
, 8);
527 gtk_box_pack_start (GTK_BOX (hbox1
), radio_mark_as_read_on_select
, FALSE
, FALSE
, 0);
529 spinbtn_mark_as_read_delay_adj
= GTK_ADJUSTMENT(gtk_adjustment_new (0, 0, 60, 1, 10, 0));
530 spinbtn_mark_as_read_delay
= gtk_spin_button_new
531 (GTK_ADJUSTMENT (spinbtn_mark_as_read_delay_adj
), 1, 0);
532 gtk_box_pack_start (GTK_BOX (hbox1
), spinbtn_mark_as_read_delay
,
534 gtk_widget_set_size_request (spinbtn_mark_as_read_delay
, 56, -1);
535 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_mark_as_read_delay
),
537 gtk_box_pack_start (GTK_BOX (hbox1
), gtk_label_new
538 (_("seconds")), FALSE
, FALSE
, 0);
540 gtk_box_pack_start (GTK_BOX (vbox3
), hbox1
, FALSE
, FALSE
, 0);
542 radio_mark_as_read_on_new_win
= gtk_radio_button_new_with_label_from_widget(
543 GTK_RADIO_BUTTON(radio_mark_as_read_on_select
),
544 _("only when opened in a new window, or replied to"));
545 gtk_box_pack_start (GTK_BOX (vbox3
), radio_mark_as_read_on_new_win
,
547 gtk_widget_show_all(vbox3
);
550 (vbox2
, checkbtn_useaddrbook
,
551 _("Display sender using address book"));
554 (vbox2
, checkbtn_show_tooltips
,
557 hbox2
= gtk_hbox_new (FALSE
, 8);
558 gtk_widget_show (hbox2
);
559 gtk_box_pack_start (GTK_BOX (vbox2
), hbox2
, FALSE
, TRUE
, 0);
561 label_datefmt
= gtk_label_new (_("Date format"));
562 gtk_widget_show (label_datefmt
);
563 gtk_box_pack_start (GTK_BOX (hbox2
), label_datefmt
, FALSE
, FALSE
, 0);
565 entry_datefmt
= gtk_entry_new ();
566 gtk_widget_show (entry_datefmt
);
567 gtk_widget_set_size_request(entry_datefmt
, 200, -1);
568 gtk_box_pack_start (GTK_BOX (hbox2
), entry_datefmt
, FALSE
, FALSE
, 0);
570 button_datefmt
= gtk_button_new_from_stock(GTK_STOCK_INFO
);
572 gtk_widget_show (button_datefmt
);
573 gtk_box_pack_start (GTK_BOX (hbox2
), button_datefmt
, FALSE
, FALSE
, 0);
574 g_signal_connect (G_OBJECT (button_datefmt
), "clicked",
575 G_CALLBACK (date_format_create
), NULL
);
577 label_fill
= gtk_label_new(" ");
578 gtk_box_pack_start(GTK_BOX(hbox2
), label_fill
, TRUE
, FALSE
, 0);
580 CLAWS_SET_TIP(button_datefmt
,
581 _("Date format help"));
583 hbox_dispitem
= gtk_hbox_new (FALSE
, 8);
584 gtk_widget_show (hbox_dispitem
);
585 gtk_box_pack_start(GTK_BOX(vbox2
), hbox_dispitem
, FALSE
, TRUE
, 0);
587 label
= gtk_label_new(_("Displayed columns"));
588 gtk_widget_show(label
);
589 gtk_box_pack_start(GTK_BOX(hbox_dispitem
), label
, FALSE
, FALSE
, 0);
590 button_dispitem
= gtk_button_new_from_stock(GTK_STOCK_EDIT
);
591 gtk_widget_show (button_dispitem
);
592 gtk_box_pack_start (GTK_BOX (hbox_dispitem
), button_dispitem
, FALSE
, FALSE
, 0);
593 g_signal_connect (G_OBJECT (button_dispitem
), "clicked",
594 G_CALLBACK (prefs_summary_column_open
),
598 (vbox1
, checkbtn_ask_mark_all_read
,
599 _("Confirm before marking all messages in a folder as read"));
601 (vbox1
, checkbtn_transhdr
,
602 _("Translate header names"));
603 CLAWS_SET_TIP(checkbtn_transhdr
,
604 _("The display of standard headers (such as 'From:', 'Subject:') "
605 "will be translated into your language."));
607 hbox2
= gtk_hbox_new (FALSE
, 8);
608 gtk_widget_show (hbox2
);
609 gtk_box_pack_start (GTK_BOX (vbox1
), hbox2
, FALSE
, FALSE
, 0);
611 g_signal_connect(G_OBJECT(radio_mark_as_read_on_select
), "toggled",
612 G_CALLBACK(mark_as_read_toggled
),
613 spinbtn_mark_as_read_delay
);
615 prefs_summaries
->window
= GTK_WIDGET(window
);
617 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_transhdr
),
618 prefs_common
.trans_hdr
);
619 combobox_select_by_data(GTK_COMBO_BOX(optmenu_folder_unread
),
620 prefs_common
.display_folder_unread
);
621 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_useaddrbook
),
622 prefs_common
.use_addr_book
);
623 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_show_tooltips
),
624 prefs_common
.show_tooltips
);
625 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_threadsubj
),
626 prefs_common
.thread_by_subject
);
627 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_ng_abbrev_len
),
628 prefs_common
.ng_abbrev_len
);
629 gtk_entry_set_text(GTK_ENTRY(entry_datefmt
),
630 prefs_common
.date_format
?prefs_common
.date_format
:"");
632 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_reopen_last_folder
),
633 prefs_common
.goto_last_folder_on_startup
);
634 combobox_select_by_data(GTK_COMBO_BOX(optmenu_always_show_msg
),
635 prefs_common
.always_show_msg
);
636 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio_mark_as_read_on_new_win
),
637 prefs_common
.mark_as_read_on_new_window
);
638 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_mark_as_read_delay
),
639 prefs_common
.mark_as_read_delay
);
640 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_immedexec
),
641 prefs_common
.immediate_exec
);
642 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_ask_mark_all_read
),
643 prefs_common
.ask_mark_all_read
);
645 combobox_select_by_data(GTK_COMBO_BOX(optmenu_sort_key
),
646 prefs_common
.default_sort_key
);
647 combobox_select_by_data(GTK_COMBO_BOX(optmenu_sort_type
),
648 prefs_common
.default_sort_type
);
650 combobox_select_by_data(GTK_COMBO_BOX(optmenu_nextunreadmsgdialog
),
651 prefs_common
.next_unread_msg_dialog
);
653 prefs_summaries
->checkbtn_transhdr
= checkbtn_transhdr
;
654 prefs_summaries
->optmenu_folder_unread
= optmenu_folder_unread
;
655 prefs_summaries
->spinbtn_ng_abbrev_len
= spinbtn_ng_abbrev_len
;
656 prefs_summaries
->checkbtn_useaddrbook
= checkbtn_useaddrbook
;
657 prefs_summaries
->checkbtn_show_tooltips
= checkbtn_show_tooltips
;
658 prefs_summaries
->checkbtn_threadsubj
= checkbtn_threadsubj
;
659 prefs_summaries
->entry_datefmt
= entry_datefmt
;
661 prefs_summaries
->checkbtn_reopen_last_folder
= checkbtn_reopen_last_folder
;
662 prefs_summaries
->optmenu_always_show_msg
= optmenu_always_show_msg
;
663 prefs_summaries
->checkbtn_mark_as_read_on_newwin
= radio_mark_as_read_on_new_win
;
664 prefs_summaries
->spinbtn_mark_as_read_delay
= spinbtn_mark_as_read_delay
;
665 prefs_summaries
->checkbtn_immedexec
= checkbtn_immedexec
;
666 prefs_summaries
->checkbtn_ask_mark_all_read
= checkbtn_ask_mark_all_read
;
667 prefs_summaries
->optmenu_sort_key
= optmenu_sort_key
;
668 prefs_summaries
->optmenu_sort_type
= optmenu_sort_type
;
669 prefs_summaries
->optmenu_nextunreadmsgdialog
= optmenu_nextunreadmsgdialog
;
671 prefs_summaries
->page
.widget
= vbox1
;
674 static void prefs_summaries_save(PrefsPage
*_page
)
676 SummariesPage
*page
= (SummariesPage
*) _page
;
678 prefs_common
.trans_hdr
= gtk_toggle_button_get_active(
679 GTK_TOGGLE_BUTTON(page
->checkbtn_transhdr
));
682 prefs_common
.display_folder_unread
= combobox_get_active_data(
683 GTK_COMBO_BOX(page
->optmenu_folder_unread
));
685 prefs_common
.use_addr_book
= gtk_toggle_button_get_active(
686 GTK_TOGGLE_BUTTON(page
->checkbtn_useaddrbook
));
687 prefs_common
.show_tooltips
= gtk_toggle_button_get_active(
688 GTK_TOGGLE_BUTTON(page
->checkbtn_show_tooltips
));
689 prefs_common
.thread_by_subject
= gtk_toggle_button_get_active(
690 GTK_TOGGLE_BUTTON(page
->checkbtn_threadsubj
));
691 prefs_common
.ng_abbrev_len
= gtk_spin_button_get_value_as_int(
692 GTK_SPIN_BUTTON(page
->spinbtn_ng_abbrev_len
));
694 g_free(prefs_common
.date_format
);
695 prefs_common
.date_format
= gtk_editable_get_chars(
696 GTK_EDITABLE(page
->entry_datefmt
), 0, -1);
698 prefs_common
.goto_last_folder_on_startup
= gtk_toggle_button_get_active(
699 GTK_TOGGLE_BUTTON(page
->checkbtn_reopen_last_folder
));
700 prefs_common
.always_show_msg
= combobox_get_active_data(
701 GTK_COMBO_BOX(page
->optmenu_always_show_msg
));
702 prefs_common
.mark_as_read_on_new_window
= gtk_toggle_button_get_active(
703 GTK_TOGGLE_BUTTON(page
->checkbtn_mark_as_read_on_newwin
));
704 prefs_common
.immediate_exec
= gtk_toggle_button_get_active(
705 GTK_TOGGLE_BUTTON(page
->checkbtn_immedexec
));
706 prefs_common
.ask_mark_all_read
= gtk_toggle_button_get_active(
707 GTK_TOGGLE_BUTTON(page
->checkbtn_ask_mark_all_read
));
708 prefs_common
.mark_as_read_delay
= gtk_spin_button_get_value_as_int(
709 GTK_SPIN_BUTTON(page
->spinbtn_mark_as_read_delay
));
711 prefs_common
.default_sort_key
= combobox_get_active_data(
712 GTK_COMBO_BOX(page
->optmenu_sort_key
));
713 prefs_common
.default_sort_type
= combobox_get_active_data(
714 GTK_COMBO_BOX(page
->optmenu_sort_type
));
715 prefs_common
.next_unread_msg_dialog
= combobox_get_active_data(
716 GTK_COMBO_BOX(page
->optmenu_nextunreadmsgdialog
));
717 main_window_reflect_prefs_all();
720 static void prefs_summaries_destroy_widget(PrefsPage
*_page
)
724 SummariesPage
*prefs_summaries
;
726 void prefs_summaries_init(void)
729 static gchar
*path
[3];
731 path
[0] = _("Display");
732 path
[1] = _("Summaries");
735 page
= g_new0(SummariesPage
, 1);
736 page
->page
.path
= path
;
737 page
->page
.create_widget
= prefs_summaries_create_widget
;
738 page
->page
.destroy_widget
= prefs_summaries_destroy_widget
;
739 page
->page
.save_page
= prefs_summaries_save
;
740 page
->page
.weight
= 140.0;
741 prefs_gtk_register_page((PrefsPage
*) page
);
742 prefs_summaries
= page
;
745 void prefs_summaries_done(void)
747 prefs_gtk_unregister_page((PrefsPage
*) prefs_summaries
);
748 g_free(prefs_summaries
);
751 static void date_format_ok_btn_clicked(GtkButton
*button
, GtkWidget
**widget
)
753 GtkWidget
*datefmt_sample
= NULL
;
756 cm_return_if_fail(widget
!= NULL
);
757 cm_return_if_fail(*widget
!= NULL
);
758 cm_return_if_fail(prefs_summaries
->entry_datefmt
!= NULL
);
760 datefmt_sample
= GTK_WIDGET(g_object_get_data
761 (G_OBJECT(*widget
), "datefmt_sample"));
762 cm_return_if_fail(datefmt_sample
!= NULL
);
764 text
= gtk_editable_get_chars(GTK_EDITABLE(datefmt_sample
), 0, -1);
765 g_free(prefs_common
.date_format
);
766 prefs_common
.date_format
= text
;
767 gtk_entry_set_text(GTK_ENTRY(prefs_summaries
->entry_datefmt
), text
);
769 gtk_widget_destroy(*widget
);
773 static void date_format_cancel_btn_clicked(GtkButton
*button
,
776 cm_return_if_fail(widget
!= NULL
);
777 cm_return_if_fail(*widget
!= NULL
);
779 gtk_widget_destroy(*widget
);
783 static gboolean
date_format_key_pressed(GtkWidget
*keywidget
, GdkEventKey
*event
,
786 if (event
&& event
->keyval
== GDK_KEY_Escape
)
787 date_format_cancel_btn_clicked(NULL
, widget
);
791 static gboolean
date_format_on_delete(GtkWidget
*dialogwidget
,
792 GdkEventAny
*event
, GtkWidget
**widget
)
794 cm_return_val_if_fail(widget
!= NULL
, FALSE
);
795 cm_return_val_if_fail(*widget
!= NULL
, FALSE
);
801 static void date_format_entry_on_change(GtkEditable
*editable
,
810 cur_time
= time(NULL
);
811 cal_time
= localtime_r(&cur_time
, <
);
813 text
= gtk_editable_get_chars(editable
, 0, -1);
815 fast_strftime(buffer
, sizeof buffer
, text
, cal_time
);
817 gtk_label_set_text(example
, buffer
);
822 static void date_format_select_row(GtkTreeView
*list_view
,
824 GtkTreeViewColumn
*column
,
825 GtkWidget
*date_format
)
829 const gchar
*old_format
;
831 GtkWidget
*datefmt_sample
;
835 cm_return_if_fail(date_format
!= NULL
);
837 /* only on double click */
838 datefmt_sample
= GTK_WIDGET(g_object_get_data(G_OBJECT(date_format
),
841 cm_return_if_fail(datefmt_sample
!= NULL
);
843 model
= gtk_tree_view_get_model(list_view
);
845 /* get format from list */
846 if (!gtk_tree_model_get_iter(model
, &iter
, path
))
849 gtk_tree_model_get(model
, &iter
, DATEFMT_FMT
, &format
, -1);
851 cur_pos
= gtk_editable_get_position(GTK_EDITABLE(datefmt_sample
));
852 old_format
= gtk_entry_get_text(GTK_ENTRY(datefmt_sample
));
854 /* insert the format into the text entry */
855 new_format
= g_malloc(strlen(old_format
) + 3);
857 strncpy(new_format
, old_format
, cur_pos
);
858 new_format
[cur_pos
] = '\0';
859 strcat(new_format
, format
);
860 strcat(new_format
, &old_format
[cur_pos
]);
862 gtk_entry_set_text(GTK_ENTRY(datefmt_sample
), new_format
);
863 gtk_editable_set_position(GTK_EDITABLE(datefmt_sample
), cur_pos
+ 2);
868 static void mark_as_read_toggled(GtkToggleButton
*button
, GtkWidget
*spinbtn
)
870 gtk_widget_set_sensitive(spinbtn
,
871 gtk_toggle_button_get_active(button
));