Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion libnemo-private/nemo-file-operations.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 16 additions & 5 deletions libnemo-private/nemo-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}

/**
Expand All @@ -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;
Expand All @@ -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);
}


Expand All @@ -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));
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 */
Expand All @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions libnemo-private/nemo-global-preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 12 additions & 0 deletions libnemo-private/org.nemo.gschema.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@
<value nick="after-current-tab" value="0"/>
<value nick="end" value="1"/>
</enum>

<enum id="org.nemo.SizePrefixes">
<value value="0" nick="base-10"/>
<value value="1" nick="base-10-full"/>
<value value="2" nick="base-2"/>
<value value="3" nick="base-2-full"/>
</enum>

<schema id="org.nemo" path="/org/nemo/" gettext-domain="nemo">
<child name="preferences" schema="org.nemo.preferences"/>
Expand Down Expand Up @@ -233,6 +240,11 @@
<_summary>Bulk rename utility</_summary>
<_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.</_description>
</key>
<key name="size-prefixes" enum="org.nemo.SizePrefixes">
<default>'base-10'</default>
<_summary>Prefixes used for file sizes</_summary>
<_description>Determines whether Nemo uses base-10, base-10 long, base-2 or base-2 long file size prefixes</_description>
</key>
</schema>

<schema id="org.nemo.icon-view" path="/org/nemo/icon-view/" gettext-domain="nemo">
Expand Down
13 changes: 13 additions & 0 deletions src/nemo-file-management-properties.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
98 changes: 98 additions & 0 deletions src/nemo-file-management-properties.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,84 @@
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox" id="vbox12">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="label7">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;File Size&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment12">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="left_padding">12</property>
<child>
<object class="GtkBox" id="hbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">12</property>
<child>
<object class="GtkLabel" id="label8">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Prefixes:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">size_prefixes_combobox</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="size_prefixes_combobox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="model">model11</property>
<child>
<object class="GtkCellRendererText" id="renderer11"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="position">2</property>
Expand Down Expand Up @@ -1834,6 +1912,26 @@
</row>
</data>
</object>
<object class="GtkListStore" id="model11">
<columns>
<!-- column-name gchararray -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">Decimal</col>
</row>
<row>
<col id="0" translatable="yes">Decimal (long format)</col>
</row>
<row>
<col id="0" translatable="yes">Binary</col>
</row>
<row>
<col id="0" translatable="yes">Binary (long format)</col>
</row>
</data>
</object>
<object class="GtkListStore" id="model2">
<columns>
<!-- column-name gchararray -->
Expand Down
12 changes: 8 additions & 4 deletions src/nemo-properties-window.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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);

Expand Down
6 changes: 4 additions & 2 deletions src/nemo-view.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down