[gnome-photos/wip/rishi/import-7: 4/5] base-item, utils: Simplify code
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/import-7: 4/5] base-item, utils: Simplify code
- Date: Wed, 14 Feb 2018 19:11:43 +0000 (UTC)
commit b970cc33f625c32eca3ac886bc3138a7ea0ac611
Author: Debarshi Ray <debarshir gnome org>
Date: Wed Feb 14 19:54:33 2018 +0100
base-item, utils: Simplify code
https://gitlab.gnome.org/GNOME/gnome-photos/issues/29
src/photos-base-item.c | 25 ++++++++++++++++++++++++-
src/photos-utils.c | 33 ---------------------------------
src/photos-utils.h | 2 --
3 files changed, 24 insertions(+), 36 deletions(-)
---
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index 4beb9f1e..43d71c72 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -196,6 +196,11 @@ static GdkPixbuf *thumbnailing_icon;
static GThreadPool *create_thumbnail_pool;
static const gint PIXEL_SIZES[] = {2048, 1024};
+enum
+{
+ THUMBNAIL_GENERATION = 0
+};
+
static void photos_base_item_populate_from_cursor (PhotosBaseItem *self, TrackerSparqlCursor *cursor);
@@ -891,11 +896,29 @@ static gchar *
photos_base_item_default_create_thumbnail_path (PhotosBaseItem *self)
{
PhotosBaseItemPrivate *priv;
+ const gchar *cache_dir;
+ g_autofree gchar *filename = NULL;
+ g_autofree gchar *md5 = NULL;
gchar *path;
+ g_autofree gchar *thumbnails_subdir = NULL;
+ gint size;
priv = photos_base_item_get_instance_private (self);
- path = photos_utils_get_thumbnail_path_for_uri (priv->uri);
+ md5 = g_compute_checksum_for_string (G_CHECKSUM_MD5, priv->uri, -1);
+ filename = g_strconcat (md5, ".png", NULL);
+
+ cache_dir = g_get_user_cache_dir ();
+ size = photos_utils_get_icon_size ();
+ thumbnails_subdir = g_strdup_printf ("%d-%d", size, THUMBNAIL_GENERATION);
+
+ path = g_build_filename (cache_dir,
+ PACKAGE_TARNAME,
+ "thumbnails",
+ thumbnails_subdir,
+ filename,
+ NULL);
+
return path;
}
diff --git a/src/photos-utils.c b/src/photos-utils.c
index 1db54b7e..96abdbe8 100644
--- a/src/photos-utils.c
+++ b/src/photos-utils.c
@@ -68,11 +68,6 @@
static const gdouble EPSILON = 1e-5;
-enum
-{
- THUMBNAIL_GENERATION = 0
-};
-
GdkPixbuf *
photos_utils_center_pixbuf (GdkPixbuf *pixbuf, gint size)
@@ -1015,34 +1010,6 @@ photos_utils_get_selection_mode (void)
}
-gchar *
-photos_utils_get_thumbnail_path_for_uri (const gchar *uri)
-{
- const gchar *cache_dir;
- g_autofree gchar *filename = NULL;
- g_autofree gchar *md5 = NULL;
- gchar *path;
- g_autofree gchar *thumbnails_subdir = NULL;
- gint size;
-
- md5 = g_compute_checksum_for_string (G_CHECKSUM_MD5, uri, -1);
- filename = g_strconcat (md5, ".png", NULL);
-
- cache_dir = g_get_user_cache_dir ();
- size = photos_utils_get_icon_size ();
- thumbnails_subdir = g_strdup_printf ("%d-%d", size, THUMBNAIL_GENERATION);
-
- path = g_build_filename (cache_dir,
- PACKAGE_TARNAME,
- "thumbnails",
- thumbnails_subdir,
- filename,
- NULL);
-
- return path;
-}
-
-
GList *
photos_utils_get_urns_from_items (GList *items)
{
diff --git a/src/photos-utils.h b/src/photos-utils.h
index 53f89810..b1662451 100644
--- a/src/photos-utils.h
+++ b/src/photos-utils.h
@@ -140,8 +140,6 @@ const gchar *photos_utils_get_provider_name (PhotosBaseManager *sr
gboolean photos_utils_get_selection_mode (void);
-gchar *photos_utils_get_thumbnail_path_for_uri (const gchar *uri);
-
GList *photos_utils_get_urns_from_items (GList *items);
const gchar *photos_utils_get_version (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]