diff --git a/thunar/thunar-details-view.c b/thunar/thunar-details-view.c index ca9357c6ae8b8af0c99d2e84f0c9a8a224c313b0..824d4a2b2fab20355022a620d1320b18aac7c15f 100644 --- a/thunar/thunar-details-view.c +++ b/thunar/thunar-details-view.c @@ -1060,3 +1060,19 @@ thunar_details_view_set_fixed_columns (ThunarDetailsView *details_view, g_object_notify (G_OBJECT (details_view), "fixed-columns"); } } + + + +/** + * thunar_details_view_set_date_deleted_column_visible: + * @details_view : a #ThunarDetailsView. + * @visible : %TRUE to show the Date Deleted column. + * + * Shows/hides the Date Deleted column. + **/ +void +thunar_details_view_set_date_deleted_column_visible (ThunarDetailsView *details_view, + gboolean visible) +{ + thunar_column_model_set_column_visible (details_view->column_model, THUNAR_COLUMN_DATE_DELETED, visible); +} diff --git a/thunar/thunar-details-view.h b/thunar/thunar-details-view.h index 240440db34b864297106c16c5114f614cdd1770c..f7f45597f835227f700d55386d15c04db511c096 100644 --- a/thunar/thunar-details-view.h +++ b/thunar/thunar-details-view.h @@ -40,7 +40,8 @@ typedef enum THUNAR_DETAILS_VIEW_ACTION_CONFIGURE_COLUMNS, } ThunarDetailsViewAction; -GType thunar_details_view_get_type (void) G_GNUC_CONST; +GType thunar_details_view_get_type (void) G_GNUC_CONST; +void thunar_details_view_set_date_deleted_column_visible (ThunarDetailsView*, gboolean); G_END_DECLS; diff --git a/thunar/thunar-enum-types.c b/thunar/thunar-enum-types.c index 5db038881f62b0705e48e83669e2b469edd5a230..0651480cbc45bd8c1d1e3450999320a471717344 100644 --- a/thunar/thunar-enum-types.c +++ b/thunar/thunar-enum-types.c @@ -101,6 +101,7 @@ thunar_column_get_type (void) { THUNAR_COLUMN_DATE_CREATED, "THUNAR_COLUMN_DATE_CREATED", N_ ("Date Created"), }, { THUNAR_COLUMN_DATE_ACCESSED, "THUNAR_COLUMN_DATE_ACCESSED", N_ ("Date Accessed"), }, { THUNAR_COLUMN_DATE_MODIFIED, "THUNAR_COLUMN_DATE_MODIFIED", N_ ("Date Modified"), }, + { THUNAR_COLUMN_DATE_DELETED, "THUNAR_COLUMN_DATE_DELETED", N_ ("Date Deleted"), }, { THUNAR_COLUMN_GROUP, "THUNAR_COLUMN_GROUP", N_ ("Group"), }, { THUNAR_COLUMN_MIME_TYPE, "THUNAR_COLUMN_MIME_TYPE", N_ ("MIME Type"), }, { THUNAR_COLUMN_NAME, "THUNAR_COLUMN_NAME", N_ ("Name"), }, diff --git a/thunar/thunar-enum-types.h b/thunar/thunar-enum-types.h index c352ec86d8c49cb8f8227348e1ef75ce21ac6e82..6e39baa4f3e296b614a4ccd0a60be39e6757c3ed 100644 --- a/thunar/thunar-enum-types.h +++ b/thunar/thunar-enum-types.h @@ -78,6 +78,7 @@ GType thunar_date_style_get_type (void) G_GNUC_CONST; * @THUNAR_COLUMN_DATE_CREATED : created time. * @THUNAR_COLUMN_DATE_ACCESSED : last access time. * @THUNAR_COLUMN_DATE_MODIFIED : last modification time. + * @THUNAR_COLUMN_DATE_DELETED : deletion time. * @THUNAR_COLUMN_GROUP : group's name. * @THUNAR_COLUMN_MIME_TYPE : mime type (e.g. "text/plain"). * @THUNAR_COLUMN_NAME : display name. @@ -98,6 +99,7 @@ typedef enum THUNAR_COLUMN_DATE_CREATED, THUNAR_COLUMN_DATE_ACCESSED, THUNAR_COLUMN_DATE_MODIFIED, + THUNAR_COLUMN_DATE_DELETED, THUNAR_COLUMN_GROUP, THUNAR_COLUMN_MIME_TYPE, THUNAR_COLUMN_NAME, diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c index f768f2bb7c8e835a102e89a46c22e0981eb5b4ca..a5423010fbabe29e555165a8b9c79520c9271879 100644 --- a/thunar/thunar-file.c +++ b/thunar/thunar-file.c @@ -2094,6 +2094,8 @@ thunar_file_get_date (const ThunarFile *file, ThunarFileDateType date_type) { const gchar *attribute; + GDateTime *datetime; + gint64 date; _thunar_return_val_if_fail (THUNAR_IS_FILE (file), 0); @@ -2114,6 +2116,14 @@ thunar_file_get_date (const ThunarFile *file, case THUNAR_FILE_DATE_MODIFIED: attribute = G_FILE_ATTRIBUTE_TIME_MODIFIED; break; + case THUNAR_FILE_DATE_DELETED: + datetime = g_file_info_get_deletion_date (file->info); + if (datetime == NULL) + return 0; + date = g_date_time_to_unix (datetime); + g_date_time_unref (datetime); + return date; + default: _thunar_assert_not_reached (); } diff --git a/thunar/thunar-file.h b/thunar/thunar-file.h index be5139a0b79dbedf0b2aefd34286254933882dea..2db54f350d7c08690b93c2bfb6da56513ee36dee 100644 --- a/thunar/thunar-file.h +++ b/thunar/thunar-file.h @@ -47,6 +47,7 @@ typedef struct _ThunarFile ThunarFile; * @THUNAR_FILE_DATE_CHANGED : date of last change to the file meta data or the content. * @THUNAR_FILE_DATE_CREATED : date of file creation. * @THUNAR_FILE_DATE_MODIFIED : date of last modification of the file's content. + * @THUNAR_FILE_DATE_DELETED : date of file deletion. * * The various dates that can be queried about a #ThunarFile. Note, that not all * #ThunarFile implementations support all types listed above. See the documentation @@ -58,6 +59,7 @@ typedef enum THUNAR_FILE_DATE_CHANGED, THUNAR_FILE_DATE_CREATED, THUNAR_FILE_DATE_MODIFIED, + THUNAR_FILE_DATE_DELETED, } ThunarFileDateType; /** diff --git a/thunar/thunar-list-model.c b/thunar/thunar-list-model.c index 1955bd12d0fe11eff710c63d021e4c27266ea16a..0a3878311d43e14a59958a3e4c0e45c50fab5178 100644 --- a/thunar/thunar-list-model.c +++ b/thunar/thunar-list-model.c @@ -161,6 +161,9 @@ static gint sort_by_date_accessed (const ThunarF static gint sort_by_date_modified (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_group (const ThunarFile *a, const ThunarFile *b, gboolean case_sensitive); @@ -610,6 +613,9 @@ thunar_list_model_get_column_type (GtkTreeModel *model, case THUNAR_COLUMN_DATE_MODIFIED: return G_TYPE_STRING; + case THUNAR_COLUMN_DATE_DELETED: + return G_TYPE_STRING; + case THUNAR_COLUMN_GROUP: return G_TYPE_STRING; @@ -732,6 +738,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_FILE_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_GROUP: g_value_init (value, G_TYPE_STRING); group = thunar_file_get_group (file); @@ -964,6 +976,8 @@ thunar_list_model_get_sort_column_id (GtkTreeSortable *sortable, *sort_column_id = THUNAR_COLUMN_DATE_ACCESSED; else if (store->sort_func == sort_by_date_modified) *sort_column_id = THUNAR_COLUMN_DATE_MODIFIED; + else if (store->sort_func == sort_by_date_deleted) + *sort_column_id = THUNAR_COLUMN_DATE_DELETED; else if (store->sort_func == sort_by_type) *sort_column_id = THUNAR_COLUMN_TYPE; else if (store->sort_func == sort_by_owner) @@ -1009,6 +1023,10 @@ thunar_list_model_set_sort_column_id (GtkTreeSortable *sortable, store->sort_func = sort_by_date_modified; break; + case THUNAR_COLUMN_DATE_DELETED: + store->sort_func = sort_by_date_deleted; + break; + case THUNAR_COLUMN_GROUP: store->sort_func = sort_by_group; break; @@ -1472,6 +1490,27 @@ sort_by_date_modified (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_group (const ThunarFile *a, const ThunarFile *b, diff --git a/thunar/thunar-window.c b/thunar/thunar-window.c index 7eec6e12d896445148548bd85bfdf31c394ed80b..96d4310c2fde70bd8656f0a588e236089ffd9cfa 100644 --- a/thunar/thunar-window.c +++ b/thunar/thunar-window.c @@ -3978,6 +3978,8 @@ void thunar_window_set_current_directory (ThunarWindow *window, ThunarFile *current_directory) { + GFile *folder = NULL; + _thunar_return_if_fail (THUNAR_IS_WINDOW (window)); _thunar_return_if_fail (current_directory == NULL || THUNAR_IS_FILE (current_directory)); @@ -4055,6 +4057,15 @@ thunar_window_set_current_directory (ThunarWindow *window, * state already while the folder view is loading. */ g_object_notify (G_OBJECT (window), "current-directory"); + + /* show/hide date_deleted column in the trash directory */ + if (current_directory == NULL) + return; + if (THUNAR_IS_DETAILS_VIEW (window->view) == FALSE) + return; + + folder = thunar_file_get_file (current_directory); + thunar_details_view_set_date_deleted_column_visible (THUNAR_DETAILS_VIEW (window->view), thunar_g_file_is_trash (folder)); }