[seahorse] Add SeahorseViewable interface, and use for showing properties



commit 7a5b350e6b8d5198ab30226b41340edb24552f7b
Author: Stef Walter <stefw collabora co uk>
Date:   Mon Dec 12 07:45:06 2011 +0100

    Add SeahorseViewable interface, and use for showing properties

 gkr/seahorse-gkr-actions.c          |   26 +---------------
 gkr/seahorse-gkr-item.c             |   19 +++++++++++
 gkr/seahorse-gkr-keyring.c          |   18 ++++++++++
 libseahorse/Makefile.am             |    1 +
 libseahorse/seahorse-catalog.c      |   42 ++++++++-----------------
 libseahorse/seahorse-viewable.c     |   59 +++++++++++++++++++++++++++++++++++
 libseahorse/seahorse-viewable.h     |   55 ++++++++++++++++++++++++++++++++
 pgp/seahorse-pgp-actions.c          |   10 ------
 pgp/seahorse-pgp-key.c              |   39 ++++++++++++++++-------
 pkcs11/seahorse-certificate.c       |   19 +++++++++++
 pkcs11/seahorse-pkcs11-actions.c    |   37 ++--------------------
 pkcs11/seahorse-pkcs11-properties.c |    2 +
 pkcs11/seahorse-pkcs11-properties.h |    1 -
 pkcs11/seahorse-private-key.c       |   19 +++++++++++
 ssh/seahorse-ssh-actions.c          |   20 ------------
 ssh/seahorse-ssh-key.c              |   18 ++++++++++
 16 files changed, 254 insertions(+), 131 deletions(-)
