diff --git a/thunar/thunar-enum-types.c b/thunar/thunar-enum-types.c index 479bbcf..d2ab4c2 100644 --- a/thunar/thunar-enum-types.c +++ b/thunar/thunar-enum-types.c @@ -90,6 +90,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 9fb34a7..d7858a2 100644 --- a/thunar/thunar-enum-types.h +++ b/thunar/thunar-enum-types.h @@ -73,6 +73,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 (i.e. "text/plain"). @@ -91,6 +92,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 3262dfb..859cd97 100644 --- a/thunar/thunar-file.c +++ b/thunar/thunar-file.c @@ -2122,6 +2122,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); @@ -2136,6 +2137,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 NULL; + /* 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 cfc3d05..5fbd500 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 9e6d83c..5295269 100644 --- a/thunar/thunar-list-model.c +++ b/thunar/thunar-list-model.c @@ -154,6 +154,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); @@ -573,6 +576,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; @@ -684,6 +690,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); + 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); @@ -903,6 +915,8 @@ thunar_list_model_get_sort_column_id (GtkTreeSortable *sortable, *sort_column_id = THUNAR_COLUMN_SIZE; 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) @@ -942,6 +956,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; @@ -1364,6 +1382,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, gboolean case_sensitive)