2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2004-2006 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 2 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, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30 #include <glib/gi18n.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"
40 #include "manage_window.h"
42 typedef struct _WrappingPage
48 GtkWidget
*spinbtn_linewrap
;
49 GtkWidget
*checkbtn_wrapquote
;
50 GtkWidget
*checkbtn_wrappastes
;
51 GtkWidget
*checkbtn_autowrap
;
54 void prefs_wrapping_create_widget(PrefsPage
*_page
, GtkWindow
*window
,
57 WrappingPage
*prefs_wrapping
= (WrappingPage
*) _page
;
61 GtkWidget
*label_linewrap
;
62 GtkObject
*spinbtn_linewrap_adj
;
63 GtkWidget
*spinbtn_linewrap
;
64 GtkWidget
*checkbtn_wrapquote
;
65 GtkWidget
*checkbtn_wrappastes
;
66 GtkWidget
*checkbtn_autowrap
;
69 vbox1
= gtk_vbox_new (FALSE
, VSPACING
);
70 gtk_widget_show (vbox1
);
71 gtk_container_set_border_width (GTK_CONTAINER (vbox1
), VBOX_BORDER
);
73 vbox2
= gtk_vbox_new (FALSE
, 0);
74 gtk_widget_show (vbox2
);
75 gtk_box_pack_start (GTK_BOX (vbox1
), vbox2
, FALSE
, FALSE
, 0);
77 PACK_CHECK_BUTTON (vbox2
, checkbtn_autowrap
, _("Auto wrapping"));
78 PACK_CHECK_BUTTON (vbox2
, checkbtn_wrapquote
, _("Wrap quotation"));
79 PACK_CHECK_BUTTON (vbox2
, checkbtn_wrappastes
, _("Wrap pasted text"));
81 hbox1
= gtk_hbox_new (FALSE
, 8);
82 gtk_widget_show (hbox1
);
83 gtk_box_pack_start (GTK_BOX (vbox2
), hbox1
, FALSE
, FALSE
, 0);
85 label_linewrap
= gtk_label_new (_("Wrap messages at"));
86 gtk_widget_show (label_linewrap
);
87 gtk_box_pack_start (GTK_BOX (hbox1
), label_linewrap
, FALSE
, FALSE
, 4);
89 spinbtn_linewrap_adj
= gtk_adjustment_new (72, 20, 1024, 1, 10, 10);
90 spinbtn_linewrap
= gtk_spin_button_new
91 (GTK_ADJUSTMENT (spinbtn_linewrap_adj
), 1, 0);
92 gtk_widget_set_size_request (spinbtn_linewrap
, 64, -1);
93 gtk_widget_show (spinbtn_linewrap
);
94 gtk_box_pack_start (GTK_BOX (hbox1
), spinbtn_linewrap
, FALSE
, FALSE
, 0);
95 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_linewrap
), TRUE
);
97 label_linewrap
= gtk_label_new (_("characters"));
98 gtk_widget_show (label_linewrap
);
99 gtk_box_pack_start (GTK_BOX (hbox1
), label_linewrap
, FALSE
, FALSE
, 0);
101 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_autowrap
),
102 prefs_common
.autowrap
);
103 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_wrapquote
),
104 prefs_common
.linewrap_quote
);
105 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_wrappastes
),
106 prefs_common
.linewrap_pastes
);
107 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_linewrap
),
108 prefs_common
.linewrap_len
);
110 prefs_wrapping
->window
= GTK_WIDGET(window
);
111 prefs_wrapping
->spinbtn_linewrap
= spinbtn_linewrap
;
112 prefs_wrapping
->checkbtn_wrapquote
= checkbtn_wrapquote
;
113 prefs_wrapping
->checkbtn_wrappastes
= checkbtn_wrappastes
;
114 prefs_wrapping
->checkbtn_autowrap
= checkbtn_autowrap
;
116 prefs_wrapping
->page
.widget
= vbox1
;
119 void prefs_wrapping_save(PrefsPage
*_page
)
121 WrappingPage
*page
= (WrappingPage
*) _page
;
123 prefs_common
.linewrap_len
=
124 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(page
->spinbtn_linewrap
));
125 prefs_common
.linewrap_quote
=
126 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->checkbtn_wrapquote
));
127 prefs_common
.linewrap_pastes
=
128 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->checkbtn_wrappastes
));
129 prefs_common
.autowrap
=
130 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->checkbtn_autowrap
));
133 static void prefs_wrapping_destroy_widget(PrefsPage
*_page
)
137 WrappingPage
*prefs_wrapping
;
139 void prefs_wrapping_init(void)
142 static gchar
*path
[3];
144 path
[0] = _("Compose");
145 path
[1] = _("Wrapping");
148 page
= g_new0(WrappingPage
, 1);
149 page
->page
.path
= path
;
150 page
->page
.create_widget
= prefs_wrapping_create_widget
;
151 page
->page
.destroy_widget
= prefs_wrapping_destroy_widget
;
152 page
->page
.save_page
= prefs_wrapping_save
;
153 page
->page
.weight
= 182.0;
154 prefs_gtk_register_page((PrefsPage
*) page
);
155 prefs_wrapping
= page
;
158 void prefs_wrapping_done(void)
160 prefs_gtk_unregister_page((PrefsPage
*) prefs_wrapping
);
161 g_free(prefs_wrapping
);