[gnome-disk-utility/udisks2-port] Use udisks_util_get_size_for_display instead of own function



commit 372e0d50b49387a2aa0e5305016e96a6fde3186e
Author: David Zeuthen <davidz redhat com>
Date:   Wed Mar 9 12:42:56 2011 -0500

    Use udisks_util_get_size_for_display instead of own function
    
    Signed-off-by: David Zeuthen <davidz redhat com>

 src/palimpsest/gduutils.c  |  135 --------------------------------------------
 src/palimpsest/gduutils.h  |    4 -
 src/palimpsest/gduwindow.c |    2 +-
 3 files changed, 1 insertions(+), 140 deletions(-)
---
diff --git a/src/palimpsest/gduutils.c b/src/palimpsest/gduutils.c
index a4e39d7..662b86a 100644
--- a/src/palimpsest/gduutils.c
+++ b/src/palimpsest/gduutils.c
@@ -25,138 +25,3 @@
 
 #include "gduutils.h"
 
-#define KILOBYTE_FACTOR 1000.0
-#define MEGABYTE_FACTOR (1000.0 * 1000.0)
-#define GIGABYTE_FACTOR (1000.0 * 1000.0 * 1000.0)
-#define TERABYTE_FACTOR (1000.0 * 1000.0 * 1000.0 * 1000.0)
-
-#define KIBIBYTE_FACTOR 1024.0
-#define MEBIBYTE_FACTOR (1024.0 * 1024.0)
-#define GIBIBYTE_FACTOR (1024.0 * 1024.0 * 1024.0)
-#define TEBIBYTE_FACTOR (1024.0 * 1024.0 * 1024.0 * 10242.0)
-
-static char *
-get_pow2_size (guint64 size)
-{
-  gchar *str;
-  gdouble displayed_size;
-  const gchar *unit;
-  guint digits;
-
-  if (size < MEBIBYTE_FACTOR)
-    {
-      displayed_size = (double) size / KIBIBYTE_FACTOR;
-      unit = "KiB";
-    }
-  else if (size < GIBIBYTE_FACTOR)
-    {
-      displayed_size = (double) size / MEBIBYTE_FACTOR;
-      unit = "MiB";
-    }
-  else if (size < TEBIBYTE_FACTOR)
-    {
-      displayed_size = (double) size / GIBIBYTE_FACTOR;
-      unit = "GiB";
-    }
-  else
-    {
-      displayed_size = (double) size / TEBIBYTE_FACTOR;
-      unit = "TiB";
-    }
-
-  if (displayed_size < 10.0)
-    digits = 1;
-  else
-    digits = 0;
-
-  str = g_strdup_printf ("%.*f %s", digits, displayed_size, unit);
-
-  return str;
-}
-
-static char *
-get_pow10_size (guint64 size)
-{
-  gchar *str;
-  gdouble displayed_size;
-  const gchar *unit;
-  guint digits;
-
-  if (size < MEGABYTE_FACTOR)
-    {
-      displayed_size = (double) size / KILOBYTE_FACTOR;
-      unit = "KB";
-    }
-  else if (size < GIGABYTE_FACTOR)
-    {
-      displayed_size = (double) size / MEGABYTE_FACTOR;
-      unit = "MB";
-    }
-  else if (size < TERABYTE_FACTOR)
-    {
-      displayed_size = (double) size / GIGABYTE_FACTOR;
-      unit = "GB";
-    }
-  else
-    {
-      displayed_size = (double) size / TERABYTE_FACTOR;
-      unit = "TB";
-    }
-
-  if (displayed_size < 10.0)
-    digits = 1;
-  else
-    digits = 0;
-
-  str = g_strdup_printf ("%.*f %s", digits, displayed_size, unit);
-
-  return str;
-}
-
-gchar *
-gdu_util_get_size_for_display (guint64 size,
-                               gboolean use_pow2,
-                               gboolean long_string)
-{
-  gchar *str;
-
-  if (long_string)
-    {
-      gchar *size_str;
-      size_str = g_strdup_printf ("%'" G_GINT64_FORMAT, size);
-      if (use_pow2)
-        {
-          gchar *pow2_str;
-          pow2_str = get_pow2_size (size);
-          /* Translators: The first %s is the size in power-of-2 units, e.g. '64 KiB'
-           * the second %s is the size as a number e.g. '65,536 bytes'
-           */
-          str = g_strdup_printf (_("%s (%s bytes)"), pow2_str, size_str);
-          g_free (pow2_str);
-        }
-      else
-        {
-          gchar *pow10_str;
-          pow10_str = get_pow10_size (size);
-          /* Translators: The first %s is the size in power-of-10 units, e.g. '100 KB'
-           * the second %s is the size as a number e.g. '100,000 bytes'
-           */
-          str = g_strdup_printf (_("%s (%s bytes)"), pow10_str, size_str);
-          g_free (pow10_str);
-        }
-
-      g_free (size_str);
-    }
-  else
-    {
-      if (use_pow2)
-        {
-          str = get_pow2_size (size);
-        }
-      else
-        {
-          str = get_pow10_size (size);
-        }
-    }
-  return str;
-}
diff --git a/src/palimpsest/gduutils.h b/src/palimpsest/gduutils.h
index c7ec490..9da0cbe 100644
--- a/src/palimpsest/gduutils.h
+++ b/src/palimpsest/gduutils.h
@@ -28,10 +28,6 @@
 
 G_BEGIN_DECLS
 
-gchar *gdu_util_get_size_for_display (guint64  size,
-                                      gboolean use_pow2,
-                                      gboolean long_string);
-
 G_END_DECLS
 
 #endif /* __GDU_UTILS_H__ */
diff --git a/src/palimpsest/gduwindow.c b/src/palimpsest/gduwindow.c
index 0826aa5..f74b776 100644
--- a/src/palimpsest/gduwindow.c
+++ b/src/palimpsest/gduwindow.c
@@ -442,7 +442,7 @@ set_size (GduWindow   *window,
           guint64      size)
 {
   gchar *s;
-  s = gdu_util_get_size_for_display (size, FALSE, TRUE);
+  s = udisks_util_get_size_for_display (size, FALSE, TRUE);
   set_string (window, label_id, s);
   g_free (s);
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]