Commit fc0b4b1e authored by Cosimo Cecchi's avatar Cosimo Cecchi

bookmark-list: add API to get a NautilusBookmark for a given URI

This will be used by the shell search provider.
parent 0ed400b9
......@@ -416,6 +416,45 @@ nautilus_bookmark_list_item_at (NautilusBookmarkList *bookmarks, guint index)
return NAUTILUS_BOOKMARK (g_list_nth_data (bookmarks->list, index));
}
/**
* nautilus_bookmark_list_item_with_uri:
*
* Get the bookmark with the specified URI, if any
* @bookmarks: the list of bookmarks.
* @uri: an URI
*
* Return value: the bookmark with URI @uri, or %NULL.
**/
NautilusBookmark *
nautilus_bookmark_list_item_with_uri (NautilusBookmarkList *bookmarks,
const gchar *uri)
{
GList *node;
gchar *bookmark_uri;
NautilusBookmark *bookmark;
gboolean found = FALSE;
g_return_val_if_fail (NAUTILUS_IS_BOOKMARK_LIST (bookmarks), NULL);
g_return_val_if_fail (uri != NULL, NULL);
for (node = bookmarks->list; node != NULL; node = node->next) {
bookmark = node->data;
bookmark_uri = nautilus_bookmark_get_uri (bookmark);
if (g_strcmp0 (uri, bookmark_uri) == 0) {
found = TRUE;
}
g_free (bookmark_uri);
if (found) {
return bookmark;
}
}
return NULL;
}
/**
* nautilus_bookmark_list_length:
*
......
......@@ -75,6 +75,8 @@ void nautilus_bookmark_list_insert_item (NautilusBook
guint nautilus_bookmark_list_length (NautilusBookmarkList *bookmarks);
NautilusBookmark * nautilus_bookmark_list_item_at (NautilusBookmarkList *bookmarks,
guint index);
NautilusBookmark * nautilus_bookmark_list_item_with_uri (NautilusBookmarkList *bookmarks,
const gchar *uri);
void nautilus_bookmark_list_move_item (NautilusBookmarkList *bookmarks,
guint index,
guint destination);
......
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