[libgit2-glib] Port GgitSignature to G_DECLARE_FINAL_TYPE macro



commit 0f8827d6d2d8f2520e439099218cd09c736de6d7
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Thu Jul 16 17:54:48 2015 +0200

    Port GgitSignature to G_DECLARE_FINAL_TYPE macro

 libgit2-glib/ggit-autocleanup.h               |    1 -
 libgit2-glib/ggit-blame.h                     |    1 +
 libgit2-glib/ggit-commit.h                    |    1 +
 libgit2-glib/ggit-diff-format-email-options.h |    1 +
 libgit2-glib/ggit-reflog-entry.h              |    1 +
 libgit2-glib/ggit-reflog.h                    |    1 +
 libgit2-glib/ggit-signature.c                 |   44 ++++++++++++------------
 libgit2-glib/ggit-signature.h                 |   34 +------------------
 libgit2-glib/ggit-types.h                     |    7 ----
 9 files changed, 29 insertions(+), 62 deletions(-)
---
diff --git a/libgit2-glib/ggit-autocleanup.h b/libgit2-glib/ggit-autocleanup.h
index a40f91a..7014810 100644
--- a/libgit2-glib/ggit-autocleanup.h
+++ b/libgit2-glib/ggit-autocleanup.h
@@ -70,7 +70,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (GgitRemote, g_object_unref)
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (GgitRemoteCallbacks, g_object_unref)
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (GgitRepository, g_object_unref)
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (GgitRevisionWalker, g_object_unref)
-G_DEFINE_AUTOPTR_CLEANUP_FUNC (GgitSignature, g_object_unref)
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (GgitSubmoduleUpdateOptions, g_object_unref)
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (GgitTreeBuilder, g_object_unref)
 
diff --git a/libgit2-glib/ggit-blame.h b/libgit2-glib/ggit-blame.h
index 21f0a65..3c79de6 100644
--- a/libgit2-glib/ggit-blame.h
+++ b/libgit2-glib/ggit-blame.h
@@ -24,6 +24,7 @@
 #include <glib-object.h>
 #include <libgit2-glib/ggit-native.h>
 #include <libgit2-glib/ggit-types.h>
+#include <libgit2-glib/ggit-signature.h>
 #include <git2.h>
 
 G_BEGIN_DECLS
diff --git a/libgit2-glib/ggit-commit.h b/libgit2-glib/ggit-commit.h
index b1c32f5..8e792db 100644
--- a/libgit2-glib/ggit-commit.h
+++ b/libgit2-glib/ggit-commit.h
@@ -29,6 +29,7 @@
 #include <libgit2-glib/ggit-types.h>
 #include <libgit2-glib/ggit-tree.h>
 #include <libgit2-glib/ggit-commit-parents.h>
+#include <libgit2-glib/ggit-signature.h>
 
 G_BEGIN_DECLS
 
diff --git a/libgit2-glib/ggit-diff-format-email-options.h b/libgit2-glib/ggit-diff-format-email-options.h
index fdf6403..72d6be9 100644
--- a/libgit2-glib/ggit-diff-format-email-options.h
+++ b/libgit2-glib/ggit-diff-format-email-options.h
@@ -25,6 +25,7 @@
 #include <git2.h>
 
 #include "ggit-types.h"
+#include "ggit-signature.h"
 
 G_BEGIN_DECLS
 
diff --git a/libgit2-glib/ggit-reflog-entry.h b/libgit2-glib/ggit-reflog-entry.h
index 8ec703a..c88d314 100644
--- a/libgit2-glib/ggit-reflog-entry.h
+++ b/libgit2-glib/ggit-reflog-entry.h
@@ -24,6 +24,7 @@
 #include <glib-object.h>
 #include <git2.h>
 #include "ggit-types.h"
+#include "ggit-signature.h"
 
 G_BEGIN_DECLS
 
diff --git a/libgit2-glib/ggit-reflog.h b/libgit2-glib/ggit-reflog.h
index 7186036..5ee6ab2 100644
--- a/libgit2-glib/ggit-reflog.h
+++ b/libgit2-glib/ggit-reflog.h
@@ -25,6 +25,7 @@
 #include <git2.h>
 #include "ggit-types.h"
 #include "ggit-ref.h"
+#include "ggit-signature.h"
 
 G_BEGIN_DECLS
 
diff --git a/libgit2-glib/ggit-signature.c b/libgit2-glib/ggit-signature.c
index 11bb8c2..f7b020f 100644
--- a/libgit2-glib/ggit-signature.c
+++ b/libgit2-glib/ggit-signature.c
@@ -24,9 +24,12 @@
 #include "ggit-signature.h"
 #include "ggit-convert.h"
 
-#define GGIT_SIGNATURE_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GGIT_TYPE_SIGNATURE, 
GgitSignaturePrivate))
-
-struct _GgitSignaturePrivate
+/**
+ * GgitSignature:
+ *
+ * Represents an action signature.
+ */
+struct _GgitSignature
 {
        gchar *encoding;
 
@@ -49,9 +52,9 @@ ggit_signature_finalize (GObject *object)
 
        signature = GGIT_SIGNATURE (object);
 
-       g_free (signature->priv->name_utf8);
-       g_free (signature->priv->email_utf8);
-       g_free (signature->priv->encoding);
+       g_free (signature->name_utf8);
+       g_free (signature->email_utf8);
+       g_free (signature->encoding);
 
        G_OBJECT_CLASS (ggit_signature_parent_class)->finalize (object);
 }
