[gnome-builder/wip/libide] libide: add IdeProjectFile:path property
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/libide] libide: add IdeProjectFile:path property
- Date: Fri, 13 Feb 2015 01:50:45 +0000 (UTC)
commit b51d46e687ebf0c5b831926d40611179b37ecb71
Author: Christian Hergert <christian hergert me>
Date: Thu Feb 12 17:48:28 2015 -0800
libide: add IdeProjectFile:path property
libide/ide-project-file.c | 45 ++++++++++++++++++++++++++++++++++++++++++++
libide/ide-project-file.h | 7 +++--
libide/ide-project-files.c | 3 ++
3 files changed, 52 insertions(+), 3 deletions(-)
---
diff --git a/libide/ide-project-file.c b/libide/ide-project-file.c
index e608492..9db9c07 100644
--- a/libide/ide-project-file.c
+++ b/libide/ide-project-file.c
@@ -24,6 +24,7 @@ typedef struct
{
GFile *file;
GFileInfo *file_info;
+ gchar *path;
} IdeProjectFilePrivate;
G_DEFINE_TYPE_WITH_PRIVATE (IdeProjectFile, ide_project_file,
@@ -34,12 +35,35 @@ enum {
PROP_FILE,
PROP_FILE_INFO,
PROP_NAME,
+ PROP_PATH,
LAST_PROP
};
static GParamSpec *gParamSpecs [LAST_PROP];
const gchar *
+ide_project_file_get_path (IdeProjectFile *self)
+{
+ IdeProjectFilePrivate *priv = ide_project_file_get_instance_private (self);
+
+ g_return_val_if_fail (IDE_IS_PROJECT_FILE (self), NULL);
+
+ return priv->path;
+}
+
+static void
+ide_project_file_set_path (IdeProjectFile *self,
+ const gchar *path)
+{
+ IdeProjectFilePrivate *priv = ide_project_file_get_instance_private (self);
+
+ g_return_if_fail (IDE_IS_PROJECT_FILE (self));
+ g_return_if_fail (!priv->path);
+
+ priv->path = g_strdup (path);
+}
+
+const gchar *
ide_project_file_get_name (IdeProjectFile *self)
{
IdeProjectFilePrivate *priv = ide_project_file_get_instance_private (self);
@@ -116,6 +140,8 @@ ide_project_file_finalize (GObject *object)
IdeProjectFile *self = (IdeProjectFile *)object;
IdeProjectFilePrivate *priv = ide_project_file_get_instance_private (self);
+ g_clear_pointer (&priv->path, g_free);
+ g_clear_object (&priv->file);
g_clear_object (&priv->file_info);
G_OBJECT_CLASS (ide_project_file_parent_class)->finalize (object);
@@ -143,6 +169,10 @@ ide_project_file_get_property (GObject *object,
g_value_set_string (value, ide_project_file_get_name (self));
break;
+ case PROP_PATH:
+ g_value_set_string (value, ide_project_file_get_path (self));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -166,6 +196,10 @@ ide_project_file_set_property (GObject *object,
ide_project_file_set_file_info (self, g_value_get_object (value));
break;
+ case PROP_PATH:
+ ide_project_file_set_path (self, g_value_get_string (value));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -208,6 +242,17 @@ ide_project_file_class_init (IdeProjectFileClass *klass)
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class, PROP_NAME,
gParamSpecs [PROP_NAME]);
+
+ gParamSpecs [PROP_PATH] =
+ g_param_spec_string ("path",
+ _("Path"),
+ _("The path for the file within the project tree."),
+ NULL,
+ (G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (object_class, PROP_PATH,
+ gParamSpecs [PROP_PATH]);
}
static void
diff --git a/libide/ide-project-file.h b/libide/ide-project-file.h
index 53482f3..51d292e 100644
--- a/libide/ide-project-file.h
+++ b/libide/ide-project-file.h
@@ -35,9 +35,10 @@ struct _IdeProjectFileClass
GObjectClass parent;
};
-GFile *ide_project_file_get_file (IdeProjectFile *file);
-GFileInfo *ide_project_file_get_file_info (IdeProjectFile *file);
-const gchar *ide_project_file_get_name (IdeProjectFile *file);
+GFile *ide_project_file_get_file (IdeProjectFile *self);
+GFileInfo *ide_project_file_get_file_info (IdeProjectFile *self);
+const gchar *ide_project_file_get_name (IdeProjectFile *self);
+const gchar *ide_project_file_get_path (IdeProjectFile *self);
G_END_DECLS
diff --git a/libide/ide-project-files.c b/libide/ide-project-files.c
index 5c9949e..7d7c94a 100644
--- a/libide/ide-project-files.c
+++ b/libide/ide-project-files.c
@@ -119,13 +119,16 @@ ide_project_files_get_file_for_path (IdeProjectFiles *self,
if (item)
{
IdeContext *context;
+ const gchar *path;
GFile *gfile;
context = ide_object_get_context (IDE_OBJECT (self));
gfile = ide_project_file_get_file (IDE_PROJECT_FILE (item));
+ path = ide_project_file_get_path (IDE_PROJECT_FILE (item));
file = g_object_new (IDE_TYPE_FILE,
"context", context,
"file", gfile,
+ "path", path,
NULL);
if (file)
g_hash_table_insert (priv->files_by_path, g_strdup (path), file);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]