Sync Spanish manual
[claws.git] / src / prefs_compose_writing.c
blobecc118e084f32f7900b948d7e53314c5feb4286f
1 /*
2 * Claws Mail -- a GTK based, lightweight, and fast e-mail client
3 * Copyright (C) 2005-2021 the Claws Mail Team and Colin Leroy <colin@colino.net>
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"
37 #include "gtk/gtkutils.h"
38 #include "gtk/prefswindow.h"
39 #include "gtk/menu.h"
41 #include "manage_window.h"
43 #include "quote_fmt.h"
44 #include "prefs_template.h"
45 #include "alertpanel.h"
46 #include "combobox.h"
48 typedef struct _WritingPage
50 PrefsPage page;
52 GtkWidget *window;
54 GtkWidget *checkbtn_autoextedit;
55 GtkWidget *checkbtn_reply_account_autosel;
56 GtkWidget *checkbtn_forward_account_autosel;
57 GtkWidget *checkbtn_reedit_account_autosel;
58 GtkWidget *spinbtn_undolevel;
59 GtkWidget *checkbtn_reply_with_quote;
60 GtkWidget *checkbtn_default_reply_list;
61 GtkWidget *checkbtn_forward_as_attachment;
62 GtkWidget *checkbtn_redirect_keep_from;
63 GtkWidget *checkbtn_autosave;
64 GtkWidget *spinbtn_autosave_length;
65 GtkWidget *checkbtn_autosave_encrypted;
66 GtkWidget *checkbtn_warn_large_insert;
67 GtkWidget *spinbtn_warn_large_insert_size;
68 GtkWidget *optmenu_dnd_insert_or_attach;
69 } WritingPage;
71 static void prefs_compose_writing_create_widget(PrefsPage *_page, GtkWindow *window,
72 gpointer data)
74 WritingPage *prefs_writing = (WritingPage *) _page;
76 GtkWidget *vbox1;
77 GtkWidget *vbox2;
78 GtkWidget *checkbtn_autoextedit;
79 GtkWidget *frame;
80 GtkWidget *hbox_autosel;
81 GtkWidget *checkbtn_reply_account_autosel;
82 GtkWidget *checkbtn_forward_account_autosel;
83 GtkWidget *checkbtn_reedit_account_autosel;
85 GtkWidget *hbox_undolevel;
86 GtkWidget *label_undolevel;
87 GtkAdjustment *spinbtn_undolevel_adj;
88 GtkWidget *spinbtn_undolevel;
90 GtkWidget *hbox_warn_large_insert;
91 GtkWidget *checkbtn_warn_large_insert;
92 GtkAdjustment *spinbtn_warn_large_insert_adj;
93 GtkWidget *spinbtn_warn_large_insert_size;
94 GtkWidget *label_warn_large_insert_size;
96 GtkWidget *checkbtn_reply_with_quote;
97 GtkWidget *checkbtn_default_reply_list;
99 GtkWidget *checkbtn_forward_as_attachment;
100 GtkWidget *checkbtn_redirect_keep_from;
102 GtkWidget *hbox_autosave;
103 GtkWidget *checkbtn_autosave;
104 GtkAdjustment *spinbtn_autosave_adj;
105 GtkWidget *spinbtn_autosave_length;
106 GtkWidget *label_autosave_length;
108 GtkWidget *hbox_autosave_encrypted;
109 GtkWidget *checkbtn_autosave_encrypted;
111 GtkWidget *hbox_dnd_insert_or_attach;
112 GtkWidget *label_dnd_insert_or_attach;
113 GtkWidget *optmenu_dnd_insert_or_attach;
114 GtkListStore *menu;
115 GtkTreeIter iter;
116 gchar *text;
118 vbox1 = gtk_box_new(GTK_ORIENTATION_VERTICAL, VSPACING);
119 gtk_widget_show (vbox1);
120 gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
122 /* Account autoselection */
123 PACK_FRAME(vbox1, frame, _("Automatic account selection"));
125 hbox_autosel = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VSPACING_NARROW);
126 gtk_widget_show (hbox_autosel);
127 gtk_container_add (GTK_CONTAINER (frame), hbox_autosel);
128 gtk_container_set_border_width (GTK_CONTAINER (hbox_autosel), 8);
130 PACK_CHECK_BUTTON (hbox_autosel, checkbtn_reply_account_autosel,
131 _("when replying"));
132 PACK_CHECK_BUTTON (hbox_autosel, checkbtn_forward_account_autosel,
133 _("when forwarding"));
134 PACK_CHECK_BUTTON (hbox_autosel, checkbtn_reedit_account_autosel,
135 _("when re-editing"));
137 /* Editing */
138 vbox2 = gtkut_get_options_frame(vbox1, &frame, _("Editing"));
140 /* Editing: automatically start the text editor */
141 PACK_CHECK_BUTTON (vbox2, checkbtn_autoextedit,
142 _("Automatically launch the external editor"));
144 /* Editing: automatically save draft */
145 hbox_autosave = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
146 gtk_widget_show (hbox_autosave);
147 gtk_box_pack_start (GTK_BOX (vbox2), hbox_autosave, FALSE, FALSE, 0);
149 PACK_CHECK_BUTTON (hbox_autosave, checkbtn_autosave,
150 _("Automatically save message to Drafts folder every"));
152 spinbtn_autosave_adj = GTK_ADJUSTMENT(gtk_adjustment_new (50, 0, 1000, 1, 10, 0));
153 spinbtn_autosave_length = gtk_spin_button_new
154 (GTK_ADJUSTMENT (spinbtn_autosave_adj), 1, 0);
155 gtk_widget_show (spinbtn_autosave_length);
156 gtk_box_pack_start (GTK_BOX (hbox_autosave), spinbtn_autosave_length, FALSE, FALSE, 0);
157 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_autosave_length), TRUE);
159 label_autosave_length = gtk_label_new(_("characters"));
160 gtk_widget_show (label_autosave_length);
161 gtk_box_pack_start (GTK_BOX (hbox_autosave), label_autosave_length, FALSE, FALSE, 0);
163 /* Editing: automatically save draft when encrypted */
164 hbox_autosave_encrypted = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
165 gtk_box_pack_start(GTK_BOX(hbox_autosave_encrypted), gtk_label_new(" "), FALSE, FALSE, 0);
166 gtk_widget_show_all (hbox_autosave_encrypted);
167 gtk_box_pack_start (GTK_BOX (vbox2), hbox_autosave_encrypted, FALSE, FALSE, 0);
169 PACK_CHECK_BUTTON (hbox_autosave_encrypted, checkbtn_autosave_encrypted,
170 _("Even if message is to be encrypted"));
172 /* Editing: undo level */
173 hbox_undolevel = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
174 gtk_widget_show (hbox_undolevel);
175 gtk_box_pack_start (GTK_BOX (vbox2), hbox_undolevel, FALSE, FALSE, 0);
177 label_undolevel = gtk_label_new (_("Undo level"));
178 gtk_widget_show (label_undolevel);
179 gtk_box_pack_start (GTK_BOX (hbox_undolevel), label_undolevel, FALSE, FALSE, 0);
181 spinbtn_undolevel_adj = GTK_ADJUSTMENT(gtk_adjustment_new (50, 0, 100, 1, 10, 0));
182 spinbtn_undolevel = gtk_spin_button_new
183 (GTK_ADJUSTMENT (spinbtn_undolevel_adj), 1, 0);
184 gtk_widget_show (spinbtn_undolevel);
185 gtk_box_pack_start (GTK_BOX (hbox_undolevel), spinbtn_undolevel, FALSE, FALSE, 0);
186 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_undolevel), TRUE);
188 /* Editing: warn when inserting large files in message body */
189 hbox_warn_large_insert = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
190 gtk_widget_show (hbox_warn_large_insert);
191 gtk_box_pack_start (GTK_BOX (vbox2), hbox_warn_large_insert, FALSE, FALSE, 0);
193 PACK_CHECK_BUTTON (hbox_warn_large_insert, checkbtn_warn_large_insert,
194 _("Warn when inserting a file into the message body which is larger than"));
196 spinbtn_warn_large_insert_adj = GTK_ADJUSTMENT(gtk_adjustment_new (50, 0, 10000, 1, 10, 0));
197 spinbtn_warn_large_insert_size = gtk_spin_button_new
198 (GTK_ADJUSTMENT (spinbtn_warn_large_insert_adj), 1, 0);
199 gtk_widget_show (spinbtn_warn_large_insert_size);
200 gtk_box_pack_start (GTK_BOX (hbox_warn_large_insert),
201 spinbtn_warn_large_insert_size, FALSE, FALSE, 0);
202 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_warn_large_insert_size),
203 TRUE);
205 label_warn_large_insert_size = gtk_label_new(_("KiB"));
206 gtk_widget_show (label_warn_large_insert_size);
207 gtk_box_pack_start (GTK_BOX (hbox_warn_large_insert),
208 label_warn_large_insert_size, FALSE, FALSE, 0);
210 /* Replying */
211 vbox2 = gtkut_get_options_frame(vbox1, &frame, _("Replying"));
213 PACK_CHECK_BUTTON (vbox2, checkbtn_reply_with_quote,
214 _("Reply will quote by default"));
216 PACK_CHECK_BUTTON (vbox2, checkbtn_default_reply_list,
217 _("Reply button invokes mailing list reply"));
219 vbox2 = gtkut_get_options_frame(vbox1, &frame, _("Forwarding"));
221 PACK_CHECK_BUTTON (vbox2, checkbtn_forward_as_attachment,
222 _("Forward as attachment"));
224 text = g_strdup_printf(_("Keep the original '%s' header when redirecting"),
225 prefs_common_translated_header_name("From"));
226 PACK_CHECK_BUTTON (vbox2, checkbtn_redirect_keep_from, text);
227 g_free(text);
229 /* dnd insert or attach */
230 label_dnd_insert_or_attach = gtk_label_new (_("When dropping files into the Compose window"));
231 gtk_label_set_xalign(GTK_LABEL(label_dnd_insert_or_attach), 0.0);
232 gtk_widget_show (label_dnd_insert_or_attach);
234 optmenu_dnd_insert_or_attach = gtkut_sc_combobox_create(NULL, FALSE);
235 gtk_widget_show (optmenu_dnd_insert_or_attach);
237 menu = GTK_LIST_STORE(gtk_combo_box_get_model(
238 GTK_COMBO_BOX(optmenu_dnd_insert_or_attach)));
239 COMBOBOX_ADD (menu, _("Ask"), COMPOSE_DND_ASK);
240 COMBOBOX_ADD (menu, _("Insert"), COMPOSE_DND_INSERT);
241 COMBOBOX_ADD (menu, _("Attach"), COMPOSE_DND_ATTACH);
243 hbox_dnd_insert_or_attach = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 20);
244 gtk_widget_show(hbox_dnd_insert_or_attach);
245 gtk_box_pack_start(GTK_BOX(vbox1), hbox_dnd_insert_or_attach, FALSE, FALSE, 0);
246 gtk_box_pack_start(GTK_BOX(hbox_dnd_insert_or_attach),
247 label_dnd_insert_or_attach, FALSE, FALSE, 0);
248 gtk_box_pack_start(GTK_BOX(hbox_dnd_insert_or_attach),
249 optmenu_dnd_insert_or_attach, FALSE, FALSE, 0);
251 SET_TOGGLE_SENSITIVITY (checkbtn_autosave, spinbtn_autosave_length);
252 SET_TOGGLE_SENSITIVITY (checkbtn_autosave, label_autosave_length);
253 SET_TOGGLE_SENSITIVITY (checkbtn_autosave, checkbtn_autosave_encrypted);
255 SET_TOGGLE_SENSITIVITY (checkbtn_warn_large_insert, spinbtn_warn_large_insert_size);
256 SET_TOGGLE_SENSITIVITY (checkbtn_warn_large_insert, label_warn_large_insert_size);
258 prefs_writing->checkbtn_autoextedit = checkbtn_autoextedit;
259 prefs_writing->checkbtn_reply_account_autosel = checkbtn_reply_account_autosel;
260 prefs_writing->checkbtn_forward_account_autosel = checkbtn_forward_account_autosel;
261 prefs_writing->checkbtn_reedit_account_autosel = checkbtn_reedit_account_autosel;
263 prefs_writing->spinbtn_undolevel = spinbtn_undolevel;
265 prefs_writing->checkbtn_autosave = checkbtn_autosave;
266 prefs_writing->spinbtn_autosave_length = spinbtn_autosave_length;
268 prefs_writing->checkbtn_autosave_encrypted = checkbtn_autosave_encrypted;
270 prefs_writing->checkbtn_warn_large_insert = checkbtn_warn_large_insert;
271 prefs_writing->spinbtn_warn_large_insert_size = spinbtn_warn_large_insert_size;
273 prefs_writing->checkbtn_forward_as_attachment =
274 checkbtn_forward_as_attachment;
275 prefs_writing->checkbtn_redirect_keep_from = checkbtn_redirect_keep_from;
276 prefs_writing->checkbtn_reply_with_quote = checkbtn_reply_with_quote;
277 prefs_writing->checkbtn_default_reply_list = checkbtn_default_reply_list;
279 prefs_writing->optmenu_dnd_insert_or_attach = optmenu_dnd_insert_or_attach;
281 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prefs_writing->checkbtn_autoextedit),
282 prefs_common.auto_exteditor);
283 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prefs_writing->checkbtn_forward_as_attachment),
284 prefs_common.forward_as_attachment);
285 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prefs_writing->checkbtn_redirect_keep_from),
286 prefs_common.redirect_keep_from);
287 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prefs_writing->checkbtn_autosave),
288 prefs_common.autosave);
289 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prefs_writing->checkbtn_autosave_encrypted),
290 prefs_common.autosave_encrypted);
291 gtk_spin_button_set_value(GTK_SPIN_BUTTON(prefs_writing->spinbtn_autosave_length),
292 prefs_common.autosave_length);
293 gtk_spin_button_set_value(GTK_SPIN_BUTTON(prefs_writing->spinbtn_undolevel),
294 prefs_common.undolevels);
295 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prefs_writing->checkbtn_warn_large_insert),
296 prefs_common.warn_large_insert);
297 gtk_spin_button_set_value(GTK_SPIN_BUTTON(prefs_writing->spinbtn_warn_large_insert_size),
298 prefs_common.warn_large_insert_size);
299 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prefs_writing->checkbtn_reply_account_autosel),
300 prefs_common.reply_account_autosel);
301 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prefs_writing->checkbtn_forward_account_autosel),
302 prefs_common.forward_account_autosel);
303 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prefs_writing->checkbtn_reedit_account_autosel),
304 prefs_common.reedit_account_autosel);
305 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prefs_writing->checkbtn_reply_with_quote),
306 prefs_common.reply_with_quote);
307 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prefs_writing->checkbtn_default_reply_list),
308 prefs_common.default_reply_list);
309 combobox_select_by_data(GTK_COMBO_BOX(optmenu_dnd_insert_or_attach),
310 prefs_common.compose_dnd_mode);
312 prefs_writing->page.widget = vbox1;
315 static void prefs_compose_writing_save(PrefsPage *_page)
317 WritingPage *page = (WritingPage *) _page;
319 prefs_common.auto_exteditor =
320 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_autoextedit));
321 prefs_common.forward_as_attachment =
322 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_forward_as_attachment));
323 prefs_common.redirect_keep_from =
324 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_redirect_keep_from));
325 prefs_common.autosave =
326 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_autosave));
327 prefs_common.autosave_encrypted =
328 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_autosave_encrypted));
329 prefs_common.autosave_length =
330 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(page->spinbtn_autosave_length));
331 prefs_common.undolevels =
332 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(page->spinbtn_undolevel));
333 prefs_common.warn_large_insert =
334 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_warn_large_insert));
335 prefs_common.warn_large_insert_size =
336 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(page->spinbtn_warn_large_insert_size));
338 prefs_common.reply_account_autosel =
339 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_reply_account_autosel));
340 prefs_common.forward_account_autosel =
341 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_forward_account_autosel));
342 prefs_common.reedit_account_autosel =
343 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_reedit_account_autosel));
344 prefs_common.reply_with_quote = gtk_toggle_button_get_active(
345 GTK_TOGGLE_BUTTON(page->checkbtn_reply_with_quote));
346 prefs_common.default_reply_list =
347 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_default_reply_list));
349 prefs_common.compose_dnd_mode = combobox_get_active_data(
350 GTK_COMBO_BOX(page->optmenu_dnd_insert_or_attach));
353 static void prefs_compose_writing_destroy_widget(PrefsPage *_page)
357 WritingPage *prefs_writing;
359 void prefs_compose_writing_init(void)
361 WritingPage *page;
362 static gchar *path[3];
364 path[0] = _("Compose");
365 path[1] = _("Writing");
366 path[2] = NULL;
368 page = g_new0(WritingPage, 1);
369 page->page.path = path;
370 page->page.create_widget = prefs_compose_writing_create_widget;
371 page->page.destroy_widget = prefs_compose_writing_destroy_widget;
372 page->page.save_page = prefs_compose_writing_save;
373 page->page.weight = 190.0;
374 prefs_gtk_register_page((PrefsPage *) page);
375 prefs_writing = page;
378 void prefs_compose_writing_done(void)
380 prefs_gtk_unregister_page((PrefsPage *) prefs_writing);
381 g_free(prefs_writing);