[frogr] Check the filesize for videos is right when loading files
- From: Mario Sanchez Prada <msanchez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [frogr] Check the filesize for videos is right when loading files
- Date: Sun, 4 Nov 2012 21:47:42 +0000 (UTC)
commit 333bffa156f4b6613315bc3d0c18e0f47620041e
Author: Mario Sanchez Prada <msanchez gnome org>
Date: Sat Nov 3 19:18:52 2012 +0100
Check the filesize for videos is right when loading files
src/frogr-controller.c | 5 ++++-
src/frogr-file-loader.c | 20 +++++++++++++-------
src/frogr-file-loader.h | 2 +-
3 files changed, 18 insertions(+), 9 deletions(-)
---
diff --git a/src/frogr-controller.c b/src/frogr-controller.c
index 8e1cef3..bd94af9 100644
--- a/src/frogr-controller.c
+++ b/src/frogr-controller.c
@@ -2615,13 +2615,16 @@ frogr_controller_load_pictures (FrogrController *self,
FrogrControllerPrivate *priv = NULL;
FrogrFileLoader *loader = NULL;
gulong max_photo_filesize = G_MAXULONG;
+ gulong max_video_filesize = G_MAXULONG;
g_return_if_fail(FROGR_IS_CONTROLLER (self));
priv = FROGR_CONTROLLER_GET_PRIVATE (self);
max_photo_filesize = frogr_account_get_max_photo_filesize (priv->account);
- loader = frogr_file_loader_new (fileuris, max_photo_filesize);
+ max_video_filesize = frogr_account_get_max_video_filesize (priv->account);
+
+ loader = frogr_file_loader_new (fileuris, max_photo_filesize, max_video_filesize);
g_signal_connect (G_OBJECT (loader), "file-loaded",
G_CALLBACK (_on_file_loaded),
diff --git a/src/frogr-file-loader.c b/src/frogr-file-loader.c
index 1b486b3..35ee1f9 100644
--- a/src/frogr-file-loader.c
+++ b/src/frogr-file-loader.c
@@ -61,7 +61,8 @@ struct _FrogrFileLoaderPrivate
guint index;
guint n_files;
- gulong max_filesize;
+ gulong max_photo_size;
+ gulong max_video_size;
gboolean keep_file_extensions;
gboolean import_tags;
gboolean public_visibility;
@@ -209,6 +210,7 @@ _load_next_file_cb (GObject *object,
gchar *contents = NULL;
gsize length = 0;
gulong picture_filesize = 0;
+ gulong max_filesize = 0;
gboolean keep_going = TRUE;
self = FROGR_FILE_LOADER (data);;
@@ -375,7 +377,9 @@ _load_next_file_cb (GObject *object,
/* Check if we must interrupt the process */
picture_filesize = frogr_picture_get_filesize (fpicture);
- if (picture_filesize > priv->max_filesize)
+ max_filesize = frogr_picture_is_video (fpicture) ? priv->max_video_size : priv->max_photo_size;
+
+ if (picture_filesize > max_filesize)
{
GtkWindow *window = NULL;
gchar *msg = NULL;
@@ -383,10 +387,10 @@ _load_next_file_cb (GObject *object,
/* First %s is the title of the picture (filename of the file by
default). Second %s is the max allowed size for a picture to be
uploaded to flickr (different for free and PRO accounts). */
- msg = g_strdup_printf (_("Can't load picture %s: size of file is bigger "
+ msg = g_strdup_printf (_("Can't load file %s: size of file is bigger "
"than the maximum allowed for this account (%s)"),
frogr_picture_get_title (fpicture),
- frogr_util_get_datasize_string (priv->max_filesize));
+ frogr_util_get_datasize_string (max_filesize));
window = frogr_main_view_get_window (priv->mainview);
frogr_util_show_error_dialog (window, msg);
@@ -645,7 +649,8 @@ frogr_file_loader_init (FrogrFileLoader *self)
priv->mainview = g_object_ref (frogr_controller_get_main_view (priv->controller));
/* Initialize values from frogr configuration */
- priv->max_filesize = G_MAXULONG;
+ priv->max_photo_size = G_MAXULONG;
+ priv->max_video_size = G_MAXULONG;
priv->keep_file_extensions = frogr_config_get_keep_file_extensions (config);
priv->import_tags = frogr_config_get_import_tags_from_metadata (config);
priv->public_visibility = frogr_config_get_default_public (config);
@@ -667,7 +672,7 @@ frogr_file_loader_init (FrogrFileLoader *self)
/* Public API */
FrogrFileLoader *
-frogr_file_loader_new (GSList *file_uris, gulong max_filesize)
+frogr_file_loader_new (GSList *file_uris, gulong max_photo_size, gulong max_video_size)
{
FrogrFileLoader *self = NULL;
FrogrFileLoaderPrivate *priv = NULL;
@@ -679,7 +684,8 @@ frogr_file_loader_new (GSList *file_uris, gulong max_filesize)
priv->current = priv->file_uris;
priv->index = 0;
priv->n_files = g_slist_length (priv->file_uris);
- priv->max_filesize = max_filesize;
+ priv->max_photo_size = max_photo_size;
+ priv->max_video_size = max_video_size;
return self;
}
diff --git a/src/frogr-file-loader.h b/src/frogr-file-loader.h
index 1382873..80e59cf 100644
--- a/src/frogr-file-loader.h
+++ b/src/frogr-file-loader.h
@@ -51,7 +51,7 @@ struct _FrogrFileLoaderClass
GType frogr_file_loader_get_type(void) G_GNUC_CONST;
-FrogrFileLoader *frogr_file_loader_new (GSList *file_uris, gulong max_filesize);
+FrogrFileLoader *frogr_file_loader_new (GSList *file_uris, gulong max_photo_size, gulong max_video_size);
void frogr_file_loader_load (FrogrFileLoader *self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]