2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2005-2012 Colin Leroy <colin@colino.net> & 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/>.
22 #include "claws-features.h"
31 #include <glib/gi18n.h>
33 #include <gdk/gdkkeysyms.h>
39 #include "prefs_common.h"
40 #include "prefs_gtk.h"
41 #include "prefs_summary_open.h"
42 #include "prefs_summary_column.h"
43 #include "prefs_folder_column.h"
46 #include "gtk/gtkutils.h"
47 #include "gtk/prefswindow.h"
48 #include "gtk/combobox.h"
50 #include "manage_window.h"
52 typedef struct _SummariesPage
58 GtkWidget
*checkbtn_transhdr
;
59 GtkWidget
*optmenu_folder_unread
;
60 GtkWidget
*spinbtn_ng_abbrev_len
;
61 GtkWidget
*checkbtn_useaddrbook
;
62 GtkWidget
*checkbtn_show_tooltips
;
63 GtkWidget
*checkbtn_threadsubj
;
64 GtkWidget
*button_datefmt
;
65 GtkWidget
*entry_datefmt
;
67 GtkWidget
*checkbtn_reopen_last_folder
;
68 GtkWidget
*optmenu_always_show_msg
;
69 GtkWidget
*checkbtn_mark_as_read_on_newwin
;
70 GtkWidget
*spinbtn_mark_as_read_delay
;
71 GtkWidget
*checkbtn_immedexec
;
72 GtkWidget
*checkbtn_ask_mark_all_read
;
73 GtkWidget
*optmenu_nextunreadmsgdialog
;
83 static void date_format_ok_btn_clicked (GtkButton
*button
,
85 static void date_format_cancel_btn_clicked (GtkButton
*button
,
87 static gboolean
date_format_key_pressed (GtkWidget
*keywidget
,
90 static gboolean
date_format_on_delete (GtkWidget
*dialogwidget
,
93 static void date_format_entry_on_change (GtkEditable
*editable
,
95 static void date_format_select_row (GtkTreeView
*list_view
,
97 GtkTreeViewColumn
*column
,
98 GtkWidget
*date_format
);
99 static void mark_as_read_toggled (GtkToggleButton
*button
,
102 static GtkWidget
*date_format_create(GtkButton
*button
, void *data
)
104 static GtkWidget
*datefmt_win
= NULL
;
107 GtkWidget
*scrolledwindow1
;
108 GtkWidget
*datefmt_list_view
;
113 GtkWidget
*confirm_area
;
115 GtkWidget
*cancel_btn
;
116 GtkWidget
*datefmt_entry
;
145 const gint TIME_FORMAT_ELEMS
=
146 sizeof time_format
/ sizeof time_format
[0];
148 GtkCellRenderer
*renderer
;
149 GtkTreeViewColumn
*column
;
150 GtkTreeSelection
*selection
;
152 time_format
[0].txt
= _("the abbreviated weekday name");
153 time_format
[1].txt
= _("the full weekday name");
154 time_format
[2].txt
= _("the abbreviated month name");
155 time_format
[3].txt
= _("the full month name");
156 time_format
[4].txt
= _("the preferred date and time for the current locale");
157 time_format
[5].txt
= _("the century number (year/100)");
158 time_format
[6].txt
= _("the day of the month as a decimal number");
159 time_format
[7].txt
= _("the hour as a decimal number using a 24-hour clock");
160 time_format
[8].txt
= _("the hour as a decimal number using a 12-hour clock");
161 time_format
[9].txt
= _("the day of the year as a decimal number");
162 time_format
[10].txt
= _("the month as a decimal number");
163 time_format
[11].txt
= _("the minute as a decimal number");
164 time_format
[12].txt
= _("either AM or PM");
165 time_format
[13].txt
= _("the second as a decimal number");
166 time_format
[14].txt
= _("the day of the week as a decimal number");
167 time_format
[15].txt
= _("the preferred date for the current locale");
168 time_format
[16].txt
= _("the last two digits of a year");
169 time_format
[17].txt
= _("the year as a decimal number");
170 time_format
[18].txt
= _("the time zone or name or abbreviation");
172 if (datefmt_win
) return datefmt_win
;
174 store
= gtk_list_store_new(N_DATEFMT_COLUMNS
,
179 for (i
= 0; i
< TIME_FORMAT_ELEMS
; i
++) {
182 gtk_list_store_append(store
, &iter
);
183 gtk_list_store_set(store
, &iter
,
184 DATEFMT_FMT
, time_format
[i
].fmt
,
185 DATEFMT_TXT
, time_format
[i
].txt
,
189 datefmt_win
= gtkut_window_new(GTK_WINDOW_TOPLEVEL
, "prefs_summaries");
190 gtk_container_set_border_width(GTK_CONTAINER(datefmt_win
), 8);
191 gtk_window_set_title(GTK_WINDOW(datefmt_win
), _("Date format"));
192 gtk_window_set_position(GTK_WINDOW(datefmt_win
), GTK_WIN_POS_CENTER
);
193 gtk_widget_set_size_request(datefmt_win
, 440, 280);
195 vbox1
= gtk_vbox_new(FALSE
, 10);
196 gtk_widget_show(vbox1
);
197 gtk_container_add(GTK_CONTAINER(datefmt_win
), vbox1
);
199 scrolledwindow1
= gtk_scrolled_window_new(NULL
, NULL
);
200 gtk_scrolled_window_set_policy
201 (GTK_SCROLLED_WINDOW(scrolledwindow1
),
202 GTK_POLICY_AUTOMATIC
, GTK_POLICY_AUTOMATIC
);
203 gtk_widget_show(scrolledwindow1
);
204 gtk_box_pack_start(GTK_BOX(vbox1
), scrolledwindow1
, TRUE
, TRUE
, 0);
206 datefmt_list_view
= gtk_tree_view_new_with_model(GTK_TREE_MODEL(store
));
207 g_object_unref(G_OBJECT(store
));
208 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(datefmt_list_view
),
209 prefs_common
.use_stripes_everywhere
);
210 gtk_widget_show(datefmt_list_view
);
211 gtk_container_add(GTK_CONTAINER(scrolledwindow1
), datefmt_list_view
);
213 renderer
= gtk_cell_renderer_text_new();
214 column
= gtk_tree_view_column_new_with_attributes
215 (_("Specifier"), renderer
, "text", DATEFMT_FMT
,
217 gtk_tree_view_append_column(GTK_TREE_VIEW(datefmt_list_view
), column
);
219 renderer
= gtk_cell_renderer_text_new();
220 column
= gtk_tree_view_column_new_with_attributes
221 (_("Description"), renderer
, "text", DATEFMT_TXT
,
223 gtk_tree_view_append_column(GTK_TREE_VIEW(datefmt_list_view
), column
);
225 /* gtk_cmclist_set_column_width(GTK_CMCLIST(datefmt_clist), 0, 80); */
226 selection
= gtk_tree_view_get_selection(GTK_TREE_VIEW(datefmt_list_view
));
227 gtk_tree_selection_set_mode(selection
, GTK_SELECTION_BROWSE
);
229 g_signal_connect(G_OBJECT(datefmt_list_view
), "row_activated",
230 G_CALLBACK(date_format_select_row
),
233 table
= gtk_table_new(2, 2, FALSE
);
234 gtk_widget_show(table
);
235 gtk_box_pack_start(GTK_BOX(vbox1
), table
, FALSE
, FALSE
, 0);
236 gtk_table_set_row_spacings(GTK_TABLE(table
), 4);
237 gtk_table_set_col_spacings(GTK_TABLE(table
), 8);
239 label1
= gtk_label_new(_("Date format"));
240 gtk_widget_show(label1
);
241 gtk_table_attach(GTK_TABLE(table
), label1
, 0, 1, 0, 1,
243 gtk_label_set_justify(GTK_LABEL(label1
), GTK_JUSTIFY_LEFT
);
244 gtk_misc_set_alignment(GTK_MISC(label1
), 0, 0.5);
246 datefmt_entry
= gtk_entry_new();
247 gtk_entry_set_max_length(GTK_ENTRY(datefmt_entry
), 256);
248 gtk_widget_show(datefmt_entry
);
249 gtk_table_attach(GTK_TABLE(table
), datefmt_entry
, 1, 2, 0, 1,
250 (GTK_EXPAND
| GTK_FILL
), 0, 0, 0);
252 /* we need the "sample" entry box; add it as data so callbacks can
253 * get the entry box */
254 g_object_set_data(G_OBJECT(datefmt_win
), "datefmt_sample",
257 label2
= gtk_label_new(_("Example"));
258 gtk_widget_show(label2
);
259 gtk_table_attach(GTK_TABLE(table
), label2
, 0, 1, 1, 2,
261 gtk_label_set_justify(GTK_LABEL(label2
), GTK_JUSTIFY_LEFT
);
262 gtk_misc_set_alignment(GTK_MISC(label2
), 0, 0.5);
264 label3
= gtk_label_new("");
265 gtk_widget_show(label3
);
266 gtk_table_attach(GTK_TABLE(table
), label3
, 1, 2, 1, 2,
267 (GTK_EXPAND
| GTK_FILL
), 0, 0, 0);
268 gtk_label_set_justify(GTK_LABEL(label3
), GTK_JUSTIFY_LEFT
);
269 gtk_misc_set_alignment(GTK_MISC(label3
), 0, 0.5);
271 gtkut_stock_button_set_create(&confirm_area
, &cancel_btn
, GTK_STOCK_CANCEL
,
272 &ok_btn
, GTK_STOCK_OK
, NULL
, NULL
);
274 gtk_box_pack_start(GTK_BOX(vbox1
), confirm_area
, FALSE
, FALSE
, 0);
275 gtk_widget_show(confirm_area
);
276 gtk_widget_grab_default(ok_btn
);
278 /* set the current format */
279 gtk_entry_set_text(GTK_ENTRY(datefmt_entry
), prefs_common
.date_format
);
280 date_format_entry_on_change(GTK_EDITABLE(datefmt_entry
),
283 g_signal_connect(G_OBJECT(ok_btn
), "clicked",
284 G_CALLBACK(date_format_ok_btn_clicked
),
286 g_signal_connect(G_OBJECT(cancel_btn
), "clicked",
287 G_CALLBACK(date_format_cancel_btn_clicked
),
289 g_signal_connect(G_OBJECT(datefmt_win
), "key_press_event",
290 G_CALLBACK(date_format_key_pressed
),
292 g_signal_connect(G_OBJECT(datefmt_win
), "delete_event",
293 G_CALLBACK(date_format_on_delete
),
295 g_signal_connect(G_OBJECT(datefmt_entry
), "changed",
296 G_CALLBACK(date_format_entry_on_change
),
299 gtk_window_set_position(GTK_WINDOW(datefmt_win
), GTK_WIN_POS_CENTER
);
300 gtk_window_set_modal(GTK_WINDOW(datefmt_win
), TRUE
);
302 gtk_widget_show(datefmt_win
);
303 manage_window_set_transient(GTK_WINDOW(datefmt_win
));
305 gtk_widget_grab_focus(ok_btn
);
310 static void prefs_summaries_create_widget(PrefsPage
*_page
, GtkWindow
*window
,
313 SummariesPage
*prefs_summaries
= (SummariesPage
*) _page
;
316 GtkWidget
*checkbtn_transhdr
;
318 GtkWidget
*optmenu_folder_unread
;
320 GtkWidget
*label_ng_abbrev
;
321 GtkWidget
*spinbtn_ng_abbrev_len
;
322 GtkAdjustment
*spinbtn_ng_abbrev_len_adj
;
325 GtkWidget
*checkbtn_useaddrbook
;
326 GtkWidget
*checkbtn_show_tooltips
;
327 GtkWidget
*checkbtn_threadsubj
;
328 GtkWidget
*label_datefmt
;
329 GtkWidget
*button_datefmt
;
330 GtkWidget
*entry_datefmt
;
331 GtkWidget
*hbox_dispitem
;
332 GtkWidget
*button_dispitem
;
334 GtkWidget
*checkbtn_reopen_last_folder
;
335 GtkWidget
*optmenu_always_show_msg
;
336 GtkWidget
*spinbtn_mark_as_read_delay
;
337 GtkAdjustment
*spinbtn_mark_as_read_delay_adj
;
338 GtkWidget
*checkbtn_immedexec
;
339 GtkWidget
*checkbtn_ask_mark_all_read
;
340 GtkWidget
*label
, *label_fill
;
343 GtkWidget
*optmenu_nextunreadmsgdialog
;
344 GtkWidget
*folderview_frame
;
345 GtkWidget
*summaryview_frame
;
346 GtkWidget
*button_edit_actions
;
347 GtkWidget
*radio_mark_as_read_on_select
;
348 GtkWidget
*radio_mark_as_read_on_new_win
;
350 vbox1
= gtk_vbox_new (FALSE
, VSPACING
);
351 gtk_widget_show (vbox1
);
352 gtk_container_set_border_width (GTK_CONTAINER (vbox1
), VBOX_BORDER
);
354 vbox2
= gtkut_get_options_frame(vbox1
, &folderview_frame
, _("Folder list"));
356 hbox0
= gtk_hbox_new (FALSE
, 8);
357 gtk_widget_show (hbox0
);
358 gtk_box_pack_start(GTK_BOX (vbox2
), hbox0
, FALSE
, FALSE
, 0);
360 label
= gtk_label_new (_("Display message number next to folder name"));
361 gtk_widget_show (label
);
362 gtk_box_pack_start(GTK_BOX(hbox0
), label
, FALSE
, FALSE
, 0);
364 optmenu_folder_unread
= gtkut_sc_combobox_create(NULL
, FALSE
);
365 menu
= GTK_LIST_STORE(gtk_combo_box_get_model(
366 GTK_COMBO_BOX(optmenu_folder_unread
)));
367 gtk_widget_show (optmenu_folder_unread
);
369 COMBOBOX_ADD (menu
, _("No"), 0);
370 COMBOBOX_ADD (menu
, _("Unread messages"), 1);
371 COMBOBOX_ADD (menu
, _("Unread and Total messages"), 2);
373 gtk_box_pack_start(GTK_BOX(hbox0
), optmenu_folder_unread
, FALSE
, FALSE
, 0);
375 hbox1
= gtk_hbox_new (FALSE
, 8);
376 gtk_widget_show (hbox1
);
377 gtk_box_pack_start(GTK_BOX (vbox2
), hbox1
, FALSE
, FALSE
, 0);
380 (vbox2
, checkbtn_reopen_last_folder
,
381 _("Open last opened folder at start-up"));
383 label_ng_abbrev
= gtk_label_new
384 (_("Abbreviate newsgroup names longer than"));
385 gtk_widget_show (label_ng_abbrev
);
386 gtk_box_pack_start (GTK_BOX (hbox1
), label_ng_abbrev
, FALSE
, FALSE
, 0);
388 spinbtn_ng_abbrev_len_adj
= GTK_ADJUSTMENT(gtk_adjustment_new (16, 0, 999, 1, 10, 0));
389 spinbtn_ng_abbrev_len
= gtk_spin_button_new
390 (GTK_ADJUSTMENT (spinbtn_ng_abbrev_len_adj
), 1, 0);
391 gtk_widget_show (spinbtn_ng_abbrev_len
);
392 gtk_box_pack_start (GTK_BOX (hbox1
), spinbtn_ng_abbrev_len
,
394 gtk_widget_set_size_request (spinbtn_ng_abbrev_len
, 56, -1);
395 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_ng_abbrev_len
),
398 label_ng_abbrev
= gtk_label_new (_("letters"));
399 gtk_widget_show (label_ng_abbrev
);
400 gtk_box_pack_start (GTK_BOX (hbox1
), label_ng_abbrev
, FALSE
, FALSE
, 0);
402 hbox_dispitem
= gtk_hbox_new (FALSE
, 8);
403 gtk_widget_show (hbox_dispitem
);
404 gtk_box_pack_start(GTK_BOX(vbox2
), hbox_dispitem
, FALSE
, TRUE
, 0);
406 label
= gtk_label_new(_("Displayed columns"));
407 gtk_widget_show(label
);
408 gtk_box_pack_start(GTK_BOX(hbox_dispitem
), label
, FALSE
, FALSE
, 0);
409 button_dispitem
= gtk_button_new_from_stock(GTK_STOCK_EDIT
);
410 gtk_widget_show (button_dispitem
);
411 gtk_box_pack_start (GTK_BOX (hbox_dispitem
), button_dispitem
, FALSE
, FALSE
, 0);
412 g_signal_connect (G_OBJECT (button_dispitem
), "clicked",
413 G_CALLBACK (prefs_folder_column_open
),
416 vbox2
= gtkut_get_options_frame(vbox1
, &summaryview_frame
, _("Message list"));
418 hbox1
= gtk_hbox_new (FALSE
, 10);
419 gtk_widget_show (hbox1
);
420 gtk_box_pack_start (GTK_BOX (vbox2
), hbox1
, FALSE
, TRUE
, 0);
422 button_edit_actions
= gtk_button_new_with_label(_("Set default selection when entering a folder"));
423 gtk_widget_show (button_edit_actions
);
424 gtk_box_pack_start (GTK_BOX (hbox1
), button_edit_actions
,
426 g_signal_connect (G_OBJECT (button_edit_actions
), "clicked",
427 G_CALLBACK (prefs_summary_open_open
),
430 /* Next Unread Message Dialog */
431 hbox1
= gtk_hbox_new (FALSE
, 10);
432 gtk_widget_show (hbox1
);
433 gtk_box_pack_start (GTK_BOX (vbox2
), hbox1
, FALSE
, FALSE
, 0);
435 label
= gtk_label_new (_("Show \"no unread (or new) message\" dialog"));
436 gtk_widget_show (label
);
437 gtk_box_pack_start(GTK_BOX(hbox1
), label
, FALSE
, FALSE
, 0);
439 optmenu_nextunreadmsgdialog
= gtkut_sc_combobox_create(NULL
, FALSE
);
440 menu
= GTK_LIST_STORE(gtk_combo_box_get_model(
441 GTK_COMBO_BOX(optmenu_nextunreadmsgdialog
)));
442 gtk_widget_show (optmenu_nextunreadmsgdialog
);
444 COMBOBOX_ADD (menu
, _("Always"), NEXTUNREADMSGDIALOG_ALWAYS
);
445 COMBOBOX_ADD (menu
, _("Assume 'Yes'"), NEXTUNREADMSGDIALOG_ASSUME_YES
);
446 COMBOBOX_ADD (menu
, _("Assume 'No'"), NEXTUNREADMSGDIALOG_ASSUME_NO
);
448 gtk_box_pack_start(GTK_BOX(hbox1
), optmenu_nextunreadmsgdialog
, FALSE
, FALSE
, 0);
450 /* Open message on select policy */
451 hbox1
= gtk_hbox_new (FALSE
, 10);
452 gtk_widget_show (hbox1
);
453 gtk_box_pack_start (GTK_BOX (vbox2
), hbox1
, FALSE
, FALSE
, 0);
454 label
= gtk_label_new (_("Open message when selected"));
455 gtk_widget_show (label
);
456 gtk_box_pack_start(GTK_BOX(hbox1
), label
, FALSE
, FALSE
, 0);
458 optmenu_always_show_msg
= gtkut_sc_combobox_create(NULL
, FALSE
);
459 menu
= GTK_LIST_STORE(gtk_combo_box_get_model(
460 GTK_COMBO_BOX(optmenu_always_show_msg
)));
461 gtk_widget_show (optmenu_always_show_msg
);
462 COMBOBOX_ADD (menu
, _("Never"), OPENMSG_REQUEST_ONLY
);
463 COMBOBOX_ADD (menu
, _("Always"), OPENMSG_ALWAYS
);
464 COMBOBOX_ADD (menu
, _("When message view is visible"),
465 OPENMSG_WHEN_VIEW_VISIBLE
);
466 gtk_box_pack_start(GTK_BOX(hbox1
), optmenu_always_show_msg
, FALSE
, FALSE
, 0);
469 (vbox2
, checkbtn_threadsubj
,
470 _("Thread using subject in addition to standard headers"));
473 (vbox2
, checkbtn_immedexec
,
474 _("Execute immediately when moving or deleting messages"));
475 CLAWS_SET_TIP(checkbtn_immedexec
,
476 _("Defers moving, copying and deleting of messages"
477 " until you choose 'Tools/Execute'"));
479 vbox3
= gtkut_get_options_frame(vbox2
, NULL
, _("Mark message as read"));
481 radio_mark_as_read_on_select
= gtk_radio_button_new_with_label(NULL
,
482 _("when selected, after"));
484 hbox1
= gtk_hbox_new (FALSE
, 8);
485 gtk_box_pack_start (GTK_BOX (hbox1
), radio_mark_as_read_on_select
, FALSE
, FALSE
, 0);
487 spinbtn_mark_as_read_delay_adj
= GTK_ADJUSTMENT(gtk_adjustment_new (0, 0, 60, 1, 10, 0));
488 spinbtn_mark_as_read_delay
= gtk_spin_button_new
489 (GTK_ADJUSTMENT (spinbtn_mark_as_read_delay_adj
), 1, 0);
490 gtk_box_pack_start (GTK_BOX (hbox1
), spinbtn_mark_as_read_delay
,
492 gtk_widget_set_size_request (spinbtn_mark_as_read_delay
, 56, -1);
493 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_mark_as_read_delay
),
495 gtk_box_pack_start (GTK_BOX (hbox1
), gtk_label_new
496 (_("seconds")), FALSE
, FALSE
, 0);
498 gtk_box_pack_start (GTK_BOX (vbox3
), hbox1
, FALSE
, FALSE
, 0);
500 radio_mark_as_read_on_new_win
= gtk_radio_button_new_with_label_from_widget(
501 GTK_RADIO_BUTTON(radio_mark_as_read_on_select
),
502 _("only when opened in a new window, or replied to"));
503 gtk_box_pack_start (GTK_BOX (vbox3
), radio_mark_as_read_on_new_win
,
505 gtk_widget_show_all(vbox3
);
508 (vbox2
, checkbtn_useaddrbook
,
509 _("Display sender using address book"));
512 (vbox2
, checkbtn_show_tooltips
,
515 #if !GTK_CHECK_VERSION(2,12,0) && !GENERIC_UMPC
516 gtk_widget_hide(checkbtn_show_tooltips
);
518 hbox2
= gtk_hbox_new (FALSE
, 8);
519 gtk_widget_show (hbox2
);
520 gtk_box_pack_start (GTK_BOX (vbox2
), hbox2
, FALSE
, TRUE
, 0);
522 label_datefmt
= gtk_label_new (_("Date format"));
523 gtk_widget_show (label_datefmt
);
524 gtk_box_pack_start (GTK_BOX (hbox2
), label_datefmt
, FALSE
, FALSE
, 0);
526 entry_datefmt
= gtk_entry_new ();
527 gtk_widget_show (entry_datefmt
);
528 gtk_widget_set_size_request(entry_datefmt
, 200, -1);
529 gtk_box_pack_start (GTK_BOX (hbox2
), entry_datefmt
, FALSE
, FALSE
, 0);
531 button_datefmt
= gtk_button_new_from_stock(GTK_STOCK_INFO
);
533 gtk_widget_show (button_datefmt
);
534 gtk_box_pack_start (GTK_BOX (hbox2
), button_datefmt
, FALSE
, FALSE
, 0);
535 g_signal_connect (G_OBJECT (button_datefmt
), "clicked",
536 G_CALLBACK (date_format_create
), NULL
);
538 label_fill
= gtk_label_new(" ");
539 gtk_box_pack_start(GTK_BOX(hbox2
), label_fill
, TRUE
, FALSE
, 0);
541 CLAWS_SET_TIP(button_datefmt
,
542 _("Date format help"));
544 hbox_dispitem
= gtk_hbox_new (FALSE
, 8);
545 gtk_widget_show (hbox_dispitem
);
546 gtk_box_pack_start(GTK_BOX(vbox2
), hbox_dispitem
, FALSE
, TRUE
, 0);
548 label
= gtk_label_new(_("Displayed columns"));
549 gtk_widget_show(label
);
550 gtk_box_pack_start(GTK_BOX(hbox_dispitem
), label
, FALSE
, FALSE
, 0);
551 button_dispitem
= gtk_button_new_from_stock(GTK_STOCK_EDIT
);
552 gtk_widget_show (button_dispitem
);
553 gtk_box_pack_start (GTK_BOX (hbox_dispitem
), button_dispitem
, FALSE
, FALSE
, 0);
554 g_signal_connect (G_OBJECT (button_dispitem
), "clicked",
555 G_CALLBACK (prefs_summary_column_open
),
559 (vbox1
, checkbtn_ask_mark_all_read
,
560 _("Confirm before marking all messages in a folder as read"));
562 (vbox1
, checkbtn_transhdr
,
563 _("Translate header names"));
564 CLAWS_SET_TIP(checkbtn_transhdr
,
565 _("The display of standard headers (such as 'From:', 'Subject:') "
566 "will be translated into your language."));
568 hbox2
= gtk_hbox_new (FALSE
, 8);
569 gtk_widget_show (hbox2
);
570 gtk_box_pack_start (GTK_BOX (vbox1
), hbox2
, FALSE
, FALSE
, 0);
572 g_signal_connect(G_OBJECT(radio_mark_as_read_on_select
), "toggled",
573 G_CALLBACK(mark_as_read_toggled
),
574 spinbtn_mark_as_read_delay
);
576 prefs_summaries
->window
= GTK_WIDGET(window
);
578 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_transhdr
),
579 prefs_common
.trans_hdr
);
580 combobox_select_by_data(GTK_COMBO_BOX(optmenu_folder_unread
),
581 prefs_common
.display_folder_unread
);
582 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_useaddrbook
),
583 prefs_common
.use_addr_book
);
584 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_show_tooltips
),
585 prefs_common
.show_tooltips
);
586 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_threadsubj
),
587 prefs_common
.thread_by_subject
);
588 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_ng_abbrev_len
),
589 prefs_common
.ng_abbrev_len
);
590 gtk_entry_set_text(GTK_ENTRY(entry_datefmt
),
591 prefs_common
.date_format
?prefs_common
.date_format
:"");
593 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_reopen_last_folder
),
594 prefs_common
.goto_last_folder_on_startup
);
595 combobox_select_by_data(GTK_COMBO_BOX(optmenu_always_show_msg
),
596 prefs_common
.always_show_msg
);
597 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio_mark_as_read_on_new_win
),
598 prefs_common
.mark_as_read_on_new_window
);
599 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_mark_as_read_delay
),
600 prefs_common
.mark_as_read_delay
);
601 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_immedexec
),
602 prefs_common
.immediate_exec
);
603 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_ask_mark_all_read
),
604 prefs_common
.ask_mark_all_read
);
606 combobox_select_by_data(GTK_COMBO_BOX(optmenu_nextunreadmsgdialog
),
607 prefs_common
.next_unread_msg_dialog
);
609 prefs_summaries
->checkbtn_transhdr
= checkbtn_transhdr
;
610 prefs_summaries
->optmenu_folder_unread
= optmenu_folder_unread
;
611 prefs_summaries
->spinbtn_ng_abbrev_len
= spinbtn_ng_abbrev_len
;
612 prefs_summaries
->checkbtn_useaddrbook
= checkbtn_useaddrbook
;
613 prefs_summaries
->checkbtn_show_tooltips
= checkbtn_show_tooltips
;
614 prefs_summaries
->checkbtn_threadsubj
= checkbtn_threadsubj
;
615 prefs_summaries
->entry_datefmt
= entry_datefmt
;
617 prefs_summaries
->checkbtn_reopen_last_folder
= checkbtn_reopen_last_folder
;
618 prefs_summaries
->optmenu_always_show_msg
= optmenu_always_show_msg
;
619 prefs_summaries
->checkbtn_mark_as_read_on_newwin
= radio_mark_as_read_on_new_win
;
620 prefs_summaries
->spinbtn_mark_as_read_delay
= spinbtn_mark_as_read_delay
;
621 prefs_summaries
->checkbtn_immedexec
= checkbtn_immedexec
;
622 prefs_summaries
->checkbtn_ask_mark_all_read
= checkbtn_ask_mark_all_read
;
623 prefs_summaries
->optmenu_nextunreadmsgdialog
= optmenu_nextunreadmsgdialog
;
625 prefs_summaries
->page
.widget
= vbox1
;
628 static void prefs_summaries_save(PrefsPage
*_page
)
630 SummariesPage
*page
= (SummariesPage
*) _page
;
632 prefs_common
.trans_hdr
= gtk_toggle_button_get_active(
633 GTK_TOGGLE_BUTTON(page
->checkbtn_transhdr
));
636 prefs_common
.display_folder_unread
= combobox_get_active_data(
637 GTK_COMBO_BOX(page
->optmenu_folder_unread
));
639 prefs_common
.use_addr_book
= gtk_toggle_button_get_active(
640 GTK_TOGGLE_BUTTON(page
->checkbtn_useaddrbook
));
641 prefs_common
.show_tooltips
= gtk_toggle_button_get_active(
642 GTK_TOGGLE_BUTTON(page
->checkbtn_show_tooltips
));
643 prefs_common
.thread_by_subject
= gtk_toggle_button_get_active(
644 GTK_TOGGLE_BUTTON(page
->checkbtn_threadsubj
));
645 prefs_common
.ng_abbrev_len
= gtk_spin_button_get_value_as_int(
646 GTK_SPIN_BUTTON(page
->spinbtn_ng_abbrev_len
));
648 g_free(prefs_common
.date_format
);
649 prefs_common
.date_format
= gtk_editable_get_chars(
650 GTK_EDITABLE(page
->entry_datefmt
), 0, -1);
652 prefs_common
.goto_last_folder_on_startup
= gtk_toggle_button_get_active(
653 GTK_TOGGLE_BUTTON(page
->checkbtn_reopen_last_folder
));
654 prefs_common
.always_show_msg
= combobox_get_active_data(
655 GTK_COMBO_BOX(page
->optmenu_always_show_msg
));
656 prefs_common
.mark_as_read_on_new_window
= gtk_toggle_button_get_active(
657 GTK_TOGGLE_BUTTON(page
->checkbtn_mark_as_read_on_newwin
));
658 prefs_common
.immediate_exec
= gtk_toggle_button_get_active(
659 GTK_TOGGLE_BUTTON(page
->checkbtn_immedexec
));
660 prefs_common
.ask_mark_all_read
= gtk_toggle_button_get_active(
661 GTK_TOGGLE_BUTTON(page
->checkbtn_ask_mark_all_read
));
662 prefs_common
.mark_as_read_delay
= gtk_spin_button_get_value_as_int(
663 GTK_SPIN_BUTTON(page
->spinbtn_mark_as_read_delay
));
665 prefs_common
.next_unread_msg_dialog
= combobox_get_active_data(
666 GTK_COMBO_BOX(page
->optmenu_nextunreadmsgdialog
));
667 main_window_reflect_prefs_all();
670 static void prefs_summaries_destroy_widget(PrefsPage
*_page
)
674 SummariesPage
*prefs_summaries
;
676 void prefs_summaries_init(void)
679 static gchar
*path
[3];
681 path
[0] = _("Display");
682 path
[1] = _("Summaries");
685 page
= g_new0(SummariesPage
, 1);
686 page
->page
.path
= path
;
687 page
->page
.create_widget
= prefs_summaries_create_widget
;
688 page
->page
.destroy_widget
= prefs_summaries_destroy_widget
;
689 page
->page
.save_page
= prefs_summaries_save
;
690 page
->page
.weight
= 140.0;
691 prefs_gtk_register_page((PrefsPage
*) page
);
692 prefs_summaries
= page
;
695 void prefs_summaries_done(void)
697 prefs_gtk_unregister_page((PrefsPage
*) prefs_summaries
);
698 g_free(prefs_summaries
);
701 static void date_format_ok_btn_clicked(GtkButton
*button
, GtkWidget
**widget
)
703 GtkWidget
*datefmt_sample
= NULL
;
706 cm_return_if_fail(widget
!= NULL
);
707 cm_return_if_fail(*widget
!= NULL
);
708 cm_return_if_fail(prefs_summaries
->entry_datefmt
!= NULL
);
710 datefmt_sample
= GTK_WIDGET(g_object_get_data
711 (G_OBJECT(*widget
), "datefmt_sample"));
712 cm_return_if_fail(datefmt_sample
!= NULL
);
714 text
= gtk_editable_get_chars(GTK_EDITABLE(datefmt_sample
), 0, -1);
715 g_free(prefs_common
.date_format
);
716 prefs_common
.date_format
= text
;
717 gtk_entry_set_text(GTK_ENTRY(prefs_summaries
->entry_datefmt
), text
);
719 gtk_widget_destroy(*widget
);
723 static void date_format_cancel_btn_clicked(GtkButton
*button
,
726 cm_return_if_fail(widget
!= NULL
);
727 cm_return_if_fail(*widget
!= NULL
);
729 gtk_widget_destroy(*widget
);
733 static gboolean
date_format_key_pressed(GtkWidget
*keywidget
, GdkEventKey
*event
,
736 if (event
&& event
->keyval
== GDK_KEY_Escape
)
737 date_format_cancel_btn_clicked(NULL
, widget
);
741 static gboolean
date_format_on_delete(GtkWidget
*dialogwidget
,
742 GdkEventAny
*event
, GtkWidget
**widget
)
744 cm_return_val_if_fail(widget
!= NULL
, FALSE
);
745 cm_return_val_if_fail(*widget
!= NULL
, FALSE
);
751 static void date_format_entry_on_change(GtkEditable
*editable
,
760 cur_time
= time(NULL
);
761 cal_time
= localtime_r(&cur_time
, <
);
763 text
= gtk_editable_get_chars(editable
, 0, -1);
765 fast_strftime(buffer
, sizeof buffer
, text
, cal_time
);
767 gtk_label_set_text(example
, buffer
);
772 static void date_format_select_row(GtkTreeView
*list_view
,
774 GtkTreeViewColumn
*column
,
775 GtkWidget
*date_format
)
779 const gchar
*old_format
;
781 GtkWidget
*datefmt_sample
;
785 cm_return_if_fail(date_format
!= NULL
);
787 /* only on double click */
788 datefmt_sample
= GTK_WIDGET(g_object_get_data(G_OBJECT(date_format
),
791 cm_return_if_fail(datefmt_sample
!= NULL
);
793 model
= gtk_tree_view_get_model(list_view
);
795 /* get format from list */
796 if (!gtk_tree_model_get_iter(model
, &iter
, path
))
799 gtk_tree_model_get(model
, &iter
, DATEFMT_FMT
, &format
, -1);
801 cur_pos
= gtk_editable_get_position(GTK_EDITABLE(datefmt_sample
));
802 old_format
= gtk_entry_get_text(GTK_ENTRY(datefmt_sample
));
804 /* insert the format into the text entry */
805 new_format
= g_malloc(strlen(old_format
) + 3);
807 strncpy(new_format
, old_format
, cur_pos
);
808 new_format
[cur_pos
] = '\0';
809 strcat(new_format
, format
);
810 strcat(new_format
, &old_format
[cur_pos
]);
812 gtk_entry_set_text(GTK_ENTRY(datefmt_sample
), new_format
);
813 gtk_editable_set_position(GTK_EDITABLE(datefmt_sample
), cur_pos
+ 2);
818 static void mark_as_read_toggled(GtkToggleButton
*button
, GtkWidget
*spinbtn
)
820 gtk_widget_set_sensitive(spinbtn
,
821 gtk_toggle_button_get_active(button
));