From 607bd8928e666901b1bab09758c37f36fe229312 Mon Sep 17 00:00:00 2001 From: Andre Miranda <andreldm@xfce.org> Date: Thu, 20 Aug 2020 20:56:26 -0300 Subject: [PATCH] Add support to created date in file properties Fixes #209 --- thunar/thunar-file.c | 3 +++ thunar/thunar-file.h | 2 ++ thunar/thunar-properties-dialog.c | 32 +++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c index fd8484498..49b48bd5c 100644 --- a/thunar/thunar-file.c +++ b/thunar/thunar-file.c @@ -2107,6 +2107,9 @@ thunar_file_get_date (const ThunarFile *file, case THUNAR_FILE_DATE_CHANGED: attribute = G_FILE_ATTRIBUTE_TIME_CHANGED; break; + case THUNAR_FILE_DATE_CREATED: + attribute = G_FILE_ATTRIBUTE_TIME_CREATED; + break; 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 26828b3c0..be5139a0b 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_CREATED : date of file creation. * @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_CREATED, THUNAR_FILE_DATE_MODIFIED, } ThunarFileDateType; diff --git a/thunar/thunar-properties-dialog.c b/thunar/thunar-properties-dialog.c index 3a5bdf635..db0bbb16f 100644 --- a/thunar/thunar-properties-dialog.c +++ b/thunar/thunar-properties-dialog.c @@ -138,6 +138,7 @@ struct _ThunarPropertiesDialog GtkWidget *link_label; GtkWidget *location_label; GtkWidget *origin_label; + GtkWidget *created_label; GtkWidget *deleted_label; GtkWidget *modified_label; GtkWidget *accessed_label; @@ -454,6 +455,21 @@ thunar_properties_dialog_init (ThunarPropertiesDialog *dialog) ++row; + label = gtk_label_new (_("Created:")); + gtk_label_set_attributes (GTK_LABEL (label), thunar_pango_attr_list_bold ()); + gtk_label_set_xalign (GTK_LABEL (label), 1.0f); + gtk_grid_attach (GTK_GRID (grid), label, 0, row, 1, 1); + gtk_widget_show (label); + + dialog->created_label = g_object_new (GTK_TYPE_LABEL, "xalign", 0.0f, NULL); + gtk_label_set_selectable (GTK_LABEL (dialog->created_label), TRUE); + exo_binding_new (G_OBJECT (dialog->created_label), "visible", G_OBJECT (label), "visible"); + gtk_widget_set_hexpand (dialog->created_label, TRUE); + gtk_grid_attach (GTK_GRID (grid), dialog->created_label, 1, row, 1, 1); + gtk_widget_show (dialog->created_label); + + ++row; + label = gtk_label_new (_("Modified:")); gtk_label_set_attributes (GTK_LABEL (label), thunar_pango_attr_list_bold ()); gtk_label_set_xalign (GTK_LABEL (label), 1.0f); @@ -1068,6 +1084,21 @@ thunar_properties_dialog_update_single (ThunarPropertiesDialog *dialog) gtk_widget_hide (dialog->location_label); } +#if GLIB_CHECK_VERSION (2, 65, 2) + /* update the created time */ + date = thunar_file_get_date_string (file, THUNAR_FILE_DATE_CREATED, date_style, date_custom_style); + if (G_LIKELY (date != NULL)) + { + gtk_label_set_text (GTK_LABEL (dialog->created_label), date); + gtk_widget_show (dialog->created_label); + g_free (date); + } + else +#endif + { + gtk_widget_hide (dialog->created_label); + } + /* update the deleted time */ date = thunar_file_get_deletion_date (file, date_style, date_custom_style); if (G_LIKELY (date != NULL)) @@ -1194,6 +1225,7 @@ thunar_properties_dialog_update_multiple (ThunarPropertiesDialog *dialog) gtk_window_set_title (GTK_WINDOW (dialog), _("Properties")); /* widgets not used with > 1 file selected */ + gtk_widget_hide (dialog->created_label); gtk_widget_hide (dialog->deleted_label); gtk_widget_hide (dialog->modified_label); gtk_widget_hide (dialog->accessed_label); -- GitLab