[frogr] Store the size of the files in FrogrPicture when loaded
- From: Mario Sanchez Prada <msanchez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [frogr] Store the size of the files in FrogrPicture when loaded
- Date: Fri, 22 Apr 2011 07:20:19 +0000 (UTC)
commit 798b0ba990ca778727eb9a663cfcd8f38ed36616
Author: Mario Sanchez Prada <msanchez igalia com>
Date: Fri Apr 22 08:24:52 2011 +0200
Store the size of the files in FrogrPicture when loaded
src/frogr-picture-loader.c | 22 ++++++++++++++++------
src/frogr-picture.c | 24 ++++++++++++++++++++++++
src/frogr-picture.h | 3 +++
3 files changed, 43 insertions(+), 6 deletions(-)
---
diff --git a/src/frogr-picture-loader.c b/src/frogr-picture-loader.c
index 6b3be9d..ffdd849 100644
--- a/src/frogr-picture-loader.c
+++ b/src/frogr-picture-loader.c
@@ -241,10 +241,14 @@ _load_next_picture_cb (GObject *object,
GFileInfo* file_info;
gchar *file_uri;
gchar *file_name;
+ guint64 filesize;
/* Gather needed information */
- file_info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
- G_FILE_QUERY_INFO_NONE, NULL, &error);
+ file_info = g_file_query_info (file,
+ G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME
+ "," G_FILE_ATTRIBUTE_STANDARD_SIZE,
+ G_FILE_QUERY_INFO_NONE,
+ NULL, &error);
if (!error)
file_name = g_strdup (g_file_info_get_display_name (file_info));
else
@@ -256,9 +260,6 @@ _load_next_picture_cb (GObject *object,
file_name = g_file_get_basename (file);
}
- if (file_info)
- g_object_unref (file_info);
-
if (priv->remove_file_extensions)
{
gchar *extension_dot;
@@ -276,7 +277,10 @@ _load_next_picture_cb (GObject *object,
/* Get (scaled) pixbuf */
s_pixbuf = _get_scaled_pixbuf (pixbuf);
- /* Build the FrogrPicture and set pixbuf */
+ /* Get the file size (in bytes) */
+ filesize = g_file_info_get_size (file_info);
+
+ /* Build the FrogrPicture */
fpicture = frogr_picture_new (file_uri,
file_name,
priv->public_visibility,
@@ -289,7 +293,13 @@ _load_next_picture_cb (GObject *object,
frogr_picture_set_pixbuf (fpicture, s_pixbuf);
+ /* FrogrPicture stores the size in KB */
+ frogr_picture_set_filesize (fpicture, filesize / 1024);
+
/* Free */
+ if (file_info)
+ g_object_unref (file_info);
+
g_object_unref (s_pixbuf);
g_free (file_uri);
g_free (file_name);
diff --git a/src/frogr-picture.c b/src/frogr-picture.c
index dda249d..caf5ec0 100644
--- a/src/frogr-picture.c
+++ b/src/frogr-picture.c
@@ -42,6 +42,8 @@ struct _FrogrPicturePrivate
gchar *tags_string;
GSList *tags_list;
+ gulong filesize; /* In KB */
+
GSList *sets;
GSList *groups;
@@ -456,6 +458,8 @@ frogr_picture_init (FrogrPicture *self)
priv->description = NULL;
priv->tags_string = NULL;
+ priv->filesize = 0;
+
priv->tags_list = NULL;
priv->sets = NULL;
priv->groups = NULL;
@@ -817,6 +821,26 @@ frogr_picture_set_pixbuf (FrogrPicture *self,
priv->pixbuf = GDK_IS_PIXBUF (pixbuf) ? g_object_ref (pixbuf) : NULL;
}
+gulong frogr_picture_get_filesize (FrogrPicture *self)
+{
+ g_return_val_if_fail(FROGR_IS_PICTURE(self), 0);
+
+ FrogrPicturePrivate *priv = NULL;
+
+ priv = FROGR_PICTURE_GET_PRIVATE (self);
+ return priv->filesize;
+}
+
+void frogr_picture_set_filesize (FrogrPicture *self, gulong filesize)
+{
+ g_return_if_fail(FROGR_IS_PICTURE(self));
+
+ FrogrPicturePrivate *priv = NULL;
+
+ priv = FROGR_PICTURE_GET_PRIVATE (self);
+ priv->filesize = filesize;
+}
+
GSList *
frogr_picture_get_sets (FrogrPicture *self)
{
diff --git a/src/frogr-picture.h b/src/frogr-picture.h
index d84561c..d6a712b 100644
--- a/src/frogr-picture.h
+++ b/src/frogr-picture.h
@@ -113,6 +113,9 @@ GdkPixbuf *frogr_picture_get_pixbuf (FrogrPicture *self);
void frogr_picture_set_pixbuf (FrogrPicture *self,
GdkPixbuf *pixbuf);
+gulong frogr_picture_get_filesize (FrogrPicture *self);
+void frogr_picture_set_filesize (FrogrPicture *self, gulong filesize);
+
GSList *frogr_picture_get_sets (FrogrPicture *self);
void frogr_picture_set_sets (FrogrPicture *self, GSList *sets);
void frogr_picture_add_set (FrogrPicture *self, FrogrPhotoSet *set);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]