diff --git a/thunar/thunar-enum-types.c b/thunar/thunar-enum-types.c index d3d94278..8ccf42a7 100644 --- a/thunar/thunar-enum-types.c +++ b/thunar/thunar-enum-types.c @@ -99,6 +99,7 @@ thunar_column_get_type (void) static const GEnumValue values[] = { { THUNAR_COLUMN_DATE_ACCESSED, "THUNAR_COLUMN_DATE_ACCESSED", N_ ("Date Accessed"), }, + { THUNAR_COLUMN_DATE_DELETED, "THUNAR_COLUMN_DATE_DELETED", N_ ("Date Deleted"), }, { THUNAR_COLUMN_DATE_MODIFIED, "THUNAR_COLUMN_DATE_MODIFIED", N_ ("Date Modified"), }, { THUNAR_COLUMN_GROUP, "THUNAR_COLUMN_GROUP", N_ ("Group"), }, { THUNAR_COLUMN_MIME_TYPE, "THUNAR_COLUMN_MIME_TYPE", N_ ("MIME Type"), }, diff --git a/thunar/thunar-enum-types.h b/thunar/thunar-enum-types.h index df25c955..82c7a1d6 100644 --- a/thunar/thunar-enum-types.h +++ b/thunar/thunar-enum-types.h @@ -76,6 +76,7 @@ GType thunar_date_style_get_type (void) G_GNUC_CONST; /** * ThunarColumn: * @THUNAR_COLUMN_DATE_ACCESSED : last access time. + * @THUNAR_COLUMN_DATE_DELETED : file deletion time. * @THUNAR_COLUMN_DATE_MODIFIED : last modification time. * @THUNAR_COLUMN_GROUP : group's name. * @THUNAR_COLUMN_MIME_TYPE : mime type (e.g. "text/plain"). @@ -95,6 +96,7 @@ typedef enum { /* visible columns */ THUNAR_COLUMN_DATE_ACCESSED, + THUNAR_COLUMN_DATE_DELETED, THUNAR_COLUMN_DATE_MODIFIED, THUNAR_COLUMN_GROUP, THUNAR_COLUMN_MIME_TYPE, diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c index 18687ff5..29f489c5 100644 --- a/thunar/thunar-file.c +++ b/thunar/thunar-file.c @@ -2175,6 +2175,7 @@ thunar_file_get_date (const ThunarFile *file, ThunarFileDateType date_type) { const gchar *attribute; + const gchar *date; _thunar_return_val_if_fail (THUNAR_IS_FILE (file), 0); @@ -2189,6 +2190,12 @@ thunar_file_get_date (const ThunarFile *file, case THUNAR_FILE_DATE_CHANGED: attribute = G_FILE_ATTRIBUTE_TIME_CHANGED; break; + case THUNAR_FILE_DATE_DELETED: + date = g_file_info_get_attribute_string (file->info, G_FILE_ATTRIBUTE_TRASH_DELETION_DATE); + if (G_UNLIKELY (date == NULL)) + return 0; + /* try to parse the DeletionDate (RFC 3339 string) */ + return thunar_util_time_from_rfc3339 (date); case THUNAR_FILE_DATE_MODIFIED: attribute = G_FILE_ATTRIBUTE_TIME_MODIFIED; break; diff --git a/thunar/thunar-file.h b/thunar/thunar-file.h index 2c744391..504e24a6 100644 --- a/thunar/thunar-file.h +++ b/thunar/thunar-file.h @@ -45,6 +45,7 @@ typedef struct _ThunarFile ThunarFile; * ThunarFileDateType: * @THUNAR_FILE_DATE_ACCESSED : date of last access to the file. * @THUNAR_FILE_DATE_CHANGED : date of last change to the file meta data or the content. + * @THUNAR_FILE_DATE_DELETED : date of file deletion. * @THUNAR_FILE_DATE_MODIFIED : date of last modification of the file's content. * * The various dates that can be queried about a #ThunarFile. Note, that not all @@ -55,6 +56,7 @@ typedef enum { THUNAR_FILE_DATE_ACCESSED, THUNAR_FILE_DATE_CHANGED, + THUNAR_FILE_DATE_DELETED, THUNAR_FILE_DATE_MODIFIED, } ThunarFileDateType; diff --git a/thunar/thunar-list-model.c b/thunar/thunar-list-model.c index 5017f276..5df6239f 100644 --- a/thunar/thunar-list-model.c +++ b/thunar/thunar-list-model.c @@ -155,6 +155,9 @@ static void thunar_list_model_files_removed (ThunarFolder static gint sort_by_date_accessed (const ThunarFile *a, const ThunarFile *b, gboolean case_sensitive); +static gint sort_by_date_deleted (const ThunarFile *a, + const ThunarFile *b, + gboolean case_sensitive); static gint sort_by_date_modified (const ThunarFile *a, const ThunarFile *b, gboolean case_sensitive); @@ -601,6 +604,9 @@ thunar_list_model_get_column_type (GtkTreeModel *model, case THUNAR_COLUMN_DATE_ACCESSED: return G_TYPE_STRING; + case THUNAR_COLUMN_DATE_DELETED: + return G_TYPE_STRING; + case THUNAR_COLUMN_DATE_MODIFIED: return G_TYPE_STRING; @@ -715,6 +721,12 @@ thunar_list_model_get_value (GtkTreeModel *model, g_value_take_string (value, str); break; + case THUNAR_COLUMN_DATE_DELETED: + g_value_init (value, G_TYPE_STRING); + str = thunar_file_get_date_string (file, THUNAR_COLUMN_DATE_DELETED, THUNAR_LIST_MODEL (model)->date_style, THUNAR_LIST_MODEL (model)->date_custom_style); + g_value_take_string (value, str); + break; + case THUNAR_COLUMN_DATE_MODIFIED: g_value_init (value, G_TYPE_STRING); str = thunar_file_get_date_string (file, THUNAR_FILE_DATE_MODIFIED, THUNAR_LIST_MODEL (model)->date_style, THUNAR_LIST_MODEL (model)->date_custom_style); @@ -949,6 +961,8 @@ thunar_list_model_get_sort_column_id (GtkTreeSortable *sortable, *sort_column_id = THUNAR_COLUMN_SIZE_IN_BYTES; else if (store->sort_func == sort_by_date_accessed) *sort_column_id = THUNAR_COLUMN_DATE_ACCESSED; + else if (store->sort_func == sort_by_date_deleted) + *sort_column_id = THUNAR_COLUMN_DATE_DELETED; else if (store->sort_func == sort_by_date_modified) *sort_column_id = THUNAR_COLUMN_DATE_MODIFIED; else if (store->sort_func == sort_by_type) @@ -988,6 +1002,10 @@ thunar_list_model_set_sort_column_id (GtkTreeSortable *sortable, store->sort_func = sort_by_date_accessed; break; + case THUNAR_COLUMN_DATE_DELETED: + store->sort_func = sort_by_date_deleted; + break; + case THUNAR_COLUMN_DATE_MODIFIED: store->sort_func = sort_by_date_modified; break; @@ -1413,6 +1431,27 @@ sort_by_date_accessed (const ThunarFile *a, +static gint +sort_by_date_deleted (const ThunarFile *a, + const ThunarFile *b, + gboolean case_sensitive) +{ + guint64 date_a; + guint64 date_b; + + date_a = thunar_file_get_date (a, THUNAR_FILE_DATE_DELETED); + date_b = thunar_file_get_date (b, THUNAR_FILE_DATE_DELETED); + + if (date_a < date_b) + return -1; + else if (date_a > date_b) + return 1; + + return thunar_file_compare_by_name (a, b, case_sensitive); +} + + + static gint sort_by_date_modified (const ThunarFile *a, const ThunarFile *b,