[json-glib] reader: Use GObject ≥ 2.26 API



commit 567d7fb4dff83c9e37e64ef8611f0231fa181c34
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Tue Dec 14 16:35:24 2010 +0000

    reader: Use GObject â?¥ 2.26 API
    
    Use modern API to deal with properties installation and notification.

 json-glib/json-reader.c |   35 +++++++++++++++--------------------
 1 files changed, 15 insertions(+), 20 deletions(-)
---
diff --git a/json-glib/json-reader.c b/json-glib/json-reader.c
index bb14e19..cde828d 100644
--- a/json-glib/json-reader.c
+++ b/json-glib/json-reader.c
@@ -100,10 +100,10 @@ enum
 
   PROP_ROOT,
 
-  LAST_PROP
+  PROP_LAST
 };
 
-static GParamSpec *reader_properties[LAST_PROP] = { NULL, };
+static GParamSpec *reader_properties[PROP_LAST] = { NULL, };
 
 G_DEFINE_TYPE (JsonReader, json_reader, G_TYPE_OBJECT);
 
@@ -166,14 +166,9 @@ static void
 json_reader_class_init (JsonReaderClass *klass)
 {
   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-  GParamSpec *pspec;
 
   g_type_class_add_private (klass, sizeof (JsonReaderPrivate));
 
-  gobject_class->set_property = json_reader_set_property;
-  gobject_class->get_property = json_reader_get_property;
-  gobject_class->dispose = json_reader_dispose;
-
   /**
    * JsonReader:root:
    *
@@ -181,15 +176,19 @@ json_reader_class_init (JsonReaderClass *klass)
    *
    * Since: 0.12
    */
-  pspec = g_param_spec_boxed ("root",
-                              "Root Node",
-                              "The root of the tree to read",
-                              JSON_TYPE_NODE,
-                              G_PARAM_READWRITE |
-                              G_PARAM_CONSTRUCT |
-                              G_PARAM_STATIC_STRINGS);
-  g_object_class_install_property (gobject_class, PROP_ROOT, pspec);
-  reader_properties[PROP_ROOT] = pspec;
+  reader_properties[PROP_ROOT] =
+    g_param_spec_boxed ("root",
+                        "Root Node",
+                        "The root of the tree to read",
+                        JSON_TYPE_NODE,
+                        G_PARAM_READWRITE |
+                        G_PARAM_CONSTRUCT |
+                        G_PARAM_STATIC_STRINGS);
+
+  gobject_class->dispose = json_reader_dispose;
+  gobject_class->set_property = json_reader_set_property;
+  gobject_class->get_property = json_reader_get_property;
+  g_object_class_install_properties (gobject_class, PROP_LAST, reader_properties);
 }
 
 static void
@@ -276,11 +275,7 @@ json_reader_set_root (JsonReader *reader,
       priv->previous_node = NULL;
     }
 
-#if GLIB_CHECK_VERSION (2, 25, 9)
   g_object_notify_by_pspec (G_OBJECT (reader), reader_properties[PROP_ROOT]);
-#else
-  g_object_notify (G_OBJECT (reader), "root");
-#endif
 }
 
 /*



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