Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Sun, 29 Oct 2023 19:32:37 UTC Commit: eef67ecc200a6cf07f277c28282facf9854cd2ea https://github.com/geany/geany/commit/eef67ecc200a6cf07f277c28282facf9854cd2...
Log Message: ----------- Merge pull request #3657 from b4n/format-size
Replace utils_make_human_readable_str() with g_format_size()
Modified Paths: -------------- src/dialogs.c src/utils.c src/utils.h
Modified: src/dialogs.c 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -1195,7 +1195,7 @@ void dialogs_show_file_properties(GeanyDocument *doc) gtk_label_set_text(GTK_LABEL(label), doc->file_type->title);
label = ui_lookup_widget(dialog, "file_size_label"); - file_size = utils_make_human_readable_str(filesize, 1, 0); + file_size = g_format_size(filesize); gtk_label_set_text(GTK_LABEL(label), file_size); g_free(file_size);
Modified: src/utils.c 49 lines changed, 0 insertions(+), 49 deletions(-) =================================================================== @@ -948,55 +948,6 @@ void utils_beep(void) }
-/* taken from busybox, thanks */ -gchar *utils_make_human_readable_str(guint64 size, gulong block_size, - gulong display_unit) -{ - /* The code will adjust for additional (appended) units. */ - static const gchar zero_and_units[] = { '0', 0, 'K', 'M', 'G', 'T' }; - static const gchar fmt[] = "%Lu %c%c"; - static const gchar fmt_tenths[] = "%Lu.%d %c%c"; - - guint64 val; - gint frac; - const gchar *u; - const gchar *f; - - u = zero_and_units; - f = fmt; - frac = 0; - - val = size * block_size; - if (val == 0) - return g_strdup(u); - - if (display_unit) - { - val += display_unit/2; /* Deal with rounding. */ - val /= display_unit; /* Don't combine with the line above!!! */ - } - else - { - ++u; - while ((val >= 1024) && (u < zero_and_units + sizeof(zero_and_units) - 1)) - { - f = fmt_tenths; - ++u; - frac = ((((gint)(val % 1024)) * 10) + (1024 / 2)) / 1024; - val /= 1024; - } - if (frac >= 10) - { /* We need to round up here. */ - ++val; - frac = 0; - } - } - - /* If f==fmt then 'frac' and 'u' are ignored. */ - return g_strdup_printf(f, val, frac, *u, 'b'); -} - - /* converts a color representation using gdk_color_parse(), with additional * support of the "0x" prefix as a synonym for "#" */ gboolean utils_parse_color(const gchar *spec, GdkColor *color)
Modified: src/utils.h 3 lines changed, 0 insertions(+), 3 deletions(-) =================================================================== @@ -281,9 +281,6 @@ gchar *utils_get_current_file_dir_utf8(void);
void utils_beep(void);
-gchar *utils_make_human_readable_str(guint64 size, gulong block_size, - gulong display_unit); - gboolean utils_parse_color(const gchar *spec, GdkColor *color);
gint utils_color_to_bgr(const GdkColor *color);
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).