diff --git a/c/Hotlist b/c/Hotlist index b543f28021126f9a113b334c8bf6427c48fc5b6a..6771775696202dbf1f98380e12982cb698c6950b 100644 --- a/c/Hotlist +++ b/c/Hotlist @@ -1961,12 +1961,33 @@ _kernel_oserror * hotlist_add(char * description, char * url, int at_bottom) { _kernel_oserror * e = NULL; int position; + hotlist_item * target; + int type; - position = at_bottom ? HOTLIST_POSITION_END : HOTLIST_POSITION_BEGINNING; + target = hotlist_find_selected_item(); + + if (!target) + { + position = at_bottom ? HOTLIST_POSITION_END : HOTLIST_POSITION_BEGINNING; + target = hotlist_root; + type = 1; + } + else + { + if (target->type == hl_directory) + { + position = HOTLIST_POSITION_BEGINNING; + } + else + { + position = HOTLIST_POSITION_AFTER; + } + type = 2; + } /* Add the item and ensure the window extent etc. is correct */ - e = hotlist_new_url(hotlist_root, + e = hotlist_new_url(target, position, description, url); @@ -1987,10 +2008,27 @@ _kernel_oserror * hotlist_add(char * description, char * url, int at_bottom) case HOTLIST_POSITION_BEGINNING: { - hotlist_redraw_items(0, - hotlist_count_displayed_items(hotlist_root->data.directory_content)); + if (type == 1) + { + hotlist_redraw_items(0, + hotlist_count_displayed_items(hotlist_root->data.directory_content)); + } + else + { + if (target->flags & HOTLIST_D_IS_OPEN) + { + hotlist_redraw_items(hotlist_find_no_from_item(target), + hotlist_count_displayed_items(hotlist_root->data.directory_content)); + } + } } break; + + case HOTLIST_POSITION_AFTER: + { + hotlist_redraw_items(hotlist_find_no_from_item(hotlist_newitem), + hotlist_count_displayed_items(hotlist_root->data.directory_content)); + } } if (!e) return hotlist_modified(HL_MODIFIED_ADD);