Document hidden pref 'warn_sending_many_recipients_num'
[claws.git] / src / prefs_receive.c
blob9e623a864ffd3ba6ca090a8c2825da359f28a160
1 /*
2 * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2005-2016 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 #include "prefs_common.h"
35 #include "prefs_gtk.h"
36 #include "inc.h"
38 #include "gtk/gtkutils.h"
39 #include "gtk/prefswindow.h"
40 #include "gtk/menu.h"
42 #include "manage_window.h"
43 #include "combobox.h"
45 typedef struct _ReceivePage
47 PrefsPage page;
49 GtkWidget *window;
51 GtkWidget *checkbtn_incext;
52 GtkWidget *entry_incext;
53 GtkWidget *checkbtn_autochk;
54 GtkWidget *spinbtn_autochk_sec;
55 GtkWidget *spinbtn_autochk_min;
56 GtkWidget *spinbtn_autochk_hour;
57 GtkWidget *checkbtn_chkonstartup;
58 GtkWidget *checkbtn_openinbox;
59 GtkWidget *checkbtn_scan_after_inc;
60 GtkWidget *checkbtn_newmail_auto;
61 GtkWidget *checkbtn_newmail_manu;
62 GtkWidget *entry_newmail_notify_cmd;
63 GtkWidget *hbox_newmail_notify;
64 GtkWidget *optmenu_recvdialog;
65 GtkWidget *checkbtn_no_recv_err_panel;
66 GtkWidget *checkbtn_close_recv_dialog;
67 } ReceivePage;
69 ReceivePage *prefs_receive;
71 static void prefs_common_recv_dialog_newmail_notify_toggle_cb(GtkWidget *w, gpointer data)
73 gboolean toggled;
75 toggled = gtk_toggle_button_get_active
76 (GTK_TOGGLE_BUTTON(prefs_receive->checkbtn_newmail_manu)) ||
77 gtk_toggle_button_get_active
78 (GTK_TOGGLE_BUTTON(prefs_receive->checkbtn_newmail_auto));
79 gtk_widget_set_sensitive(prefs_receive->hbox_newmail_notify, toggled);
82 static void prefs_receive_itv_spinbutton_value_changed_cb(GtkWidget *w, gpointer data)
84 ReceivePage *page = (ReceivePage *)data;
85 gint seconds = gtk_spin_button_get_value_as_int (
86 GTK_SPIN_BUTTON (page->spinbtn_autochk_sec));
87 gint minutes = gtk_spin_button_get_value_as_int (
88 GTK_SPIN_BUTTON (page->spinbtn_autochk_min));
89 gint hours = gtk_spin_button_get_value_as_int (
90 GTK_SPIN_BUTTON(page->spinbtn_autochk_hour));
91 if (seconds < 10 && minutes == 0 && hours == 0) {
92 gtk_spin_button_set_value (
93 GTK_SPIN_BUTTON (page->spinbtn_autochk_sec), 10.0);
97 static void prefs_receive_create_widget(PrefsPage *_page, GtkWindow *window,
98 gpointer data)
100 ReceivePage *prefs_receive = (ReceivePage *) _page;
102 GtkWidget *vbox1;
103 GtkWidget *vbox2;
104 GtkWidget *checkbtn_incext;
105 GtkWidget *hbox;
106 GtkWidget *label_incext;
107 GtkWidget *entry_incext;
109 GtkWidget *hbox_autochk;
110 GtkWidget *checkbtn_autochk;
111 GtkAdjustment *spinbtn_autochk_adj;
112 GtkWidget *spinbtn_autochk_sec;
113 GtkWidget *spinbtn_autochk_min;
114 GtkWidget *spinbtn_autochk_hour;
115 GtkWidget *label_autochk2;
116 GtkWidget *label_autochk1;
117 GtkWidget *label_autochk0;
118 GtkWidget *checkbtn_chkonstartup;
119 GtkWidget *checkbtn_openinbox;
120 GtkWidget *checkbtn_scan_after_inc;
122 GtkWidget *frame;
123 GtkWidget *vbox3;
124 GtkWidget *hbox_newmail_notify;
125 GtkWidget *checkbtn_newmail_auto;
126 GtkWidget *checkbtn_newmail_manu;
127 GtkWidget *entry_newmail_notify_cmd;
128 GtkWidget *label_newmail_notify_cmd;
130 GtkWidget *label_recvdialog;
131 GtkListStore *menu;
132 GtkTreeIter iter;
133 GtkWidget *optmenu_recvdialog;
134 GtkWidget *checkbtn_no_recv_err_panel;
135 GtkWidget *checkbtn_close_recv_dialog;
137 vbox1 = gtk_vbox_new (FALSE, VSPACING);
138 gtk_widget_show (vbox1);
139 gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
141 /* Use of external incorporation program */
142 vbox2 = gtkut_get_options_frame(vbox1, &frame, _("External incorporation program"));
144 PACK_CHECK_BUTTON (vbox2, checkbtn_incext,
145 _("Use external program for receiving mail"));
147 hbox = gtk_hbox_new (FALSE, 8);
148 gtk_widget_show (hbox);
149 gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
150 SET_TOGGLE_SENSITIVITY (checkbtn_incext, hbox);
152 label_incext = gtk_label_new (_("Command"));
153 gtk_widget_show (label_incext);
154 gtk_box_pack_start (GTK_BOX (hbox), label_incext, FALSE, FALSE, 0);
156 entry_incext = gtk_entry_new ();
157 gtk_widget_show (entry_incext);
158 gtk_box_pack_start (GTK_BOX (hbox), entry_incext, TRUE, TRUE, 0);
160 /* Auto-checking */
161 vbox2 = gtkut_get_options_frame(vbox1, &frame, _("Automatic checking"));
163 hbox_autochk = gtk_hbox_new (FALSE, 8);
164 gtk_widget_show (hbox_autochk);
165 gtk_box_pack_start (GTK_BOX (vbox2), hbox_autochk, FALSE, FALSE, 0);
167 PACK_CHECK_BUTTON (hbox_autochk, checkbtn_autochk,
168 _("Check for new mail every"));
170 spinbtn_autochk_adj = GTK_ADJUSTMENT(gtk_adjustment_new (5, 0, 99, 1, 10, 0));
171 spinbtn_autochk_hour = gtk_spin_button_new
172 (GTK_ADJUSTMENT (spinbtn_autochk_adj), 1, 0);
174 gtk_widget_show (spinbtn_autochk_hour);
175 gtk_box_pack_start (GTK_BOX (hbox_autochk), spinbtn_autochk_hour, FALSE, FALSE, 0);
177 label_autochk0 = gtk_label_new (_("hours"));
178 gtk_widget_show (label_autochk0);
179 gtk_box_pack_start (GTK_BOX (hbox_autochk), label_autochk0, FALSE, FALSE, 0);
181 spinbtn_autochk_adj = GTK_ADJUSTMENT(gtk_adjustment_new (5, 0, 59, 1, 10, 0));
182 spinbtn_autochk_min = gtk_spin_button_new
183 (GTK_ADJUSTMENT (spinbtn_autochk_adj), 1, 0);
184 gtk_widget_show (spinbtn_autochk_min);
185 gtk_box_pack_start (GTK_BOX (hbox_autochk), spinbtn_autochk_min, FALSE, FALSE, 0);
187 label_autochk1 = gtk_label_new (_("minutes"));
188 gtk_widget_show (label_autochk1);
189 gtk_box_pack_start (GTK_BOX (hbox_autochk), label_autochk1, FALSE, FALSE, 0);
191 spinbtn_autochk_adj = GTK_ADJUSTMENT(gtk_adjustment_new (5, 0, 59, 1, 10, 0));
192 spinbtn_autochk_sec = gtk_spin_button_new
193 (GTK_ADJUSTMENT (spinbtn_autochk_adj), 1, 0);
194 gtk_widget_show (spinbtn_autochk_sec);
195 gtk_box_pack_start (GTK_BOX (hbox_autochk), spinbtn_autochk_sec, FALSE, FALSE, 0);
196 gtk_widget_set_size_request (spinbtn_autochk_sec, 48, -1);
197 gtk_widget_set_size_request (spinbtn_autochk_min, 48, -1);
198 gtk_widget_set_size_request (spinbtn_autochk_hour, 48, -1);
199 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_autochk_sec), TRUE);
200 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_autochk_min), TRUE);
201 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_autochk_hour), TRUE);
203 label_autochk2 = gtk_label_new (_("seconds"));
204 gtk_widget_show (label_autochk2);
205 gtk_box_pack_start (GTK_BOX (hbox_autochk), label_autochk2, FALSE, FALSE, 0);
207 SET_TOGGLE_SENSITIVITY(checkbtn_autochk, spinbtn_autochk_sec);
208 SET_TOGGLE_SENSITIVITY(checkbtn_autochk, spinbtn_autochk_min);
209 SET_TOGGLE_SENSITIVITY(checkbtn_autochk, spinbtn_autochk_hour);
210 SET_TOGGLE_SENSITIVITY(checkbtn_autochk, label_autochk0);
211 SET_TOGGLE_SENSITIVITY(checkbtn_autochk, label_autochk1);
212 SET_TOGGLE_SENSITIVITY(checkbtn_autochk, label_autochk2);
214 PACK_CHECK_BUTTON (vbox2, checkbtn_chkonstartup,
215 _("Check for new mail on start-up"));
217 /* receive dialog */
218 vbox2 = gtkut_get_options_frame(vbox1, &frame, _("Dialogs"));
220 label_recvdialog = gtk_label_new (_("Show receive dialog"));
221 gtk_misc_set_alignment(GTK_MISC(label_recvdialog), 0, 0.5);
222 gtk_widget_show (label_recvdialog);
224 optmenu_recvdialog = gtkut_sc_combobox_create(NULL, FALSE);
225 gtk_widget_show (optmenu_recvdialog);
227 menu = GTK_LIST_STORE(gtk_combo_box_get_model(
228 GTK_COMBO_BOX(optmenu_recvdialog)));
229 COMBOBOX_ADD (menu, _("Always"), RECV_DIALOG_ALWAYS);
230 COMBOBOX_ADD (menu, _("Only on manual receiving"), RECV_DIALOG_MANUAL);
231 COMBOBOX_ADD (menu, _("Never"), RECV_DIALOG_NEVER);
233 hbox = gtk_hbox_new(FALSE, 20);
234 gtk_widget_show(hbox);
235 gtk_box_pack_start(GTK_BOX(hbox), label_recvdialog, FALSE, FALSE, 0);
236 gtk_box_pack_start(GTK_BOX(hbox), optmenu_recvdialog, FALSE, FALSE, 0);
238 gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, FALSE, 0);
240 PACK_CHECK_BUTTON (vbox2, checkbtn_close_recv_dialog,
241 _("Close receive dialog when finished"));
243 PACK_CHECK_BUTTON (vbox2, checkbtn_no_recv_err_panel,
244 _("Don't popup error dialog on receive error"));
246 vbox2 = gtkut_get_options_frame(vbox1, &frame,
247 _("After receiving new mail"));
249 PACK_CHECK_BUTTON (vbox2, checkbtn_openinbox, _("Go to Inbox"));
250 PACK_CHECK_BUTTON (vbox2, checkbtn_scan_after_inc,
251 _("Update all local folders"));
253 vbox3 = gtkut_get_options_frame(vbox2, &frame, _("Run command"));
255 hbox = gtk_hbox_new (TRUE, 8);
256 gtk_widget_show (hbox);
257 PACK_CHECK_BUTTON (hbox, checkbtn_newmail_auto,
258 _("after automatic check"));
259 PACK_CHECK_BUTTON (hbox, checkbtn_newmail_manu,
260 _("after manual check"));
261 gtk_box_pack_start (GTK_BOX(vbox3), hbox, FALSE, FALSE, 0);
263 hbox_newmail_notify = gtk_hbox_new (FALSE, 8);
264 gtk_widget_show (hbox_newmail_notify);
265 gtk_box_pack_start (GTK_BOX (vbox3), hbox_newmail_notify, FALSE,
266 FALSE, 0);
268 label_newmail_notify_cmd = gtk_label_new (_("Command to execute:\n"
269 "(use %d as number of new "
270 "mails)"));
271 gtk_label_set_justify(GTK_LABEL(label_newmail_notify_cmd),
272 GTK_JUSTIFY_RIGHT);
273 gtk_widget_show (label_newmail_notify_cmd);
274 gtk_box_pack_start (GTK_BOX (hbox_newmail_notify),
275 label_newmail_notify_cmd, FALSE, FALSE, 0);
277 entry_newmail_notify_cmd = gtk_entry_new ();
278 gtk_widget_show (entry_newmail_notify_cmd);
279 gtk_box_pack_start (GTK_BOX (hbox_newmail_notify),
280 entry_newmail_notify_cmd, TRUE, TRUE, 0);
282 gtk_widget_set_sensitive(hbox_newmail_notify,
283 prefs_common.newmail_notify_auto ||
284 prefs_common.newmail_notify_manu);
286 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_newmail_auto),
287 prefs_common.newmail_notify_auto);
288 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_newmail_manu),
289 prefs_common.newmail_notify_manu);
290 gtk_entry_set_text(GTK_ENTRY(entry_newmail_notify_cmd),
291 prefs_common.newmail_notify_cmd);
292 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_autochk),
293 prefs_common.autochk_newmail);
294 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_incext),
295 prefs_common.use_extinc);
296 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_no_recv_err_panel),
297 prefs_common.no_recv_err_panel);
298 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_close_recv_dialog),
299 prefs_common.close_recv_dialog);
300 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_chkonstartup),
301 prefs_common.chk_on_startup);
302 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_openinbox),
303 prefs_common.open_inbox_on_inc);
304 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_scan_after_inc),
305 prefs_common.scan_all_after_inc);
307 gtk_entry_set_text(GTK_ENTRY(entry_incext),
308 prefs_common.extinc_cmd);
309 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_autochk_hour),
310 prefs_common.autochk_itv / 3600);
311 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_autochk_min),
312 (prefs_common.autochk_itv % 3600) / 60);
313 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_autochk_sec),
314 (prefs_common.autochk_itv % 3600) % 60);
315 combobox_select_by_data(GTK_COMBO_BOX(optmenu_recvdialog),
316 prefs_common.recv_dialog_mode);
318 prefs_receive->window = GTK_WIDGET(window);
319 prefs_receive->checkbtn_incext = checkbtn_incext;
320 prefs_receive->entry_incext = entry_incext;
321 prefs_receive->checkbtn_autochk = checkbtn_autochk;
322 prefs_receive->spinbtn_autochk_sec = spinbtn_autochk_sec;
323 prefs_receive->spinbtn_autochk_min = spinbtn_autochk_min;
324 prefs_receive->spinbtn_autochk_hour = spinbtn_autochk_hour;
325 prefs_receive->checkbtn_chkonstartup = checkbtn_chkonstartup;
326 prefs_receive->checkbtn_openinbox = checkbtn_openinbox;
327 prefs_receive->checkbtn_scan_after_inc = checkbtn_scan_after_inc;
328 prefs_receive->checkbtn_newmail_auto = checkbtn_newmail_auto;
329 prefs_receive->checkbtn_newmail_manu = checkbtn_newmail_manu;
330 prefs_receive->entry_newmail_notify_cmd = entry_newmail_notify_cmd;
331 prefs_receive->hbox_newmail_notify = hbox_newmail_notify;
333 prefs_receive->optmenu_recvdialog = optmenu_recvdialog;
334 prefs_receive->checkbtn_no_recv_err_panel = checkbtn_no_recv_err_panel;
335 prefs_receive->checkbtn_close_recv_dialog = checkbtn_close_recv_dialog;
336 prefs_receive->page.widget = vbox1;
338 g_signal_connect(G_OBJECT(checkbtn_newmail_auto), "toggled",
339 G_CALLBACK(prefs_common_recv_dialog_newmail_notify_toggle_cb),
340 NULL);
341 g_signal_connect(G_OBJECT(checkbtn_newmail_manu), "toggled",
342 G_CALLBACK(prefs_common_recv_dialog_newmail_notify_toggle_cb),
343 NULL);
344 g_signal_connect(G_OBJECT(spinbtn_autochk_hour), "value-changed",
345 G_CALLBACK(prefs_receive_itv_spinbutton_value_changed_cb),
346 (gpointer) prefs_receive);
347 g_signal_connect(G_OBJECT(spinbtn_autochk_min), "value-changed",
348 G_CALLBACK(prefs_receive_itv_spinbutton_value_changed_cb),
349 (gpointer) prefs_receive);
350 g_signal_connect(G_OBJECT(spinbtn_autochk_sec), "value-changed",
351 G_CALLBACK(prefs_receive_itv_spinbutton_value_changed_cb),
352 (gpointer) prefs_receive);
355 static void prefs_receive_save(PrefsPage *_page)
357 ReceivePage *page = (ReceivePage *) _page;
358 gchar *tmp;
360 prefs_common.use_extinc = gtk_toggle_button_get_active(
361 GTK_TOGGLE_BUTTON(page->checkbtn_incext));
362 prefs_common.no_recv_err_panel = gtk_toggle_button_get_active(
363 GTK_TOGGLE_BUTTON(page->checkbtn_no_recv_err_panel));
364 prefs_common.close_recv_dialog = gtk_toggle_button_get_active(
365 GTK_TOGGLE_BUTTON(page->checkbtn_close_recv_dialog));
366 prefs_common.chk_on_startup = gtk_toggle_button_get_active(
367 GTK_TOGGLE_BUTTON(page->checkbtn_chkonstartup));
368 prefs_common.open_inbox_on_inc = gtk_toggle_button_get_active(
369 GTK_TOGGLE_BUTTON(page->checkbtn_openinbox));
370 prefs_common.scan_all_after_inc = gtk_toggle_button_get_active(
371 GTK_TOGGLE_BUTTON(page->checkbtn_scan_after_inc));
373 prefs_common.newmail_notify_auto = gtk_toggle_button_get_active(
374 GTK_TOGGLE_BUTTON(page->checkbtn_newmail_auto));
375 prefs_common.newmail_notify_manu = gtk_toggle_button_get_active(
376 GTK_TOGGLE_BUTTON(page->checkbtn_newmail_manu));
377 prefs_common.autochk_newmail = gtk_toggle_button_get_active(
378 GTK_TOGGLE_BUTTON(page->checkbtn_autochk));
379 prefs_common.autochk_itv =
380 (3600 * gtk_spin_button_get_value_as_int(
381 GTK_SPIN_BUTTON(page->spinbtn_autochk_hour)))
382 + (60 * gtk_spin_button_get_value_as_int(
383 GTK_SPIN_BUTTON(page->spinbtn_autochk_min)))
384 + gtk_spin_button_get_value_as_int(
385 GTK_SPIN_BUTTON(page->spinbtn_autochk_sec));
387 tmp = gtk_editable_get_chars(GTK_EDITABLE(page->entry_incext), 0, -1);
388 g_free(prefs_common.extinc_cmd);
389 prefs_common.extinc_cmd = tmp;
391 tmp = gtk_editable_get_chars(GTK_EDITABLE(page->entry_newmail_notify_cmd), 0, -1);
392 g_free(prefs_common.newmail_notify_cmd);
393 prefs_common.newmail_notify_cmd = tmp;
394 prefs_common.recv_dialog_mode =
395 combobox_get_active_data(GTK_COMBO_BOX(page->optmenu_recvdialog));
397 inc_autocheck_timer_remove();
398 inc_autocheck_timer_set();
402 static void prefs_receive_destroy_widget(PrefsPage *_page)
406 void prefs_receive_init(void)
408 ReceivePage *page;
409 static gchar *path[3];
411 path[0] = _("Mail Handling");
412 path[1] = _("Receiving");
413 path[2] = NULL;
415 page = g_new0(ReceivePage, 1);
416 page->page.path = path;
417 page->page.create_widget = prefs_receive_create_widget;
418 page->page.destroy_widget = prefs_receive_destroy_widget;
419 page->page.save_page = prefs_receive_save;
420 page->page.weight = 200.0;
421 prefs_gtk_register_page((PrefsPage *) page);
422 prefs_receive = page;
425 void prefs_receive_done(void)
427 prefs_gtk_unregister_page((PrefsPage *) prefs_receive);
428 g_free(prefs_receive);