Fix CID 1596595: Resource leak
[claws.git] / src / prefs_summaries.c
blob576174746aad62cfe91252d6b80b8c8f617abf7c
1 /*
2 * Claws Mail -- a GTK based, lightweight, and fast e-mail client
3 * Copyright (C) 2005-2024 the Claws Mail Team and Colin Leroy
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 #include "foldersel.h"
35 #include "prefs_common.h"
36 #include "prefs_gtk.h"
37 #include "prefs_summary_open.h"
38 #include "prefs_summary_column.h"
39 #include "prefs_folder_column.h"
41 #include "gtk/menu.h"
42 #include "gtk/gtkutils.h"
43 #include "gtk/prefswindow.h"
44 #include "gtk/combobox.h"
46 #include "manage_window.h"
48 typedef struct _SummariesPage
50 PrefsPage page;
52 GtkWidget *window;
54 GtkWidget *optmenu_folder_unread;
55 GtkWidget *spinbtn_ng_abbrev_len;
56 GtkWidget *checkbtn_useaddrbook;
57 GtkWidget *checkbtn_show_tooltips;
58 GtkWidget *checkbtn_threadsubj;
59 GtkWidget *button_datefmt;
60 GtkWidget *entry_datefmt;
62 GtkWidget *checkbtn_reopen_last_folder;
63 GtkWidget *checkbtn_startup_folder;
64 GtkWidget *startup_folder_entry;
65 GtkWidget *startup_folder_select;
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_run_processingrules_mark_all_read;
77 GtkWidget *checkbtn_ask_override_colorlabel;
78 GtkWidget *optmenu_sort_key;
79 GtkWidget *optmenu_sort_type;
80 GtkWidget *optmenu_summaryfromshow;
81 GtkWidget *optmenu_nextunreadmsgdialog;
82 GtkWidget *checkbtn_folder_default_thread;
83 GtkWidget *checkbtn_folder_default_thread_collapsed;
84 GtkWidget *checkbtn_folder_default_hide_read_threads;
85 GtkWidget *checkbtn_folder_default_hide_read_msgs;
86 GtkWidget *checkbtn_folder_default_hide_del_msgs;
87 GtkWidget *checkbtn_summary_col_lock;
89 } SummariesPage;
91 enum {
92 DATEFMT_FMT,
93 DATEFMT_TXT,
94 N_DATEFMT_COLUMNS
97 static void date_format_ok_btn_clicked (GtkButton *button,
98 GtkWidget **widget);
99 static void date_format_cancel_btn_clicked (GtkButton *button,
100 GtkWidget **widget);
101 static gboolean date_format_key_pressed (GtkWidget *keywidget,
102 GdkEventKey *event,
103 GtkWidget **widget);
104 static gboolean date_format_on_delete (GtkWidget *dialogwidget,
105 GdkEventAny *event,
106 GtkWidget **widget);
107 static void date_format_entry_on_change (GtkEditable *editable,
108 GtkLabel *example);
109 static void date_format_select_row (GtkTreeView *list_view,
110 GtkTreePath *path,
111 GtkTreeViewColumn *column,
112 GtkWidget *date_format);
113 static void mark_as_read_toggled (GtkToggleButton *button,
114 GtkWidget *spinbtn);
115 static void always_show_msg_toggled (GtkToggleButton *button,
116 gpointer user_data);
118 static void reopen_last_folder_toggled(GtkToggleButton *toggle_btn, GtkWidget *widget)
120 gboolean is_active;
122 is_active = gtk_toggle_button_get_active(toggle_btn);
123 gtk_widget_set_sensitive(widget, !is_active);
124 if (is_active)
125 prefs_common.goto_folder_on_startup = FALSE;
128 static void startup_folder_toggled(GtkToggleButton *toggle_btn, GtkWidget *widget)
130 gboolean is_active;
132 is_active = gtk_toggle_button_get_active(toggle_btn);
133 gtk_widget_set_sensitive(widget, !is_active);
134 if (is_active)
135 prefs_common.goto_last_folder_on_startup = FALSE;
138 static void foldersel_cb(GtkWidget *widget, gpointer data)
140 GtkWidget *entry = (GtkWidget *) data;
141 FolderItem *item;
142 gchar *item_id;
143 gint newpos = 0;
145 item = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL, FALSE, NULL);
146 if (item && (item_id = folder_item_get_identifier(item)) != NULL) {
147 gtk_editable_delete_text(GTK_EDITABLE(entry), 0, -1);
148 gtk_editable_insert_text(GTK_EDITABLE(entry), item_id, strlen(item_id), &newpos);
149 g_free(item_id);
153 static GtkWidget *date_format_create(GtkButton *button, void *data)
155 static GtkWidget *datefmt_win = NULL;
157 GtkWidget *vbox1;
158 GtkWidget *scrolledwindow1;
159 GtkWidget *datefmt_list_view;
160 GtkWidget *table;
161 GtkWidget *label1;
162 GtkWidget *label2;
163 GtkWidget *label3;
164 GtkWidget *confirm_area;
165 GtkWidget *ok_btn;
166 GtkWidget *cancel_btn;
167 GtkWidget *datefmt_entry;
168 GtkListStore *store;
170 struct {
171 gchar *fmt;
172 gchar *txt;
173 } time_format[] = {
174 { "%a", NULL },
175 { "%A", NULL },
176 { "%b", NULL },
177 { "%B", NULL },
178 { "%c", NULL },
179 { "%C", NULL },
180 { "%d", NULL },
181 { "%H", NULL },
182 { "%I", NULL },
183 { "%j", NULL },
184 { "%m", NULL },
185 { "%M", NULL },
186 { "%p", NULL },
187 { "%S", NULL },
188 { "%w", NULL },
189 { "%x", NULL },
190 { "%y", NULL },
191 { "%Y", NULL },
192 { "%Z", NULL }
195 gint i;
196 const gint TIME_FORMAT_ELEMS =
197 sizeof time_format / sizeof time_format[0];
199 GtkCellRenderer *renderer;
200 GtkTreeViewColumn *column;
201 GtkTreeSelection *selection;
203 time_format[0].txt = _("the abbreviated weekday name");
204 time_format[1].txt = _("the full weekday name");
205 time_format[2].txt = _("the abbreviated month name");
206 time_format[3].txt = _("the full month name");
207 time_format[4].txt = _("the preferred date and time for the current locale");
208 time_format[5].txt = _("the century number (year/100)");
209 time_format[6].txt = _("the day of the month as a decimal number");
210 time_format[7].txt = _("the hour as a decimal number using a 24-hour clock");
211 time_format[8].txt = _("the hour as a decimal number using a 12-hour clock");
212 time_format[9].txt = _("the day of the year as a decimal number");
213 time_format[10].txt = _("the month as a decimal number");
214 time_format[11].txt = _("the minute as a decimal number");
215 time_format[12].txt = _("either AM or PM");
216 time_format[13].txt = _("the second as a decimal number");
217 time_format[14].txt = _("the day of the week as a decimal number");
218 time_format[15].txt = _("the preferred date for the current locale");
219 time_format[16].txt = _("the last two digits of a year");
220 time_format[17].txt = _("the year as a decimal number");
221 time_format[18].txt = _("the time zone or name or abbreviation");
223 if (datefmt_win) return datefmt_win;
225 store = gtk_list_store_new(N_DATEFMT_COLUMNS,
226 G_TYPE_STRING,
227 G_TYPE_STRING,
228 -1);
230 for (i = 0; i < TIME_FORMAT_ELEMS; i++) {
231 GtkTreeIter iter;
233 gtk_list_store_append(store, &iter);
234 gtk_list_store_set(store, &iter,
235 DATEFMT_FMT, time_format[i].fmt,
236 DATEFMT_TXT, time_format[i].txt,
237 -1);
240 datefmt_win = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "prefs_summaries");
241 gtk_container_set_border_width(GTK_CONTAINER(datefmt_win), 8);
242 gtk_window_set_title(GTK_WINDOW(datefmt_win), _("Date format"));
243 gtk_window_set_position(GTK_WINDOW(datefmt_win), GTK_WIN_POS_CENTER);
244 gtk_window_set_type_hint(GTK_WINDOW(datefmt_win), GDK_WINDOW_TYPE_HINT_DIALOG);
245 gtk_widget_set_size_request(datefmt_win, 440, 280);
247 vbox1 = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
248 gtk_widget_show(vbox1);
249 gtk_container_add(GTK_CONTAINER(datefmt_win), vbox1);
251 scrolledwindow1 = gtk_scrolled_window_new(NULL, NULL);
252 gtk_scrolled_window_set_policy
253 (GTK_SCROLLED_WINDOW(scrolledwindow1),
254 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
255 gtk_widget_show(scrolledwindow1);
256 gtk_box_pack_start(GTK_BOX(vbox1), scrolledwindow1, TRUE, TRUE, 0);
258 datefmt_list_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
259 g_object_unref(G_OBJECT(store));
260 gtk_widget_show(datefmt_list_view);
261 gtk_container_add(GTK_CONTAINER(scrolledwindow1), datefmt_list_view);
263 renderer = gtk_cell_renderer_text_new();
264 column = gtk_tree_view_column_new_with_attributes
265 (_("Specifier"), renderer, "text", DATEFMT_FMT,
266 NULL);
267 gtk_tree_view_append_column(GTK_TREE_VIEW(datefmt_list_view), column);
269 renderer = gtk_cell_renderer_text_new();
270 column = gtk_tree_view_column_new_with_attributes
271 (_("Description"), renderer, "text", DATEFMT_TXT,
272 NULL);
273 gtk_tree_view_append_column(GTK_TREE_VIEW(datefmt_list_view), column);
275 /* gtk_cmclist_set_column_width(GTK_CMCLIST(datefmt_clist), 0, 80); */
276 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(datefmt_list_view));
277 gtk_tree_selection_set_mode(selection, GTK_SELECTION_BROWSE);
279 g_signal_connect(G_OBJECT(datefmt_list_view), "row_activated",
280 G_CALLBACK(date_format_select_row),
281 datefmt_win);
283 table = gtk_grid_new();
284 gtk_widget_show(table);
285 gtk_box_pack_start(GTK_BOX(vbox1), table, FALSE, FALSE, 0);
286 gtk_grid_set_row_spacing(GTK_GRID(table), 4);
287 gtk_grid_set_column_spacing(GTK_GRID(table), 8);
289 label1 = gtk_label_new(_("Date format"));
290 gtk_widget_show(label1);
291 gtk_label_set_justify(GTK_LABEL(label1), GTK_JUSTIFY_LEFT);
292 gtk_label_set_xalign(GTK_LABEL(label1), 0.0);
293 gtk_grid_attach(GTK_GRID(table), label1, 0, 0, 1, 1);
295 datefmt_entry = gtk_entry_new();
296 gtk_entry_set_max_length(GTK_ENTRY(datefmt_entry), 256);
297 gtk_widget_show(datefmt_entry);
298 gtk_grid_attach(GTK_GRID(table), datefmt_entry, 1, 0, 1, 1);
299 gtk_widget_set_hexpand(datefmt_entry, TRUE);
300 gtk_widget_set_halign(datefmt_entry, GTK_ALIGN_FILL);
302 /* we need the "sample" entry box; add it as data so callbacks can
303 * get the entry box */
304 g_object_set_data(G_OBJECT(datefmt_win), "datefmt_sample",
305 datefmt_entry);
307 label2 = gtk_label_new(_("Example"));
308 gtk_widget_show(label2);
309 gtk_label_set_justify(GTK_LABEL(label2), GTK_JUSTIFY_LEFT);
310 gtk_label_set_xalign(GTK_LABEL(label2), 0.0);
311 gtk_grid_attach(GTK_GRID(table), label2, 0, 1, 1, 1);
313 label3 = gtk_label_new("");
314 gtk_widget_show(label3);
315 gtk_label_set_justify(GTK_LABEL(label3), GTK_JUSTIFY_LEFT);
316 gtk_label_set_xalign(GTK_LABEL(label3), 0.0);
317 gtk_grid_attach(GTK_GRID(table), label3, 1, 1, 1, 1);
318 gtk_widget_set_hexpand(label3, TRUE);
319 gtk_widget_set_halign(label3, GTK_ALIGN_FILL);
321 gtkut_stock_button_set_create(&confirm_area, &cancel_btn, NULL, _("_Cancel"),
322 &ok_btn, NULL, _("_OK"), NULL, NULL, NULL);
324 gtk_box_pack_start(GTK_BOX(vbox1), confirm_area, FALSE, FALSE, 0);
325 gtk_widget_show(confirm_area);
326 gtk_widget_grab_default(ok_btn);
328 /* set the current format */
329 gtk_entry_set_text(GTK_ENTRY(datefmt_entry), prefs_common.date_format);
330 date_format_entry_on_change(GTK_EDITABLE(datefmt_entry),
331 GTK_LABEL(label3));
333 g_signal_connect(G_OBJECT(ok_btn), "clicked",
334 G_CALLBACK(date_format_ok_btn_clicked),
335 &datefmt_win);
336 g_signal_connect(G_OBJECT(cancel_btn), "clicked",
337 G_CALLBACK(date_format_cancel_btn_clicked),
338 &datefmt_win);
339 g_signal_connect(G_OBJECT(datefmt_win), "key_press_event",
340 G_CALLBACK(date_format_key_pressed),
341 &datefmt_win);
342 g_signal_connect(G_OBJECT(datefmt_win), "delete_event",
343 G_CALLBACK(date_format_on_delete),
344 &datefmt_win);
345 g_signal_connect(G_OBJECT(datefmt_entry), "changed",
346 G_CALLBACK(date_format_entry_on_change),
347 label3);
349 gtk_widget_show(datefmt_win);
350 manage_window_set_transient(GTK_WINDOW(datefmt_win));
351 gtk_window_set_modal(GTK_WINDOW(datefmt_win), TRUE);
353 gtk_widget_grab_focus(ok_btn);
355 return datefmt_win;
358 static void prefs_summaries_create_widget(PrefsPage *_page, GtkWindow *window,
359 gpointer data)
361 SummariesPage *prefs_summaries = (SummariesPage *) _page;
363 GtkWidget *notebook;
364 GtkWidget *hbox0, *hbox1, *hbox2;
365 GtkWidget *vbox1, *vbox2, *vbox3, *vbox4;
366 GtkWidget *frame_new_folders;
367 GtkWidget *optmenu_folder_unread;
368 GtkWidget *label_ng_abbrev;
369 GtkWidget *spinbtn_ng_abbrev_len;
370 GtkAdjustment *spinbtn_ng_abbrev_len_adj;
371 GtkWidget *checkbtn_useaddrbook;
372 GtkWidget *checkbtn_show_tooltips;
373 GtkWidget *checkbtn_threadsubj;
374 GtkWidget *label_datefmt;
375 GtkWidget *button_datefmt;
376 GtkWidget *entry_datefmt;
377 GtkWidget *button_dispitem;
378 GtkWidget *checkbtn_reopen_last_folder;
379 GtkWidget *checkbtn_startup_folder;
380 GtkWidget *startup_folder_entry;
381 GtkWidget *startup_folder_select;
382 GtkWidget *checkbtn_always_show_msg;
383 GtkWidget *checkbtn_show_on_folder_open;
384 GtkWidget *checkbtn_show_on_search_results;
385 GtkWidget *checkbtn_show_on_prevnext;
386 GtkWidget *checkbtn_show_on_deletemove;
387 GtkWidget *checkbtn_show_on_directional;
388 GtkWidget *spinbtn_mark_as_read_delay;
389 GtkAdjustment *spinbtn_mark_as_read_delay_adj;
390 GtkWidget *checkbtn_immedexec;
391 GtkWidget *checkbtn_ask_mark_all_read;
392 GtkWidget *checkbtn_run_processingrules_mark_all_read;
393 GtkWidget *checkbtn_ask_override_colorlabel;
394 GtkWidget *label, *label_fill;
395 GtkListStore *menu;
396 GtkTreeIter iter;
397 GtkWidget *optmenu_summaryfromshow;
398 GtkWidget *optmenu_nextunreadmsgdialog;
399 GtkWidget *button_edit_actions;
400 GtkWidget *radio_mark_as_read_on_select;
401 GtkWidget *radio_mark_as_read_on_new_win;
402 GtkWidget *optmenu_sort_key;
403 GtkWidget *optmenu_sort_type;
404 GtkWidget *checkbtn_folder_default_thread;
405 GtkWidget *checkbtn_folder_default_thread_collapsed;
406 GtkWidget *checkbtn_folder_default_hide_read_threads;
407 GtkWidget *checkbtn_folder_default_hide_read_msgs;
408 GtkWidget *checkbtn_folder_default_hide_del_msgs;
409 GtkWidget *checkbtn_summary_col_lock;
411 notebook = gtk_notebook_new();
412 gtk_widget_show(notebook);
414 vbox1 = gtk_box_new(GTK_ORIENTATION_VERTICAL, VSPACING);
415 gtk_widget_show (vbox1);
416 gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
417 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox1,
418 gtk_label_new(_("Folder list")));
420 hbox0 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
421 gtk_widget_show (hbox0);
422 gtk_box_pack_start(GTK_BOX(vbox1), hbox0, FALSE, TRUE, 0);
424 label = gtk_label_new(_("Displayed columns"));
425 gtk_widget_show(label);
426 gtk_box_pack_start(GTK_BOX(hbox0), label, FALSE, FALSE, 0);
427 button_dispitem = gtk_button_new_with_mnemonic("_Edit");
428 gtk_widget_show (button_dispitem);
429 gtk_box_pack_start (GTK_BOX (hbox0), button_dispitem, FALSE, FALSE, 0);
430 g_signal_connect (G_OBJECT (button_dispitem), "clicked",
431 G_CALLBACK (prefs_folder_column_open),
432 NULL);
434 hbox0 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
435 gtk_widget_show (hbox0);
436 gtk_box_pack_start(GTK_BOX (vbox1), hbox0, FALSE, FALSE, 0);
438 label = gtk_label_new (_("Display message count next to folder name"));
439 gtk_widget_show (label);
440 gtk_box_pack_start(GTK_BOX(hbox0), label, FALSE, FALSE, 0);
442 optmenu_folder_unread = gtkut_sc_combobox_create(NULL, FALSE);
443 menu = GTK_LIST_STORE(gtk_combo_box_get_model(
444 GTK_COMBO_BOX(optmenu_folder_unread)));
445 gtk_widget_show (optmenu_folder_unread);
447 COMBOBOX_ADD (menu, _("No"), 0);
448 COMBOBOX_ADD (menu, _("Unread messages"), 1);
449 COMBOBOX_ADD (menu, _("Unread and Total messages"), 2);
451 gtk_box_pack_start(GTK_BOX(hbox0), optmenu_folder_unread, FALSE, FALSE, 0);
453 PACK_CHECK_BUTTON
454 (vbox1, checkbtn_reopen_last_folder,
455 _("Open last opened folder at start-up"));
457 hbox0 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
458 gtk_widget_show(hbox0);
459 gtk_box_pack_start(GTK_BOX(vbox1), hbox0, FALSE, FALSE, 0);
461 PACK_CHECK_BUTTON
462 (hbox0, checkbtn_startup_folder,
463 _("Open selected folder at start-up"));
465 startup_folder_entry = gtk_entry_new();
466 gtk_widget_show(startup_folder_entry);
467 gtk_box_pack_start(GTK_BOX(hbox0), startup_folder_entry, TRUE, TRUE, 0);
468 startup_folder_select = gtkut_get_browse_directory_btn(_("_Browse"));
469 gtk_widget_show(startup_folder_select);
470 gtk_box_pack_start(GTK_BOX(hbox0), startup_folder_select, FALSE, FALSE, 0);
472 SET_TOGGLE_SENSITIVITY(checkbtn_startup_folder, startup_folder_entry)
473 SET_TOGGLE_SENSITIVITY(checkbtn_startup_folder, startup_folder_select)
475 g_signal_connect(G_OBJECT(checkbtn_reopen_last_folder), "toggled",
476 G_CALLBACK(reopen_last_folder_toggled), checkbtn_startup_folder);
477 g_signal_connect(G_OBJECT(checkbtn_startup_folder), "toggled",
478 G_CALLBACK(startup_folder_toggled), checkbtn_reopen_last_folder);
479 g_signal_connect(G_OBJECT(startup_folder_select), "clicked",
480 G_CALLBACK(foldersel_cb), startup_folder_entry);
482 PACK_CHECK_BUTTON
483 (vbox1, checkbtn_run_processingrules_mark_all_read,
484 _("Run processing rules before marking all messages in a folder as read or unread"));
486 hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
487 gtk_widget_show (hbox1);
488 gtk_box_pack_start(GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
490 label_ng_abbrev = gtk_label_new
491 (_("Abbreviate newsgroup names longer than"));
492 gtk_widget_show (label_ng_abbrev);
493 gtk_box_pack_start (GTK_BOX (hbox1), label_ng_abbrev, FALSE, FALSE, 0);
495 spinbtn_ng_abbrev_len_adj = GTK_ADJUSTMENT(gtk_adjustment_new (16, 0, 999, 1, 10, 0));
496 spinbtn_ng_abbrev_len = gtk_spin_button_new
497 (GTK_ADJUSTMENT (spinbtn_ng_abbrev_len_adj), 1, 0);
498 gtk_widget_show (spinbtn_ng_abbrev_len);
499 gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_ng_abbrev_len,
500 FALSE, FALSE, 0);
501 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_ng_abbrev_len),
502 TRUE);
504 label_ng_abbrev = gtk_label_new (_("letters"));
505 gtk_widget_show (label_ng_abbrev);
506 gtk_box_pack_start (GTK_BOX (hbox1), label_ng_abbrev, FALSE, FALSE, 0);
508 vbox1 = gtk_box_new(GTK_ORIENTATION_VERTICAL, VSPACING);
509 gtk_widget_show (vbox1);
510 gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
511 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox1,
512 gtk_label_new(_("Message list")));
514 hbox0 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
515 gtk_widget_show (hbox0);
516 gtk_box_pack_start(GTK_BOX(vbox1), hbox0, FALSE, TRUE, 0);
518 label = gtk_label_new(_("Displayed columns"));
519 gtk_widget_show(label);
520 gtk_box_pack_start(GTK_BOX(hbox0), label, FALSE, FALSE, 0);
521 button_dispitem = gtk_button_new_with_mnemonic("_Edit");
522 gtk_widget_show (button_dispitem);
523 gtk_box_pack_start (GTK_BOX (hbox0), button_dispitem, FALSE, FALSE, 0);
524 g_signal_connect (G_OBJECT (button_dispitem), "clicked",
525 G_CALLBACK (prefs_summary_column_open),
526 NULL);
528 PACK_SPACER(hbox0, hbox1, 4);
529 PACK_CHECK_BUTTON(hbox0, checkbtn_summary_col_lock, _("Lock column headers"));
531 hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
532 gtk_widget_show (hbox1);
533 gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
535 label = gtk_label_new (_("Displayed in From column"));
536 gtk_widget_show (label);
537 gtk_box_pack_start(GTK_BOX(hbox1), label, FALSE, FALSE, 0);
539 optmenu_summaryfromshow = gtkut_sc_combobox_create(NULL, FALSE);
540 menu = GTK_LIST_STORE(gtk_combo_box_get_model(
541 GTK_COMBO_BOX(optmenu_summaryfromshow)));
542 gtk_widget_show (optmenu_summaryfromshow);
544 COMBOBOX_ADD (menu, _("Name"), SHOW_NAME);
545 COMBOBOX_ADD (menu, _("Address"), SHOW_ADDR);
546 COMBOBOX_ADD (menu, _("Name and Address"), SHOW_BOTH);
548 gtk_box_pack_start(GTK_BOX(hbox1), optmenu_summaryfromshow, FALSE, FALSE, 0);
549 hbox2 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
550 gtk_widget_show (hbox2);
551 gtk_box_pack_start (GTK_BOX (vbox1), hbox2, FALSE, TRUE, 0);
553 label_datefmt = gtk_label_new (_("Date format"));
554 gtk_widget_show (label_datefmt);
555 gtk_box_pack_start (GTK_BOX (hbox2), label_datefmt, FALSE, FALSE, 0);
557 entry_datefmt = gtk_entry_new ();
558 gtk_widget_show (entry_datefmt);
559 gtk_box_pack_start (GTK_BOX (hbox2), entry_datefmt, FALSE, FALSE, 0);
561 button_datefmt = gtkut_stock_button("dialog-information", _("_Information"));
563 gtk_widget_show (button_datefmt);
564 gtk_box_pack_start (GTK_BOX (hbox2), button_datefmt, FALSE, FALSE, 0);
565 g_signal_connect (G_OBJECT (button_datefmt), "clicked",
566 G_CALLBACK (date_format_create), NULL);
568 label_fill = gtk_label_new(" ");
569 gtk_box_pack_start(GTK_BOX(hbox2), label_fill, TRUE, FALSE, 0);
571 CLAWS_SET_TIP(button_datefmt,
572 _("Date format help"));
574 hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
575 gtk_widget_show (hbox1);
576 gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, TRUE, 0);
578 button_edit_actions = gtk_button_new_with_label(_("Set message selection when entering a folder"));
579 gtk_widget_show (button_edit_actions);
580 gtk_box_pack_start (GTK_BOX (hbox1), button_edit_actions,
581 FALSE, TRUE, 0);
582 g_signal_connect (G_OBJECT (button_edit_actions), "clicked",
583 G_CALLBACK (prefs_summary_open_open),
584 NULL);
586 /* Open message on select policy */
587 vbox4 = gtkut_get_options_frame(vbox1, NULL, _("Open message when selected"));
589 PACK_CHECK_BUTTON(vbox4, checkbtn_always_show_msg,
590 _("Always"));
591 PACK_CHECK_BUTTON(vbox4, checkbtn_show_on_folder_open,
592 _("When opening a folder"));
593 PACK_CHECK_BUTTON(vbox4, checkbtn_show_on_search_results,
594 _("When displaying search results"));
595 PACK_CHECK_BUTTON(vbox4, checkbtn_show_on_prevnext,
596 _("When selecting next or previous message using shortcuts"));
597 PACK_CHECK_BUTTON(vbox4, checkbtn_show_on_deletemove,
598 _("When deleting or moving messages"));
599 PACK_CHECK_BUTTON(vbox4, checkbtn_show_on_directional,
600 _("When using directional keys"));
602 vbox3 = gtkut_get_options_frame(vbox1, NULL, _("Mark message as read"));
604 radio_mark_as_read_on_select = gtk_radio_button_new_with_label(NULL,
605 _("when selected, after"));
607 hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
608 gtk_box_pack_start (GTK_BOX (hbox1), radio_mark_as_read_on_select, FALSE, FALSE, 0);
610 spinbtn_mark_as_read_delay_adj = GTK_ADJUSTMENT(gtk_adjustment_new (0, 0, 60, 1, 10, 0));
611 spinbtn_mark_as_read_delay = gtk_spin_button_new
612 (GTK_ADJUSTMENT (spinbtn_mark_as_read_delay_adj), 1, 0);
613 gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_mark_as_read_delay,
614 FALSE, FALSE, 0);
615 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_mark_as_read_delay),
616 TRUE);
617 gtk_box_pack_start (GTK_BOX (hbox1), gtk_label_new
618 (_("seconds")), FALSE, FALSE, 0);
620 gtk_box_pack_start (GTK_BOX (vbox3), hbox1, FALSE, FALSE, 0);
622 radio_mark_as_read_on_new_win = gtk_radio_button_new_with_label_from_widget(
623 GTK_RADIO_BUTTON(radio_mark_as_read_on_select),
624 _("only when opened in a new window, or replied to"));
625 gtk_box_pack_start (GTK_BOX (vbox3), radio_mark_as_read_on_new_win,
626 FALSE, FALSE, 0);
627 gtk_widget_show_all(vbox3);
629 /* Next Unread Message Dialog */
630 hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
631 gtk_widget_show (hbox1);
632 gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
634 label = gtk_label_new (_("Show \"no unread (or new) message\" dialog"));
635 gtk_widget_show (label);
636 gtk_box_pack_start(GTK_BOX(hbox1), label, FALSE, FALSE, 0);
638 optmenu_nextunreadmsgdialog = gtkut_sc_combobox_create(NULL, FALSE);
639 menu = GTK_LIST_STORE(gtk_combo_box_get_model(
640 GTK_COMBO_BOX(optmenu_nextunreadmsgdialog)));
641 gtk_widget_show (optmenu_nextunreadmsgdialog);
643 COMBOBOX_ADD (menu, _("Always"), NEXTUNREADMSGDIALOG_ALWAYS);
644 COMBOBOX_ADD (menu, _("Assume 'Yes'"), NEXTUNREADMSGDIALOG_ASSUME_YES);
645 COMBOBOX_ADD (menu, _("Assume 'No'"), NEXTUNREADMSGDIALOG_ASSUME_NO);
647 gtk_box_pack_start(GTK_BOX(hbox1), optmenu_nextunreadmsgdialog, FALSE, FALSE, 0);
649 PACK_CHECK_BUTTON
650 (vbox1, checkbtn_useaddrbook,
651 _("Display sender using address book"));
653 PACK_CHECK_BUTTON
654 (vbox1, checkbtn_threadsubj,
655 _("Thread using subject in addition to standard headers"));
657 PACK_CHECK_BUTTON
658 (vbox1, checkbtn_immedexec,
659 _("Execute immediately when moving or deleting messages"));
660 CLAWS_SET_TIP(checkbtn_immedexec,
661 _("When unchecked moving, copying and deleting of messages"
662 " is deferred until you use 'Tools/Execute'"));
664 PACK_CHECK_BUTTON
665 (vbox1, checkbtn_ask_mark_all_read,
666 _("Confirm when marking all messages as read or unread"));
667 PACK_CHECK_BUTTON
668 (vbox1, checkbtn_ask_override_colorlabel,
669 _("Confirm when changing color labels"));
671 PACK_CHECK_BUTTON
672 (vbox1, checkbtn_show_tooltips,
673 _("Show tooltips"));
675 hbox2 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
676 gtk_widget_show (hbox2);
677 gtk_box_pack_start (GTK_BOX (vbox1), hbox2, FALSE, FALSE, 0);
679 vbox1 = gtk_box_new(GTK_ORIENTATION_VERTICAL, VSPACING);
680 gtk_widget_show (vbox1);
681 gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
682 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox1,
683 gtk_label_new(_("Defaults")));
685 vbox2 = gtkut_get_options_frame(vbox1, &frame_new_folders, _("New folders"));
687 hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
688 gtk_widget_show(hbox1);
689 gtk_box_pack_start(GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
691 label = gtk_label_new(_("Sort by"));
692 gtk_widget_show(label);
693 gtk_box_pack_start(GTK_BOX(hbox1), label, FALSE, FALSE, 0);
695 optmenu_sort_key = gtkut_sc_combobox_create(NULL, FALSE);
696 menu = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(optmenu_sort_key)));
697 gtk_widget_show(optmenu_sort_key);
699 COMBOBOX_ADD(menu, _("Number"), SORT_BY_NUMBER);
700 COMBOBOX_ADD(menu, _("Size"), SORT_BY_SIZE);
701 COMBOBOX_ADD(menu, _("Date"), SORT_BY_DATE);
702 COMBOBOX_ADD(menu, _("Thread date"), SORT_BY_THREAD_DATE);
703 COMBOBOX_ADD(menu, _("From"), SORT_BY_FROM);
704 COMBOBOX_ADD(menu, _("To"), SORT_BY_TO);
705 COMBOBOX_ADD(menu, _("Subject"), SORT_BY_SUBJECT);
706 COMBOBOX_ADD(menu, _("Color label"), SORT_BY_LABEL);
707 COMBOBOX_ADD(menu, _("Tag"), SORT_BY_TAGS);
708 COMBOBOX_ADD(menu, _("Mark"), SORT_BY_MARK);
709 COMBOBOX_ADD(menu, _("Status"), SORT_BY_STATUS);
710 COMBOBOX_ADD(menu, _("Attachment"), SORT_BY_MIME);
711 COMBOBOX_ADD(menu, _("Score"), SORT_BY_SCORE);
712 COMBOBOX_ADD(menu, _("Locked"), SORT_BY_LOCKED);
713 COMBOBOX_ADD(menu, _("Don't sort"), SORT_BY_NONE);
715 gtk_box_pack_start(GTK_BOX(hbox1), optmenu_sort_key, FALSE, FALSE, 0);
717 optmenu_sort_type = gtkut_sc_combobox_create(NULL, FALSE);
718 menu = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(optmenu_sort_type)));
719 gtk_widget_show(optmenu_sort_type);
721 COMBOBOX_ADD(menu, _("Ascending"), SORT_ASCENDING);
722 COMBOBOX_ADD(menu, _("Descending"), SORT_DESCENDING);
724 gtk_box_pack_start(GTK_BOX(hbox1), optmenu_sort_type, FALSE, FALSE, 0);
726 PACK_CHECK_BUTTON
727 (vbox2, checkbtn_folder_default_thread,
728 _("Thread view"));
729 PACK_CHECK_BUTTON
730 (vbox2, checkbtn_folder_default_thread_collapsed,
731 _("Collapse all threads"));
732 PACK_CHECK_BUTTON
733 (vbox2, checkbtn_folder_default_hide_read_threads,
734 _("Hide read threads"));
735 PACK_CHECK_BUTTON
736 (vbox2, checkbtn_folder_default_hide_read_msgs,
737 _("Hide read messages"));
738 PACK_CHECK_BUTTON
739 (vbox2, checkbtn_folder_default_hide_del_msgs,
740 _("Hide deleted messages"));
742 prefs_summaries->optmenu_folder_unread = optmenu_folder_unread;
743 prefs_summaries->spinbtn_ng_abbrev_len = spinbtn_ng_abbrev_len;
744 prefs_summaries->checkbtn_useaddrbook = checkbtn_useaddrbook;
745 prefs_summaries->checkbtn_show_tooltips = checkbtn_show_tooltips;
746 prefs_summaries->checkbtn_threadsubj = checkbtn_threadsubj;
747 prefs_summaries->entry_datefmt = entry_datefmt;
748 prefs_summaries->checkbtn_reopen_last_folder = checkbtn_reopen_last_folder;
749 prefs_summaries->checkbtn_startup_folder = checkbtn_startup_folder;
750 prefs_summaries->startup_folder_entry = startup_folder_entry;
752 prefs_summaries->checkbtn_always_show_msg = checkbtn_always_show_msg;
753 prefs_summaries->checkbtn_show_on_folder_open = checkbtn_show_on_folder_open;
754 prefs_summaries->checkbtn_show_on_search_results = checkbtn_show_on_search_results;
755 prefs_summaries->checkbtn_show_on_prevnext = checkbtn_show_on_prevnext;
756 prefs_summaries->checkbtn_show_on_deletemove = checkbtn_show_on_deletemove;
757 prefs_summaries->checkbtn_show_on_directional = checkbtn_show_on_directional;
759 prefs_summaries->checkbtn_mark_as_read_on_newwin = radio_mark_as_read_on_new_win;
760 prefs_summaries->spinbtn_mark_as_read_delay = spinbtn_mark_as_read_delay;
761 prefs_summaries->checkbtn_immedexec = checkbtn_immedexec;
762 prefs_summaries->checkbtn_ask_mark_all_read = checkbtn_ask_mark_all_read;
763 prefs_summaries->checkbtn_run_processingrules_mark_all_read = checkbtn_run_processingrules_mark_all_read;
764 prefs_summaries->checkbtn_ask_override_colorlabel = checkbtn_ask_override_colorlabel;
765 prefs_summaries->optmenu_sort_key = optmenu_sort_key;
766 prefs_summaries->optmenu_sort_type = optmenu_sort_type;
767 prefs_summaries->optmenu_nextunreadmsgdialog = optmenu_nextunreadmsgdialog;
768 prefs_summaries->optmenu_summaryfromshow = optmenu_summaryfromshow;
770 prefs_summaries->checkbtn_folder_default_thread = checkbtn_folder_default_thread;
771 prefs_summaries->checkbtn_folder_default_thread_collapsed = checkbtn_folder_default_thread_collapsed;
772 prefs_summaries->checkbtn_folder_default_hide_read_threads = checkbtn_folder_default_hide_read_threads;
773 prefs_summaries->checkbtn_folder_default_hide_read_msgs = checkbtn_folder_default_hide_read_msgs;
774 prefs_summaries->checkbtn_folder_default_hide_del_msgs = checkbtn_folder_default_hide_del_msgs;
775 prefs_summaries->checkbtn_summary_col_lock = checkbtn_summary_col_lock;
777 prefs_summaries->page.widget = vbox1;
778 g_signal_connect(G_OBJECT(checkbtn_always_show_msg), "toggled",
779 G_CALLBACK(always_show_msg_toggled), prefs_summaries);
781 g_signal_connect(G_OBJECT(radio_mark_as_read_on_select), "toggled",
782 G_CALLBACK(mark_as_read_toggled),
783 spinbtn_mark_as_read_delay);
785 prefs_summaries->window = GTK_WIDGET(window);
787 combobox_select_by_data(GTK_COMBO_BOX(optmenu_folder_unread),
788 prefs_common.display_folder_unread);
789 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_useaddrbook),
790 prefs_common.use_addr_book);
791 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_show_tooltips),
792 prefs_common.show_tooltips);
793 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_threadsubj),
794 prefs_common.thread_by_subject);
795 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_ng_abbrev_len),
796 prefs_common.ng_abbrev_len);
797 gtk_entry_set_text(GTK_ENTRY(entry_datefmt),
798 prefs_common.date_format?prefs_common.date_format:"");
799 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_reopen_last_folder),
800 prefs_common.goto_last_folder_on_startup);
801 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_startup_folder),
802 prefs_common.goto_folder_on_startup);
803 gtk_entry_set_text(GTK_ENTRY(startup_folder_entry),
804 prefs_common.startup_folder?prefs_common.startup_folder:"");
806 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_always_show_msg),
807 prefs_common.always_show_msg);
808 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_show_on_folder_open),
809 prefs_common.open_selected_on_folder_open);
810 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_show_on_search_results),
811 prefs_common.open_selected_on_search_results);
812 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_show_on_prevnext),
813 prefs_common.open_selected_on_prevnext);
814 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_show_on_deletemove),
815 prefs_common.open_selected_on_deletemove);
816 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_show_on_directional),
817 prefs_common.open_selected_on_directional);
819 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio_mark_as_read_on_new_win),
820 prefs_common.mark_as_read_on_new_window);
821 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_mark_as_read_delay),
822 prefs_common.mark_as_read_delay);
823 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_immedexec),
824 prefs_common.immediate_exec);
825 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_ask_mark_all_read),
826 prefs_common.ask_mark_all_read);
827 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_run_processingrules_mark_all_read),
828 prefs_common.run_processingrules_before_mark_all);
829 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_ask_override_colorlabel),
830 prefs_common.ask_override_colorlabel);
832 combobox_select_by_data(GTK_COMBO_BOX(optmenu_sort_key),
833 prefs_common.default_sort_key);
834 combobox_select_by_data(GTK_COMBO_BOX(optmenu_sort_type),
835 prefs_common.default_sort_type);
837 combobox_select_by_data(GTK_COMBO_BOX(optmenu_summaryfromshow),
838 prefs_common.summary_from_show);
840 combobox_select_by_data(GTK_COMBO_BOX(optmenu_nextunreadmsgdialog),
841 prefs_common.next_unread_msg_dialog);
843 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_folder_default_thread),
844 prefs_common.folder_default_thread);
845 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_folder_default_thread_collapsed),
846 prefs_common.folder_default_thread_collapsed);
847 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_folder_default_hide_read_threads),
848 prefs_common.folder_default_hide_read_threads);
849 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_folder_default_hide_read_msgs),
850 prefs_common.folder_default_hide_read_msgs);
851 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_folder_default_hide_del_msgs),
852 prefs_common.folder_default_hide_del_msgs);
853 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_summary_col_lock),
854 prefs_common.summary_col_lock);
856 gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 0);
858 prefs_summaries->page.widget = notebook;
861 static void prefs_summaries_save(PrefsPage *_page)
863 SummariesPage *page = (SummariesPage *) _page;
865 prefs_common.display_folder_unread = combobox_get_active_data(
866 GTK_COMBO_BOX(page->optmenu_folder_unread));
868 prefs_common.use_addr_book = gtk_toggle_button_get_active(
869 GTK_TOGGLE_BUTTON(page->checkbtn_useaddrbook));
870 prefs_common.show_tooltips = gtk_toggle_button_get_active(
871 GTK_TOGGLE_BUTTON(page->checkbtn_show_tooltips));
872 prefs_common.thread_by_subject = gtk_toggle_button_get_active(
873 GTK_TOGGLE_BUTTON(page->checkbtn_threadsubj));
874 prefs_common.ng_abbrev_len = gtk_spin_button_get_value_as_int(
875 GTK_SPIN_BUTTON(page->spinbtn_ng_abbrev_len));
877 g_free(prefs_common.date_format);
878 prefs_common.date_format = gtk_editable_get_chars(
879 GTK_EDITABLE(page->entry_datefmt), 0, -1);
881 prefs_common.goto_last_folder_on_startup = gtk_toggle_button_get_active(
882 GTK_TOGGLE_BUTTON(page->checkbtn_reopen_last_folder));
883 prefs_common.goto_folder_on_startup = gtk_toggle_button_get_active(
884 GTK_TOGGLE_BUTTON(page->checkbtn_startup_folder));
885 prefs_common.startup_folder = gtk_editable_get_chars(
886 GTK_EDITABLE(page->startup_folder_entry), 0, -1);
888 prefs_common.always_show_msg = gtk_toggle_button_get_active(
889 GTK_TOGGLE_BUTTON(page->checkbtn_always_show_msg));
890 prefs_common.open_selected_on_folder_open = gtk_toggle_button_get_active(
891 GTK_TOGGLE_BUTTON(page->checkbtn_show_on_folder_open));
892 prefs_common.open_selected_on_search_results = gtk_toggle_button_get_active(
893 GTK_TOGGLE_BUTTON(page->checkbtn_show_on_search_results));
894 prefs_common.open_selected_on_prevnext = gtk_toggle_button_get_active(
895 GTK_TOGGLE_BUTTON(page->checkbtn_show_on_prevnext));
896 prefs_common.open_selected_on_deletemove = gtk_toggle_button_get_active(
897 GTK_TOGGLE_BUTTON(page->checkbtn_show_on_deletemove));
898 prefs_common.open_selected_on_directional = gtk_toggle_button_get_active(
899 GTK_TOGGLE_BUTTON(page->checkbtn_show_on_directional));
901 prefs_common.mark_as_read_on_new_window = gtk_toggle_button_get_active(
902 GTK_TOGGLE_BUTTON(page->checkbtn_mark_as_read_on_newwin));
903 prefs_common.immediate_exec = gtk_toggle_button_get_active(
904 GTK_TOGGLE_BUTTON(page->checkbtn_immedexec));
905 prefs_common.ask_mark_all_read = gtk_toggle_button_get_active(
906 GTK_TOGGLE_BUTTON(page->checkbtn_ask_mark_all_read));
907 prefs_common.run_processingrules_before_mark_all = gtk_toggle_button_get_active(
908 GTK_TOGGLE_BUTTON(page->checkbtn_run_processingrules_mark_all_read));
909 prefs_common.ask_override_colorlabel = gtk_toggle_button_get_active(
910 GTK_TOGGLE_BUTTON(page->checkbtn_ask_override_colorlabel));
911 prefs_common.mark_as_read_delay = gtk_spin_button_get_value_as_int(
912 GTK_SPIN_BUTTON(page->spinbtn_mark_as_read_delay));
913 prefs_common.summary_col_lock = gtk_toggle_button_get_active(
914 GTK_TOGGLE_BUTTON(page->checkbtn_summary_col_lock));
916 prefs_common.default_sort_key = combobox_get_active_data(
917 GTK_COMBO_BOX(page->optmenu_sort_key));
918 prefs_common.default_sort_type = combobox_get_active_data(
919 GTK_COMBO_BOX(page->optmenu_sort_type));
920 prefs_common.summary_from_show = combobox_get_active_data(
921 GTK_COMBO_BOX(page->optmenu_summaryfromshow));
922 prefs_common.next_unread_msg_dialog = combobox_get_active_data(
923 GTK_COMBO_BOX(page->optmenu_nextunreadmsgdialog));
924 prefs_common.folder_default_thread = gtk_toggle_button_get_active(
925 GTK_TOGGLE_BUTTON(page->checkbtn_folder_default_thread));
926 prefs_common.folder_default_thread_collapsed = gtk_toggle_button_get_active(
927 GTK_TOGGLE_BUTTON(page->checkbtn_folder_default_thread_collapsed));
928 prefs_common.folder_default_hide_read_threads = gtk_toggle_button_get_active(
929 GTK_TOGGLE_BUTTON(page->checkbtn_folder_default_hide_read_threads));
930 prefs_common.folder_default_hide_read_msgs = gtk_toggle_button_get_active(
931 GTK_TOGGLE_BUTTON(page->checkbtn_folder_default_hide_read_msgs));
932 prefs_common.folder_default_hide_del_msgs = gtk_toggle_button_get_active(
933 GTK_TOGGLE_BUTTON(page->checkbtn_folder_default_hide_del_msgs));
934 prefs_common.folder_default_hide_del_msgs = gtk_toggle_button_get_active(
935 GTK_TOGGLE_BUTTON(page->checkbtn_folder_default_hide_del_msgs));
937 main_window_reflect_prefs_all();
940 static void prefs_summaries_destroy_widget(PrefsPage *_page)
944 SummariesPage *prefs_summaries;
946 void prefs_summaries_init(void)
948 SummariesPage *page;
949 static gchar *path[3];
951 path[0] = _("Display");
952 path[1] = _("Summaries");
953 path[2] = NULL;
955 page = g_new0(SummariesPage, 1);
956 page->page.path = path;
957 page->page.create_widget = prefs_summaries_create_widget;
958 page->page.destroy_widget = prefs_summaries_destroy_widget;
959 page->page.save_page = prefs_summaries_save;
960 page->page.weight = 140.0;
961 prefs_gtk_register_page((PrefsPage *) page);
962 prefs_summaries = page;
965 void prefs_summaries_done(void)
967 prefs_gtk_unregister_page((PrefsPage *) prefs_summaries);
968 g_free(prefs_summaries);
971 static void date_format_ok_btn_clicked(GtkButton *button, GtkWidget **widget)
973 GtkWidget *datefmt_sample = NULL;
974 gchar *text;
976 cm_return_if_fail(widget != NULL);
977 cm_return_if_fail(*widget != NULL);
978 cm_return_if_fail(prefs_summaries->entry_datefmt != NULL);
980 datefmt_sample = GTK_WIDGET(g_object_get_data
981 (G_OBJECT(*widget), "datefmt_sample"));
982 cm_return_if_fail(datefmt_sample != NULL);
984 text = gtk_editable_get_chars(GTK_EDITABLE(datefmt_sample), 0, -1);
985 g_free(prefs_common.date_format);
986 prefs_common.date_format = text;
987 gtk_entry_set_text(GTK_ENTRY(prefs_summaries->entry_datefmt), text);
989 gtk_widget_destroy(*widget);
990 *widget = NULL;
993 static void date_format_cancel_btn_clicked(GtkButton *button,
994 GtkWidget **widget)
996 cm_return_if_fail(widget != NULL);
997 cm_return_if_fail(*widget != NULL);
999 gtk_widget_destroy(*widget);
1000 *widget = NULL;
1003 static gboolean date_format_key_pressed(GtkWidget *keywidget, GdkEventKey *event,
1004 GtkWidget **widget)
1006 if (event && event->keyval == GDK_KEY_Escape)
1007 date_format_cancel_btn_clicked(NULL, widget);
1008 return FALSE;
1011 static gboolean date_format_on_delete(GtkWidget *dialogwidget,
1012 GdkEventAny *event, GtkWidget **widget)
1014 cm_return_val_if_fail(widget != NULL, FALSE);
1015 cm_return_val_if_fail(*widget != NULL, FALSE);
1017 *widget = NULL;
1018 return FALSE;
1021 static void date_format_entry_on_change(GtkEditable *editable,
1022 GtkLabel *example)
1024 time_t cur_time;
1025 struct tm *cal_time;
1026 gchar buffer[100];
1027 gchar *text;
1028 struct tm lt;
1030 cur_time = time(NULL);
1031 cal_time = localtime_r(&cur_time, &lt);
1032 buffer[0] = 0;
1033 text = gtk_editable_get_chars(editable, 0, -1);
1034 if (text)
1035 fast_strftime(buffer, sizeof buffer, text, cal_time);
1037 gtk_label_set_text(example, buffer);
1039 g_free(text);
1042 static void date_format_select_row(GtkTreeView *list_view,
1043 GtkTreePath *path,
1044 GtkTreeViewColumn *column,
1045 GtkWidget *date_format)
1047 gint cur_pos;
1048 gchar *format;
1049 const gchar *old_format;
1050 gchar *new_format;
1051 GtkWidget *datefmt_sample;
1052 GtkTreeIter iter;
1053 GtkTreeModel *model;
1055 cm_return_if_fail(date_format != NULL);
1057 /* only on double click */
1058 datefmt_sample = GTK_WIDGET(g_object_get_data(G_OBJECT(date_format),
1059 "datefmt_sample"));
1061 cm_return_if_fail(datefmt_sample != NULL);
1063 model = gtk_tree_view_get_model(list_view);
1065 /* get format from list */
1066 if (!gtk_tree_model_get_iter(model, &iter, path))
1067 return;
1069 gtk_tree_model_get(model, &iter, DATEFMT_FMT, &format, -1);
1071 cur_pos = gtk_editable_get_position(GTK_EDITABLE(datefmt_sample));
1072 old_format = gtk_entry_get_text(GTK_ENTRY(datefmt_sample));
1074 /* insert the format into the text entry */
1075 new_format = g_malloc(strlen(old_format) + 3);
1077 strncpy(new_format, old_format, cur_pos);
1078 new_format[cur_pos] = '\0';
1079 strcat(new_format, format);
1080 g_free(format);
1081 strcat(new_format, &old_format[cur_pos]);
1083 gtk_entry_set_text(GTK_ENTRY(datefmt_sample), new_format);
1084 gtk_editable_set_position(GTK_EDITABLE(datefmt_sample), cur_pos + 2);
1086 g_free(new_format);
1089 static void always_show_msg_toggled(GtkToggleButton *button,
1090 gpointer user_data)
1092 const SummariesPage *prefs_summaries = (SummariesPage *)user_data;
1093 gboolean state;
1095 cm_return_if_fail(prefs_summaries != NULL);
1097 state = gtk_toggle_button_get_active(button);
1099 gtk_widget_set_sensitive(prefs_summaries->checkbtn_show_on_folder_open, !state);
1100 gtk_widget_set_sensitive(prefs_summaries->checkbtn_show_on_search_results, !state);
1101 gtk_widget_set_sensitive(prefs_summaries->checkbtn_show_on_prevnext, !state);
1102 gtk_widget_set_sensitive(prefs_summaries->checkbtn_show_on_deletemove, !state);
1103 gtk_widget_set_sensitive(prefs_summaries->checkbtn_show_on_directional, !state);
1106 static void mark_as_read_toggled(GtkToggleButton *button, GtkWidget *spinbtn)
1108 gtk_widget_set_sensitive(spinbtn,
1109 gtk_toggle_button_get_active(button));