[gnome-photos/wip/rishi/thumbnailer: 10/16] Add some thumbnailing related utilities
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/thumbnailer: 10/16] Add some thumbnailing related utilities
- Date: Mon, 13 Feb 2017 23:32:00 +0000 (UTC)
commit ebecc34bf47c644f0c490f5d0ca7b266a2a518ad
Author: Debarshi Ray <debarshir gnome org>
Date: Mon Feb 13 18:43:39 2017 +0100
Add some thumbnailing related utilities
src/photos-glib.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++
src/photos-glib.h | 12 +++++++++++
2 files changed, 67 insertions(+), 0 deletions(-)
---
diff --git a/src/photos-glib.c b/src/photos-glib.c
index ed634c7..8fa5644 100644
--- a/src/photos-glib.c
+++ b/src/photos-glib.c
@@ -39,6 +39,11 @@ struct _PhotosGLibFileCreateData
guint count;
};
+enum
+{
+ THUMBNAIL_GENERATION = 0
+};
+
gboolean
photos_glib_app_info_launch_uri (GAppInfo *appinfo,
@@ -251,6 +256,24 @@ photos_glib_file_create_finish (GFile *file, GAsyncResult *res, GFile **out_uniq
}
+void
+photos_glib_file_query_info_async (GFile *file,
+ const gchar *attributes,
+ GFileQueryInfoFlags flags,
+ gint io_priority,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+}
+
+
+GFileInfo *
+photos_glib_file_query_info_finish (GFile *file, GAsyncResult *res, GError **error)
+{
+}
+
+
gchar *
photos_glib_filename_strip_extension (const gchar *filename_with_extension)
{
@@ -270,6 +293,38 @@ photos_glib_filename_strip_extension (const gchar *filename_with_extension)
}
+gchar *
+photos_glib_get_thumbnail_path_for_file (GFile *file, gint size)
+{
+ const gchar *cache_dir;
+ gchar *filename = NULL;
+ gchar *md5 = NULL;
+ gchar *path;
+ gchar *uri = NULL;
+ gchar *thumbnails_subdir = NULL;
+
+ uri = g_file_get_uri (file);
+ md5 = g_compute_checksum_for_string (G_CHECKSUM_MD5, uri, -1);
+ filename = g_strconcat (md5, ".png", NULL);
+
+ cache_dir = g_get_user_cache_dir ();
+ thumbnails_subdir = g_strdup_printf ("%d-%d", size, THUMBNAIL_GENERATION);
+
+ path = g_build_filename (cache_dir,
+ PACKAGE_TARNAME,
+ "thumbnails",
+ thumbnails_subdir,
+ filename,
+ NULL);
+
+ g_free (filename);
+ g_free (md5);
+ g_free (thumbnails_subdir);
+ g_free (uri);
+ return path;
+}
+
+
gboolean
photos_glib_make_directory_with_parents (GFile *file, GCancellable *cancellable, GError **error)
{
diff --git a/src/photos-glib.h b/src/photos-glib.h
index afb85fa..4ce7e5a 100644
--- a/src/photos-glib.h
+++ b/src/photos-glib.h
@@ -42,8 +42,20 @@ GFileOutputStream *photos_glib_file_create_finish (GFile *file,
GFile **out_unique_file,
GError **error);
+void photos_glib_file_query_info_async (GFile *file,
+ const gchar *attributes,
+ GFileQueryInfoFlags flags,
+ gint io_priority,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+GFileInfo *photos_glib_file_query_info_finish (GFile *file, GAsyncResult *res, GError
**error);
+
gchar *photos_glib_filename_strip_extension (const gchar *filename_with_extension);
+gchar *photos_glib_get_thumbnail_path_for_file (GFile *file, gint size);
+
gboolean photos_glib_make_directory_with_parents (GFile *file,
GCancellable *cancellable,
GError **error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]