[gtk+] GtkPlacesSidebar: Show unmounted bookmarks
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] GtkPlacesSidebar: Show unmounted bookmarks
- Date: Thu, 14 Nov 2013 04:29:02 +0000 (UTC)
commit 3f5af532f7e8cec7da7eef31bdfa9e25949cdbd3
Author: Bastien Nocera <hadess hadess net>
Date: Wed Nov 6 19:12:03 2013 +0100
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
gtk/gtkplacessidebar.c | 52 ++++++++++++++++++++++++++++++++---------------
1 files changed, 35 insertions(+), 17 deletions(-)
---
diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c
index 7dcfcb0..6479348 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]