[nautilus] Use new GTK bookmarks location



commit ed9057711896dd71a6e1524b9fcf963b9adb24c0
Author: William Jon McCann <jmccann redhat com>
Date:   Fri Apr 27 12:57:14 2012 -0400

    Use new GTK bookmarks location
    
    If it doesn't exist fallback to reading from the old location but
    always write to the new location.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=674986

 src/nautilus-bookmark-list.c |   31 ++++++++++++++++++++++++++++++-
 1 files changed, 30 insertions(+), 1 deletions(-)
---
diff --git a/src/nautilus-bookmark-list.c b/src/nautilus-bookmark-list.c
index 3d7d437..c66a417 100644
--- a/src/nautilus-bookmark-list.c
+++ b/src/nautilus-bookmark-list.c
@@ -76,7 +76,7 @@ new_bookmark_from_uri (const char *uri, const char *label)
 }
 
 static GFile *
-nautilus_bookmark_list_get_file (void)
+nautilus_bookmark_list_get_legacy_file (void)
 {
 	char *filename;
 	GFile *file;
@@ -91,6 +91,23 @@ nautilus_bookmark_list_get_file (void)
 	return file;
 }
 
+static GFile *
+nautilus_bookmark_list_get_file (void)
+{
+	char *filename;
+	GFile *file;
+
+	filename = g_build_filename (g_get_user_config_dir (),
+				     "gtk-3.0",
+				     "bookmarks",
+				     NULL);
+	file = g_file_new_for_path (filename);
+
+	g_free (filename);
+
+	return file;
+}
+
 /* Initialization.  */
 
 static void
@@ -497,6 +514,9 @@ load_file_async (NautilusBookmarkList *self,
 	GFile *file;
 
 	file = nautilus_bookmark_list_get_file ();
+	if (!g_file_query_exists (file, NULL)) {
+		file = nautilus_bookmark_list_get_legacy_file ();
+	}
 
 	/* Wipe out old list. */
 	clear (self);
@@ -543,6 +563,8 @@ save_file_async (NautilusBookmarkList *bookmarks,
 	GFile *file;
 	GList *l;
 	GString *bookmark_string;
+	GFile *parent;
+	char *path;
 
 	/* temporarily disable bookmark file monitoring when writing file */
 	if (bookmarks->monitor != NULL) {
@@ -577,6 +599,13 @@ save_file_async (NautilusBookmarkList *bookmarks,
 
 	/* keep the bookmark list alive */
 	g_object_ref (bookmarks);
+
+	parent = g_file_get_parent (file);
+	path = g_file_get_path (parent);
+	g_mkdir_with_parents (path, 0700);
+	g_free (path);
+	g_object_unref (parent);
+
 	g_file_replace_contents_async (file, bookmark_string->str,
 				       bookmark_string->len, NULL,
 				       FALSE, 0, NULL, callback,



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