[nautilus/wip/antoniof/creation-time-attr: 18/20] general: Support sorting by creation date
- From: Ondrej Holy <oholy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/antoniof/creation-time-attr: 18/20] general: Support sorting by creation date
- Date: Tue, 5 Jan 2021 14:03:50 +0000 (UTC)
commit 22d2c30d5f8aea3f6828a34b04e926f29a66c91a
Author: António Fernandes <antoniof gnome org>
Date: Tue Dec 22 01:12:13 2020 +0000
general: Support sorting by creation date
No user visible changes yet.
data/org.gnome.nautilus.gschema.xml | 3 ++-
src/nautilus-canvas-view.c | 12 ++++++++++++
src/nautilus-file.c | 19 +++++++++++++++++++
src/nautilus-file.h | 3 ++-
src/nautilus-list-view.c | 1 +
src/nautilus-view-icon-controller.c | 12 ++++++++++++
6 files changed, 48 insertions(+), 2 deletions(-)
---
diff --git a/data/org.gnome.nautilus.gschema.xml b/data/org.gnome.nautilus.gschema.xml
index 941812ea8..3b085ea52 100644
--- a/data/org.gnome.nautilus.gschema.xml
+++ b/data/org.gnome.nautilus.gschema.xml
@@ -32,7 +32,8 @@
<value value="2" nick="type"/>
<value value="3" nick="mtime"/>
<value value="4" nick="atime"/>
- <value value="5" nick="starred"/>
+ <value value="5" nick="btime"/>
+ <value value="6" nick="starred"/>
</enum>
<enum id="org.gnome.nautilus.CanvasZoomLevel">
diff --git a/src/nautilus-canvas-view.c b/src/nautilus-canvas-view.c
index 4b3197bd7..144deb06b 100644
--- a/src/nautilus-canvas-view.c
+++ b/src/nautilus-canvas-view.c
@@ -148,6 +148,18 @@ static const SortCriterion sort_criteria[] =
"access-date-desc",
TRUE
},
+ {
+ NAUTILUS_FILE_SORT_BY_BTIME,
+ "creation date",
+ "creation-date",
+ FALSE
+ },
+ {
+ NAUTILUS_FILE_SORT_BY_BTIME,
+ "creation date",
+ "creation-date-desc",
+ TRUE
+ },
{
NAUTILUS_FILE_SORT_BY_TRASHED_TIME,
"trashed",
diff --git a/src/nautilus-file.c b/src/nautilus-file.c
index 4758ad1d1..b0dca1e3c 100644
--- a/src/nautilus-file.c
+++ b/src/nautilus-file.c
@@ -3747,6 +3747,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);
@@ -3852,6 +3862,13 @@ nautilus_file_compare_for_sort_by_attribute_q (NautilusFile *file_1,
directories_first,
reversed);
}
+ else if (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,
@@ -7474,6 +7491,8 @@ 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_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)
diff --git a/src/nautilus-file.h b/src/nautilus-file.h
index eb3a1f13f..2e4820f97 100644
--- a/src/nautilus-file.h
+++ b/src/nautilus-file.h
@@ -60,7 +60,8 @@ typedef enum {
NAUTILUS_FILE_SORT_BY_TYPE = 2,
NAUTILUS_FILE_SORT_BY_MTIME = 3,
NAUTILUS_FILE_SORT_BY_ATIME = 4,
- NAUTILUS_FILE_SORT_BY_STARRED = 5,
+ NAUTILUS_FILE_SORT_BY_BTIME = 5,
+ NAUTILUS_FILE_SORT_BY_STARRED = 6,
/* The following are specific to special locations and as such are not to be
* included in the "org.gnome.nautilus.SortOrder" enum.
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index 0bfb7dec4..ff4ca50de 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -142,6 +142,7 @@ get_default_sort_order (NautilusFile *file,
"type",
"date_modified",
"date_accessed",
+ "date_created",
"starred",
"trashed_on",
"search_relevance",
diff --git a/src/nautilus-view-icon-controller.c b/src/nautilus-view-icon-controller.c
index ab8b82426..5e528e032 100644
--- a/src/nautilus-view-icon-controller.c
+++ b/src/nautilus-view-icon-controller.c
@@ -84,6 +84,18 @@ static const SortConstants sorts_constants[] =
"access-date-desc",
TRUE,
},
+ {
+ NAUTILUS_FILE_SORT_BY_BTIME,
+ "creation date",
+ "creation-date",
+ FALSE,
+ },
+ {
+ NAUTILUS_FILE_SORT_BY_BTIME,
+ "creation date",
+ "creation-date-desc",
+ TRUE,
+ },
{
NAUTILUS_FILE_SORT_BY_TRASHED_TIME,
"trashed",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]