[libchamplain] Use new macros for defining interfaces



commit cc0986aa7ae57f2791a704a6ac0d3ccbebb8d537
Author: JiÅ?í Techet <techet gmail com>
Date:   Wed Feb 16 00:46:34 2011 +0100

    Use new macros for defining interfaces

 champlain/champlain-location.c |   76 ++++++++++++++-------------------------
 champlain/champlain-location.h |   11 ++++--
 2 files changed, 35 insertions(+), 52 deletions(-)
---
diff --git a/champlain/champlain-location.c b/champlain/champlain-location.c
index 22bce1c..ad1acc2 100644
--- a/champlain/champlain-location.c
+++ b/champlain/champlain-location.c
@@ -27,58 +27,36 @@
 #include "champlain-location.h"
 #include "champlain-private.h"
 
-static void
-champlain_location_base_init (gpointer g_iface)
-{
-  static gboolean initialized = FALSE;
-
-  if (!initialized)
-    {
-      /**
-       * ChamplainLocation:longitude:
-       *
-       * The longitude coordonate
-       *
-       * Since: 0.10
-       */
-      g_object_interface_install_property (g_iface,
-          g_param_spec_double ("longitude", "Longitude",
-              "The longitude coordonate",
-              -180.0f, 180.0f, 0.0f, CHAMPLAIN_PARAM_READWRITE));
-
-      /**
-       * ChamplainLocation:latitude:
-       *
-       * The latitude coordonate
-       *
-       * Since: 0.10
-       */
-      g_object_interface_install_property (g_iface,
-          g_param_spec_double ("latitude", "Latitude",
-              "The latitude coordonate",
-              -90.0f, 90.0f, 0.0f, CHAMPLAIN_PARAM_READWRITE));
-
-      initialized = TRUE;
-    }
-}
+typedef ChamplainLocationIface  ChamplainLocationInterface;
+G_DEFINE_INTERFACE (ChamplainLocation, champlain_location, G_TYPE_OBJECT);
 
 
-GType
-champlain_location_get_type (void)
+static void
+champlain_location_default_init (ChamplainLocationInterface *iface)
 {
-  static GType type = 0;
-  if (type == 0)
-    {
-      static const GTypeInfo info =
-      {
-        sizeof (ChamplainLocationIface),
-        champlain_location_base_init,          /* base_init */
-        NULL,
-      };
-      type = g_type_register_static (G_TYPE_INTERFACE,
-                                     "ChamplainLocation", &info, 0);
-    }
-  return type;
+  /**
+   * ChamplainLocation:longitude:
+   *
+   * The longitude coordonate
+   *
+   * Since: 0.10
+   */
+  g_object_interface_install_property (iface,
+      g_param_spec_double ("longitude", "Longitude",
+          "The longitude coordonate",
+          -180.0f, 180.0f, 0.0f, CHAMPLAIN_PARAM_READWRITE));
+
+  /**
+   * ChamplainLocation:latitude:
+   *
+   * The latitude coordonate
+   *
+   * Since: 0.10
+   */
+  g_object_interface_install_property (iface,
+      g_param_spec_double ("latitude", "Latitude",
+          "The latitude coordonate",
+          -90.0f, 90.0f, 0.0f, CHAMPLAIN_PARAM_READWRITE));
 }
 
 
diff --git a/champlain/champlain-location.h b/champlain/champlain-location.h
index 3c52141..96bc8f7 100644
--- a/champlain/champlain-location.h
+++ b/champlain/champlain-location.h
@@ -16,6 +16,10 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#if !defined (__CHAMPLAIN_CHAMPLAIN_H_INSIDE__) && !defined (CHAMPLAIN_COMPILATION)
+#error "Only <champlain/champlain.h> can be included directly."
+#endif
+
 #ifndef __CHAMPLAIN_LOCATION_H__
 #define __CHAMPLAIN_LOCATION_H__
 
@@ -28,13 +32,14 @@ G_BEGIN_DECLS
 #define CHAMPLAIN_IS_LOCATION(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CHAMPLAIN_TYPE_LOCATION))
 #define CHAMPLAIN_LOCATION_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), CHAMPLAIN_TYPE_LOCATION, ChamplainLocationIface))
 
+typedef struct _ChamplainLocation ChamplainLocation; /* Dummy object */
+typedef struct _ChamplainLocationIface ChamplainLocationIface;
+
 /**
  * ChamplainLocation:
  *
  * An interface common to objects having latitude and longitude.
  */
-typedef struct _ChamplainLocation ChamplainLocation; /* Dummy object */
-typedef struct _ChamplainLocationIface ChamplainLocationIface;
 
 /**
  * ChamplainLocationIface:
@@ -47,7 +52,7 @@ typedef struct _ChamplainLocationIface ChamplainLocationIface;
 struct _ChamplainLocationIface
 {
   /*< private >*/
-  GTypeInterface parent;
+  GTypeInterface g_iface;
 
   /*< public >*/
   gdouble (* get_latitude) (ChamplainLocation *location);



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