[gnome-builder] libide: add path and language properties to IdeFile
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide: add path and language properties to IdeFile
- Date: Mon, 23 Mar 2015 23:30:15 +0000 (UTC)
commit 95caafccd5c1ea0c301d0e3ca7ce520c94b47703
Author: Christian Hergert <christian hergert me>
Date: Thu Feb 12 17:29:46 2015 -0800
libide: add path and language properties to IdeFile
libide/ide-file.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++
libide/ide-file.h | 1 +
2 files changed, 60 insertions(+), 0 deletions(-)
---
diff --git a/libide/ide-file.c b/libide/ide-file.c
index 2c02957..0e10441 100644
--- a/libide/ide-file.c
+++ b/libide/ide-file.c
@@ -26,12 +26,15 @@ typedef struct
{
GFile *file;
IdeLanguage *language;
+ gchar *path;
} IdeFilePrivate;
enum
{
PROP_0,
PROP_FILE,
+ PROP_LANGUAGE,
+ PROP_PATH,
LAST_PROP
};
@@ -202,6 +205,28 @@ ide_file_set_file (IdeFile *self,
}
}
+const gchar *
+ide_file_get_path (IdeFile *self)
+{
+ IdeFilePrivate *priv = ide_file_get_instance_private (self);
+
+ g_return_val_if_fail (IDE_IS_FILE (self), NULL);
+
+ return priv->path;
+}
+
+static void
+ide_file_set_path (IdeFile *self,
+ const gchar *path)
+{
+ IdeFilePrivate *priv = ide_file_get_instance_private (self);
+
+ g_return_if_fail (IDE_IS_FILE (self));
+ g_return_if_fail (!priv->path);
+
+ priv->path = g_strdup (path);
+}
+
static void
ide_file_finalize (GObject *object)
{
@@ -209,6 +234,8 @@ ide_file_finalize (GObject *object)
IdeFilePrivate *priv = ide_file_get_instance_private (self);
g_clear_object (&priv->file);
+ g_clear_object (&priv->language);
+ g_clear_pointer (&priv->path, g_free);
G_OBJECT_CLASS (ide_file_parent_class)->finalize (object);
}
@@ -227,6 +254,14 @@ ide_file_get_property (GObject *object,
g_value_set_object (value, ide_file_get_file (self));
break;
+ case PROP_LANGUAGE:
+ g_value_set_object (value, ide_file_get_language (self));
+ break;
+
+ case PROP_PATH:
+ g_value_set_string (value, ide_file_get_path (self));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -246,6 +281,10 @@ ide_file_set_property (GObject *object,
ide_file_set_file (self, g_value_get_object (value));
break;
+ case PROP_PATH:
+ ide_file_set_path (self, g_value_get_string (value));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -270,6 +309,26 @@ ide_file_class_init (IdeFileClass *klass)
G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class, PROP_FILE,
gParamSpecs [PROP_FILE]);
+
+ gParamSpecs [PROP_LANGUAGE] =
+ g_param_spec_object ("language",
+ _("Language"),
+ _("The file language."),
+ IDE_TYPE_LANGUAGE,
+ (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (object_class, PROP_LANGUAGE,
+ gParamSpecs [PROP_LANGUAGE]);
+
+ gParamSpecs [PROP_PATH] =
+ g_param_spec_string ("path",
+ _("Path"),
+ _("The path within the project."),
+ 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-file.h b/libide/ide-file.h
index 796eb86..77606a0 100644
--- a/libide/ide-file.h
+++ b/libide/ide-file.h
@@ -38,6 +38,7 @@ const gchar *ide_file_get_project_path (IdeFile *self);
guint ide_file_hash (IdeFile *self);
gboolean ide_file_equal (IdeFile *self,
IdeFile *other);
+const gchar *ide_file_get_path (IdeFile *self);
//IdeFileSettings *ide_file_get_file_settings (IdeFile *self);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]