[nautilus] bookmark-list: add API to get a NautilusBookmark for a given URI
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] bookmark-list: add API to get a NautilusBookmark for a given URI
- Date: Fri, 14 Sep 2012 21:06:45 +0000 (UTC)
commit fc0b4b1ef598c893d69754e3455c99230b9c5a24
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Fri Sep 14 16:55:22 2012 -0400
bookmark-list: add API to get a NautilusBookmark for a given URI
This will be used by the shell search provider.
src/nautilus-bookmark-list.c | 39 +++++++++++++++++++++++++++++++++++++++
src/nautilus-bookmark-list.h | 2 ++
2 files changed, 41 insertions(+), 0 deletions(-)
---
diff --git a/src/nautilus-bookmark-list.c b/src/nautilus-bookmark-list.c
index ec04c56..9eec5e8 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 04cee8f..a9227cf 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]