summaryrefslogtreecommitdiff
path: root/gtk/gtkbookmarksmanager.c
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@gnome.org>2012-09-03 20:52:27 -0500
committerFederico Mena Quintero <federico@gnome.org>2012-09-03 20:52:27 -0500
commit36969380b3ba7a2ca322b53022c3b869e5470043 (patch)
tree07432819d90aa9228359717561ceb0cc48cb7ed0 /gtk/gtkbookmarksmanager.c
parent163beca27959e3803bbd5be09d78fc86381e5946 (diff)
downloadgtk+-36969380b3ba7a2ca322b53022c3b869e5470043.tar.gz
Read the legacy bookmarks file
Signed-off-by: Federico Mena Quintero <federico@gnome.org>
Diffstat (limited to 'gtk/gtkbookmarksmanager.c')
-rw-r--r--gtk/gtkbookmarksmanager.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/gtk/gtkbookmarksmanager.c b/gtk/gtkbookmarksmanager.c
index b998c4aa33..19f79f9eb0 100644
--- a/gtk/gtkbookmarksmanager.c
+++ b/gtk/gtkbookmarksmanager.c
@@ -40,7 +40,7 @@ _gtk_bookmark_free (GtkBookmark *bookmark)
}
static GFile *
-get_bookmarks_file (void)
+get_legacy_bookmarks_file (void)
{
GFile *file;
gchar *filename;
@@ -52,6 +52,19 @@ get_bookmarks_file (void)
return file;
}
+static GFile *
+get_bookmarks_file (void)
+{
+ GFile *file;
+ gchar *filename;
+
+ 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;
+}
+
static GSList *
read_bookmarks (GFile *file)
{
@@ -189,6 +202,17 @@ _gtk_bookmarks_manager_new (GtkBookmarksChangedFunc changed_func, gpointer chang
bookmarks_file = get_bookmarks_file ();
manager->bookmarks = read_bookmarks (bookmarks_file);
+ if (!priv->bookmarks)
+ {
+ GFile *legacy_bookmarks_file;
+
+ /* Read the legacy one and write it to the new one */
+ legacy_bookmarks_file = get_legacy_bookmarks_file ();
+ priv->bookmarks = read_bookmarks (legacy_bookmarks_file);
+ save_bookmarks (bookmarks_file, priv->bookmarks);
+
+ g_object_unref (legacy_bookmarks_file);
+ }
error = NULL;
manager->bookmarks_monitor = g_file_monitor_file (bookmarks_file,