* Modified the _get_display_size method to fit with the file management specs
authorSergio Villar Senin <svillar@igalia.com>
Wed, 2 May 2007 06:46:34 +0000 (06:46 +0000)
committerSergio Villar Senin <svillar@igalia.com>
Wed, 2 May 2007 06:46:34 +0000 (06:46 +0000)
* Replaced the old display size of the details dialog by the new call

pmo-trunk-r1726

src/modest-text-utils.c
src/modest-text-utils.h
src/widgets/modest-details-dialog.c

index 4159c15..de8b38f 100644 (file)
@@ -1052,16 +1052,19 @@ modest_text_utils_get_display_size (guint size)
        const guint KB=1024;
        const guint MB=1024 * KB;
        const guint GB=1024 * MB;
        const guint KB=1024;
        const guint MB=1024 * KB;
        const guint GB=1024 * MB;
-       const guint TB=1024 * GB;
-
-       if (size < KB)
-               return g_strdup_printf (_("%0.1f 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);
+
+       g_message ("SIZE: %d",size);
+
+       if (0 < size && size < KB)
+               return g_strdup_printf (_FM("sfil_li_size_kb"), 1);
+       else if (KB <= size && size < 100 * KB)
+               return g_strdup_printf (_FM("sfil_li_size_1kb_99kb"), size / KB);
+       else if (100*KB <= size && size < MB)
+               return g_strdup_printf (_FM("sfil_li_size_100kb_1mb"), size / MB);
+       else if (MB <= size && size < 10*MB)
+               return g_strdup_printf (_FM("sfil_li_size_1mb_10mb"), size / MB);
+       else if (10*MB <= size && size < GB)
+               return g_strdup_printf (_FM("sfil_li_size_10mb_1gb"), size / MB);
        else
        else
-               return g_strdup_printf (_("Very big"));
+               return g_strdup_printf (_FM("sfil_li_size_1gb_or_greater"), size / GB); 
 }
 }
index 8b00746..80e12a0 100644 (file)
@@ -36,6 +36,8 @@
 #include <time.h>
 #include <glib.h>
 
 #include <time.h>
 #include <glib.h>
 
+#define _FM(str) dgettext("hildon-fm",str)
+
 /**
  * modest_text_utils_derived_subject:
  * @subject: a string which contains the original subject
 /**
  * modest_text_utils_derived_subject:
  * @subject: a string which contains the original subject
index 8642516..ca73139 100644 (file)
@@ -270,7 +270,8 @@ modest_details_dialog_set_folder_default (ModestDetailsDialog *self,
                                          TnyFolder *folder)
 {
        TnyFolderStats *stats;
                                          TnyFolder *folder)
 {
        TnyFolderStats *stats;
-       gchar *count, *size;
+       gchar *count, *size_s;
+       gint size;
        
        /* Set window title */
        gtk_window_set_title (GTK_WINDOW (self), _("mcen_ti_folder_properties"));
        
        /* Set window title */
        gtk_window_set_title (GTK_WINDOW (self), _("mcen_ti_folder_properties"));
@@ -279,16 +280,20 @@ modest_details_dialog_set_folder_default (ModestDetailsDialog *self,
        /* Get stats */
        stats = tny_folder_get_stats (folder);
        count = g_strdup_printf ("%d", tny_folder_stats_get_all_count (stats));
        /* Get stats */
        stats = tny_folder_get_stats (folder);
        count = g_strdup_printf ("%d", tny_folder_stats_get_all_count (stats));
-       /* FIXME: format the size */
-       size = g_strdup_printf ("%d", tny_folder_stats_get_local_size (stats));
+       /* Format the size */
+       size = tny_folder_stats_get_local_size (stats);
+       if (size <= 0)
+               size_s = g_strdup (_("mcen_va_message_properties_size_noinfo"));
+       else
+               size_s = modest_text_utils_get_display_size (size);
 
        modest_details_dialog_add_data (self, _("mcen_fi_folder_properties_foldername"), 
                                        tny_folder_get_name (folder));
        modest_details_dialog_add_data (self, _("mcen_fi_folder_properties_messages"), count);
 
        modest_details_dialog_add_data (self, _("mcen_fi_folder_properties_foldername"), 
                                        tny_folder_get_name (folder));
        modest_details_dialog_add_data (self, _("mcen_fi_folder_properties_messages"), count);
-       modest_details_dialog_add_data (self, _("mcen_fi_folder_properties_size"), size);
+       modest_details_dialog_add_data (self, _("mcen_fi_folder_properties_size"), size_s);
 
        /* Frees */
 
        /* Frees */
-       g_free (size);
+       g_free (size_s);
        g_free (count);
        g_object_unref (stats);
 }
        g_free (count);
        g_object_unref (stats);
 }