diff --git a/midori/midori-speeddial.vala b/midori/midori-speeddial.vala index 6df4191d..ac039c82 100644 --- a/midori/midori-speeddial.vala +++ b/midori/midori-speeddial.vala @@ -18,6 +18,16 @@ namespace Sokoke { } namespace Midori { + public errordomain SpeedDialError { + INVALID_MESSAGE, + NO_ACTION, + NO_ID, + NO_URL, + NO_TITLE, + NO_ID2, + INVALID_ACTION, + } + public class SpeedDial : GLib.Object { string filename; string? html = null; @@ -108,7 +118,7 @@ namespace Midori { } } - public string get_next_free_slot () { + public string get_next_free_slot (out uint count = null) { uint slot_count = 0; foreach (string tile in keyfile.get_groups ()) { try { @@ -117,14 +127,17 @@ namespace Midori { } catch (KeyFileError error) { } } + if (&count != null) + count = slot_count; uint slot = 1; while (slot <= slot_count) { string tile = "Dial %u".printf (slot); if (!keyfile.has_group (tile)) - return "Dial %u".printf (slot); + return tile; slot++; } + return "Dial %u".printf (slot_count + 1); } @@ -172,13 +185,8 @@ namespace Midori { var markup = new StringBuilder (header); uint slot_count = 1; - foreach (string tile in keyfile.get_groups ()) { - try { - if (keyfile.has_key (tile, "uri")) - slot_count++; - } - catch (KeyFileError error) { } - } + string dial_id = get_next_free_slot (out slot_count); + uint next_slot = dial_id.substring (5, -1).to_int (); /* Try to guess the best X by X grid size */ uint grid_index = 3; @@ -250,7 +258,7 @@ namespace Midori {