[gnome-photos/wip/rishi/thumbnailer: 12/12] local-item, utils: foo
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/thumbnailer: 12/12] local-item, utils: foo
- Date: Sun, 12 Feb 2017 03:25:34 +0000 (UTC)
commit 7eb5a50ea0acae98b5bebdb75d831d17c8502b16
Author: Debarshi Ray <debarshir gnome org>
Date: Thu Feb 9 20:32:12 2017 +0100
local-item, utils: foo
src/photos-local-item.c | 40 +++++++++++++++++++++++++++++++++++++++-
src/photos-utils.c | 33 +++++++++++++++------------------
src/photos-utils.h | 2 ++
3 files changed, 56 insertions(+), 19 deletions(-)
---
diff --git a/src/photos-local-item.c b/src/photos-local-item.c
index 50cee15..9d64475 100644
--- a/src/photos-local-item.c
+++ b/src/photos-local-item.c
@@ -109,24 +109,62 @@ 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);
+ GError *local_error;
GFile *file = NULL;
+ GFile *pipeline_file = NULL;
+ GQuark orientation;
gboolean ret_val = FALSE;
const gchar *mime_type;
const gchar *uri;
+ gchar *pipeline = NULL;
+ gchar *pipeline_path = NULL;
gint64 mtime;
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);
+ orientation = photos_base_item_get_orientation (item);
+
+ pipeline_path = photos_local_item_get_pipeline_path (self);
+ pipeline_file = g_file_new_for_path (pipeline_path);
- if (!photos_utils_create_thumbnail (file, mime_type, mtime, cancellable, error))
+ local_error = NULL;
+ if (!g_file_load_contents (pipeline_path, cancellable, &pipeline, NULL, NULL, &local_error))
+ {
+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
+ {
+ g_error_free (local_error);
+ goto carry_on;
+ }
+ else
+ {
+ goto out;
+ }
+ }
+
+ carry_on:
+ if (pipeline == NULL)
+ pipeline = g_strdup ("<?xml version='1.0' encoding='UTF-8'?><gegl></gegl>");
+
+ local_error = NULL;
+ if (!photos_utils_create_thumbnail (file, mime_type, mtime, orientation, pipeline, cancellable,
&local_error))
goto out;
ret_val = TRUE;
out:
+ if (!ret_val)
+ {
+ g_assert_nonnull (local_error);
+ g_propagate_error (error, local_error);
+ }
+
g_clear_object (&file);
+ g_clear_object (&pipeline_file);
+ g_free (pipeline);
+ g_free (pipeline_path);
return ret_val;
}
diff --git a/src/photos-utils.c b/src/photos-utils.c
index 34a7375..ca66dc4 100644
--- a/src/photos-utils.c
+++ b/src/photos-utils.c
@@ -55,12 +55,14 @@
#include "photos-operation-jpg-guess-sizes.h"
#include "photos-operation-png-guess-sizes.h"
#include "photos-operation-saturation.h"
+#include "photos-quarks.h"
#include "photos-query.h"
#include "photos-share-point.h"
#include "photos-share-point-email.h"
#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"
@@ -426,34 +428,29 @@ gboolean
photos_utils_create_thumbnail (GFile *file,
const gchar *mime_type,
gint64 mtime,
+ GQuark orientation,
+ const gchar *pipeline,
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,
+ pipeline,
+ cancellable,
+ error))
+ goto out;
- gnome_desktop_thumbnail_factory_save_thumbnail (factory, pixbuf, uri, (time_t) mtime);
+ //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;
}
diff --git a/src/photos-utils.h b/src/photos-utils.h
index 4c5393e..73dc1ca 100644
--- a/src/photos-utils.h
+++ b/src/photos-utils.h
@@ -73,6 +73,8 @@ 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,
+ const gchar *pipeline,
GCancellable *cancellable,
GError **error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]