[seahorse] common: Port SeahorseBackend to vala
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [seahorse] common: Port SeahorseBackend to vala
- Date: Wed, 26 Jun 2013 10:18:34 +0000 (UTC)
commit 0900e89bd89a6b589287a1af81bc573f853a8a05
Author: Stef Walter <stefw gnome org>
Date: Thu May 2 21:09:35 2013 +0200
common: Port SeahorseBackend to vala
common/Makefile.am | 1 +
common/backend.vala | 41 ++++++++++++++++
gkr/seahorse-gkr-backend.c | 40 +++++++++++++--
libseahorse/Makefile.am | 1 -
libseahorse/seahorse-backend.c | 83 --------------------------------
libseahorse/seahorse-backend.h | 53 --------------------
libseahorse/seahorse-catalog.c | 1 -
libseahorse/seahorse-search-provider.c | 1 -
pgp/seahorse-pgp-backend.c | 40 +++++++++++++--
pkcs11/seahorse-pkcs11-backend.c | 39 +++++++++++++--
src/seahorse-import-dialog.c | 2 +-
src/seahorse-sidebar.c | 1 -
ssh/seahorse-ssh-backend.c | 40 +++++++++++++--
13 files changed, 181 insertions(+), 162 deletions(-)
---
diff --git a/common/Makefile.am b/common/Makefile.am
index f11cac0..e99efb7 100644
--- a/common/Makefile.am
+++ b/common/Makefile.am
@@ -7,6 +7,7 @@ INCLUDES = -I$(top_builddir) \
noinst_LTLIBRARIES = libcommon.la
libcommon_la_SOURCES = \
+ backend.vala \
deletable.vala \
deleter.vala \
exportable.vala \
diff --git a/common/backend.vala b/common/backend.vala
new file mode 100644
index 0000000..d0ddbfb
--- /dev/null
+++ b/common/backend.vala
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+
+namespace Seahorse {
+
+public interface Backend : Gcr.Collection {
+ public abstract string name { get; }
+ public abstract string label { get; }
+ public abstract string description { get; }
+ public abstract Gtk.ActionGroup actions { owned get; }
+
+ public abstract Place lookup_place(string uri);
+
+ public void register() {
+ Registry.register_object(this, "backend");
+ }
+
+ public static GLib.List<Backend> get_registered() {
+ return (GLib.List<Seahorse.Backend>)Registry.object_instances("backend");
+ }
+}
+
+}
diff --git a/gkr/seahorse-gkr-backend.c b/gkr/seahorse-gkr-backend.c
index d70e8b6..f0af32d 100644
--- a/gkr/seahorse-gkr-backend.c
+++ b/gkr/seahorse-gkr-backend.c
@@ -25,7 +25,7 @@
#include "seahorse-gkr-backend.h"
#include "seahorse-gkr-dialogs.h"
-#include "seahorse-backend.h"
+#include "seahorse-common.h"
#include "seahorse-progress.h"
#include <glib/gi18n.h>
@@ -191,6 +191,31 @@ seahorse_gkr_backend_constructed (GObject *obj)
NULL, on_service_new, g_object_ref (self));
}
+static const gchar *
+seahorse_gkr_backend_get_name (SeahorseBackend *backend)
+{
+ return SEAHORSE_GKR_NAME;
+}
+
+static const gchar *
+seahorse_gkr_backend_get_label (SeahorseBackend *backend)
+{
+ return _("Passwords");
+}
+
+static const gchar *
+seahorse_gkr_backend_get_description (SeahorseBackend *backend)
+{
+ return _("Stored personal passwords, credentials and secrets");
+}
+
+static GtkActionGroup *
+seahorse_gkr_backend_get_actions (SeahorseBackend *backend)
+{
+ SeahorseGkrBackend *self = SEAHORSE_GKR_BACKEND (backend);
+ return g_object_ref (self->actions);
+}
+
static void
seahorse_gkr_backend_get_property (GObject *obj,
guint prop_id,
@@ -198,19 +223,20 @@ seahorse_gkr_backend_get_property (GObject *obj,
GParamSpec *pspec)
{
SeahorseGkrBackend *self = SEAHORSE_GKR_BACKEND (obj);
+ SeahorseBackend *backend = SEAHORSE_BACKEND (obj);
switch (prop_id) {
case PROP_NAME:
- g_value_set_string (value, SEAHORSE_GKR_NAME);
+ g_value_set_string (value, seahorse_gkr_backend_get_name (backend));
break;
case PROP_LABEL:
- g_value_set_string (value, _("Passwords"));
+ g_value_set_string (value, seahorse_gkr_backend_get_label (backend));
break;
case PROP_DESCRIPTION:
- g_value_set_string (value, _("Stored personal passwords, credentials and secrets"));
+ g_value_set_string (value, seahorse_gkr_backend_get_description (backend));
break;
case PROP_ACTIONS:
- g_value_set_object (value, self->actions);
+ g_value_take_object (value, seahorse_gkr_backend_get_actions (backend));
break;
case PROP_ALIASES:
g_value_set_boxed (value, self->aliases);
@@ -335,6 +361,10 @@ static void
seahorse_gkr_backend_iface (SeahorseBackendIface *iface)
{
iface->lookup_place = seahorse_gkr_backend_lookup_place;
+ iface->get_actions = seahorse_gkr_backend_get_actions;
+ iface->get_description = seahorse_gkr_backend_get_description;
+ iface->get_label = seahorse_gkr_backend_get_label;
+ iface->get_name = seahorse_gkr_backend_get_name;
}
void
diff --git a/libseahorse/Makefile.am b/libseahorse/Makefile.am
index 64c4e76..f554bcc 100644
--- a/libseahorse/Makefile.am
+++ b/libseahorse/Makefile.am
@@ -46,7 +46,6 @@ libseahorse_la_SOURCES = \
seahorse-action.c seahorse-action.h \
seahorse-actions.c seahorse-actions.h \
seahorse-application.c seahorse-application.h \
- seahorse-backend.c seahorse-backend.h \
seahorse-bind.c seahorse-bind.h \
seahorse-catalog.c seahorse-catalog.h \
seahorse-collection.c seahorse-collection.h \
diff --git a/libseahorse/seahorse-catalog.c b/libseahorse/seahorse-catalog.c
index ac76674..403f402 100644
--- a/libseahorse/seahorse-catalog.c
+++ b/libseahorse/seahorse-catalog.c
@@ -24,7 +24,6 @@
#include "seahorse-action.h"
#include "seahorse-actions.h"
-#include "seahorse-backend.h"
#include "seahorse-catalog.h"
#include "seahorse-common.h"
#include "seahorse-object.h"
diff --git a/libseahorse/seahorse-search-provider.c b/libseahorse/seahorse-search-provider.c
index 85f2727..d435383 100644
--- a/libseahorse/seahorse-search-provider.c
+++ b/libseahorse/seahorse-search-provider.c
@@ -27,7 +27,6 @@
#define SECRET_API_SUBJECT_TO_CHANGE
#include <libsecret/secret.h>
-#include "seahorse-backend.h"
#include "seahorse-predicate.h"
#include "seahorse-common.h"
#include "seahorse-widget.h"
diff --git a/pgp/seahorse-pgp-backend.c b/pgp/seahorse-pgp-backend.c
index 256d231..86a89ff 100644
--- a/pgp/seahorse-pgp-backend.c
+++ b/pgp/seahorse-pgp-backend.c
@@ -28,7 +28,6 @@
#include "seahorse-transfer.h"
#include "seahorse-unknown-source.h"
-#include "seahorse-backend.h"
#include "seahorse-common.h"
#include "seahorse-progress.h"
#include "seahorse-servers.h"
@@ -156,26 +155,51 @@ seahorse_pgp_backend_constructed (GObject *obj)
#endif
}
+static const gchar *
+seahorse_pgp_backend_get_name (SeahorseBackend *backend)
+{
+ return SEAHORSE_PGP_NAME;
+}
+
+static const gchar *
+seahorse_pgp_backend_get_label (SeahorseBackend *backend)
+{
+ return _("PGP Keys");
+}
+
+static const gchar *
+seahorse_pgp_backend_get_description (SeahorseBackend *backend)
+{
+ return _("PGP keys are for encrypting email or files");
+}
+
+static GtkActionGroup *
+seahorse_pgp_backend_get_actions (SeahorseBackend *backend)
+{
+ SeahorsePgpBackend *self = SEAHORSE_PGP_BACKEND (backend);
+ return g_object_ref (self->actions);
+}
+
static void
seahorse_pgp_backend_get_property (GObject *obj,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
- SeahorsePgpBackend *self = SEAHORSE_PGP_BACKEND (obj);
+ SeahorseBackend *backend = SEAHORSE_BACKEND (obj);
switch (prop_id) {
case PROP_NAME:
- g_value_set_string (value, SEAHORSE_PGP_NAME);
+ g_value_set_string (value, seahorse_pgp_backend_get_name (backend));
break;
case PROP_LABEL:
- g_value_set_string (value, _("PGP Keys"));
+ g_value_set_string (value, seahorse_pgp_backend_get_label (backend));
break;
case PROP_DESCRIPTION:
- g_value_set_string (value, _("PGP keys are for encrypting email or files"));
+ g_value_set_string (value, seahorse_pgp_backend_get_description (backend));
break;
case PROP_ACTIONS:
- g_value_set_object (value, self->actions);
+ g_value_take_object (value, seahorse_pgp_backend_get_actions (backend));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
@@ -261,6 +285,10 @@ static void
seahorse_pgp_backend_iface (SeahorseBackendIface *iface)
{
iface->lookup_place = seahorse_pgp_backend_lookup_place;
+ iface->get_actions = seahorse_pgp_backend_get_actions;
+ iface->get_description = seahorse_pgp_backend_get_description;
+ iface->get_label = seahorse_pgp_backend_get_label;
+ iface->get_name = seahorse_pgp_backend_get_name;
}
SeahorsePgpBackend *
diff --git a/pkcs11/seahorse-pkcs11-backend.c b/pkcs11/seahorse-pkcs11-backend.c
index 1f076fe..6e8cd8c 100644
--- a/pkcs11/seahorse-pkcs11-backend.c
+++ b/pkcs11/seahorse-pkcs11-backend.c
@@ -26,7 +26,6 @@
#include "seahorse-pkcs11-generate.h"
#include "seahorse-token.h"
-#include "seahorse-backend.h"
#include "seahorse-util.h"
#include <gcr/gcr-base.h>
@@ -171,24 +170,50 @@ seahorse_pkcs11_backend_constructed (GObject *obj)
g_object_ref (self));
}
+static const gchar *
+seahorse_pkcs11_backend_get_name (SeahorseBackend *backend)
+{
+ return SEAHORSE_PKCS11_NAME;
+}
+
+static const gchar *
+seahorse_pkcs11_backend_get_label (SeahorseBackend *backend)
+{
+ return _("Certificates");
+}
+
+static const gchar *
+seahorse_pkcs11_backend_get_description (SeahorseBackend *backend)
+{
+ return _("X.509 certificates and related keys");
+}
+
+static GtkActionGroup *
+seahorse_pkcs11_backend_get_actions (SeahorseBackend *backend)
+{
+ return NULL;
+}
+
static void
seahorse_pkcs11_backend_get_property (GObject *obj,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
+ SeahorseBackend *backend = SEAHORSE_BACKEND (obj);
+
switch (prop_id) {
case PROP_NAME:
- g_value_set_string (value, SEAHORSE_PKCS11_NAME);
+ g_value_set_string (value, seahorse_pkcs11_backend_get_name (backend));
break;
case PROP_LABEL:
- g_value_set_string (value, _("Certificates"));
+ g_value_set_string (value, seahorse_pkcs11_backend_get_label (backend));
break;
case PROP_DESCRIPTION:
- g_value_set_string (value, _("X.509 certificates and related keys"));
+ g_value_set_string (value, seahorse_pkcs11_backend_get_description (backend));
break;
case PROP_ACTIONS:
- g_value_set_object (value, NULL);
+ g_value_take_object (value, seahorse_pkcs11_backend_get_actions (backend));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
@@ -294,6 +319,10 @@ static void
seahorse_pkcs11_backend_iface (SeahorseBackendIface *iface)
{
iface->lookup_place = seahorse_pkcs11_backend_lookup_place;
+ iface->get_actions = seahorse_pkcs11_backend_get_actions;
+ iface->get_description = seahorse_pkcs11_backend_get_description;
+ iface->get_label = seahorse_pkcs11_backend_get_label;
+ iface->get_name = seahorse_pkcs11_backend_get_name;
}
void
diff --git a/src/seahorse-import-dialog.c b/src/seahorse-import-dialog.c
index 2979d5e..6c1e31a 100644
--- a/src/seahorse-import-dialog.c
+++ b/src/seahorse-import-dialog.c
@@ -23,7 +23,7 @@
#include "config.h"
-#include "seahorse-backend.h"
+#include "seahorse-common.h"
#include "seahorse-import-dialog.h"
diff --git a/src/seahorse-sidebar.c b/src/seahorse-sidebar.c
index bae1074..363cffe 100644
--- a/src/seahorse-sidebar.c
+++ b/src/seahorse-sidebar.c
@@ -25,7 +25,6 @@
#include "seahorse-action.h"
#include "seahorse-actions.h"
-#include "seahorse-backend.h"
#include "seahorse-common.h"
#include "seahorse-interaction.h"
#include "seahorse-lockable.h"
diff --git a/ssh/seahorse-ssh-backend.c b/ssh/seahorse-ssh-backend.c
index 0f370b2..809c7b3 100644
--- a/ssh/seahorse-ssh-backend.c
+++ b/ssh/seahorse-ssh-backend.c
@@ -25,7 +25,7 @@
#include "seahorse-ssh-dialogs.h"
#include "seahorse-ssh-source.h"
-#include "seahorse-backend.h"
+#include "seahorse-common.h"
#include <glib/gi18n.h>
@@ -77,24 +77,50 @@ seahorse_ssh_backend_constructed (GObject *obj)
seahorse_place_load (SEAHORSE_PLACE (self->dot_ssh), NULL, NULL, NULL);
}
+static const gchar *
+seahorse_ssh_backend_get_name (SeahorseBackend *backend)
+{
+ return SEAHORSE_SSH_NAME;
+}
+
+static const gchar *
+seahorse_ssh_backend_get_label (SeahorseBackend *backend)
+{
+ return _("Secure Shell");
+}
+
+static const gchar *
+seahorse_ssh_backend_get_description (SeahorseBackend *backend)
+{
+ return _("Keys used to connect securely to other computers");
+}
+
+static GtkActionGroup *
+seahorse_ssh_backend_get_actions (SeahorseBackend *backend)
+{
+ return NULL;
+}
+
static void
seahorse_ssh_backend_get_property (GObject *obj,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
+ SeahorseBackend *backend = SEAHORSE_BACKEND (obj);
+
switch (prop_id) {
case PROP_NAME:
- g_value_set_string (value, SEAHORSE_SSH_NAME);
+ g_value_set_string (value, seahorse_ssh_backend_get_name (backend));
break;
case PROP_LABEL:
- g_value_set_string (value, _("Secure Shell"));
+ g_value_set_string (value, seahorse_ssh_backend_get_label (backend));
break;
case PROP_DESCRIPTION:
- g_value_set_string (value, _("Keys used to connect securely to other computers"));
+ g_value_set_string (value, seahorse_ssh_backend_get_description (backend));
break;
case PROP_ACTIONS:
- g_value_set_object (value, NULL);
+ g_value_take_object (value, seahorse_ssh_backend_get_actions (backend));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
@@ -180,6 +206,10 @@ static void
seahorse_ssh_backend_iface (SeahorseBackendIface *iface)
{
iface->lookup_place = seahorse_ssh_backend_lookup_place;
+ iface->get_actions = seahorse_ssh_backend_get_actions;
+ iface->get_description = seahorse_ssh_backend_get_description;
+ iface->get_label = seahorse_ssh_backend_get_label;
+ iface->get_name = seahorse_ssh_backend_get_name;
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]