diff options
author | Cosimo Cecchi <cosimoc@gnome.org> | 2012-10-22 12:44:29 -0400 |
---|---|---|
committer | Cosimo Cecchi <cosimoc@gnome.org> | 2012-10-22 12:44:29 -0400 |
commit | 26e6907a9343e45500d4c3373e4210d072db08e1 (patch) | |
tree | 60fc2b00fda7f8487fa0bdda0b55f274435d4178 | |
parent | d09413bcff9b62af6ea58d003ffe2b76c792a57f (diff) | |
download | nautilus-26e6907a9343e45500d4c3373e4210d072db08e1.tar.gz |
bookmark-list: change item_with_uri() API to use a GFile instead
Avoid GFile<->URI roundtrips if possible. Also, this will allow us to
use the same API for another purpose.
-rw-r--r-- | src/nautilus-bookmark-list.c | 22 | ||||
-rw-r--r-- | src/nautilus-bookmark-list.h | 4 | ||||
-rw-r--r-- | src/nautilus-shell-search-provider.c | 16 |
3 files changed, 21 insertions, 21 deletions
diff --git a/src/nautilus-bookmark-list.c b/src/nautilus-bookmark-list.c index a3319d97d..24dbe9244 100644 --- a/src/nautilus-bookmark-list.c +++ b/src/nautilus-bookmark-list.c @@ -356,35 +356,35 @@ nautilus_bookmark_list_item_at (NautilusBookmarkList *bookmarks, guint index) } /** - * nautilus_bookmark_list_item_with_uri: + * nautilus_bookmark_list_item_with_location: * - * Get the bookmark with the specified URI, if any + * Get the bookmark with the specified location, if any * @bookmarks: the list of bookmarks. - * @uri: an URI + * @location: a #GFile * - * Return value: the bookmark with URI @uri, or %NULL. + * Return value: the bookmark with location @location, or %NULL. **/ NautilusBookmark * -nautilus_bookmark_list_item_with_uri (NautilusBookmarkList *bookmarks, - const gchar *uri) +nautilus_bookmark_list_item_with_location (NautilusBookmarkList *bookmarks, + GFile *location) { GList *node; - gchar *bookmark_uri; + GFile *bookmark_location; NautilusBookmark *bookmark; gboolean found = FALSE; g_return_val_if_fail (NAUTILUS_IS_BOOKMARK_LIST (bookmarks), NULL); - g_return_val_if_fail (uri != NULL, NULL); + g_return_val_if_fail (G_IS_FILE (location), NULL); for (node = bookmarks->list; node != NULL; node = node->next) { bookmark = node->data; - bookmark_uri = nautilus_bookmark_get_uri (bookmark); + bookmark_location = nautilus_bookmark_get_location (bookmark); - if (g_strcmp0 (uri, bookmark_uri) == 0) { + if (g_file_equal (location, bookmark_location)) { found = TRUE; } - g_free (bookmark_uri); + g_object_unref (bookmark_location); if (found) { return bookmark; diff --git a/src/nautilus-bookmark-list.h b/src/nautilus-bookmark-list.h index b498c1f63..451e217a2 100644 --- a/src/nautilus-bookmark-list.h +++ b/src/nautilus-bookmark-list.h @@ -71,8 +71,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); +NautilusBookmark * nautilus_bookmark_list_item_with_location (NautilusBookmarkList *bookmarks, + GFile *location); void nautilus_bookmark_list_move_item (NautilusBookmarkList *bookmarks, guint index, guint destination); diff --git a/src/nautilus-shell-search-provider.c b/src/nautilus-shell-search-provider.c index ddc972773..67a6c58ad 100644 --- a/src/nautilus-shell-search-provider.c +++ b/src/nautilus-shell-search-provider.c @@ -104,12 +104,12 @@ static gchar * get_display_name (NautilusShellSearchProviderApp *self, NautilusFile *file) { - gchar *uri; + GFile *location; NautilusBookmark *bookmark; - uri = nautilus_file_get_uri (file); - bookmark = nautilus_bookmark_list_item_with_uri (self->bookmarks, uri); - g_free (uri); + location = nautilus_file_get_location (file); + bookmark = nautilus_bookmark_list_item_with_location (self->bookmarks, location); + g_object_unref (location); if (bookmark) return g_strdup (nautilus_bookmark_get_name (bookmark)); @@ -121,12 +121,12 @@ static GIcon * get_gicon (NautilusShellSearchProviderApp *self, NautilusFile *file) { - gchar *uri; + GFile *location; NautilusBookmark *bookmark; - uri = nautilus_file_get_uri (file); - bookmark = nautilus_bookmark_list_item_with_uri (self->bookmarks, uri); - g_free (uri); + location = nautilus_file_get_location (file); + bookmark = nautilus_bookmark_list_item_with_location (self->bookmarks, location); + g_object_unref (location); if (bookmark) return nautilus_bookmark_get_icon (bookmark); |