[gnome-builder/wip/project-selector: 23/67] libide: add IdeProjectInfo:last-modified-at
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/project-selector: 23/67] libide: add IdeProjectInfo:last-modified-at
- Date: Mon, 6 Apr 2015 21:31:06 +0000 (UTC)
commit 9487594cc0fe876220c8d3fc5d723009d17fc67a
Author: Christian Hergert <christian hergert me>
Date: Thu Apr 2 00:09:23 2015 -0700
libide: add IdeProjectInfo:last-modified-at
libide/autotools/ide-autotools-project-miner.c | 9 ++++-
libide/ide-project-info.c | 54 ++++++++++++++++++++++-
libide/ide-project-info.h | 19 ++++----
3 files changed, 69 insertions(+), 13 deletions(-)
---
diff --git a/libide/autotools/ide-autotools-project-miner.c b/libide/autotools/ide-autotools-project-miner.c
index 8cfd07b..9760ec3 100644
--- a/libide/autotools/ide-autotools-project-miner.c
+++ b/libide/autotools/ide-autotools-project-miner.c
@@ -50,7 +50,9 @@ ide_autotools_project_miner_discovered (IdeAutotoolsProjectMiner *self,
g_autofree gchar *name = NULL;
g_autoptr(GFile) file = NULL;
g_autoptr(IdeProjectInfo) project_info = NULL;
+ g_autoptr(GDateTime) last_modified_at = NULL;
const gchar *filename;
+ guint64 mtime;
IDE_ENTRY;
@@ -61,6 +63,9 @@ ide_autotools_project_miner_discovered (IdeAutotoolsProjectMiner *self,
uri = g_file_get_uri (directory);
g_debug ("Discovered autotools project at %s", uri);
+ mtime = g_file_info_get_attribute_uint64 (file_info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
+ last_modified_at = g_date_time_new_from_unix_local (mtime);
+
filename = g_file_info_get_attribute_byte_string (file_info, G_FILE_ATTRIBUTE_STANDARD_NAME);
file = g_file_get_child (directory, filename);
name = g_file_get_basename (directory);
@@ -68,6 +73,7 @@ ide_autotools_project_miner_discovered (IdeAutotoolsProjectMiner *self,
project_info = g_object_new (IDE_TYPE_PROJECT_INFO,
"directory", directory,
"file", file,
+ "last-modified-at", last_modified_at,
"name", name,
NULL);
@@ -103,7 +109,8 @@ ide_autotools_project_miner_mine_directory (IdeAutotoolsProjectMiner *self,
file_enum = g_file_enumerate_children (directory,
G_FILE_ATTRIBUTE_STANDARD_NAME","
- G_FILE_ATTRIBUTE_STANDARD_TYPE,
+ G_FILE_ATTRIBUTE_STANDARD_TYPE","
+ G_FILE_ATTRIBUTE_TIME_MODIFIED,
G_FILE_QUERY_INFO_NONE,
cancellable,
NULL);
diff --git a/libide/ide-project-info.c b/libide/ide-project-info.c
index 8036616..9ef5426 100644
--- a/libide/ide-project-info.c
+++ b/libide/ide-project-info.c
@@ -35,9 +35,10 @@ struct _IdeProjectInfo
{
GObject parent_instance;
- GFile *directory;
- GFile *file;
- gchar *name;
+ GDateTime *last_modified_at;
+ GFile *directory;
+ GFile *file;
+ gchar *name;
};
G_DEFINE_TYPE (IdeProjectInfo, ide_project_info, G_TYPE_OBJECT)
@@ -46,6 +47,7 @@ enum {
PROP_0,
PROP_DIRECTORY,
PROP_FILE,
+ PROP_LAST_MODIFIED_AT,
PROP_NAME,
LAST_PROP
};
@@ -86,6 +88,20 @@ ide_project_info_get_file (IdeProjectInfo *self)
return self->file;
}
+/**
+ * ide_project_info_get_last_modified_at:
+ *
+ *
+ * Returns: (transfer none) (nullable): A #GDateTime or %NULL.
+ */
+GDateTime *
+ide_project_info_get_last_modified_at (IdeProjectInfo *self)
+{
+ g_return_val_if_fail (IDE_IS_PROJECT_INFO (self), NULL);
+
+ return self->last_modified_at;
+}
+
const gchar *
ide_project_info_get_name (IdeProjectInfo *self)
{
@@ -117,6 +133,20 @@ ide_project_info_set_file (IdeProjectInfo *self,
}
void
+ide_project_info_set_last_modified_at (IdeProjectInfo *self,
+ GDateTime *last_modified_at)
+{
+ g_assert (IDE_IS_PROJECT_INFO (self));
+
+ if (last_modified_at != self->last_modified_at)
+ {
+ g_clear_pointer (&self->last_modified_at, g_date_time_unref);
+ self->last_modified_at = last_modified_at ? g_date_time_ref (last_modified_at) : NULL;
+ g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_LAST_MODIFIED_AT]);
+ }
+}
+
+void
ide_project_info_set_name (IdeProjectInfo *self,
const gchar *name)
{
@@ -135,6 +165,7 @@ ide_project_info_finalize (GObject *object)
{
IdeProjectInfo *self = (IdeProjectInfo *)object;
+ g_clear_pointer (&self->last_modified_at, g_date_time_unref);
g_clear_pointer (&self->name, g_free);
g_clear_object (&self->directory);
g_clear_object (&self->file);
@@ -160,6 +191,10 @@ ide_project_info_get_property (GObject *object,
g_value_set_object (value, ide_project_info_get_file (self));
break;
+ case PROP_LAST_MODIFIED_AT:
+ g_value_set_boxed (value, ide_project_info_get_last_modified_at (self));
+ break;
+
case PROP_NAME:
g_value_set_string (value, ide_project_info_get_name (self));
break;
@@ -187,6 +222,10 @@ ide_project_info_set_property (GObject *object,
ide_project_info_set_file (self, g_value_get_object (value));
break;
+ case PROP_LAST_MODIFIED_AT:
+ ide_project_info_set_last_modified_at (self, g_value_get_boxed (value));
+ break;
+
case PROP_NAME:
ide_project_info_set_name (self, g_value_get_string (value));
break;
@@ -228,6 +267,15 @@ ide_project_info_class_init (IdeProjectInfoClass *klass)
G_TYPE_FILE,
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class, PROP_FILE, gParamSpecs [PROP_FILE]);
+
+ gParamSpecs [PROP_LAST_MODIFIED_AT] =
+ g_param_spec_boxed ("last-modified-at",
+ _("Last Modified At"),
+ _("Last Modified At"),
+ G_TYPE_DATE_TIME,
+ (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (object_class, PROP_LAST_MODIFIED_AT,
+ gParamSpecs [PROP_LAST_MODIFIED_AT]);
}
static void
diff --git a/libide/ide-project-info.h b/libide/ide-project-info.h
index 81e56d0..f59c948 100644
--- a/libide/ide-project-info.h
+++ b/libide/ide-project-info.h
@@ -27,15 +27,16 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (IdeProjectInfo, ide_project_info, IDE, PROJECT_INFO, GObject)
-GFile *ide_project_info_get_file (IdeProjectInfo *self);
-GFile *ide_project_info_get_directory (IdeProjectInfo *self);
-const gchar *ide_project_info_get_name (IdeProjectInfo *self);
-void ide_project_info_set_file (IdeProjectInfo *self,
- GFile *file);
-void ide_project_info_set_directory (IdeProjectInfo *self,
- GFile *directory);
-void ide_project_info_set_name (IdeProjectInfo *self,
- const gchar *name);
+GFile *ide_project_info_get_file (IdeProjectInfo *self);
+GFile *ide_project_info_get_directory (IdeProjectInfo *self);
+const gchar *ide_project_info_get_name (IdeProjectInfo *self);
+void ide_project_info_set_file (IdeProjectInfo *self,
+ GFile *file);
+void ide_project_info_set_directory (IdeProjectInfo *self,
+ GFile *directory);
+void ide_project_info_set_name (IdeProjectInfo *self,
+ const gchar *name);
+GDateTime *ide_project_info_get_last_modified_at (IdeProjectInfo *self);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]