[Xfce4-commits] <thunar:master> Add common function to get the .gtk-bookmarks file.

Nick Schermer noreply at xfce.org
Sat Nov 10 17:04:02 CET 2012


Updating branch refs/heads/master
         to 115da6b521dbc30b844d57d5fad6b647bbaa6888 (commit)
       from 42c64c1693350448e91be05da79bcdaca8179c0a (commit)

commit 115da6b521dbc30b844d57d5fad6b647bbaa6888
Author: Nick Schermer <nick at xfce.org>
Date:   Fri Nov 9 20:14:47 2012 +0100

    Add common function to get the .gtk-bookmarks file.

 thunar/thunar-gio-extensions.c  |   15 +++++++++++++++
 thunar/thunar-gio-extensions.h  |    1 +
 thunar/thunar-shortcuts-model.c |    5 ++---
 thunar/thunar-window.c          |    6 +-----
 4 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/thunar/thunar-gio-extensions.c b/thunar/thunar-gio-extensions.c
index 939aa6d..8700d58 100644
--- a/thunar/thunar-gio-extensions.c
+++ b/thunar/thunar-gio-extensions.c
@@ -71,6 +71,21 @@ thunar_g_file_new_for_desktop (void)
 
 
 
+GFile *
+thunar_g_file_new_for_bookmarks (void)
+{
+  gchar *filename;
+  GFile *bookmarks;
+
+  filename = g_build_filename (xfce_get_homedir (), ".gtk-bookmarks", NULL);
+  bookmarks = g_file_new_for_path (filename);
+  g_free (filename);
+
+  return bookmarks;
+}
+
+
+
 gboolean
 thunar_g_file_is_root (GFile *file)
 {
diff --git a/thunar/thunar-gio-extensions.h b/thunar/thunar-gio-extensions.h
index d29b963..4758710 100644
--- a/thunar/thunar-gio-extensions.h
+++ b/thunar/thunar-gio-extensions.h
@@ -29,6 +29,7 @@ GFile    *thunar_g_file_new_for_home             (void);
 GFile    *thunar_g_file_new_for_root             (void);
 GFile    *thunar_g_file_new_for_trash            (void);
 GFile    *thunar_g_file_new_for_desktop          (void);
+GFile    *thunar_g_file_new_for_bookmarks        (void);
 
 gboolean  thunar_g_file_is_root                  (GFile                *file);
 gboolean  thunar_g_file_is_trashed               (GFile                *file);
diff --git a/thunar/thunar-shortcuts-model.c b/thunar/thunar-shortcuts-model.c
index bbdf396..8da1b45 100644
--- a/thunar/thunar-shortcuts-model.c
+++ b/thunar/thunar-shortcuts-model.c
@@ -907,6 +907,7 @@ thunar_shortcuts_model_shortcut_places (ThunarShortcutsModel *model)
         }
     }
   g_object_unref (desktop);
+  g_object_unref (home);
 
   /* append the trash icon if the trash is supported */
   if (thunar_g_vfs_is_uri_scheme_supported ("trash"))
@@ -926,7 +927,7 @@ thunar_shortcuts_model_shortcut_places (ThunarShortcutsModel *model)
     }
 
   /* determine the URI to the Gtk+ bookmarks file */
-  model->bookmarks_file = g_file_resolve_relative_path (home, ".gtk-bookmarks");
+  model->bookmarks_file = thunar_g_file_new_for_bookmarks ();
 
   /* register with the alteration monitor for the bookmarks file */
   model->bookmarks_monitor = g_file_monitor_file (model->bookmarks_file, G_FILE_MONITOR_NONE, NULL, NULL);
@@ -938,8 +939,6 @@ thunar_shortcuts_model_shortcut_places (ThunarShortcutsModel *model)
 
   /* read the Gtk+ bookmarks file */
   model->bookmarks_idle_id = g_idle_add_full (G_PRIORITY_DEFAULT, thunar_shortcuts_model_load, model, NULL);
-
-  g_object_unref (home);
 }
 
 
diff --git a/thunar/thunar-window.c b/thunar/thunar-window.c
index aaf9674..1761f2b 100644
--- a/thunar/thunar-window.c
+++ b/thunar/thunar-window.c
@@ -2028,7 +2028,6 @@ static gboolean
 thunar_window_bookmark_merge (gpointer user_data)
 {
   ThunarWindow *window = THUNAR_WINDOW (user_data);
-  GFile        *home;
 
   _thunar_return_val_if_fail (THUNAR_IS_WINDOW (window), FALSE);
 
@@ -2051,10 +2050,7 @@ thunar_window_bookmark_merge (gpointer user_data)
   /* lazy initialize the bookmarks */
   if (window->bookmark_file == NULL)
     {
-      home = thunar_g_file_new_for_home ();
-      window->bookmark_file = g_file_resolve_relative_path (home, ".gtk-bookmarks");
-      g_object_unref (home);
-
+      window->bookmark_file = thunar_g_file_new_for_bookmarks ();
       window->bookmark_monitor = g_file_monitor_file (window->bookmark_file, G_FILE_MONITOR_NONE, NULL, NULL);
       if (G_LIKELY (window->bookmark_monitor != NULL))
         {


More information about the Xfce4-commits mailing list