diff options
author | Cosimo Cecchi <cosimoc@gnome.org> | 2012-09-14 16:55:22 -0400 |
---|---|---|
committer | Cosimo Cecchi <cosimoc@gnome.org> | 2012-09-14 17:00:51 -0400 |
commit | fc0b4b1ef598c893d69754e3455c99230b9c5a24 (patch) | |
tree | 7ae1c561b1f3b836e31eb0186cbd6c709500cbb7 /src/nautilus-bookmark-list.c | |
parent | 0ed400b9c1692e42498bff3c10780073ec137f63 (diff) | |
download | nautilus-fc0b4b1ef598c893d69754e3455c99230b9c5a24.tar.gz |
bookmark-list: add API to get a NautilusBookmark for a given URI
This will be used by the shell search provider.
Diffstat (limited to 'src/nautilus-bookmark-list.c')
-rw-r--r-- | src/nautilus-bookmark-list.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/nautilus-bookmark-list.c b/src/nautilus-bookmark-list.c index ec04c56da..9eec5e832 100644 --- a/src/nautilus-bookmark-list.c +++ b/src/nautilus-bookmark-list.c @@ -417,6 +417,45 @@ nautilus_bookmark_list_item_at (NautilusBookmarkList *bookmarks, guint 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: * * Get the number of bookmarks in the list. |