From 1515b1e8d9aec2d74f1694476735ce5e6fbc8a46 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Fri, 18 Nov 2011 22:17:39 +0100 Subject: [PATCH] Only show one empty speed dial shortcut at the end And discard invalid groups automatically. --- midori/midori-view.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/midori/midori-view.c b/midori/midori-view.c index 35c4af76..43bf7658 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -3736,14 +3736,12 @@ prepare_speed_dial_html (MidoriView* view, g_string_append_printf (markup, ""); - while (slot <= slot_count) + for (i = 0; groups[i]; i++) { - gchar* dial_entry = g_strdup_printf ("Dial %d", slot); - gchar* uri = g_key_file_get_string (key_file, dial_entry, "uri", NULL); - - if (uri && *uri && *uri != '#') + gchar* uri = g_key_file_get_string (key_file, groups[i], "uri", NULL); + if (uri && strstr (uri, "://")) { - gchar* title = g_key_file_get_string (key_file, dial_entry, "title", NULL); + gchar* title = g_key_file_get_string (key_file, groups[i], "title", NULL); gchar* thumb_file = sokoke_build_thumbnail_path (uri); gchar* encoded; @@ -3759,10 +3757,11 @@ prepare_speed_dial_html (MidoriView* view, { encoded = g_strdup (""); if (load_missing) - midori_view_speed_dial_get_thumb (view, dial_entry, uri); + midori_view_speed_dial_get_thumb (view, groups[i], uri); } g_free (thumb_file); + slot = atoi (groups[i] + strlen ("Dial ")); g_string_append_printf (markup, "
" "" @@ -3774,18 +3773,18 @@ prepare_speed_dial_html (MidoriView* view, g_free (encoded); } else - { - g_string_append_printf (markup, - "
" - "" - "
%s
\n", - slot, slot, _("Click to add a shortcut")); - } + g_key_file_remove_group (key_file, groups[i], NULL); slot++; - g_free (dial_entry); g_free (uri); } + g_strfreev (groups); + + g_string_append_printf (markup, + "
" + "" + "
%s
\n", + slot, slot, _("Click to add a shortcut")); g_string_append_printf (markup, "
\n\n\n"); -- 2.39.5