[next] telepathy-glib: TpHandleRepoIface: Use G_DEFINE_INTERFACE

Xavier Claessens xclaesse at kemper.freedesktop.org
Fri Jun 29 06:37:51 PDT 2012


Module: telepathy-glib
Branch: next
Commit: 9b28efdc5aa735dd5482f0f050031594f20d3e9a
URL:    http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=9b28efdc5aa735dd5482f0f050031594f20d3e9a

Author: Xavier Claessens <xavier.claessens at collabora.co.uk>
Date:   Tue May 29 10:14:50 2012 +0200

TpHandleRepoIface: Use G_DEFINE_INTERFACE

https://bugs.freedesktop.org/show_bug.cgi?id=50341

---

 telepathy-glib/handle-repo-internal.h |    3 ++
 telepathy-glib/handle-repo.c          |   57 +++++++-------------------------
 2 files changed, 16 insertions(+), 44 deletions(-)

diff --git a/telepathy-glib/handle-repo-internal.h b/telepathy-glib/handle-repo-internal.h
index 722f59c..9441fc0 100644
--- a/telepathy-glib/handle-repo-internal.h
+++ b/telepathy-glib/handle-repo-internal.h
@@ -29,6 +29,9 @@
 
 G_BEGIN_DECLS
 
+/* G_DEFINE_INTERFACE wants that name */
+typedef struct _TpHandleRepoIfaceClass TpHandleRepoIfaceInterface;
+
 /*      <-- this is no longer a gtkdoc comment because this is not public API
  * TpHandleRepoIfaceClass:
  * @parent_class: Fields shared with GTypeInterface
diff --git a/telepathy-glib/handle-repo.c b/telepathy-glib/handle-repo.c
index 5fc49bd..4918831 100644
--- a/telepathy-glib/handle-repo.c
+++ b/telepathy-glib/handle-repo.c
@@ -38,50 +38,7 @@
 
 #include <telepathy-glib/handle-repo-internal.h>
 
-static void
-repo_base_init (gpointer klass)
-{
-  static gboolean initialized = FALSE;
-
-  if (!initialized)
-    {
-      GParamSpec *param_spec;
-
-      initialized = TRUE;
-
-      param_spec = g_param_spec_uint ("handle-type", "Handle type",
-          "The TpHandleType held in this handle repository.",
-          0, G_MAXUINT32, 0,
-          G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-      g_object_interface_install_property (klass, param_spec);
-    }
-}
-
-GType
-tp_handle_repo_iface_get_type (void)
-{
-  static GType type = 0;
-  if (G_UNLIKELY (type == 0))
-    {
-      static const GTypeInfo info = {
-        sizeof (TpHandleRepoIfaceClass),
-        repo_base_init,
-        NULL,   /* base_finalize */
-        NULL,   /* class_init */
-        NULL,   /* class_finalize */
-        NULL,   /* class_data */
-        0,
-        0,      /* n_preallocs */
-        NULL    /* instance_init */
-      };
-
-      type = g_type_register_static (G_TYPE_INTERFACE, "TpHandleRepoIface",
-          &info, 0);
-    }
-
-  return type;
-}
-
+G_DEFINE_INTERFACE (TpHandleRepoIface, tp_handle_repo_iface, G_TYPE_OBJECT);
 
 /**
  * tp_handle_is_valid: (skip)
@@ -419,3 +376,15 @@ tp_handle_get_qdata (TpHandleRepoIface *repo, TpHandle handle,
   return TP_HANDLE_REPO_IFACE_GET_CLASS (repo)->get_qdata (repo,
       handle, key_id);
 }
+
+static void
+tp_handle_repo_iface_default_init (TpHandleRepoIfaceInterface *iface)
+{
+  GParamSpec *param_spec;
+
+  param_spec = g_param_spec_uint ("handle-type", "Handle type",
+      "The TpHandleType held in this handle repository.",
+      0, G_MAXUINT32, 0,
+      G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+  g_object_interface_install_property (iface, param_spec);
+}



More information about the telepathy-commits mailing list