[gnome-photos] Switch to our own thumbnailing infrastructure
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos] Switch to our own thumbnailing infrastructure
- Date: Tue, 14 Feb 2017 17:54:39 +0000 (UTC)
commit f8ceb9d27184ecd03bd40a4caa7abc8a8d1272f8
Author: Debarshi Ray <debarshir gnome org>
Date: Thu Feb 9 20:32:12 2017 +0100
Switch to our own thumbnailing infrastructure
https://bugzilla.gnome.org/show_bug.cgi?id=690255
src/photos-base-item.c | 32 +++++++++++++++---------------
src/photos-facebook-item.c | 3 +-
src/photos-flickr-item.c | 3 +-
src/photos-google-item.c | 3 +-
src/photos-local-item.c | 32 +++++++++++++++++++++++++----
src/photos-media-server-item.c | 17 +++++++++++++++-
src/photos-utils.c | 42 ++++++++++++++++++++-------------------
src/photos-utils.h | 4 +++
8 files changed, 88 insertions(+), 48 deletions(-)
---
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index f50b30a..fbd1729 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -898,7 +898,7 @@ photos_base_item_thumbnail_path_info (GObject *source_object, GAsyncResult *res,
GFile *file = G_FILE (source_object);
GFileInfo *info = NULL;
- info = g_file_query_info_finish (file, res, &error);
+ info = photos_utils_file_query_info_finish (file, res, &error);
if (error != NULL)
{
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
@@ -966,13 +966,13 @@ photos_base_item_create_thumbnail_cb (GObject *source_object, GAsyncResult *res,
goto out;
}
- g_file_query_info_async (file,
- G_FILE_ATTRIBUTE_THUMBNAIL_PATH,
- G_FILE_QUERY_INFO_NONE,
- G_PRIORITY_DEFAULT,
- priv->cancellable,
- photos_base_item_thumbnail_path_info,
- self);
+ photos_utils_file_query_info_async (file,
+ G_FILE_ATTRIBUTE_THUMBNAIL_PATH,
+ G_FILE_QUERY_INFO_NONE,
+ G_PRIORITY_DEFAULT,
+ priv->cancellable,
+ photos_base_item_thumbnail_path_info,
+ self);
out:
g_object_unref (file);
@@ -988,7 +988,7 @@ photos_base_item_file_query_info (GObject *source_object, GAsyncResult *res, gpo
GFile *file = G_FILE (source_object);
GFileInfo *info = NULL;
- info = g_file_query_info_finish (file, res, &error);
+ info = photos_utils_file_query_info_finish (file, res, &error);
if (error != NULL)
{
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
@@ -2211,13 +2211,13 @@ photos_base_item_refresh_icon (PhotosBaseItem *self)
return;
file = g_file_new_for_uri (priv->uri);
- g_file_query_info_async (file,
- G_FILE_ATTRIBUTE_THUMBNAIL_PATH,
- G_FILE_QUERY_INFO_NONE,
- G_PRIORITY_DEFAULT,
- priv->cancellable,
- photos_base_item_file_query_info,
- self);
+ photos_utils_file_query_info_async (file,
+ G_FILE_ATTRIBUTE_THUMBNAIL_PATH,
+ G_FILE_QUERY_INFO_NONE,
+ G_PRIORITY_DEFAULT,
+ priv->cancellable,
+ photos_base_item_file_query_info,
+ self);
g_object_unref (file);
}
diff --git a/src/photos-facebook-item.c b/src/photos-facebook-item.c
index 34b0eef..dfd886b 100644
--- a/src/photos-facebook-item.c
+++ b/src/photos-facebook-item.c
@@ -32,7 +32,6 @@
#include <glib.h>
#include <glib/gi18n.h>
#include <goa/goa.h>
-#include <libgnome-desktop/gnome-desktop-thumbnail.h>
#include "photos-base-manager.h"
#include "photos-debug.h"
@@ -159,7 +158,7 @@ photos_facebook_item_create_thumbnail (PhotosBaseItem *item, GCancellable *cance
remote_file = g_file_new_for_uri (thumbnail_image->source);
uri = photos_base_item_get_uri (item);
- local_path = gnome_desktop_thumbnail_path_for_uri (uri, GNOME_DESKTOP_THUMBNAIL_SIZE_NORMAL);
+ local_path = photos_utils_get_thumbnail_path_for_uri (uri);
local_file = g_file_new_for_path (local_path);
local_dir = g_path_get_dirname (local_path);
diff --git a/src/photos-flickr-item.c b/src/photos-flickr-item.c
index 4e17936..b4d0a76 100644
--- a/src/photos-flickr-item.c
+++ b/src/photos-flickr-item.c
@@ -32,7 +32,6 @@
#include <glib/gi18n.h>
#include <goa/goa.h>
#include <grilo.h>
-#include <libgnome-desktop/gnome-desktop-thumbnail.h>
#include "photos-base-manager.h"
#include "photos-debug.h"
@@ -234,7 +233,7 @@ photos_flickr_item_create_thumbnail (PhotosBaseItem *item, GCancellable *cancell
remote_file = g_file_new_for_uri (thumbnail_uri);
uri = photos_base_item_get_uri (item);
- local_path = gnome_desktop_thumbnail_path_for_uri (uri, GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE);
+ local_path = photos_utils_get_thumbnail_path_for_uri (uri);
local_file = g_file_new_for_path (local_path);
local_dir = g_path_get_dirname (local_path);
diff --git a/src/photos-google-item.c b/src/photos-google-item.c
index 140fef2..116684b 100644
--- a/src/photos-google-item.c
+++ b/src/photos-google-item.c
@@ -30,7 +30,6 @@
#include <gio/gio.h>
#include <glib.h>
#include <glib/gi18n.h>
-#include <libgnome-desktop/gnome-desktop-thumbnail.h>
#include "photos-base-manager.h"
#include "photos-debug.h"
@@ -189,7 +188,7 @@ photos_google_item_create_thumbnail (PhotosBaseItem *item, GCancellable *cancell
remote_file = g_file_new_for_uri (thumbnail_uri);
uri = photos_base_item_get_uri (item);
- local_path = gnome_desktop_thumbnail_path_for_uri (uri, GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE);
+ local_path = photos_utils_get_thumbnail_path_for_uri (uri);
local_file = g_file_new_for_path (local_path);
local_dir = g_path_get_dirname (local_path);
diff --git a/src/photos-local-item.c b/src/photos-local-item.c
index e3eda5a..20b0572 100644
--- a/src/photos-local-item.c
+++ b/src/photos-local-item.c
@@ -110,24 +110,46 @@ photos_local_item_create_pipeline_path (PhotosBaseItem *item)
static gboolean
photos_local_item_create_thumbnail (PhotosBaseItem *item, GCancellable *cancellable, GError **error)
{
+ PhotosLocalItem *self = PHOTOS_LOCAL_ITEM (item);
GFile *file = NULL;
+ GQuark orientation;
gboolean ret_val = FALSE;
const gchar *mime_type;
const gchar *uri;
+ gchar *pipeline_path = NULL;
+ gchar *pipeline_uri = NULL;
+ gint64 height;
gint64 mtime;
+ gint64 width;
- uri = photos_base_item_get_uri (item);
+ uri = photos_base_item_get_uri (PHOTOS_BASE_ITEM (self));
file = g_file_new_for_uri (uri);
- mime_type = photos_base_item_get_mime_type (item);
- mtime = photos_base_item_get_mtime (item);
-
- if (!photos_utils_create_thumbnail (file, mime_type, mtime, cancellable, error))
+ mime_type = photos_base_item_get_mime_type (PHOTOS_BASE_ITEM (self));
+ mtime = photos_base_item_get_mtime (PHOTOS_BASE_ITEM (self));
+ orientation = photos_base_item_get_orientation (PHOTOS_BASE_ITEM (self));
+ height = photos_base_item_get_height (PHOTOS_BASE_ITEM (self));
+ width = photos_base_item_get_width (PHOTOS_BASE_ITEM (self));
+
+ pipeline_path = photos_local_item_get_pipeline_path (self);
+ pipeline_uri = photos_utils_convert_path_to_uri (pipeline_path);
+
+ if (!photos_utils_create_thumbnail (file,
+ mime_type,
+ mtime,
+ orientation,
+ height,
+ width,
+ pipeline_uri,
+ cancellable,
+ error))
goto out;
ret_val = TRUE;
out:
g_clear_object (&file);
+ g_free (pipeline_path);
+ g_free (pipeline_uri);
return ret_val;
}
diff --git a/src/photos-media-server-item.c b/src/photos-media-server-item.c
index 77d7e92..5051d8b 100644
--- a/src/photos-media-server-item.c
+++ b/src/photos-media-server-item.c
@@ -82,16 +82,31 @@ static gboolean
photos_media_server_item_create_thumbnail (PhotosBaseItem *item, GCancellable *cancellable, GError **error)
{
GFile *file;
+ GQuark orientation;
gboolean ret_val;
const gchar *mime_type;
const gchar *uri;
+ gint64 height;
gint64 mtime;
+ gint64 width;
uri = photos_base_item_get_uri (item);
file = g_file_new_for_uri (uri);
mime_type = photos_base_item_get_mime_type (item);
mtime = photos_base_item_get_mtime (item);
- ret_val = photos_utils_create_thumbnail (file, mime_type, mtime, cancellable, error);
+ orientation = photos_base_item_get_orientation (item);
+ height = photos_base_item_get_height (item);
+ width = photos_base_item_get_width (item);
+
+ ret_val = photos_utils_create_thumbnail (file,
+ mime_type,
+ mtime,
+ orientation,
+ height,
+ width,
+ "",
+ cancellable,
+ error);
g_object_unref (file);
return ret_val;
diff --git a/src/photos-utils.c b/src/photos-utils.c
index 7bc3fbe..3667354 100644
--- a/src/photos-utils.c
+++ b/src/photos-utils.c
@@ -32,7 +32,6 @@
#include <string.h>
#include <glib.h>
-#include <libgnome-desktop/gnome-desktop-thumbnail.h>
#include <tracker-sparql.h>
#include <libgd/gd.h>
@@ -54,6 +53,7 @@
#include "photos-share-point-google.h"
#include "photos-share-point-online.h"
#include "photos-source.h"
+#include "photos-thumbnail-factory.h"
#include "photos-tool.h"
#include "photos-tool-colors.h"
#include "photos-tool-crop.h"
@@ -399,34 +399,32 @@ gboolean
photos_utils_create_thumbnail (GFile *file,
const gchar *mime_type,
gint64 mtime,
+ GQuark orientation,
+ gint64 original_height,
+ gint64 original_width,
+ const gchar *pipeline_uri,
GCancellable *cancellable,
GError **error)
{
- GnomeDesktopThumbnailFactory *factory = NULL;
+ PhotosThumbnailFactory *factory = NULL;
gboolean ret_val = FALSE;
- gchar *uri = NULL;
- GdkPixbuf *pixbuf = NULL;
- uri = g_file_get_uri (file);
- factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE);
- pixbuf = gnome_desktop_thumbnail_factory_generate_thumbnail (factory, uri, mime_type);
- if (pixbuf == NULL)
- {
- /* FIXME: use proper #defines and enumerated types */
- g_set_error (error,
- g_quark_from_static_string ("gnome-desktop-error"),
- 0,
- "GnomeDesktopThumbnailFactory failed");
- goto out;
- }
+ factory = photos_thumbnail_factory_dup_singleton (NULL, NULL);
+ if (!photos_thumbnail_factory_generate_thumbnail (factory,
+ file,
+ mime_type,
+ orientation,
+ original_height,
+ original_width,
+ pipeline_uri,
+ cancellable,
+ error))
+ goto out;
- gnome_desktop_thumbnail_factory_save_thumbnail (factory, pixbuf, uri, (time_t) mtime);
ret_val = TRUE;
out:
- g_clear_object (&pixbuf);
g_clear_object (&factory);
- g_free (uri);
return ret_val;
}
@@ -444,7 +442,11 @@ photos_utils_get_thumbnail_icon (const gchar *uri)
file = g_file_new_for_uri (uri);
error = NULL;
- info = g_file_query_info (file, G_FILE_ATTRIBUTE_THUMBNAIL_PATH, G_FILE_QUERY_INFO_NONE, NULL, &error);
+ info = photos_utils_file_query_info (file,
+ G_FILE_ATTRIBUTE_THUMBNAIL_PATH,
+ G_FILE_QUERY_INFO_NONE,
+ NULL,
+ &error);
if (error != NULL)
{
g_warning ("Unable to fetch thumbnail path for %s: %s", uri, error->message);
diff --git a/src/photos-utils.h b/src/photos-utils.h
index e3c3faa..c872381 100644
--- a/src/photos-utils.h
+++ b/src/photos-utils.h
@@ -68,6 +68,10 @@ GIcon *photos_utils_create_symbolic_icon_for_scale (const gchar *name,
gboolean photos_utils_create_thumbnail (GFile *file,
const gchar *mime_type,
gint64 mtime,
+ GQuark orientation,
+ gint64 original_height,
+ gint64 original_width,
+ const gchar *pipeline_uri,
GCancellable *cancellable,
GError **error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]