[seahorse] Make the properties viewer work for keys and certificates.



commit 27a2ede548cab9f035a542d4b052a12d652716bf
Author: Stef Walter <stefw collabora co uk>
Date:   Mon Nov 7 09:49:02 2011 +0100

    Make the properties viewer work for keys and certificates.

 pkcs11/Makefile.am                         |    2 +-
 pkcs11/seahorse-certificate.c              |   42 ++++--
 pkcs11/seahorse-certificate.h              |    6 +-
 pkcs11/seahorse-pkcs11-actions.c           |   32 +----
 pkcs11/seahorse-pkcs11-certificate-props.c |  228 -------------------------
 pkcs11/seahorse-pkcs11-certificate-props.h |   75 --------
 pkcs11/seahorse-pkcs11-properties.c        |  251 ++++++++++++++++++++++++++++
 pkcs11/seahorse-pkcs11-properties.h        |   45 +++++
 pkcs11/seahorse-private-key.c              |   20 +-
 pkcs11/seahorse-private-key.h              |    4 +-
 pkcs11/seahorse-token.c                    |   16 +-
 11 files changed, 354 insertions(+), 367 deletions(-)
---
diff --git a/pkcs11/Makefile.am b/pkcs11/Makefile.am
index c9ab464..118a340 100644
--- a/pkcs11/Makefile.am
+++ b/pkcs11/Makefile.am
@@ -19,9 +19,9 @@ libseahorse_pkcs11_la_SOURCES = \
 	seahorse-interaction.c seahorse-interaction.h \
 	seahorse-pkcs11-actions.c seahorse-pkcs11-actions.h \
 	seahorse-pkcs11-backend.c seahorse-pkcs11-backend.h \
-	seahorse-pkcs11-certificate-props.c seahorse-pkcs11-certificate-props.h \
 	seahorse-pkcs11-helpers.c seahorse-pkcs11-helpers.h \
 	seahorse-pkcs11-operations.c seahorse-pkcs11-operations.h \
+	seahorse-pkcs11-properties.c seahorse-pkcs11-properties.h \
 	seahorse-pkcs11.c seahorse-pkcs11.h \
 	seahorse-private-key.c seahorse-private-key.h \
 	seahorse-token.c seahorse-token.h
