[nautilus/wip/antoniof/add-date-created] file: Add "date_created" attribute
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/antoniof/add-date-created] file: Add "date_created" attribute
- Date: Sat, 22 Aug 2020 10:08:36 +0000 (UTC)
commit 1c4f6beea3e0c7a62fe4c9f158770f9a6571e5df
Author: António Fernandes <antoniof gnome org>
Date: Sat Aug 22 11:04:26 2020 +0100
file: Add "date_created" attribute
src/nautilus-file-private.h | 1 +
src/nautilus-file.c | 60 ++++++++++++++++++++++++++++++++++++++++++---
src/nautilus-file.h | 8 +++++-
src/nautilus-list-view.c | 1 +
src/nautilus-vfs-file.c | 16 ++++++++++++
5 files changed, 82 insertions(+), 4 deletions(-)
---
diff --git a/src/nautilus-file-private.h b/src/nautilus-file-private.h
index ed9725b23..831ed8d44 100644
--- a/src/nautilus-file-private.h
+++ b/src/nautilus-file-private.h
@@ -67,6 +67,7 @@ struct NautilusFileDetails
time_t atime; /* 0 is unknown */
time_t mtime; /* 0 is unknown */
+ time_t btime; /* 0 is unknown */
char *symlink_name;
diff --git a/src/nautilus-file.c b/src/nautilus-file.c
index ff902db12..a070d5430 100644
--- a/src/nautilus-file.c
+++ b/src/nautilus-file.c
@@ -144,6 +144,9 @@ static GQuark attribute_name_q,
attribute_accessed_date_q,
attribute_date_accessed_q,
attribute_date_accessed_full_q,
+ attribute_creation_date_q,
+ attribute_date_created_q,
+ attribute_date_created_full_q,
attribute_mime_type_q,
attribute_size_detail_q,
attribute_deep_size_q,
@@ -554,6 +557,7 @@ nautilus_file_clear_info (NautilusFile *file)
file->details->sort_order = 0;
file->details->mtime = 0;
file->details->atime = 0;
+ file->details->btime = 0;
file->details->trash_time = 0;
file->details->recency = 0;
g_free (file->details->symlink_name);
@@ -2433,7 +2437,7 @@ update_info_internal (NautilusFile *file,
int uid, gid;
goffset size;
int sort_order;
- time_t atime, mtime;
+ time_t atime, mtime, btime;
time_t trash_time;
time_t recency;
GTimeVal g_trash_time;
@@ -2765,6 +2769,7 @@ update_info_internal (NautilusFile *file,
atime = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_ACCESS);
mtime = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
+ btime = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_CREATED);
if (file->details->atime != atime ||
file->details->mtime != mtime)
{
@@ -2777,6 +2782,7 @@ update_info_internal (NautilusFile *file,
}
file->details->atime = atime;
file->details->mtime = mtime;
+ file->details->btime = btime;
if (file->details->thumbnail != NULL &&
file->details->thumbnail_mtime != 0 &&
@@ -3154,6 +3160,12 @@ get_time (NautilusFile *file,
}
break;
+ case NAUTILUS_DATE_TYPE_CREATED:
+ {
+ time = file->details->btime;
+ }
+ break;
+
case NAUTILUS_DATE_TYPE_TRASHED:
{
time = file->details->trash_time;
@@ -3729,6 +3741,16 @@ nautilus_file_compare_for_sort (NautilusFile *file_1,
}
break;
+ case NAUTILUS_FILE_SORT_BY_BTIME:
+ {
+ result = compare_by_time (file_1, file_2, NAUTILUS_DATE_TYPE_CREATED);
+ if (result == 0)
+ {
+ result = compare_by_full_path (file_1, file_2);
+ }
+ }
+ break;
+
case NAUTILUS_FILE_SORT_BY_TRASHED_TIME:
{
result = compare_by_time (file_1, file_2, NAUTILUS_DATE_TYPE_TRASHED);
@@ -3834,6 +3856,13 @@ nautilus_file_compare_for_sort_by_attribute_q (NautilusFile *file_1,
directories_first,
reversed);
}
+ else if (attribute == attribute_creation_date_q || attribute == attribute_date_created_q || attribute ==
attribute_date_created_full_q)
+ {
+ return nautilus_file_compare_for_sort (file_1, file_2,
+ NAUTILUS_FILE_SORT_BY_BTIME,
+ directories_first,
+ reversed);
+ }
else if (attribute == attribute_trashed_on_q || attribute == attribute_trashed_on_full_q)
{
return nautilus_file_compare_for_sort (file_1, file_2,
@@ -5398,6 +5427,7 @@ nautilus_file_get_date (NautilusFile *file,
g_return_val_if_fail (date_type == NAUTILUS_DATE_TYPE_ACCESSED
|| date_type == NAUTILUS_DATE_TYPE_MODIFIED
+ || date_type == NAUTILUS_DATE_TYPE_CREATED
|| date_type == NAUTILUS_DATE_TYPE_TRASHED
|| date_type == NAUTILUS_DATE_TYPE_RECENCY,
FALSE);
@@ -5873,6 +5903,12 @@ nautilus_file_get_atime (NautilusFile *file)
return file->details->atime;
}
+time_t
+nautilus_file_get_btime (NautilusFile *file)
+{
+ return file->details->btime;
+}
+
time_t
nautilus_file_get_recency (NautilusFile *file)
{
@@ -7156,8 +7192,8 @@ nautilus_file_get_deep_directory_count_as_string (NautilusFile *file)
* @file: NautilusFile representing the file in question.
* @attribute_name: The name of the desired attribute. The currently supported
* set includes "name", "type", "detailed_type", "mime_type", "size", "deep_size", "deep_directory_count",
- * "deep_file_count", "deep_total_count", "date_modified", "date_accessed",
- * "date_modified_full", "date_accessed_full",
+ * "deep_file_count", "deep_total_count", "date_modified", "date_accessed", "date_created",
+ * "date_modified_full", "date_accessed_full", "date_created_full",
* "owner", "group", "permissions", "octal_permissions", "uri", "where",
* "link_target", "volume", "free_space", "selinux_context", "trashed_on", "trashed_on_full",
"trashed_orig_path",
* "recency"
@@ -7246,6 +7282,18 @@ nautilus_file_get_string_attribute_q (NautilusFile *file,
NAUTILUS_DATE_TYPE_ACCESSED,
NAUTILUS_DATE_FORMAT_FULL);
}
+ if (attribute_q == attribute_date_created_q)
+ {
+ return nautilus_file_get_date_as_string (file,
+ NAUTILUS_DATE_TYPE_CREATED,
+ NAUTILUS_DATE_FORMAT_REGULAR);
+ }
+ if (attribute_q == attribute_date_created_full_q)
+ {
+ return nautilus_file_get_date_as_string (file,
+ NAUTILUS_DATE_TYPE_CREATED,
+ NAUTILUS_DATE_FORMAT_FULL);
+ }
if (attribute_q == attribute_trashed_on_q)
{
return nautilus_file_get_date_as_string (file,
@@ -7453,6 +7501,9 @@ nautilus_file_is_date_sort_attribute_q (GQuark attribute_q)
attribute_q == attribute_accessed_date_q ||
attribute_q == attribute_date_accessed_q ||
attribute_q == attribute_date_accessed_full_q ||
+ attribute_q == attribute_creation_date_q ||
+ attribute_q == attribute_date_created_q ||
+ attribute_q == attribute_date_created_full_q ||
attribute_q == attribute_trashed_on_q ||
attribute_q == attribute_trashed_on_full_q ||
attribute_q == attribute_recency_q)
@@ -9227,6 +9278,9 @@ nautilus_file_class_init (NautilusFileClass *class)
attribute_accessed_date_q = g_quark_from_static_string ("accessed_date");
attribute_date_accessed_q = g_quark_from_static_string ("date_accessed");
attribute_date_accessed_full_q = g_quark_from_static_string ("date_accessed_full");
+ attribute_creation_date_q = g_quark_from_static_string ("creation_date");
+ attribute_date_created_q = g_quark_from_static_string ("date_created");
+ attribute_date_created_full_q = g_quark_from_static_string ("date_created_full");
attribute_mime_type_q = g_quark_from_static_string ("mime_type");
attribute_size_detail_q = g_quark_from_static_string ("size_detail");
attribute_deep_size_q = g_quark_from_static_string ("deep_size");
diff --git a/src/nautilus-file.h b/src/nautilus-file.h
index 2164808ca..ab2ebdb31 100644
--- a/src/nautilus-file.h
+++ b/src/nautilus-file.h
@@ -67,7 +67,11 @@ typedef enum {
*/
NAUTILUS_FILE_SORT_BY_TRASHED_TIME,
NAUTILUS_FILE_SORT_BY_SEARCH_RELEVANCE,
- NAUTILUS_FILE_SORT_BY_RECENCY
+ NAUTILUS_FILE_SORT_BY_RECENCY,
+
+ /* The following is not used for sorting yet.
+ */
+ NAUTILUS_FILE_SORT_BY_BTIME
} NautilusFileSortType;
typedef enum {
@@ -196,6 +200,7 @@ gboolean nautilus_file_can_get_size (Nautilu
goffset nautilus_file_get_size (NautilusFile
*file);
time_t nautilus_file_get_mtime (NautilusFile
*file);
time_t nautilus_file_get_atime (NautilusFile
*file);
+time_t nautilus_file_get_btime (NautilusFile
*file);
time_t nautilus_file_get_recency (NautilusFile
*file);
time_t nautilus_file_get_trash_time (NautilusFile
*file);
GFileType nautilus_file_get_file_type (NautilusFile
*file);
@@ -529,6 +534,7 @@ struct NautilusFile {
typedef enum {
NAUTILUS_DATE_TYPE_MODIFIED,
NAUTILUS_DATE_TYPE_ACCESSED,
+ NAUTILUS_DATE_TYPE_CREATED,
NAUTILUS_DATE_TYPE_TRASHED,
NAUTILUS_DATE_TYPE_RECENCY
} NautilusDateType;
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index 2ac0890e5..25b46bf64 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -146,6 +146,7 @@ get_default_sort_order (NautilusFile *file,
"trashed_on",
"search_relevance",
"recency",
+ "date_created", /* Not used yet */
NULL
};
diff --git a/src/nautilus-vfs-file.c b/src/nautilus-vfs-file.c
index 66dff20a2..ccbbc3536 100644
--- a/src/nautilus-vfs-file.c
+++ b/src/nautilus-vfs-file.c
@@ -225,11 +225,13 @@ vfs_file_get_date (NautilusFile *file,
{
time_t atime;
time_t mtime;
+ time_t btime;
time_t recency;
time_t trash_time;
atime = nautilus_file_get_atime (file);
mtime = nautilus_file_get_mtime (file);
+ btime = nautilus_file_get_btime (file);
recency = nautilus_file_get_recency (file);
trash_time = nautilus_file_get_trash_time (file);
@@ -263,6 +265,20 @@ vfs_file_get_date (NautilusFile *file,
return TRUE;
}
+ case NAUTILUS_DATE_TYPE_CREATED:
+ {
+ /* Before we have info on a file, the date is unknown. */
+ if (btime == 0)
+ {
+ return FALSE;
+ }
+ if (date != NULL)
+ {
+ *date = btime;
+ }
+ return TRUE;
+ }
+
case NAUTILUS_DATE_TYPE_TRASHED:
{
/* Before we have info on a file, the date is unknown. */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]