[gnome-builder] project: use G_DECLARE_FINAL_TYPE()
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] project: use G_DECLARE_FINAL_TYPE()
- Date: Thu, 16 Apr 2015 07:15:26 +0000 (UTC)
commit ba1e3f6e7ce8fd0e57daba5153f87ab19aa2bbbb
Author: Christian Hergert <christian hergert me>
Date: Thu Apr 16 00:15:19 2015 -0700
project: use G_DECLARE_FINAL_TYPE()
libide/ide-project.c | 76 +++++++++++++++++++------------------------------
libide/ide-project.h | 25 ++++++----------
2 files changed, 40 insertions(+), 61 deletions(-)
---
diff --git a/libide/ide-project.c b/libide/ide-project.c
index 1077575..716191a 100644
--- a/libide/ide-project.c
+++ b/libide/ide-project.c
@@ -26,12 +26,14 @@
#include "ide-project-item.h"
#include "ide-vcs.h"
-typedef struct
+struct _IdeProject
{
+ IdeObject parent_instance;
+
GRWLock rw_lock;
IdeProjectItem *root;
gchar *name;
-} IdeProjectPrivate;
+};
typedef struct
{
@@ -39,7 +41,7 @@ typedef struct
GFile *new_file;
} RenameFile;
-G_DEFINE_TYPE_WITH_PRIVATE (IdeProject, ide_project, IDE_TYPE_OBJECT)
+G_DEFINE_TYPE (IdeProject, ide_project, IDE_TYPE_OBJECT)
enum {
PROP_0,
@@ -53,66 +55,54 @@ static GParamSpec *gParamSpecs [LAST_PROP];
void
ide_project_reader_lock (IdeProject *self)
{
- IdeProjectPrivate *priv = ide_project_get_instance_private (self);
-
g_return_if_fail (IDE_IS_PROJECT (self));
- g_rw_lock_reader_lock (&priv->rw_lock);
+ g_rw_lock_reader_lock (&self->rw_lock);
}
void
ide_project_reader_unlock (IdeProject *self)
{
- IdeProjectPrivate *priv = ide_project_get_instance_private (self);
-
g_return_if_fail (IDE_IS_PROJECT (self));
- g_rw_lock_reader_unlock (&priv->rw_lock);
+ g_rw_lock_reader_unlock (&self->rw_lock);
}
void
ide_project_writer_lock (IdeProject *self)
{
- IdeProjectPrivate *priv = ide_project_get_instance_private (self);
-
g_return_if_fail (IDE_IS_PROJECT (self));
- g_rw_lock_writer_lock (&priv->rw_lock);
+ g_rw_lock_writer_lock (&self->rw_lock);
}
void
ide_project_writer_unlock (IdeProject *self)
{
- IdeProjectPrivate *priv = ide_project_get_instance_private (self);
-
g_return_if_fail (IDE_IS_PROJECT (self));
- g_rw_lock_writer_unlock (&priv->rw_lock);
+ g_rw_lock_writer_unlock (&self->rw_lock);
}
const gchar *
-ide_project_get_name (IdeProject *project)
+ide_project_get_name (IdeProject *self)
{
- IdeProjectPrivate *priv = ide_project_get_instance_private (project);
-
- g_return_val_if_fail (IDE_IS_PROJECT (project), NULL);
+ g_return_val_if_fail (IDE_IS_PROJECT (self), NULL);
- return priv->name;
+ return self->name;
}
void
-_ide_project_set_name (IdeProject *project,
+_ide_project_set_name (IdeProject *self,
const gchar *name)
{
- IdeProjectPrivate *priv = ide_project_get_instance_private (project);
-
- g_return_if_fail (IDE_IS_PROJECT (project));
+ g_return_if_fail (IDE_IS_PROJECT (self));
- if (priv->name != name)
+ if (self->name != name)
{
- g_free (priv->name);
- priv->name = g_strdup (name);
- g_object_notify_by_pspec (G_OBJECT (project), gParamSpecs [PROP_NAME]);
+ g_free (self->name);
+ self->name = g_strdup (name);
+ g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_NAME]);
}
}
@@ -133,27 +123,24 @@ _ide_project_set_name (IdeProject *project,
* Returns: (transfer none): An #IdeProjectItem.
*/
IdeProjectItem *
-ide_project_get_root (IdeProject *project)
+ide_project_get_root (IdeProject *self)
{
- IdeProjectPrivate *priv = ide_project_get_instance_private (project);
-
- g_return_val_if_fail (IDE_IS_PROJECT (project), NULL);
+ g_return_val_if_fail (IDE_IS_PROJECT (self), NULL);
- return priv->root;
+ return self->root;
}
static void
-ide_project_set_root (IdeProject *project,
+ide_project_set_root (IdeProject *self,
IdeProjectItem *root)
{
- IdeProjectPrivate *priv = ide_project_get_instance_private (project);
g_autoptr(IdeProjectItem) allocated = NULL;
IdeContext *context;
- g_return_if_fail (IDE_IS_PROJECT (project));
+ g_return_if_fail (IDE_IS_PROJECT (self));
g_return_if_fail (!root || IDE_IS_PROJECT_ITEM (root));
- context = ide_object_get_context (IDE_OBJECT (project));
+ context = ide_object_get_context (IDE_OBJECT (self));
if (!root)
{
@@ -163,8 +150,8 @@ ide_project_set_root (IdeProject *project,
root = allocated;
}
- if (g_set_object (&priv->root, root))
- g_object_notify_by_pspec (G_OBJECT (project), gParamSpecs [PROP_ROOT]);
+ if (g_set_object (&self->root, root))
+ g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_ROOT]);
}
/**
@@ -319,11 +306,10 @@ static void
ide_project_finalize (GObject *object)
{
IdeProject *self = (IdeProject *)object;
- IdeProjectPrivate *priv = ide_project_get_instance_private (self);
- g_clear_object (&priv->root);
- g_clear_pointer (&priv->name, g_free);
- g_rw_lock_clear (&priv->rw_lock);
+ g_clear_object (&self->root);
+ g_clear_pointer (&self->name, g_free);
+ g_rw_lock_clear (&self->rw_lock);
G_OBJECT_CLASS (ide_project_parent_class)->finalize (object);
}
@@ -403,9 +389,7 @@ ide_project_class_init (IdeProjectClass *klass)
static void
ide_project_init (IdeProject *self)
{
- IdeProjectPrivate *priv = ide_project_get_instance_private (self);
-
- g_rw_lock_init (&priv->rw_lock);
+ g_rw_lock_init (&self->rw_lock);
}
static void
diff --git a/libide/ide-project.h b/libide/ide-project.h
index b707e6b..4b36b59 100644
--- a/libide/ide-project.h
+++ b/libide/ide-project.h
@@ -26,24 +26,19 @@ G_BEGIN_DECLS
#define IDE_TYPE_PROJECT (ide_project_get_type())
-G_DECLARE_DERIVABLE_TYPE (IdeProject, ide_project, IDE, PROJECT, IdeObject)
+G_DECLARE_FINAL_TYPE (IdeProject, ide_project, IDE, PROJECT, IdeObject)
-struct _IdeProjectClass
-{
- IdeObjectClass parent;
-};
-
-IdeProjectItem *ide_project_get_root (IdeProject *project);
-const gchar *ide_project_get_name (IdeProject *project);
-IdeFile *ide_project_get_file_for_path (IdeProject *project,
+IdeProjectItem *ide_project_get_root (IdeProject *self);
+const gchar *ide_project_get_name (IdeProject *self);
+IdeFile *ide_project_get_file_for_path (IdeProject *self,
const gchar *path);
IdeFile *ide_project_get_project_file (IdeProject *self,
GFile *gfile);
-void ide_project_reader_lock (IdeProject *project);
-void ide_project_reader_unlock (IdeProject *project);
-void ide_project_writer_lock (IdeProject *project);
-void ide_project_writer_unlock (IdeProject *project);
-void ide_project_add_file (IdeProject *project,
+void ide_project_reader_lock (IdeProject *self);
+void ide_project_reader_unlock (IdeProject *self);
+void ide_project_writer_lock (IdeProject *self);
+void ide_project_writer_unlock (IdeProject *self);
+void ide_project_add_file (IdeProject *self,
IdeProjectFile *file);
IdeProjectFiles *ide_project_get_files (IdeProject *self);
void ide_project_rename_file_async (IdeProject *self,
@@ -52,7 +47,7 @@ void ide_project_rename_file_async (IdeProject *self,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
-gboolean ide_project_rename_file_finish (IdeProject *project,
+gboolean ide_project_rename_file_finish (IdeProject *self,
GAsyncResult *result,
GError **error);
void ide_project_trash_file_async (IdeProject *self,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]