[seahorse] common: Migrate SeahorsePlace to vala



commit 8ea08059c12f8b9b6e1015aca315575bb972c877
Author: Stef Walter <stefw gnome org>
Date:   Thu May 2 20:51:44 2013 +0200

    common: Migrate SeahorsePlace to vala

 common/Makefile.am                       |    2 +
 common/place.vala                        |   36 ++++++++++
 gkr/seahorse-gkr-item.c                  |    1 -
 gkr/seahorse-gkr-keyring.c               |   64 +++++++++++++-----
 gkr/seahorse-gkr-keyring.h               |    2 -
 libseahorse/Makefile.am                  |    1 -
 libseahorse/seahorse-backend.h           |    2 +-
 libseahorse/seahorse-catalog.h           |    2 +-
 libseahorse/seahorse-key-manager-store.c |    1 -
 libseahorse/seahorse-object.c            |    2 +-
 libseahorse/seahorse-place.c             |  104 -----------------------------
 libseahorse/seahorse-place.h             |   75 ---------------------
 libseahorse/seahorse-predicate.c         |    2 +-
 pgp/seahorse-gpgme-key.c                 |    1 -
 pgp/seahorse-gpgme-keyring.c             |   50 ++++++++++++--
 pgp/seahorse-hkp-source.c                |   18 +-----
 pgp/seahorse-ldap-source.c               |   12 +---
 pgp/seahorse-pgp-backend.c               |    2 +-
 pgp/seahorse-server-source.c             |   73 ++++++++++++++++++++-
 pgp/seahorse-transfer.h                  |    2 +-
 pgp/seahorse-unknown-source.c            |   69 ++++++++++++++++++--
 pkcs11/seahorse-pkcs11-backend.c         |    1 -
 pkcs11/seahorse-pkcs11-generate.c        |    2 +-
 pkcs11/seahorse-token.c                  |  106 ++++++++++++++++++++++-------
 src/seahorse-import-dialog.c             |    3 +-
 src/seahorse-sidebar.c                   |    1 -
 src/seahorse-sidebar.h                   |    2 +-
 ssh/seahorse-ssh-backend.c               |    2 +-
 ssh/seahorse-ssh-key.c                   |    1 -
 ssh/seahorse-ssh-key.h                   |    1 -
 ssh/seahorse-ssh-source.c                |   57 +++++++++++++---
 31 files changed, 398 insertions(+), 299 deletions(-)
---
diff --git a/common/Makefile.am b/common/Makefile.am
index 320ce96..f11cac0 100644
--- a/common/Makefile.am
+++ b/common/Makefile.am
@@ -11,6 +11,7 @@ libcommon_la_SOURCES = \
        deleter.vala \
        exportable.vala \
        exporter.vala \
+       place.vala \
        registry.vala \
        viewable.vala \
        $(NULL)
@@ -20,6 +21,7 @@ AM_VALAFLAGS = \
        --use-header \
        --header=seahorse-common.h \
        --pkg gtk+-3.0 \
+       --pkg gcr-3 \
        --vapi=common.vapi \
        $(NULL)
 
diff --git a/common/place.vala b/common/place.vala
new file mode 100644
index 0000000..84429d7
--- /dev/null
+++ b/common/place.vala
@@ -0,0 +1,36 @@
+/*
+ * Seahorse
+ *
+ * Copyright (C) 2004,2005 Stefan Walter
+ * Copyright (C) 2011 Collabora Ltd.
+ * Copyright (C) 2013 Stef Walter
+ *
+ * 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.
+ */
+
+namespace Seahorse {
+
+public interface Place : Gcr.Collection {
+       public abstract string label { owned get; }
+       public abstract string description { owned get; }
+       public abstract string uri { owned get; }
+       public abstract GLib.Icon icon { owned get; }
+       public abstract Gtk.ActionGroup actions { owned get; }
+
+       public abstract async bool load(GLib.Cancellable? cancellable) throws GLib.Error;
+}
+
+}
diff --git a/gkr/seahorse-gkr-item.c b/gkr/seahorse-gkr-item.c
index 757b4d2..0230b64 100644
--- a/gkr/seahorse-gkr-item.c
+++ b/gkr/seahorse-gkr-item.c
@@ -36,7 +36,6 @@
 
 #include "seahorse-common.h"
 #include "seahorse-icons.h"
-#include "seahorse-place.h"
 #include "seahorse-util.h"
 
 #define GENERIC_SECRET "org.freedesktop.Secret.Generic"
diff --git a/gkr/seahorse-gkr-keyring.c b/gkr/seahorse-gkr-keyring.c
index b05cd0b..b89cb39 100644
--- a/gkr/seahorse-gkr-keyring.c
+++ b/gkr/seahorse-gkr-keyring.c
@@ -202,28 +202,60 @@ seahorse_gkr_keyring_finalize (GObject *obj)
        G_OBJECT_CLASS (seahorse_gkr_keyring_parent_class)->finalize (obj);
 }
 
