[gimp] Bug 703065 - Jpeg file size preview error is back
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 703065 - Jpeg file size preview error is back
- Date: Fri, 4 Oct 2013 22:14:45 +0000 (UTC)
commit 1f21a28770a548423467d93d85ac514c39e97884
Author: Michael Natterer <mitch gimp org>
Date: Sat Oct 5 00:14:14 2013 +0200
Bug 703065 - Jpeg file size preview error is back
Use GIO to get the file size.
plug-ins/file-jpeg/jpeg-save.c | 49 +++++++++++++++++++++++++++++----------
1 files changed, 36 insertions(+), 13 deletions(-)
---
diff --git a/plug-ins/file-jpeg/jpeg-save.c b/plug-ins/file-jpeg/jpeg-save.c
index 2ec4286..f8547ee 100644
--- a/plug-ins/file-jpeg/jpeg-save.c
+++ b/plug-ins/file-jpeg/jpeg-save.c
@@ -191,19 +191,42 @@ background_jpeg_save (PreviewPersistent *pp)
/* display the preview stuff */
if (!pp->abort_me)
{
- struct stat buf;
- gchar *text;
- gchar *size_text;
+ GFile *file = g_file_new_for_path (pp->file_name);
- g_stat (pp->file_name, &buf);
-
- size_text = g_format_size (buf.st_size);
- text = g_strdup_printf (_("File size: %s"), size_text);
-
- gtk_label_set_text (GTK_LABEL (preview_size), text);
-
- g_free (text);
- g_free (size_text);
+ if (file)
+ {
+ GFileInfo *info = g_file_query_info (file,
+ G_FILE_ATTRIBUTE_STANDARD_SIZE,
+ G_FILE_QUERY_INFO_NONE,
+ NULL, NULL);
+
+ if (info)
+ {
+ goffset size = g_file_info_get_size (info);
+ gchar *size_text;
+ gchar *text;
+
+ size_text = g_format_size (size);
+ text = g_strdup_printf (_("File size: %s"), size_text);
+ gtk_label_set_text (GTK_LABEL (preview_size), text);
+ g_free (text);
+ g_free (size_text);
+
+ g_object_unref (info);
+ }
+ else
+ {
+ gtk_label_set_text (GTK_LABEL (preview_size),
+ _("File size: unknown"));
+ }
+
+ g_object_unref (file);
+ }
+ else
+ {
+ gtk_label_set_text (GTK_LABEL (preview_size),
+ _("File size: unknown"));
+ }
/* and load the preview */
load_image (pp->file_name, GIMP_RUN_NONINTERACTIVE, TRUE, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]