aboutsummaryrefslogtreecommitdiff
path: root/hildon/hildon-helper.c
diff options
context:
space:
mode:
authorClaudio Saavedra <csaavedra@igalia.com>2009-05-13 13:41:28 +0300
committerClaudio Saavedra <csaavedra@igalia.com>2009-05-13 13:41:28 +0300
commit49ef2e563975a0452ececf42d255033a87e63402 (patch)
treee9ea0e974b13c6ac9994d6713a17d549bf360460 /hildon/hildon-helper.c
parent8cbb6770b420188bc035fc61f5b5066202349eda (diff)
Add new file size formatting method
Based on a patch by Christian Dywan (christian@imendio.com) * doc/hildon-sections.txt: * hildon/hildon-helper.c (+hildon_format_file_size_for_display): * hildon/hildon-helper.h: New file size formatting method. * debian/changelog: * debian/control: Depend on osso-filemanager l10n package for proper localization strings.
Diffstat (limited to 'hildon/hildon-helper.c')
-rw-r--r--hildon/hildon-helper.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/hildon/hildon-helper.c b/hildon/hildon-helper.c
index cd3026d..509bf7b 100644
--- a/hildon/hildon-helper.c
+++ b/hildon/hildon-helper.c
@@ -503,6 +503,42 @@ hildon_helper_set_thumb_scrollbar (GtkScrolledWindow *win,
gtk_widget_set_name (win->vscrollbar, (thumb) ? "hildon-thumb-scrollbar" : NULL);
}
+/**
+ * hildon_format_file_size_for_display:
+ * @size: a size in bytes
+ *
+ * Formats a file size in bytes for display in applications.
+ *
+ * This function is similar to g_format_file_size_for_display() but the
+ * translations are from Maemo so might differ slightly.
+ *
+ * Since: 2.2
+ **/
+gchar *
+hildon_format_file_size_for_display (goffset size)
+{
+ #define _HFM(string) g_dgettext ("osso-filemanager", string)
+
+ if (size < 1024)
+ return g_strdup_printf (_HFM ("ckdg_va_properties_size_kb"),
+ 1);
+ else if (size < 100 * 1024)
+ return g_strdup_printf (_HFM ("ckdg_va_properties_size_1kb_99k"),
+ size / 1024);
+ else if (size < 1024 * 1024)
+ return g_strdup_printf (_HFM ("ckdg_va_properties_size_100kb_1mb"),
+ size / 1024);
+ else if (size < 10 * 1024 * 1024)
+ return g_strdup_printf (_HFM ("ckdg_va_properties_size_1mb_10mb"),
+ size / (1024.0f * 1024.0f));
+ else if (size < 1024 * 1024 * 1024)
+ return g_strdup_printf (_HFM ("ckdg_va_properties_size_10mb_1gb"),
+ size / (1024.0f * 1024.0f));
+ else
+ return g_strdup_printf (_HFM ("ckdg_va_properties_size_1gb_or_greater"),
+ size / (1024.0f * 1024.0f * 1024.0f));
+}
+