[Commits] [SCM] claws branch, quota-info, updated. 4.3.1-57-g39285b1b7
miras at claws-mail.org
miras at claws-mail.org
Wed Mar 12 21:00:33 UTC 2025
The branch, quota-info has been updated
via 39285b1b7042af97e9e079a242611f26dc901775 (commit)
from cea094a331ded341a3c58275c0c844549c462df9 (commit)
Summary of changes:
src/common/utils.c | 23 +++++++++++++++++++++++
src/common/utils.h | 1 +
src/summaryview.c | 14 +++++++++-----
3 files changed, 33 insertions(+), 5 deletions(-)
- Log -----------------------------------------------------------------
commit 39285b1b7042af97e9e079a242611f26dc901775
Author: Michael Rasmussen <mir at datanom.net>
Date: Wed Mar 12 22:00:25 2025 +0100
Format quota in human readable string
Signed-off-by: Michael Rasmussen <mir at datanom.net>
diff --git a/src/common/utils.c b/src/common/utils.c
index 1313c0b8b..a037fa553 100644
--- a/src/common/utils.c
+++ b/src/common/utils.c
@@ -203,6 +203,29 @@ gchar *to_human_readable(goffset size)
}
}
+/*!
+ * \brief Convert a given size in bytes in a human-readable string
+ *
+ * \param size The size expressed in bytes to convert in string
+ * \return The string that respresents the size in an human-readable way
+ */
+gchar *to_human_readable_ext (gulong bytes) {
+ char *suffix[] = {"B", "KB", "MB", "GB", "TB"};
+ char length = sizeof(suffix) / sizeof(suffix[0]);
+
+ int i = 0;
+ double dblBytes = bytes;
+
+ if (bytes > 1024) {
+ for (i = 0; (bytes / 1024) > 0 && i<length-1; i++, bytes /= 1024)
+ dblBytes = bytes / 1024.0;
+ }
+
+ gchar *output;
+ output = g_strdup_printf("%.02lf%s", dblBytes, suffix[i]);
+ return output;
+}
+
/* compare paths */
gint path_cmp(const gchar *s1, const gchar *s2)
{
diff --git a/src/common/utils.h b/src/common/utils.h
index e107805e3..1a974852b 100644
--- a/src/common/utils.h
+++ b/src/common/utils.h
@@ -288,6 +288,7 @@ gchar *itos_buf (gchar *nstr,
gint n);
gchar *itos (gint n);
gchar *to_human_readable (goffset size);
+gchar *to_human_readable_ext (gulong size);
/* alternative string functions */
gint path_cmp (const gchar *s1,
diff --git a/src/summaryview.c b/src/summaryview.c
index d1aa1710a..7a5c3f4b4 100644
--- a/src/summaryview.c
+++ b/src/summaryview.c
@@ -2792,8 +2792,10 @@ static void summary_status_show(SummaryView *summaryview)
gtk_label_set_text(GTK_LABEL(summaryview->statlabel_msgs), str);
g_free(str);
-
if (has_quota) {
+ gchar* s_size = to_human_readable_ext(size*1024);
+ gchar* s_limit = to_human_readable_ext(limit*1024);
+
tooltip = g_strdup_printf("<b>%s</b>\n"
"<b>%s</b> %d\n"
"<b>%s</b> %d\n"
@@ -2805,8 +2807,8 @@ static void summary_status_show(SummaryView *summaryview)
"<b>%s</b> %d\n"
"<b>%s</b> %d\n"
"<b>%s</b> %d\n"
- "<b>%s</b> %lu\n"
- "<b>%s</b> %lu",
+ "<b>%s</b> %s\n"
+ "<b>%s</b> %s",
_("Message summary"),
_("New:"), n_new,
_("Unread:"), n_unread,
@@ -2818,8 +2820,10 @@ static void summary_status_show(SummaryView *summaryview)
_("Locked:"), n_locked,
_("Ignored:"), n_ignored,
_("Watched:"), n_watched,
- _("Size:"), size,
- _("Limit:"), limit);
+ _("Size:"), s_size,
+ _("Limit:"), s_limit);
+ g_free(s_size);
+ g_free(s_limit);
} else {
tooltip = g_strdup_printf("<b>%s</b>\n"
"<b>%s</b> %d\n"
-----------------------------------------------------------------------
hooks/post-receive
--
Claws Mail
More information about the Commits
mailing list