[epiphany/wip/ephy-sync: 115/116] ephy-bookmark: Implement JsonSerializable interface
- From: Gabriel - Cristian Ivascu <gabrielivascu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/wip/ephy-sync: 115/116] ephy-bookmark: Implement JsonSerializable interface
- Date: Thu, 28 Jul 2016 09:35:30 +0000 (UTC)
commit 0ed49404d653c8d7cfc52a87699fb778ceabff75
Author: Gabriel Ivascu <ivascu gabriel59 gmail com>
Date: Wed Jul 27 13:32:15 2016 +0300
ephy-bookmark: Implement JsonSerializable interface
src/ephy-bookmark.c | 46 +++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 45 insertions(+), 1 deletions(-)
---
diff --git a/src/ephy-bookmark.c b/src/ephy-bookmark.c
index 3cf08b4..a877a82 100644
--- a/src/ephy-bookmark.c
+++ b/src/ephy-bookmark.c
@@ -19,6 +19,8 @@
#include "ephy-bookmark.h"
+#include <json-glib/json-glib.h>
+
struct _EphyBookmark {
GObject parent_instance;
@@ -27,7 +29,12 @@ struct _EphyBookmark {
GSequence *tags;
};
-G_DEFINE_TYPE (EphyBookmark, ephy_bookmark, G_TYPE_OBJECT)
+static JsonSerializableIface *serializable_iface = NULL;
+
+static void json_serializable_iface_init (gpointer g_iface);
+
+G_DEFINE_TYPE_EXTENDED (EphyBookmark, ephy_bookmark, G_TYPE_OBJECT, 0,
+ G_IMPLEMENT_INTERFACE (JSON_TYPE_SERIALIZABLE, json_serializable_iface_init))
enum {
PROP_0,
@@ -136,6 +143,43 @@ ephy_bookmark_init (EphyBookmark *self)
{
}
+static JsonNode *
+ephy_bookmark_json_serializable_serialize_property (JsonSerializable *serializable,
+ const gchar *property_name,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ return serializable_iface->serialize_property (serializable,
+ property_name,
+ value,
+ pspec);
+}
+
+static gboolean
+ephy_bookmark_json_serializable_deserialize_property (JsonSerializable *serializable,
+ const gchar *property_name,
+ GValue *value,
+ GParamSpec *pspec,
+ JsonNode *property_node)
+{
+ return serializable_iface->deserialize_property (serializable,
+ property_name,
+ value,
+ pspec,
+ property_node);
+}
+
+static void
+json_serializable_iface_init (gpointer g_iface)
+{
+ JsonSerializableIface *iface = g_iface;
+
+ serializable_iface = g_type_default_interface_peek (JSON_TYPE_SERIALIZABLE);
+
+ iface->serialize_property = ephy_bookmark_json_serializable_serialize_property;
+ iface->deserialize_property = ephy_bookmark_json_serializable_deserialize_property;
+}
+
EphyBookmark *
ephy_bookmark_new (char *url, char *title)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]