2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2004 Hiroyuki Yamamoto & 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.
26 #include "prefs_gtk.h"
27 #include "prefs_gpg.h"
29 struct GPGConfig prefs_gpg;
31 static PrefParam param[] = {
33 {"auto_check_signatures", "TRUE",
34 &prefs_gpg.auto_check_signatures, P_BOOL,
36 {"store_passphrase", "FALSE", &prefs_gpg.store_passphrase, P_BOOL,
38 {"store_passphrase_timeout", "0",
39 &prefs_gpg.store_passphrase_timeout, P_INT,
42 {"passphrase_grab", "FALSE", &prefs_gpg.passphrase_grab, P_BOOL,
44 #endif /* __MINGW32__ */
45 {"gpg_warning", "TRUE", &prefs_gpg.gpg_warning, P_BOOL,
48 {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
51 static void prefs_privacy_create(void)
59 GtkWidget *checkbtn_auto_check_signatures;
60 GtkWidget *checkbtn_store_passphrase;
61 GtkObject *spinbtn_store_passphrase_adj;
62 GtkWidget *spinbtn_store_passphrase;
63 GtkTooltips *store_tooltip;
64 GtkWidget *checkbtn_passphrase_grab;
65 GtkWidget *checkbtn_gpg_warning;
67 vbox1 = gtk_vbox_new (FALSE, VSPACING);
68 gtk_widget_show (vbox1);
69 gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
71 vbox2 = gtk_vbox_new (FALSE, 0);
72 gtk_widget_show (vbox2);
73 gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
75 PACK_CHECK_BUTTON (vbox2, checkbtn_auto_check_signatures,
76 _("Automatically check signatures"));
78 PACK_CHECK_BUTTON (vbox2, checkbtn_store_passphrase,
79 _("Store passphrase in memory temporarily"));
81 vbox3 = gtk_vbox_new (FALSE, 0);
82 gtk_widget_show (vbox3);
83 gtk_box_pack_start (GTK_BOX (vbox2), vbox3, FALSE, FALSE, 0);
85 hbox1 = gtk_hbox_new (FALSE, 8);
86 gtk_widget_show (hbox1);
87 gtk_box_pack_start (GTK_BOX (vbox3), hbox1, FALSE, FALSE, 0);
89 hbox_spc = gtk_hbox_new (FALSE, 0);
90 gtk_widget_show (hbox_spc);
91 gtk_box_pack_start (GTK_BOX (hbox1), hbox_spc, FALSE, FALSE, 0);
92 gtk_widget_set_usize (hbox_spc, 12, -1);
94 label = gtk_label_new (_("Expire after"));
95 gtk_widget_show (label);
96 gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
98 store_tooltip = gtk_tooltips_new();
100 spinbtn_store_passphrase_adj = gtk_adjustment_new (0, 0, 1440, 1, 5, 5);
101 spinbtn_store_passphrase = gtk_spin_button_new
102 (GTK_ADJUSTMENT (spinbtn_store_passphrase_adj), 1, 0);
103 gtk_widget_show (spinbtn_store_passphrase);
104 gtk_tooltips_set_tip(GTK_TOOLTIPS(store_tooltip), spinbtn_store_passphrase,
105 _("Setting to '0' will store the passphrase"
106 " for the whole session"),
108 gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_store_passphrase, FALSE, FALSE, 0);
109 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_store_passphrase),
111 gtk_widget_set_usize (spinbtn_store_passphrase, 64, -1);
113 label = gtk_label_new (_("minute(s) "));
114 gtk_widget_show (label);
115 gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
117 hbox1 = gtk_hbox_new (FALSE, 8);
118 gtk_widget_show (hbox1);
119 gtk_box_pack_start (GTK_BOX (vbox3), hbox1, FALSE, FALSE, 0);
121 hbox_spc = gtk_hbox_new (FALSE, 0);
122 gtk_widget_show (hbox_spc);
123 gtk_box_pack_start (GTK_BOX (hbox1), hbox_spc, FALSE, FALSE, 0);
124 gtk_widget_set_usize (hbox_spc, 12, -1);
126 SET_TOGGLE_SENSITIVITY (checkbtn_store_passphrase, vbox3);
129 PACK_CHECK_BUTTON (vbox2, checkbtn_passphrase_grab,
130 _("Grab input while entering a passphrase"));
134 (vbox2, checkbtn_gpg_warning,
135 _("Display warning on startup if GnuPG doesn't work"));
137 hbox1 = gtk_hbox_new (FALSE, 8);
138 gtk_widget_show (hbox1);
139 gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
142 privacy.checkbtn_auto_check_signatures
143 = checkbtn_auto_check_signatures;
144 privacy.checkbtn_store_passphrase = checkbtn_store_passphrase;
145 privacy.spinbtn_store_passphrase = spinbtn_store_passphrase;
146 privacy.spinbtn_store_passphrase_adj = spinbtn_store_passphrase_adj;
147 privacy.checkbtn_passphrase_grab = checkbtn_passphrase_grab;
148 privacy.checkbtn_gpg_warning = checkbtn_gpg_warning;
152 GPGConfig *prefs_gpg_get_config(void)
157 void prefs_gpg_save_config(void)
162 debug_print("Saving GPGME config\n");
164 rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
165 pfile = prefs_write_open(rcpath);
167 if (!pfile || (prefs_set_block_label(pfile, "GPGME") < 0))
170 if (prefs_write_param(param, pfile->fp) < 0) {
171 g_warning("failed to write GPGME configuration to file\n");
172 prefs_file_close_revert(pfile);
175 fprintf(pfile->fp, "\n");
177 prefs_file_close(pfile);
180 void prefs_gpg_init()
182 prefs_set_default(param);
183 prefs_read_config(param, "GPGME", COMMON_RC);
186 void prefs_gpg_done()