Commit 5b80a0e6 authored by Cosimo Cecchi's avatar Cosimo Cecchi

Add a method to move bookmarks in the list.

So that moving a bookmark in the list doesn't trigger two
'contents-changed' signals in a row.
parent c87d0252
......@@ -316,6 +316,41 @@ nautilus_bookmark_list_delete_item_at (NautilusBookmarkList *bookmarks,
nautilus_bookmark_list_contents_changed (bookmarks);
}
/**
* nautilus_bookmark_list_move_item:
*
* Move the item from the given position to the destination.
* @index: the index of the first bookmark.
* @destination: the index of the second bookmark.
**/
void
nautilus_bookmark_list_move_item (NautilusBookmarkList *bookmarks,
guint index,
guint destination)
{
GList *bookmark_item;
if (index == destination) {
return;
}
bookmark_item = g_list_nth (bookmarks->list, index);
bookmarks->list = g_list_remove_link (bookmarks->list,
bookmark_item);
if (index < destination) {
bookmarks->list = g_list_insert (bookmarks->list,
bookmark_item->data,
destination - 1);
} else {
bookmarks->list = g_list_insert (bookmarks->list,
bookmark_item->data,
destination);
}
nautilus_bookmark_list_contents_changed (bookmarks);
}
/**
* nautilus_bookmark_list_delete_items_with_uri:
*
......
......@@ -74,6 +74,9 @@ void nautilus_bookmark_list_insert_item (NautilusBook
guint nautilus_bookmark_list_length (NautilusBookmarkList *bookmarks);
NautilusBookmark * nautilus_bookmark_list_item_at (NautilusBookmarkList *bookmarks,
guint index);
void nautilus_bookmark_list_move_item (NautilusBookmarkList *bookmarks,
guint index,
guint destination);
void nautilus_bookmark_list_set_window_geometry (NautilusBookmarkList *bookmarks,
const char *geometry);
const char * nautilus_bookmark_list_get_window_geometry (NautilusBookmarkList *bookmarks);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment