diff --git a/libnemo-private/nemo-file-operations.c b/libnemo-private/nemo-file-operations.c index 6baba4e7f..73af68de0 100644 --- a/libnemo-private/nemo-file-operations.c +++ b/libnemo-private/nemo-file-operations.c @@ -848,7 +848,11 @@ custom_size_to_string (char *format, va_list va) goffset size; size = va_arg (va, goffset); - return g_format_size (size); + + int prefix; + prefix = g_settings_get_enum (nemo_preferences, NEMO_PREFERENCES_SIZE_PREFIXES); + + return g_format_size_full (size, prefix); } static void diff --git a/libnemo-private/nemo-file.c b/libnemo-private/nemo-file.c index 4a772b59d..523a23916 100644 --- a/libnemo-private/nemo-file.c +++ b/libnemo-private/nemo-file.c @@ -5844,6 +5844,7 @@ nemo_file_get_size_as_string (NemoFile *file) { guint item_count; gboolean count_unreadable; + int prefix; if (file == NULL) { return NULL; @@ -5861,7 +5862,9 @@ nemo_file_get_size_as_string (NemoFile *file) if (file->details->size == -1) { return NULL; } - return g_format_size (file->details->size); + + prefix = g_settings_get_enum (nemo_preferences, NEMO_PREFERENCES_SIZE_PREFIXES); + return g_format_size_full (file->details->size, prefix); } /** @@ -5881,6 +5884,7 @@ nemo_file_get_size_as_string_with_real_size (NemoFile *file) { guint item_count; gboolean count_unreadable; + int prefix; if (file == NULL) { return NULL; @@ -5898,8 +5902,11 @@ nemo_file_get_size_as_string_with_real_size (NemoFile *file) if (file->details->size == -1) { return NULL; } - - return g_format_size_full (file->details->size, G_FORMAT_SIZE_LONG_FORMAT); + + /* If base-2 or base-2-full, then prefix will be 2 (i.e. base-2), if base-10 or base-10-long + then prefix will be 0 (i.e. base-0). Prefix will be added to LONG_FORMAT */ + prefix = (g_settings_get_enum (nemo_preferences, NEMO_PREFERENCES_SIZE_PREFIXES) / 2) * 2; + return g_format_size_full (file->details->size, G_FORMAT_SIZE_LONG_FORMAT + prefix); } @@ -5915,6 +5922,7 @@ nemo_file_get_deep_count_as_string_internal (NemoFile *file, guint unreadable_count; guint total_count; goffset total_size; + int prefix; /* Must ask for size or some kind of count, but not both. */ g_assert (!report_size || (!report_directory_count && !report_file_count)); @@ -5959,7 +5967,8 @@ nemo_file_get_deep_count_as_string_internal (NemoFile *file, * directly if desired. */ if (report_size) { - return g_format_size (total_size); + prefix = g_settings_get_enum (nemo_preferences, NEMO_PREFERENCES_SIZE_PREFIXES); + return g_format_size_full (total_size, prefix); } return format_item_count_for_display (report_directory_count @@ -6672,6 +6681,7 @@ nemo_file_get_volume_free_space (NemoFile *file) GFile *location; char *res; time_t now; + int prefix; now = time (NULL); /* Update first time and then every 2 seconds */ @@ -6689,7 +6699,8 @@ nemo_file_get_volume_free_space (NemoFile *file) res = NULL; if (file->details->free_space != (guint64)-1) { - res = g_format_size (file->details->free_space); + prefix = g_settings_get_enum (nemo_preferences, NEMO_PREFERENCES_SIZE_PREFIXES); + res = g_format_size_full (file->details->free_space, prefix); } return res; diff --git a/libnemo-private/nemo-global-preferences.h b/libnemo-private/nemo-global-preferences.h index 1ea2cca00..608d5b17c 100644 --- a/libnemo-private/nemo-global-preferences.h +++ b/libnemo-private/nemo-global-preferences.h @@ -194,6 +194,9 @@ typedef enum /* Desktop background */ #define NEMO_PREFERENCES_SHOW_DESKTOP "show-desktop-icons" +/* File size unit prefix */ +#define NEMO_PREFERENCES_SIZE_PREFIXES "size-prefixes" + void nemo_global_preferences_init (void); char *nemo_global_preferences_get_default_folder_viewer_preference_as_iid (void); diff --git a/libnemo-private/org.nemo.gschema.xml.in b/libnemo-private/org.nemo.gschema.xml.in index c6b6dd31f..35d5e86e4 100644 --- a/libnemo-private/org.nemo.gschema.xml.in +++ b/libnemo-private/org.nemo.gschema.xml.in @@ -52,6 +52,13 @@ + + + + + + + @@ -233,6 +240,11 @@ <_summary>Bulk rename utility <_description>If set, Nemo will append URIs of selected files and treat the result as a command line for bulk renaming. Bulk rename applications can register themselves in this key by setting the key to a space-separated string of their executable name and any command line options. If the executable name is not set to a full path, it will be searched for in the search path. + + 'base-10' + <_summary>Prefixes used for file sizes + <_description>Determines whether Nemo uses base-10, base-10 long, base-2 or base-2 long file size prefixes + diff --git a/src/nemo-file-management-properties.c b/src/nemo-file-management-properties.c index 49c826bcd..5e90c5652 100644 --- a/src/nemo-file-management-properties.c +++ b/src/nemo-file-management-properties.c @@ -50,6 +50,7 @@ #define NEMO_FILE_MANAGEMENT_PROPERTIES_PREVIEW_TEXT_WIDGET "preview_text_combobox" #define NEMO_FILE_MANAGEMENT_PROPERTIES_PREVIEW_IMAGE_WIDGET "preview_image_combobox" #define NEMO_FILE_MANAGEMENT_PROPERTIES_PREVIEW_FOLDER_WIDGET "preview_folder_combobox" +#define NEMO_FILE_MANAGEMENT_PROPERTIES_SIZE_PREFIXES_WIDGET "size_prefixes_combobox" /* bool preferences */ #define NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_LOCATION_ENTRY_WIDGET "show_location_entry_checkbutton" @@ -143,6 +144,14 @@ static const char * const executable_text_values[] = { NULL }; +static const char * const size_prefixes_values[] = { + "base-10", + "base-10-full", + "base-2", + "base-2-full", + NULL +}; + static const guint64 thumbnail_limit_values[] = { 102400, 512000, @@ -814,6 +823,10 @@ nemo_file_management_properties_dialog_setup (GtkBuilder *builder, GtkWindow *wi NEMO_FILE_MANAGEMENT_PROPERTIES_PREVIEW_FOLDER_WIDGET, NEMO_PREFERENCES_SHOW_DIRECTORY_ITEM_COUNTS, (const char **) preview_values); + bind_builder_enum (builder, nemo_preferences, + NEMO_FILE_MANAGEMENT_PROPERTIES_SIZE_PREFIXES_WIDGET, + NEMO_PREFERENCES_SIZE_PREFIXES, + (const char **) size_prefixes_values); bind_builder_enum (builder, nemo_preferences, NEMO_FILE_MANAGEMENT_PROPERTIES_DATE_FORMAT_WIDGET, NEMO_PREFERENCES_DATE_FORMAT, diff --git a/src/nemo-file-management-properties.ui b/src/nemo-file-management-properties.ui index ef739264d..488c986c3 100644 --- a/src/nemo-file-management-properties.ui +++ b/src/nemo-file-management-properties.ui @@ -1160,6 +1160,84 @@ 1 + + + True + False + vertical + 6 + + + True + False + 0 + <b>File Size</b> + True + + + False + False + 0 + + + + + True + False + 12 + + + True + False + 12 + + + True + False + _Prefixes: + True + size_prefixes_combobox + + + False + False + 0 + + + + + True + False + model11 + + + + 0 + + + + + False + False + 1 + + + + + + + False + False + 1 + + + + + False + False + 2 + + 2 @@ -1834,6 +1912,26 @@ + + + + + + + + Decimal + + + Decimal (long format) + + + Binary + + + Binary (long format) + + + diff --git a/src/nemo-properties-window.c b/src/nemo-properties-window.c index 9b8fe6a29..14fd51d40 100644 --- a/src/nemo-properties-window.c +++ b/src/nemo-properties-window.c @@ -2118,7 +2118,9 @@ directory_contents_value_field_update (NemoPropertiesWindow *window) } } else { char *size_str; - size_str = g_format_size (total_size); + int prefix; + prefix = g_settings_get_enum (nemo_preferences, NEMO_PREFERENCES_SIZE_PREFIXES); + size_str = g_format_size_full (total_size, prefix); text = g_strdup_printf (ngettext("%'d item, with size %s", "%'d items, totalling %s", total_count), @@ -2878,10 +2880,12 @@ create_pie_widget (NemoPropertiesWindow *window) gchar *uri; GFile *location; GFileInfo *info; + int prefix; - capacity = g_format_size (window->details->volume_capacity); - free = g_format_size (window->details->volume_free); - used = g_format_size (window->details->volume_capacity - window->details->volume_free); + prefix = g_settings_get_enum (nemo_preferences, NEMO_PREFERENCES_SIZE_PREFIXES); + capacity = g_format_size_full (window->details->volume_capacity, prefix); + free = g_format_size_full (window->details->volume_free, prefix); + used = g_format_size_full (window->details->volume_capacity - window->details->volume_free, prefix); file = get_original_file (window); diff --git a/src/nemo-view.c b/src/nemo-view.c index 52c72930a..64b1b8de4 100644 --- a/src/nemo-view.c +++ b/src/nemo-view.c @@ -2848,8 +2848,10 @@ nemo_view_display_selection_info (NemoView *view) if (non_folder_size_known) { char *size_string; - - size_string = g_format_size (non_folder_size); + int prefix; + + prefix = g_settings_get_enum (nemo_preferences, NEMO_PREFERENCES_SIZE_PREFIXES); + size_string = g_format_size_full (non_folder_size, prefix); /* This is marked for translation in case a localiser * needs to use something other than parentheses. The * first message gives the number of items selected;