prefs_message.c (6924B)
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 4 * 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. 9 * 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. 14 * 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/>. 17 */ 18 19 #include "defs.h" 20 21 #include <stdio.h> 22 #include <stdlib.h> 23 24 #include <glib.h> 25 #include <glib/gi18n.h> 26 #include <gtk/gtk.h> 27 #include <gdk/gdkkeysyms.h> 28 29 #include "prefs_common.h" 30 #include "prefs_gtk.h" 31 #include "prefs_display_header.h" 32 33 #include "gtk/gtkutils.h" 34 #include "gtk/prefswindow.h" 35 36 #include "manage_window.h" 37 38 typedef struct _MessagePage 39 { 40 PrefsPage page; 41 42 GtkWidget *window; 43 44 GtkWidget *checkbtn_disphdr; 45 46 GtkWidget *checkbtn_html; 47 GtkWidget *spinbtn_linespc; 48 49 GtkWidget *checkbtn_hide_quoted; 50 51 GtkWidget *checkbtn_attach_desc; 52 } MessagePage; 53 54 static void prefs_message_create_widget(PrefsPage *_page, GtkWindow *window, 55 gpointer data) 56 { 57 MessagePage *prefs_message = (MessagePage *) _page; 58 59 GtkWidget *vbox1; 60 GtkWidget *vbox2; 61 GtkWidget *hbox1; 62 GtkWidget *checkbtn_disphdr; 63 64 GtkWidget *button_edit_disphdr; 65 GtkWidget *checkbtn_html; 66 GtkWidget *hbox_linespc; 67 GtkWidget *label_linespc; 68 GtkAdjustment *spinbtn_linespc_adj; 69 GtkWidget *spinbtn_linespc; 70 71 GtkWidget *frame; 72 GtkWidget *checkbtn_hide_quoted; 73 74 GtkWidget *checkbtn_attach_desc; 75 76 GtkWidget *frame_quote; 77 GtkWidget *hbox2; 78 GtkWidget *vbox_quote; 79 80 vbox1 = gtk_box_new(GTK_ORIENTATION_VERTICAL, VSPACING); 81 gtk_widget_show (vbox1); 82 gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER); 83 84 vbox2 = gtkut_get_options_frame(vbox1, &frame, _("Headers")); 85 86 hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8); 87 gtk_widget_show (hbox1); 88 gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0); 89 90 PACK_CHECK_BUTTON(hbox1, checkbtn_disphdr, 91 _("Display headers in message view")); 92 93 button_edit_disphdr = gtk_button_new_with_mnemonic(_("_Edit")); 94 gtk_widget_show (button_edit_disphdr); 95 gtk_box_pack_start (GTK_BOX (hbox1), button_edit_disphdr, 96 FALSE, TRUE, 0); 97 g_signal_connect (G_OBJECT (button_edit_disphdr), "clicked", 98 G_CALLBACK (prefs_display_header_open), 99 NULL); 100 101 SET_TOGGLE_SENSITIVITY(checkbtn_disphdr, button_edit_disphdr); 102 103 vbox2 = gtkut_get_options_frame(vbox1, &frame, _("HTML messages")); 104 PACK_CHECK_BUTTON(vbox2, checkbtn_html, 105 _("Render HTML messages as text")); 106 107 hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 32); 108 gtk_widget_show (hbox1); 109 gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, TRUE, 0); 110 111 hbox_linespc = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8); 112 gtk_widget_show (hbox1); 113 gtk_box_pack_start (GTK_BOX (hbox1), hbox_linespc, FALSE, TRUE, 0); 114 115 label_linespc = gtk_label_new (_("Line space")); 116 gtk_widget_show (label_linespc); 117 gtk_box_pack_start (GTK_BOX (hbox_linespc), label_linespc, 118 FALSE, FALSE, 0); 119 120 spinbtn_linespc_adj = GTK_ADJUSTMENT(gtk_adjustment_new (2, 0, 16, 1, 1, 0)); 121 spinbtn_linespc = gtk_spin_button_new 122 (GTK_ADJUSTMENT (spinbtn_linespc_adj), 1, 0); 123 gtk_widget_show (spinbtn_linespc); 124 gtk_box_pack_start (GTK_BOX (hbox_linespc), spinbtn_linespc, 125 FALSE, FALSE, 0); 126 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_linespc), TRUE); 127 128 label_linespc = gtk_label_new (_("pixels")); 129 gtk_widget_show (label_linespc); 130 gtk_box_pack_start (GTK_BOX (hbox_linespc), label_linespc, 131 FALSE, FALSE, 0); 132 gtk_widget_show_all (hbox1); 133 134 PACK_CHECK_BUTTON(vbox1, checkbtn_attach_desc, 135 _("Show attachment descriptions (rather than names)")); 136 137 /* quote chars */ 138 PACK_FRAME (vbox1, frame_quote, _("Quotation")); 139 140 vbox_quote = gtk_box_new(GTK_ORIENTATION_VERTICAL, VSPACING_NARROW); 141 gtk_widget_show (vbox_quote); 142 gtk_container_add (GTK_CONTAINER (frame_quote), vbox_quote); 143 gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8); 144 145 hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 32); 146 gtk_widget_show (hbox1); 147 PACK_CHECK_BUTTON(vbox_quote, checkbtn_hide_quoted, _("Collapse quoted text on double click")); 148 gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0); 149 150 hbox2 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8); 151 gtk_widget_show (hbox2); 152 gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0); 153 154 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_disphdr), 155 prefs_common.display_header); 156 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_html), 157 prefs_common.render_html); 158 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_hide_quoted), 159 prefs_common.hide_quoted); 160 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_attach_desc), 161 prefs_common.attach_desc); 162 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_linespc), 163 prefs_common.line_space); 164 165 prefs_message->window = GTK_WIDGET(window); 166 prefs_message->checkbtn_disphdr = checkbtn_disphdr; 167 prefs_message->checkbtn_html = checkbtn_html; 168 prefs_message->spinbtn_linespc = spinbtn_linespc; 169 prefs_message->checkbtn_hide_quoted = checkbtn_hide_quoted; 170 prefs_message->checkbtn_attach_desc = checkbtn_attach_desc; 171 172 prefs_message->page.widget = vbox1; 173 } 174 175 static void prefs_message_save(PrefsPage *_page) 176 { 177 MessagePage *page = (MessagePage *) _page; 178 179 prefs_common.display_header = gtk_toggle_button_get_active( 180 GTK_TOGGLE_BUTTON(page->checkbtn_disphdr)); 181 prefs_common.render_html = gtk_toggle_button_get_active( 182 GTK_TOGGLE_BUTTON(page->checkbtn_html)); 183 prefs_common.hide_quoted = gtk_toggle_button_get_active( 184 GTK_TOGGLE_BUTTON(page->checkbtn_hide_quoted)); 185 prefs_common.attach_desc = gtk_toggle_button_get_active( 186 GTK_TOGGLE_BUTTON(page->checkbtn_attach_desc)); 187 prefs_common.line_space = gtk_spin_button_get_value_as_int( 188 GTK_SPIN_BUTTON(page->spinbtn_linespc)); 189 190 main_window_reflect_prefs_all_real(FALSE); 191 } 192 193 static void prefs_message_destroy_widget(PrefsPage *_page) 194 { 195 } 196 197 MessagePage *prefs_message; 198 199 void prefs_message_init(void) 200 { 201 MessagePage *page; 202 static gchar *path[3]; 203 204 path[0] = _("Message View"); 205 path[1] = _("Text Options"); 206 path[2] = NULL; 207 208 page = g_new0(MessagePage, 1); 209 page->page.path = path; 210 page->page.create_widget = prefs_message_create_widget; 211 page->page.destroy_widget = prefs_message_destroy_widget; 212 page->page.save_page = prefs_message_save; 213 page->page.weight = 170.0; 214 prefs_gtk_register_page((PrefsPage *) page); 215 prefs_message = page; 216 } 217 218 void prefs_message_done(void) 219 { 220 prefs_gtk_unregister_page((PrefsPage *) prefs_message); 221 g_free(prefs_message); 222 }