Check for thumbnail directory when saving thumbnail files

This commit is contained in:
Paweł Forysiuk 2011-04-05 19:52:59 +02:00 committed by Christian Dywan
parent f179d41cff
commit e314892818
2 changed files with 14 additions and 0 deletions

View file

@ -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);
}

View file

@ -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);