From a8ce104d86c46ae23dfbfb4af298d4b168d4bf56 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pawe=C5=82=20Forysiuk?= Date: Sat, 19 Mar 2011 19:13:47 +0100 Subject: [PATCH] Helper function for computing path to thumbnail file --- midori/sokoke.c | 18 ++++++++++++++++++ midori/sokoke.h | 3 +++ 2 files changed, 21 insertions(+) diff --git a/midori/sokoke.c b/midori/sokoke.c index 7bb38b12..8b3bd144 100644 --- a/midori/sokoke.c +++ b/midori/sokoke.c @@ -2184,3 +2184,21 @@ sokoke_widget_copy_clipboard (GtkWidget* widget, clipboard = gtk_clipboard_get_for_display (display, GDK_SELECTION_PRIMARY); gtk_clipboard_set_text (clipboard, text, -1); } + +gchar* +sokoke_build_thumbnail_path (const gchar* name) +{ + gchar* path = NULL; + if (name != NULL) + { + gchar* checksum = g_compute_checksum_for_string (G_CHECKSUM_MD5, name, -1); + gchar* filename = g_strdup_printf ("%s.png", checksum); + + path = g_build_filename (g_get_user_cache_dir (), "midori", "thumbnails", + filename, NULL); + + g_free (filename); + g_free (checksum); + } + return path; +} diff --git a/midori/sokoke.h b/midori/sokoke.h index 88137861..e76a914f 100644 --- a/midori/sokoke.h +++ b/midori/sokoke.h @@ -284,4 +284,7 @@ void sokoke_widget_copy_clipboard (GtkWidget* widget, const gchar* text); +gchar* +sokoke_build_thumbnail_path (const gchar* name); + #endif /* !__SOKOKE_H__ */ -- 2.39.5