@@ -62,13 +65,13 @@ ggit_signature_set_property (GObject      *object,
                              const GValue *value,
                              GParamSpec   *pspec)
 {
-       GgitSignature *self = GGIT_SIGNATURE (object);
+       GgitSignature *signature = GGIT_SIGNATURE (object);
 
        switch (prop_id)
        {
                case PROP_ENCODING:
-                       g_free (self->priv->encoding);
-                       self->priv->encoding = g_value_dup_string (value);
+                       g_free (signature->encoding);
+                       signature->encoding = g_value_dup_string (value);
                        break;
                default:
                        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -82,12 +85,12 @@ ggit_signature_get_property (GObject    *object,
                              GValue     *value,
                              GParamSpec *pspec)
 {
-       GgitSignature *self = GGIT_SIGNATURE (object);
+       GgitSignature *signature = GGIT_SIGNATURE (object);
 
        switch (prop_id)
        {
                case PROP_ENCODING:
-                       g_value_set_string (value, self->priv->encoding);
+                       g_value_set_string (value, signature->encoding);
                        break;
                default:
                        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -105,8 +108,6 @@ ggit_signature_class_init (GgitSignatureClass *klass)
        object_class->get_property = ggit_signature_get_property;
        object_class->set_property = ggit_signature_set_property;
 
-       g_type_class_add_private (object_class, sizeof (GgitSignaturePrivate));
-
        g_object_class_install_property (object_class,
                                         PROP_ENCODING,
                                         g_param_spec_string ("encoding",
@@ -118,9 +119,8 @@ ggit_signature_class_init (GgitSignatureClass *klass)
 }
 
 static void
-ggit_signature_init (GgitSignature *self)
+ggit_signature_init (GgitSignature *signature)
 {
-       self->priv = GGIT_SIGNATURE_GET_PRIVATE (self);
 }
 
 GgitSignature *
@@ -252,7 +252,7 @@ ggit_signature_copy (GgitSignature *signature)
        g_return_val_if_fail (GGIT_IS_SIGNATURE (signature), NULL);
 
        git_signature_dup (&ret, _ggit_native_get (signature));
-       return _ggit_signature_wrap (ret, signature->priv->encoding, TRUE);
+       return _ggit_signature_wrap (ret, signature->encoding, TRUE);
 }
 
 static gchar *
@@ -285,11 +285,11 @@ ggit_signature_get_name (GgitSignature *signature)
 
        s = _ggit_native_get (signature);
 
-       signature->priv->name_utf8 = ensure_utf8 (signature->priv->name_utf8,
-                                                 signature->priv->encoding,
+       signature->name_utf8 = ensure_utf8 (signature->name_utf8,
+                                                 signature->encoding,
                                                  s->name);
 
-       return signature->priv->name_utf8;
+       return signature->name_utf8;
 }
 
 /**
@@ -309,11 +309,11 @@ ggit_signature_get_email (GgitSignature *signature)
 
        s = _ggit_native_get (signature);
 
-       signature->priv->email_utf8 = ensure_utf8 (signature->priv->email_utf8,
-                                                  signature->priv->encoding,
+       signature->email_utf8 = ensure_utf8 (signature->email_utf8,
+                                                  signature->encoding,
                                                   s->email);
 
-       return signature->priv->email_utf8;
+       return signature->email_utf8;
 }
 
 /**
diff --git a/libgit2-glib/ggit-signature.h b/libgit2-glib/ggit-signature.h
index cc968e2..af8138c 100644
--- a/libgit2-glib/ggit-signature.h
+++ b/libgit2-glib/ggit-signature.h
@@ -27,38 +27,8 @@
 
 G_BEGIN_DECLS
 
-#define GGIT_TYPE_SIGNATURE            (ggit_signature_get_type ())
-#define GGIT_SIGNATURE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GGIT_TYPE_SIGNATURE, 
GgitSignature))
-#define GGIT_SIGNATURE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GGIT_TYPE_SIGNATURE, 
GgitSignatureClass))
-#define GGIT_IS_SIGNATURE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GGIT_TYPE_SIGNATURE))
-#define GGIT_IS_SIGNATURE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GGIT_TYPE_SIGNATURE))
-#define GGIT_SIGNATURE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GGIT_TYPE_SIGNATURE, 
GgitSignatureClass))
-
-typedef struct _GgitSignatureClass     GgitSignatureClass;
-typedef struct _GgitSignaturePrivate   GgitSignaturePrivate;
-
-struct _GgitSignature
-{
-       /*< private >*/
-       GgitNative parent;
-
-       /* priv padding */
-       GgitSignaturePrivate *priv;
-};
-
-/**
- * GgitSignatureClass:
- * @parent_class: The parent class.
- *
- * The class structure for #GgitSignatureClass.
- */
-struct _GgitSignatureClass
-{
-       /*< private >*/
-       GgitNativeClass parent_class;
-};
-
-GType                 ggit_signature_get_type          (void) G_GNUC_CONST;
+#define GGIT_TYPE_SIGNATURE (ggit_signature_get_type ())
+G_DECLARE_FINAL_TYPE (GgitSignature, ggit_signature, GGIT, SIGNATURE, GgitNative)
 
 GgitSignature        *_ggit_signature_wrap             (const git_signature *signature,
                                                         const gchar         *encoding,
diff --git a/libgit2-glib/ggit-types.h b/libgit2-glib/ggit-types.h
index 498020e..1dcbe04 100644
--- a/libgit2-glib/ggit-types.h
+++ b/libgit2-glib/ggit-types.h
@@ -286,13 +286,6 @@ typedef struct _GgitRepository GgitRepository;
 typedef struct _GgitRevisionWalker GgitRevisionWalker;
 
 /**
- * GgitSignature:
- *
- * Represents an action signature.
- */
-typedef struct _GgitSignature GgitSignature;
-
-/**
  * GgitStatusOptions:
  *
  * Represents the options used when creating getting file status.


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