mirror of
https://github.com/moparisthebest/hexchat
synced 2024-11-22 09:12:22 -05:00
Use glib to format filesize in dccgui
This commit is contained in:
parent
660b860ddd
commit
8a0f2b1d21
@ -103,26 +103,15 @@ static short view_mode; /* 1=download 2=upload 3=both */
|
|||||||
#define VIEW_UPLOAD 2
|
#define VIEW_UPLOAD 2
|
||||||
#define VIEW_BOTH 3
|
#define VIEW_BOTH 3
|
||||||
|
|
||||||
#define KILOBYTE 1024
|
|
||||||
#define MEGABYTE (KILOBYTE * 1024)
|
|
||||||
#define GIGABYTE (MEGABYTE * 1024)
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
proper_unit (DCC_SIZE size, char *buf, int buf_len)
|
proper_unit (DCC_SIZE size, char *buf, int buf_len)
|
||||||
{
|
{
|
||||||
if (size <= KILOBYTE)
|
gchar *formated_str = g_format_size ((guint64)size);
|
||||||
{
|
|
||||||
snprintf (buf, buf_len, "%"DCC_SFMT"B", size);
|
g_strlcpy (buf, formated_str, buf_len);
|
||||||
}
|
|
||||||
else if (size > KILOBYTE && size <= MEGABYTE)
|
g_free (formated_str);
|
||||||
{
|
|
||||||
snprintf (buf, buf_len, "%"DCC_SFMT"kB", size / KILOBYTE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
snprintf (buf, buf_len, "%.2fMB", (float)size / MEGABYTE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user