diff --git a/pkcs11/seahorse-certificate.c b/pkcs11/seahorse-certificate.c
index 9572189..8538089 100644
--- a/pkcs11/seahorse-certificate.c
+++ b/pkcs11/seahorse-certificate.c
@@ -51,8 +51,10 @@ enum {
 	PROP_ATTRIBUTES,
 	PROP_FLAGS,
 	PROP_ACTIONS,
+	PROP_PARTNER,
+
 	PROP_ICON,
-	PROP_PRIVATE_KEY
+	PROP_DESCRIPTION
 };
 
 struct _SeahorseCertificatePrivate {
@@ -160,11 +162,14 @@ seahorse_certificate_get_property (GObject *obj,
 	case PROP_ACTIONS:
 		g_value_set_object (value, self->pv->actions);
 		break;
+	case PROP_PARTNER:
+		g_value_set_object (value, seahorse_certificate_get_partner (self));
+		break;
 	case PROP_ICON:
 		g_value_set_object (value, seahorse_certificate_get_icon (self));
 		break;
-	case PROP_PRIVATE_KEY:
-		g_value_set_object (value, seahorse_certificate_get_private_key (self));
+	case PROP_DESCRIPTION:
+		g_value_set_string (value, seahorse_certificate_get_description (self));
 		break;
 	default:
 		gcr_certificate_mixin_get_property (obj, prop_id, value, pspec);
@@ -203,8 +208,8 @@ seahorse_certificate_set_property (GObject *obj,
 			gck_attribute_init_copy (&self->pv->der_value, der_value);
 		}
 		break;
-	case PROP_PRIVATE_KEY:
-		seahorse_certificate_set_private_key (self, g_value_get_object (value));
+	case PROP_PARTNER:
+		seahorse_certificate_set_partner (self, g_value_get_object (value));
 		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
@@ -237,13 +242,15 @@ seahorse_certificate_class_init (SeahorseCertificateClass *klass)
 	         g_param_spec_object ("actions", "Actions", "Actions", GTK_TYPE_ACTION_GROUP,
 	                              G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
 
-	g_object_class_install_property (gobject_class, PROP_PRIVATE_KEY,
-	            g_param_spec_object ("private-key", "Private key", "Private key associated with certificate",
+	g_object_class_install_property (gobject_class, PROP_PARTNER,
+	            g_param_spec_object ("partner", "Partner", "Private key associated with certificate",
 	                                 SEAHORSE_TYPE_PRIVATE_KEY, G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE));
 
-	g_object_class_override_property (gobject_class, PROP_ICON, "icon");
 	g_object_class_override_property (gobject_class, PROP_ATTRIBUTES, "attributes");
 
+	g_object_class_override_property (gobject_class, PROP_ICON, "icon");
+	g_object_class_override_property (gobject_class, PROP_DESCRIPTION, "description");
+
 	gcr_certificate_mixin_class_init (gobject_class);
 }
 
@@ -282,16 +289,27 @@ seahorse_certificate_get_icon (SeahorseCertificate *self)
 	return self->pv->icon;
 }
 
+const gchar *
+seahorse_certificate_get_description (SeahorseCertificate *self)
+{
+	g_return_val_if_fail (SEAHORSE_IS_CERTIFICATE (self), NULL);
+
+	if (self->pv->private_key)
+		return _("Certificate and Key");
+
+	return _("Certificate");
+}
+
 SeahorsePrivateKey *
-seahorse_certificate_get_private_key (SeahorseCertificate *self)
+seahorse_certificate_get_partner (SeahorseCertificate *self)
 {
 	g_return_val_if_fail (SEAHORSE_IS_CERTIFICATE (self), NULL);
 	return self->pv->private_key;
 }
 
 void
-seahorse_certificate_set_private_key (SeahorseCertificate *self,
-                                      SeahorsePrivateKey *private_key)
+seahorse_certificate_set_partner (SeahorseCertificate *self,
+                                  SeahorsePrivateKey *private_key)
 {
 	GObject *obj;
 
@@ -307,7 +325,7 @@ seahorse_certificate_set_private_key (SeahorseCertificate *self,
 		                           (gpointer *)self->pv->private_key);
 
 	obj = G_OBJECT (self);
-	g_object_notify (obj, "private-key");
+	g_object_notify (obj, "partner");
 	g_clear_object (&self->pv->icon);
 	g_object_notify (obj, "icon");
 	g_object_notify (obj, "description");
diff --git a/pkcs11/seahorse-certificate.h b/pkcs11/seahorse-certificate.h
index f6f4d8e..1c5429d 100644
--- a/pkcs11/seahorse-certificate.h
+++ b/pkcs11/seahorse-certificate.h
@@ -51,9 +51,11 @@ GType                 seahorse_certificate_get_type               (void) G_GNUC_
 
 GIcon *               seahorse_certificate_get_icon               (SeahorseCertificate *self);
 
-SeahorsePrivateKey *  seahorse_certificate_get_private_key        (SeahorseCertificate *self);
+const gchar *         seahorse_certificate_get_description        (SeahorseCertificate *self);
 
-void                  seahorse_certificate_set_private_key        (SeahorseCertificate *self,
+SeahorsePrivateKey *  seahorse_certificate_get_partner            (SeahorseCertificate *self);
+
+void                  seahorse_certificate_set_partner            (SeahorseCertificate *self,
                                                                    SeahorsePrivateKey *private_key);
 
 #endif /* __SEAHORSE_CERTIFICATE_H__ */
diff --git a/pkcs11/seahorse-pkcs11-actions.c b/pkcs11/seahorse-pkcs11-actions.c
index a5a0bec..472ce09 100644
--- a/pkcs11/seahorse-pkcs11-actions.c
+++ b/pkcs11/seahorse-pkcs11-actions.c
@@ -27,7 +27,7 @@
 #include "seahorse-certificate.h"
 #include "seahorse-interaction.h"
 #include "seahorse-pkcs11.h"
-#include "seahorse-pkcs11-certificate-props.h"
+#include "seahorse-pkcs11-properties.h"
 #include "seahorse-pkcs11-operations.h"
 #include "seahorse-token.h"
 
@@ -190,44 +190,19 @@ typedef struct {
 	SeahorseActionsClass parent_class;
 } SeahorsePkcs11ObjectActionsClass;
 
-static GQuark QUARK_WINDOW = 0;
-
 G_DEFINE_TYPE (SeahorsePkcs11ObjectActions, seahorse_pkcs11_object_actions, SEAHORSE_TYPE_ACTIONS);
 
 static void
-properties_response (GtkDialog *dialog, gint response_id, gpointer user_data)
-{
-	gtk_widget_destroy (GTK_WIDGET (dialog));
-}
-
-static void
 on_show_properties (GtkAction *action,
                     gpointer user_data)
 {
 	GtkWindow *window;
-	gpointer previous;
 	GObject *object;
 
-	object = G_OBJECT (user_data);
-
-	/* Try to show an already present window */
-	previous = g_object_get_qdata (object, QUARK_WINDOW);
-	if (GTK_IS_WINDOW (previous)) {
-		window = GTK_WINDOW (previous);
-		if (gtk_widget_get_visible (GTK_WIDGET (window))) {
-			gtk_window_present (window);
-			return;
-		}
-	}
-
 	/* Create a new dialog for the certificate */
-	window = GTK_WINDOW (seahorse_pkcs11_certificate_props_new (GCR_CERTIFICATE (object)));
-	gtk_window_set_transient_for (window, seahorse_action_get_window (action));
-	g_object_set_qdata (G_OBJECT (object), QUARK_WINDOW, window);
+	object = G_OBJECT (user_data);
+	window = seahorse_pkcs11_properties_show (object, seahorse_action_get_window (action));
 	gtk_widget_show (GTK_WIDGET (window));
-
-	/* Close the window when we get a response */
-	g_signal_connect (window, "response", G_CALLBACK (properties_response), NULL);
 }
 
 static void
@@ -329,7 +304,6 @@ static void
 seahorse_pkcs11_object_actions_class_init (SeahorsePkcs11ObjectActionsClass *klass)
 {
 	SeahorseActionsClass *actions_class = SEAHORSE_ACTIONS_CLASS (klass);
-	QUARK_WINDOW = g_quark_from_static_string ("seahorse-pkcs11-actions-window");
 	actions_class->clone_for_objects = seahorse_pkcs11_object_actions_clone_for_objects;
 }
 
diff --git a/pkcs11/seahorse-pkcs11-properties.c b/pkcs11/seahorse-pkcs11-properties.c
new file mode 100644
index 0000000..fcb81d3
--- /dev/null
+++ b/pkcs11/seahorse-pkcs11-properties.c
@@ -0,0 +1,251 @@
+/*
+ * Seahorse
+ *
+ * Copyright (C) 2008 Stefan Walter
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include "seahorse-certificate.h"
+#include "seahorse-pkcs11-properties.h"
+
+#include <gcr/gcr.h>
+
+#define SEAHORSE_PKCS11_PROPERTIES_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST ((klass), SEAHORSE_TYPE_PKCS11_PROPERTIES, SeahorsePkcs11PropertiesClass))
+#define SEAHORSE_IS_PKCS11_PROPERTIES_CLASS(klass)    (G_TYPE_CHECK_CLASS_TYPE ((klass), SEAHORSE_TYPE_PKCS11_PROPERTIES))
+#define SEAHORSE_PKCS11_PROPERTIES_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), SEAHORSE_TYPE_PKCS11_PROPERTIES, SeahorsePkcs11PropertiesClass))
+
+typedef struct _SeahorsePkcs11PropertiesClass SeahorsePkcs11PropertiesClass;
+
+struct _SeahorsePkcs11Properties {
+	GtkWindow parent;
+	GcrViewer *viewer;
+	GObject *object;
+};
+
+struct _SeahorsePkcs11PropertiesClass {
+	GtkWindowClass parent_class;
+};
+
+enum {
+	PROP_0,
+	PROP_OBJECT
+};
+
+static GQuark QUARK_WINDOW = 0;
+
+G_DEFINE_TYPE (SeahorsePkcs11Properties, seahorse_pkcs11_properties, GTK_TYPE_WINDOW);
+
+static void
+seahorse_pkcs11_properties_init (SeahorsePkcs11Properties *self)
+{
+	GtkWidget *viewer;
+
+	gtk_window_set_default_size (GTK_WINDOW (self), 400, 400);
+
+	self->viewer = gcr_viewer_new_scrolled ();
+	viewer = GTK_WIDGET (self->viewer);
+	gtk_container_add (GTK_CONTAINER (self), viewer);
+	gtk_widget_set_hexpand (viewer, TRUE);
+	gtk_widget_set_vexpand (viewer, TRUE);
+	gtk_widget_show (viewer);
+}
+
+static void
+add_renderer_for_object (SeahorsePkcs11Properties *self,
+                         GObject *object)
+{
+	GckAttributes *attributes = NULL;
+	GcrRenderer *renderer;
+	gchar *label = NULL;
+
+	g_object_get (object, "label", &label, "attributes", &attributes, NULL);
+	if (attributes != NULL) {
+		renderer = gcr_renderer_create (label, attributes);
+		if (renderer) {
+			g_object_bind_property (object, "label",
+			                        renderer, "label",
+			                        G_BINDING_DEFAULT);
+			g_object_bind_property (object, "attributes",
+			                        renderer, "attributes",
+			                        G_BINDING_DEFAULT);
+
+			gcr_viewer_add_renderer (self->viewer, renderer);
+			g_object_unref (renderer);
+		}
+		gck_attributes_unref (attributes);
+	}
+
+	g_free (label);
+}
+
+static void
+on_object_label_changed (GObject *obj,
+                         GParamSpec *spec,
+                         gpointer user_data)
+{
+	SeahorsePkcs11Properties *self = SEAHORSE_PKCS11_PROPERTIES (user_data);
+	gchar *description = NULL;
+	gchar *label = NULL;
+	gchar *title;
+
+	g_object_get (obj, "label", &label, "description", &description, NULL);
+	if (label && !label[0]) {
+		g_free (label);
+		label = NULL;
+		label = _("Unnamed");
+	}
+
+	title = g_strdup_printf ("%s - %s",
+	                         label ? label : _("Unnamed"),
+	                         description);
+
+	g_free (label);
+	g_free (description);
+
+	gtk_window_set_title (GTK_WINDOW (self), title);
+	g_free (title);
+}
+
+static void
+seahorse_pkcs11_properties_constructed (GObject *obj)
+{
+	SeahorsePkcs11Properties *self = SEAHORSE_PKCS11_PROPERTIES (obj);
+	GObject *partner = NULL;
+
+	G_OBJECT_CLASS (seahorse_pkcs11_properties_parent_class)->constructed (obj);
+
+	g_return_if_fail (self->object != NULL);
+	g_object_set_qdata (self->object, QUARK_WINDOW, self);
+
+	g_signal_connect (self->object, "notify::label", G_CALLBACK (on_object_label_changed), self);
+	on_object_label_changed (self->object, NULL, self);
+
+	add_renderer_for_object (self, self->object);
+
+	g_object_get (self->object, "partner", &partner, NULL);
+	if (partner != NULL) {
+		add_renderer_for_object (self, partner);
+		g_object_unref (partner);
+	}
+}
+
+static void
+seahorse_pkcs11_properties_set_property (GObject *obj,
+                                         guint prop_id,
+                                         const GValue *value,
+                                         GParamSpec *pspec)
+{
+	SeahorsePkcs11Properties *self = SEAHORSE_PKCS11_PROPERTIES (obj);
+
+	switch (prop_id) {
+	case PROP_OBJECT:
+		g_return_if_fail (self->object == NULL);
+		self->object = g_value_dup_object (value);
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+		break;
+	}
+}
+
+static void
+seahorse_pkcs11_properties_get_property (GObject *obj,
+                                         guint prop_id,
+                                         GValue *value,
+                                         GParamSpec *pspec)
+{
+	SeahorsePkcs11Properties *self = SEAHORSE_PKCS11_PROPERTIES (obj);
+
+	switch (prop_id) {
+	case PROP_OBJECT:
+		g_value_set_object (value, seahorse_pkcs11_properties_get_object (self));
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+		break;
+	}
+}
+
+static void
+seahorse_pkcs11_properties_finalize (GObject *obj)
+{
+	SeahorsePkcs11Properties *self = SEAHORSE_PKCS11_PROPERTIES (obj);
+
+	if (self->object) {
+		if (g_object_get_qdata (self->object, QUARK_WINDOW) == self)
+			g_object_set_qdata (self->object, QUARK_WINDOW, NULL);
+	}
+
+	g_clear_object (&self->object);
+
+	G_OBJECT_CLASS (seahorse_pkcs11_properties_parent_class)->finalize (obj);
+}
+
+static void
+seahorse_pkcs11_properties_class_init (SeahorsePkcs11PropertiesClass *klass)
+{
+	GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+	seahorse_pkcs11_properties_parent_class = g_type_class_peek_parent (klass);
+
+	gobject_class->constructed = seahorse_pkcs11_properties_constructed;
+	gobject_class->set_property = seahorse_pkcs11_properties_set_property;
+	gobject_class->get_property = seahorse_pkcs11_properties_get_property;
+	gobject_class->finalize = seahorse_pkcs11_properties_finalize;
+
+	g_object_class_install_property (gobject_class, PROP_OBJECT,
+	           g_param_spec_object ("object", "Object", "Certificate or key to display", G_TYPE_OBJECT,
+	                                G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+	QUARK_WINDOW = g_quark_from_static_string ("seahorse-pkcs11-properties-window");
+}
+
+/* -----------------------------------------------------------------------------
+ * PUBLIC
+ */
+
+GtkWindow *
+seahorse_pkcs11_properties_show (GObject  *object,
+                                 GtkWindow *parent)
+{
+	GObject *previous;
+	GtkWindow *window;
+
+	/* Try to show an already present window */
+	previous = g_object_get_qdata (object, QUARK_WINDOW);
+	if (GTK_IS_WINDOW (previous)) {
+		window = GTK_WINDOW (previous);
+		if (gtk_widget_get_visible (GTK_WIDGET (window))) {
+			gtk_window_present (window);
+			return window;
+		}
+	}
+
+	return g_object_new (SEAHORSE_TYPE_PKCS11_PROPERTIES,
+	                     "object", object,
+	                     "transient-for", parent,
+	                     NULL);
+}
+
+GObject *
+seahorse_pkcs11_properties_get_object (SeahorsePkcs11Properties *self)
+{
+	g_return_val_if_fail (SEAHORSE_IS_PKCS11_PROPERTIES (self), NULL);
+	return self->object;
+}
diff --git a/pkcs11/seahorse-pkcs11-properties.h b/pkcs11/seahorse-pkcs11-properties.h
new file mode 100644
index 0000000..4dce342
--- /dev/null
+++ b/pkcs11/seahorse-pkcs11-properties.h
@@ -0,0 +1,45 @@
+/* 
+ * Seahorse
+ * 
+ * Copyright (C) 2008 Stefan Walter
+ * 
+ * This program is free software; you can redistribute it and/or modify 
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *  
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *  
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.  
+ */
+
+#ifndef __SEAHORSE_PKCS11_PROPERTIES_H__
+#define __SEAHORSE_PKCS11_PROPERTIES_H__
+
+#include <gcr/gcr.h>
+
+#include <gtk/gtk.h>
+
+#include <glib-object.h>
+#include <glib/gi18n.h>
+
+#define SEAHORSE_TYPE_PKCS11_PROPERTIES               (seahorse_pkcs11_properties_get_type ())
+#define SEAHORSE_PKCS11_PROPERTIES(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAHORSE_TYPE_PKCS11_PROPERTIES, SeahorsePkcs11Properties))
+#define SEAHORSE_IS_PKCS11_PROPERTIES(obj)            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SEAHORSE_TYPE_PKCS11_PROPERTIES))
+
+typedef struct _SeahorsePkcs11Properties SeahorsePkcs11Properties;
+
+GType            seahorse_pkcs11_properties_get_type            (void);
+
+GtkWindow *      seahorse_pkcs11_properties_show                (GObject *object,
+                                                                 GtkWindow *parent);
+
+GObject *        seahorse_pkcs11_properties_get_object          (SeahorsePkcs11Properties *self);
+
+#endif /* __SEAHORSE_PKCS11_PROPERTIES_H__ */
diff --git a/pkcs11/seahorse-private-key.c b/pkcs11/seahorse-private-key.c
index f1d52df..4206657 100644
--- a/pkcs11/seahorse-private-key.c
+++ b/pkcs11/seahorse-private-key.c
@@ -51,7 +51,7 @@ enum {
 	PROP_ATTRIBUTES,
 	PROP_FLAGS,
 	PROP_ACTIONS,
-	PROP_CERTIFICATE,
+	PROP_PARTNER,
 
 	PROP_LABEL,
 	PROP_MARKUP,
@@ -147,8 +147,8 @@ seahorse_private_key_get_property (GObject *obj,
 	case PROP_ACTIONS:
 		g_value_set_object (value, self->pv->actions);
 		break;
-	case PROP_CERTIFICATE:
-		g_value_set_object (value, seahorse_private_key_get_certificate (self));
+	case PROP_PARTNER:
+		g_value_set_object (value, seahorse_private_key_get_partner (self));
 		break;
 	case PROP_LABEL:
 		g_value_take_string (value, calculate_label (self));
@@ -191,8 +191,8 @@ seahorse_private_key_set_property (GObject *obj,
 			gck_attributes_unref (self->pv->attributes);
 		self->pv->attributes = g_value_dup_boxed (value);
 		break;
-	case PROP_CERTIFICATE:
-		seahorse_private_key_set_certificate (self, g_value_get_object (value));
+	case PROP_PARTNER:
+		seahorse_private_key_set_partner (self, g_value_get_object (value));
 		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
@@ -223,8 +223,8 @@ seahorse_private_key_class_init (SeahorsePrivateKeyClass *klass)
 	         g_param_spec_object ("actions", "Actions", "Actions", GTK_TYPE_ACTION_GROUP,
 	                              G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
 
-	g_object_class_install_property (gobject_class, PROP_CERTIFICATE,
-	            g_param_spec_object ("certificate", "Certificate", "Certificate associated with this private key",
+	g_object_class_install_property (gobject_class, PROP_PARTNER,
+	            g_param_spec_object ("partner", "Partner", "Certificate associated with this private key",
 	                                 SEAHORSE_TYPE_CERTIFICATE, G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE));
 
 	g_object_class_install_property (gobject_class, PROP_LABEL,
@@ -254,7 +254,7 @@ seahorse_private_key_object_attributes_iface (GckObjectAttributesIface *iface)
 }
 
 SeahorseCertificate *
-seahorse_private_key_get_certificate (SeahorsePrivateKey *self)
+seahorse_private_key_get_partner (SeahorsePrivateKey *self)
 {
 	g_return_val_if_fail (SEAHORSE_IS_PRIVATE_KEY (self), NULL);
 	return self->pv->certificate;
@@ -263,7 +263,7 @@ seahorse_private_key_get_certificate (SeahorsePrivateKey *self)
 static void
 notify_certificate_change (GObject *obj)
 {
-	g_object_notify (obj, "certificate");
+	g_object_notify (obj, "partner");
 	g_object_notify (obj, "label");
 	g_object_notify (obj, "markup");
 }
@@ -278,7 +278,7 @@ on_certificate_gone (gpointer data,
 }
 
 void
-seahorse_private_key_set_certificate (SeahorsePrivateKey *self,
+seahorse_private_key_set_partner (SeahorsePrivateKey *self,
                                       SeahorseCertificate *certificate)
 {
 	g_return_if_fail (SEAHORSE_IS_PRIVATE_KEY (self));
diff --git a/pkcs11/seahorse-private-key.h b/pkcs11/seahorse-private-key.h
index 96c4651..1f63015 100644
--- a/pkcs11/seahorse-private-key.h
+++ b/pkcs11/seahorse-private-key.h
@@ -49,9 +49,9 @@ struct _SeahorsePrivateKeyClass {
 
 GType                 seahorse_private_key_get_type           (void) G_GNUC_CONST;
 
-SeahorseCertificate * seahorse_private_key_get_certificate    (SeahorsePrivateKey *self);
+SeahorseCertificate * seahorse_private_key_get_partner        (SeahorsePrivateKey *self);
 
-void                  seahorse_private_key_set_certificate    (SeahorsePrivateKey *self,
+void                  seahorse_private_key_set_partner        (SeahorsePrivateKey *self,
                                                                SeahorseCertificate *certificate);
 
 GIcon *               seahorse_private_key_get_icon           (SeahorsePrivateKey *self);
diff --git a/pkcs11/seahorse-token.c b/pkcs11/seahorse-token.c
index ae79576..9f8f5d1 100644
--- a/pkcs11/seahorse-token.c
+++ b/pkcs11/seahorse-token.c
@@ -197,12 +197,12 @@ static gboolean
 make_certificate_key_pair (SeahorseCertificate *certificate,
                            SeahorsePrivateKey *private_key)
 {
-	if (seahorse_certificate_get_private_key (certificate) ||
-	    seahorse_private_key_get_certificate (private_key))
+	if (seahorse_certificate_get_partner (certificate) ||
+	    seahorse_private_key_get_partner (private_key))
 		return FALSE;
 
-	seahorse_certificate_set_private_key (certificate, private_key);
-	seahorse_private_key_set_certificate (private_key, certificate);
+	seahorse_certificate_set_partner (certificate, private_key);
+	seahorse_private_key_set_partner (private_key, certificate);
 	return TRUE;
 }
 
@@ -215,12 +215,12 @@ break_certificate_key_pair (gpointer object)
 
 	if (SEAHORSE_IS_CERTIFICATE (object)) {
 		certificate = SEAHORSE_CERTIFICATE (object);
-		pair = seahorse_certificate_get_private_key (certificate);
-		seahorse_certificate_set_private_key (certificate, NULL);
+		pair = seahorse_certificate_get_partner (certificate);
+		seahorse_certificate_set_partner (certificate, NULL);
 	} else if (SEAHORSE_IS_PRIVATE_KEY (object)) {
 		private_key = SEAHORSE_PRIVATE_KEY (object);
-		pair = seahorse_private_key_get_certificate (private_key);
-		seahorse_private_key_set_certificate (private_key, NULL);
+		pair = seahorse_private_key_get_partner (private_key);
+		seahorse_private_key_set_partner (private_key, NULL);
 	} else {
 		pair = NULL;
 	}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]