2013-02-27 [mones] 3.9.0cvs104
[claws.git] / src / prefs_wrapping.c
blobed1bc29796225e76d3fb50774be4a27de0732eb9
1 /*
2 * Sylpheed -- 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_vbox_new (FALSE, VSPACING);
73 gtk_widget_show (vbox1);
74 gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
76 vbox2 = gtk_vbox_new (FALSE, 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_hbox_new (FALSE, 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_set_size_request (spinbtn_linewrap, 64, -1);
97 gtk_widget_show (spinbtn_linewrap);
98 gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_linewrap, FALSE, FALSE, 0);
99 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_linewrap), TRUE);
101 label_linewrap = gtk_label_new (_("characters"));
102 gtk_widget_show (label_linewrap);
103 gtk_box_pack_start (GTK_BOX (hbox1), label_linewrap, FALSE, FALSE, 0);
105 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_autowrap),
106 prefs_common.autowrap);
107 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_wrapquote),
108 prefs_common.linewrap_quote);
109 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_wrappastes),
110 prefs_common.linewrap_pastes);
111 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_autoindent),
112 prefs_common.auto_indent);
113 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_linewrap),
114 prefs_common.linewrap_len);
116 prefs_wrapping->window = GTK_WIDGET(window);
117 prefs_wrapping->spinbtn_linewrap = spinbtn_linewrap;
118 prefs_wrapping->checkbtn_wrapquote = checkbtn_wrapquote;
119 prefs_wrapping->checkbtn_wrappastes = checkbtn_wrappastes;
120 prefs_wrapping->checkbtn_autowrap = checkbtn_autowrap;
121 prefs_wrapping->checkbtn_autoindent = checkbtn_autoindent;
123 prefs_wrapping->page.widget = vbox1;
126 static void prefs_wrapping_save(PrefsPage *_page)
128 WrappingPage *page = (WrappingPage *) _page;
130 prefs_common.linewrap_len =
131 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(page->spinbtn_linewrap));
132 prefs_common.linewrap_quote =
133 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_wrapquote));
134 prefs_common.linewrap_pastes =
135 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_wrappastes));
136 prefs_common.autowrap =
137 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_autowrap));
138 prefs_common.auto_indent =
139 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_autoindent));
142 static void prefs_wrapping_destroy_widget(PrefsPage *_page)
146 WrappingPage *prefs_wrapping;
148 void prefs_wrapping_init(void)
150 WrappingPage *page;
151 static gchar *path[3];
153 path[0] = _("Compose");
154 path[1] = _("Wrapping");
155 path[2] = NULL;
157 page = g_new0(WrappingPage, 1);
158 page->page.path = path;
159 page->page.create_widget = prefs_wrapping_create_widget;
160 page->page.destroy_widget = prefs_wrapping_destroy_widget;
161 page->page.save_page = prefs_wrapping_save;
162 page->page.weight = 182.0;
163 prefs_gtk_register_page((PrefsPage *) page);
164 prefs_wrapping = page;
167 void prefs_wrapping_done(void)
169 prefs_gtk_unregister_page((PrefsPage *) prefs_wrapping);
170 g_free(prefs_wrapping);