From 65f573cfe455f6c74d1d9e228a6a462017d3805f Mon Sep 17 00:00:00 2001 From: raveit65 Date: Sun, 16 Apr 2017 11:36:20 +0200 Subject: Use gtk+-3 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 taken from: https://git.gnome.org/browse/nautilus/commit/?id=ed90577 --- src/caja-bookmark-list.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'src/caja-bookmark-list.c') diff --git a/src/caja-bookmark-list.c b/src/caja-bookmark-list.c index 8aac12da..d39b2b98 100644 --- a/src/caja-bookmark-list.c +++ b/src/caja-bookmark-list.c @@ -115,7 +115,7 @@ new_bookmark_from_uri (const char *uri, const char *label) } static GFile * -caja_bookmark_list_get_file (void) +caja_bookmark_list_get_legacy_file (void) { char *filename; GFile *file; @@ -130,6 +130,23 @@ caja_bookmark_list_get_file (void) return file; } +static GFile * +caja_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 @@ -559,6 +576,9 @@ load_file_async (CajaBookmarkList *self, GFile *file; file = caja_bookmark_list_get_file (); + if (!g_file_query_exists (file, NULL)) { + file = caja_bookmark_list_get_legacy_file (); + } /* Wipe out old list. */ clear (self); @@ -606,6 +626,8 @@ save_file_async (CajaBookmarkList *bookmarks, GFile *file; GList *l; GString *bookmark_string; + GFile *parent; + char *path; /* temporarily disable bookmark file monitoring when writing file */ if (bookmarks->monitor != NULL) @@ -645,6 +667,13 @@ save_file_async (CajaBookmarkList *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, -- cgit v1.2.1