[gtk+/places-sidebar] If a bookmark doesn't have an explicit label, use the display name of the file
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/places-sidebar] If a bookmark doesn't have an explicit label, use the display name of the file
- Date: Fri, 7 Sep 2012 19:37:25 +0000 (UTC)
commit f05874a1f0e23b52f6e465c9d0699fcfd1282d8e
Author: Federico Mena Quintero <federico gnome org>
Date: Fri Sep 7 14:36:05 2012 -0500
If a bookmark doesn't have an explicit label, use the display name of the file
We query the file info for display name and icon synchronously. If it becomes a problem,
we'll make it async, more in line with NautilusBookmark.
Signed-off-by: Federico Mena Quintero <federico gnome org>
gtk/gtkplacessidebar.c | 43 +++++++++++++++++++++++++++++--------------
1 files changed, 29 insertions(+), 14 deletions(-)
---
diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c
index 0ac7d01..bb1eb85 100644
--- a/gtk/gtkplacessidebar.c
+++ b/gtk/gtkplacessidebar.c
@@ -910,6 +910,8 @@ update_places (GtkPlacesSidebar *sidebar)
bookmarks = _gtk_bookmarks_manager_list_bookmarks (sidebar->bookmarks_manager);
for (sl = bookmarks, index = 0; sl; sl = sl->next, index++) {
+ GFileInfo *info;
+
root = sl->data;
#if 0
@@ -932,23 +934,36 @@ update_places (GtkPlacesSidebar *sidebar)
nautilus_file_unref (file);
#endif
- bookmark_name = _gtk_bookmarks_manager_get_bookmark_label (sidebar->bookmarks_manager, root);
- icon = NULL; /* FIXME: icon = nautilus_bookmark_get_icon (bookmark); */
- mount_uri = g_file_get_uri (root);
- tooltip = g_file_get_parse_name (root);
+ /* FIXME: we are getting file info synchronously. We may want to do it async at some point. */
+ info = g_file_query_info (root,
+ "standard::display-name,standard::icon",
+ G_FILE_QUERY_INFO_NONE,
+ NULL,
+ NULL); /* NULL-GError */
- add_place (sidebar, PLACES_BOOKMARK,
- SECTION_BOOKMARKS,
- bookmark_name, icon, mount_uri,
- NULL, NULL, NULL, index,
- tooltip);
+ if (info) {
+ bookmark_name = _gtk_bookmarks_manager_get_bookmark_label (sidebar->bookmarks_manager, root);
- if (icon)
- g_object_unref (icon);
+ if (bookmark_name == NULL)
+ bookmark_name = g_strdup (g_file_info_get_display_name (info));
- g_free (mount_uri);
- g_free (tooltip);
- g_free (bookmark_name);
+ icon = g_file_info_get_icon (info);
+
+ mount_uri = g_file_get_uri (root);
+ tooltip = g_file_get_parse_name (root);
+
+ add_place (sidebar, PLACES_BOOKMARK,
+ SECTION_BOOKMARKS,
+ bookmark_name, icon, mount_uri,
+ NULL, NULL, NULL, index,
+ tooltip);
+
+ g_free (mount_uri);
+ g_free (tooltip);
+ g_free (bookmark_name);
+
+ g_object_unref (info);
+ }
}
g_slist_foreach (bookmarks, (GFunc) g_object_unref, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]