gimp r25285 - in trunk: . app/actions app/core app/dialogs app/display app/widgets libgimpbase plug-ins/uri



Author: neo
Date: Fri Mar 28 16:33:24 2008
New Revision: 25285
URL: http://svn.gnome.org/viewvc/gimp?rev=25285&view=rev

Log:
2008-03-28  Sven Neumann  <sven gimp org>

	* libgimpbase/gimpmemsize.[ch]: deprecate gimp_memsize_to_string()
	in favor of g_format_size_for_display().

	* app/actions/edit-commands.c
	* app/core/gimpimagefile.c
	* app/dialogs/image-new-dialog.c
	* app/dialogs/image-scale-dialog.c
	* app/display/gimpdisplayshell-title.c
	* app/widgets/gimpimagepropview.c
	* app/widgets/gimptemplateeditor.c
	* app/widgets/gimpthumbbox.c
	* plug-ins/uri/uri-backend-gnomevfs.c
	* plug-ins/uri/uri-backend-gvfs.c
	* plug-ins/uri/uri-backend-libcurl.c
	* plug-ins/uri/uri-backend-wget.c: use g_format_size_for_display()
	instead of gimp_memsize_to_string().


Modified:
   trunk/ChangeLog
   trunk/app/actions/edit-commands.c
   trunk/app/core/gimpimagefile.c
   trunk/app/dialogs/image-new-dialog.c
   trunk/app/dialogs/image-scale-dialog.c
   trunk/app/display/gimpdisplayshell-title.c
   trunk/app/widgets/gimpimagepropview.c
   trunk/app/widgets/gimptemplateeditor.c
   trunk/app/widgets/gimpthumbbox.c
   trunk/libgimpbase/gimpmemsize.c
   trunk/libgimpbase/gimpmemsize.h
   trunk/plug-ins/uri/uri-backend-gnomevfs.c
   trunk/plug-ins/uri/uri-backend-gvfs.c
   trunk/plug-ins/uri/uri-backend-libcurl.c
   trunk/plug-ins/uri/uri-backend-wget.c

Modified: trunk/app/actions/edit-commands.c
==============================================================================
--- trunk/app/actions/edit-commands.c	(original)
+++ trunk/app/actions/edit-commands.c	Fri Mar 28 16:33:24 2008
@@ -165,7 +165,7 @@
                                       &guisize);
   memsize += guisize;
 
