From 7789fb9e6646603ea84871d9c0858c12e376c804 Mon Sep 17 00:00:00 2001 From: Not Zed Date: Wed, 10 Dec 2003 05:29:06 +0000 Subject: use a POSITIVE value for the response value, gtk uses -ative ones. Bug 2003-12-10 Not Zed * em-folder-selector.h: use a POSITIVE value for the response value, gtk uses -ative ones. Bug #51752. * Makefile.am (INCLUDES): added smime/lib and smime/gui to includes. * em-folder-tree.c (emft_popup_rename_folder): removed unused 'why', why not? * em-format-html-display.c (efhd_xpkcs7mime_validity_clicked): setup a table of buttons to view any certs we have. * em-folder-browser.c (emfb_activate): separeate view_menu unreffing from view_instance. fixes a runtime warning. svn path=/trunk/; revision=23905 --- mail/em-format-html-display.c | 78 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) (limited to 'mail/em-format-html-display.c') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index 808f8d030e..47c0041ff3 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -73,6 +73,9 @@ #include #include +#include "certificate-viewer.h" +#include "e-cert-db.h" + #include "mail-config.h" #include "em-format-html-display.h" @@ -590,6 +593,7 @@ efhd_complete(EMFormat *emf) /* ********************************************************************** */ /* TODO: rename some of this stuff, it isn't 'smime' specific */ +/* TODO: move the dialogue elsehwere */ /* FIXME: also in em-format-html.c */ static const struct { const char *icon, *shortdesc, *description; @@ -634,6 +638,72 @@ efhd_xpkcs7mime_info_response(GtkWidget *w, guint button, struct _smime_pobject po->widget = NULL; } +static void +efhd_xpkcs7mime_viewcert_clicked(GtkWidget *button, struct _smime_pobject *po) +{ + CamelCipherCertInfo *info = g_object_get_data((GObject *)button, "e-cert-info"); + ECertDB *db = e_cert_db_peek(); + ECert *ec = NULL; + + if (info->email) + ec = e_cert_db_find_cert_by_email_address(db, info->email, NULL); + + if (ec == NULL && info->name) + ec = e_cert_db_find_cert_by_nickname(db, info->name, NULL); + + if (ec != NULL) { + GtkWidget *w = certificate_viewer_show(ec); + + if (w && po->widget) + gtk_window_set_transient_for((GtkWindow *)w, (GtkWindow *)po->widget); + + g_object_unref(ec); + } else { + g_warning("can't find certificate for %s <%s>", info->name?info->name:"", info->email?info->email:""); + } +} + +static void +efhd_xpkcs7mime_add_cert_table(GtkWidget *vbox, EDList *certlist, struct _smime_pobject *po) +{ + CamelCipherCertInfo *info = (CamelCipherCertInfo *)certlist->head; + GtkTable *table = (GtkTable *)gtk_table_new(e_dlist_length(certlist), 2, FALSE); + int n = 0; + + while (info->next) { + char *la = NULL; + const char *l = NULL; + + if (info->name) { + if (info->email && strcmp(info->name, info->email) != 0) + l = la = g_strdup_printf("%s <%s>", info->name, info->email); + else + l = info->name; + } else { + if (info->email) + l = info->email; + } + + if (l) { + GtkWidget *w; + + w = gtk_label_new(l); + gtk_misc_set_alignment((GtkMisc *)w, 0.0, 0.5); + g_free(la); + gtk_table_attach(table, w, 0, 1, n, n+1, GTK_FILL, GTK_FILL, 3, 3); + w = gtk_button_new_with_mnemonic(_("_View Certificate")); + gtk_table_attach(table, w, 1, 2, n, n+1, 0, 0, 3, 3); + g_object_set_data((GObject *)w, "e-cert-info", info); + g_signal_connect(w, "clicked", G_CALLBACK(efhd_xpkcs7mime_viewcert_clicked), po); + n++; + } + + info = info->next; + } + + gtk_box_pack_start((GtkBox *)vbox, (GtkWidget *)table, TRUE, TRUE, 6); +} + static void efhd_xpkcs7mime_validity_clicked(GtkWidget *button, EMFormatHTMLPObject *pobject) { @@ -659,6 +729,10 @@ efhd_xpkcs7mime_validity_clicked(GtkWidget *button, EMFormatHTMLPObject *pobject gtk_label_set_line_wrap((GtkLabel *)w, FALSE); gtk_box_pack_start((GtkBox *)vbox, w, TRUE, TRUE, 6); } + + if (!e_dlist_empty(&po->valid->sign.signers)) + efhd_xpkcs7mime_add_cert_table(vbox, &po->valid->sign.signers, po); + gtk_widget_show_all(vbox); vbox = glade_xml_get_widget(xml, "encryption_vbox"); @@ -672,6 +746,10 @@ efhd_xpkcs7mime_validity_clicked(GtkWidget *button, EMFormatHTMLPObject *pobject gtk_label_set_line_wrap((GtkLabel *)w, FALSE); gtk_box_pack_start((GtkBox *)vbox, w, TRUE, TRUE, 6); } + + if (!e_dlist_empty(&po->valid->encrypt.encrypters)) + efhd_xpkcs7mime_add_cert_table(vbox, &po->valid->encrypt.encrypters, po); + gtk_widget_show_all(vbox); g_object_unref(xml); -- cgit v1.2.3