[nautilus] bookmark-list: change item_with_uri() API to use a GFile instead



commit 26e6907a9343e45500d4c3373e4210d072db08e1
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Oct 22 12:44:29 2012 -0400

    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.

 src/nautilus-bookmark-list.c         |   22 +++++++++++-----------
 src/nautilus-bookmark-list.h         |    4 ++--
 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 a3319d9..24dbe92 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 b498c1f..451e217 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 ddc9727..67a6c58 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);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]