]> spindle.queued.net Git - midori/commitdiff
Check for thumbnail directory when saving thumbnail files
authorPaweł Forysiuk <tuxator@o2.pl>
Tue, 5 Apr 2011 17:52:59 +0000 (19:52 +0200)
committerChristian Dywan <christian@twotoasts.de>
Tue, 5 Apr 2011 21:52:21 +0000 (23:52 +0200)
midori/midori-browser.c
midori/midori-view.c

index ca2b5a5819c29bd6e75e8d41ed67c8d98d53ac7a..2a7f94229473ded02e3d8dd8a35a7b3f1844014d 100644 (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);
     }
index 2a5862594a9270f474f9ffc6c4a30a891631dbe8..49eb95caaf963a3157449987ccbb1636a7b47836 100644 (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);