[gnome-builder/wip/libide: 32/153] libide: add IdeProjectFile:file property
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/libide: 32/153] libide: add IdeProjectFile:file property
- Date: Fri, 13 Feb 2015 20:02:51 +0000 (UTC)
commit f7b15feca210399914e25892868a3fd69aefd8be
Author: Christian Hergert <christian hergert me>
Date: Sat Feb 7 19:39:51 2015 -0800
libide: add IdeProjectFile:file property
This makes it so we can actually get the path to the file. GFileInfo
isn't enough since it doesn't contain a reference to the GFile or enough
information to recreate it.
libide/ide-project-file.c | 46 ++++++++++++++++++++++++++++++++++++++------
libide/ide-project-file.h | 5 +--
2 files changed, 41 insertions(+), 10 deletions(-)
---
diff --git a/libide/ide-project-file.c b/libide/ide-project-file.c
index bb96d10..034ae6b 100644
--- a/libide/ide-project-file.c
+++ b/libide/ide-project-file.c
@@ -22,6 +22,7 @@
typedef struct
{
+ GFile *file;
GFileInfo *file_info;
} IdeProjectFilePrivate;
@@ -30,20 +31,34 @@ G_DEFINE_TYPE_WITH_PRIVATE (IdeProjectFile, ide_project_file,
enum {
PROP_0,
+ PROP_FILE,
PROP_FILE_INFO,
LAST_PROP
};
static GParamSpec *gParamSpecs [LAST_PROP];
-IdeProjectFile *
-ide_project_file_new (IdeProjectItem *parent,
- GFileInfo *file_info)
+GFile *
+ide_project_file_get_file (IdeProjectFile *file)
{
- return g_object_new (IDE_TYPE_PROJECT_FILE,
- "parent", parent,
- "file-info", file_info,
- NULL);
+ IdeProjectFilePrivate *priv = ide_project_file_get_instance_private (file);
+
+ g_return_val_if_fail (IDE_IS_PROJECT_FILE (file), NULL);
+
+ return priv->file;
+}
+
+void
+ide_project_file_set_file (IdeProjectFile *self,
+ GFile *file)
+{
+ IdeProjectFilePrivate *priv = ide_project_file_get_instance_private (self);
+
+ g_return_if_fail (IDE_IS_PROJECT_FILE (self));
+ g_return_if_fail (!file || G_IS_FILE (file));
+
+ if (g_set_object (&priv->file, file))
+ g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_FILE]);
}
GFileInfo *
@@ -90,6 +105,10 @@ ide_project_file_get_property (GObject *object,
switch (prop_id)
{
+ case PROP_FILE:
+ g_value_set_object (value, ide_project_file_get_file (self));
+ break;
+
case PROP_FILE_INFO:
g_value_set_object (value, ide_project_file_get_file_info (self));
break;
@@ -109,6 +128,10 @@ ide_project_file_set_property (GObject *object,
switch (prop_id)
{
+ case PROP_FILE:
+ ide_project_file_set_file (self, g_value_get_object (value));
+ break;
+
case PROP_FILE_INFO:
ide_project_file_set_file_info (self, g_value_get_object (value));
break;
@@ -127,6 +150,15 @@ ide_project_file_class_init (IdeProjectFileClass *klass)
object_class->get_property = ide_project_file_get_property;
object_class->set_property = ide_project_file_set_property;
+ gParamSpecs [PROP_FILE] =
+ g_param_spec_object ("file",
+ _("File"),
+ _("A GFile to the underlying file."),
+ G_TYPE_FILE,
+ (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (object_class, PROP_FILE,
+ gParamSpecs [PROP_FILE]);
+
gParamSpecs [PROP_FILE_INFO] =
g_param_spec_object ("file-info",
_("File Info"),
diff --git a/libide/ide-project-file.h b/libide/ide-project-file.h
index 47e69c4..1e0d66c 100644
--- a/libide/ide-project-file.h
+++ b/libide/ide-project-file.h
@@ -28,15 +28,14 @@ G_BEGIN_DECLS
#define IDE_TYPE_PROJECT_FILE (ide_project_file_get_type())
-G_DECLARE_DERIVABLE_TYPE (IdeProjectFile, ide_project_file, IDE, PROJECT_FILE,
- IdeProjectItem)
+G_DECLARE_DERIVABLE_TYPE (IdeProjectFile, ide_project_file, IDE, PROJECT_FILE, IdeProjectItem)
struct _IdeProjectFileClass
{
GObjectClass parent;
};
-IdeFile *ide_project_file_get_file (IdeProjectFile *file);
+GFile *ide_project_file_get_file (IdeProjectFile *file);
GFileInfo *ide_project_file_get_file_info (IdeProjectFile *file);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]