-  size = gimp_memsize_to_string (memsize);
+  size = g_format_size_for_display (memsize);
 
   gimp_message_box_set_text (GIMP_MESSAGE_DIALOG (dialog)->box,
                              _("Clearing the undo history of this "

Modified: trunk/app/core/gimpimagefile.c
==============================================================================
--- trunk/app/core/gimpimagefile.c	(original)
+++ trunk/app/core/gimpimagefile.c	Fri Mar 28 16:33:24 2008
@@ -551,7 +551,7 @@
 
         if (thumbnail->image_filesize > 0)
           {
-            gchar *size = gimp_memsize_to_string (thumbnail->image_filesize);
+            gchar *size = g_format_size_for_display (thumbnail->image_filesize);
 
             if (str->len > 0)
               g_string_append_c (str, '\n');

Modified: trunk/app/dialogs/image-new-dialog.c
==============================================================================
--- trunk/app/dialogs/image-new-dialog.c	(original)
+++ trunk/app/dialogs/image-new-dialog.c	Fri Mar 28 16:33:24 2008
@@ -309,14 +309,14 @@
                     G_CALLBACK (image_new_confirm_response),
                     data);
 
-  size = gimp_memsize_to_string (data->template->initial_size);
+  size = g_format_size_for_display (data->template->initial_size);
   gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (dialog)->box,
                                      _("You are trying to create an image "
                                        "with a size of %s."), size);
   g_free (size);
 
   config = GIMP_GUI_CONFIG (data->context->gimp->config);
-  size = gimp_memsize_to_string (config->max_new_image_size);
+  size = g_format_size_for_display (config->max_new_image_size);
   gimp_message_box_set_text (GIMP_MESSAGE_DIALOG (dialog)->box,
                               _("An image of the chosen size will use more "
                                 "memory than what is configured as "

Modified: trunk/app/dialogs/image-scale-dialog.c
==============================================================================
--- trunk/app/dialogs/image-scale-dialog.c	(original)
+++ trunk/app/dialogs/image-scale-dialog.c	Fri Mar 28 16:33:24 2008
@@ -232,13 +232,13 @@
   GtkWidget *widget = image_scale_confirm_dialog (dialog);
   gchar     *size;
 
-  size = gimp_memsize_to_string (new_memsize);
+  size = g_format_size_for_display (new_memsize);
   gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (widget)->box,
                                      _("You are trying to create an image "
                                        "with a size of %s."), size);
   g_free (size);
 
-  size = gimp_memsize_to_string (max_memsize);
+  size = g_format_size_for_display (max_memsize);
   gimp_message_box_set_text (GIMP_MESSAGE_DIALOG (widget)->box,
                              _("Scaling the image to the chosen size will "
                                "make it use more memory than what is "

Modified: trunk/app/display/gimpdisplayshell-title.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-title.c	(original)
+++ trunk/app/display/gimpdisplayshell-title.c	Fri Mar 28 16:33:24 2008
@@ -303,8 +303,8 @@
                 GimpObject *object = GIMP_OBJECT (image);
                 gchar      *str;
 
-                str = gimp_memsize_to_string (gimp_object_get_memsize (object,
-                                                                       NULL));
+                str = g_format_size_for_display (gimp_object_get_memsize (object,
+                                                                          NULL));
 
                 i += print (title, title_len, i, "%s", str);
 

Modified: trunk/app/widgets/gimpimagepropview.c
==============================================================================
--- trunk/app/widgets/gimpimagepropview.c	(original)
+++ trunk/app/widgets/gimpimagepropview.c	Fri Mar 28 16:33:24 2008
@@ -309,8 +309,8 @@
 gimp_image_prop_view_label_set_memsize (GtkWidget  *label,
                                         GimpObject *object)
 {
-  gchar *str = gimp_memsize_to_string (gimp_object_get_memsize (object, NULL));
-
+  gchar *str = g_format_size_for_display (gimp_object_get_memsize (object,
+                                                                   NULL));
   gtk_label_set_text (GTK_LABEL (label), str);
   g_free (str);
 }
@@ -347,7 +347,7 @@
 
       if (g_stat (filename, &buf) == 0)
         {
-          gchar *str = gimp_memsize_to_string (buf.st_size);
+          gchar *str = g_format_size_for_display (buf.st_size);
 
           gtk_label_set_text (GTK_LABEL (label), str);
           g_free (str);
@@ -404,7 +404,7 @@
       gchar      *str;
       gchar       buf[256];
 
-      str = gimp_memsize_to_string (gimp_object_get_memsize (object, NULL));
+      str = g_format_size_for_display (gimp_object_get_memsize (object, NULL));
       g_snprintf (buf, sizeof (buf), "%d (%s)", steps, str);
       g_free (str);
 

Modified: trunk/app/widgets/gimptemplateeditor.c
==============================================================================
--- trunk/app/widgets/gimptemplateeditor.c	(original)
+++ trunk/app/widgets/gimptemplateeditor.c	Fri Mar 28 16:33:24 2008
@@ -639,7 +639,7 @@
     }
 
 #ifdef ENABLE_MEMSIZE_LABEL
-  text = gimp_memsize_to_string (template->initial_size);
+  text = g_format_size_for_display (template->initial_size);
   gtk_label_set_text (GTK_LABEL (editor->memsize_label), text);
   g_free (text);
 #endif

Modified: trunk/app/widgets/gimpthumbbox.c
==============================================================================
--- trunk/app/widgets/gimpthumbbox.c	(original)
+++ trunk/app/widgets/gimpthumbbox.c	Fri Mar 28 16:33:24 2008
@@ -724,7 +724,7 @@
               gchar *size;
               gchar *text;
 
-              size = gimp_memsize_to_string (thumb->image_filesize);
+              size = g_format_size_for_display (thumb->image_filesize);
               text = g_strdup_printf ("%s\n%s",
                                       size, _("Creating preview..."));
 

Modified: trunk/libgimpbase/gimpmemsize.c
==============================================================================
--- trunk/libgimpbase/gimpmemsize.c	(original)
+++ trunk/libgimpbase/gimpmemsize.c	Fri Mar 28 16:33:24 2008
@@ -62,7 +62,7 @@
  * Creates a string representation of a given memory size. This string
  * can be parsed by gimp_memsize_deserialize() and can thus be used in
  * config files. It should not be displayed to the user. If you need a
- * nice human-readable string please use gimp_memsize_to_string().
+ * nice human-readable string please use g_format_size_for_display().
  *
  * Return value: A newly allocated string representation of @memsize.
  *
@@ -153,77 +153,14 @@
  * gimp_memsize_to_string:
  * @memsize: A memory size in bytes.
  *
- * This function returns a human readable, translated representation
- * of the passed @memsize. Large values are displayed using a
- * reasonable memsize unit, e.g.: "345" becomes "345 Bytes", "4500"
- * becomes "4.4 KB" and so on.
+ * This function is deprecated! Use g_format_size_for_display() instead.
  *
  * Return value: A newly allocated human-readable, translated string.
  **/
 gchar *
 gimp_memsize_to_string (guint64 memsize)
 {
-#if defined _MSC_VER && (_MSC_VER < 1300)
-/* sorry, error C2520: conversion from unsigned __int64 to double not
- *                     implemented, use signed __int64
- */
-#  define CAST_DOUBLE (gdouble)(gint64)
-#else
-#  define CAST_DOUBLE (gdouble)
-#endif
-
-  if (memsize < 1024)
-    {
-      gint bytes = (gint) memsize;
-
-      return g_strdup_printf (dngettext (GETTEXT_PACKAGE "-libgimp",
-                                         "%d Byte",
-                                         "%d Bytes", bytes), bytes);
-    }
-
-  if (memsize < 1024 * 10)
-    {
-      return g_strdup_printf (_("%.2f KB"), CAST_DOUBLE memsize / 1024.0);
-    }
-  else if (memsize < 1024 * 100)
-    {
-      return g_strdup_printf (_("%.1f KB"), CAST_DOUBLE memsize / 1024.0);
-    }
-  else if (memsize < 1024 * 1024)
-    {
-      return g_strdup_printf (_("%d KB"), (gint) memsize / 1024);
-    }
-
-  memsize /= 1024;
-
-  if (memsize < 1024 * 10)
-    {
-      return g_strdup_printf (_("%.2f MB"), CAST_DOUBLE memsize / 1024.0);
-    }
-  else if (memsize < 1024 * 100)
-    {
-      return g_strdup_printf (_("%.1f MB"), CAST_DOUBLE memsize / 1024.0);
-    }
-  else if (memsize < 1024 * 1024)
-    {
-      return g_strdup_printf (_("%d MB"), (gint) memsize / 1024);
-    }
-
-  memsize /= 1024;
-
-  if (memsize < 1024 * 10)
-    {
-      return g_strdup_printf (_("%.2f GB"), CAST_DOUBLE memsize / 1024.0);
-    }
-  else if (memsize < 1024 * 100)
-    {
-      return g_strdup_printf (_("%.1f GB"), CAST_DOUBLE memsize / 1024.0);
-    }
-  else
-    {
-      return g_strdup_printf (_("%d GB"), (gint) memsize / 1024);
-    }
-#undef CAST_DOUBLE
+  return g_format_size_for_display (memsize);
 }
 
 

Modified: trunk/libgimpbase/gimpmemsize.h
==============================================================================
--- trunk/libgimpbase/gimpmemsize.h	(original)
+++ trunk/libgimpbase/gimpmemsize.h	Fri Mar 28 16:33:24 2008
@@ -36,8 +36,12 @@
 gboolean   gimp_memsize_deserialize      (const gchar *string,
                                           guint64     *memsize);
 
+#ifndef GIMP_DISABLE_DEPRECATED
+
 gchar    * gimp_memsize_to_string        (guint64      memsize) G_GNUC_MALLOC;
 
+#endif /* GIMP_DISABLE_DEPRECATED */
+
 
 /*
  * GIMP_TYPE_PARAM_MEMSIZE

Modified: trunk/plug-ins/uri/uri-backend-gnomevfs.c
==============================================================================
--- trunk/plug-ins/uri/uri-backend-gnomevfs.c	(original)
+++ trunk/plug-ins/uri/uri-backend-gnomevfs.c	Fri Mar 28 16:33:24 2008
@@ -285,7 +285,7 @@
       return FALSE;
     }
 
-  memsize = gimp_memsize_to_string (file_size);
+  memsize = g_format_size_for_display (file_size);
 
   gimp_progress_init_printf (file_size > 0 ?
                              copying_format_str : copied_format_str,
@@ -306,7 +306,7 @@
         {
           if (result != GNOME_VFS_ERROR_EOF)
             {
-              memsize = gimp_memsize_to_string (sizeof (buffer));
+              memsize = g_format_size_for_display (sizeof (buffer));
               g_set_error (error, 0, 0,
                            _("Failed to read %s from '%s': %s"),
                            memsize, src_uri,
@@ -339,7 +339,7 @@
             }
           else
             {
-              memsize = gimp_memsize_to_string (bytes_read);
+              memsize = g_format_size_for_display (bytes_read);
 
               gimp_progress_set_text_printf (copied_format_str, memsize);
               gimp_progress_pulse ();
@@ -355,7 +355,7 @@
 
       if (chunk_written < chunk_read)
         {
-          memsize = gimp_memsize_to_string (chunk_read);
+          memsize = g_format_size_for_display (chunk_read);
           g_set_error (error, 0, 0,
                        _("Failed to write %s to '%s': %s"),
                        memsize, dest_uri,

Modified: trunk/plug-ins/uri/uri-backend-gvfs.c
==============================================================================
--- trunk/plug-ins/uri/uri-backend-gvfs.c	(original)
+++ trunk/plug-ins/uri/uri-backend-gvfs.c	Fri Mar 28 16:33:24 2008
@@ -191,8 +191,8 @@
   if (total_num_bytes > 0)
     {
       const gchar *format;
-      gchar       *done  = gimp_memsize_to_string (current_num_bytes);
-      gchar       *total = gimp_memsize_to_string (total_num_bytes);
+      gchar       *done  = g_format_size_for_display (current_num_bytes);
+      gchar       *total = g_format_size_for_display (total_num_bytes);
 
       switch (progress->mode)
         {
@@ -215,7 +215,7 @@
   else
     {
       const gchar *format;
-      gchar       *done = gimp_memsize_to_string (current_num_bytes);
+      gchar       *done = g_format_size_for_display (current_num_bytes);
 
       switch (progress->mode)
         {

Modified: trunk/plug-ins/uri/uri-backend-libcurl.c
==============================================================================
--- trunk/plug-ins/uri/uri-backend-libcurl.c	(original)
+++ trunk/plug-ins/uri/uri-backend-libcurl.c	Fri Mar 28 16:33:24 2008
@@ -122,14 +122,14 @@
 
   if (dltotal > 0.0)
     {
-      memsize = gimp_memsize_to_string (dltotal);
+      memsize = g_format_size_for_display (dltotal);
       gimp_progress_set_text_printf (_("Downloading %s of image data"),
                                      memsize);
       gimp_progress_update (dlnow / dltotal);
     }
   else
     {
-      memsize = gimp_memsize_to_string (dlnow);
+      memsize = g_format_size_for_display (dlnow);
       gimp_progress_set_text_printf (_("Downloaded %s of image data"),
                                      memsize);
       gimp_progress_pulse ();

Modified: trunk/plug-ins/uri/uri-backend-wget.c
==============================================================================
--- trunk/plug-ins/uri/uri-backend-wget.c	(original)
+++ trunk/plug-ins/uri/uri-backend-wget.c	Fri Mar 28 16:33:24 2008
@@ -298,7 +298,7 @@
       /*  Start the actual download...  */
       if (size > 0)
         {
-          memsize = gimp_memsize_to_string (size);
+          memsize = g_format_size_for_display (size);
           message = g_strdup_printf (_("Downloading %s of image data"),
                                      memsize);
         }
@@ -339,7 +339,7 @@
                 }
               else
                 {
-                  memsize = gimp_memsize_to_string (kilobytes * 1024);
+                  memsize = g_format_size_for_display (kilobytes * 1024);
 
                   gimp_progress_set_text_printf
                     (_("Downloaded %s of image data"), memsize);



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