]> spindle.queued.net Git - midori/commitdiff
Save speed dial thumbnails by uri rather than by dial id
authorPaweł Forysiuk <tuxator@o2.pl>
Fri, 8 Apr 2011 19:18:41 +0000 (21:18 +0200)
committerChristian Dywan <christian@twotoasts.de>
Sun, 10 Apr 2011 18:35:28 +0000 (20:35 +0200)
midori/main.c
midori/midori-browser.c
midori/midori-view.c

index 22db9958a1693a8f52a8c3a2b1c4cf27908b0a1f..540871449b33324fdf14a3e8bfc562c7d9b3e398 100644 (file)
@@ -1483,6 +1483,7 @@ speeddial_new_from_file (const gchar* config,
     guint rows;
     gchar* slot = NULL;
     gchar* dial_id = NULL;
+    gchar* uri = NULL;
     gchar* json_content;
     gchar** parts;
 
@@ -1525,11 +1526,12 @@ speeddial_new_from_file (const gchar* config,
                 dial_id = g_strdup_printf ("Dial %s", slot + 1);
                 slot_count++;
             }
-            else if (g_str_equal (key, "href") && (*val && strncmp (val, "#", 1)))
+            else if (g_str_equal (key, "href"))
             {
-                g_key_file_set_value (key_file, dial_id, "uri", val);
+                katze_assign (uri, g_strdup (val));
+                g_key_file_set_value (key_file, dial_id, "uri", uri);
             }
-            else if (g_str_equal (key, "img") && *val)
+            else if (g_str_equal (key, "img") && (*val && strncmp (val, "#", 1)))
             {
                 gsize sz;
                 gint state = 0;
@@ -1545,7 +1547,7 @@ speeddial_new_from_file (const gchar* config,
                                           PACKAGE_NAME, "thumbnails", NULL);
                 if (!g_file_test (thumb_dir, G_FILE_TEST_EXISTS))
                     katze_mkdir_with_parents (thumb_dir, 0700);
-                thumb_path = sokoke_build_thumbnail_path (slot);
+                thumb_path = sokoke_build_thumbnail_path (uri);
                 g_file_set_contents (thumb_path, (gchar*)decoded, sz, NULL);
 
                 g_free (decoded);
index f4251447987e66873e946cafa232645bd0b584dc..e4863ebb297e8c81f2a34520ca4f38458db1c134 100644 (file)
@@ -1174,7 +1174,7 @@ midori_browser_add_speed_dial (MidoriBrowser* browser)
         gchar* dial_id = g_strdup_printf ("Dial %s", slot_id + 1);
         gchar* config_file = g_build_filename (sokoke_set_config_dir (NULL),
                                                "speeddial", NULL);
-        gchar* file_path = sokoke_build_thumbnail_path (slot_id);
+        gchar* file_path = sokoke_build_thumbnail_path (uri);
         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);
index 11373c59fbc647ecb1a98bd3b42323058bf1f02b..0481f5c2878422691228c661eca92b175ebd9992 100644 (file)
@@ -3919,9 +3919,9 @@ prepare_speed_dial_html (MidoriView* view)
         if (g_key_file_has_group (key_file, dial_entry))
         {
             gchar* slot_id = g_strdup_printf ("s%d", slot);
-            gchar* thumb_file = sokoke_build_thumbnail_path (slot_id);
             gchar* uri = g_key_file_get_string (key_file, dial_entry, "uri", NULL);
             gchar* title = g_key_file_get_string (key_file, dial_entry, "title", NULL);
+            gchar* thumb_file = sokoke_build_thumbnail_path (uri);
             gchar* encoded;
 
             if (g_access (thumb_file, F_OK) == 0)
@@ -5585,7 +5585,7 @@ thumb_view_load_status_cb (MidoriView* thumb_view,
     GdkPixbuf* img;
     gchar* file_path;
     gchar* thumb_dir;
-    gchar* dom_id;
+    gchar* thumb_uri;
     MidoriBrowser* browser;
     gint i;
     GtkWidget* tab;
@@ -5595,8 +5595,8 @@ thumb_view_load_status_cb (MidoriView* thumb_view,
 
     gtk_widget_realize (midori_view_get_web_view (MIDORI_VIEW (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_uri = g_object_get_data (G_OBJECT (thumb_view), "thumb-uri");
+    file_path  = sokoke_build_thumbnail_path (thumb_uri);
     thumb_dir = g_build_path (G_DIR_SEPARATOR_S, g_get_user_cache_dir (),
                               PACKAGE_NAME, "thumbnails", NULL);
 
@@ -5607,7 +5607,7 @@ thumb_view_load_status_cb (MidoriView* thumb_view,
 
     g_object_unref (img);
 
-    g_free (dom_id);
+    g_free (thumb_uri);
     g_free (file_path);
     g_free (thumb_dir);
 
@@ -5671,7 +5671,7 @@ midori_view_speed_dial_get_thumb (MidoriView* view,
         "enable-plugins", FALSE, "auto-load-images", TRUE, NULL);
     _midori_view_set_settings (MIDORI_VIEW (thumb_view), settings);
 
-    g_object_set_data (G_OBJECT (thumb_view), "dom-id", dom_id);
+    g_object_set_data (G_OBJECT (thumb_view), "thumb-uri", url);
     g_signal_connect (thumb_view, "notify::load-status",
         G_CALLBACK (thumb_view_load_status_cb), view);
     midori_view_set_uri (MIDORI_VIEW (thumb_view), url);