]> spindle.queued.net Git - midori/commitdiff
Only show one empty speed dial shortcut at the end
authorChristian Dywan <christian@twotoasts.de>
Fri, 18 Nov 2011 21:17:39 +0000 (22:17 +0100)
committerChristian Dywan <christian@twotoasts.de>
Fri, 18 Nov 2011 21:34:56 +0000 (22:34 +0100)
And discard invalid groups automatically.

midori/midori-view.c

index 35c4af768b0c17bba1bfb8a2e4f7bc066639510f..43bf765878654117220b1c0e4927a1c723b287e3 100644 (file)
@@ -3736,14 +3736,12 @@ prepare_speed_dial_html (MidoriView* view,
         g_string_append_printf (markup,
             "<style>.cross { left: -14px }</style>");
 
-    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,
                 "<div class=\"shortcut\" id=\"s%d\"><div class=\"preview\">"
                 "<a class=\"cross\" href=\"#\" onclick='clearShortcut(\"s%d\");'></a>"
@@ -3774,18 +3773,18 @@ prepare_speed_dial_html (MidoriView* view,
             g_free (encoded);
         }
         else
-        {
-            g_string_append_printf (markup,
-                "<div class=\"shortcut\" id=\"s%d\"><div class=\"preview new\">"
-                "<a class=\"add\" href=\"#\" onclick='return getAction(\"s%d\");'></a>"
-                "</div><div class=\"title\">%s</div></div>\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,
+        "<div class=\"shortcut\" id=\"s%d\"><div class=\"preview new\">"
+        "<a class=\"add\" href=\"#\" onclick='return getAction(\"s%d\");'></a>"
+        "</div><div class=\"title\">%s</div></div>\n",
+        slot, slot, _("Click to add a shortcut"));
     g_string_append_printf (markup,
             "</div>\n</body>\n</html>\n");