summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCosimo Cecchi <cosimoc@gnome.org>2012-09-14 16:55:22 -0400
committerCosimo Cecchi <cosimoc@gnome.org>2012-09-14 17:00:51 -0400
commitfc0b4b1ef598c893d69754e3455c99230b9c5a24 (patch)
tree7ae1c561b1f3b836e31eb0186cbd6c709500cbb7 /src
parent0ed400b9c1692e42498bff3c10780073ec137f63 (diff)
downloadnautilus-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')
-rw-r--r--src/nautilus-bookmark-list.c39
-rw-r--r--src/nautilus-bookmark-list.h2
2 files changed, 41 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.
diff --git a/src/nautilus-bookmark-list.h b/src/nautilus-bookmark-list.h
index 04cee8fa7..a9227cfad 100644
--- a/src/nautilus-bookmark-list.h
+++ b/src/nautilus-bookmark-list.h
@@ -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);