[libgit2-glib] Port GgitCredSshKeyFromAgent to G_DECLARE_FINAL_TYPE macro
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgit2-glib] Port GgitCredSshKeyFromAgent to G_DECLARE_FINAL_TYPE macro
- Date: Sat, 25 Jul 2015 19:34:34 +0000 (UTC)
commit 26f1e7f842e64ba5dfdcdfd5d26e7a6130badd3e
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Sat Jul 25 21:34:10 2015 +0200
Port GgitCredSshKeyFromAgent to G_DECLARE_FINAL_TYPE macro
libgit2-glib/ggit-autocleanup.h | 1 -
libgit2-glib/ggit-cred-ssh-key-from-agent.c | 34 +++++++++++++-------------
libgit2-glib/ggit-cred-ssh-key-from-agent.h | 29 ++--------------------
libgit2-glib/ggit-types.h | 7 -----
4 files changed, 20 insertions(+), 51 deletions(-)
---
diff --git a/libgit2-glib/ggit-autocleanup.h b/libgit2-glib/ggit-autocleanup.h
index 4efd6ad..1bdb868 100644
--- a/libgit2-glib/ggit-autocleanup.h
+++ b/libgit2-glib/ggit-autocleanup.h
@@ -60,7 +60,6 @@ G_BEGIN_DECLS
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GgitCred, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GgitCredPlaintext, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GgitCredSshInteractive, g_object_unref)
-G_DEFINE_AUTOPTR_CLEANUP_FUNC (GgitCredSshKeyFromAgent, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GgitRepository, g_object_unref)
#endif /* GLIB_CHECK_VERSION (2, 44, 0) */
diff --git a/libgit2-glib/ggit-cred-ssh-key-from-agent.c b/libgit2-glib/ggit-cred-ssh-key-from-agent.c
index d38d7d1..14c1f4b 100644
--- a/libgit2-glib/ggit-cred-ssh-key-from-agent.c
+++ b/libgit2-glib/ggit-cred-ssh-key-from-agent.c
@@ -28,9 +28,16 @@
#include "ggit-error.h"
#include "ggit-cred-ssh-key-from-agent.h"
+/**
+ * GgitCredSshKeyFromAgent:
+ *
+ * Represents a ssh key agent credential.
+ */
-struct _GgitCredSshKeyFromAgentPrivate
+struct _GgitCredSshKeyFromAgent
{
+ GgitCred parent_instance;
+
gchar *username;
};
@@ -52,9 +59,9 @@ G_DEFINE_TYPE_EXTENDED (GgitCredSshKeyFromAgent,
static void
ggit_cred_ssh_key_from_agent_finalize (GObject *object)
{
- GgitCredSshKeyFromAgentPrivate *priv = GGIT_CRED_SSH_KEY_FROM_AGENT (object)->priv;
+ GgitCredSshKeyFromAgent *cred = GGIT_CRED_SSH_KEY_FROM_AGENT (object);
- g_free (priv->username);
+ g_free (cred->username);
G_OBJECT_CLASS (ggit_cred_ssh_key_from_agent_parent_class)->finalize (object);
}
@@ -65,12 +72,12 @@ ggit_cred_ssh_key_from_agent_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
- GgitCredSshKeyFromAgentPrivate *priv = GGIT_CRED_SSH_KEY_FROM_AGENT (object)->priv;
+ GgitCredSshKeyFromAgent *cred = GGIT_CRED_SSH_KEY_FROM_AGENT (object);
switch (prop_id)
{
case PROP_USERNAME:
- g_value_set_string (value, priv->username);
+ g_value_set_string (value, cred->username);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -84,12 +91,12 @@ ggit_cred_ssh_key_from_agent_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
- GgitCredSshKeyFromAgentPrivate *priv = GGIT_CRED_SSH_KEY_FROM_AGENT (object)->priv;
+ GgitCredSshKeyFromAgent *cred = GGIT_CRED_SSH_KEY_FROM_AGENT (object);
switch (prop_id)
{
case PROP_USERNAME:
- priv->username = g_value_dup_string (value);
+ cred->username = g_value_dup_string (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -115,16 +122,11 @@ ggit_cred_ssh_key_from_agent_class_init (GgitCredSshKeyFromAgentClass *klass)
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
-
- g_type_class_add_private (object_class, sizeof (GgitCredSshKeyFromAgentPrivate));
}
static void
ggit_cred_ssh_key_from_agent_init (GgitCredSshKeyFromAgent *cred)
{
- cred->priv = G_TYPE_INSTANCE_GET_PRIVATE(cred,
- GGIT_TYPE_CRED_SSH_KEY_FROM_AGENT,
- GgitCredSshKeyFromAgentPrivate);
}
static gboolean
@@ -132,7 +134,7 @@ ggit_cred_ssh_key_from_agent_initable_init (GInitable *initable,
GCancellable *cancellable,
GError **error)
{
- GgitCredSshKeyFromAgentPrivate *priv;
+ GgitCredSshKeyFromAgent *gcred = GGIT_CRED_SSH_KEY_FROM_AGENT (initable);
git_cred *cred;
gint ret;
@@ -143,9 +145,7 @@ ggit_cred_ssh_key_from_agent_initable_init (GInitable *initable,
return FALSE;
}
- priv = GGIT_CRED_SSH_KEY_FROM_AGENT (initable)->priv;
-
- ret = git_cred_ssh_key_from_agent (&cred, priv->username);
+ ret = git_cred_ssh_key_from_agent (&cred, gcred->username);
if (ret != GIT_OK)
{
@@ -198,7 +198,7 @@ ggit_cred_ssh_key_from_agent_get_username (GgitCredSshKeyFromAgent *cred)
{
g_return_val_if_fail (GGIT_IS_CRED_SSH_KEY_FROM_AGENT (cred), NULL);
- return cred->priv->username;
+ return cred->username;
}
/* ex:set ts=8 noet: */
diff --git a/libgit2-glib/ggit-cred-ssh-key-from-agent.h b/libgit2-glib/ggit-cred-ssh-key-from-agent.h
index 846d357..878c4e8 100644
--- a/libgit2-glib/ggit-cred-ssh-key-from-agent.h
+++ b/libgit2-glib/ggit-cred-ssh-key-from-agent.h
@@ -24,35 +24,12 @@
#include <glib-object.h>
#include <libgit2-glib/ggit-cred.h>
+#include <libgit2-glib/ggit-autocleanup.h>
G_BEGIN_DECLS
-#define GGIT_TYPE_CRED_SSH_KEY_FROM_AGENT (ggit_cred_ssh_key_from_agent_get_type ())
-#define GGIT_CRED_SSH_KEY_FROM_AGENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GGIT_TYPE_CRED_SSH_KEY_FROM_AGENT, GgitCredSshKeyFromAgent))
-#define GGIT_CRED_SSH_KEY_FROM_AGENT_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GGIT_TYPE_CRED_SSH_KEY_FROM_AGENT, GgitCredSshKeyFromAgent const))
-#define GGIT_CRED_SSH_KEY_FROM_AGENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
GGIT_TYPE_CRED_SSH_KEY_FROM_AGENT, GgitCredSshKeyFromAgentClass))
-#define GGIT_IS_CRED_SSH_KEY_FROM_AGENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
GGIT_TYPE_CRED_SSH_KEY_FROM_AGENT))
-#define GGIT_IS_CRED_SSH_KEY_FROM_AGENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
GGIT_TYPE_CRED_SSH_KEY_FROM_AGENT))
-#define GGIT_CRED_SSH_KEY_FROM_AGENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
GGIT_TYPE_CRED_SSH_KEY_FROM_AGENT, GgitCredSshKeyFromAgentClass))
-
-typedef struct _GgitCredSshKeyFromAgentClass GgitCredSshKeyFromAgentClass;
-typedef struct _GgitCredSshKeyFromAgentPrivate GgitCredSshKeyFromAgentPrivate;
-
-struct _GgitCredSshKeyFromAgent
-{
- /*< private >*/
- GgitCred parent;
-
- GgitCredSshKeyFromAgentPrivate *priv;
-};
-
-struct _GgitCredSshKeyFromAgentClass
-{
- /*< private >*/
- GgitCredClass parent_class;
-};
-
-GType ggit_cred_ssh_key_from_agent_get_type (void) G_GNUC_CONST;
+#define GGIT_TYPE_CRED_SSH_KEY_FROM_AGENT (ggit_cred_ssh_key_from_agent_get_type ())
+G_DECLARE_FINAL_TYPE (GgitCredSshKeyFromAgent, ggit_cred_ssh_key_from_agent, GGIT, CRED_SSH_KEY_FROM_AGENT,
GgitCred)
GgitCredSshKeyFromAgent *
ggit_cred_ssh_key_from_agent_new (const gchar *username,
diff --git a/libgit2-glib/ggit-types.h b/libgit2-glib/ggit-types.h
index a960b5a..2459438 100644
--- a/libgit2-glib/ggit-types.h
+++ b/libgit2-glib/ggit-types.h
@@ -68,13 +68,6 @@ typedef struct _GgitCredSshInteractive GgitCredSshInteractive;
typedef struct _GgitCredSshInteractivePrompt GgitCredSshInteractivePrompt;
/**
- * GgitCredSshKeyFromAgent:
- *
- * Represents a ssh key agent credential.
- */
-typedef struct _GgitCredSshKeyFromAgent GgitCredSshKeyFromAgent;
-
-/**
* GgitCredPlaintext:
*
* Represents a plain text credential.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]