---
diff --git a/gkr/seahorse-gkr-actions.c b/gkr/seahorse-gkr-actions.c
index 533a3ad..112f1b5 100644
--- a/gkr/seahorse-gkr-actions.c
+++ b/gkr/seahorse-gkr-actions.c
@@ -475,19 +475,6 @@ typedef struct {
 G_DEFINE_TYPE (SeahorseGkrItemActions, seahorse_gkr_item_actions, SEAHORSE_TYPE_ACTIONS);
 
 static void
-on_password_properties (GtkAction *action,
-                        gpointer user_data)
-{
-	seahorse_gkr_item_properties_show (SEAHORSE_GKR_ITEM (user_data),
-	                                   seahorse_action_get_window (action));
-}
-
-static const GtkActionEntry ITEM_ACTIONS[] = {
-	{ "properties", GTK_STOCK_PROPERTIES, NULL, NULL,
-	  N_("Properties of the password."), G_CALLBACK (on_password_properties) },
-};
-
-static void
 seahorse_gkr_item_actions_init (SeahorseGkrItemActions *self)
 {
 
@@ -497,18 +484,7 @@ static GtkActionGroup *
 seahorse_gkr_item_actions_clone_for_objects (SeahorseActions *actions,
                                              GList *objects)
 {
-	GtkActionGroup *cloned;
-
-	cloned = gtk_action_group_new ("KeyringItem");
-	gtk_action_group_set_translation_domain (cloned, GETTEXT_PACKAGE);
-
-	if (!objects->next)
-		gtk_action_group_add_actions_full (cloned, ITEM_ACTIONS,
-		                                   G_N_ELEMENTS (ITEM_ACTIONS),
-		                                   g_object_ref (objects->data),
-		                                   g_object_unref);
-
-	return cloned;
+	return NULL;
 }
 
 static void
diff --git a/gkr/seahorse-gkr-item.c b/gkr/seahorse-gkr-item.c
index 4e5486d..a11de08 100644
--- a/gkr/seahorse-gkr-item.c
+++ b/gkr/seahorse-gkr-item.c
@@ -28,6 +28,7 @@
 
 #include "seahorse-gkr.h"
 #include "seahorse-gkr-actions.h"
+#include "seahorse-gkr-dialogs.h"
 #include "seahorse-gkr-item.h"
 #include "seahorse-gkr-item-deleter.h"
 #include "seahorse-gkr-keyring.h"
@@ -38,6 +39,7 @@
 #include "seahorse-place.h"
 #include "seahorse-util.h"
 #include "seahorse-secure-memory.h"
+#include "seahorse-viewable.h"
 
 #define GENERIC_SECRET "org.freedesktop.Secret.Generic"
 #define NETWORK_PASSWORD "org.gnome.keyring.NetworkPassword"
@@ -478,8 +480,11 @@ static gboolean  require_item_attrs                  (SeahorseGkrItem *self);
 
 static void      seahorse_gkr_item_deletable_iface   (SeahorseDeletableIface *iface);
 
+static void      seahorse_gkr_item_viewable_iface    (SeahorseViewableIface *iface);
+
 G_DEFINE_TYPE_WITH_CODE (SeahorseGkrItem, seahorse_gkr_item, SEAHORSE_TYPE_OBJECT,
                          G_IMPLEMENT_INTERFACE (SEAHORSE_TYPE_DELETABLE, seahorse_gkr_item_deletable_iface);
+                         G_IMPLEMENT_INTERFACE (SEAHORSE_TYPE_VIEWABLE, seahorse_gkr_item_viewable_iface);
 );
 
 /* -----------------------------------------------------------------------------
@@ -926,6 +931,20 @@ seahorse_gkr_item_deletable_iface (SeahorseDeletableIface *iface)
 	iface->create_deleter = seahorse_gkr_item_create_deleter;
 }
 
+static void
+seahorse_gkr_item_show_viewer (SeahorseViewable *viewable,
+                               GtkWindow *parent)
+{
+	seahorse_gkr_item_properties_show (SEAHORSE_GKR_ITEM (viewable),
+	                                   parent);
+}
+
+static void
+seahorse_gkr_item_viewable_iface (SeahorseViewableIface *iface)
+{
+	iface->show_viewer = seahorse_gkr_item_show_viewer;
+}
+
 SeahorseGkrItem *
 seahorse_gkr_item_new (SeahorseGkrKeyring *keyring,
                        const gchar *keyring_name,
diff --git a/gkr/seahorse-gkr-keyring.c b/gkr/seahorse-gkr-keyring.c
index b309e6f..98eacd3 100644
--- a/gkr/seahorse-gkr-keyring.c
+++ b/gkr/seahorse-gkr-keyring.c
@@ -23,6 +23,7 @@
 #include "config.h"
 
 #include "seahorse-gkr.h"
+#include "seahorse-gkr-dialogs.h"
 #include "seahorse-gkr-keyring-deleter.h"
 #include "seahorse-gkr-keyring.h"
 #include "seahorse-gkr-operation.h"
@@ -30,6 +31,7 @@
 
 #include "seahorse-action.h"
 #include "seahorse-deletable.h"
+#include "seahorse-viewable.h"
 #include "seahorse-progress.h"
 #include "seahorse-util.h"
 
@@ -66,10 +68,13 @@ static void     seahorse_keyring_collection_iface   (GcrCollectionIface *iface);
 
 static void     seahorse_keyring_deletable_iface    (SeahorseDeletableIface *iface);
 
+static void     seahorse_keyring_viewable_iface     (SeahorseViewableIface *iface);
+
 G_DEFINE_TYPE_WITH_CODE (SeahorseGkrKeyring, seahorse_gkr_keyring, SEAHORSE_TYPE_OBJECT,
                          G_IMPLEMENT_INTERFACE (GCR_TYPE_COLLECTION, seahorse_keyring_collection_iface);
                          G_IMPLEMENT_INTERFACE (SEAHORSE_TYPE_PLACE, seahorse_keyring_place_iface);
                          G_IMPLEMENT_INTERFACE (SEAHORSE_TYPE_DELETABLE, seahorse_keyring_deletable_iface);
+                         G_IMPLEMENT_INTERFACE (SEAHORSE_TYPE_VIEWABLE, seahorse_keyring_viewable_iface);
 );
 
 static GType
@@ -539,6 +544,19 @@ seahorse_keyring_deletable_iface (SeahorseDeletableIface *iface)
 	iface->create_deleter = seahorse_gkr_keyring_create_deleter;
 }
 
+static void
+seahorse_gkr_keyring_show_viewer (SeahorseViewable *viewable,
+                                  GtkWindow *parent)
+{
+	seahorse_gkr_keyring_properties_show (SEAHORSE_GKR_KEYRING (viewable),
+	                                      parent);
+}
+
+static void
+seahorse_keyring_viewable_iface (SeahorseViewableIface *iface)
+{
+	iface->show_viewer = seahorse_gkr_keyring_show_viewer;
+}
 
 SeahorseGkrKeyring*
 seahorse_gkr_keyring_new (const gchar *keyring_name)
diff --git a/libseahorse/Makefile.am b/libseahorse/Makefile.am
index d2b43bf..668fa17 100644
--- a/libseahorse/Makefile.am
+++ b/libseahorse/Makefile.am
@@ -61,6 +61,7 @@ libseahorse_la_SOURCES = \
 	seahorse-types.c seahorse-types.h \
 	seahorse-util.c seahorse-util.h \
 	seahorse-validity.c seahorse-validity.h \
+	seahorse-viewable.c seahorse-viewable.h \
 	seahorse-widget.c seahorse-widget.h \
 	$(MARSHAL_SRCS) \
 	$(KEYSERVER_SRCS)
diff --git a/libseahorse/seahorse-catalog.c b/libseahorse/seahorse-catalog.c
index 80e852e..65b2d32 100644
--- a/libseahorse/seahorse-catalog.c
+++ b/libseahorse/seahorse-catalog.c
@@ -25,6 +25,7 @@
 #include "seahorse-action.h"
 #include "seahorse-actions.h"
 #include "seahorse-backend.h"
+#include "seahorse-catalog.h"
 #include "seahorse-deletable.h"
 #include "seahorse-exportable.h"
 #include "seahorse-object.h"
@@ -32,7 +33,7 @@
 #include "seahorse-progress.h"
 #include "seahorse-registry.h"
 #include "seahorse-util.h"
-#include "seahorse-catalog.h"
+#include "seahorse-viewable.h"
 
 #include <gcr/gcr.h>
 
@@ -136,6 +137,7 @@ lookup_actions_for_objects (SeahorseCatalog *self,
                             GList *objects)
 {
 	GtkActionGroup *actions;
+	GtkActionGroup *cloned;
 	GHashTableIter iter;
 	GList *results;
 	GHashTable *table;
@@ -165,8 +167,9 @@ lookup_actions_for_objects (SeahorseCatalog *self,
 	results = NULL;
 	g_hash_table_iter_init (&iter, table);
 	while (g_hash_table_iter_next (&iter, (gpointer *)&actions, (gpointer *)&queue)) {
-		results = g_list_prepend (results,
-		      seahorse_actions_clone_for_objects (actions, queue->head));
+		cloned = seahorse_actions_clone_for_objects (actions, queue->head);
+		if (cloned != NULL)
+			results = g_list_prepend (results, cloned);
 	}
 
 	g_hash_table_destroy (table);
@@ -336,19 +339,15 @@ seahorse_catalog_real_selection_changed (SeahorseCatalog *self)
 			can_export = TRUE;
 		if (seahorse_deletable_can_delete (l->data))
 			can_delete = TRUE;
-		if (can_export && can_delete)
+		if (seahorse_viewable_can_view (l->data))
+			can_properties = TRUE;
+		if (can_export && can_delete && can_properties)
 			break;
 	}
 
 	groups = lookup_actions_for_objects (self, objects);
 	g_list_free (objects);
 
-	/* Add all those actions */
-	for (l = groups; l != NULL; l = g_list_next (l)) {
-		if (gtk_action_group_get_action (l->data, "properties"))
-			can_properties = TRUE;
-	}
-
 	gtk_action_set_sensitive (self->pv->properties_object, can_properties);
 	gtk_action_set_sensitive (self->pv->edit_delete, can_delete);
 	gtk_action_set_sensitive (self->pv->edit_copy, can_export);
@@ -591,26 +590,11 @@ seahorse_catalog_show_context_menu (SeahorseCatalog *self,
 
 void
 seahorse_catalog_show_properties (SeahorseCatalog *self,
-                                 GObject* obj)
+                                  GObject* obj)
 {
-	GtkActionGroup *actions, *cloned;
-	GtkAction *action;
-	GList *objects;
-
-	g_object_get (obj, "actions", &actions, NULL);
-	if (actions == NULL)
-		return;
-
-	objects = g_list_append (NULL, obj);
-	cloned = seahorse_actions_clone_for_objects (actions, objects);
-	g_object_unref (actions);
-	g_list_free (objects);
-
-	action = gtk_action_group_get_action (cloned, "properties");
-	if (action != NULL)
-		seahorse_action_activate_with_window (action, seahorse_catalog_get_window (self));
-
-	g_object_unref (cloned);
+	if (seahorse_viewable_can_view (obj))
+		seahorse_viewable_show_viewer (SEAHORSE_VIEWABLE (obj),
+		                               seahorse_catalog_get_window (self));
 }
 
 GtkWindow *
diff --git a/libseahorse/seahorse-viewable.c b/libseahorse/seahorse-viewable.c
new file mode 100644
index 0000000..158e5af
--- /dev/null
+++ b/libseahorse/seahorse-viewable.c
@@ -0,0 +1,59 @@
+/*
+ * Seahorse
+ *
+ * Copyright (C) 2004,2005 Stefan Walter
+ * Copyright (C) 2011 Collabora Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 General Public License for more details.
+ * You should have received a copy of the GNU 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-viewable.h"
+
+typedef SeahorseViewableIface SeahorseViewableInterface;
+
+G_DEFINE_INTERFACE (SeahorseViewable, seahorse_viewable, G_TYPE_OBJECT);
+
+void
+seahorse_viewable_show_viewer (SeahorseViewable *viewable,
+                               GtkWindow *parent)
+{
+	SeahorseViewableIface *iface;
+
+	g_return_if_fail (SEAHORSE_IS_VIEWABLE (viewable));
+	g_return_if_fail (parent == NULL || GTK_IS_WINDOW (parent));
+
+	iface = SEAHORSE_VIEWABLE_GET_INTERFACE (viewable);
+	g_return_if_fail (iface->show_viewer != NULL);
+
+	return iface->show_viewer (viewable, parent);
+}
+
+static void
+seahorse_viewable_default_init (SeahorseViewableIface *iface)
+{
+	static gboolean initialized = FALSE;
+	if (!initialized) {
+		initialized = TRUE;
+	}
+}
+
+gboolean
+seahorse_viewable_can_view (gpointer object)
+{
+	return SEAHORSE_IS_VIEWABLE (object);
+}
diff --git a/libseahorse/seahorse-viewable.h b/libseahorse/seahorse-viewable.h
new file mode 100644
index 0000000..2b14f42
--- /dev/null
+++ b/libseahorse/seahorse-viewable.h
@@ -0,0 +1,55 @@
+/*
+ * Seahorse
+ *
+ * Copyright (C) 2011 Collabora Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 General Public License for more details.
+ * You should have received a copy of the GNU 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.
+ *
+ * Author: Stef Walter <stefw collabora co uk>
+ */
+
+#ifndef __SEAHORSE_VIEWABLE_H__
+#define __SEAHORSE_VIEWABLE_H__
+
+#include "seahorse-exporter.h"
+
+#include <gio/gio.h>
+
+#include <gtk/gtk.h>
+
+#define SEAHORSE_TYPE_VIEWABLE                (seahorse_viewable_get_type ())
+#define SEAHORSE_VIEWABLE(obj)                (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAHORSE_TYPE_VIEWABLE, SeahorseViewable))
+#define SEAHORSE_IS_VIEWABLE(obj)             (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SEAHORSE_TYPE_VIEWABLE))
+#define SEAHORSE_VIEWABLE_GET_INTERFACE(obj)  (G_TYPE_INSTANCE_GET_INTERFACE ((obj), SEAHORSE_TYPE_VIEWABLE, SeahorseViewableIface))
+
+typedef struct _SeahorseViewable SeahorseViewable;
+typedef struct _SeahorseViewableIface SeahorseViewableIface;
+
+struct _SeahorseViewableIface {
+	GTypeInterface parent;
+
+	void           (* show_viewer)      (SeahorseViewable *viewable,
+	                                     GtkWindow *parent);
+};
+
+GType              seahorse_viewable_get_type               (void) G_GNUC_CONST;
+
+void               seahorse_viewable_show_viewer            (SeahorseViewable *viewable,
+                                                             GtkWindow *parent);
+
+gboolean           seahorse_viewable_can_view               (gpointer object);
+
+#endif /* __SEAHORSE_VIEWABLE_H__ */
diff --git a/pgp/seahorse-pgp-actions.c b/pgp/seahorse-pgp-actions.c
index 522f92d..43a60e9 100644
--- a/pgp/seahorse-pgp-actions.c
+++ b/pgp/seahorse-pgp-actions.c
@@ -189,19 +189,9 @@ on_key_sign (GtkAction* action,
 	seahorse_gpgme_sign_prompt (SEAHORSE_GPGME_KEY (objects->data), window);
 }
 
-static void
-on_show_properties (GtkAction *action,
-                    gpointer user_data)
-{
-	seahorse_pgp_key_properties_show (SEAHORSE_PGP_KEY (user_data),
-	                                  seahorse_action_get_window (action));
-}
-
 static const GtkActionEntry KEY_ACTIONS[] = {
 	{ "key-sign", GTK_STOCK_INDEX, N_("_Sign Key..."), "",
 	  N_("Sign public key"), G_CALLBACK (on_key_sign) },
-	{ "properties", GTK_STOCK_PROPERTIES, NULL, NULL,
-	  N_("Properties of the key."), G_CALLBACK (on_show_properties) },
 };
 
 static void
diff --git a/pgp/seahorse-pgp-key.c b/pgp/seahorse-pgp-key.c
index 502efa2..d5b6af4 100644
--- a/pgp/seahorse-pgp-key.c
+++ b/pgp/seahorse-pgp-key.c
@@ -20,21 +20,23 @@
  */
 #include "config.h"
 
-#include <string.h>
-
-#include <glib/gi18n.h>
+#include "seahorse-pgp.h"
+#include "seahorse-pgp-dialogs.h"
+#include "seahorse-pgp-key.h"
+#include "seahorse-pgp-uid.h"
+#include "seahorse-pgp-subkey.h"
 
 #include "seahorse-icons.h"
 #include "seahorse-object-list.h"
 #include "seahorse-util.h"
-
-#include "pgp/seahorse-pgp.h"
-#include "pgp/seahorse-pgp-key.h"
-#include "pgp/seahorse-pgp-uid.h"
-#include "pgp/seahorse-pgp-subkey.h"
+#include "seahorse-viewable.h"
 
 #include <gcr/gcr.h>
 
+#include <glib/gi18n.h>
+
+#include <string.h>
+
 enum {
 	PROP_0,
 	PROP_PHOTOS,
@@ -49,7 +51,11 @@ enum {
 	PROP_DESCRIPTION
 };
 
-G_DEFINE_TYPE (SeahorsePgpKey, seahorse_pgp_key, SEAHORSE_TYPE_OBJECT);
+static void        seahorse_pgp_key_viewable_iface          (SeahorseViewableIface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (SeahorsePgpKey, seahorse_pgp_key, SEAHORSE_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (SEAHORSE_TYPE_VIEWABLE, seahorse_pgp_key_viewable_iface);
+);
 
 struct _SeahorsePgpKeyPrivate {
 	gchar *keyid;
@@ -477,9 +483,18 @@ seahorse_pgp_key_class_init (SeahorsePgpKeyClass *klass)
  	                             "", G_PARAM_READABLE));
 }
 
-/* -----------------------------------------------------------------------------
- * PUBLIC 
- */
+static void
+seahorse_pgp_key_show_viewer (SeahorseViewable *viewable,
+                              GtkWindow *parent)
+{
+	seahorse_pgp_key_properties_show (SEAHORSE_PGP_KEY (viewable), parent);
+}
+
+static void
+seahorse_pgp_key_viewable_iface (SeahorseViewableIface *iface)
+{
+	iface->show_viewer = seahorse_pgp_key_show_viewer;
+}
 
 gchar*
 seahorse_pgp_key_calc_identifier (const gchar *keyid)
diff --git a/pkcs11/seahorse-certificate.c b/pkcs11/seahorse-certificate.c
index e828d41..42b3d44 100644
--- a/pkcs11/seahorse-certificate.c
+++ b/pkcs11/seahorse-certificate.c
@@ -28,6 +28,7 @@
 #include "seahorse-pkcs11-actions.h"
 #include "seahorse-pkcs11-deleter.h"
 #include "seahorse-pkcs11-helpers.h"
+#include "seahorse-pkcs11-properties.h"
 #include "seahorse-private-key.h"
 #include "seahorse-token.h"
 #include "seahorse-types.h"
@@ -36,6 +37,7 @@
 #include "seahorse-exportable.h"
 #include "seahorse-util.h"
 #include "seahorse-validity.h"
+#include "seahorse-viewable.h"
 
 #include <gcr/gcr.h>
 #include <gck/pkcs11.h>
@@ -83,12 +85,15 @@ static void   seahorse_certificate_deletable_iface             (SeahorseDeletabl
 
 static void   seahorse_certificate_exportable_iface            (SeahorseExportableIface *iface);
 
+static void   seahorse_certificate_viewable_iface              (SeahorseViewableIface *iface);
+
 G_DEFINE_TYPE_WITH_CODE (SeahorseCertificate, seahorse_certificate, GCK_TYPE_OBJECT,
                          GCR_CERTIFICATE_MIXIN_IMPLEMENT_COMPARABLE ();
                          G_IMPLEMENT_INTERFACE (GCR_TYPE_CERTIFICATE, seahorse_certificate_certificate_iface);
                          G_IMPLEMENT_INTERFACE (GCK_TYPE_OBJECT_CACHE, seahorse_certificate_object_cache_iface);
                          G_IMPLEMENT_INTERFACE (SEAHORSE_TYPE_DELETABLE, seahorse_certificate_deletable_iface);
                          G_IMPLEMENT_INTERFACE (SEAHORSE_TYPE_EXPORTABLE, seahorse_certificate_exportable_iface);
+                         G_IMPLEMENT_INTERFACE (SEAHORSE_TYPE_VIEWABLE, seahorse_certificate_viewable_iface);
 );
 
 static void
@@ -399,6 +404,20 @@ seahorse_certificate_deletable_iface (SeahorseDeletableIface *iface)
 	iface->create_deleter = seahorse_certificate_create_deleter;
 }
 
+static void
+seahorse_certificate_show_viewer (SeahorseViewable *viewable,
+                                  GtkWindow *parent)
+{
+	GtkWindow *viewer = seahorse_pkcs11_properties_show (G_OBJECT (viewable), parent);
+	gtk_widget_show (GTK_WIDGET (viewer));
+}
+
+static void
+seahorse_certificate_viewable_iface (SeahorseViewableIface *iface)
+{
+	iface->show_viewer = seahorse_certificate_show_viewer;
+}
+
 GIcon *
 seahorse_certificate_get_icon (SeahorseCertificate *self)
 {
diff --git a/pkcs11/seahorse-pkcs11-actions.c b/pkcs11/seahorse-pkcs11-actions.c
index ebbc152..6deae7b 100644
--- a/pkcs11/seahorse-pkcs11-actions.c
+++ b/pkcs11/seahorse-pkcs11-actions.c
@@ -38,6 +38,8 @@
 #include "seahorse-registry.h"
 #include "seahorse-util.h"
 
+#include <glib/gi18n.h>
+
 GType   seahorse_pkcs11_token_actions_get_type       (void) G_GNUC_CONST;
 #define SEAHORSE_TYPE_PKCS11_TOKEN_ACTIONS           (seahorse_pkcs11_token_actions_get_type ())
 #define SEAHORSE_PKCS11_TOKEN_ACTIONS(obj)           (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAHORSE_TYPE_PKCS11_TOKEN_ACTIONS, SeahorsePkcs11TokenActions))
@@ -207,25 +209,6 @@ typedef struct {
 G_DEFINE_TYPE (SeahorsePkcs11ObjectActions, seahorse_pkcs11_object_actions, SEAHORSE_TYPE_ACTIONS);
 
 static void
-on_show_properties (GtkAction *action,
-                    gpointer user_data)
-{
-	GtkWindow *window;
-	GObject *object;
-
-	/* Create a new dialog for the certificate */
-	object = G_OBJECT (user_data);
-	window = seahorse_pkcs11_properties_show (object, seahorse_action_get_window (action));
-	gtk_widget_show (GTK_WIDGET (window));
-}
-
-
-static const GtkActionEntry CERTIFICATE_ACTIONS[] = {
-	{ "properties", GTK_STOCK_PROPERTIES, NULL, NULL,
-	  N_("Properties of the certificate."), G_CALLBACK (on_show_properties) },
-};
-
-static void
 seahorse_pkcs11_object_actions_init (SeahorsePkcs11ObjectActions *self)
 {
 
@@ -235,21 +218,7 @@ static GtkActionGroup *
 seahorse_pkcs11_object_actions_clone_for_objects (SeahorseActions *actions,
                                            GList *objects)
 {
-	GtkActionGroup *cloned;
-
-	g_return_val_if_fail (objects != NULL, NULL);
-
-	cloned = gtk_action_group_new ("Pkcs11Object");
-	gtk_action_group_set_translation_domain (cloned, GETTEXT_PACKAGE);
-
-	/* Only one object? */
-	if (!objects->next)
-		gtk_action_group_add_actions_full (cloned, CERTIFICATE_ACTIONS,
-		                                   G_N_ELEMENTS (CERTIFICATE_ACTIONS),
-		                                   g_object_ref (objects->data),
-		                                   g_object_unref);
-
-	return cloned;
+	return NULL;
 }
 
 static void
diff --git a/pkcs11/seahorse-pkcs11-properties.c b/pkcs11/seahorse-pkcs11-properties.c
index e091a29..6dec566 100644
--- a/pkcs11/seahorse-pkcs11-properties.c
+++ b/pkcs11/seahorse-pkcs11-properties.c
@@ -36,6 +36,8 @@
 
 #include <gcr/gcr.h>
 
+#include <glib/gi18n.h>
+
 static const gchar *UI_STRING =
 "<ui>"
 "	<toolbar name='Toolbar'>"
diff --git a/pkcs11/seahorse-pkcs11-properties.h b/pkcs11/seahorse-pkcs11-properties.h
index 4dce342..da93b39 100644
--- a/pkcs11/seahorse-pkcs11-properties.h
+++ b/pkcs11/seahorse-pkcs11-properties.h
@@ -27,7 +27,6 @@
 #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))
diff --git a/pkcs11/seahorse-private-key.c b/pkcs11/seahorse-private-key.c
index 45bf02f..804e591 100644
--- a/pkcs11/seahorse-private-key.c
+++ b/pkcs11/seahorse-private-key.c
@@ -27,12 +27,14 @@
 #include "seahorse-pkcs11-actions.h"
 #include "seahorse-pkcs11-helpers.h"
 #include "seahorse-pkcs11-key-deleter.h"
+#include "seahorse-pkcs11-properties.h"
 #include "seahorse-token.h"
 #include "seahorse-types.h"
 
 #include "seahorse-deletable.h"
 #include "seahorse-exportable.h"
 #include "seahorse-util.h"
+#include "seahorse-viewable.h"
 
 #include <gcr/gcr.h>
 #include <gck/pkcs11.h>
@@ -79,10 +81,13 @@ static void seahorse_private_key_exportable_iface (SeahorseExportableIface *ifac
 
 static void seahorse_private_key_object_cache_iface (GckObjectCacheIface *iface);
 
+static void seahorse_private_key_viewable_iface (SeahorseViewableIface *iface);
+
 G_DEFINE_TYPE_WITH_CODE (SeahorsePrivateKey, seahorse_private_key, GCK_TYPE_OBJECT,
                          G_IMPLEMENT_INTERFACE (GCK_TYPE_OBJECT_CACHE, seahorse_private_key_object_cache_iface);
                          G_IMPLEMENT_INTERFACE (SEAHORSE_TYPE_DELETABLE, seahorse_private_key_deletable_iface);
                          G_IMPLEMENT_INTERFACE (SEAHORSE_TYPE_EXPORTABLE, seahorse_private_key_exportable_iface);
+                         G_IMPLEMENT_INTERFACE (SEAHORSE_TYPE_VIEWABLE, seahorse_private_key_viewable_iface);
 );
 
 static void
@@ -322,6 +327,20 @@ seahorse_private_key_exportable_iface (SeahorseExportableIface *iface)
 	iface->create_exporters = seahorse_private_key_create_exporters;
 }
 
+static void
+seahorse_private_key_show_viewer (SeahorseViewable *viewable,
+                                  GtkWindow *parent)
+{
+	GtkWindow *viewer = seahorse_pkcs11_properties_show (G_OBJECT (viewable), parent);
+	gtk_widget_show (GTK_WIDGET (viewer));
+}
+
+static void
+seahorse_private_key_viewable_iface (SeahorseViewableIface *iface)
+{
+	iface->show_viewer = seahorse_private_key_show_viewer;
+}
+
 SeahorseCertificate *
 seahorse_private_key_get_partner (SeahorsePrivateKey *self)
 {
diff --git a/ssh/seahorse-ssh-actions.c b/ssh/seahorse-ssh-actions.c
index 2087ca7..44f6e14 100644
--- a/ssh/seahorse-ssh-actions.c
+++ b/ssh/seahorse-ssh-actions.c
@@ -82,25 +82,12 @@ on_ssh_upload (GtkAction* action,
 	seahorse_ssh_upload_prompt (ssh_keys, seahorse_action_get_window (action));
 }
 
-static void
-on_show_properties (GtkAction *action,
-                    gpointer user_data)
-{
-	seahorse_ssh_key_properties_show (SEAHORSE_SSH_KEY (user_data),
-	                                  seahorse_action_get_window (action));
-}
-
 static const GtkActionEntry KEYS_ACTIONS[] = {
 	{ "remote-ssh-upload", NULL, N_ ("Configure Key for _Secure Shell..."), "",
 		N_ ("Send public Secure Shell key to another machine, and enable logins using that key."),
 		G_CALLBACK (on_ssh_upload) },
 };
 
-static const GtkActionEntry KEY_ACTIONS[] = {
-	{ "properties", GTK_STOCK_PROPERTIES, NULL, NULL,
-	  N_("Properties of the key."), G_CALLBACK (on_show_properties) },
-};
-
 static void
 seahorse_ssh_actions_init (SeahorseSshActions *self)
 {
@@ -127,13 +114,6 @@ seahorse_ssh_actions_clone_for_objects (SeahorseActions *actions,
 	                                   seahorse_object_list_copy (objects),
 	                                   seahorse_object_list_free);
 
-	/* A single object */
-	if (!objects->next)
-		gtk_action_group_add_actions_full (cloned, KEY_ACTIONS,
-		                                   G_N_ELEMENTS (KEY_ACTIONS),
-		                                   g_object_ref (objects->data),
-		                                   g_object_unref);
-
 	return cloned;
 }
 
diff --git a/ssh/seahorse-ssh-key.c b/ssh/seahorse-ssh-key.c
index a20f91a..916a2f0 100644
--- a/ssh/seahorse-ssh-key.c
+++ b/ssh/seahorse-ssh-key.c
@@ -24,6 +24,7 @@
 
 #include "seahorse-ssh-actions.h"
 #include "seahorse-ssh-deleter.h"
+#include "seahorse-ssh-dialogs.h"
 #include "seahorse-ssh-exporter.h"
 #include "seahorse-ssh-key.h"
 #include "seahorse-ssh-operation.h"
@@ -34,6 +35,7 @@
 #include "seahorse-icons.h"
 #include "seahorse-place.h"
 #include "seahorse-validity.h"
+#include "seahorse-viewable.h"
 
 #include <gcr/gcr.h>
 
@@ -59,9 +61,12 @@ static void       seahorse_ssh_key_deletable_iface       (SeahorseDeletableIface
 
 static void       seahorse_ssh_key_exportable_iface      (SeahorseExportableIface *iface);
 
+static void       seahorse_ssh_key_viewable_iface        (SeahorseViewableIface *iface);
+
 G_DEFINE_TYPE_WITH_CODE (SeahorseSSHKey, seahorse_ssh_key, SEAHORSE_TYPE_OBJECT,
                          G_IMPLEMENT_INTERFACE (SEAHORSE_TYPE_EXPORTABLE, seahorse_ssh_key_exportable_iface);
                          G_IMPLEMENT_INTERFACE (SEAHORSE_TYPE_DELETABLE, seahorse_ssh_key_deletable_iface);
+                         G_IMPLEMENT_INTERFACE (SEAHORSE_TYPE_VIEWABLE, seahorse_ssh_key_viewable_iface);
 );
 
 /* -----------------------------------------------------------------------------
@@ -331,6 +336,19 @@ seahorse_ssh_key_deletable_iface (SeahorseDeletableIface *iface)
 	iface->create_deleter = seahorse_ssh_key_create_deleter;
 }
 
+static void
+seahorse_ssh_key_show_viewer (SeahorseViewable *viewable,
+                              GtkWindow *parent)
+{
+	seahorse_ssh_key_properties_show (SEAHORSE_SSH_KEY (viewable), parent);
+}
+
+static void
+seahorse_ssh_key_viewable_iface (SeahorseViewableIface *iface)
+{
+	iface->show_viewer = seahorse_ssh_key_show_viewer;
+}
+
 SeahorseSSHKey* 
 seahorse_ssh_key_new (SeahorsePlace *place,
                       SeahorseSSHKeyData *data)



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