[Xfce4-commits] [xfce/thunar] 06/06: Add german (and custom) date format (Bug #14527)

noreply at xfce.org noreply at xfce.org
Wed Jul 18 22:07:34 CEST 2018


This is an automated email from the git hooks/post-receive script.

a   l   e   x       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       x   f   c   e   -   4   .   1   4   
   in repository xfce/thunar.

commit 6a22d059527165f9d081501e66cfafd720698395
Author: Alexander Schwinn <acs82 at gmx.de>
Date:   Mon Jul 16 00:31:28 2018 +0200

    Add german (and custom) date format (Bug #14527)
---
 thunar/thunar-dialogs.c            |  6 ++--
 thunar/thunar-enum-types.c         | 15 +++++---
 thunar/thunar-enum-types.h         |  5 ++-
 thunar/thunar-file.c               | 12 ++++---
 thunar/thunar-file.h               |  6 ++--
 thunar/thunar-list-model.c         | 74 ++++++++++++++++++++++++++++++++++++--
 thunar/thunar-preferences-dialog.c | 41 +++++++++++++++++++--
 thunar/thunar-preferences.c        | 13 +++++++
 thunar/thunar-properties-dialog.c  |  8 +++--
 thunar/thunar-standard-view.c      |  1 +
 thunar/thunar-util.c               | 29 +++++++++++----
 thunar/thunar-util.h               |  3 +-
 12 files changed, 185 insertions(+), 28 deletions(-)

diff --git a/thunar/thunar-dialogs.c b/thunar/thunar-dialogs.c
index c152928..d5c0225 100644
--- a/thunar/thunar-dialogs.c
+++ b/thunar/thunar-dialogs.c
@@ -528,6 +528,7 @@ thunar_dialogs_show_job_ask_replace (GtkWindow  *parent,
   GtkWidget         *image;
   GtkWidget         *label;
   GdkPixbuf         *icon;
+  gchar             *date_custom_style;
   gchar             *date_string;
   gchar             *size_string;
   gchar             *text;
@@ -541,6 +542,7 @@ thunar_dialogs_show_job_ask_replace (GtkWindow  *parent,
   /* determine the style used to format dates */
   preferences = thunar_preferences_get ();
   g_object_get (G_OBJECT (preferences), "misc-date-style", &date_style, NULL);
+  g_object_get (G_OBJECT (preferences), "misc-date-custom-style", &date_custom_style, NULL);
   g_object_get (G_OBJECT (preferences), "misc-file-size-binary", &file_size_binary, NULL);
   g_object_unref (G_OBJECT (preferences));
 
@@ -628,7 +630,7 @@ thunar_dialogs_show_job_ask_replace (GtkWindow  *parent,
   gtk_widget_show (image);
 
   size_string = thunar_file_get_size_string_long (dst_file, file_size_binary);
-  date_string = thunar_file_get_date_string (dst_file, THUNAR_FILE_DATE_MODIFIED, date_style);
+  date_string = thunar_file_get_date_string (dst_file, THUNAR_FILE_DATE_MODIFIED, date_style, date_custom_style);
   text = g_strdup_printf ("%s %s\n%s %s", _("Size:"), size_string, _("Modified:"), date_string);
   label = gtk_label_new (text);
   gtk_label_set_xalign (GTK_LABEL (label), 0.0f);
@@ -664,7 +666,7 @@ thunar_dialogs_show_job_ask_replace (GtkWindow  *parent,
   gtk_widget_show (image);
 
   size_string = thunar_file_get_size_string_long (src_file, file_size_binary);
-  date_string = thunar_file_get_date_string (src_file, THUNAR_FILE_DATE_MODIFIED, date_style);
+  date_string = thunar_file_get_date_string (src_file, THUNAR_FILE_DATE_MODIFIED, date_style, date_custom_style);
   text = g_strdup_printf ("%s %s\n%s %s", _("Size:"), size_string, _("Modified:"), date_string);
   label = gtk_label_new (text);
   gtk_label_set_xalign (GTK_LABEL (label), 0.0f);
diff --git a/thunar/thunar-enum-types.c b/thunar/thunar-enum-types.c
index 5585f4a..5d93f91 100644
--- a/thunar/thunar-enum-types.c
+++ b/thunar/thunar-enum-types.c
@@ -65,11 +65,16 @@ thunar_date_style_get_type (void)
     {
       static const GEnumValue values[] =
       {
-        { THUNAR_DATE_STYLE_SIMPLE, "THUNAR_DATE_STYLE_SIMPLE", "simple", },
-        { THUNAR_DATE_STYLE_SHORT,  "THUNAR_DATE_STYLE_SHORT",  "short",  },
-        { THUNAR_DATE_STYLE_LONG,   "THUNAR_DATE_STYLE_LONG",   "long",   },
-        { THUNAR_DATE_STYLE_ISO,    "THUNAR_DATE_STYLE_ISO",    "iso",   },
-        { 0,                        NULL,                       NULL,     },
+        { THUNAR_DATE_STYLE_SIMPLE,   "THUNAR_DATE_STYLE_SIMPLE",   "simple",   },
+        { THUNAR_DATE_STYLE_SHORT,    "THUNAR_DATE_STYLE_SHORT",    "short",    },
+        { THUNAR_DATE_STYLE_LONG,     "THUNAR_DATE_STYLE_LONG",     "long",     },
+        { THUNAR_DATE_STYLE_YYYYMMDD, "THUNAR_DATE_STYLE_YYYYMMDD", "yyyymmdd", },
+        { THUNAR_DATE_STYLE_MMDDYYYY, "THUNAR_DATE_STYLE_MMDDYYYY", "mmddyyyy", },
+        { THUNAR_DATE_STYLE_DDMMYYYY, "THUNAR_DATE_STYLE_DDMMYYYY", "ddmmyyyy", },
+        { THUNAR_DATE_STYLE_CUSTOM,   "THUNAR_DATE_STYLE_CUSTOM",   "custom",   },
+        /* to stay backward compartible*/
+        { THUNAR_DATE_STYLE_YYYYMMDD, "THUNAR_DATE_STYLE_ISO",      "iso",      },
+        { 0,                          NULL,                         NULL,       },
       };
 
       type = g_enum_register_static (I_("ThunarDateStyle"), values);
diff --git a/thunar/thunar-enum-types.h b/thunar/thunar-enum-types.h
index e5e6aa9..71d6695 100644
--- a/thunar/thunar-enum-types.h
+++ b/thunar/thunar-enum-types.h
@@ -62,7 +62,10 @@ typedef enum
   THUNAR_DATE_STYLE_SIMPLE,
   THUNAR_DATE_STYLE_SHORT,
   THUNAR_DATE_STYLE_LONG,
-  THUNAR_DATE_STYLE_ISO,
+  THUNAR_DATE_STYLE_YYYYMMDD,
+  THUNAR_DATE_STYLE_MMDDYYYY,
+  THUNAR_DATE_STYLE_DDMMYYYY,
+  THUNAR_DATE_STYLE_CUSTOM,
 } ThunarDateStyle;
 
 GType thunar_date_style_get_type (void) G_GNUC_CONST;
diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c
index 6ace63f..222b3c9 100644
--- a/thunar/thunar-file.c
+++ b/thunar/thunar-file.c
@@ -2187,6 +2187,7 @@ thunar_file_get_date (const ThunarFile  *file,
  * @file       : a #ThunarFile instance.
  * @date_type  : the kind of date you are interested to know about @file.
  * @date_style : the style used to format the date.
+ * @date_custom_style : custom style to apply, if @date_style is set to custom
  *
  * Tries to determine the @date_type of @file, and if @file supports the
  * given @date_type, it'll be formatted as string and returned. The
@@ -2198,9 +2199,10 @@ thunar_file_get_date (const ThunarFile  *file,
 gchar*
 thunar_file_get_date_string (const ThunarFile  *file,
                              ThunarFileDateType date_type,
-                             ThunarDateStyle    date_style)
+                             ThunarDateStyle    date_style,
+                             const gchar       *date_custom_style)
 {
-  return thunar_util_humanize_file_time (thunar_file_get_date (file, date_type), date_style);
+  return thunar_util_humanize_file_time (thunar_file_get_date (file, date_type), date_style, date_custom_style);
 }
 
 
@@ -3177,6 +3179,7 @@ thunar_file_get_display_name (const ThunarFile *file)
  * thunar_file_get_deletion_date:
  * @file       : a #ThunarFile instance.
  * @date_style : the style used to format the date.
+ * @date_custom_style : custom style to apply, if @date_style is set to custom
  *
  * Returns the deletion date of the @file if the @file
  * is located in the trash. Otherwise %NULL will be
@@ -3190,7 +3193,8 @@ thunar_file_get_display_name (const ThunarFile *file)
  **/
 gchar*
 thunar_file_get_deletion_date (const ThunarFile *file,
-                               ThunarDateStyle   date_style)
+                               ThunarDateStyle   date_style,
+                               const gchar      *date_custom_style)
 {
   const gchar *date;
   time_t       deletion_time;
@@ -3206,7 +3210,7 @@ thunar_file_get_deletion_date (const ThunarFile *file,
   deletion_time = thunar_util_time_from_rfc3339 (date);
 
   /* humanize the time value */
-  return thunar_util_humanize_file_time (deletion_time, date_style);
+  return thunar_util_humanize_file_time (deletion_time, date_style, date_custom_style);
 }
 
 
diff --git a/thunar/thunar-file.h b/thunar/thunar-file.h
index 73000e4..e02168e 100644
--- a/thunar/thunar-file.h
+++ b/thunar/thunar-file.h
@@ -165,7 +165,8 @@ guint64           thunar_file_get_date                   (const ThunarFile
 
 gchar            *thunar_file_get_date_string            (const ThunarFile       *file,
                                                           ThunarFileDateType      date_type,
-                                                          ThunarDateStyle         date_style) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
+                                                          ThunarDateStyle         date_style,
+                                                          const gchar            *date_custom_style) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
 gchar            *thunar_file_get_mode_string            (const ThunarFile       *file) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
 gchar            *thunar_file_get_size_string            (const ThunarFile       *file) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
 gchar            *thunar_file_get_size_in_bytes_string   (const ThunarFile       *file) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
@@ -212,7 +213,8 @@ gboolean          thunar_file_is_desktop_file            (const ThunarFile
 const gchar      *thunar_file_get_display_name           (const ThunarFile       *file) G_GNUC_CONST;
 
 gchar            *thunar_file_get_deletion_date          (const ThunarFile       *file,
-                                                          ThunarDateStyle         date_style) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
+                                                          ThunarDateStyle         date_style,
+                                                          const gchar            *date_custom_style) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
 const gchar      *thunar_file_get_original_path          (const ThunarFile       *file);
 guint32           thunar_file_get_item_count             (const ThunarFile       *file);
 
diff --git a/thunar/thunar-list-model.c b/thunar/thunar-list-model.c
index 2821b67..713aa51 100644
--- a/thunar/thunar-list-model.c
+++ b/thunar/thunar-list-model.c
@@ -46,6 +46,7 @@ enum
   PROP_0,
   PROP_CASE_SENSITIVE,
   PROP_DATE_STYLE,
+  PROP_DATE_CUSTOM_STYLE,
   PROP_FOLDER,
   PROP_FOLDERS_FIRST,
   PROP_NUM_FILES,
@@ -185,6 +186,9 @@ static void               thunar_list_model_set_case_sensitive    (ThunarListMod
 static ThunarDateStyle    thunar_list_model_get_date_style        (ThunarListModel        *store);
 static void               thunar_list_model_set_date_style        (ThunarListModel        *store,
                                                                    ThunarDateStyle         date_style);
+static const char*        thunar_list_model_get_date_custom_style (ThunarListModel        *store);
+static void               thunar_list_model_set_date_custom_style (ThunarListModel        *store,
+                                                                   const char             *date_custom_style);
 static gint               thunar_list_model_get_num_files         (ThunarListModel        *store);
 static gboolean           thunar_list_model_get_folders_first     (ThunarListModel        *store);
 
@@ -217,6 +221,7 @@ struct _ThunarListModel
   gboolean        show_hidden : 1;
   gboolean        file_size_binary : 1;
   ThunarDateStyle date_style;
+  char           *date_custom_style;
 
   /* Use the shared ThunarFileMonitor instance, so we
    * do not need to connect "changed" handler to every
@@ -287,6 +292,18 @@ thunar_list_model_class_init (ThunarListModelClass *klass)
                          EXO_PARAM_READWRITE);
 
   /**
+   * ThunarListModel:date-custom-style:
+   *
+   * The style used for custom format of dates.
+   **/
+  list_model_props[PROP_DATE_CUSTOM_STYLE] =
+      g_param_spec_string ("date-custom-style",
+                           "DateCustomStyle",
+                           NULL,
+                           "%Y-%m-%d %H:%M:%S",
+                           EXO_PARAM_READWRITE);
+
+  /**
    * ThunarListModel:folder:
    *
    * The folder presented by this #ThunarListModel.
@@ -481,6 +498,10 @@ thunar_list_model_get_property (GObject    *object,
       g_value_set_enum (value, thunar_list_model_get_date_style (store));
       break;
 
+    case PROP_DATE_CUSTOM_STYLE:
+      g_value_set_string (value, thunar_list_model_get_date_custom_style (store));
+      break;
+
     case PROP_FOLDER:
       g_value_set_object (value, thunar_list_model_get_folder (store));
       break;
@@ -527,6 +548,10 @@ thunar_list_model_set_property (GObject      *object,
       thunar_list_model_set_date_style (store, g_value_get_enum (value));
       break;
 
+    case PROP_DATE_CUSTOM_STYLE:
+      thunar_list_model_set_date_custom_style (store, g_value_get_string (value));
+      break;
+
     case PROP_FOLDER:
       thunar_list_model_set_folder (store, g_value_get_object (value));
       break;
@@ -686,13 +711,13 @@ thunar_list_model_get_value (GtkTreeModel *model,
     {
     case THUNAR_COLUMN_DATE_ACCESSED:
       g_value_init (value, G_TYPE_STRING);
-      str = thunar_file_get_date_string (file, THUNAR_FILE_DATE_ACCESSED, THUNAR_LIST_MODEL (model)->date_style);
+      str = thunar_file_get_date_string (file, THUNAR_FILE_DATE_ACCESSED, 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);
+      str = thunar_file_get_date_string (file, THUNAR_FILE_DATE_MODIFIED, THUNAR_LIST_MODEL (model)->date_style, THUNAR_LIST_MODEL (model)->date_custom_style);
       g_value_take_string (value, str);
       break;
 
@@ -1771,6 +1796,51 @@ thunar_list_model_set_date_style (ThunarListModel *store,
 
 
 /**
+ * thunar_list_model_get_date_custom_style:
+ * @store : a valid #ThunarListModel object.
+ *
+ * Return value: the style used to format customdates in the given @store.
+ **/
+static const char*
+thunar_list_model_get_date_custom_style (ThunarListModel *store)
+{
+  _thunar_return_val_if_fail (THUNAR_IS_LIST_MODEL (store), THUNAR_DATE_STYLE_SIMPLE);
+  return store->date_custom_style;
+}
+
+
+
+/**
+ * thunar_list_model_set_date_custom_style:
+ * @store             : a valid #ThunarListModel object.
+ * @date_custom_style : the style that should be used to format
+ *                      custom dates in the @store.
+ *
+ * Changes the style used to format custom dates in @store to the specified @date_custom_style.
+ **/
+static void
+thunar_list_model_set_date_custom_style (ThunarListModel *store,
+                                         const char      *date_custom_style)
+{
+  _thunar_return_if_fail (THUNAR_IS_LIST_MODEL (store));
+
+  /* check if we have a new setting */
+  if (g_strcmp0 (store->date_custom_style, date_custom_style) != 0)
+    {
+      /* apply the new setting */
+      store->date_custom_style = g_strdup (date_custom_style);
+
+      /* notify listeners */
+      g_object_notify_by_pspec (G_OBJECT (store), list_model_props[PROP_DATE_CUSTOM_STYLE]);
+
+      /* emit a "changed" signal for each row, so the display is reloaded with the new date style */
+      gtk_tree_model_foreach (GTK_TREE_MODEL (store), (GtkTreeModelForeachFunc) gtk_tree_model_row_changed, NULL);
+    }
+}
+
+
+
+/**
  * thunar_list_model_get_folder:
  * @store : a valid #ThunarListModel object.
  *
diff --git a/thunar/thunar-preferences-dialog.c b/thunar/thunar-preferences-dialog.c
index dd19f6d..edd32c8 100644
--- a/thunar/thunar-preferences-dialog.c
+++ b/thunar/thunar-preferences-dialog.c
@@ -199,6 +199,23 @@ thunar_preferences_dialog_class_init (ThunarPreferencesDialogClass *klass)
 
 
 static void
+on_date_format_changed (GtkWidget *combo,
+                        GtkWidget *customFormat)
+{
+  GtkComboBox *combobox = GTK_COMBO_BOX (combo);
+
+  _thunar_return_if_fail (GTK_IS_COMBO_BOX (combobox));
+  _thunar_return_if_fail (GTK_IS_WIDGET (customFormat));
+
+  if (gtk_combo_box_get_active (combobox) == THUNAR_DATE_STYLE_CUSTOM)
+    gtk_widget_set_visible (customFormat, TRUE);
+  else
+    gtk_widget_set_visible (customFormat, FALSE);
+}
+
+
+
+static void
 thunar_preferences_dialog_init (ThunarPreferencesDialog *dialog)
 {
   ThunarDateStyle date_style;
@@ -206,6 +223,7 @@ thunar_preferences_dialog_init (ThunarPreferencesDialog *dialog)
   GtkWidget      *notebook;
   GtkWidget      *button;
   GtkWidget      *combo;
+  GtkWidget      *entry;
   GtkWidget      *frame;
   GtkWidget      *label;
   GtkWidget      *range;
@@ -355,12 +373,15 @@ thunar_preferences_dialog_init (ThunarPreferencesDialog *dialog)
   gtk_widget_show (label);
 
   combo = gtk_combo_box_text_new ();
-  for (date_style = THUNAR_DATE_STYLE_SIMPLE; date_style <= THUNAR_DATE_STYLE_ISO; ++date_style)
+  for (date_style = THUNAR_DATE_STYLE_SIMPLE; date_style <= THUNAR_DATE_STYLE_DDMMYYYY; ++date_style)
     {
-      date = thunar_util_humanize_file_time (time (NULL), date_style);
+      date = thunar_util_humanize_file_time (time (NULL), date_style, NULL);
       gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), date);
       g_free (date);
     }
+
+  /* TRANSLATORS: custom date format */
+  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("Custom"));
   exo_mutual_binding_new (G_OBJECT (dialog->preferences), "misc-date-style", G_OBJECT (combo), "active");
   gtk_widget_set_hexpand (combo, TRUE);
   gtk_grid_attach (GTK_GRID (grid), combo, 1, 0, 1, 1);
@@ -368,6 +389,22 @@ thunar_preferences_dialog_init (ThunarPreferencesDialog *dialog)
   gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
   gtk_widget_show (combo);
 
+  entry = gtk_entry_new ();
+  /* TRANSLATORS: Please do not translate the first column (specifiers), 'strftime' and of course '\n' */
+  gtk_widget_set_tooltip_text (entry, _("Custom date format to apply.\n\n"
+                                        "The most common specifiers are:\n"
+                                        "%d day of month\n"
+                                        "%m month\n"
+                                        "%Y year including century\n"
+                                        "%H hour\n"
+                                        "%M minute\n"
+                                        "%S second\n\n"
+                                        "For a complete list, check the man pages of 'strftime'"));
+  exo_mutual_binding_new (G_OBJECT (dialog->preferences), "misc-date-custom-style", G_OBJECT (entry), "text");
+  g_signal_connect (G_OBJECT (combo), "changed", G_CALLBACK (on_date_format_changed), entry);
+  gtk_grid_attach (GTK_GRID (grid), entry, 1, 1, 1, 1);
+  if (gtk_combo_box_get_active (GTK_COMBO_BOX (combo)) == THUNAR_DATE_STYLE_CUSTOM)
+    gtk_widget_set_visible (entry, TRUE);
 
   /*
      Side Pane
diff --git a/thunar/thunar-preferences.c b/thunar/thunar-preferences.c
index db92bf2..5931842 100644
--- a/thunar/thunar-preferences.c
+++ b/thunar/thunar-preferences.c
@@ -75,6 +75,7 @@ enum
   PROP_MISC_VOLUME_MANAGEMENT,
   PROP_MISC_CASE_SENSITIVE,
   PROP_MISC_DATE_STYLE,
+  PROP_MISC_DATE_CUSTOM_STYLE,
   PROP_EXEC_SHELL_SCRIPTS_BY_DEFAULT,
   PROP_MISC_FOLDERS_FIRST,
   PROP_MISC_FULL_PATH_IN_TITLE,
@@ -493,6 +494,18 @@ thunar_preferences_class_init (ThunarPreferencesClass *klass)
                          EXO_PARAM_READWRITE);
 
   /**
+   * ThunarPreferences:misc-date-custom-style:
+   *
+   * If 'custom' is selected as date format, this date-style will be used
+   **/
+  preferences_props[PROP_MISC_DATE_CUSTOM_STYLE] =
+      g_param_spec_string ("misc-date-custom-style",
+                           "MiscDateCustomStyle",
+                           NULL,
+                           "%Y-%m-%d %H:%M:%S",
+                           EXO_PARAM_READWRITE);
+
+  /**
    * ThunarPreferences:misc-execute-shell-scripts-by-default:
    *
    * Shell scripts are often unsafe to execute, require additional
diff --git a/thunar/thunar-properties-dialog.c b/thunar/thunar-properties-dialog.c
index b2da0a8..4168b53 100644
--- a/thunar/thunar-properties-dialog.c
+++ b/thunar/thunar-properties-dialog.c
@@ -908,6 +908,7 @@ thunar_properties_dialog_update_single (ThunarPropertiesDialog *dialog)
   GVolume           *volume;
   GIcon             *gicon;
   glong              offset;
+  gchar             *date_custom_style;
   gchar             *date;
   gchar             *display_name;
   gchar             *fs_string;
@@ -939,6 +940,7 @@ thunar_properties_dialog_update_single (ThunarPropertiesDialog *dialog)
 
   /* determine the style used to format dates */
   g_object_get (G_OBJECT (dialog->preferences), "misc-date-style", &date_style, NULL);
+  g_object_get (G_OBJECT (dialog->preferences), "misc-date-custom-style", &date_custom_style, NULL);
 
   /* update the properties dialog title */
   str = g_strdup_printf (_("%s - Properties"), thunar_file_get_display_name (file));
@@ -1056,7 +1058,7 @@ thunar_properties_dialog_update_single (ThunarPropertiesDialog *dialog)
     }
 
   /* update the deleted time */
-  date = thunar_file_get_deletion_date (file, date_style);
+  date = thunar_file_get_deletion_date (file, date_style, date_custom_style);
   if (G_LIKELY (date != NULL))
     {
       gtk_label_set_text (GTK_LABEL (dialog->deleted_label), date);
@@ -1069,7 +1071,7 @@ thunar_properties_dialog_update_single (ThunarPropertiesDialog *dialog)
     }
 
   /* update the modified time */
-  date = thunar_file_get_date_string (file, THUNAR_FILE_DATE_MODIFIED, date_style);
+  date = thunar_file_get_date_string (file, THUNAR_FILE_DATE_MODIFIED, date_style, date_custom_style);
   if (G_LIKELY (date != NULL))
     {
       gtk_label_set_text (GTK_LABEL (dialog->modified_label), date);
@@ -1082,7 +1084,7 @@ thunar_properties_dialog_update_single (ThunarPropertiesDialog *dialog)
     }
 
   /* update the accessed time */
-  date = thunar_file_get_date_string (file, THUNAR_FILE_DATE_ACCESSED, date_style);
+  date = thunar_file_get_date_string (file, THUNAR_FILE_DATE_ACCESSED, date_style, date_custom_style);
   if (G_LIKELY (date != NULL))
     {
       gtk_label_set_text (GTK_LABEL (dialog->accessed_label), date);
diff --git a/thunar/thunar-standard-view.c b/thunar/thunar-standard-view.c
index 539f6a9..a5e2966 100644
--- a/thunar/thunar-standard-view.c
+++ b/thunar/thunar-standard-view.c
@@ -706,6 +706,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
   g_signal_connect (G_OBJECT (standard_view->model), "error", G_CALLBACK (thunar_standard_view_error), standard_view);
   exo_binding_new (G_OBJECT (standard_view->preferences), "misc-case-sensitive", G_OBJECT (standard_view->model), "case-sensitive");
   exo_binding_new (G_OBJECT (standard_view->preferences), "misc-date-style", G_OBJECT (standard_view->model), "date-style");
+  exo_binding_new (G_OBJECT (standard_view->preferences), "misc-date-custom-style", G_OBJECT (standard_view->model), "date-custom-style");
   exo_binding_new (G_OBJECT (standard_view->preferences), "misc-folders-first", G_OBJECT (standard_view->model), "folders-first");
   exo_binding_new (G_OBJECT (standard_view->preferences), "misc-file-size-binary", G_OBJECT (standard_view->model), "file-size-binary");
 
diff --git a/thunar/thunar-util.c b/thunar/thunar-util.c
index c61a73b..c3c864a 100644
--- a/thunar/thunar-util.c
+++ b/thunar/thunar-util.c
@@ -357,8 +357,9 @@ thunar_util_expand_filename (const gchar  *filename,
 
 /**
  * thunar_util_humanize_file_time:
- * @file_time   : a #guint64 timestamp.
- * @date_format : the #ThunarDateFormat used to humanize the @file_time.
+ * @file_time         : a #guint64 timestamp.
+ * @date_style        : the #ThunarDateFormat used to humanize the @file_time.
+ * @date_custom_style : custom style to apply, if @date_style is set to custom
  *
  * Returns a human readable date representation of the specified
  * @file_time. The caller is responsible to free the returned
@@ -368,8 +369,9 @@ thunar_util_expand_filename (const gchar  *filename,
  *               according to the @date_format.
  **/
 gchar*
-thunar_util_humanize_file_time (guint64         file_time,
-                                ThunarDateStyle date_style)
+thunar_util_humanize_file_time (guint64          file_time,
+                                ThunarDateStyle  date_style,
+                                const gchar     *date_custom_style)
 {
   const gchar *date_format;
   struct tm   *tfile;
@@ -443,11 +445,26 @@ thunar_util_humanize_file_time (guint64         file_time,
           /* use long, date(1)-like format string */
           return exo_strdup_strftime ("%c", tfile);
         }
-      else /* if (date_style == THUNAR_DATE_STYLE_ISO) */
+      else if (date_style == THUNAR_DATE_STYLE_YYYYMMDD)
         {
-          /* use ISO date formatting */
           return exo_strdup_strftime ("%Y-%m-%d %H:%M:%S", tfile);
         }
+      else if (date_style == THUNAR_DATE_STYLE_MMDDYYYY)
+        {
+          return exo_strdup_strftime ("%m-%d-%Y %H:%M:%S", tfile);
+        }
+      else if (date_style == THUNAR_DATE_STYLE_DDMMYYYY)
+        {
+          return exo_strdup_strftime ("%d-%m-%Y %H:%M:%S", tfile);
+        }
+      else /* if (date_style == THUNAR_DATE_STYLE_CUSTOM) */
+        {
+          if (date_custom_style == NULL)
+            return g_strdup ("");
+
+          /* use custom date formatting */
+          return exo_strdup_strftime (date_custom_style, tfile);
+        }
     }
 
   /* the file_time is invalid */
diff --git a/thunar/thunar-util.h b/thunar/thunar-util.h
index d0f277c..a534a9a 100644
--- a/thunar/thunar-util.h
+++ b/thunar/thunar-util.h
@@ -54,7 +54,8 @@ gchar     *thunar_util_expand_filename          (const gchar    *filename,
                                                  GError        **error) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
 
 gchar     *thunar_util_humanize_file_time       (guint64         file_time,
-                                                 ThunarDateStyle date_style) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
+                                                 ThunarDateStyle date_style,
+                                                 const gchar    *date_custom_style) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
 
 GdkScreen *thunar_util_parse_parent             (gpointer        parent,
                                                  GtkWindow     **window_return) G_GNUC_WARN_UNUSED_RESULT;

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list