namespace Sokoke {
extern static string js_script_eval (void* ctx, string script, void* error);
- extern static string build_thumbnail_path (string uri);
}
namespace Midori {
string uri = keyfile.get_string (tile, "uri");
if (img != null && uri[0] != '\0' && uri[0] != '#') {
uchar[] decoded = Base64.decode (img);
- FileUtils.set_data (Sokoke.build_thumbnail_path (uri), decoded);
+ FileUtils.set_data (build_thumbnail_path (uri), decoded);
}
keyfile.remove_key (tile, "img");
}
Katze.mkdir_with_parents (Path.build_path (Path.DIR_SEPARATOR_S,
Paths.get_cache_dir (), "thumbnails"), 0700);
- string filename = Sokoke.build_thumbnail_path (uri);
+ string filename = build_thumbnail_path (uri);
try {
img.save (filename, "png", null, "compression", "7", null);
}
save ();
}
+ string build_thumbnail_path (string filename) {
+ string thumbnail = Checksum.compute_for_string (ChecksumType.MD5, filename) + ".png";
+ return Path.build_filename (Paths.get_cache_dir (), "thumbnails", thumbnail);
+ }
+
public unowned string get_html (bool close_buttons_left, GLib.Object view) throws Error {
bool load_missing = true;
string uri = keyfile.get_string (tile, "uri");
if (uri != null && uri.str ("://") != null && tile.has_prefix ("Dial ")) {
string title = keyfile.get_string (tile, "title");
- string thumb_filename = Sokoke.build_thumbnail_path (uri);
+ string thumb_filename = build_thumbnail_path (uri);
uint slot = tile.substring (5, -1).to_int ();
string encoded;
try {
if (action == "delete") {
string uri = keyfile.get_string (dial_id, "uri");
- string file_path = Sokoke.build_thumbnail_path (uri);
+ string file_path = build_thumbnail_path (uri);
keyfile.remove_group (dial_id);
FileUtils.unlink (file_path);
}
gtk_clipboard_set_text (clipboard, text ? 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 (midori_paths_get_cache_dir (), "thumbnails", filename, NULL);
-
- g_free (filename);
- g_free (checksum);
- }
- return path;
-}
-
static gboolean
sokoke_entry_has_placeholder_text (GtkEntry* entry)
{