From 0eb7520d23cc4ca6cdd9b6c97d3f6cbafcdfc927 Mon Sep 17 00:00:00 2001 From: rbuj Date: Sun, 28 Mar 2021 12:07:58 +0200 Subject: Add creation time support --- libcaja-private/caja-column-utilities.c | 8 ++++++++ libcaja-private/caja-file-private.h | 1 + libcaja-private/caja-file.c | 33 +++++++++++++++++++++++++++++-- libcaja-private/caja-file.h | 2 ++ libcaja-private/caja-vfs-file.c | 11 +++++++++++ libcaja-private/org.mate.caja.gschema.xml | 2 +- src/caja-file-management-properties.c | 1 + src/caja-file-management-properties.ui | 3 +++ src/file-manager/fm-icon-view.c | 13 ++++++++++++ src/file-manager/fm-properties-window.c | 4 ++++ 10 files changed, 75 insertions(+), 3 deletions(-) diff --git a/libcaja-private/caja-column-utilities.c b/libcaja-private/caja-column-utilities.c index d8b6a406..0471e8b5 100644 --- a/libcaja-private/caja-column-utilities.c +++ b/libcaja-private/caja-column-utilities.c @@ -77,6 +77,14 @@ get_builtin_columns (void) "description", _("The date the file was modified."), NULL)); + columns = g_list_append (columns, + g_object_new (CAJA_TYPE_COLUMN, + "name", "date_created", + "attribute", "date_created", + "label", _("Date Created"), + "description", _("The date the file was created."), + NULL)); + columns = g_list_append (columns, g_object_new (CAJA_TYPE_COLUMN, "name", "date_accessed", diff --git a/libcaja-private/caja-file-private.h b/libcaja-private/caja-file-private.h index 7642029e..315b3b98 100644 --- a/libcaja-private/caja-file-private.h +++ b/libcaja-private/caja-file-private.h @@ -88,6 +88,7 @@ struct _CajaFilePrivate time_t atime; /* 0 is unknown */ time_t mtime; /* 0 is unknown */ time_t ctime; /* 0 is unknown */ + time_t btime; /* 0 is unknown */ char *symlink_name; diff --git a/libcaja-private/caja-file.c b/libcaja-private/caja-file.c index 25660700..4d4a40d4 100644 --- a/libcaja-private/caja-file.c +++ b/libcaja-private/caja-file.c @@ -120,6 +120,8 @@ static GQuark attribute_name_q, attribute_size_q, attribute_size_on_disk_q, attribute_type_q, + attribute_creation_date_q, + attribute_date_created_q, attribute_modification_date_q, attribute_date_modified_q, attribute_accessed_date_q, @@ -476,6 +478,7 @@ caja_file_clear_info (CajaFile *file) file->details->mtime = 0; file->details->atime = 0; file->details->ctime = 0; + file->details->btime = 0; file->details->trash_time = 0; g_free (file->details->symlink_name); file->details->symlink_name = NULL; @@ -2108,7 +2111,7 @@ update_info_internal (CajaFile *file, goffset size; goffset size_on_disk; int sort_order; - time_t atime, mtime, ctime; + time_t atime, mtime, ctime, btime; time_t trash_time; const char * time_string; const char *symlink_name, *mime_type, *selinux_context, *thumbnail_path; @@ -2404,9 +2407,11 @@ update_info_internal (CajaFile *file, atime = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_ACCESS); ctime = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_CHANGED); 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 || - file->details->ctime != ctime) { + file->details->ctime != ctime || + file->details->btime != btime) { if (file->details->thumbnail == NULL) { file->details->thumbnail_is_up_to_date = FALSE; } @@ -2416,6 +2421,7 @@ update_info_internal (CajaFile *file, file->details->atime = atime; file->details->ctime = ctime; file->details->mtime = mtime; + file->details->btime = btime; if (file->details->thumbnail != NULL && file->details->thumbnail_mtime != 0 && @@ -2790,6 +2796,9 @@ get_time (CajaFile *file, case CAJA_DATE_TYPE_ACCESSED: time = file->details->atime; break; + case CAJA_DATE_TYPE_CREATED: + time = file->details->btime; + break; case CAJA_DATE_TYPE_TRASHED: time = file->details->trash_time; break; @@ -3495,6 +3504,12 @@ caja_file_compare_for_sort (CajaFile *file_1, result = compare_by_full_path (file_1, file_2); } break; + case CAJA_FILE_SORT_BY_BTIME: + result = compare_by_time (file_1, file_2, CAJA_DATE_TYPE_CREATED); + if (result == 0) { + result = compare_by_full_path (file_1, file_2); + } + break; case CAJA_FILE_SORT_BY_ATIME: result = compare_by_time (file_1, file_2, CAJA_DATE_TYPE_ACCESSED); if (result == 0) { @@ -3576,6 +3591,11 @@ caja_file_compare_for_sort_by_attribute_q (CajaFile *file_1, CAJA_FILE_SORT_BY_MTIME, directories_first, reversed); + } else if (attribute == attribute_creation_date_q || attribute == attribute_date_created_q) { + return caja_file_compare_for_sort (file_1, file_2, + CAJA_FILE_SORT_BY_BTIME, + directories_first, + reversed); } else if (attribute == attribute_accessed_date_q || attribute == attribute_date_accessed_q) { return caja_file_compare_for_sort (file_1, file_2, CAJA_FILE_SORT_BY_ATIME, @@ -4719,6 +4739,7 @@ caja_file_get_date (CajaFile *file, g_return_val_if_fail (date_type == CAJA_DATE_TYPE_CHANGED || date_type == CAJA_DATE_TYPE_ACCESSED || date_type == CAJA_DATE_TYPE_MODIFIED + || date_type == CAJA_DATE_TYPE_CREATED || date_type == CAJA_DATE_TYPE_TRASHED || date_type == CAJA_DATE_TYPE_PERMISSIONS_CHANGED, FALSE); @@ -6556,6 +6577,10 @@ caja_file_get_string_attribute_q (CajaFile *file, GQuark attribute_q) return caja_file_get_date_as_string (file, CAJA_DATE_TYPE_ACCESSED); } + if (attribute_q == attribute_date_created_q) { + return caja_file_get_date_as_string (file, + CAJA_DATE_TYPE_CREATED); + } if (attribute_q == attribute_trashed_on_q) { return caja_file_get_date_as_string (file, CAJA_DATE_TYPE_TRASHED); @@ -6722,6 +6747,8 @@ caja_file_is_date_sort_attribute_q (GQuark attribute_q) { if (attribute_q == attribute_modification_date_q || attribute_q == attribute_date_modified_q || + attribute_q == attribute_creation_date_q || + attribute_q == attribute_date_created_q || attribute_q == attribute_accessed_date_q || attribute_q == attribute_date_accessed_q || attribute_q == attribute_date_changed_q || @@ -8596,6 +8623,8 @@ caja_file_class_init (CajaFileClass *class) attribute_type_q = g_quark_from_static_string ("type"); attribute_modification_date_q = g_quark_from_static_string ("modification_date"); attribute_date_modified_q = g_quark_from_static_string ("date_modified"); + attribute_creation_date_q = g_quark_from_static_string ("creation_date"); + attribute_date_created_q = g_quark_from_static_string ("date_created"); attribute_accessed_date_q = g_quark_from_static_string ("accessed_date"); attribute_date_accessed_q = g_quark_from_static_string ("date_accessed"); attribute_emblems_q = g_quark_from_static_string ("emblems"); diff --git a/libcaja-private/caja-file.h b/libcaja-private/caja-file.h index eb57599c..b4498bcd 100644 --- a/libcaja-private/caja-file.h +++ b/libcaja-private/caja-file.h @@ -64,6 +64,7 @@ typedef enum CAJA_FILE_SORT_BY_SIZE, CAJA_FILE_SORT_BY_TYPE, CAJA_FILE_SORT_BY_MTIME, + CAJA_FILE_SORT_BY_BTIME, CAJA_FILE_SORT_BY_ATIME, CAJA_FILE_SORT_BY_EMBLEMS, CAJA_FILE_SORT_BY_TRASHED_TIME, @@ -511,6 +512,7 @@ struct CajaFile typedef enum { CAJA_DATE_TYPE_MODIFIED, + CAJA_DATE_TYPE_CREATED, CAJA_DATE_TYPE_CHANGED, CAJA_DATE_TYPE_ACCESSED, CAJA_DATE_TYPE_PERMISSIONS_CHANGED, diff --git a/libcaja-private/caja-vfs-file.c b/libcaja-private/caja-vfs-file.c index f876a402..1f64d93d 100644 --- a/libcaja-private/caja-vfs-file.c +++ b/libcaja-private/caja-vfs-file.c @@ -354,6 +354,17 @@ vfs_file_get_date (CajaFile *file, *date = file->details->mtime; } return TRUE; + case CAJA_DATE_TYPE_CREATED: + /* Before we have info on a file, the date is unknown. */ + if (file->details->btime == 0) + { + return FALSE; + } + if (date != NULL) + { + *date = file->details->btime; + } + return TRUE; case CAJA_DATE_TYPE_TRASHED: /* Before we have info on a file, the date is unknown. */ if (file->details->trash_time == 0) diff --git a/libcaja-private/org.mate.caja.gschema.xml b/libcaja-private/org.mate.caja.gschema.xml index dee7377a..399efdc7 100644 --- a/libcaja-private/org.mate.caja.gschema.xml +++ b/libcaja-private/org.mate.caja.gschema.xml @@ -278,7 +278,7 @@ A list of captions below an icon in the icon view and the desktop. The actual number of captions shown depends on the zoom level. Some possible values are: - "size", "type", "date_modified", "date_changed", "date_accessed", "owner", + "size", "type", "date_modified", "date_created", "date_changed", "date_accessed", "owner", "group", "permissions", "octal_permissions" and "mime_type". diff --git a/src/caja-file-management-properties.c b/src/caja-file-management-properties.c index 3c702cc3..5a4368a7 100644 --- a/src/caja-file-management-properties.c +++ b/src/caja-file-management-properties.c @@ -111,6 +111,7 @@ static const char * const sort_order_values[] = "size_on_disk", "type", "mtime", + "btime", "atime", "emblems", "extension", diff --git a/src/caja-file-management-properties.ui b/src/caja-file-management-properties.ui index 6449694a..80f6e8aa 100644 --- a/src/caja-file-management-properties.ui +++ b/src/caja-file-management-properties.ui @@ -92,6 +92,9 @@ By Modification Date + + By Creation Date + By Access Date diff --git a/src/file-manager/fm-icon-view.c b/src/file-manager/fm-icon-view.c index 664fd752..b6345018 100644 --- a/src/file-manager/fm-icon-view.c +++ b/src/file-manager/fm-icon-view.c @@ -158,6 +158,13 @@ static const SortCriterion sort_criteria[] = N_("by Modification _Date"), N_("Keep icons sorted by modification date in rows") }, + { + CAJA_FILE_SORT_BY_BTIME, + "creation date", + "Sort by Creation Date", + N_("by _Creation Date"), + N_("Keep icons sorted by creation date in rows") + }, { CAJA_FILE_SORT_BY_EMBLEMS, "emblems", @@ -1855,6 +1862,12 @@ static const GtkRadioActionEntry arrange_radio_entries[] = N_("Keep icons sorted by modification date in rows"), CAJA_FILE_SORT_BY_MTIME }, + { + "Sort by Creation Date", NULL, + N_("By _Creation Date"), NULL, + N_("Keep icons sorted by creation date in rows"), + CAJA_FILE_SORT_BY_BTIME + }, { "Sort by Emblems", NULL, N_("By _Emblems"), NULL, diff --git a/src/file-manager/fm-properties-window.c b/src/file-manager/fm-properties-window.c index e132b60f..944b18f0 100644 --- a/src/file-manager/fm-properties-window.c +++ b/src/file-manager/fm-properties-window.c @@ -3362,6 +3362,10 @@ create_basic_page (FMPropertiesWindow *window) "date_modified", INCONSISTENT_STATE_STRING, FALSE); + append_title_value_pair (window, grid, _("Created:"), + "date_created", + INCONSISTENT_STATE_STRING, + FALSE); } if (should_show_free_space (window)) { -- cgit v1.2.1