pidgin/pidgin

442a78eea36e
Parents 359ad954dccc
Children 3dc779e621c5
Display a certificate request field in Pidgin and Finch by just using
the display string of the certificate in a label.
--- a/finch/gntrequest.c Sun Feb 26 03:38:28 2012 +0000
+++ b/finch/gntrequest.c Sun Feb 26 03:54:26 2012 +0000
@@ -571,6 +571,22 @@
return combo;
}
+static GntWidget*
+create_certificate_field(PurpleRequestField *field)
+{
+ GntWidget *w;
+ PurpleCertificate *cert;
+ char *str;
+
+ cert = purple_request_field_certificate_get_value(field);
+ str = purple_certificate_get_display_string(cert);
+ w = gnt_label_new(str);
+
+ g_free(str);
+
+ return w;
+}
+
static void *
finch_request_fields(const char *title, const char *primary,
const char *secondary, PurpleRequestFields *allfields,
@@ -650,6 +666,10 @@
accountlist = create_account_field(field);
purple_request_field_set_ui_data(field, accountlist);
}
+ else if (type == PURPLE_REQUEST_FIELD_CERTIFICATE)
+ {
+ purple_request_field_set_ui_data(field, create_certificate_field(field));
+ }
else
{
purple_request_field_set_ui_data(field, gnt_label_new_with_format(_("Not implemented yet."),
--- a/pidgin/gtkrequest.c Sun Feb 26 03:38:28 2012 +0000
+++ b/pidgin/gtkrequest.c Sun Feb 26 03:54:26 2012 +0000
@@ -1191,6 +1191,29 @@
return pidgin_make_scrollable(treeview, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC, GTK_SHADOW_IN, -1, -1);
}
+static GtkWidget *
+create_certificate_field(PurpleRequestField *field)
+{
+ GtkWidget *cert_label;
+ PurpleCertificate *cert;
+ char *str;
+ char *escaped;
+
+ cert = purple_request_field_certificate_get_value(field);
+ str = purple_certificate_get_display_string(cert);
+ escaped = g_markup_escape_text(str, -1);
+
+ cert_label = gtk_label_new(NULL);
+ gtk_label_set_markup(GTK_LABEL(cert_label), escaped);
+ gtk_label_set_line_wrap(GTK_LABEL(cert_label), TRUE);
+ gtk_misc_set_alignment(GTK_MISC(cert_label), 0, 0);
+
+ g_free(str);
+ g_free(escaped);
+
+ return cert_label;
+}
+
static void *
pidgin_request_fields(const char *title, const char *primary,
const char *secondary, PurpleRequestFields *fields,
@@ -1478,6 +1501,8 @@
widget = create_image_field(field);
else if (type == PURPLE_REQUEST_FIELD_ACCOUNT)
widget = create_account_field(field);
+ else if (type == PURPLE_REQUEST_FIELD_CERTIFICATE)
+ widget = create_certificate_field(field);
else
continue;
}