From: Paweł Forysiuk Date: Sat, 19 Mar 2011 18:13:47 +0000 (+0100) Subject: Helper function for computing path to thumbnail file X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a8ce104d86c46ae23dfbfb4af298d4b168d4bf56;p=midori Helper function for computing path to thumbnail file --- 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__ */