diff options
author | raveit65 <[email protected]> | 2017-04-16 11:36:20 +0200 |
---|---|---|
committer | lukefromdc <[email protected]> | 2017-04-20 15:51:24 -0400 |
commit | 65f573cfe455f6c74d1d9e228a6a462017d3805f (patch) | |
tree | 0d7ea4a4f9f4a9c039206c3e9aa3c776ae9d50e2 /src/caja-bookmark-list.c | |
parent | 55087066adcf0d4dcc575bf5b3cd09d7c073aa7c (diff) | |
download | caja-65f573cfe455f6c74d1d9e228a6a462017d3805f.tar.bz2 caja-65f573cfe455f6c74d1d9e228a6a462017d3805f.tar.xz |
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
Diffstat (limited to 'src/caja-bookmark-list.c')
-rw-r--r-- | src/caja-bookmark-list.c | 31 |
1 files changed, 30 insertions, 1 deletions
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, |