#include <thunar/thunar-util.h>
#include <thunar/thunar-dialogs.h>
#include <thunar/thunar-icon-factory.h>
+#include <thunar/thunar-preferences.h>
gchar *
thunar_file_get_size_string (const ThunarFile *file)
{
+ ThunarPreferences *preferences;
+ gboolean file_size_binary;
+
_thunar_return_val_if_fail (THUNAR_IS_FILE (file), NULL);
- return g_format_size (thunar_file_get_size (file));
+
+ preferences = thunar_preferences_get ();
+ g_object_get (preferences, "misc-file-size-binary", &file_size_binary, NULL);
+ g_object_unref (preferences);
+
+ return g_format_size_full (thunar_file_get_size (file), file_size_binary ? G_FORMAT_SIZE_IEC_UNITS : G_FORMAT_SIZE_DEFAULT);
}
#include <thunar/thunar-file.h>
#include <thunar/thunar-gio-extensions.h>
+#include <thunar/thunar-preferences.h>
#include <thunar/thunar-private.h>
#include <thunar/thunar-util.h>
gchar *
thunar_g_file_get_free_space_string (GFile *file)
{
- gchar *fs_free_str;
- gchar *fs_size_str;
- guint64 fs_free;
- guint64 fs_size;
- gchar *fs_string = NULL;
+ gchar *fs_free_str;
+ gchar *fs_size_str;
+ guint64 fs_free;
+ guint64 fs_size;
+ gchar *fs_string = NULL;
+ ThunarPreferences *preferences;
+ gboolean file_size_binary;
_thunar_return_val_if_fail (G_IS_FILE (file), NULL);
+ preferences = thunar_preferences_get ();
+ g_object_get (preferences, "misc-file-size-binary", &file_size_binary, NULL);
+ g_object_unref (preferences);
+
if (thunar_g_file_get_free_space (file, &fs_free, &fs_size)
&& fs_size > 0)
{
- fs_free_str = g_format_size (fs_free);
- fs_size_str = g_format_size (fs_size);
+ fs_free_str = g_format_size_full (fs_free, file_size_binary ? G_FORMAT_SIZE_IEC_UNITS : G_FORMAT_SIZE_DEFAULT);
+ fs_size_str = g_format_size_full (fs_size, file_size_binary ? G_FORMAT_SIZE_IEC_UNITS : G_FORMAT_SIZE_DEFAULT);
/* free disk space string */
fs_string = g_strdup_printf (_("%s of %s (%d%% used)"),
fs_free_str, fs_size_str,
gint nrows;
ThunarPreferences *preferences;
gboolean show_image_size;
+ gboolean file_size_binary;
_thunar_return_val_if_fail (THUNAR_IS_LIST_MODEL (store), NULL);
+ preferences = thunar_preferences_get ();
+ g_object_get (preferences, "misc-file-size-binary", &file_size_binary, NULL);
+ g_object_unref (preferences);
+
if (selected_items == NULL)
{
/* try to determine a file for the current folder */
&& thunar_g_file_get_free_space (thunar_file_get_file (file), &size, NULL)))
{
/* humanize the free space */
- fspace_string = g_format_size (size);
+ fspace_string = g_format_size_full (size, file_size_binary ? G_FORMAT_SIZE_IEC_UNITS : G_FORMAT_SIZE_DEFAULT);
size_summary = 0;
row = g_sequence_get_begin_iter (store->rows);
if (size_summary > 0)
{
/* generate a text which includes the size of all items in the folder */
- size_string = g_format_size (size_summary);
+ size_string = g_format_size_full (size_summary, file_size_binary ? G_FORMAT_SIZE_IEC_UNITS : G_FORMAT_SIZE_DEFAULT);
text = g_strdup_printf (ngettext ("%d item (%s), Free space: %s", "%d items (%s), Free space: %s", nrows),
nrows, size_string, fspace_string);
g_free (size_string);
/* text for the items in the folder */
if (non_folder_count > 0)
{
- size_string = g_format_size (size_summary);
+ size_string = g_format_size_full (size_summary, file_size_binary ? G_FORMAT_SIZE_IEC_UNITS : G_FORMAT_SIZE_DEFAULT);
if (folder_count > 0)
{
/* item count if there are also folders in the selection */
gtk_frame_set_label_widget (GTK_FRAME (frame), label);
gtk_widget_show (label);
- table = gtk_table_new (3, 2, FALSE);
+ table = gtk_table_new (4, 3, FALSE);
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
gtk_table_set_col_spacings (GTK_TABLE (table), 12);
gtk_container_set_border_width (GTK_CONTAINER (table), 12);
gtk_table_attach (GTK_TABLE (table), button, 0, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (button);
+ button = gtk_check_button_new_with_mnemonic (_("Show file size in binary"));
+ exo_mutual_binding_new (G_OBJECT (dialog->preferences), "misc-file-size-binary", G_OBJECT (button), "active");
+ gtk_widget_set_tooltip_text (button, _("Select this option to show file size in binary format instead of decimal."));
+ gtk_table_attach (GTK_TABLE (table), button, 0, 2, 3, 4, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
+ gtk_widget_show (button);
+
frame = g_object_new (GTK_TYPE_FRAME, "border-width", 0, "shadow-type", GTK_SHADOW_NONE, NULL);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0);
gtk_widget_show (frame);
PROP_MISC_TAB_CLOSE_MIDDLE_CLICK,
PROP_MISC_TEXT_BESIDE_ICONS,
PROP_MISC_THUMBNAIL_MODE,
+ PROP_MISC_FILE_SIZE_BINARY,
PROP_SHORTCUTS_ICON_EMBLEMS,
PROP_SHORTCUTS_ICON_SIZE,
PROP_TREE_ICON_EMBLEMS,
THUNAR_THUMBNAIL_MODE_ONLY_LOCAL,
EXO_PARAM_READWRITE);
+ /**
+ * ThunarPreferences:misc-file-size-binary:
+ *
+ * Show file size in binary format instead of decimal.
+ **/
+ preferences_props[PROP_MISC_FILE_SIZE_BINARY] =
+ g_param_spec_boolean ("misc-file-size-binary",
+ "MiscFileSizeBinary",
+ NULL,
+ FALSE,
+ EXO_PARAM_READWRITE);
+
/**
* ThunarPreferences:shortcuts-icon-emblems:
*
#include <locale.h>
#endif
+#include <thunar/thunar-deep-count-job.h>
#include <thunar/thunar-gtk-extensions.h>
+#include <thunar/thunar-preferences.h>
#include <thunar/thunar-private.h>
#include <thunar/thunar-size-label.h>
-#include <thunar/thunar-deep-count-job.h>
static void
thunar_size_label_files_changed (ThunarSizeLabel *size_label)
{
- gchar *size_string;
- guint64 size;
+ gchar *size_string;
+ guint64 size;
+ ThunarPreferences *preferences;
+ gboolean file_size_binary;
_thunar_return_if_fail (THUNAR_IS_SIZE_LABEL (size_label));
_thunar_return_if_fail (size_label->files != NULL);
_thunar_return_if_fail (THUNAR_IS_FILE (size_label->files->data));
+ preferences = thunar_preferences_get ();
+ g_object_get (preferences, "misc-file-size-binary", &file_size_binary, NULL);
+ g_object_unref (preferences);
+
/* cancel the pending job (if any) */
if (G_UNLIKELY (size_label->job != NULL))
{
size = thunar_file_get_size (THUNAR_FILE (size_label->files->data));
/* setup the new label */
- size_string = g_format_size_full (size, G_FORMAT_SIZE_LONG_FORMAT);
+ size_string = g_format_size_full (size, file_size_binary ? G_FORMAT_SIZE_LONG_FORMAT | G_FORMAT_SIZE_IEC_UNITS : G_FORMAT_SIZE_LONG_FORMAT);
gtk_label_set_text (GTK_LABEL (size_label->label), size_string);
g_free (size_string);
}
guint unreadable_directory_count,
ThunarSizeLabel *size_label)
{
- gchar *size_string;
- gchar *text;
- guint n;
- gchar *unreable_text;
+ gchar *size_string;
+ gchar *text;
+ guint n;
+ gchar *unreable_text;
+ ThunarPreferences *preferences;
+ gboolean file_size_binary;
_thunar_return_if_fail (THUNAR_IS_DEEP_COUNT_JOB (job));
_thunar_return_if_fail (THUNAR_IS_SIZE_LABEL (size_label));
_thunar_return_if_fail (size_label->job == job);
+ preferences = thunar_preferences_get ();
+ g_object_get (preferences, "misc-file-size-binary", &file_size_binary, NULL);
+ g_object_unref (preferences);
+
/* determine the total number of items */
n = file_count + directory_count + unreadable_directory_count;
if (G_LIKELY (n > unreadable_directory_count))
{
/* update the label */
- size_string = g_format_size (total_size);
+ size_string = g_format_size_full (total_size, file_size_binary ? G_FORMAT_SIZE_IEC_UNITS : G_FORMAT_SIZE_DEFAULT);
text = g_strdup_printf (ngettext ("%u item, totalling %s", "%u items, totalling %s", n), n, size_string);
g_free (size_string);
#include <thunar/thunar-io-scan-directory.h>
#include <thunar/thunar-io-jobs-util.h>
#include <thunar/thunar-job.h>
+#include <thunar/thunar-preferences.h>
#include <thunar/thunar-private.h>
#include <thunar/thunar-thumbnail-cache.h>
#include <thunar/thunar-transfer-job.h>
thunar_transfer_job_veryify_destination (ThunarTransferJob *transfer_job,
GError **error)
{
- GFileInfo *filesystem_info;
- guint64 free_space;
- GFile *dest;
- GFileInfo *dest_info;
- gchar *dest_name = NULL;
- gchar *base_name;
- gboolean succeed = TRUE;
- gchar *size_string;
+ GFileInfo *filesystem_info;
+ guint64 free_space;
+ GFile *dest;
+ GFileInfo *dest_info;
+ gchar *dest_name = NULL;
+ gchar *base_name;
+ gboolean succeed = TRUE;
+ gchar *size_string;
+ ThunarPreferences *preferences;
+ gboolean file_size_binary;
_thunar_return_val_if_fail (THUNAR_IS_TRANSFER_JOB (transfer_job), FALSE);
+ preferences = thunar_preferences_get ();
+ g_object_get (preferences, "misc-file-size-binary", &file_size_binary, NULL);
+ g_object_unref (preferences);
+
/* no target file list */
if (transfer_job->target_file_list == NULL)
return TRUE;
free_space = g_file_info_get_attribute_uint64 (filesystem_info, G_FILE_ATTRIBUTE_FILESYSTEM_FREE);
if (transfer_job->total_size > free_space)
{
- size_string = g_format_size (transfer_job->total_size - free_space);
+ size_string = g_format_size_full (transfer_job->total_size - free_space, file_size_binary ? G_FORMAT_SIZE_IEC_UNITS : G_FORMAT_SIZE_DEFAULT);
succeed = thunar_job_ask_no_size (THUNAR_JOB (transfer_job),
_("Error while copying to \"%s\": %s more space is "
"required to copy to the destination"),
gchar *
thunar_transfer_job_get_status (ThunarTransferJob *job)
{
- gchar *total_size_str;
- gchar *total_progress_str;
- gchar *transfer_rate_str;
- GString *status;
- gulong remaining_time;
+ gchar *total_size_str;
+ gchar *total_progress_str;
+ gchar *transfer_rate_str;
+ GString *status;
+ gulong remaining_time;
+ ThunarPreferences *preferences;
+ gboolean file_size_binary;
_thunar_return_val_if_fail (THUNAR_IS_TRANSFER_JOB (job), NULL);
+ preferences = thunar_preferences_get ();
+ g_object_get (preferences, "misc-file-size-binary", &file_size_binary, NULL);
+ g_object_unref (preferences);
+
status = g_string_sized_new (100);
/* transfer status like "22.6MB of 134.1MB" */
- total_size_str = g_format_size (job->total_size);
- total_progress_str = g_format_size (job->total_progress);
+ total_size_str = g_format_size_full (job->total_size, file_size_binary ? G_FORMAT_SIZE_IEC_UNITS : G_FORMAT_SIZE_DEFAULT);
+ total_progress_str = g_format_size_full (job->total_progress, file_size_binary ? G_FORMAT_SIZE_IEC_UNITS : G_FORMAT_SIZE_DEFAULT);
g_string_append_printf (status, _("%s of %s"), total_progress_str, total_size_str);
g_free (total_size_str);
g_free (total_progress_str);
&& (job->last_update_time - job->start_time) > MINIMUM_TRANSFER_TIME)
{
/* remaining time based on the transfer speed */
- transfer_rate_str = g_format_size (job->transfer_rate);
+ transfer_rate_str = g_format_size_full (job->transfer_rate, file_size_binary ? G_FORMAT_SIZE_IEC_UNITS : G_FORMAT_SIZE_DEFAULT);
remaining_time = (job->total_size - job->total_progress) / job->transfer_rate;
if (remaining_time > 0)