From: Paweł Forysiuk Date: Tue, 5 Apr 2011 17:52:59 +0000 (+0200) Subject: Check for thumbnail directory when saving thumbnail files X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e314892818f2ebf291394f4fabf7d1b816ce4d98;p=midori Check for thumbnail directory when saving thumbnail files --- diff --git a/midori/midori-browser.c b/midori/midori-browser.c index ca2b5a58..2a7f9422 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -1175,11 +1175,16 @@ midori_browser_add_speed_dial (MidoriBrowser* browser) gchar* config_file = g_build_filename (sokoke_set_config_dir (NULL), "speeddial", NULL); gchar* file_path = sokoke_build_thumbnail_path (slot_id); + gchar* thumb_dir = g_build_path (G_DIR_SEPARATOR_S, g_get_user_cache_dir (), + PACKAGE_NAME, "thumbnails", NULL); g_object_get (browser, "speed-dial", &key_file, NULL); g_key_file_set_string (key_file, dial_id, "uri", uri); g_key_file_set_string (key_file, dial_id, "title", title); + if (!g_file_test (thumb_dir, G_FILE_TEST_EXISTS)) + katze_mkdir_with_parents (thumb_dir, 0700); + gdk_pixbuf_save (img, file_path, "png", NULL, "compression", "7", NULL); sokoke_key_file_save_to_file (key_file, config_file, NULL); @@ -1192,6 +1197,7 @@ midori_browser_add_speed_dial (MidoriBrowser* browser) g_object_unref (img); g_free (file_path); + g_free (thumb_dir); g_free (config_file); g_free (dial_id); } diff --git a/midori/midori-view.c b/midori/midori-view.c index 2a586259..49eb95ca 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -5573,6 +5573,7 @@ thumb_view_load_status_cb (MidoriView* thumb_view, { GdkPixbuf* img; gchar* file_path; + gchar* thumb_dir; gchar* dom_id; MidoriBrowser* browser; gint i; @@ -5585,12 +5586,19 @@ thumb_view_load_status_cb (MidoriView* thumb_view, img = midori_view_get_snapshot (MIDORI_VIEW (thumb_view), 240, 160); dom_id = g_object_get_data (G_OBJECT (thumb_view), "dom-id"); file_path = sokoke_build_thumbnail_path (dom_id); + thumb_dir = g_build_path (G_DIR_SEPARATOR_S, g_get_user_cache_dir (), + PACKAGE_NAME, "thumbnails", NULL); + + if (!g_file_test (thumb_dir, G_FILE_TEST_EXISTS)) + katze_mkdir_with_parents (thumb_dir, 0700); + gdk_pixbuf_save (img, file_path, "png", NULL, "compression", "7", NULL); g_object_unref (img); g_free (dom_id); g_free (file_path); + g_free (thumb_dir); g_signal_handlers_disconnect_by_func ( thumb_view, thumb_view_load_status_cb, view);