Remove wrong initialization from max_message_size
[claws.git] / src / prefs_wrapping.c
blobb3624682b7b02bb30b028719136a9328307a03eb
1 /*
2 * Claws Mail -- a GTK based, lightweight, and fast e-mail client
3 * Copyright (C) 2004-2012 Hiroyuki Yamamoto & 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/>.
20 #ifdef HAVE_CONFIG_H
21 # include "config.h"
22 #include "claws-features.h"
23 #endif
25 #include "defs.h"
27 #include <stdio.h>
28 #include <stdlib.h>
30 #include <glib.h>
31 #include <glib/gi18n.h>
32 #include <gtk/gtk.h>
33 #include <gdk/gdkkeysyms.h>
35 #include "prefs_common.h"
36 #include "prefs_gtk.h"
38 #include "gtk/gtkutils.h"
39 #include "gtk/prefswindow.h"
41 #include "manage_window.h"
43 typedef struct _WrappingPage
45 PrefsPage page;
47 GtkWidget *window;
49 GtkWidget *spinbtn_linewrap;
50 GtkWidget *checkbtn_wrapquote;
51 GtkWidget *checkbtn_wrappastes;
52 GtkWidget *checkbtn_autowrap;
53 GtkWidget *checkbtn_autoindent;
54 } WrappingPage;
56 static void prefs_wrapping_create_widget(PrefsPage *_page, GtkWindow *window,
57 gpointer data)
59 WrappingPage *prefs_wrapping = (WrappingPage *) _page;
61 GtkWidget *vbox1;
62 GtkWidget *vbox2;
63 GtkWidget *label_linewrap;
64 GtkAdjustment *spinbtn_linewrap_adj;
65 GtkWidget *spinbtn_linewrap;
66 GtkWidget *checkbtn_wrapquote;
67 GtkWidget *checkbtn_wrappastes;
68 GtkWidget *checkbtn_autowrap;
69 GtkWidget *checkbtn_autoindent;
70 GtkWidget *hbox1;
72 vbox1 = gtk_box_new(GTK_ORIENTATION_VERTICAL, VSPACING);
73 gtk_widget_show (vbox1);
74 gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
76 vbox2 = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
77 gtk_widget_show (vbox2);
78 gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
80 PACK_CHECK_BUTTON (vbox2, checkbtn_autowrap, _("Auto wrapping"));
81 PACK_CHECK_BUTTON (vbox2, checkbtn_wrapquote, _("Wrap quotation"));
82 PACK_CHECK_BUTTON (vbox2, checkbtn_wrappastes, _("Wrap pasted text"));
83 PACK_CHECK_BUTTON (vbox2, checkbtn_autoindent, _("Auto indent"));
85 hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
86 gtk_widget_show (hbox1);
87 gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
89 label_linewrap = gtk_label_new (_("Wrap text at"));
90 gtk_widget_show (label_linewrap);
91 gtk_box_pack_start (GTK_BOX (hbox1), label_linewrap, FALSE, FALSE, 4);
93 spinbtn_linewrap_adj = GTK_ADJUSTMENT(gtk_adjustment_new (72, 20, 1024, 1, 10, 0));
94 spinbtn_linewrap = gtk_spin_button_new
95 (GTK_ADJUSTMENT (spinbtn_linewrap_adj), 1, 0);
96 gtk_widget_show (spinbtn_linewrap);
97 gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_linewrap, FALSE, FALSE, 0);
98 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_linewrap), TRUE);
100 label_linewrap = gtk_label_new (_("characters"));
101 gtk_widget_show (label_linewrap);
102 gtk_box_pack_start (GTK_BOX (hbox1), label_linewrap, FALSE, FALSE, 0);
104 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_autowrap),
105 prefs_common.autowrap);
106 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_wrapquote),
107 prefs_common.linewrap_quote);
108 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_wrappastes),
109 prefs_common.linewrap_pastes);
110 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_autoindent),
111 prefs_common.auto_indent);
112 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_linewrap),
113 prefs_common.linewrap_len);
115 prefs_wrapping->window = GTK_WIDGET(window);
116 prefs_wrapping->spinbtn_linewrap = spinbtn_linewrap;
117 prefs_wrapping->checkbtn_wrapquote = checkbtn_wrapquote;
118 prefs_wrapping->checkbtn_wrappastes = checkbtn_wrappastes;
119 prefs_wrapping->checkbtn_autowrap = checkbtn_autowrap;
120 prefs_wrapping->checkbtn_autoindent = checkbtn_autoindent;
122 prefs_wrapping->page.widget = vbox1;
125 static void prefs_wrapping_save(PrefsPage *_page)
127 WrappingPage *page = (WrappingPage *) _page;
129 prefs_common.linewrap_len =
130 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(page->spinbtn_linewrap));
131 prefs_common.linewrap_quote =
132 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_wrapquote));
133 prefs_common.linewrap_pastes =
134 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_wrappastes));
135 prefs_common.autowrap =
136 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_autowrap));
137 prefs_common.auto_indent =
138 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_autoindent));
141 static void prefs_wrapping_destroy_widget(PrefsPage *_page)
145 WrappingPage *prefs_wrapping;
147 void prefs_wrapping_init(void)
149 WrappingPage *page;
150 static gchar *path[3];
152 path[0] = _("Compose");
153 path[1] = _("Wrapping");
154 path[2] = NULL;
156 page = g_new0(WrappingPage, 1);
157 page->page.path = path;
158 page->page.create_widget = prefs_wrapping_create_widget;
159 page->page.destroy_widget = prefs_wrapping_destroy_widget;
160 page->page.save_page = prefs_wrapping_save;
161 page->page.weight = 182.0;
162 prefs_gtk_register_page((PrefsPage *) page);
163 prefs_wrapping = page;
166 void prefs_wrapping_done(void)
168 prefs_gtk_unregister_page((PrefsPage *) prefs_wrapping);
169 g_free(prefs_wrapping);