diff --git a/src/bin/e_fm_device.c b/src/bin/e_fm_device.c index 44a63a754..95f702806 100644 --- a/src/bin/e_fm_device.c +++ b/src/bin/e_fm_device.c @@ -2,11 +2,6 @@ #include "e_fm_shared_codec.h" #include "e_fm_shared_device.h" -#define TEBIBYTE_SIZE 1099511627776LL -#define GIBIBYTE_SIZE 1073741824 -#define MEBIBYTE_SIZE 1048576 -#define KIBIBYTE_SIZE 1024 - static void _e_fm2_volume_write(E_Volume *v) EINA_ARG_NONNULL(1); static void _e_fm2_volume_erase(E_Volume *v) EINA_ARG_NONNULL(1); static void _e_fm2_device_mount_free(E_Fm2_Mount *m) EINA_ARG_NONNULL(1); @@ -22,24 +17,13 @@ static void _e_fm2_device_volume_setup(E_Volume *v) { char label[1024] = {0}; - char size[256] = {0}; + char *size = NULL; const char *icon = NULL; unsigned long long sz; /* Compute the size in a readable form */ if (v->size) - { - if ((sz = (v->size / TEBIBYTE_SIZE)) > 0) - snprintf(size, sizeof(size) - 1, _("%llu TiB"), sz); - else if ((sz = (v->size / GIBIBYTE_SIZE)) > 0) - snprintf(size, sizeof(size) - 1, _("%llu GiB"), sz); - else if ((sz = (v->size / MEBIBYTE_SIZE)) > 0) - snprintf(size, sizeof(size) - 1, _("%llu MiB"), sz); - else if ((sz = (v->size / KIBIBYTE_SIZE)) > 0) - snprintf(size, sizeof(size) - 1, _("%llu KiB"), sz); - else - snprintf(size, sizeof(size) - 1, _("%llu B"), v->size); - } + size = e_util_size_string_get(v->size); /* Choose the label */ if ((v->label) && (v->label[0])) @@ -108,6 +92,8 @@ _e_fm2_device_volume_setup(E_Volume *v) strcmp(v->mount_point, "/home") && strcmp(v->mount_point, "/tmp"))) _e_fm2_volume_write(v); + + E_FREE(size); } EAPI void @@ -341,11 +327,6 @@ _e_fm2_volume_write(E_Volume *v) } } -#undef TEBIBYTE_SIZE -#undef GIBIBYTE_SIZE -#undef MEBIBYTE_SIZE -#undef KIBIBYTE_SIZE - static void _e_fm2_volume_erase(E_Volume *v) { diff --git a/src/bin/e_utils.c b/src/bin/e_utils.c index fb454152b..401cf4818 100644 --- a/src/bin/e_utils.c +++ b/src/bin/e_utils.c @@ -897,19 +897,24 @@ e_util_size_string_get(off_t size) char buf[256]; dsize = (double)size; - if (dsize < 1024.0) snprintf(buf, sizeof(buf), _("%'.0f Bytes"), dsize); + if (dsize < 1024.0) snprintf(buf, sizeof(buf), _("%'.0f bytes"), dsize); else { dsize /= 1024.0; - if (dsize < 1024) snprintf(buf, sizeof(buf), _("%'.0f KB"), dsize); + if (dsize < 1024) snprintf(buf, sizeof(buf), _("%'.0f KiB"), dsize); else { dsize /= 1024.0; - if (dsize < 1024) snprintf(buf, sizeof(buf), _("%'.0f MB"), dsize); + if (dsize < 1024) snprintf(buf, sizeof(buf), _("%'.1f MiB"), dsize); else { dsize /= 1024.0; - snprintf(buf, sizeof(buf), _("%'.1f GB"), dsize); + if (dsize < 1024) snprintf(buf, sizeof(buf), _("%'.1f GiB"), dsize); + else + { + dsize /= 1024.0; + snprintf(buf, sizeof(buf), _("%'.1f TiB"), dsize); + } } } } diff --git a/src/modules/conf_performance/e_int_config_performance.c b/src/modules/conf_performance/e_int_config_performance.c index 2ba51d95e..4d2d8d38e 100644 --- a/src/modules/conf_performance/e_int_config_performance.c +++ b/src/modules/conf_performance/e_int_config_performance.c @@ -124,13 +124,13 @@ _basic_create(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dialog_Data ob = e_widget_label_add(evas, _("Font cache size")); e_widget_list_object_append(ol, ob, 1, 1, 0.5); - ob = e_widget_slider_add(evas, 1, 0, _("%1.1f MB"), 0, 4, 0.1, 0, + ob = e_widget_slider_add(evas, 1, 0, _("%1.1f MiB"), 0, 4, 0.1, 0, &(cfdata->font_cache), NULL, 100); e_widget_list_object_append(ol, ob, 1, 0, 0.5); ob = e_widget_label_add(evas, _("Image cache size")); e_widget_list_object_append(ol, ob, 1, 1, 0.5); - ob = e_widget_slider_add(evas, 1, 0, _("%1.0f MB"), 0, 32, 1, 0, + ob = e_widget_slider_add(evas, 1, 0, _("%1.0f MiB"), 0, 32, 1, 0, &(cfdata->image_cache), NULL, 100); e_widget_list_object_append(ol, ob, 1, 0, 0.5); diff --git a/src/modules/shot/e_mod_main.c b/src/modules/shot/e_mod_main.c index e8be3941b..4790e6463 100644 --- a/src/modules/shot/e_mod_main.c +++ b/src/modules/shot/e_mod_main.c @@ -337,11 +337,15 @@ _upload_progress_cb(void *data __UNUSED__, int ev_type __UNUSED__, void *event) if (o_label) { char buf[1024]; - + char *buf_now, *buf_total; + + buf_now = e_util_size_string_get(ev->up.now); + buf_total = e_util_size_string_get(ev->up.total); snprintf(buf, sizeof(buf), - "Uploaded %1.1fKB / %1.1fKB", - ev->up.now / 1024, - ev->up.total / 1024); + _("Uploaded %s / %s"), + buf_now, buf_total); + E_FREE(buf_now); + E_FREE(buf_total); e_widget_label_text_set(o_label, buf); } return EINA_FALSE;