[nautilus] file: add an utility to set the file directory



commit a332b89eeba00447d6fafca816fae1f30a13952f
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Sep 1 11:44:53 2014 -0700

    file: add an utility to set the file directory
    
    We're going to add some other code in here.

 libnautilus-private/nautilus-desktop-icon-file.c |    2 +-
 libnautilus-private/nautilus-file-private.h      |    2 ++
 libnautilus-private/nautilus-file.c              |   16 +++++++++++-----
 3 files changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/libnautilus-private/nautilus-desktop-icon-file.c 
b/libnautilus-private/nautilus-desktop-icon-file.c
index f546efa..dbdc72f 100644
--- a/libnautilus-private/nautilus-desktop-icon-file.c
+++ b/libnautilus-private/nautilus-desktop-icon-file.c
@@ -271,7 +271,7 @@ nautilus_desktop_icon_file_new (NautilusDesktopLink *link)
        eazel_dump_stack_trace ("\t", 10);
 #endif
 
-       file->details->directory = directory;
+       nautilus_file_set_directory (file, directory);
 
        icon_file = NAUTILUS_DESKTOP_ICON_FILE (file);
        icon_file->details->link = link;
diff --git a/libnautilus-private/nautilus-file-private.h b/libnautilus-private/nautilus-file-private.h
index 5dd41ba..1beaa60 100644
--- a/libnautilus-private/nautilus-file-private.h
+++ b/libnautilus-private/nautilus-file-private.h
@@ -256,6 +256,8 @@ gboolean      nautilus_file_set_display_name               (NautilusFile
                                                            const char             *display_name,
                                                            const char             *edit_name,
                                                            gboolean                custom);
+void          nautilus_file_set_directory                  (NautilusFile           *file,
+                                                           NautilusDirectory      *directory);
 void          nautilus_file_set_mount                      (NautilusFile           *file,
                                                            GMount                 *mount);
 
diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c
index 466023e..1c27edd 100644
--- a/libnautilus-private/nautilus-file.c
+++ b/libnautilus-private/nautilus-file.c
@@ -500,6 +500,14 @@ nautilus_file_clear_info (NautilusFile *file)
        clear_metadata (file);
 }
 
+void
+nautilus_file_set_directory (NautilusFile *file,
+                            NautilusDirectory *directory)
+{
+       g_clear_object (&file->details->directory);
+       file->details->directory = nautilus_directory_ref (directory);
+}
+
 static NautilusFile *
 nautilus_file_new_from_filename (NautilusDirectory *directory,
                                 const char *filename,
@@ -530,8 +538,7 @@ nautilus_file_new_from_filename (NautilusDirectory *directory,
        } else {
                file = NAUTILUS_FILE (g_object_new (NAUTILUS_TYPE_VFS_FILE, NULL));
        }
-
-       file->details->directory = nautilus_directory_ref (directory);
+       nautilus_file_set_directory (file, directory);
 
        file->details->name = eel_ref_str_new (filename);
 
@@ -634,7 +641,7 @@ nautilus_file_new_from_info (NautilusDirectory *directory,
        g_return_val_if_fail (info != NULL, NULL);
 
        file = NAUTILUS_FILE (g_object_new (NAUTILUS_TYPE_VFS_FILE, NULL));
-       file->details->directory = nautilus_directory_ref (directory);
+       nautilus_file_set_directory (file, directory);
 
        update_info_and_name (file, info);
 
@@ -2624,8 +2631,7 @@ nautilus_file_update_name_and_directory (NautilusFile *file,
        monitors = nautilus_directory_remove_file_monitors (old_directory, file);
        nautilus_directory_remove_file (old_directory, file);
 
-       file->details->directory = nautilus_directory_ref (new_directory);
-       nautilus_directory_unref (old_directory);
+       nautilus_file_set_directory (file, new_directory);
 
        if (name) {
                update_name_internal (file, name, FALSE);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]