From 95de09de07d4164134d9ada677d7404d0327094a Mon Sep 17 00:00:00 2001 From: Adam Purkrt Date: Sat, 3 Feb 2018 11:37:04 +0100 Subject: [PATCH 2/2] Display also size in bytes in overwrite confirmation Bug: 11690 The patch adds displaying size in bytes in addition to a human readable size to the dialog for overwriting file. --- thunar/thunar-dialogs.c | 4 ++-- thunar/thunar-file.c | 24 ++++++++++++++++++++++++ thunar/thunar-file.h | 2 ++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/thunar/thunar-dialogs.c b/thunar/thunar-dialogs.c index 5d5da967..97980bd2 100644 --- a/thunar/thunar-dialogs.c +++ b/thunar/thunar-dialogs.c @@ -632,7 +632,7 @@ thunar_dialogs_show_job_ask_replace (GtkWindow *parent, g_object_unref (G_OBJECT (icon)); gtk_widget_show (image); - size_string = thunar_file_get_size_string_formatted (dst_file, file_size_binary); + 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); text = g_strdup_printf ("%s %s\n%s %s", _("Size:"), size_string, _("Modified:"), date_string); label = gtk_label_new (text); @@ -668,7 +668,7 @@ thunar_dialogs_show_job_ask_replace (GtkWindow *parent, g_object_unref (G_OBJECT (icon)); gtk_widget_show (image); - size_string = thunar_file_get_size_string_formatted (src_file, file_size_binary); + 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); text = g_strdup_printf ("%s %s\n%s %s", _("Size:"), size_string, _("Modified:"), date_string); label = gtk_label_new (text); diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c index 9f8b2aeb..8d61bf01 100644 --- a/thunar/thunar-file.c +++ b/thunar/thunar-file.c @@ -2338,6 +2338,30 @@ thunar_file_get_size_string_formatted (const ThunarFile *file, const gboolean fi +/** + * thunar_file_get_size_string_long: + * @file : a #ThunarFile instance. + * @file_size_binary : indicates if file size format + * should be binary or not. + * + * Returns the size of the file as text in a human readable + * format in decimal or binary format, including the exact + * size in bytes. You'll need to free the result using + * g_free() if you're done with it. + * + * Return value: the size of @file in a human readable + * format, including size in bytes. + **/ +gchar * +thunar_file_get_size_string_long (const ThunarFile *file, const gboolean file_size_binary) +{ + _thunar_return_val_if_fail (THUNAR_IS_FILE (file), NULL); + return g_format_size_full (thunar_file_get_size (file), + G_FORMAT_SIZE_LONG_FORMAT | (file_size_binary ? G_FORMAT_SIZE_IEC_UNITS : G_FORMAT_SIZE_DEFAULT)); +} + + + /** * thunar_file_get_volume: * @file : a #ThunarFile instance. diff --git a/thunar/thunar-file.h b/thunar/thunar-file.h index f16a3e31..73000e4c 100644 --- a/thunar/thunar-file.h +++ b/thunar/thunar-file.h @@ -171,6 +171,8 @@ gchar *thunar_file_get_size_string (const ThunarFile gchar *thunar_file_get_size_in_bytes_string (const ThunarFile *file) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; gchar *thunar_file_get_size_string_formatted (const ThunarFile *file, const gboolean file_size_binary); +gchar *thunar_file_get_size_string_long (const ThunarFile *file, + const gboolean file_size_binary); GVolume *thunar_file_get_volume (const ThunarFile *file); -- 2.16.1