Commit fc93cc19 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

deprecate gimp_memsize_to_string() in favor of

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().

svn path=/trunk/; revision=25285
parent 3f18f32c
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().
2008-03-28 Sven Neumann <sven@gimp.org>
* configure.in: put GIO check back in as we need it to initialize
......
......@@ -165,7 +165,7 @@ edit_undo_clear_cmd_callback (GtkAction *action,
&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 "
......
......@@ -551,7 +551,7 @@ gimp_imagefile_get_desc_string (GimpImagefile *imagefile)
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');
......
......@@ -309,14 +309,14 @@ image_new_confirm_dialog (ImageNewDialog *data)
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 "
......
......@@ -232,13 +232,13 @@ image_scale_confirm_large (ImageScaleDialog *dialog,
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 "
......
......@@ -303,8 +303,8 @@ gimp_display_shell_format_title (GimpDisplayShell *shell,
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);
......
......@@ -309,8 +309,8 @@ static void
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 @@ gimp_image_prop_view_label_set_filesize (GtkWidget *label,
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 @@ gimp_image_prop_view_label_set_undo (GtkWidget *label,
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);
......
......@@ -639,7 +639,7 @@ gimp_template_editor_template_notify (GimpTemplate *template,
}
#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
......
......@@ -724,7 +724,7 @@ gimp_thumb_box_auto_thumbnail (GimpThumbBox *box)
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..."));
......
......@@ -62,7 +62,7 @@ gimp_memsize_get_type (void)
* 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_deserialize (const gchar *string,
* 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);
}
......
......@@ -36,8 +36,12 @@ gchar * gimp_memsize_serialize (guint64 memsize) G_GNUC_MALLOC;
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
......
......@@ -285,7 +285,7 @@ copy_uri (const gchar *src_uri,
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 @@ copy_uri (const gchar *src_uri,
{
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 @@ copy_uri (const gchar *src_uri,
}
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 @@ copy_uri (const gchar *src_uri,
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,
......
......@@ -191,8 +191,8 @@ uri_progress_callback (goffset current_num_bytes,
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 @@ uri_progress_callback (goffset current_num_bytes,
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)
{
......
......@@ -122,14 +122,14 @@ progress_callback (void *clientp,
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 ();
......
......@@ -298,7 +298,7 @@ uri_backend_load_image (const gchar *uri,
/* 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 @@ uri_backend_load_image (const gchar *uri,
}
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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment