Bug 792746 - Fails to build with ENABLE_SMIME set to OFF
[evolution.git] / src / mail / e-mail-config-security-page.c
blobebec0d062b7d904b464060a86604b05387a1172b
1 /*
2 * e-mail-config-security-page.c
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * for more details.
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program; if not, see <http://www.gnu.org/licenses/>.
18 #include "evolution-config.h"
20 #include <glib/gi18n-lib.h>
22 #include <e-util/e-util.h>
23 #include <libebackend/libebackend.h>
25 #if defined (ENABLE_SMIME)
26 #include <smime/gui/e-cert-selector.h>
27 #endif /* ENABLE_SMIME */
29 #ifdef HAVE_LIBCRYPTUI
30 #define LIBCRYPTUI_API_SUBJECT_TO_CHANGE
31 #include <libcryptui/cryptui.h>
32 #undef LIBCRYPTUI_API_SUBJECT_TO_CHANGE
33 #endif /* HAVE_LIBCRYPTUI */
35 #include "e-mail-config-security-page.h"
37 #define E_MAIL_CONFIG_SECURITY_PAGE_GET_PRIVATE(obj) \
38 (G_TYPE_INSTANCE_GET_PRIVATE \
39 ((obj), E_TYPE_MAIL_CONFIG_SECURITY_PAGE, EMailConfigSecurityPagePrivate))
41 struct _EMailConfigSecurityPagePrivate {
42 ESource *identity_source;
45 enum {
46 PROP_0,
47 PROP_IDENTITY_SOURCE
50 /* Forward Declarations */
51 static void e_mail_config_security_page_interface_init
52 (EMailConfigPageInterface *iface);
54 G_DEFINE_TYPE_WITH_CODE (
55 EMailConfigSecurityPage,
56 e_mail_config_security_page,
57 GTK_TYPE_SCROLLED_WINDOW,
58 G_IMPLEMENT_INTERFACE (
59 E_TYPE_EXTENSIBLE, NULL)
60 G_IMPLEMENT_INTERFACE (
61 E_TYPE_MAIL_CONFIG_PAGE,
62 e_mail_config_security_page_interface_init))
64 #ifdef ENABLE_SMIME
65 static void
66 mail_config_security_page_cert_selected (ECertSelector *selector,
67 const gchar *key,
68 GtkEntry *entry)
70 if (key != NULL)
71 gtk_entry_set_text (entry, key);
73 gtk_widget_destroy (GTK_WIDGET (selector));
76 static void
77 mail_config_security_page_select_encrypt_cert (GtkButton *button,
78 GtkEntry *entry)
80 GtkWidget *selector;
81 gpointer parent;
83 parent = gtk_widget_get_toplevel (GTK_WIDGET (button));
84 parent = GTK_IS_WIDGET (parent) ? parent : NULL;
86 selector = e_cert_selector_new (
87 E_CERT_SELECTOR_RECIPIENT,
88 gtk_entry_get_text (entry));
89 gtk_window_set_transient_for (
90 GTK_WINDOW (selector), parent);
91 gtk_widget_show (selector);
93 g_signal_connect (
94 selector, "selected",
95 G_CALLBACK (mail_config_security_page_cert_selected),
96 entry);
99 static void
100 mail_config_security_page_select_sign_cert (GtkButton *button,
101 GtkEntry *entry)
103 GtkWidget *selector;
104 gpointer parent;
106 parent = gtk_widget_get_toplevel (GTK_WIDGET (button));
107 parent = GTK_IS_WIDGET (parent) ? parent : NULL;
109 selector = e_cert_selector_new (
110 E_CERT_SELECTOR_SIGNER,
111 gtk_entry_get_text (entry));
112 gtk_window_set_transient_for (
113 GTK_WINDOW (selector), parent);
114 gtk_widget_show (selector);
116 g_signal_connect (
117 selector, "selected",
118 G_CALLBACK (mail_config_security_page_cert_selected),
119 entry);
122 static void
123 mail_config_security_page_clear_cert (GtkButton *button,
124 GtkEntry *entry)
126 gtk_entry_set_text (entry, "");
128 #endif /* ENABLE_SMIME */
130 static void
131 mail_config_security_page_set_identity_source (EMailConfigSecurityPage *page,
132 ESource *identity_source)
134 g_return_if_fail (E_IS_SOURCE (identity_source));
135 g_return_if_fail (page->priv->identity_source == NULL);
137 page->priv->identity_source = g_object_ref (identity_source);
140 static void
141 mail_config_security_page_set_property (GObject *object,
142 guint property_id,
143 const GValue *value,
144 GParamSpec *pspec)
146 switch (property_id) {
147 case PROP_IDENTITY_SOURCE:
148 mail_config_security_page_set_identity_source (
149 E_MAIL_CONFIG_SECURITY_PAGE (object),
150 g_value_get_object (value));
151 return;
154 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
157 static void
158 mail_config_security_page_get_property (GObject *object,
159 guint property_id,
160 GValue *value,
161 GParamSpec *pspec)
163 switch (property_id) {
164 case PROP_IDENTITY_SOURCE:
165 g_value_set_object (
166 value,
167 e_mail_config_security_page_get_identity_source (
168 E_MAIL_CONFIG_SECURITY_PAGE (object)));
169 return;
172 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
175 static void
176 mail_config_security_page_dispose (GObject *object)
178 EMailConfigSecurityPagePrivate *priv;
180 priv = E_MAIL_CONFIG_SECURITY_PAGE_GET_PRIVATE (object);
182 if (priv->identity_source != NULL) {
183 g_object_unref (priv->identity_source);
184 priv->identity_source = NULL;
187 /* Chain up to parent's dispose() method. */
188 G_OBJECT_CLASS (e_mail_config_security_page_parent_class)->
189 dispose (object);
192 #ifdef HAVE_LIBCRYPTUI
193 static GtkWidget *
194 mail_security_page_get_openpgpg_combo (void)
196 GtkWidget *widget;
197 GtkListStore *store;
198 CryptUIKeyset *keyset;
199 GtkCellRenderer *cell;
200 GList *keys, *kiter;
202 store = GTK_LIST_STORE (gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING));
204 keyset = cryptui_keyset_new ("openpgp", FALSE);
205 cryptui_keyset_set_expand_keys (keyset, TRUE);
207 keys = cryptui_keyset_get_keys (keyset);
208 for (kiter = keys; kiter; kiter = g_list_next (kiter)) {
209 const gchar *key = kiter->data;
210 guint flags;
212 flags = cryptui_keyset_key_flags (keyset, key);
214 if ((flags & CRYPTUI_FLAG_CAN_SIGN) != 0 &&
215 (flags & CRYPTUI_FLAG_IS_VALID) != 0 &&
216 (flags & (CRYPTUI_FLAG_EXPIRED | CRYPTUI_FLAG_REVOKED | CRYPTUI_FLAG_DISABLED)) == 0) {
217 gchar *keyid, *display_name, *display_id, *description;
219 keyid = cryptui_keyset_key_raw_keyid (keyset, key);
220 if (keyid && *keyid) {
221 GtkTreeIter iter;
223 display_name = cryptui_keyset_key_display_name (keyset, key);
224 display_id = cryptui_keyset_key_display_id (keyset, key);
226 if (!display_id || !*display_id) {
227 g_free (display_id);
228 display_id = g_strdup (keyid);
231 /* Translators: This string is to describe a PGP key in a combo box in mail account's preferences.
232 The first '%s' is a key ID, the second '%s' is a display name of the key. */
233 description = g_strdup_printf (C_("PGPKeyDescription", "%s — %s"), display_id, display_name);
235 gtk_list_store_append (store, &iter);
236 gtk_list_store_set (store, &iter,
237 0, keyid,
238 1, description,
239 -1);
241 g_free (display_name);
242 g_free (display_id);
243 g_free (description);
246 g_free (keyid);
250 g_list_free (keys);
251 g_object_unref (keyset);
253 widget = gtk_combo_box_new_with_model_and_entry (GTK_TREE_MODEL (store));
254 g_object_unref (store);
256 gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (widget), 0);
257 gtk_cell_layout_clear (GTK_CELL_LAYOUT (widget));
259 cell = gtk_cell_renderer_text_new ();
260 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (widget), cell, TRUE);
261 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (widget), cell, "text", 1, NULL);
263 return widget;
265 #endif /* HAVE_LIBCRYPTUI */
267 static void
268 mail_config_security_page_constructed (GObject *object)
270 EMailConfigSecurityPage *page;
271 ESource *source;
272 ESourceMailComposition *composition_ext;
273 ESourceOpenPGP *openpgp_ext;
274 GtkLabel *label;
275 GtkWidget *widget;
276 GtkWidget *container;
277 GtkWidget *main_box;
278 GtkSizeGroup *size_group;
279 const gchar *extension_name;
280 const gchar *text;
281 gchar *markup;
283 #if defined (ENABLE_SMIME)
284 ESourceSMIME *smime_ext;
285 GtkEntry *entry;
286 #endif /* ENABLE_SMIME */
288 page = E_MAIL_CONFIG_SECURITY_PAGE (object);
290 /* Chain up to parent's constructed() method. */
291 G_OBJECT_CLASS (e_mail_config_security_page_parent_class)->constructed (object);
293 source = e_mail_config_security_page_get_identity_source (page);
295 extension_name = E_SOURCE_EXTENSION_MAIL_COMPOSITION;
296 composition_ext = e_source_get_extension (source, extension_name);
298 extension_name = E_SOURCE_EXTENSION_OPENPGP;
299 openpgp_ext = e_source_get_extension (source, extension_name);
301 #if defined (ENABLE_SMIME)
302 extension_name = E_SOURCE_EXTENSION_SMIME;
303 smime_ext = e_source_get_extension (source, extension_name);
304 #endif /* ENABLE_SMIME */
306 main_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
308 size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
310 /*** General ***/
312 widget = gtk_grid_new ();
313 gtk_grid_set_row_spacing (GTK_GRID (widget), 6);
314 gtk_grid_set_column_spacing (GTK_GRID (widget), 6);
315 gtk_box_pack_start (GTK_BOX (main_box), widget, FALSE, FALSE, 0);
316 gtk_widget_show (widget);
318 container = widget;
320 text = _("General");
321 markup = g_markup_printf_escaped ("<b>%s</b>", text);
322 widget = gtk_label_new (markup);
323 gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
324 gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
325 gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 1, 1);
326 gtk_widget_show (widget);
327 g_free (markup);
329 text = _("_Do not sign meeting requests (for Outlook compatibility)");
330 widget = gtk_check_button_new_with_mnemonic (text);
331 gtk_widget_set_margin_left (widget, 12);
332 gtk_grid_attach (GTK_GRID (container), widget, 0, 1, 1, 1);
333 gtk_widget_show (widget);
335 e_binding_bind_property (
336 composition_ext, "sign-imip",
337 widget, "active",
338 G_BINDING_BIDIRECTIONAL |
339 G_BINDING_SYNC_CREATE);
341 /*** Pretty Good Privacy (OpenPGP) ***/
343 widget = gtk_grid_new ();
344 gtk_grid_set_row_spacing (GTK_GRID (widget), 6);
345 gtk_grid_set_column_spacing (GTK_GRID (widget), 6);
346 gtk_box_pack_start (GTK_BOX (main_box), widget, FALSE, FALSE, 0);
347 gtk_widget_show (widget);
349 container = widget;
351 text = _("Pretty Good Privacy (OpenPGP)");
352 markup = g_markup_printf_escaped ("<b>%s</b>", text);
353 widget = gtk_label_new (markup);
354 gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
355 gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
356 gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 2, 1);
357 gtk_widget_show (widget);
358 g_free (markup);
360 text = _("OpenPGP _Key ID:");
361 widget = gtk_label_new_with_mnemonic (text);
362 gtk_widget_set_margin_left (widget, 12);
363 gtk_size_group_add_widget (size_group, widget);
364 gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
365 gtk_grid_attach (GTK_GRID (container), widget, 0, 1, 1, 1);
366 gtk_widget_show (widget);
368 label = GTK_LABEL (widget);
370 #ifdef HAVE_LIBCRYPTUI
371 widget = mail_security_page_get_openpgpg_combo ();
372 #else /* HAVE_LIBCRYPTUI */
373 widget = gtk_entry_new ();
374 #endif /* HAVE_LIBCRYPTUI */
376 gtk_widget_set_hexpand (widget, TRUE);
377 gtk_label_set_mnemonic_widget (label, widget);
378 gtk_grid_attach (GTK_GRID (container), widget, 1, 1, 1, 1);
379 gtk_widget_show (widget);
381 #ifdef HAVE_LIBCRYPTUI
382 /* There's expected an entry, thus provide it. */
383 widget = gtk_bin_get_child (GTK_BIN (widget));
384 g_warn_if_fail (GTK_IS_ENTRY (widget));
385 #endif /* HAVE_LIBCRYPTUI */
387 e_binding_bind_object_text_property (
388 openpgp_ext, "key-id",
389 widget, "text",
390 G_BINDING_SYNC_CREATE |
391 G_BINDING_BIDIRECTIONAL);
393 text = _("Si_gning algorithm:");
394 widget = gtk_label_new_with_mnemonic (text);
395 gtk_widget_set_margin_left (widget, 12);
396 gtk_size_group_add_widget (size_group, widget);
397 gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
398 gtk_grid_attach (GTK_GRID (container), widget, 0, 2, 1, 1);
399 gtk_widget_show (widget);
401 label = GTK_LABEL (widget);
403 widget = gtk_combo_box_text_new ();
404 gtk_combo_box_text_append (
405 GTK_COMBO_BOX_TEXT (widget),
406 "", _("Default"));
407 gtk_combo_box_text_append (
408 GTK_COMBO_BOX_TEXT (widget),
409 "sha1", _("SHA1"));
410 gtk_combo_box_text_append (
411 GTK_COMBO_BOX_TEXT (widget),
412 "sha256", _("SHA256"));
413 gtk_combo_box_text_append (
414 GTK_COMBO_BOX_TEXT (widget),
415 "sha384", _("SHA384"));
416 gtk_combo_box_text_append (
417 GTK_COMBO_BOX_TEXT (widget),
418 "sha512", _("SHA512"));
419 gtk_widget_set_halign (widget, GTK_ALIGN_START);
420 gtk_label_set_mnemonic_widget (label, widget);
421 gtk_grid_attach (GTK_GRID (container), widget, 1, 2, 1, 1);
422 gtk_widget_show (widget);
424 e_binding_bind_property (
425 openpgp_ext, "signing-algorithm",
426 widget, "active-id",
427 G_BINDING_SYNC_CREATE |
428 G_BINDING_BIDIRECTIONAL);
430 /* Make sure the combo box has an active item. */
431 if (gtk_combo_box_get_active_id (GTK_COMBO_BOX (widget)) == NULL)
432 gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
434 text = _("Al_ways sign outgoing messages when using this account");
435 widget = gtk_check_button_new_with_mnemonic (text);
436 gtk_widget_set_margin_left (widget, 12);
437 gtk_grid_attach (GTK_GRID (container), widget, 0, 3, 2, 1);
438 gtk_widget_show (widget);
440 e_binding_bind_property (
441 openpgp_ext, "sign-by-default",
442 widget, "active",
443 G_BINDING_SYNC_CREATE |
444 G_BINDING_BIDIRECTIONAL);
446 text = _("Always enc_rypt outgoing messages when using this account");
447 widget = gtk_check_button_new_with_mnemonic (text);
448 gtk_widget_set_margin_left (widget, 12);
449 gtk_grid_attach (GTK_GRID (container), widget, 0, 4, 2, 1);
450 gtk_widget_show (widget);
452 e_binding_bind_property (
453 openpgp_ext, "encrypt-by-default",
454 widget, "active",
455 G_BINDING_SYNC_CREATE |
456 G_BINDING_BIDIRECTIONAL);
458 text = _("Always encrypt to _myself when sending encrypted messages");
459 widget = gtk_check_button_new_with_mnemonic (text);
460 gtk_widget_set_margin_left (widget, 12);
461 gtk_grid_attach (GTK_GRID (container), widget, 0, 5, 2, 1);
462 gtk_widget_show (widget);
464 e_binding_bind_property (
465 openpgp_ext, "encrypt-to-self",
466 widget, "active",
467 G_BINDING_SYNC_CREATE |
468 G_BINDING_BIDIRECTIONAL);
470 text = _("Always _trust keys in my keyring when encrypting");
471 widget = gtk_check_button_new_with_mnemonic (text);
472 gtk_widget_set_margin_left (widget, 12);
473 gtk_grid_attach (GTK_GRID (container), widget, 0, 6, 2, 1);
474 gtk_widget_show (widget);
476 e_binding_bind_property (
477 openpgp_ext, "always-trust",
478 widget, "active",
479 G_BINDING_SYNC_CREATE |
480 G_BINDING_BIDIRECTIONAL);
482 text = _("Prefer _inline sign/encrypt for plain text messages");
483 widget = gtk_check_button_new_with_mnemonic (text);
484 gtk_widget_set_margin_left (widget, 12);
485 gtk_grid_attach (GTK_GRID (container), widget, 0, 7, 2, 1);
486 gtk_widget_show (widget);
488 e_binding_bind_property (
489 openpgp_ext, "prefer-inline",
490 widget, "active",
491 G_BINDING_SYNC_CREATE |
492 G_BINDING_BIDIRECTIONAL);
494 #if defined (ENABLE_SMIME)
496 /*** Security MIME (S/MIME) ***/
498 widget = gtk_grid_new ();
499 gtk_grid_set_row_spacing (GTK_GRID (widget), 6);
500 gtk_grid_set_column_spacing (GTK_GRID (widget), 6);
501 gtk_box_pack_start (GTK_BOX (main_box), widget, FALSE, FALSE, 0);
502 gtk_widget_show (widget);
504 container = widget;
506 text = _("Secure MIME (S/MIME)");
507 markup = g_markup_printf_escaped ("<b>%s</b>", text);
508 widget = gtk_label_new (markup);
509 gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
510 gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
511 gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 4, 1);
512 gtk_widget_show (widget);
513 g_free (markup);
515 text = _("Sig_ning certificate:");
516 widget = gtk_label_new_with_mnemonic (text);
517 gtk_widget_set_margin_left (widget, 12);
518 gtk_size_group_add_widget (size_group, widget);
519 gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
520 gtk_grid_attach (GTK_GRID (container), widget, 0, 1, 1, 1);
521 gtk_widget_show (widget);
523 label = GTK_LABEL (widget);
525 widget = gtk_entry_new ();
526 gtk_widget_set_hexpand (widget, TRUE);
527 gtk_label_set_mnemonic_widget (label, widget);
528 gtk_grid_attach (GTK_GRID (container), widget, 1, 1, 1, 1);
529 gtk_widget_show (widget);
531 e_binding_bind_object_text_property (
532 smime_ext, "signing-certificate",
533 widget, "text",
534 G_BINDING_BIDIRECTIONAL |
535 G_BINDING_SYNC_CREATE);
537 entry = GTK_ENTRY (widget);
539 widget = gtk_button_new_with_label (_("Select"));
540 gtk_grid_attach (GTK_GRID (container), widget, 2, 1, 1, 1);
541 gtk_widget_show (widget);
543 g_signal_connect (
544 widget, "clicked",
545 G_CALLBACK (mail_config_security_page_select_sign_cert),
546 entry);
548 widget = e_dialog_button_new_with_icon ("edit-clear", _("_Clear"));
549 gtk_grid_attach (GTK_GRID (container), widget, 3, 1, 1, 1);
550 gtk_widget_show (widget);
552 g_signal_connect (
553 widget, "clicked",
554 G_CALLBACK (mail_config_security_page_clear_cert),
555 entry);
557 text = _("Signing _algorithm:");
558 widget = gtk_label_new_with_mnemonic (text);
559 gtk_widget_set_margin_left (widget, 12);
560 gtk_size_group_add_widget (size_group, widget);
561 gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
562 gtk_grid_attach (GTK_GRID (container), widget, 0, 2, 1, 1);
563 gtk_widget_show (widget);
565 label = GTK_LABEL (widget);
567 widget = gtk_combo_box_text_new ();
568 gtk_combo_box_text_append (
569 GTK_COMBO_BOX_TEXT (widget),
570 "", _("Default"));
571 gtk_combo_box_text_append (
572 GTK_COMBO_BOX_TEXT (widget),
573 "sha1", _("SHA1"));
574 gtk_combo_box_text_append (
575 GTK_COMBO_BOX_TEXT (widget),
576 "sha256", _("SHA256"));
577 gtk_combo_box_text_append (
578 GTK_COMBO_BOX_TEXT (widget),
579 "sha384", _("SHA384"));
580 gtk_combo_box_text_append (
581 GTK_COMBO_BOX_TEXT (widget),
582 "sha512", _("SHA512"));
583 gtk_widget_set_halign (widget, GTK_ALIGN_START);
584 gtk_label_set_mnemonic_widget (label, widget);
585 gtk_grid_attach (GTK_GRID (container), widget, 1, 2, 1, 1);
586 gtk_widget_show (widget);
588 e_binding_bind_property (
589 smime_ext, "signing-algorithm",
590 widget, "active-id",
591 G_BINDING_SYNC_CREATE |
592 G_BINDING_BIDIRECTIONAL);
594 /* Make sure the combo box has an active item. */
595 if (gtk_combo_box_get_active_id (GTK_COMBO_BOX (widget)) == NULL)
596 gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
598 text = _("Always sign outgoing messages when using this account");
599 widget = gtk_check_button_new_with_mnemonic (text);
600 gtk_widget_set_margin_left (widget, 12);
601 gtk_grid_attach (GTK_GRID (container), widget, 0, 3, 4, 1);
602 gtk_widget_show (widget);
604 e_binding_bind_property (
605 smime_ext, "sign-by-default",
606 widget, "active",
607 G_BINDING_SYNC_CREATE |
608 G_BINDING_BIDIRECTIONAL);
610 /* Add extra padding between signing stuff and encryption stuff. */
611 gtk_widget_set_margin_bottom (widget, 6);
613 text = _("Encryption certificate:");
614 widget = gtk_label_new_with_mnemonic (text);
615 gtk_widget_set_margin_left (widget, 12);
616 gtk_size_group_add_widget (size_group, widget);
617 gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
618 gtk_grid_attach (GTK_GRID (container), widget, 0, 4, 1, 1);
619 gtk_widget_show (widget);
621 label = GTK_LABEL (widget);
623 widget = gtk_entry_new ();
624 gtk_widget_set_hexpand (widget, TRUE);
625 gtk_label_set_mnemonic_widget (label, widget);
626 gtk_grid_attach (GTK_GRID (container), widget, 1, 4, 1, 1);
627 gtk_widget_show (widget);
629 e_binding_bind_object_text_property (
630 smime_ext, "encryption-certificate",
631 widget, "text",
632 G_BINDING_BIDIRECTIONAL |
633 G_BINDING_SYNC_CREATE);
635 entry = GTK_ENTRY (widget);
637 widget = gtk_button_new_with_label (_("Select"));
638 gtk_grid_attach (GTK_GRID (container), widget, 2, 4, 1, 1);
639 gtk_widget_show (widget);
641 g_signal_connect (
642 widget, "clicked",
643 G_CALLBACK (mail_config_security_page_select_encrypt_cert),
644 entry);
646 widget = e_dialog_button_new_with_icon ("edit-clear", _("_Clear"));
647 gtk_grid_attach (GTK_GRID (container), widget, 3, 4, 1, 1);
648 gtk_widget_show (widget);
650 g_signal_connect (
651 widget, "clicked",
652 G_CALLBACK (mail_config_security_page_clear_cert),
653 entry);
655 text = _("Always encrypt outgoing messages when using this account");
656 widget = gtk_check_button_new_with_mnemonic (text);
657 gtk_widget_set_margin_left (widget, 12);
658 gtk_grid_attach (GTK_GRID (container), widget, 0, 5, 4, 1);
659 gtk_widget_show (widget);
661 e_binding_bind_property (
662 smime_ext, "encrypt-by-default",
663 widget, "active",
664 G_BINDING_SYNC_CREATE |
665 G_BINDING_BIDIRECTIONAL);
667 text = _("Always encrypt to myself when sending encrypted messages");
668 widget = gtk_check_button_new_with_mnemonic (text);
669 gtk_widget_set_margin_left (widget, 12);
670 gtk_grid_attach (GTK_GRID (container), widget, 0, 6, 4, 1);
671 gtk_widget_show (widget);
673 e_binding_bind_property (
674 smime_ext, "encrypt-to-self",
675 widget, "active",
676 G_BINDING_SYNC_CREATE |
677 G_BINDING_BIDIRECTIONAL);
679 #endif /* ENABLE_SMIME */
681 g_object_unref (size_group);
683 e_mail_config_page_set_content (E_MAIL_CONFIG_PAGE (page), main_box);
685 e_extensible_load_extensions (E_EXTENSIBLE (page));
688 static void
689 e_mail_config_security_page_class_init (EMailConfigSecurityPageClass *class)
691 GObjectClass *object_class;
693 g_type_class_add_private (
694 class, sizeof (EMailConfigSecurityPagePrivate));
696 object_class = G_OBJECT_CLASS (class);
697 object_class->set_property = mail_config_security_page_set_property;
698 object_class->get_property = mail_config_security_page_get_property;
699 object_class->dispose = mail_config_security_page_dispose;
700 object_class->constructed = mail_config_security_page_constructed;
702 g_object_class_install_property (
703 object_class,
704 PROP_IDENTITY_SOURCE,
705 g_param_spec_object (
706 "identity-source",
707 "Identity Source",
708 "Mail identity source being edited",
709 E_TYPE_SOURCE,
710 G_PARAM_READWRITE |
711 G_PARAM_CONSTRUCT_ONLY |
712 G_PARAM_STATIC_STRINGS));
715 static void
716 e_mail_config_security_page_interface_init (EMailConfigPageInterface *iface)
718 iface->title = _("Security");
719 iface->sort_order = E_MAIL_CONFIG_SECURITY_PAGE_SORT_ORDER;
722 static void
723 e_mail_config_security_page_init (EMailConfigSecurityPage *page)
725 page->priv = E_MAIL_CONFIG_SECURITY_PAGE_GET_PRIVATE (page);
728 EMailConfigPage *
729 e_mail_config_security_page_new (ESource *identity_source)
731 g_return_val_if_fail (E_IS_SOURCE (identity_source), NULL);
733 return g_object_new (
734 E_TYPE_MAIL_CONFIG_SECURITY_PAGE,
735 "identity-source", identity_source, NULL);
738 ESource *
739 e_mail_config_security_page_get_identity_source (EMailConfigSecurityPage *page)
741 g_return_val_if_fail (E_IS_MAIL_CONFIG_SECURITY_PAGE (page), NULL);
743 return page->priv->identity_source;