set chmod 0600 on log files, history files, saved parts, etc.
[claws.git] / src / prefs_summaries.c
blobfe0f942158710fa5b585a4dd057c280d48563c28
1 /*
2 * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2005-2018 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/>.
19 #ifdef HAVE_CONFIG_H
20 # include "config.h"
21 #include "claws-features.h"
22 #endif
24 #include "defs.h"
26 #include <stdio.h>
27 #include <stdlib.h>
29 #include <glib.h>
30 #include <glib/gi18n.h>
31 #include <gtk/gtk.h>
32 #include <gdk/gdkkeysyms.h>
34 #ifdef G_OS_WIN32
35 # include <w32lib.h>
36 #endif
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"
44 #include "gtk/menu.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
53 PrefsPage page;
55 GtkWidget *window;
57 GtkWidget *optmenu_folder_unread;
58 GtkWidget *spinbtn_ng_abbrev_len;
59 GtkWidget *checkbtn_useaddrbook;
60 GtkWidget *checkbtn_show_tooltips;
61 GtkWidget *checkbtn_threadsubj;
62 GtkWidget *button_datefmt;
63 GtkWidget *entry_datefmt;
65 GtkWidget *checkbtn_reopen_last_folder;
66 GtkWidget *checkbtn_always_show_msg;
67 GtkWidget *checkbtn_show_on_folder_open;
68 GtkWidget *checkbtn_show_on_search_results;
69 GtkWidget *checkbtn_show_on_prevnext;
70 GtkWidget *checkbtn_show_on_deletemove;
71 GtkWidget *checkbtn_show_on_directional;
72 GtkWidget *checkbtn_mark_as_read_on_newwin;
73 GtkWidget *spinbtn_mark_as_read_delay;
74 GtkWidget *checkbtn_immedexec;
75 GtkWidget *checkbtn_ask_mark_all_read;
76 GtkWidget *checkbtn_ask_override_colorlabel;
77 GtkWidget *optmenu_sort_key;
78 GtkWidget *optmenu_sort_type;
79 GtkWidget *optmenu_summaryfromshow;
80 GtkWidget *optmenu_nextunreadmsgdialog;
81 GtkWidget *checkbtn_folder_default_thread;
82 GtkWidget *checkbtn_folder_default_thread_collapsed;
83 GtkWidget *checkbtn_folder_default_hide_read_threads;
84 GtkWidget *checkbtn_folder_default_hide_read_msgs;
85 GtkWidget *checkbtn_folder_default_hide_del_msgs;
86 GtkWidget *checkbtn_summary_col_lock;
88 } SummariesPage;
90 enum {
91 DATEFMT_FMT,
92 DATEFMT_TXT,
93 N_DATEFMT_COLUMNS
96 static void date_format_ok_btn_clicked (GtkButton *button,
97 GtkWidget **widget);
98 static void date_format_cancel_btn_clicked (GtkButton *button,
99 GtkWidget **widget);
100 static gboolean date_format_key_pressed (GtkWidget *keywidget,
101 GdkEventKey *event,
102 GtkWidget **widget);
103 static gboolean date_format_on_delete (GtkWidget *dialogwidget,
104 GdkEventAny *event,
105 GtkWidget **widget);
106 static void date_format_entry_on_change (GtkEditable *editable,
107 GtkLabel *example);
108 static void date_format_select_row (GtkTreeView *list_view,
109 GtkTreePath *path,
110 GtkTreeViewColumn *column,
111 GtkWidget *date_format);
112 static void mark_as_read_toggled (GtkToggleButton *button,
113 GtkWidget *spinbtn);
114 static void always_show_msg_toggled (GtkToggleButton *button,
115 gpointer user_data);
117 static GtkWidget *date_format_create(GtkButton *button, void *data)
119 static GtkWidget *datefmt_win = NULL;
121 GtkWidget *vbox1;
122 GtkWidget *scrolledwindow1;
123 GtkWidget *datefmt_list_view;
124 GtkWidget *table;
125 GtkWidget *label1;
126 GtkWidget *label2;
127 GtkWidget *label3;
128 GtkWidget *confirm_area;
129 GtkWidget *ok_btn;
130 GtkWidget *cancel_btn;
131 GtkWidget *datefmt_entry;
132 GtkListStore *store;
134 struct {
135 gchar *fmt;
136 gchar *txt;
137 } time_format[] = {
138 { "%a", NULL },
139 { "%A", NULL },
140 { "%b", NULL },
141 { "%B", NULL },
142 { "%c", NULL },
143 { "%C", NULL },
144 { "%d", NULL },
145 { "%H", NULL },
146 { "%I", NULL },
147 { "%j", NULL },
148 { "%m", NULL },
149 { "%M", NULL },
150 { "%p", NULL },
151 { "%S", NULL },
152 { "%w", NULL },
153 { "%x", NULL },
154 { "%y", NULL },
155 { "%Y", NULL },
156 { "%Z", NULL }
159 gint i;
160 const gint TIME_FORMAT_ELEMS =
161 sizeof time_format / sizeof time_format[0];
163 GtkCellRenderer *renderer;
164 GtkTreeViewColumn *column;
165 GtkTreeSelection *selection;
167 time_format[0].txt = _("the abbreviated weekday name");
168 time_format[1].txt = _("the full weekday name");
169 time_format[2].txt = _("the abbreviated month name");
170 time_format[3].txt = _("the full month name");
171 time_format[4].txt = _("the preferred date and time for the current locale");
172 time_format[5].txt = _("the century number (year/100)");
173 time_format[6].txt = _("the day of the month as a decimal number");
174 time_format[7].txt = _("the hour as a decimal number using a 24-hour clock");
175 time_format[8].txt = _("the hour as a decimal number using a 12-hour clock");
176 time_format[9].txt = _("the day of the year as a decimal number");
177 time_format[10].txt = _("the month as a decimal number");
178 time_format[11].txt = _("the minute as a decimal number");
179 time_format[12].txt = _("either AM or PM");
180 time_format[13].txt = _("the second as a decimal number");
181 time_format[14].txt = _("the day of the week as a decimal number");
182 time_format[15].txt = _("the preferred date for the current locale");
183 time_format[16].txt = _("the last two digits of a year");
184 time_format[17].txt = _("the year as a decimal number");
185 time_format[18].txt = _("the time zone or name or abbreviation");
187 if (datefmt_win) return datefmt_win;
189 store = gtk_list_store_new(N_DATEFMT_COLUMNS,
190 G_TYPE_STRING,
191 G_TYPE_STRING,
192 -1);
194 for (i = 0; i < TIME_FORMAT_ELEMS; i++) {
195 GtkTreeIter iter;
197 gtk_list_store_append(store, &iter);
198 gtk_list_store_set(store, &iter,
199 DATEFMT_FMT, time_format[i].fmt,
200 DATEFMT_TXT, time_format[i].txt,
201 -1);
204 datefmt_win = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "prefs_summaries");
205 gtk_container_set_border_width(GTK_CONTAINER(datefmt_win), 8);
206 gtk_window_set_title(GTK_WINDOW(datefmt_win), _("Date format"));
207 gtk_window_set_position(GTK_WINDOW(datefmt_win), GTK_WIN_POS_CENTER);
208 gtk_window_set_type_hint(GTK_WINDOW(datefmt_win), GDK_WINDOW_TYPE_HINT_DIALOG);
209 gtk_widget_set_size_request(datefmt_win, 440, 280);
211 vbox1 = gtk_vbox_new(FALSE, 10);
212 gtk_widget_show(vbox1);
213 gtk_container_add(GTK_CONTAINER(datefmt_win), vbox1);
215 scrolledwindow1 = gtk_scrolled_window_new(NULL, NULL);
216 gtk_scrolled_window_set_policy
217 (GTK_SCROLLED_WINDOW(scrolledwindow1),
218 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
219 gtk_widget_show(scrolledwindow1);
220 gtk_box_pack_start(GTK_BOX(vbox1), scrolledwindow1, TRUE, TRUE, 0);
222 datefmt_list_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
223 g_object_unref(G_OBJECT(store));
224 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(datefmt_list_view),
225 prefs_common.use_stripes_everywhere);
226 gtk_widget_show(datefmt_list_view);
227 gtk_container_add(GTK_CONTAINER(scrolledwindow1), datefmt_list_view);
229 renderer = gtk_cell_renderer_text_new();
230 column = gtk_tree_view_column_new_with_attributes
231 (_("Specifier"), renderer, "text", DATEFMT_FMT,
232 NULL);
233 gtk_tree_view_append_column(GTK_TREE_VIEW(datefmt_list_view), column);
235 renderer = gtk_cell_renderer_text_new();
236 column = gtk_tree_view_column_new_with_attributes
237 (_("Description"), renderer, "text", DATEFMT_TXT,
238 NULL);
239 gtk_tree_view_append_column(GTK_TREE_VIEW(datefmt_list_view), column);
241 /* gtk_cmclist_set_column_width(GTK_CMCLIST(datefmt_clist), 0, 80); */
242 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(datefmt_list_view));
243 gtk_tree_selection_set_mode(selection, GTK_SELECTION_BROWSE);
245 g_signal_connect(G_OBJECT(datefmt_list_view), "row_activated",
246 G_CALLBACK(date_format_select_row),
247 datefmt_win);
249 table = gtk_table_new(2, 2, FALSE);
250 gtk_widget_show(table);
251 gtk_box_pack_start(GTK_BOX(vbox1), table, FALSE, FALSE, 0);
252 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
253 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
255 label1 = gtk_label_new(_("Date format"));
256 gtk_widget_show(label1);
257 gtk_table_attach(GTK_TABLE(table), label1, 0, 1, 0, 1,
258 GTK_FILL, 0, 0, 0);
259 gtk_label_set_justify(GTK_LABEL(label1), GTK_JUSTIFY_LEFT);
260 gtk_misc_set_alignment(GTK_MISC(label1), 0, 0.5);
262 datefmt_entry = gtk_entry_new();
263 gtk_entry_set_max_length(GTK_ENTRY(datefmt_entry), 256);
264 gtk_widget_show(datefmt_entry);
265 gtk_table_attach(GTK_TABLE(table), datefmt_entry, 1, 2, 0, 1,
266 (GTK_EXPAND | GTK_FILL), 0, 0, 0);
268 /* we need the "sample" entry box; add it as data so callbacks can
269 * get the entry box */
270 g_object_set_data(G_OBJECT(datefmt_win), "datefmt_sample",
271 datefmt_entry);
273 label2 = gtk_label_new(_("Example"));
274 gtk_widget_show(label2);
275 gtk_table_attach(GTK_TABLE(table), label2, 0, 1, 1, 2,
276 GTK_FILL, 0, 0, 0);
277 gtk_label_set_justify(GTK_LABEL(label2), GTK_JUSTIFY_LEFT);
278 gtk_misc_set_alignment(GTK_MISC(label2), 0, 0.5);
280 label3 = gtk_label_new("");
281 gtk_widget_show(label3);
282 gtk_table_attach(GTK_TABLE(table), label3, 1, 2, 1, 2,
283 (GTK_EXPAND | GTK_FILL), 0, 0, 0);
284 gtk_label_set_justify(GTK_LABEL(label3), GTK_JUSTIFY_LEFT);
285 gtk_misc_set_alignment(GTK_MISC(label3), 0, 0.5);
287 gtkut_stock_button_set_create(&confirm_area, &cancel_btn, GTK_STOCK_CANCEL,
288 &ok_btn, GTK_STOCK_OK, NULL, NULL);
290 gtk_box_pack_start(GTK_BOX(vbox1), confirm_area, FALSE, FALSE, 0);
291 gtk_widget_show(confirm_area);
292 gtk_widget_grab_default(ok_btn);
294 /* set the current format */
295 gtk_entry_set_text(GTK_ENTRY(datefmt_entry), prefs_common.date_format);
296 date_format_entry_on_change(GTK_EDITABLE(datefmt_entry),
297 GTK_LABEL(label3));
299 g_signal_connect(G_OBJECT(ok_btn), "clicked",
300 G_CALLBACK(date_format_ok_btn_clicked),
301 &datefmt_win);
302 g_signal_connect(G_OBJECT(cancel_btn), "clicked",
303 G_CALLBACK(date_format_cancel_btn_clicked),
304 &datefmt_win);
305 g_signal_connect(G_OBJECT(datefmt_win), "key_press_event",
306 G_CALLBACK(date_format_key_pressed),
307 &datefmt_win);
308 g_signal_connect(G_OBJECT(datefmt_win), "delete_event",
309 G_CALLBACK(date_format_on_delete),
310 &datefmt_win);
311 g_signal_connect(G_OBJECT(datefmt_entry), "changed",
312 G_CALLBACK(date_format_entry_on_change),
313 label3);
315 gtk_widget_show(datefmt_win);
316 manage_window_set_transient(GTK_WINDOW(datefmt_win));
317 gtk_window_set_modal(GTK_WINDOW(datefmt_win), TRUE);
319 gtk_widget_grab_focus(ok_btn);
321 return datefmt_win;
324 static void prefs_summaries_create_widget(PrefsPage *_page, GtkWindow *window,
325 gpointer data)
327 SummariesPage *prefs_summaries = (SummariesPage *) _page;
329 GtkWidget *notebook;
330 GtkWidget *hbox0, *hbox1, *hbox2;
331 GtkWidget *vbox1, *vbox2, *vbox3, *vbox4;
332 GtkWidget *frame_new_folders;
333 GtkWidget *optmenu_folder_unread;
334 GtkWidget *label_ng_abbrev;
335 GtkWidget *spinbtn_ng_abbrev_len;
336 GtkAdjustment *spinbtn_ng_abbrev_len_adj;
337 GtkWidget *checkbtn_useaddrbook;
338 GtkWidget *checkbtn_show_tooltips;
339 GtkWidget *checkbtn_threadsubj;
340 GtkWidget *label_datefmt;
341 GtkWidget *button_datefmt;
342 GtkWidget *entry_datefmt;
343 GtkWidget *button_dispitem;
344 GtkWidget *checkbtn_reopen_last_folder;
345 GtkWidget *checkbtn_always_show_msg;
346 GtkWidget *checkbtn_show_on_folder_open;
347 GtkWidget *checkbtn_show_on_search_results;
348 GtkWidget *checkbtn_show_on_prevnext;
349 GtkWidget *checkbtn_show_on_deletemove;
350 GtkWidget *checkbtn_show_on_directional;
351 GtkWidget *spinbtn_mark_as_read_delay;
352 GtkAdjustment *spinbtn_mark_as_read_delay_adj;
353 GtkWidget *checkbtn_immedexec;
354 GtkWidget *checkbtn_ask_mark_all_read;
355 GtkWidget *checkbtn_ask_override_colorlabel;
356 GtkWidget *label, *label_fill;
357 GtkListStore *menu;
358 GtkTreeIter iter;
359 GtkWidget *optmenu_summaryfromshow;
360 GtkWidget *optmenu_nextunreadmsgdialog;
361 GtkWidget *button_edit_actions;
362 GtkWidget *radio_mark_as_read_on_select;
363 GtkWidget *radio_mark_as_read_on_new_win;
364 GtkWidget *optmenu_sort_key;
365 GtkWidget *optmenu_sort_type;
366 GtkWidget *checkbtn_folder_default_thread;
367 GtkWidget *checkbtn_folder_default_thread_collapsed;
368 GtkWidget *checkbtn_folder_default_hide_read_threads;
369 GtkWidget *checkbtn_folder_default_hide_read_msgs;
370 GtkWidget *checkbtn_folder_default_hide_del_msgs;
371 GtkWidget *checkbtn_summary_col_lock;
373 notebook = gtk_notebook_new();
374 gtk_widget_show(notebook);
376 vbox1 = gtk_vbox_new (FALSE, VSPACING);
377 gtk_widget_show (vbox1);
378 gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
379 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox1,
380 gtk_label_new(_("Folder list")));
382 hbox0 = gtk_hbox_new (FALSE, 8);
383 gtk_widget_show (hbox0);
384 gtk_box_pack_start(GTK_BOX(vbox1), hbox0, FALSE, TRUE, 0);
386 label = gtk_label_new(_("Displayed columns"));
387 gtk_widget_show(label);
388 gtk_box_pack_start(GTK_BOX(hbox0), label, FALSE, FALSE, 0);
389 button_dispitem = gtk_button_new_from_stock(GTK_STOCK_EDIT);
390 gtk_widget_show (button_dispitem);
391 gtk_box_pack_start (GTK_BOX (hbox0), button_dispitem, FALSE, FALSE, 0);
392 g_signal_connect (G_OBJECT (button_dispitem), "clicked",
393 G_CALLBACK (prefs_folder_column_open),
394 NULL);
396 hbox0 = gtk_hbox_new (FALSE, 8);
397 gtk_widget_show (hbox0);
398 gtk_box_pack_start(GTK_BOX (vbox1), hbox0, FALSE, FALSE, 0);
400 label = gtk_label_new (_("Display message count next to folder name"));
401 gtk_widget_show (label);
402 gtk_box_pack_start(GTK_BOX(hbox0), label, FALSE, FALSE, 0);
404 optmenu_folder_unread = gtkut_sc_combobox_create(NULL, FALSE);
405 menu = GTK_LIST_STORE(gtk_combo_box_get_model(
406 GTK_COMBO_BOX(optmenu_folder_unread)));
407 gtk_widget_show (optmenu_folder_unread);
409 COMBOBOX_ADD (menu, _("No"), 0);
410 COMBOBOX_ADD (menu, _("Unread messages"), 1);
411 COMBOBOX_ADD (menu, _("Unread and Total messages"), 2);
413 gtk_box_pack_start(GTK_BOX(hbox0), optmenu_folder_unread, FALSE, FALSE, 0);
415 PACK_CHECK_BUTTON
416 (vbox1, checkbtn_reopen_last_folder,
417 _("Open last opened folder at start-up"));
419 hbox1 = gtk_hbox_new (FALSE, 8);
420 gtk_widget_show (hbox1);
421 gtk_box_pack_start(GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
423 label_ng_abbrev = gtk_label_new
424 (_("Abbreviate newsgroup names longer than"));
425 gtk_widget_show (label_ng_abbrev);
426 gtk_box_pack_start (GTK_BOX (hbox1), label_ng_abbrev, FALSE, FALSE, 0);
428 spinbtn_ng_abbrev_len_adj = GTK_ADJUSTMENT(gtk_adjustment_new (16, 0, 999, 1, 10, 0));
429 spinbtn_ng_abbrev_len = gtk_spin_button_new
430 (GTK_ADJUSTMENT (spinbtn_ng_abbrev_len_adj), 1, 0);
431 gtk_widget_show (spinbtn_ng_abbrev_len);
432 gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_ng_abbrev_len,
433 FALSE, FALSE, 0);
434 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_ng_abbrev_len),
435 TRUE);
437 label_ng_abbrev = gtk_label_new (_("letters"));
438 gtk_widget_show (label_ng_abbrev);
439 gtk_box_pack_start (GTK_BOX (hbox1), label_ng_abbrev, FALSE, FALSE, 0);
441 vbox1 = gtk_vbox_new (FALSE, VSPACING);
442 gtk_widget_show (vbox1);
443 gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
444 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox1,
445 gtk_label_new(_("Message list")));
447 hbox0 = gtk_hbox_new (FALSE, 8);
448 gtk_widget_show (hbox0);
449 gtk_box_pack_start(GTK_BOX(vbox1), hbox0, FALSE, TRUE, 0);
451 label = gtk_label_new(_("Displayed columns"));
452 gtk_widget_show(label);
453 gtk_box_pack_start(GTK_BOX(hbox0), label, FALSE, FALSE, 0);
454 button_dispitem = gtk_button_new_from_stock(GTK_STOCK_EDIT);
455 gtk_widget_show (button_dispitem);
456 gtk_box_pack_start (GTK_BOX (hbox0), button_dispitem, FALSE, FALSE, 0);
457 g_signal_connect (G_OBJECT (button_dispitem), "clicked",
458 G_CALLBACK (prefs_summary_column_open),
459 NULL);
461 PACK_SPACER(hbox0, hbox1, 4);
462 PACK_CHECK_BUTTON(hbox0, checkbtn_summary_col_lock, _("Lock column headers"));
464 hbox1 = gtk_hbox_new (FALSE, 10);
465 gtk_widget_show (hbox1);
466 gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
468 label = gtk_label_new (_("Displayed in From column"));
469 gtk_widget_show (label);
470 gtk_box_pack_start(GTK_BOX(hbox1), label, FALSE, FALSE, 0);
472 optmenu_summaryfromshow = gtkut_sc_combobox_create(NULL, FALSE);
473 menu = GTK_LIST_STORE(gtk_combo_box_get_model(
474 GTK_COMBO_BOX(optmenu_summaryfromshow)));
475 gtk_widget_show (optmenu_summaryfromshow);
477 COMBOBOX_ADD (menu, _("Name"), SHOW_NAME);
478 COMBOBOX_ADD (menu, _("Address"), SHOW_ADDR);
479 COMBOBOX_ADD (menu, _("Name and Address"), SHOW_BOTH);
481 gtk_box_pack_start(GTK_BOX(hbox1), optmenu_summaryfromshow, FALSE, FALSE, 0);
482 hbox2 = gtk_hbox_new (FALSE, 8);
483 gtk_widget_show (hbox2);
484 gtk_box_pack_start (GTK_BOX (vbox1), hbox2, FALSE, TRUE, 0);
486 label_datefmt = gtk_label_new (_("Date format"));
487 gtk_widget_show (label_datefmt);
488 gtk_box_pack_start (GTK_BOX (hbox2), label_datefmt, FALSE, FALSE, 0);
490 entry_datefmt = gtk_entry_new ();
491 gtk_widget_show (entry_datefmt);
492 gtk_box_pack_start (GTK_BOX (hbox2), entry_datefmt, FALSE, FALSE, 0);
494 button_datefmt = gtk_button_new_from_stock(GTK_STOCK_INFO);
496 gtk_widget_show (button_datefmt);
497 gtk_box_pack_start (GTK_BOX (hbox2), button_datefmt, FALSE, FALSE, 0);
498 g_signal_connect (G_OBJECT (button_datefmt), "clicked",
499 G_CALLBACK (date_format_create), NULL);
501 label_fill = gtk_label_new(" ");
502 gtk_box_pack_start(GTK_BOX(hbox2), label_fill, TRUE, FALSE, 0);
504 CLAWS_SET_TIP(button_datefmt,
505 _("Date format help"));
507 hbox1 = gtk_hbox_new (FALSE, 10);
508 gtk_widget_show (hbox1);
509 gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, TRUE, 0);
511 button_edit_actions = gtk_button_new_with_label(_("Set message selection when entering a folder"));
512 gtk_widget_show (button_edit_actions);
513 gtk_box_pack_start (GTK_BOX (hbox1), button_edit_actions,
514 FALSE, TRUE, 0);
515 g_signal_connect (G_OBJECT (button_edit_actions), "clicked",
516 G_CALLBACK (prefs_summary_open_open),
517 NULL);
519 /* Open message on select policy */
520 vbox4 = gtkut_get_options_frame(vbox1, NULL, _("Open message when selected"));
522 PACK_CHECK_BUTTON(vbox4, checkbtn_always_show_msg,
523 _("Always"));
524 PACK_CHECK_BUTTON(vbox4, checkbtn_show_on_folder_open,
525 _("When opening a folder"));
526 PACK_CHECK_BUTTON(vbox4, checkbtn_show_on_search_results,
527 _("When displaying search results"));
528 PACK_CHECK_BUTTON(vbox4, checkbtn_show_on_prevnext,
529 _("When selecting next or previous message using shortcuts"));
530 PACK_CHECK_BUTTON(vbox4, checkbtn_show_on_deletemove,
531 _("When deleting or moving messages"));
532 PACK_CHECK_BUTTON(vbox4, checkbtn_show_on_directional,
533 _("When using directional keys"));
535 vbox3 = gtkut_get_options_frame(vbox1, NULL, _("Mark message as read"));
537 radio_mark_as_read_on_select = gtk_radio_button_new_with_label(NULL,
538 _("when selected, after"));
540 hbox1 = gtk_hbox_new (FALSE, 8);
541 gtk_box_pack_start (GTK_BOX (hbox1), radio_mark_as_read_on_select, FALSE, FALSE, 0);
543 spinbtn_mark_as_read_delay_adj = GTK_ADJUSTMENT(gtk_adjustment_new (0, 0, 60, 1, 10, 0));
544 spinbtn_mark_as_read_delay = gtk_spin_button_new
545 (GTK_ADJUSTMENT (spinbtn_mark_as_read_delay_adj), 1, 0);
546 gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_mark_as_read_delay,
547 FALSE, FALSE, 0);
548 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_mark_as_read_delay),
549 TRUE);
550 gtk_box_pack_start (GTK_BOX (hbox1), gtk_label_new
551 (_("seconds")), FALSE, FALSE, 0);
553 gtk_box_pack_start (GTK_BOX (vbox3), hbox1, FALSE, FALSE, 0);
555 radio_mark_as_read_on_new_win = gtk_radio_button_new_with_label_from_widget(
556 GTK_RADIO_BUTTON(radio_mark_as_read_on_select),
557 _("only when opened in a new window, or replied to"));
558 gtk_box_pack_start (GTK_BOX (vbox3), radio_mark_as_read_on_new_win,
559 FALSE, FALSE, 0);
560 gtk_widget_show_all(vbox3);
562 /* Next Unread Message Dialog */
563 hbox1 = gtk_hbox_new (FALSE, 10);
564 gtk_widget_show (hbox1);
565 gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
567 label = gtk_label_new (_("Show \"no unread (or new) message\" dialog"));
568 gtk_widget_show (label);
569 gtk_box_pack_start(GTK_BOX(hbox1), label, FALSE, FALSE, 0);
571 optmenu_nextunreadmsgdialog = gtkut_sc_combobox_create(NULL, FALSE);
572 menu = GTK_LIST_STORE(gtk_combo_box_get_model(
573 GTK_COMBO_BOX(optmenu_nextunreadmsgdialog)));
574 gtk_widget_show (optmenu_nextunreadmsgdialog);
576 COMBOBOX_ADD (menu, _("Always"), NEXTUNREADMSGDIALOG_ALWAYS);
577 COMBOBOX_ADD (menu, _("Assume 'Yes'"), NEXTUNREADMSGDIALOG_ASSUME_YES);
578 COMBOBOX_ADD (menu, _("Assume 'No'"), NEXTUNREADMSGDIALOG_ASSUME_NO);
580 gtk_box_pack_start(GTK_BOX(hbox1), optmenu_nextunreadmsgdialog, FALSE, FALSE, 0);
582 PACK_CHECK_BUTTON
583 (vbox1, checkbtn_useaddrbook,
584 _("Display sender using address book"));
586 PACK_CHECK_BUTTON
587 (vbox1, checkbtn_threadsubj,
588 _("Thread using subject in addition to standard headers"));
590 PACK_CHECK_BUTTON
591 (vbox1, checkbtn_immedexec,
592 _("Execute immediately when moving or deleting messages"));
593 CLAWS_SET_TIP(checkbtn_immedexec,
594 _("When unchecked moving, copying and deleting of messages"
595 " is deferred until you use 'Tools/Execute'"));
597 PACK_CHECK_BUTTON
598 (vbox1, checkbtn_ask_mark_all_read,
599 _("Confirm when marking all messages as read or unread"));
600 PACK_CHECK_BUTTON
601 (vbox1, checkbtn_ask_override_colorlabel,
602 _("Confirm when changing color labels"));
604 PACK_CHECK_BUTTON
605 (vbox1, checkbtn_show_tooltips,
606 _("Show tooltips"));
608 hbox2 = gtk_hbox_new (FALSE, 8);
609 gtk_widget_show (hbox2);
610 gtk_box_pack_start (GTK_BOX (vbox1), hbox2, FALSE, FALSE, 0);
612 vbox1 = gtk_vbox_new (FALSE, VSPACING);
613 gtk_widget_show (vbox1);
614 gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
615 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox1,
616 gtk_label_new(_("Defaults")));
618 vbox2 = gtkut_get_options_frame(vbox1, &frame_new_folders, _("New folders"));
620 hbox1 = gtk_hbox_new(FALSE, 10);
621 gtk_widget_show(hbox1);
622 gtk_box_pack_start(GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
624 label = gtk_label_new(_("Sort by"));
625 gtk_widget_show(label);
626 gtk_box_pack_start(GTK_BOX(hbox1), label, FALSE, FALSE, 0);
628 optmenu_sort_key = gtkut_sc_combobox_create(NULL, FALSE);
629 menu = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(optmenu_sort_key)));
630 gtk_widget_show(optmenu_sort_key);
632 COMBOBOX_ADD(menu, _("Number"), SORT_BY_NUMBER);
633 COMBOBOX_ADD(menu, _("Size"), SORT_BY_SIZE);
634 COMBOBOX_ADD(menu, _("Date"), SORT_BY_DATE);
635 COMBOBOX_ADD(menu, _("Thread date"), SORT_BY_THREAD_DATE);
636 COMBOBOX_ADD(menu, _("From"), SORT_BY_FROM);
637 COMBOBOX_ADD(menu, _("To"), SORT_BY_TO);
638 COMBOBOX_ADD(menu, _("Subject"), SORT_BY_SUBJECT);
639 COMBOBOX_ADD(menu, _("Color label"), SORT_BY_LABEL);
640 COMBOBOX_ADD(menu, _("Tag"), SORT_BY_TAGS);
641 COMBOBOX_ADD(menu, _("Mark"), SORT_BY_MARK);
642 COMBOBOX_ADD(menu, _("Status"), SORT_BY_STATUS);
643 COMBOBOX_ADD(menu, _("Attachment"), SORT_BY_MIME);
644 COMBOBOX_ADD(menu, _("Score"), SORT_BY_SCORE);
645 COMBOBOX_ADD(menu, _("Locked"), SORT_BY_LOCKED);
646 COMBOBOX_ADD(menu, _("Don't sort"), SORT_BY_NONE);
648 gtk_box_pack_start(GTK_BOX(hbox1), optmenu_sort_key, FALSE, FALSE, 0);
650 optmenu_sort_type = gtkut_sc_combobox_create(NULL, FALSE);
651 menu = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(optmenu_sort_type)));
652 gtk_widget_show(optmenu_sort_type);
654 COMBOBOX_ADD(menu, _("Ascending"), SORT_ASCENDING);
655 COMBOBOX_ADD(menu, _("Descending"), SORT_DESCENDING);
657 gtk_box_pack_start(GTK_BOX(hbox1), optmenu_sort_type, FALSE, FALSE, 0);
659 PACK_CHECK_BUTTON
660 (vbox2, checkbtn_folder_default_thread,
661 _("Thread view"));
662 PACK_CHECK_BUTTON
663 (vbox2, checkbtn_folder_default_thread_collapsed,
664 _("Collapse all threads"));
665 PACK_CHECK_BUTTON
666 (vbox2, checkbtn_folder_default_hide_read_threads,
667 _("Hide read threads"));
668 PACK_CHECK_BUTTON
669 (vbox2, checkbtn_folder_default_hide_read_msgs,
670 _("Hide read messages"));
671 PACK_CHECK_BUTTON
672 (vbox2, checkbtn_folder_default_hide_del_msgs,
673 _("Hide deleted messages"));
675 prefs_summaries->optmenu_folder_unread = optmenu_folder_unread;
676 prefs_summaries->spinbtn_ng_abbrev_len = spinbtn_ng_abbrev_len;
677 prefs_summaries->checkbtn_useaddrbook = checkbtn_useaddrbook;
678 prefs_summaries->checkbtn_show_tooltips = checkbtn_show_tooltips;
679 prefs_summaries->checkbtn_threadsubj = checkbtn_threadsubj;
680 prefs_summaries->entry_datefmt = entry_datefmt;
681 prefs_summaries->checkbtn_reopen_last_folder = checkbtn_reopen_last_folder;
683 prefs_summaries->checkbtn_always_show_msg = checkbtn_always_show_msg;
684 prefs_summaries->checkbtn_show_on_folder_open = checkbtn_show_on_folder_open;
685 prefs_summaries->checkbtn_show_on_search_results = checkbtn_show_on_search_results;
686 prefs_summaries->checkbtn_show_on_prevnext = checkbtn_show_on_prevnext;
687 prefs_summaries->checkbtn_show_on_deletemove = checkbtn_show_on_deletemove;
688 prefs_summaries->checkbtn_show_on_directional = checkbtn_show_on_directional;
690 prefs_summaries->checkbtn_mark_as_read_on_newwin = radio_mark_as_read_on_new_win;
691 prefs_summaries->spinbtn_mark_as_read_delay = spinbtn_mark_as_read_delay;
692 prefs_summaries->checkbtn_immedexec = checkbtn_immedexec;
693 prefs_summaries->checkbtn_ask_mark_all_read = checkbtn_ask_mark_all_read;
694 prefs_summaries->checkbtn_ask_override_colorlabel = checkbtn_ask_override_colorlabel;
695 prefs_summaries->optmenu_sort_key = optmenu_sort_key;
696 prefs_summaries->optmenu_sort_type = optmenu_sort_type;
697 prefs_summaries->optmenu_nextunreadmsgdialog = optmenu_nextunreadmsgdialog;
698 prefs_summaries->optmenu_summaryfromshow = optmenu_summaryfromshow;
700 prefs_summaries->checkbtn_folder_default_thread = checkbtn_folder_default_thread;
701 prefs_summaries->checkbtn_folder_default_thread_collapsed = checkbtn_folder_default_thread_collapsed;
702 prefs_summaries->checkbtn_folder_default_hide_read_threads = checkbtn_folder_default_hide_read_threads;
703 prefs_summaries->checkbtn_folder_default_hide_read_msgs = checkbtn_folder_default_hide_read_msgs;
704 prefs_summaries->checkbtn_folder_default_hide_del_msgs = checkbtn_folder_default_hide_del_msgs;
705 prefs_summaries->checkbtn_summary_col_lock = checkbtn_summary_col_lock;
707 prefs_summaries->page.widget = vbox1;
708 g_signal_connect(G_OBJECT(checkbtn_always_show_msg), "toggled",
709 G_CALLBACK(always_show_msg_toggled), prefs_summaries);
711 g_signal_connect(G_OBJECT(radio_mark_as_read_on_select), "toggled",
712 G_CALLBACK(mark_as_read_toggled),
713 spinbtn_mark_as_read_delay);
715 prefs_summaries->window = GTK_WIDGET(window);
717 combobox_select_by_data(GTK_COMBO_BOX(optmenu_folder_unread),
718 prefs_common.display_folder_unread);
719 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_useaddrbook),
720 prefs_common.use_addr_book);
721 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_show_tooltips),
722 prefs_common.show_tooltips);
723 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_threadsubj),
724 prefs_common.thread_by_subject);
725 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_ng_abbrev_len),
726 prefs_common.ng_abbrev_len);
727 gtk_entry_set_text(GTK_ENTRY(entry_datefmt),
728 prefs_common.date_format?prefs_common.date_format:"");
729 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_reopen_last_folder),
730 prefs_common.goto_last_folder_on_startup);
732 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_always_show_msg),
733 prefs_common.always_show_msg);
734 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_show_on_folder_open),
735 prefs_common.open_selected_on_folder_open);
736 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_show_on_search_results),
737 prefs_common.open_selected_on_search_results);
738 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_show_on_prevnext),
739 prefs_common.open_selected_on_prevnext);
740 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_show_on_deletemove),
741 prefs_common.open_selected_on_deletemove);
742 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_show_on_directional),
743 prefs_common.open_selected_on_directional);
745 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio_mark_as_read_on_new_win),
746 prefs_common.mark_as_read_on_new_window);
747 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_mark_as_read_delay),
748 prefs_common.mark_as_read_delay);
749 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_immedexec),
750 prefs_common.immediate_exec);
751 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_ask_mark_all_read),
752 prefs_common.ask_mark_all_read);
753 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_ask_override_colorlabel),
754 prefs_common.ask_override_colorlabel);
756 combobox_select_by_data(GTK_COMBO_BOX(optmenu_sort_key),
757 prefs_common.default_sort_key);
758 combobox_select_by_data(GTK_COMBO_BOX(optmenu_sort_type),
759 prefs_common.default_sort_type);
761 combobox_select_by_data(GTK_COMBO_BOX(optmenu_summaryfromshow),
762 prefs_common.summary_from_show);
764 combobox_select_by_data(GTK_COMBO_BOX(optmenu_nextunreadmsgdialog),
765 prefs_common.next_unread_msg_dialog);
767 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_folder_default_thread),
768 prefs_common.folder_default_thread);
769 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_folder_default_thread_collapsed),
770 prefs_common.folder_default_thread_collapsed);
771 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_folder_default_hide_read_threads),
772 prefs_common.folder_default_hide_read_threads);
773 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_folder_default_hide_read_msgs),
774 prefs_common.folder_default_hide_read_msgs);
775 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_folder_default_hide_del_msgs),
776 prefs_common.folder_default_hide_del_msgs);
777 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_summary_col_lock),
778 prefs_common.summary_col_lock);
780 gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 0);
782 prefs_summaries->page.widget = notebook;
785 static void prefs_summaries_save(PrefsPage *_page)
787 SummariesPage *page = (SummariesPage *) _page;
789 prefs_common.display_folder_unread = combobox_get_active_data(
790 GTK_COMBO_BOX(page->optmenu_folder_unread));
792 prefs_common.use_addr_book = gtk_toggle_button_get_active(
793 GTK_TOGGLE_BUTTON(page->checkbtn_useaddrbook));
794 prefs_common.show_tooltips = gtk_toggle_button_get_active(
795 GTK_TOGGLE_BUTTON(page->checkbtn_show_tooltips));
796 prefs_common.thread_by_subject = gtk_toggle_button_get_active(
797 GTK_TOGGLE_BUTTON(page->checkbtn_threadsubj));
798 prefs_common.ng_abbrev_len = gtk_spin_button_get_value_as_int(
799 GTK_SPIN_BUTTON(page->spinbtn_ng_abbrev_len));
801 g_free(prefs_common.date_format);
802 prefs_common.date_format = gtk_editable_get_chars(
803 GTK_EDITABLE(page->entry_datefmt), 0, -1);
805 prefs_common.goto_last_folder_on_startup = gtk_toggle_button_get_active(
806 GTK_TOGGLE_BUTTON(page->checkbtn_reopen_last_folder));
808 prefs_common.always_show_msg = gtk_toggle_button_get_active(
809 GTK_TOGGLE_BUTTON(page->checkbtn_always_show_msg));
810 prefs_common.open_selected_on_folder_open = gtk_toggle_button_get_active(
811 GTK_TOGGLE_BUTTON(page->checkbtn_show_on_folder_open));
812 prefs_common.open_selected_on_search_results = gtk_toggle_button_get_active(
813 GTK_TOGGLE_BUTTON(page->checkbtn_show_on_search_results));
814 prefs_common.open_selected_on_prevnext = gtk_toggle_button_get_active(
815 GTK_TOGGLE_BUTTON(page->checkbtn_show_on_prevnext));
816 prefs_common.open_selected_on_deletemove = gtk_toggle_button_get_active(
817 GTK_TOGGLE_BUTTON(page->checkbtn_show_on_deletemove));
818 prefs_common.open_selected_on_directional = gtk_toggle_button_get_active(
819 GTK_TOGGLE_BUTTON(page->checkbtn_show_on_directional));
821 prefs_common.mark_as_read_on_new_window = gtk_toggle_button_get_active(
822 GTK_TOGGLE_BUTTON(page->checkbtn_mark_as_read_on_newwin));
823 prefs_common.immediate_exec = gtk_toggle_button_get_active(
824 GTK_TOGGLE_BUTTON(page->checkbtn_immedexec));
825 prefs_common.ask_mark_all_read = gtk_toggle_button_get_active(
826 GTK_TOGGLE_BUTTON(page->checkbtn_ask_mark_all_read));
827 prefs_common.ask_override_colorlabel = gtk_toggle_button_get_active(
828 GTK_TOGGLE_BUTTON(page->checkbtn_ask_override_colorlabel));
829 prefs_common.mark_as_read_delay = gtk_spin_button_get_value_as_int(
830 GTK_SPIN_BUTTON(page->spinbtn_mark_as_read_delay));
831 prefs_common.summary_col_lock = gtk_toggle_button_get_active(
832 GTK_TOGGLE_BUTTON(page->checkbtn_summary_col_lock));
834 prefs_common.default_sort_key = combobox_get_active_data(
835 GTK_COMBO_BOX(page->optmenu_sort_key));
836 prefs_common.default_sort_type = combobox_get_active_data(
837 GTK_COMBO_BOX(page->optmenu_sort_type));
838 prefs_common.summary_from_show = combobox_get_active_data(
839 GTK_COMBO_BOX(page->optmenu_summaryfromshow));
840 prefs_common.next_unread_msg_dialog = combobox_get_active_data(
841 GTK_COMBO_BOX(page->optmenu_nextunreadmsgdialog));
842 prefs_common.folder_default_thread = gtk_toggle_button_get_active(
843 GTK_TOGGLE_BUTTON(page->checkbtn_folder_default_thread));
844 prefs_common.folder_default_thread_collapsed = gtk_toggle_button_get_active(
845 GTK_TOGGLE_BUTTON(page->checkbtn_folder_default_thread_collapsed));
846 prefs_common.folder_default_hide_read_threads = gtk_toggle_button_get_active(
847 GTK_TOGGLE_BUTTON(page->checkbtn_folder_default_hide_read_threads));
848 prefs_common.folder_default_hide_read_msgs = gtk_toggle_button_get_active(
849 GTK_TOGGLE_BUTTON(page->checkbtn_folder_default_hide_read_msgs));
850 prefs_common.folder_default_hide_del_msgs = gtk_toggle_button_get_active(
851 GTK_TOGGLE_BUTTON(page->checkbtn_folder_default_hide_del_msgs));
852 prefs_common.folder_default_hide_del_msgs = gtk_toggle_button_get_active(
853 GTK_TOGGLE_BUTTON(page->checkbtn_folder_default_hide_del_msgs));
855 main_window_reflect_prefs_all();
858 static void prefs_summaries_destroy_widget(PrefsPage *_page)
862 SummariesPage *prefs_summaries;
864 void prefs_summaries_init(void)
866 SummariesPage *page;
867 static gchar *path[3];
869 path[0] = _("Display");
870 path[1] = _("Summaries");
871 path[2] = NULL;
873 page = g_new0(SummariesPage, 1);
874 page->page.path = path;
875 page->page.create_widget = prefs_summaries_create_widget;
876 page->page.destroy_widget = prefs_summaries_destroy_widget;
877 page->page.save_page = prefs_summaries_save;
878 page->page.weight = 140.0;
879 prefs_gtk_register_page((PrefsPage *) page);
880 prefs_summaries = page;
883 void prefs_summaries_done(void)
885 prefs_gtk_unregister_page((PrefsPage *) prefs_summaries);
886 g_free(prefs_summaries);
889 static void date_format_ok_btn_clicked(GtkButton *button, GtkWidget **widget)
891 GtkWidget *datefmt_sample = NULL;
892 gchar *text;
894 cm_return_if_fail(widget != NULL);
895 cm_return_if_fail(*widget != NULL);
896 cm_return_if_fail(prefs_summaries->entry_datefmt != NULL);
898 datefmt_sample = GTK_WIDGET(g_object_get_data
899 (G_OBJECT(*widget), "datefmt_sample"));
900 cm_return_if_fail(datefmt_sample != NULL);
902 text = gtk_editable_get_chars(GTK_EDITABLE(datefmt_sample), 0, -1);
903 g_free(prefs_common.date_format);
904 prefs_common.date_format = text;
905 gtk_entry_set_text(GTK_ENTRY(prefs_summaries->entry_datefmt), text);
907 gtk_widget_destroy(*widget);
908 *widget = NULL;
911 static void date_format_cancel_btn_clicked(GtkButton *button,
912 GtkWidget **widget)
914 cm_return_if_fail(widget != NULL);
915 cm_return_if_fail(*widget != NULL);
917 gtk_widget_destroy(*widget);
918 *widget = NULL;
921 static gboolean date_format_key_pressed(GtkWidget *keywidget, GdkEventKey *event,
922 GtkWidget **widget)
924 if (event && event->keyval == GDK_KEY_Escape)
925 date_format_cancel_btn_clicked(NULL, widget);
926 return FALSE;
929 static gboolean date_format_on_delete(GtkWidget *dialogwidget,
930 GdkEventAny *event, GtkWidget **widget)
932 cm_return_val_if_fail(widget != NULL, FALSE);
933 cm_return_val_if_fail(*widget != NULL, FALSE);
935 *widget = NULL;
936 return FALSE;
939 static void date_format_entry_on_change(GtkEditable *editable,
940 GtkLabel *example)
942 time_t cur_time;
943 struct tm *cal_time;
944 gchar buffer[100];
945 gchar *text;
946 struct tm lt;
948 cur_time = time(NULL);
949 cal_time = localtime_r(&cur_time, &lt);
950 buffer[0] = 0;
951 text = gtk_editable_get_chars(editable, 0, -1);
952 if (text)
953 fast_strftime(buffer, sizeof buffer, text, cal_time);
955 gtk_label_set_text(example, buffer);
957 g_free(text);
960 static void date_format_select_row(GtkTreeView *list_view,
961 GtkTreePath *path,
962 GtkTreeViewColumn *column,
963 GtkWidget *date_format)
965 gint cur_pos;
966 gchar *format;
967 const gchar *old_format;
968 gchar *new_format;
969 GtkWidget *datefmt_sample;
970 GtkTreeIter iter;
971 GtkTreeModel *model;
973 cm_return_if_fail(date_format != NULL);
975 /* only on double click */
976 datefmt_sample = GTK_WIDGET(g_object_get_data(G_OBJECT(date_format),
977 "datefmt_sample"));
979 cm_return_if_fail(datefmt_sample != NULL);
981 model = gtk_tree_view_get_model(list_view);
983 /* get format from list */
984 if (!gtk_tree_model_get_iter(model, &iter, path))
985 return;
987 gtk_tree_model_get(model, &iter, DATEFMT_FMT, &format, -1);
989 cur_pos = gtk_editable_get_position(GTK_EDITABLE(datefmt_sample));
990 old_format = gtk_entry_get_text(GTK_ENTRY(datefmt_sample));
992 /* insert the format into the text entry */
993 new_format = g_malloc(strlen(old_format) + 3);
995 strncpy(new_format, old_format, cur_pos);
996 new_format[cur_pos] = '\0';
997 strcat(new_format, format);
998 g_free(format);
999 strcat(new_format, &old_format[cur_pos]);
1001 gtk_entry_set_text(GTK_ENTRY(datefmt_sample), new_format);
1002 gtk_editable_set_position(GTK_EDITABLE(datefmt_sample), cur_pos + 2);
1004 g_free(new_format);
1007 static void always_show_msg_toggled(GtkToggleButton *button,
1008 gpointer user_data)
1010 const SummariesPage *prefs_summaries = (SummariesPage *)user_data;
1011 gboolean state;
1013 cm_return_if_fail(prefs_summaries != NULL);
1015 state = gtk_toggle_button_get_active(button);
1017 gtk_widget_set_sensitive(prefs_summaries->checkbtn_show_on_folder_open, !state);
1018 gtk_widget_set_sensitive(prefs_summaries->checkbtn_show_on_search_results, !state);
1019 gtk_widget_set_sensitive(prefs_summaries->checkbtn_show_on_prevnext, !state);
1020 gtk_widget_set_sensitive(prefs_summaries->checkbtn_show_on_deletemove, !state);
1021 gtk_widget_set_sensitive(prefs_summaries->checkbtn_show_on_directional, !state);
1024 static void mark_as_read_toggled(GtkToggleButton *button, GtkWidget *spinbtn)
1026 gtk_widget_set_sensitive(spinbtn,
1027 gtk_toggle_button_get_active(button));