Save speed dial thumbnails by uri rather than by dial id

This commit is contained in:
Paweł Forysiuk 2011-04-08 21:18:41 +02:00 committed by Christian Dywan
parent 30d14ca320
commit 09a92c16bb
3 changed files with 13 additions and 11 deletions

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

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

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