1
0
mirror of https://gitlab.gnome.org/GNOME/nautilus synced 2024-06-30 23:46:35 +00:00

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
This commit is contained in:
William Jon McCann 2012-04-27 12:57:14 -04:00 committed by Cosimo Cecchi
parent 4b23fe542a
commit ed90577118

View File

@ -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,