[seahorse] Post SeahorseObject to Vala
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [seahorse] Post SeahorseObject to Vala
- Date: Sat, 4 Nov 2017 01:53:11 +0000 (UTC)
commit 4b5d5219b6f28b0260e44db2924c593ab1831c6e
Author: Niels De Graef <nielsdegraef gmail com>
Date: Tue Oct 3 19:40:36 2017 +0200
Post SeahorseObject to Vala
common/Makefile.am | 1 +
common/config.vapi | 15 -
common/object.vala | 162 +++++++++
libseahorse/Makefile.am | 1 -
libseahorse/seahorse-interaction.c | 2 -
libseahorse/seahorse-interaction.h | 2 +-
libseahorse/seahorse-key-manager-store.c | 2 -
libseahorse/seahorse-key-manager-store.h | 3 +-
libseahorse/seahorse-object-model.h | 2 +-
libseahorse/seahorse-object-widget.h | 3 +-
libseahorse/seahorse-object.c | 557 ------------------------------
libseahorse/seahorse-object.h | 86 -----
libseahorse/seahorse-predicate.c | 3 -
libseahorse/seahorse-predicate.h | 2 +-
libseahorse/seahorse-util.c | 3 +-
pgp/seahorse-combo-keys.c | 2 +-
pgp/seahorse-gpgme-exporter.c | 3 -
pgp/seahorse-gpgme-uid.h | 2 +-
pgp/seahorse-keyserver-results.h | 1 -
pgp/seahorse-keyserver-sync.c | 1 -
pgp/seahorse-pgp-actions.c | 1 -
pgp/seahorse-pgp-key-properties.c | 1 -
pgp/seahorse-pgp-key.h | 2 -
pgp/seahorse-pgp-keysets.c | 3 +-
pgp/seahorse-pgp-signature.c | 2 -
pgp/seahorse-pgp-subkey.h | 2 +-
pgp/seahorse-pgp-uid.h | 2 -
pgp/seahorse-unknown-source.c | 2 -
pgp/seahorse-unknown-source.h | 2 +-
pgp/seahorse-unknown.h | 2 +-
po/POTFILES.in | 2 +-
ssh/key.vala | 8 -
32 files changed, 180 insertions(+), 702 deletions(-)
---
diff --git a/common/Makefile.am b/common/Makefile.am
index 94584f4..a3566eb 100644
--- a/common/Makefile.am
+++ b/common/Makefile.am
@@ -18,6 +18,7 @@ common_VALA = \
common/exporter.vala \
common/icons.vala \
common/lockable.vala \
+ common/object.vala \
common/passphrase-prompt.vala \
common/place.vala \
common/registry.vala \
diff --git a/common/config.vapi b/common/config.vapi
index 340b8d9..54bbddc 100644
--- a/common/config.vapi
+++ b/common/config.vapi
@@ -46,21 +46,6 @@ public class Interaction : GLib.TlsInteraction {
public Gtk.Window? parent;
}
-[CCode (cheader_filename = "libseahorse/seahorse-object.h")]
-public class Object : GLib.Object {
- public Place place { get; }
- public Actions actions { get; }
- public string label { get; }
- public string markup { get; }
- public string nickname { get; }
- public GLib.Icon icon { get; }
- public string identifier { get; }
- public Usage usage { get; }
- public Seahorse.Flags flags { get; }
-
- public Object();
-}
-
[CCode (cheader_filename = "libseahorse/seahorse-progress.h")]
namespace Progress {
public void show(GLib.Cancellable? cancellable, string title, bool delayed);
diff --git a/common/object.vala b/common/object.vala
new file mode 100644
index 0000000..e93bbcf
--- /dev/null
+++ b/common/object.vala
@@ -0,0 +1,162 @@
+/*
+ * Seahorse
+ *
+ * Copyright (C) 2008 Stefan Walter
+ * Copyright (C) 2011 Collabora Ltd.
+ * Copyright (C) 2017 Niels De Graef
+ *
+ * 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, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+public class Seahorse.Object : GLib.Object {
+
+/**
+ * @label: DBUS: "display-name"
+ * @markup: Markup text
+ * @nickname: DBUS: "simple-name"
+ * @identifier: DBUS: "key-id", "display-id", "raw-id"
+ * @identifier_explicit:
+ * @location: describes the loaction of the object (local, remte, invalid...)
+ * @usage: DBUS: "etype"
+ */
+
+
+ // XXX only notify if changed
+ /**
+ * The place this Object came from.
+ */
+ [Notify]
+ public weak Place place { get; set; default = null; }
+
+ /**
+ * Actions for the object
+ */
+ public Gtk.ActionGroup? actions { get; set; default = null; }
+
+ /**
+ * Stock ID for this Object.
+ * XXX Nullable?
+ */
+ [Notify]
+ public GLib.Icon? icon { get; set; default = new ThemedIcon("gtk-missing-image"); }
+
+ /**
+ * This object's displayable label.
+ */
+ [Notify]
+ public string label {
+ get { return this._label; }
+ set {
+ this._label = value;
+ recalculate_label();
+ }
+ }
+ private string _label = "";
+
+ /**
+ * This object's displayable markup.
+ */
+ // XXX explicit op true zetten in set;
+ [Notify]
+ public string markup {
+ get { return this._markup; }
+ set {
+ this.markup_explicit = true;
+ this._markup = value;
+ }
+ }
+ private string _markup = "";
+ // If true the markup will not be set automatically
+ private bool markup_explicit;
+
+
+ /**
+ * This object's short name.
+ */
+ // XXX explicit op true zetten in set;
+ [Notify]
+ public string nickname {
+ get { return this._nickname; }
+ set {
+ this.nickname_explicit = true;
+ this._nickname = value;
+ }
+ }
+ private string _nickname = "";
+ // If true the nickname will not be set automatically
+ private bool nickname_explicit;
+
+
+ /**
+ * Displayable ID for the object.
+ */
+ // XXX explicit op true zetten in set;
+ [Notify]
+ public string identifier {
+ get { return this._identifier; }
+ set {
+ this._identifier = value;
+ }
+ }
+ private string _identifier = "";
+
+ // XXX only notify if changed
+ /**
+ * How this object is used.
+ */
+ [Notify]
+ public Usage usage { get; set; default = Usage.NONE; }
+
+ // XXX maybe we can set the property name with CCode?
+ /**
+ * This object's flags.
+ */
+ [Notify]
+ public Flags object_flags { get; set; default = Flags.NONE; }
+
+ /**
+ * Whether this Object can be deleted.
+ */
+ public bool deletable { get { return Flags.DELETABLE in this.object_flags; } }
+
+ /**
+ * Whether this Object can be exported.
+ */
+ public bool exportable { get { return Flags.EXPORTABLE in this.object_flags; } }
+
+ public Object() {
+ }
+
+ public Flags get_flags() {
+ return this.object_flags;
+ }
+
+ public void set_flags(Flags flags) {
+ this.object_flags = flags;
+ }
+
+ // Recalculates nickname and markup from the label
+ private void recalculate_label() {
+ if (!this.markup_explicit) {
+ this.markup = Markup.escape_text (this.label ?? "");
+ notify_property("markup");
+ }
+
+ if (!this.nickname_explicit) {
+ this.nickname = this.label ?? "";
+ notify_property("nickname");
+ }
+ }
+}
diff --git a/libseahorse/Makefile.am b/libseahorse/Makefile.am
index d004587..b111ad8 100644
--- a/libseahorse/Makefile.am
+++ b/libseahorse/Makefile.am
@@ -31,7 +31,6 @@ libseahorse_a_SOURCES = \
libseahorse/seahorse-collection.c libseahorse/seahorse-collection.h \
libseahorse/seahorse-interaction.c libseahorse/seahorse-interaction.h \
libseahorse/seahorse-key-manager-store.c libseahorse/seahorse-key-manager-store.h \
- libseahorse/seahorse-object.c libseahorse/seahorse-object.h \
libseahorse/seahorse-object-list.c libseahorse/seahorse-object-list.h \
libseahorse/seahorse-object-model.c libseahorse/seahorse-object-model.h \
libseahorse/seahorse-object-widget.c libseahorse/seahorse-object-widget.h \
diff --git a/libseahorse/seahorse-interaction.c b/libseahorse/seahorse-interaction.c
index 086cb0b..72014e3 100644
--- a/libseahorse/seahorse-interaction.c
+++ b/libseahorse/seahorse-interaction.c
@@ -21,8 +21,6 @@
#include "config.h"
-#include "seahorse-common.h"
-
#include "seahorse-interaction.h"
#include <glib/gi18n.h>
diff --git a/libseahorse/seahorse-interaction.h b/libseahorse/seahorse-interaction.h
index 8eb6388..74f6e39 100644
--- a/libseahorse/seahorse-interaction.h
+++ b/libseahorse/seahorse-interaction.h
@@ -23,7 +23,7 @@
#include <gtk/gtk.h>
-#include "seahorse-object.h"
+#include "seahorse-common.h"
#define SEAHORSE_TYPE_INTERACTION (seahorse_interaction_get_type ())
#define SEAHORSE_INTERACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
SEAHORSE_TYPE_INTERACTION, SeahorseInteraction))
diff --git a/libseahorse/seahorse-key-manager-store.c b/libseahorse/seahorse-key-manager-store.c
index 2905baa..cb5403b 100644
--- a/libseahorse/seahorse-key-manager-store.c
+++ b/libseahorse/seahorse-key-manager-store.c
@@ -28,8 +28,6 @@
#include "seahorse-prefs.h"
#include "seahorse-util.h"
-#include "seahorse-common.h"
-
#include <string.h>
#include <unistd.h>
diff --git a/libseahorse/seahorse-key-manager-store.h b/libseahorse/seahorse-key-manager-store.h
index 749cd49..30f4d92 100644
--- a/libseahorse/seahorse-key-manager-store.h
+++ b/libseahorse/seahorse-key-manager-store.h
@@ -22,7 +22,8 @@
#define __SEAHORSE_KEY_MANAGER_STORE_H__
#include "seahorse-collection.h"
-#include "seahorse-object.h"
+
+#include "seahorse-common.h"
#include <gtk/gtk.h>
#include <gcr/gcr.h>
diff --git a/libseahorse/seahorse-object-model.h b/libseahorse/seahorse-object-model.h
index ed15a85..9a7d3fa 100644
--- a/libseahorse/seahorse-object-model.h
+++ b/libseahorse/seahorse-object-model.h
@@ -22,7 +22,7 @@
#include <gtk/gtk.h>
-#include "seahorse-object.h"
+#include "seahorse-common.h"
#define SEAHORSE_TYPE_OBJECT_MODEL (seahorse_object_model_get_type ())
#define SEAHORSE_OBJECT_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
SEAHORSE_TYPE_OBJECT_MODEL, SeahorseObjectModel))
diff --git a/libseahorse/seahorse-object-widget.h b/libseahorse/seahorse-object-widget.h
index 5e99c63..0e41479 100644
--- a/libseahorse/seahorse-object-widget.h
+++ b/libseahorse/seahorse-object-widget.h
@@ -22,7 +22,8 @@
#include <glib.h>
-#include "seahorse-object.h"
+#include "seahorse-common.h"
+
#include "seahorse-widget.h"
#define SEAHORSE_TYPE_OBJECT_WIDGET (seahorse_object_widget_get_type ())
diff --git a/libseahorse/seahorse-predicate.c b/libseahorse/seahorse-predicate.c
index 76684fe..b3d49a5 100644
--- a/libseahorse/seahorse-predicate.c
+++ b/libseahorse/seahorse-predicate.c
@@ -21,11 +21,8 @@
#include "config.h"
-#include "seahorse-object.h"
#include "seahorse-predicate.h"
-#include "seahorse-common.h"
-
#include "string.h"
#include <glib/gi18n.h>
diff --git a/libseahorse/seahorse-predicate.h b/libseahorse/seahorse-predicate.h
index e8565e0..a9ef55c 100644
--- a/libseahorse/seahorse-predicate.h
+++ b/libseahorse/seahorse-predicate.h
@@ -22,7 +22,7 @@
#ifndef __SEAHORSE_PREDICATE_H__
#define __SEAHORSE_PREDICATE_H__
-#include "seahorse-object.h"
+#include "seahorse-common.h"
#include <glib-object.h>
diff --git a/libseahorse/seahorse-util.c b/libseahorse/seahorse-util.c
index e77931a..c229ab8 100644
--- a/libseahorse/seahorse-util.c
+++ b/libseahorse/seahorse-util.c
@@ -21,7 +21,8 @@
#include "config.h"
-#include "seahorse-object.h"
+#include "seahorse-common.h"
+
#include "seahorse-util.h"
#include "seahorse-widget.h"
diff --git a/pgp/seahorse-combo-keys.c b/pgp/seahorse-combo-keys.c
index 66c28b8..da50e82 100644
--- a/pgp/seahorse-combo-keys.c
+++ b/pgp/seahorse-combo-keys.c
@@ -21,7 +21,7 @@
#include "seahorse-combo-keys.h"
-#include "libseahorse/seahorse-object.h"
+#include "seahorse-common.h"
enum {
COMBO_LABEL,
diff --git a/pgp/seahorse-gpgme-exporter.c b/pgp/seahorse-gpgme-exporter.c
index 3e7819f..47d621d 100644
--- a/pgp/seahorse-gpgme-exporter.c
+++ b/pgp/seahorse-gpgme-exporter.c
@@ -28,10 +28,7 @@
#include "seahorse-gpgme-keyring.h"
#include "seahorse-gpg-op.h"
-#include "seahorse-common.h"
-
#include "libseahorse/seahorse-progress.h"
-#include "libseahorse/seahorse-object.h"
#include "libseahorse/seahorse-util.h"
#include <glib/gi18n.h>
diff --git a/pgp/seahorse-gpgme-uid.h b/pgp/seahorse-gpgme-uid.h
index 46edf84..5eddfb1 100644
--- a/pgp/seahorse-gpgme-uid.h
+++ b/pgp/seahorse-gpgme-uid.h
@@ -24,7 +24,7 @@
#include <gpgme.h>
-#include "libseahorse/seahorse-object.h"
+#include "seahorse-common.h"
#include "pgp/seahorse-gpgme-key.h"
#include "pgp/seahorse-pgp-uid.h"
diff --git a/pgp/seahorse-keyserver-results.h b/pgp/seahorse-keyserver-results.h
index 34823df..fc9f9b9 100644
--- a/pgp/seahorse-keyserver-results.h
+++ b/pgp/seahorse-keyserver-results.h
@@ -27,7 +27,6 @@
#include <gtk/gtk.h>
#include "seahorse-common.h"
-#include "libseahorse/seahorse-object.h"
G_BEGIN_DECLS
diff --git a/pgp/seahorse-keyserver-sync.c b/pgp/seahorse-keyserver-sync.c
index 34f6492..64ee596 100644
--- a/pgp/seahorse-keyserver-sync.c
+++ b/pgp/seahorse-keyserver-sync.c
@@ -27,7 +27,6 @@
#include "seahorse-common.h"
-#include "libseahorse/seahorse-object.h"
#include "libseahorse/seahorse-prefs.h"
#include "libseahorse/seahorse-progress.h"
#include "libseahorse/seahorse-util.h"
diff --git a/pgp/seahorse-pgp-actions.c b/pgp/seahorse-pgp-actions.c
index ef4173c..7ae80ca 100644
--- a/pgp/seahorse-pgp-actions.c
+++ b/pgp/seahorse-pgp-actions.c
@@ -35,7 +35,6 @@
#include "seahorse-common.h"
-#include "libseahorse/seahorse-object.h"
#include "libseahorse/seahorse-object-list.h"
#include "libseahorse/seahorse-util.h"
diff --git a/pgp/seahorse-pgp-key-properties.c b/pgp/seahorse-pgp-key-properties.c
index 90508e9..b5c23db 100644
--- a/pgp/seahorse-pgp-key-properties.c
+++ b/pgp/seahorse-pgp-key-properties.c
@@ -39,7 +39,6 @@
#include "seahorse-common.h"
#include "libseahorse/seahorse-bind.h"
-#include "libseahorse/seahorse-object.h"
#include "libseahorse/seahorse-object-model.h"
#include "libseahorse/seahorse-object-widget.h"
#include "libseahorse/seahorse-util.h"
diff --git a/pgp/seahorse-pgp-key.h b/pgp/seahorse-pgp-key.h
index 0f2b85d..adbf480 100644
--- a/pgp/seahorse-pgp-key.h
+++ b/pgp/seahorse-pgp-key.h
@@ -24,8 +24,6 @@
#include "seahorse-common.h"
-#include "libseahorse/seahorse-object.h"
-
enum {
SKEY_PGPSIG_TRUSTED = 0x0001,
SKEY_PGPSIG_PERSONAL = 0x0002
diff --git a/pgp/seahorse-pgp-keysets.c b/pgp/seahorse-pgp-keysets.c
index b3dd354..9f0c663 100644
--- a/pgp/seahorse-pgp-keysets.c
+++ b/pgp/seahorse-pgp-keysets.c
@@ -26,9 +26,10 @@
#include "seahorse-pgp-backend.h"
#include "seahorse-pgp-key.h"
+#include "seahorse-common.h"
+
#include "libseahorse/seahorse-application.h"
#include "libseahorse/seahorse-collection.h"
-#include "libseahorse/seahorse-object.h"
#include "libseahorse/seahorse-predicate.h"
/* -----------------------------------------------------------------------------
diff --git a/pgp/seahorse-pgp-signature.c b/pgp/seahorse-pgp-signature.c
index 628af51..12612ba 100644
--- a/pgp/seahorse-pgp-signature.c
+++ b/pgp/seahorse-pgp-signature.c
@@ -25,8 +25,6 @@
#include "seahorse-pgp-key.h"
#include "seahorse-pgp-signature.h"
-#include "libseahorse/seahorse-object.h"
-
#include <string.h>
#include <glib/gi18n.h>
diff --git a/pgp/seahorse-pgp-subkey.h b/pgp/seahorse-pgp-subkey.h
index eb6c855..7af4921 100644
--- a/pgp/seahorse-pgp-subkey.h
+++ b/pgp/seahorse-pgp-subkey.h
@@ -22,7 +22,7 @@
#include <glib-object.h>
-#include "libseahorse/seahorse-object.h"
+#include "seahorse-common.h"
#define SEAHORSE_TYPE_PGP_SUBKEY (seahorse_pgp_subkey_get_type ())
diff --git a/pgp/seahorse-pgp-uid.h b/pgp/seahorse-pgp-uid.h
index 90c699c..2d6790a 100644
--- a/pgp/seahorse-pgp-uid.h
+++ b/pgp/seahorse-pgp-uid.h
@@ -24,8 +24,6 @@
#include "seahorse-common.h"
-#include "libseahorse/seahorse-object.h"
-
#include "seahorse-pgp-key.h"
#define SEAHORSE_TYPE_PGP_UID (seahorse_pgp_uid_get_type ())
diff --git a/pgp/seahorse-unknown-source.c b/pgp/seahorse-unknown-source.c
index 5a21e2b..1d36e3b 100644
--- a/pgp/seahorse-unknown-source.c
+++ b/pgp/seahorse-unknown-source.c
@@ -25,8 +25,6 @@
#include "seahorse-pgp-key.h"
#include "seahorse-unknown.h"
-#include "seahorse-common.h"
-
#include <gcr/gcr-base.h>
#include <glib/gi18n.h>
diff --git a/pgp/seahorse-unknown-source.h b/pgp/seahorse-unknown-source.h
index 9716533..cf502bb 100644
--- a/pgp/seahorse-unknown-source.h
+++ b/pgp/seahorse-unknown-source.h
@@ -21,7 +21,7 @@
#ifndef __SEAHORSE_UNKNOWN_SOURCE_H__
#define __SEAHORSE_UNKNOWN_SOURCE_H__
-#include "libseahorse/seahorse-object.h"
+#include "seahorse-common.h"
#define SEAHORSE_TYPE_UNKNOWN_SOURCE (seahorse_unknown_source_get_type ())
#define SEAHORSE_UNKNOWN_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
SEAHORSE_TYPE_UNKNOWN_SOURCE, SeahorseUnknownSource))
diff --git a/pgp/seahorse-unknown.h b/pgp/seahorse-unknown.h
index 56d6a33..eb12b3c 100644
--- a/pgp/seahorse-unknown.h
+++ b/pgp/seahorse-unknown.h
@@ -22,7 +22,7 @@
#include <gtk/gtk.h>
-#include "libseahorse/seahorse-object.h"
+#include "seahorse-common.h"
#include "seahorse-unknown-source.h"
#define SEAHORSE_TYPE_UNKNOWN (seahorse_unknown_get_type ())
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 1b35237..31d1643 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -2,6 +2,7 @@
# Please keep this file sorted alphabetically.
common/catalog.vala
common/exportable.vala
+common/object.vala
common/passphrase-prompt.vala
common/util.vala
common/validity.vala
@@ -23,7 +24,6 @@ libseahorse/seahorse-add-keyserver.ui
libseahorse/seahorse-application.c
libseahorse/seahorse-interaction.c
libseahorse/seahorse-key-manager-store.c
-libseahorse/seahorse-object.c
libseahorse/seahorse-prefs.c
libseahorse/seahorse-prefs.ui
libseahorse/seahorse-progress.ui
diff --git a/ssh/key.vala b/ssh/key.vala
index 2a49854..1fbd83f 100644
--- a/ssh/key.vala
+++ b/ssh/key.vala
@@ -81,14 +81,6 @@ public class Seahorse.Ssh.Key : Seahorse.Object, Seahorse.Exportable, Seahorse.D
get { return this.key_data != null ? this.key_data.length : 0; }
}
- public bool deletable {
- get { return Seahorse.Flags.DELETABLE in this.flags; }
- }
-
- public bool exportable {
- get { return Seahorse.Flags.EXPORTABLE in this.flags; }
- }
-
public Key(Source source, KeyData key_data) {
GLib.Object(place: source, key_data: key_data);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]