return (count >= 1) ? TRUE : FALSE;
}
+
+
+
+
+gchar *
+modest_text_utils_get_display_size (gint size)
+{
+ const int KB=1024;
+ const int MB=1024 * KB;
+ const int GB=1024 * MB;
+ const int TB=1024 * GB;
+ const int PB=1024 * TB;
+
+ if (size < KB)
+ return g_strdup_printf (_("%0.2f Kb"), (double)size / KB);
+ else if (size < MB)
+ return g_strdup_printf (_("%d Kb"), size / KB);
+ else if (size < GB)
+ return g_strdup_printf (_("%d Mb"), size / MB);
+ else if (size < TB)
+ return g_strdup_printf (_("%d Gb"), size/ GB);
+ else if (size < PB)
+ return g_strdup_printf (_("%d Tb"), size/ TB);
+ else
+ return g_strdup_printf (_("Very big"));
+}
/**
+ * modest_text_utils_get_display_size:
+ * @size: size in bytes
+ *
+ * get a string representation for a size in bytes.
+ *
+ * Returns: the newly allocated display string for the
+ * size in bytes. must be freed.
+ */
+gchar * modest_text_utils_get_display_size (gint size);
+
+
+/**
* modest_text_utils_validate_email_address:
* @email_address: a string
*
}
}
-
+
void
_modest_header_view_msgtype_cell_data (GtkTreeViewColumn *column, GtkCellRenderer *renderer,
GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer user_data)
gpointer user_data)
{
TnyHeaderFlags flags;
- guint size;
- gchar *size_str;
- const gchar* unit;
-
- gtk_tree_model_get (tree_model, iter,
+ guint size;
+ gchar *size_str;
+ const gchar* unit;
+
+ gtk_tree_model_get (tree_model, iter,
TNY_GTK_HEADER_LIST_MODEL_FLAGS_COLUMN, &flags,
TNY_GTK_HEADER_LIST_MODEL_MESSAGE_SIZE_COLUMN, &size,
- -1);
-
- if (size < 1024*1024) {
- unit = _("Kb");
- size /= 1024;
- } else if (size < 1024*1024*1024) {
- unit = _("Mb");
- size /= (1024*1024);
- } else {
- unit = _("Gb");
- size /= (1024*1024*1024);
- }
-
- size_str = g_strdup_printf ("%d %s", size, unit);
-
- g_object_set (G_OBJECT(renderer),
- "weight", (flags & TNY_HEADER_FLAG_SEEN) ? 400: 800,
- "style", (flags & TNY_HEADER_FLAG_DELETED) ?
- PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL,
- "text", size_str,
+ -1);
+
+ size_str = modest_text_utils_get_display_size (size);
+
+ g_object_set (G_OBJECT(renderer),
+ "weight", (flags & TNY_HEADER_FLAG_SEEN) ? 400: 800,
+ "style", (flags & TNY_HEADER_FLAG_DELETED) ?
+ PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL,
+ "text", size_str,
NULL);
g_free (size_str);