+static gchar *
+seahorse_gkr_keyring_get_description (SeahorsePlace *place)
+{
+       g_return_val_if_fail (SEAHORSE_IS_GKR_KEYRING (place), NULL);
+       if (seahorse_gkr_backend_has_alias (NULL, "login", SEAHORSE_GKR_KEYRING (place)))
+               return g_strdup (_("A keyring that is automatically unlocked on login"));
+       return g_strdup (_("A keyring used to store passwords"));
+}
+
+static GtkActionGroup *
+seahorse_gkr_keyring_get_actions (SeahorsePlace *place)
+{
+       return seahorse_gkr_keyring_actions_new (SEAHORSE_GKR_KEYRING (place));
+}
+
+static gchar *
+seahorse_gkr_keyring_get_uri (SeahorsePlace *place)
+{
+       const gchar *object_path;
+       object_path = g_dbus_proxy_get_object_path (G_DBUS_PROXY (place));
+       return g_strdup_printf ("secret-service://%s", object_path);
+}
+
+static GIcon *
+seahorse_gkr_keyring_get_icon (SeahorsePlace *place)
+{
+       return g_themed_icon_new ("folder");
+}
+
+static gchar *
+seahorse_gkr_keyring_get_label (SeahorsePlace *place)
+{
+       return secret_collection_get_label (SECRET_COLLECTION (place));
+}
+
 static void
 seahorse_gkr_keyring_get_property (GObject *obj, guint prop_id, GValue *value, 
                            GParamSpec *pspec)
 {
        SeahorseGkrKeyring *self = SEAHORSE_GKR_KEYRING (obj);
-       const gchar *object_path;
-       gchar *text;
+       SeahorsePlace *place = SEAHORSE_PLACE (obj);
 
        switch (prop_id) {
        case PROP_DESCRIPTION:
-               g_value_set_string (value, seahorse_gkr_keyring_get_description (self));
+               g_value_take_string (value, seahorse_gkr_keyring_get_description (place));
                break;
        case PROP_IS_DEFAULT:
                g_value_set_boolean (value, seahorse_gkr_keyring_get_is_default (self));
                break;
        case PROP_URI:
-               object_path = g_dbus_proxy_get_object_path (G_DBUS_PROXY (self));
-               text = g_strdup_printf ("secret-service://%s", object_path);
-               g_value_take_string (value, text);
+               g_value_take_string (value, seahorse_gkr_keyring_get_uri (place));
                break;
        case PROP_ACTIONS:
-               g_value_take_object (value, seahorse_gkr_keyring_actions_new (self));
+               g_value_take_object (value, seahorse_gkr_keyring_get_actions (place));
                break;
        case PROP_LOCKABLE:
                g_value_set_boolean (value, !secret_collection_get_locked (SECRET_COLLECTION (self)));
@@ -235,7 +267,7 @@ seahorse_gkr_keyring_get_property (GObject *obj, guint prop_id, GValue *value,
                g_value_set_boolean (value, TRUE);
                break;
        case PROP_ICON:
-               g_value_take_object (value, g_themed_icon_new ("folder"));
+               g_value_take_object (value, seahorse_gkr_keyring_get_icon (place));
                break;
        default:
                G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
@@ -270,8 +302,13 @@ seahorse_gkr_keyring_class_init (SeahorseGkrKeyringClass *klass)
 static void
 seahorse_gkr_keyring_place_iface (SeahorsePlaceIface *iface)
 {
-       iface->load_async = seahorse_gkr_keyring_load_async;
+       iface->load = seahorse_gkr_keyring_load_async;
        iface->load_finish = seahorse_gkr_keyring_load_finish;
+       iface->get_actions = seahorse_gkr_keyring_get_actions;
+       iface->get_description = seahorse_gkr_keyring_get_description;
+       iface->get_icon = seahorse_gkr_keyring_get_icon;
+       iface->get_label = seahorse_gkr_keyring_get_label;
+       iface->get_uri = seahorse_gkr_keyring_get_uri;
 }
 
 static guint
@@ -467,15 +504,6 @@ seahorse_keyring_viewable_iface (SeahorseViewableIface *iface)
        iface->show_viewer = seahorse_gkr_keyring_show_viewer;
 }
 
-const gchar *
-seahorse_gkr_keyring_get_description (SeahorseGkrKeyring *self)
-{
-       g_return_val_if_fail (SEAHORSE_IS_GKR_KEYRING (self), NULL);
-       if (seahorse_gkr_backend_has_alias (NULL, "login", self))
-               return _("A keyring that is automatically unlocked on login");
-       return _("A keyring used to store passwords");
-}
-
 gboolean
 seahorse_gkr_keyring_get_is_default (SeahorseGkrKeyring *self)
 {
diff --git a/gkr/seahorse-gkr-keyring.h b/gkr/seahorse-gkr-keyring.h
index e7c49b3..e6afaae 100644
--- a/gkr/seahorse-gkr-keyring.h
+++ b/gkr/seahorse-gkr-keyring.h
@@ -51,8 +51,6 @@ struct _SeahorseGkrKeyringClass {
 
 GType                seahorse_gkr_keyring_get_type         (void);
 
-const gchar *        seahorse_gkr_keyring_get_description  (SeahorseGkrKeyring *self);
-
 gboolean             seahorse_gkr_keyring_get_is_default   (SeahorseGkrKeyring *self);
 
 #endif /* __SEAHORSE_GKR_KEYRING_H__ */
diff --git a/libseahorse/Makefile.am b/libseahorse/Makefile.am
index ad43c89..64c4e76 100644
--- a/libseahorse/Makefile.am
+++ b/libseahorse/Makefile.am
@@ -61,7 +61,6 @@ libseahorse_la_SOURCES = \
        seahorse-object-model.c seahorse-object-model.h \
        seahorse-object-widget.c seahorse-object-widget.h \
        seahorse-passphrase.c seahorse-passphrase.h \
-       seahorse-place.c seahorse-place.h \
        seahorse-predicate.c seahorse-predicate.h \
        seahorse-prefs.c seahorse-prefs.h \
        seahorse-progress.c seahorse-progress.h \
diff --git a/libseahorse/seahorse-backend.h b/libseahorse/seahorse-backend.h
index d8dd75f..fee6ae5 100644
--- a/libseahorse/seahorse-backend.h
+++ b/libseahorse/seahorse-backend.h
@@ -22,7 +22,7 @@
 #ifndef __SEAHORSE_BACKEND_H__
 #define __SEAHORSE_BACKEND_H__
 
-#include "seahorse-place.h"
+#include "seahorse-common.h"
 
 #include <glib-object.h>
 
diff --git a/libseahorse/seahorse-catalog.h b/libseahorse/seahorse-catalog.h
index ce3c96a..08a3dfa 100644
--- a/libseahorse/seahorse-catalog.h
+++ b/libseahorse/seahorse-catalog.h
@@ -24,7 +24,7 @@
 
 #include <glib-object.h>
 
-#include "seahorse-place.h"
+#include "seahorse-common.h"
 #include "seahorse-widget.h"
 
 #define SEAHORSE_CATALOG_MENU_OBJECT   "ObjectPopup"
diff --git a/libseahorse/seahorse-key-manager-store.c b/libseahorse/seahorse-key-manager-store.c
index fe0b2c3..2f7fbd1 100644
--- a/libseahorse/seahorse-key-manager-store.c
+++ b/libseahorse/seahorse-key-manager-store.c
@@ -24,7 +24,6 @@
 #include "config.h"
 
 #include "seahorse-common.h"
-#include "seahorse-place.h"
 #include "seahorse-util.h"
 
 #include "seahorse-key-manager-store.h"
diff --git a/libseahorse/seahorse-object.c b/libseahorse/seahorse-object.c
index 89b27d2..563b8ac 100644
--- a/libseahorse/seahorse-object.c
+++ b/libseahorse/seahorse-object.c
@@ -22,8 +22,8 @@
 
 #include "config.h"
 
+#include "seahorse-common.h"
 #include "seahorse-object.h"
-#include "seahorse-place.h"
 #include "seahorse-predicate.h"
 
 #include "string.h"
diff --git a/libseahorse/seahorse-predicate.c b/libseahorse/seahorse-predicate.c
index 22c58f5..e3d508e 100644
--- a/libseahorse/seahorse-predicate.c
+++ b/libseahorse/seahorse-predicate.c
@@ -22,8 +22,8 @@
 
 #include "config.h"
 
+#include "seahorse-common.h"
 #include "seahorse-object.h"
-#include "seahorse-place.h"
 #include "seahorse-predicate.h"
 
 #include "string.h"
diff --git a/pgp/seahorse-gpgme-key.c b/pgp/seahorse-gpgme-key.c
index 9566423..67d1902 100644
--- a/pgp/seahorse-gpgme-key.c
+++ b/pgp/seahorse-gpgme-key.c
@@ -37,7 +37,6 @@
 #include "seahorse-icons.h"
 #include "seahorse-predicate.h"
 #include "seahorse-object-list.h"
-#include "seahorse-place.h"
 #include "seahorse-util.h"
 
 #include <glib/gi18n.h>
diff --git a/pgp/seahorse-gpgme-keyring.c b/pgp/seahorse-gpgme-keyring.c
index 0fb3bae..7a6f26b 100644
--- a/pgp/seahorse-gpgme-keyring.c
+++ b/pgp/seahorse-gpgme-keyring.c
@@ -32,7 +32,6 @@
 #include "seahorse-pgp-key.h"
 
 #include "seahorse-common.h"
-#include "seahorse-place.h"
 #include "seahorse-progress.h"
 #include "seahorse-util.h"
 #include "seahorse-passphrase.h"
@@ -802,29 +801,59 @@ seahorse_gpgme_keyring_init (SeahorseGpgmeKeyring *self)
        }
 }
 
+static gchar *
+seahorse_gpgme_keyring_get_label (SeahorsePlace *place)
+{
+       return g_strdup (_("GnuPG keys"));
+}
+
+static gchar *
+seahorse_gpgme_keyring_get_description (SeahorsePlace *place)
+{
+       return g_strdup (_("GnuPG: default keyring directory"));
+}
+
+static GIcon *
+seahorse_gpgme_keyring_get_icon (SeahorsePlace *place)
+{
+       return g_themed_icon_new (GCR_ICON_GNUPG);
+}
+
+static GtkActionGroup *
+seahorse_gpgme_keyring_get_actions (SeahorsePlace *place)
+{
+       return g_object_ref (SEAHORSE_GPGME_KEYRING (place)->pv->actions);
+}
+
+static gchar *
+seahorse_gpgme_keyring_get_uri (SeahorsePlace *place)
+{
+       return g_strdup ("gnupg://");
+}
+
 static void
 seahorse_gpgme_keyring_get_property (GObject *obj,
                                      guint prop_id,
                                      GValue *value,
                                      GParamSpec *pspec)
 {
-       SeahorseGpgmeKeyring *self = SEAHORSE_GPGME_KEYRING (obj);
+       SeahorsePlace *place = SEAHORSE_PLACE (obj);
 
        switch (prop_id) {
        case PROP_LABEL:
-               g_value_set_string (value, _("GnuPG keys"));
+               g_value_take_string (value, seahorse_gpgme_keyring_get_label (place));
                break;
        case PROP_DESCRIPTION:
-               g_value_set_string (value, _("GnuPG: default keyring directory"));
+               g_value_take_string (value, seahorse_gpgme_keyring_get_description (place));
                break;
        case PROP_ICON:
-               g_value_take_object (value, g_themed_icon_new (GCR_ICON_GNUPG));
+               g_value_take_object (value, seahorse_gpgme_keyring_get_icon (place));
                break;
        case PROP_URI:
-               g_value_set_string (value, "gnupg://");
+               g_value_take_string (value, seahorse_gpgme_keyring_get_uri (place));
                break;
        case PROP_ACTIONS:
-               g_value_set_object (value, self->pv->actions);
+               g_value_take_object (value, seahorse_gpgme_keyring_get_actions (place));
                break;
        default:
                G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
@@ -900,8 +929,13 @@ seahorse_gpgme_keyring_class_init (SeahorseGpgmeKeyringClass *klass)
 static void
 seahorse_gpgme_keyring_place_iface (SeahorsePlaceIface *iface)
 {
-       iface->load_async = seahorse_gpgme_keyring_load_async;
+       iface->load = seahorse_gpgme_keyring_load_async;
        iface->load_finish = seahorse_gpgme_keyring_load_finish;
+       iface->get_actions = seahorse_gpgme_keyring_get_actions;
+       iface->get_description = seahorse_gpgme_keyring_get_description;
+       iface->get_icon = seahorse_gpgme_keyring_get_icon;
+       iface->get_label = seahorse_gpgme_keyring_get_label;
+       iface->get_uri = seahorse_gpgme_keyring_get_uri;
 }
 
 static guint
diff --git a/pgp/seahorse-hkp-source.c b/pgp/seahorse-hkp-source.c
index 629a15d..120c927 100644
--- a/pgp/seahorse-hkp-source.c
+++ b/pgp/seahorse-hkp-source.c
@@ -35,7 +35,6 @@
 #include "seahorse-servers.h"
 
 #include "seahorse-object-list.h"
-#include "seahorse-place.h"
 #include "seahorse-progress.h"
 #include "seahorse-util.h"
 
@@ -490,10 +489,7 @@ detect_key (const gchar *text, gint len, const gchar **start, const gchar **end)
  *  SEAHORSE HKP SOURCE
  */
 
-static void seahorse_place_iface (SeahorsePlaceIface *iface);
-
-G_DEFINE_TYPE_EXTENDED (SeahorseHKPSource, seahorse_hkp_source, SEAHORSE_TYPE_SERVER_SOURCE, 0,
-                        G_IMPLEMENT_INTERFACE (SEAHORSE_TYPE_PLACE, seahorse_place_iface));
+G_DEFINE_TYPE (SeahorseHKPSource, seahorse_hkp_source, SEAHORSE_TYPE_SERVER_SOURCE);
 
 static void 
 seahorse_hkp_source_init (SeahorseHKPSource *hsrc)
@@ -1025,18 +1021,6 @@ seahorse_hkp_source_export_finish (SeahorseServerSource *source,
 }
 
 /**
-* iface: The interface to set
-*
-* Set up the default SeahorseSourceIface
-*
-**/
-static void 
-seahorse_place_iface (SeahorsePlaceIface *iface)
-{
-
-}
-
-/**
 * klass:
 *
 * Initialize the basic class stuff
diff --git a/pgp/seahorse-ldap-source.c b/pgp/seahorse-ldap-source.c
index 776912e..e2473be 100644
--- a/pgp/seahorse-ldap-source.c
+++ b/pgp/seahorse-ldap-source.c
@@ -34,8 +34,8 @@
 #include "seahorse-pgp-subkey.h"
 #include "seahorse-pgp-uid.h"
 
+#include "seahorse-common.h"
 #include "seahorse-object-list.h"
-#include "seahorse-place.h"
 #include "seahorse-progress.h"
 #include "seahorse-servers.h"
 #include "seahorse-util.h"
@@ -735,10 +735,7 @@ seahorse_ldap_source_connect_finish (SeahorseLDAPSource *source,
        return ldap;
 }
 
-static void seahorse_place_iface (SeahorsePlaceIface *iface);
-
-G_DEFINE_TYPE_EXTENDED (SeahorseLDAPSource, seahorse_ldap_source, SEAHORSE_TYPE_SERVER_SOURCE, 0,
-                        G_IMPLEMENT_INTERFACE (SEAHORSE_TYPE_PLACE, seahorse_place_iface));
+G_DEFINE_TYPE (SeahorseLDAPSource, seahorse_ldap_source, SEAHORSE_TYPE_SERVER_SOURCE);
 
 static void 
 seahorse_ldap_source_init (SeahorseLDAPSource *self)
@@ -1425,11 +1422,6 @@ seahorse_ldap_source_export_finish (SeahorseServerSource *source,
        return output;
 }
 
-static void 
-seahorse_place_iface (SeahorsePlaceIface *iface)
-{
-}
-
 /* Initialize the basic class stuff */
 static void
 seahorse_ldap_source_class_init (SeahorseLDAPSourceClass *klass)
diff --git a/pgp/seahorse-pgp-backend.c b/pgp/seahorse-pgp-backend.c
index cfb7e1f..256d231 100644
--- a/pgp/seahorse-pgp-backend.c
+++ b/pgp/seahorse-pgp-backend.c
@@ -142,7 +142,7 @@ seahorse_pgp_backend_constructed (GObject *obj)
        G_OBJECT_CLASS (seahorse_pgp_backend_parent_class)->constructed (obj);
 
        self->keyring = seahorse_gpgme_keyring_new ();
-       seahorse_place_load_async (SEAHORSE_PLACE (self->keyring), NULL, NULL, NULL);
+       seahorse_place_load (SEAHORSE_PLACE (self->keyring), NULL, NULL, NULL);
 
        self->discovery = seahorse_discovery_new ();
        self->unknown = seahorse_unknown_source_new ();
diff --git a/pgp/seahorse-server-source.c b/pgp/seahorse-server-source.c
index 0b2d541..2b1a53d 100644
--- a/pgp/seahorse-server-source.c
+++ b/pgp/seahorse-server-source.c
@@ -63,8 +63,11 @@ struct _SeahorseServerSourcePrivate {
 
 static void      seahorse_server_source_collection_init    (GcrCollectionIface *iface);
 
+static void      seahorse_server_source_place_iface        (SeahorsePlaceIface *iface);
+
 G_DEFINE_TYPE_WITH_CODE (SeahorseServerSource, seahorse_server_source, G_TYPE_OBJECT,
                          G_IMPLEMENT_INTERFACE (GCR_TYPE_COLLECTION, seahorse_server_source_collection_init);
+                         G_IMPLEMENT_INTERFACE (SEAHORSE_TYPE_PLACE, seahorse_server_source_place_iface);
 );
 
 /* GObject handlers */
@@ -148,6 +151,65 @@ seahorse_server_source_finalize (GObject *gobject)
     G_OBJECT_CLASS (seahorse_server_source_parent_class)->finalize (gobject);
 }
 
+static void
+seahorse_server_source_load (SeahorsePlace *self,
+                              GCancellable *cancellable,
+                              GAsyncReadyCallback callback,
+                              gpointer user_data)
+{
+       g_return_if_reached ();
+}
+
+static gboolean
+seahorse_server_source_load_finish (SeahorsePlace *self,
+                                     GAsyncResult *res,
+                                     GError **error)
+{
+       g_return_val_if_reached (FALSE);
+}
+
+static gchar *
+seahorse_server_source_get_label (SeahorsePlace* self)
+{
+       return g_strdup (SEAHORSE_SERVER_SOURCE (self)->priv->server);
+}
+
+static gchar *
+seahorse_server_source_get_description (SeahorsePlace* self)
+{
+       return g_strdup (SEAHORSE_SERVER_SOURCE (self)->priv->uri);
+}
+
+static gchar *
+seahorse_server_source_get_uri (SeahorsePlace* self)
+{
+       return g_strdup (SEAHORSE_SERVER_SOURCE (self)->priv->uri);
+}
+
+static GIcon *
+seahorse_server_source_get_icon (SeahorsePlace* self)
+{
+       return g_themed_icon_new (GTK_STOCK_DIALOG_QUESTION);
+}
+
+static GtkActionGroup *
+seahorse_server_source_get_actions (SeahorsePlace* self)
+{
+       return NULL;
+}
+
+static void
+seahorse_server_source_place_iface (SeahorsePlaceIface *iface)
+{
+       iface->load = seahorse_server_source_load;
+       iface->load_finish = seahorse_server_source_load_finish;
+       iface->get_actions = seahorse_server_source_get_actions;
+       iface->get_description = seahorse_server_source_get_description;
+       iface->get_icon = seahorse_server_source_get_icon;
+       iface->get_label = seahorse_server_source_get_label;
+       iface->get_uri = seahorse_server_source_get_uri;
+}
+
 /**
 * object: A SeahorseServerSource object
 * prop_id: The ID of the property to set
@@ -197,21 +259,26 @@ seahorse_server_get_property (GObject *obj,
                               GParamSpec *pspec)
 {
        SeahorseServerSource *self = SEAHORSE_SERVER_SOURCE (obj);
+       SeahorsePlace *place = SEAHORSE_PLACE (self);
 
        switch (prop_id) {
        case PROP_LABEL:
+               g_value_take_string (value, seahorse_server_source_get_label (place));
+               break;
        case PROP_KEY_SERVER:
                g_value_set_string (value, self->priv->server);
                break;
        case PROP_DESCRIPTION:
+               g_value_take_string (value, seahorse_server_source_get_description (place));
+               break;
        case PROP_URI:
-               g_value_set_string (value, self->priv->uri);
+               g_value_take_string (value, seahorse_server_source_get_uri (place));
                break;
        case PROP_ICON:
-               g_value_take_object (value, g_themed_icon_new (GTK_STOCK_DIALOG_QUESTION));
+               g_value_take_object (value, seahorse_server_source_get_icon (place));
                break;
        case PROP_ACTIONS:
-               g_value_set_object (value, NULL);
+               g_value_set_object (value, seahorse_server_source_get_actions (place));
                break;
        default:
                G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
diff --git a/pgp/seahorse-transfer.h b/pgp/seahorse-transfer.h
index ca9b56f..f4047d2 100644
--- a/pgp/seahorse-transfer.h
+++ b/pgp/seahorse-transfer.h
@@ -23,7 +23,7 @@
 #ifndef __SEAHORSE_TRANSFER_H__
 #define __SEAHORSE_TRANSFER_H__
 
-#include "seahorse-place.h"
+#include "seahorse-common.h"
 
 #include "seahorse-server-source.h"
 
diff --git a/pgp/seahorse-unknown-source.c b/pgp/seahorse-unknown-source.c
index 26f1f82..c0929c6 100644
--- a/pgp/seahorse-unknown-source.c
+++ b/pgp/seahorse-unknown-source.c
@@ -25,7 +25,7 @@
 #include "seahorse-pgp-key.h"
 #include "seahorse-unknown-source.h"
 
-#include "seahorse-place.h"
+#include "seahorse-common.h"
 #include "seahorse-unknown.h"
 
 #include <gcr/gcr-base.h>
@@ -68,24 +68,75 @@ seahorse_unknown_source_init (SeahorseUnknownSource *self)
 }
 
 static void
+seahorse_unknown_source_load (SeahorsePlace *self,
+                              GCancellable *cancellable,
+                              GAsyncReadyCallback callback,
+                              gpointer user_data)
+{
+       g_return_if_reached ();
+}
+
+static gboolean
+seahorse_unknown_source_load_finish (SeahorsePlace *self,
+                                     GAsyncResult *res,
+                                     GError **error)
+{
+       g_return_val_if_reached (FALSE);
+}
+
+static gchar *
+seahorse_unknown_source_get_label (SeahorsePlace* self)
+{
+       return g_strdup ("");
+}
+
+static gchar *
+seahorse_unknown_source_get_description (SeahorsePlace* self)
+{
+       return NULL;
+}
+
+static gchar *
+seahorse_unknown_source_get_uri (SeahorsePlace* self)
+{
+       return NULL;
+}
+
+static GIcon *
+seahorse_unknown_source_get_icon (SeahorsePlace* self)
+{
+       return NULL;
+}
+
+static GtkActionGroup *
+seahorse_unknown_source_get_actions (SeahorsePlace* self)
+{
+       return NULL;
+}
+
+static void
 seahorse_unknown_source_get_property (GObject *obj,
                                       guint prop_id,
                                       GValue *value,
                                       GParamSpec *pspec)
 {
+       SeahorsePlace *place = SEAHORSE_PLACE (obj);
+
        switch (prop_id) {
        case PROP_LABEL:
-               g_value_set_string (value, "");
+               g_value_take_string (value, seahorse_unknown_source_get_label (place));
                break;
        case PROP_DESCRIPTION:
+               g_value_take_string (value, seahorse_unknown_source_get_description (place));
+               break;
        case PROP_URI:
-               g_value_set_string (value, NULL);
+               g_value_take_string (value, seahorse_unknown_source_get_uri (place));
                break;
        case PROP_ICON:
-               g_value_set_object (value, NULL);
+               g_value_take_object (value, seahorse_unknown_source_get_icon (place));
                break;
        case PROP_ACTIONS:
-               g_value_set_object (value, NULL);
+               g_value_take_object (value, seahorse_unknown_source_get_actions (place));
                break;
        default:
                G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
@@ -152,7 +203,13 @@ seahorse_unknown_source_collection_iface (GcrCollectionIface *iface)
 static void
 seahorse_unknown_source_place_iface (SeahorsePlaceIface *iface)
 {
-       /* no implementation */
+       iface->load = seahorse_unknown_source_load;
+       iface->load_finish = seahorse_unknown_source_load_finish;
+       iface->get_actions = seahorse_unknown_source_get_actions;
+       iface->get_description = seahorse_unknown_source_get_description;
+       iface->get_icon = seahorse_unknown_source_get_icon;
+       iface->get_label = seahorse_unknown_source_get_label;
+       iface->get_uri = seahorse_unknown_source_get_uri;
 }
 
 SeahorseUnknownSource*
diff --git a/pkcs11/seahorse-pkcs11-backend.c b/pkcs11/seahorse-pkcs11-backend.c
index ccac03c..1f076fe 100644
--- a/pkcs11/seahorse-pkcs11-backend.c
+++ b/pkcs11/seahorse-pkcs11-backend.c
@@ -27,7 +27,6 @@
 #include "seahorse-token.h"
 
 #include "seahorse-backend.h"
-#include "seahorse-place.h"
 #include "seahorse-util.h"
 
 #include <gcr/gcr-base.h>
diff --git a/pkcs11/seahorse-pkcs11-generate.c b/pkcs11/seahorse-pkcs11-generate.c
index db0f56a..ac5c261 100644
--- a/pkcs11/seahorse-pkcs11-generate.c
+++ b/pkcs11/seahorse-pkcs11-generate.c
@@ -113,7 +113,7 @@ complete_generate (SeahorsePkcs11Generate *self,
        if (*error != NULL)
                seahorse_util_handle_error (error, NULL, _("Couldn't generate private key"));
        else
-               seahorse_place_load_async (SEAHORSE_PLACE (self->token), self->cancellable, NULL, NULL);
+               seahorse_place_load (SEAHORSE_PLACE (self->token), self->cancellable, NULL, NULL);
 
        g_clear_object (&self->cancellable);
        gck_attributes_unref (self->pub_attrs);
diff --git a/pkcs11/seahorse-token.c b/pkcs11/seahorse-token.c
index 575e8e4..ea1eb4f 100644
--- a/pkcs11/seahorse-token.c
+++ b/pkcs11/seahorse-token.c
@@ -34,8 +34,8 @@
 #include "seahorse-private-key.h"
 #include "seahorse-token.h"
 
+#include "seahorse-common.h"
 #include "seahorse-lockable.h"
-#include "seahorse-place.h"
 #include "seahorse-util.h"
 
 enum {
@@ -550,7 +550,7 @@ seahorse_token_constructed (GObject *obj)
 
        g_return_if_fail (self->pv->slot != NULL);
 
-       seahorse_place_load_async (SEAHORSE_PLACE (self), NULL, NULL, NULL);
+       seahorse_place_load (SEAHORSE_PLACE (self), NULL, NULL, NULL);
 
        data = gck_uri_data_new ();
        data->token_info = seahorse_token_get_info (self);
@@ -559,6 +559,70 @@ seahorse_token_constructed (GObject *obj)
        gck_uri_data_free (data);
 }
 
+static gchar *
+seahorse_token_get_label (SeahorsePlace* place)
+{
+       SeahorseToken *self = SEAHORSE_TOKEN (place);
+       GckTokenInfo *token;
+       gchar *string;
+
+       token = gck_slot_get_token_info (self->pv->slot);
+       if (token == NULL)
+               string = g_strdup (C_("Label", "Unknown"));
+       else
+               string = g_strdup (token->label);
+       gck_token_info_free (token);
+
+       return string;
+}
+
+static gchar *
+seahorse_token_get_description (SeahorsePlace* place)
+{
+       SeahorseToken *self = SEAHORSE_TOKEN (place);
+       GckTokenInfo *token;
+       gchar *string;
+
+       token = gck_slot_get_token_info (self->pv->slot);
+       if (token == NULL)
+               string = NULL;
+       else
+               string = g_strdup (token->manufacturer_id);
+       gck_token_info_free (token);
+
+       return string;
+}
+
+static gchar *
+seahorse_token_get_uri (SeahorsePlace* place)
+{
+       return g_strdup (SEAHORSE_TOKEN (place)->pv->uri);
+}
+
+static GIcon *
+seahorse_token_get_icon (SeahorsePlace* place)
+{
+       SeahorseToken *self = SEAHORSE_TOKEN (place);
+       GckTokenInfo *token;
+       GIcon *icon;
+
+       token = gck_slot_get_token_info (self->pv->slot);
+       if (token == NULL)
+               icon = g_themed_icon_new (GTK_STOCK_DIALOG_QUESTION);
+       else
+               icon = gcr_icon_for_token (token);
+       gck_token_info_free (token);
+
+       return icon;
+}
+
+static GtkActionGroup *
+seahorse_token_get_actions (SeahorsePlace* place)
+{
+       return NULL;
+}
+
+
 static void
 seahorse_token_get_property (GObject *object,
                              guint prop_id,
@@ -566,32 +630,17 @@ seahorse_token_get_property (GObject *object,
                              GParamSpec *pspec)
 {
        SeahorseToken *self = SEAHORSE_TOKEN (object);
-       GckTokenInfo *token;
+       SeahorsePlace *place = SEAHORSE_PLACE (object);
 
        switch (prop_id) {
        case PROP_LABEL:
-               token = gck_slot_get_token_info (self->pv->slot);
-               if (token == NULL)
-                       g_value_set_string (value, C_("Label", "Unknown"));
-               else
-                       g_value_set_string (value, token->label);
-               gck_token_info_free (token);
+               g_value_take_string (value, seahorse_token_get_label (place));
                break;
        case PROP_DESCRIPTION:
-               token = gck_slot_get_token_info (self->pv->slot);
-               if (token == NULL)
-                       g_value_set_string (value, NULL);
-               else
-                       g_value_set_string (value, token->manufacturer_id);
-               gck_token_info_free (token);
+               g_value_take_string (value, seahorse_token_get_description (place));
                break;
        case PROP_ICON:
-               token = gck_slot_get_token_info (self->pv->slot);
-               if (token == NULL)
-                       g_value_take_object (value, g_themed_icon_new (GTK_STOCK_DIALOG_QUESTION));
-               else
-                       g_value_take_object (value, gcr_icon_for_token (token));
-               gck_token_info_free (token);
+               g_value_take_object (value, seahorse_token_get_icon (place));
                break;
        case PROP_SLOT:
                g_value_set_object (value, self->pv->slot);
@@ -600,10 +649,10 @@ seahorse_token_get_property (GObject *object,
                g_value_set_uint (value, 0);
                break;
        case PROP_URI:
-               g_value_set_string (value, self->pv->uri);
+               g_value_take_string (value, seahorse_token_get_uri (place));
                break;
        case PROP_ACTIONS:
-               g_value_set_object (value, NULL);
+               g_value_take_object (value, seahorse_token_get_actions (place));
                break;
        case PROP_INFO:
                g_value_set_boxed (value, self->pv->info);
@@ -724,8 +773,13 @@ seahorse_token_class_init (SeahorseTokenClass *klass)
 static void
 seahorse_token_place_iface (SeahorsePlaceIface *iface)
 {
-       iface->load_async = seahorse_token_load_async;
+       iface->load = seahorse_token_load_async;
        iface->load_finish = seahorse_token_load_finish;
+       iface->get_actions = seahorse_token_get_actions;
+       iface->get_description = seahorse_token_get_description;
+       iface->get_icon = seahorse_token_get_icon;
+       iface->get_label = seahorse_token_get_label;
+       iface->get_uri = seahorse_token_get_uri;
 }
 
 static guint
@@ -788,7 +842,7 @@ on_session_logout (GObject *source,
 
        gck_session_logout_finish (GCK_SESSION (source), result, &error);
        if (error == NULL)
-               seahorse_place_load_async (SEAHORSE_PLACE (self), NULL, NULL, NULL);
+               seahorse_place_load (SEAHORSE_PLACE (self), NULL, NULL, NULL);
        else
                g_simple_async_result_take_error (res, error);
 
@@ -830,7 +884,7 @@ on_session_login_open (GObject *source,
        session = gck_session_open_finish (result, &error);
        if (error == NULL) {
                seahorse_token_set_session (self, session);
-               seahorse_place_load_async (SEAHORSE_PLACE (self), NULL, NULL, NULL);
+               seahorse_place_load (SEAHORSE_PLACE (self), NULL, NULL, NULL);
                g_object_unref (session);
        } else {
                g_simple_async_result_take_error (res, error);
diff --git a/src/seahorse-import-dialog.c b/src/seahorse-import-dialog.c
index c6843b2..2979d5e 100644
--- a/src/seahorse-import-dialog.c
+++ b/src/seahorse-import-dialog.c
@@ -24,7 +24,6 @@
 #include "config.h"
 
 #include "seahorse-backend.h"
-#include "seahorse-place.h"
 
 #include "seahorse-import-dialog.h"
 
@@ -88,7 +87,7 @@ on_import_button_imported (GcrImportButton *button,
                for (l = backends; l != NULL; l = g_list_next (l)) {
                        place = seahorse_backend_lookup_place (l->data, uri);
                        if (place != NULL)
-                               seahorse_place_load_async (place, NULL, NULL, NULL);
+                               seahorse_place_load (place, NULL, NULL, NULL);
                }
                g_list_free (backends);
                g_free (uri);
diff --git a/src/seahorse-sidebar.c b/src/seahorse-sidebar.c
index 5390e15..bae1074 100644
--- a/src/seahorse-sidebar.c
+++ b/src/seahorse-sidebar.c
@@ -29,7 +29,6 @@
 #include "seahorse-common.h"
 #include "seahorse-interaction.h"
 #include "seahorse-lockable.h"
-#include "seahorse-place.h"
 #include "seahorse-util.h"
 
 #include "gkr/seahorse-gkr.h"
diff --git a/src/seahorse-sidebar.h b/src/seahorse-sidebar.h
index c0d326a..82286d8 100644
--- a/src/seahorse-sidebar.h
+++ b/src/seahorse-sidebar.h
@@ -22,7 +22,7 @@
 #ifndef __SEAHORSE_SIDEBAR_H__
 #define __SEAHORSE_SIDEBAR_H__
 
-#include "seahorse-place.h"
+#include "seahorse-common.h"
 
 #include <gcr/gcr.h>
 
diff --git a/ssh/seahorse-ssh-backend.c b/ssh/seahorse-ssh-backend.c
index 72e0ed0..0f370b2 100644
--- a/ssh/seahorse-ssh-backend.c
+++ b/ssh/seahorse-ssh-backend.c
@@ -74,7 +74,7 @@ seahorse_ssh_backend_constructed (GObject *obj)
        G_OBJECT_CLASS (seahorse_ssh_backend_parent_class)->constructed (obj);
 
        self->dot_ssh = seahorse_ssh_source_new ();
-       seahorse_place_load_async (SEAHORSE_PLACE (self->dot_ssh), NULL, NULL, NULL);
+       seahorse_place_load (SEAHORSE_PLACE (self->dot_ssh), NULL, NULL, NULL);
 }
 
 static void
diff --git a/ssh/seahorse-ssh-key.c b/ssh/seahorse-ssh-key.c
index b1914a4..a353013 100644
--- a/ssh/seahorse-ssh-key.c
+++ b/ssh/seahorse-ssh-key.c
@@ -32,7 +32,6 @@
 
 #include "seahorse-common.h"
 #include "seahorse-icons.h"
-#include "seahorse-place.h"
 #include "seahorse-validity.h"
 
 #include <gcr/gcr.h>
diff --git a/ssh/seahorse-ssh-key.h b/ssh/seahorse-ssh-key.h
index 8cd9319..954f6b4 100644
--- a/ssh/seahorse-ssh-key.h
+++ b/ssh/seahorse-ssh-key.h
@@ -26,7 +26,6 @@
 #include <gtk/gtk.h>
 
 #include "seahorse-object.h"
-#include "seahorse-place.h"
 #include "seahorse-validity.h"
 
 #include "seahorse-ssh-key-data.h"
diff --git a/ssh/seahorse-ssh-source.c b/ssh/seahorse-ssh-source.c
index c77c28a..73e2977 100644
--- a/ssh/seahorse-ssh-source.c
+++ b/ssh/seahorse-ssh-source.c
@@ -27,7 +27,7 @@
 #include "seahorse-ssh-operation.h"
 #include "seahorse-ssh-source.h"
 
-#include "seahorse-place.h"
+#include "seahorse-common.h"
 #include "seahorse-util.h"
 
 #include <gcr/gcr.h>
@@ -148,7 +148,7 @@ scheduled_refresh (SeahorseSSHSource *ssrc)
 {
     seahorse_debug ("scheduled refresh event ocurring now");
     cancel_scheduled_refresh (ssrc);
-    seahorse_place_load_async (SEAHORSE_PLACE (ssrc), NULL, NULL, NULL);
+    seahorse_place_load (SEAHORSE_PLACE (ssrc), NULL, NULL, NULL);
     return FALSE; /* don't run again */    
 }
 
@@ -217,6 +217,38 @@ merge_keydata (SeahorseSSHKey *prev, SeahorseSSHKeyData *keydata)
         
 }
 
+static gchar *
+seahorse_ssh_source_get_label (SeahorsePlace *place)
+{
+       return g_strdup (_("OpenSSH keys"));
+}
+
+static gchar *
+seahorse_ssh_source_get_description (SeahorsePlace *place)
+{
+       SeahorseSSHSource *self = SEAHORSE_SSH_SOURCE (place);
+       return g_strdup_printf (_("OpenSSH: %s"), self->priv->ssh_homedir);
+}
+
+static gchar *
+seahorse_ssh_source_get_uri (SeahorsePlace *place)
+{
+       SeahorseSSHSource *self = SEAHORSE_SSH_SOURCE (place);
+       return g_strdup_printf ("openssh://%s", self->priv->ssh_homedir);
+}
+
+static GIcon *
+seahorse_ssh_source_get_icon (SeahorsePlace *place)
+{
+       return g_themed_icon_new (GCR_ICON_HOME_DIRECTORY);
+}
+
+static GtkActionGroup *
+seahorse_ssh_source_get_actions (SeahorsePlace* self)
+{
+       return NULL;
+}
+
 static void 
 seahorse_ssh_source_get_property (GObject *obj,
                                   guint prop_id,
@@ -224,28 +256,26 @@ seahorse_ssh_source_get_property (GObject *obj,
                                   GParamSpec *pspec)
 {
        SeahorseSSHSource *self = SEAHORSE_SSH_SOURCE (obj);
-       gchar *text;
+       SeahorsePlace *place = SEAHORSE_PLACE (obj);
 
        switch (prop_id) {
        case PROP_LABEL:
-               g_value_set_string (value, _("OpenSSH keys"));
+               g_value_take_string (value, seahorse_ssh_source_get_label (place));
                break;
        case PROP_DESCRIPTION:
-               text = g_strdup_printf (_("OpenSSH: %s"), self->priv->ssh_homedir);
-               g_value_take_string (value, text);
+               g_value_take_string (value, seahorse_ssh_source_get_description (place));
                break;
        case PROP_ICON:
-               g_value_take_object (value, g_themed_icon_new (GCR_ICON_HOME_DIRECTORY));
+               g_value_take_object (value, seahorse_ssh_source_get_icon (place));
                break;
        case PROP_BASE_DIRECTORY:
                g_value_set_string (value, self->priv->ssh_homedir);
                break;
        case PROP_URI:
-               g_value_take_string (value, g_strdup_printf ("openssh://%s",
-                                                            self->priv->ssh_homedir));
+               g_value_take_string (value, seahorse_ssh_source_get_uri (place));
                break;
        case PROP_ACTIONS:
-               g_value_set_object (value, NULL);
+               g_value_take_object (value, seahorse_ssh_source_get_actions (place));
                break;
        default:
                G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
@@ -826,8 +856,13 @@ seahorse_ssh_source_import_finish (SeahorseSSHSource *self,
 static void 
 seahorse_ssh_source_place_iface (SeahorsePlaceIface *iface)
 {
-       iface->load_async = seahorse_ssh_source_load_async;
+       iface->load = seahorse_ssh_source_load_async;
        iface->load_finish = seahorse_ssh_source_load_finish;
+       iface->get_actions = seahorse_ssh_source_get_actions;
+       iface->get_description = seahorse_ssh_source_get_description;
+       iface->get_icon = seahorse_ssh_source_get_icon;
+       iface->get_label = seahorse_ssh_source_get_label;
+       iface->get_uri = seahorse_ssh_source_get_uri;
 }
 
 /* -----------------------------------------------------------------------------


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