2 * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2005-2020 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/>.
21 #include "claws-features.h"
30 #include <glib/gi18n.h>
32 #include <gdk/gdkkeysyms.h>
34 #include "prefs_common.h"
35 #include "prefs_gtk.h"
36 #include "prefs_display_header.h"
38 #include "gtk/gtkutils.h"
39 #include "gtk/prefswindow.h"
41 #include "manage_window.h"
43 typedef struct _MessagePage
49 GtkWidget
*checkbtn_disphdrpane
;
50 GtkWidget
*checkbtn_disphdr
;
51 GtkWidget
*checkbtn_dispxface
;
52 GtkWidget
*checkbtn_savexface
;
54 GtkWidget
*checkbtn_html
;
55 GtkWidget
*checkbtn_html_plugin
;
56 GtkWidget
*checkbtn_promote_html_part
;
57 GtkWidget
*spinbtn_linespc
;
59 GtkWidget
*checkbtn_smoothscroll
;
60 GtkWidget
*spinbtn_scrollstep
;
61 GtkWidget
*checkbtn_halfpage
;
62 GtkWidget
*checkbtn_hide_quoted
;
64 GtkWidget
*checkbtn_attach_desc
;
65 GtkWidget
*entry_quote_chars
;
68 static void disphdr_pane_toggled(GtkToggleButton
*toggle_btn
, GtkWidget
*widget
)
72 is_active
= gtk_toggle_button_get_active(toggle_btn
);
74 gtk_widget_set_sensitive(widget
, !is_active
);
77 static void prefs_message_create_widget(PrefsPage
*_page
, GtkWindow
*window
,
80 MessagePage
*prefs_message
= (MessagePage
*) _page
;
85 GtkWidget
*checkbtn_disphdrpane
;
86 GtkWidget
*checkbtn_disphdr
;
87 GtkWidget
*checkbtn_dispxface
;
88 GtkWidget
*checkbtn_savexface
;
90 GtkWidget
*button_edit_disphdr
;
91 GtkWidget
*checkbtn_html
;
92 GtkWidget
*checkbtn_html_plugin
;
93 GtkWidget
*checkbtn_promote_html_part
;
94 GtkWidget
*hbox_linespc
;
95 GtkWidget
*label_linespc
;
96 GtkAdjustment
*spinbtn_linespc_adj
;
97 GtkWidget
*spinbtn_linespc
;
101 GtkWidget
*checkbtn_smoothscroll
;
103 GtkWidget
*label_scr
;
104 GtkAdjustment
*spinbtn_scrollstep_adj
;
105 GtkWidget
*spinbtn_scrollstep
;
106 GtkWidget
*checkbtn_halfpage
;
107 GtkWidget
*checkbtn_hide_quoted
;
109 GtkWidget
*checkbtn_attach_desc
;
111 GtkWidget
*frame_quote
;
113 GtkWidget
*vbox_quote
;
114 GtkWidget
*entry_quote_chars
;
115 GtkWidget
*label_quote_chars
;
117 vbox1
= gtk_vbox_new (FALSE
, VSPACING
);
118 gtk_widget_show (vbox1
);
119 gtk_container_set_border_width (GTK_CONTAINER (vbox1
), VBOX_BORDER
);
121 vbox2
= gtkut_get_options_frame(vbox1
, &frame
, _("Headers"));
123 PACK_CHECK_BUTTON(vbox2
, checkbtn_disphdrpane
,
124 _("Display header pane above message view"));
127 PACK_CHECK_BUTTON(vbox2
, checkbtn_dispxface
,
128 _("Display (X-)Face in message view"));
129 PACK_CHECK_BUTTON(vbox2
, checkbtn_savexface
,
130 _("Save (X-)Face in address book if possible"));
132 PACK_CHECK_BUTTON(vbox2
, checkbtn_dispxface
,
133 _("Display Face in message view"));
134 PACK_CHECK_BUTTON(vbox2
, checkbtn_savexface
,
135 _("Save Face in address book if possible"));
138 gtk_widget_set_sensitive(checkbtn_dispxface
,
139 !prefs_common
.display_header_pane
);
141 g_signal_connect(G_OBJECT(checkbtn_disphdrpane
), "toggled",
142 G_CALLBACK(disphdr_pane_toggled
), checkbtn_dispxface
);
144 hbox1
= gtk_hbox_new (FALSE
, 8);
145 gtk_widget_show (hbox1
);
146 gtk_box_pack_start (GTK_BOX (vbox2
), hbox1
, FALSE
, TRUE
, 0);
148 PACK_CHECK_BUTTON(hbox1
, checkbtn_disphdr
,
149 _("Display headers in message view"));
151 button_edit_disphdr
= gtk_button_new_from_stock(GTK_STOCK_EDIT
);
152 gtk_widget_show (button_edit_disphdr
);
153 gtk_box_pack_start (GTK_BOX (hbox1
), button_edit_disphdr
,
155 g_signal_connect (G_OBJECT (button_edit_disphdr
), "clicked",
156 G_CALLBACK (prefs_display_header_open
),
159 SET_TOGGLE_SENSITIVITY(checkbtn_disphdr
, button_edit_disphdr
);
161 vbox2
= gtkut_get_options_frame(vbox1
, &frame
, _("HTML messages"));
163 PACK_CHECK_BUTTON(vbox2
, checkbtn_html
,
164 _("Render HTML messages as text"));
166 PACK_CHECK_BUTTON(vbox2
, checkbtn_html_plugin
,
167 _("Render HTML-only messages with plugin if possible"));
169 PACK_CHECK_BUTTON(vbox2
, checkbtn_promote_html_part
,
170 _("Select the HTML part of multipart/alternative messages"));
172 hbox1
= gtk_hbox_new (FALSE
, 32);
173 gtk_widget_show (hbox1
);
174 gtk_box_pack_start (GTK_BOX (vbox1
), hbox1
, FALSE
, TRUE
, 0);
176 hbox_linespc
= gtk_hbox_new (FALSE
, 8);
177 gtk_widget_show (hbox1
);
178 gtk_box_pack_start (GTK_BOX (hbox1
), hbox_linespc
, FALSE
, TRUE
, 0);
180 label_linespc
= gtk_label_new (_("Line space"));
181 gtk_widget_show (label_linespc
);
182 gtk_box_pack_start (GTK_BOX (hbox_linespc
), label_linespc
,
185 spinbtn_linespc_adj
= GTK_ADJUSTMENT(gtk_adjustment_new (2, 0, 16, 1, 1, 0));
186 spinbtn_linespc
= gtk_spin_button_new
187 (GTK_ADJUSTMENT (spinbtn_linespc_adj
), 1, 0);
188 gtk_widget_show (spinbtn_linespc
);
189 gtk_box_pack_start (GTK_BOX (hbox_linespc
), spinbtn_linespc
,
191 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_linespc
), TRUE
);
193 label_linespc
= gtk_label_new (_("pixels"));
194 gtk_widget_show (label_linespc
);
195 gtk_box_pack_start (GTK_BOX (hbox_linespc
), label_linespc
,
197 gtk_widget_show_all (hbox1
);
199 vbox_scr
= gtkut_get_options_frame(vbox1
, &frame
, _("Scroll"));
201 PACK_CHECK_BUTTON(vbox_scr
, checkbtn_halfpage
, _("Half page"));
203 hbox1
= gtk_hbox_new (FALSE
, 32);
204 gtk_widget_show (hbox1
);
205 gtk_box_pack_start (GTK_BOX (vbox_scr
), hbox1
, FALSE
, TRUE
, 0);
207 PACK_CHECK_BUTTON(hbox1
, checkbtn_smoothscroll
, _("Smooth scroll"));
209 hbox_scr
= gtk_hbox_new (FALSE
, 8);
210 gtk_widget_show (hbox_scr
);
211 gtk_box_pack_start (GTK_BOX (hbox1
), hbox_scr
, FALSE
, FALSE
, 0);
213 label_scr
= gtk_label_new (_("Step"));
214 gtk_widget_show (label_scr
);
215 gtk_box_pack_start (GTK_BOX (hbox_scr
), label_scr
, FALSE
, FALSE
, 0);
217 spinbtn_scrollstep_adj
= GTK_ADJUSTMENT(gtk_adjustment_new (1, 1, 100, 1, 10, 0));
218 spinbtn_scrollstep
= gtk_spin_button_new
219 (GTK_ADJUSTMENT (spinbtn_scrollstep_adj
), 1, 0);
220 gtk_widget_show (spinbtn_scrollstep
);
221 gtk_box_pack_start (GTK_BOX (hbox_scr
), spinbtn_scrollstep
,
223 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_scrollstep
),
226 label_scr
= gtk_label_new (_("pixels"));
227 gtk_widget_show (label_scr
);
228 gtk_box_pack_start (GTK_BOX (hbox_scr
), label_scr
, FALSE
, FALSE
, 0);
230 SET_TOGGLE_SENSITIVITY (checkbtn_smoothscroll
, hbox_scr
)
232 PACK_CHECK_BUTTON(vbox1
, checkbtn_attach_desc
,
233 _("Show attachment descriptions (rather than names)"));
236 PACK_FRAME (vbox1
, frame_quote
, _("Quotation"));
238 vbox_quote
= gtk_vbox_new (FALSE
, VSPACING_NARROW
);
239 gtk_widget_show (vbox_quote
);
240 gtk_container_add (GTK_CONTAINER (frame_quote
), vbox_quote
);
241 gtk_container_set_border_width (GTK_CONTAINER (vbox_quote
), 8);
243 hbox1
= gtk_hbox_new (FALSE
, 32);
244 gtk_widget_show (hbox1
);
245 PACK_CHECK_BUTTON(vbox_quote
, checkbtn_hide_quoted
, _("Collapse quoted text on double click"));
246 gtk_box_pack_start (GTK_BOX (vbox_quote
), hbox1
, FALSE
, FALSE
, 0);
248 hbox2
= gtk_hbox_new (FALSE
, 8);
249 gtk_widget_show (hbox2
);
250 gtk_box_pack_start (GTK_BOX (hbox1
), hbox2
, FALSE
, FALSE
, 0);
252 label_quote_chars
= gtk_label_new (_("Treat these characters as quotation marks"));
253 gtk_widget_show (label_quote_chars
);
254 gtk_box_pack_start (GTK_BOX (hbox2
), label_quote_chars
, FALSE
, FALSE
, 0);
256 entry_quote_chars
= gtk_entry_new ();
257 gtk_widget_show (entry_quote_chars
);
258 gtk_box_pack_start (GTK_BOX (hbox2
), entry_quote_chars
,
260 gtk_widget_set_size_request (entry_quote_chars
, 64, -1);
262 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_disphdrpane
),
263 prefs_common
.display_header_pane
);
265 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_dispxface
),
266 prefs_common
.display_xface
);
267 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_savexface
),
268 prefs_common
.save_xface
);
270 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_disphdr
),
271 prefs_common
.display_header
);
272 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_html
),
273 prefs_common
.render_html
);
274 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_html_plugin
),
275 prefs_common
.invoke_plugin_on_html
);
276 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_promote_html_part
),
277 prefs_common
.promote_html_part
);
278 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_smoothscroll
),
279 prefs_common
.enable_smooth_scroll
);
280 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_hide_quoted
),
281 prefs_common
.hide_quoted
);
282 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_halfpage
),
283 prefs_common
.scroll_halfpage
);
284 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_attach_desc
),
285 prefs_common
.attach_desc
);
286 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_linespc
),
287 prefs_common
.line_space
);
288 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_scrollstep
),
289 prefs_common
.scroll_step
);
290 gtk_entry_set_text(GTK_ENTRY(entry_quote_chars
),
291 prefs_common
.quote_chars
?prefs_common
.quote_chars
:"");
293 prefs_message
->window
= GTK_WIDGET(window
);
294 prefs_message
->checkbtn_disphdrpane
= checkbtn_disphdrpane
;
295 prefs_message
->checkbtn_dispxface
= checkbtn_dispxface
;
296 prefs_message
->checkbtn_savexface
= checkbtn_savexface
;
297 prefs_message
->checkbtn_disphdr
= checkbtn_disphdr
;
298 prefs_message
->checkbtn_html
= checkbtn_html
;
299 prefs_message
->checkbtn_html_plugin
= checkbtn_html_plugin
;
300 prefs_message
->checkbtn_promote_html_part
= checkbtn_promote_html_part
;
301 prefs_message
->spinbtn_linespc
= spinbtn_linespc
;
302 prefs_message
->checkbtn_smoothscroll
= checkbtn_smoothscroll
;
303 prefs_message
->checkbtn_hide_quoted
= checkbtn_hide_quoted
;
304 prefs_message
->spinbtn_scrollstep
= spinbtn_scrollstep
;
305 prefs_message
->checkbtn_halfpage
= checkbtn_halfpage
;
306 prefs_message
->checkbtn_attach_desc
= checkbtn_attach_desc
;
307 prefs_message
->entry_quote_chars
= entry_quote_chars
;
309 prefs_message
->page
.widget
= vbox1
;
312 static void prefs_message_save(PrefsPage
*_page
)
314 MessagePage
*page
= (MessagePage
*) _page
;
316 prefs_common
.display_header_pane
= gtk_toggle_button_get_active(
317 GTK_TOGGLE_BUTTON(page
->checkbtn_disphdrpane
));
318 prefs_common
.display_xface
= gtk_toggle_button_get_active(
319 GTK_TOGGLE_BUTTON(page
->checkbtn_dispxface
));
320 prefs_common
.save_xface
= gtk_toggle_button_get_active(
321 GTK_TOGGLE_BUTTON(page
->checkbtn_savexface
));
322 prefs_common
.display_header
= gtk_toggle_button_get_active(
323 GTK_TOGGLE_BUTTON(page
->checkbtn_disphdr
));
324 prefs_common
.render_html
= gtk_toggle_button_get_active(
325 GTK_TOGGLE_BUTTON(page
->checkbtn_html
));
326 prefs_common
.invoke_plugin_on_html
= gtk_toggle_button_get_active(
327 GTK_TOGGLE_BUTTON(page
->checkbtn_html_plugin
));
328 prefs_common
.promote_html_part
= gtk_toggle_button_get_active(
329 GTK_TOGGLE_BUTTON(page
->checkbtn_promote_html_part
));
330 prefs_common
.enable_smooth_scroll
= gtk_toggle_button_get_active(
331 GTK_TOGGLE_BUTTON(page
->checkbtn_smoothscroll
));
332 prefs_common
.scroll_halfpage
= gtk_toggle_button_get_active(
333 GTK_TOGGLE_BUTTON(page
->checkbtn_halfpage
));
334 prefs_common
.hide_quoted
= gtk_toggle_button_get_active(
335 GTK_TOGGLE_BUTTON(page
->checkbtn_hide_quoted
));
336 prefs_common
.attach_desc
= gtk_toggle_button_get_active(
337 GTK_TOGGLE_BUTTON(page
->checkbtn_attach_desc
));
338 prefs_common
.line_space
= gtk_spin_button_get_value_as_int(
339 GTK_SPIN_BUTTON(page
->spinbtn_linespc
));
340 prefs_common
.scroll_step
= gtk_spin_button_get_value_as_int(
341 GTK_SPIN_BUTTON(page
->spinbtn_scrollstep
));
343 g_free(prefs_common
.quote_chars
);
344 prefs_common
.quote_chars
= gtk_editable_get_chars(
345 GTK_EDITABLE(page
->entry_quote_chars
), 0, -1);
346 remove_space(prefs_common
.quote_chars
);
348 main_window_reflect_prefs_all_real(FALSE
);
351 static void prefs_message_destroy_widget(PrefsPage
*_page
)
355 MessagePage
*prefs_message
;
357 void prefs_message_init(void)
360 static gchar
*path
[3];
362 path
[0] = _("Message View");
363 path
[1] = _("Text Options");
366 page
= g_new0(MessagePage
, 1);
367 page
->page
.path
= path
;
368 page
->page
.create_widget
= prefs_message_create_widget
;
369 page
->page
.destroy_widget
= prefs_message_destroy_widget
;
370 page
->page
.save_page
= prefs_message_save
;
371 page
->page
.weight
= 170.0;
372 prefs_gtk_register_page((PrefsPage
*) page
);
373 prefs_message
= page
;
376 void prefs_message_done(void)
378 prefs_gtk_unregister_page((PrefsPage
*) prefs_message
);
379 g_free(prefs_message
);