2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2005 Colin Leroy <colin@colino.net> & The Sylpheed-Claws 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 #include "imap-thread.h"
45 typedef struct _OtherPage
51 GtkWidget *checkbtn_addaddrbyclick;
52 GtkWidget *checkbtn_confonexit;
53 GtkWidget *checkbtn_cleanonexit;
54 GtkWidget *checkbtn_askonclean;
55 GtkWidget *checkbtn_warnqueued;
56 GtkWidget *checkbtn_cliplog;
57 GtkWidget *loglength_entry;
58 GtkWidget *spinbtn_iotimeout;
61 void prefs_other_create_widget(PrefsPage *_page, GtkWindow *window,
64 OtherPage *prefs_other = (OtherPage *) _page;
69 GtkWidget *frame_addr;
71 GtkWidget *checkbtn_addaddrbyclick;
73 GtkWidget *frame_cliplog;
74 GtkWidget *vbox_cliplog;
75 GtkWidget *hbox_cliplog;
76 GtkWidget *checkbtn_cliplog;
77 GtkWidget *loglength_label;
78 GtkWidget *loglength_entry;
79 GtkTooltips *loglength_tooltip;
81 GtkWidget *frame_exit;
83 GtkWidget *checkbtn_confonexit;
84 GtkWidget *checkbtn_cleanonexit;
85 GtkWidget *checkbtn_askonclean;
86 GtkWidget *checkbtn_warnqueued;
88 GtkWidget *label_iotimeout;
89 GtkWidget *spinbtn_iotimeout;
90 GtkObject *spinbtn_iotimeout_adj;
93 vbox1 = gtk_vbox_new (FALSE, VSPACING);
94 gtk_widget_show (vbox1);
95 gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
97 PACK_FRAME (vbox1, frame_addr, _("Address book"));
99 vbox_addr = gtk_vbox_new (FALSE, 0);
100 gtk_widget_show (vbox_addr);
101 gtk_container_add (GTK_CONTAINER (frame_addr), vbox_addr);
102 gtk_container_set_border_width (GTK_CONTAINER (vbox_addr), 8);
105 (vbox_addr, checkbtn_addaddrbyclick,
106 _("Add address to destination when double-clicked"));
109 PACK_FRAME (vbox1, frame_cliplog, _("Log Size"));
111 vbox_cliplog = gtk_vbox_new (FALSE, 0);
112 gtk_widget_show (vbox_cliplog);
113 gtk_container_add (GTK_CONTAINER (frame_cliplog), vbox_cliplog);
114 gtk_container_set_border_width (GTK_CONTAINER (vbox_cliplog), 8);
115 PACK_CHECK_BUTTON (vbox_cliplog, checkbtn_cliplog,
116 _("Clip the log size"));
117 hbox_cliplog = gtk_hbox_new (FALSE, 3);
118 gtk_container_add (GTK_CONTAINER (vbox_cliplog), hbox_cliplog);
119 gtk_widget_show (hbox_cliplog);
121 loglength_label = gtk_label_new (_("Log window length"));
122 gtk_box_pack_start (GTK_BOX (hbox_cliplog), loglength_label,
124 gtk_widget_show (GTK_WIDGET (loglength_label));
126 loglength_tooltip = gtk_tooltips_new();
128 loglength_entry = gtk_entry_new ();
129 gtk_widget_set_size_request (GTK_WIDGET (loglength_entry), 64, -1);
130 gtk_box_pack_start (GTK_BOX (hbox_cliplog), loglength_entry,
132 gtk_widget_show (GTK_WIDGET (loglength_entry));
133 gtk_tooltips_set_tip(GTK_TOOLTIPS(loglength_tooltip), loglength_entry,
134 _("0 to stop logging in the log window"),
136 SET_TOGGLE_SENSITIVITY(checkbtn_cliplog, loglength_entry);
139 PACK_FRAME (vbox1, frame_exit, _("On exit"));
141 vbox_exit = gtk_vbox_new (FALSE, 0);
142 gtk_widget_show (vbox_exit);
143 gtk_container_add (GTK_CONTAINER (frame_exit), vbox_exit);
144 gtk_container_set_border_width (GTK_CONTAINER (vbox_exit), 8);
146 PACK_CHECK_BUTTON (vbox_exit, checkbtn_confonexit,
147 _("Confirm on exit"));
149 hbox1 = gtk_hbox_new (FALSE, 32);
150 gtk_widget_show (hbox1);
151 gtk_box_pack_start (GTK_BOX (vbox_exit), hbox1, FALSE, FALSE, 0);
153 PACK_CHECK_BUTTON (hbox1, checkbtn_cleanonexit,
154 _("Empty trash on exit"));
155 PACK_CHECK_BUTTON (hbox1, checkbtn_askonclean,
156 _("Ask before emptying"));
157 SET_TOGGLE_SENSITIVITY (checkbtn_cleanonexit, checkbtn_askonclean);
159 PACK_CHECK_BUTTON (vbox_exit, checkbtn_warnqueued,
160 _("Warn if there are queued messages"));
162 hbox1 = gtk_hbox_new (FALSE, 8);
163 gtk_widget_show (hbox1);
164 gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
166 label_iotimeout = gtk_label_new (_("Socket I/O timeout:"));
167 gtk_widget_show (label_iotimeout);
168 gtk_box_pack_start (GTK_BOX (hbox1), label_iotimeout, FALSE, FALSE, 0);
170 spinbtn_iotimeout_adj = gtk_adjustment_new (60, 0, 1000, 1, 10, 10);
171 spinbtn_iotimeout = gtk_spin_button_new
172 (GTK_ADJUSTMENT (spinbtn_iotimeout_adj), 1, 0);
173 gtk_widget_show (spinbtn_iotimeout);
174 gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_iotimeout,
176 gtk_widget_set_size_request (spinbtn_iotimeout, 64, -1);
177 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_iotimeout), TRUE);
179 label_iotimeout = gtk_label_new (_("seconds"));
180 gtk_widget_show (label_iotimeout);
181 gtk_box_pack_start (GTK_BOX (hbox1), label_iotimeout, FALSE, FALSE, 0);
183 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_addaddrbyclick),
184 prefs_common.add_address_by_click);
185 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_confonexit),
186 prefs_common.confirm_on_exit);
187 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_cleanonexit),
188 prefs_common.clean_on_exit);
189 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_askonclean),
190 prefs_common.ask_on_clean);
191 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_warnqueued),
192 prefs_common.warn_queued_on_exit);
193 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_cliplog),
194 prefs_common.cliplog);
196 tmp = g_strdup_printf("%d", prefs_common.loglength);
197 gtk_entry_set_text(GTK_ENTRY(loglength_entry), tmp);
200 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_iotimeout),
201 prefs_common.io_timeout_secs);
203 prefs_other->checkbtn_addaddrbyclick = checkbtn_addaddrbyclick;
204 prefs_other->checkbtn_confonexit = checkbtn_confonexit;
205 prefs_other->checkbtn_cleanonexit = checkbtn_cleanonexit;
206 prefs_other->checkbtn_askonclean = checkbtn_askonclean;
207 prefs_other->checkbtn_warnqueued = checkbtn_warnqueued;
208 prefs_other->checkbtn_cliplog = checkbtn_cliplog;
209 prefs_other->loglength_entry = loglength_entry;
210 prefs_other->spinbtn_iotimeout = spinbtn_iotimeout;
212 prefs_other->page.widget = vbox1;
215 void prefs_other_save(PrefsPage *_page)
217 OtherPage *page = (OtherPage *) _page;
218 MainWindow *mainwindow;
220 gchar *tmp = gtk_editable_get_chars(GTK_EDITABLE(page->loglength_entry), 0, -1);
222 if (tmp && atoi(tmp)) {
223 prefs_common.loglength = atoi(tmp);
226 prefs_common.add_address_by_click = gtk_toggle_button_get_active(
227 GTK_TOGGLE_BUTTON(page->checkbtn_addaddrbyclick));
228 prefs_common.confirm_on_exit = gtk_toggle_button_get_active(
229 GTK_TOGGLE_BUTTON(page->checkbtn_confonexit));
230 prefs_common.clean_on_exit = gtk_toggle_button_get_active(
231 GTK_TOGGLE_BUTTON(page->checkbtn_cleanonexit));
232 prefs_common.ask_on_clean = gtk_toggle_button_get_active(
233 GTK_TOGGLE_BUTTON(page->checkbtn_askonclean));
234 prefs_common.warn_queued_on_exit = gtk_toggle_button_get_active(
235 GTK_TOGGLE_BUTTON(page->checkbtn_warnqueued));
236 prefs_common.cliplog = gtk_toggle_button_get_active(
237 GTK_TOGGLE_BUTTON(page->checkbtn_cliplog));
238 prefs_common.io_timeout_secs = gtk_spin_button_get_value_as_int(
239 GTK_SPIN_BUTTON(page->spinbtn_iotimeout));
240 sock_set_io_timeout(prefs_common.io_timeout_secs);
242 imap_main_set_timeout(prefs_common.io_timeout_secs);
244 mainwindow = mainwindow_get_mainwindow();
245 log_window_set_clipping(mainwindow->logwin, prefs_common.cliplog,
246 prefs_common.loglength);
250 static void prefs_other_destroy_widget(PrefsPage *_page)
254 OtherPage *prefs_other;
256 void prefs_other_init(void)
259 static gchar *path[2];
261 path[0] = _("Other");
264 page = g_new0(OtherPage, 1);
265 page->page.path = path;
266 page->page.create_widget = prefs_other_create_widget;
267 page->page.destroy_widget = prefs_other_destroy_widget;
268 page->page.save_page = prefs_other_save;
269 page->page.weight = 5.0;
270 prefs_gtk_register_page((PrefsPage *) page);
274 void prefs_other_done(void)
276 prefs_gtk_unregister_page((PrefsPage *) prefs_other);