diff options
author | Bastien Nocera <hadess@hadess.net> | 2013-11-06 19:12:03 +0100 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2013-11-13 23:23:50 -0500 |
commit | 3f5af532f7e8cec7da7eef31bdfa9e25949cdbd3 (patch) | |
tree | 950c823e8047ba2baca5077aadbb2745f9ca59c2 | |
parent | 3c6c90086fe3507563abdd1d511e6f264d131572 (diff) | |
download | gtk+-3f5af532f7e8cec7da7eef31bdfa9e25949cdbd3.tar.gz |
GtkPlacesSidebar: Show unmounted bookmarks
The GtkFileInfo is only used if there's no bookmark name,
or to get the icon for the remote share or local folder.
https://bugzilla.gnome.org/show_bug.cgi?id=711548
-rw-r--r-- | gtk/gtkplacessidebar.c | 52 |
1 files changed, 35 insertions, 17 deletions
diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c index 7dcfcb0c9e..64793487f2 100644 --- a/gtk/gtkplacessidebar.c +++ b/gtk/gtkplacessidebar.c @@ -254,7 +254,9 @@ enum { #define ICON_NAME_EJECT "media-eject-symbolic" #define ICON_NAME_NETWORK "network-workgroup-symbolic" #define ICON_NAME_NETWORK_SERVER "network-server-symbolic" +#define ICON_NAME_FOLDER_NETWORK "folder-remote-symbolic" +#define ICON_NAME_FOLDER "folder-symbolic" #define ICON_NAME_FOLDER_DESKTOP "user-desktop" #define ICON_NAME_FOLDER_DOCUMENTS "folder-documents-symbolic" #define ICON_NAME_FOLDER_DOWNLOAD "folder-download-symbolic" @@ -1081,8 +1083,10 @@ update_places (GtkPlacesSidebar *sidebar) for (sl = bookmarks, index = 0; sl; sl = sl->next, index++) { GFileInfo *info; + gboolean is_native; root = sl->data; + is_native = g_file_is_native (root); #if 0 /* FIXME: remove this? If we *do* show bookmarks for nonexistent files, the user will eventually clean them up */ @@ -1093,6 +1097,9 @@ update_places (GtkPlacesSidebar *sidebar) if (_gtk_bookmarks_manager_get_is_builtin (sidebar->bookmarks_manager, root)) continue; + if (sidebar->local_only && !is_native) + continue; + /* 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::symbolic-icon", @@ -1100,29 +1107,40 @@ update_places (GtkPlacesSidebar *sidebar) NULL, NULL); /* NULL-GError */ - if (info) + bookmark_name = _gtk_bookmarks_manager_get_bookmark_label (sidebar->bookmarks_manager, root); + if (bookmark_name == NULL && info != NULL) + bookmark_name = g_strdup (g_file_info_get_display_name (info)); + else if (bookmark_name == NULL) { - bookmark_name = _gtk_bookmarks_manager_get_bookmark_label (sidebar->bookmarks_manager, root); + /* Don't add non-UTF-8 bookmarks */ + bookmark_name = g_file_get_basename (root); + if (!g_utf8_validate (bookmark_name, -1, NULL)) + { + g_free (bookmark_name); + continue; + } + } - if (bookmark_name == NULL) - bookmark_name = g_strdup (g_file_info_get_display_name (info)); + if (info) + icon = g_object_ref (g_file_info_get_symbolic_icon (info)); + else + icon = g_themed_icon_new_with_default_fallbacks (is_native ? ICON_NAME_FOLDER : ICON_NAME_FOLDER_NETWORK); - icon = g_file_info_get_symbolic_icon (info); - mount_uri = g_file_get_uri (root); - tooltip = g_file_get_parse_name (root); + 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); + 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_free (mount_uri); + g_free (tooltip); + g_free (bookmark_name); - g_object_unref (info); - } + if (info) + g_object_unref (info); } g_slist_foreach (bookmarks, (GFunc) g_object_unref, NULL); |