[nautilus/wip/csoriano/destktop-split2: 40/54] file, directory: move file creation dispatching to directory
- From: Carlos Soriano Sánchez <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/csoriano/destktop-split2: 40/54] file, directory: move file creation dispatching to directory
- Date: Wed, 30 Mar 2016 14:06:09 +0000 (UTC)
commit 49c13ffc60f61630f5e0286b64d0fdd97c7a841d
Author: Carlos Soriano <csoriano gnome org>
Date: Tue Mar 29 21:30:12 2016 +0200
file, directory: move file creation dispatching to directory
It's the directory who owns the files, and we were actually creating
new files from nautilus directories in nautilus-file.
We can move that code to nautilus directory.
In this way, we will able to handle files of a specific scheme better,
like the desktop, in future patches.
libnautilus-private/nautilus-directory.c | 39 ++++++++++++++++++++++++++++++
libnautilus-private/nautilus-directory.h | 3 ++
libnautilus-private/nautilus-file.c | 26 +-------------------
3 files changed, 43 insertions(+), 25 deletions(-)
---
diff --git a/libnautilus-private/nautilus-directory.c b/libnautilus-private/nautilus-directory.c
index d9b2575..515d38b 100644
--- a/libnautilus-private/nautilus-directory.c
+++ b/libnautilus-private/nautilus-directory.c
@@ -28,11 +28,14 @@
#include "nautilus-file-private.h"
#include "nautilus-file-utilities.h"
#include "nautilus-search-directory.h"
+#include "nautilus-search-directory-file.h"
+#include "nautilus-vfs-file.h"
#include "nautilus-global-preferences.h"
#include "nautilus-lib-self-check-functions.h"
#include "nautilus-metadata.h"
#include "nautilus-profile.h"
#include "nautilus-desktop-directory.h"
+#include "nautilus-desktop-directory-file.h"
#include "nautilus-vfs-directory.h"
#include <eel/eel-glib-extensions.h>
#include <eel/eel-string.h>
@@ -540,6 +543,42 @@ nautilus_directory_get_location (NautilusDirectory *directory)
return g_object_ref (directory->details->location);
}
+NautilusFile *
+nautilus_directory_new_file_from_filename (NautilusDirectory *directory,
+ const char *filename,
+ gboolean self_owned)
+{
+ NautilusFile *file;
+
+ g_assert (NAUTILUS_IS_DIRECTORY (directory));
+ g_assert (filename != NULL);
+ g_assert (filename[0] != '\0');
+
+ if (NAUTILUS_IS_DESKTOP_DIRECTORY (directory)) {
+ g_print ("DIRECTORY FILE\n");
+ if (self_owned) {
+ file = NAUTILUS_FILE (g_object_new (NAUTILUS_TYPE_DESKTOP_DIRECTORY_FILE, NULL));
+ } else {
+ /* This doesn't normally happen, unless the user somehow types in a uri
+ * that references a file like this. (See #349840) */
+ file = NAUTILUS_FILE (g_object_new (NAUTILUS_TYPE_VFS_FILE, NULL));
+ }
+ } else if (NAUTILUS_IS_SEARCH_DIRECTORY (directory)) {
+ if (self_owned) {
+ file = NAUTILUS_FILE (g_object_new (NAUTILUS_TYPE_SEARCH_DIRECTORY_FILE, NULL));
+ } else {
+ /* This doesn't normally happen, unless the user somehow types in a uri
+ * that references a file like this. (See #349840) */
+ file = NAUTILUS_FILE (g_object_new (NAUTILUS_TYPE_VFS_FILE, NULL));
+ }
+ } else {
+ file = NAUTILUS_FILE (g_object_new (NAUTILUS_TYPE_VFS_FILE, NULL));
+ }
+ nautilus_file_set_directory (file, directory);
+
+ return file;
+}
+
static NautilusDirectory *
nautilus_directory_new (GFile *location)
{
diff --git a/libnautilus-private/nautilus-directory.h b/libnautilus-private/nautilus-directory.h
index 38662ec..c04888e 100644
--- a/libnautilus-private/nautilus-directory.h
+++ b/libnautilus-private/nautilus-directory.h
@@ -233,5 +233,8 @@ gboolean nautilus_directory_is_editable (NautilusDirector
void nautilus_directory_dump (NautilusDirectory *directory);
+NautilusFile * nautilus_directory_new_file_from_filename (NautilusDirectory *directory,
+ const char *filename,
+ gboolean self_owned);
#endif /* NAUTILUS_DIRECTORY_H */
diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c
index 1efe626..513533b 100644
--- a/libnautilus-private/nautilus-file.c
+++ b/libnautilus-private/nautilus-file.c
@@ -26,8 +26,6 @@
#include "nautilus-directory-notify.h"
#include "nautilus-directory-private.h"
#include "nautilus-signaller.h"
-#include "nautilus-desktop-directory.h"
-#include "nautilus-desktop-directory-file.h"
#include "nautilus-desktop-icon-file.h"
#include "nautilus-file-attributes.h"
#include "nautilus-file-private.h"
@@ -38,8 +36,6 @@
#include "nautilus-link.h"
#include "nautilus-metadata.h"
#include "nautilus-module.h"
-#include "nautilus-search-directory.h"
-#include "nautilus-search-directory-file.h"
#include "nautilus-thumbnails.h"
#include "nautilus-ui-utilities.h"
#include "nautilus-video-mime-types.h"
@@ -534,27 +530,7 @@ nautilus_file_new_from_filename (NautilusDirectory *directory,
g_assert (filename != NULL);
g_assert (filename[0] != '\0');
- if (NAUTILUS_IS_DESKTOP_DIRECTORY (directory)) {
- if (self_owned) {
- file = NAUTILUS_FILE (g_object_new (NAUTILUS_TYPE_DESKTOP_DIRECTORY_FILE, NULL));
- } else {
- /* This doesn't normally happen, unless the user somehow types in a uri
- * that references a file like this. (See #349840) */
- file = NAUTILUS_FILE (g_object_new (NAUTILUS_TYPE_VFS_FILE, NULL));
- }
- } else if (NAUTILUS_IS_SEARCH_DIRECTORY (directory)) {
- if (self_owned) {
- file = NAUTILUS_FILE (g_object_new (NAUTILUS_TYPE_SEARCH_DIRECTORY_FILE, NULL));
- } else {
- /* This doesn't normally happen, unless the user somehow types in a uri
- * that references a file like this. (See #349840) */
- file = NAUTILUS_FILE (g_object_new (NAUTILUS_TYPE_VFS_FILE, NULL));
- }
- } else {
- file = NAUTILUS_FILE (g_object_new (NAUTILUS_TYPE_VFS_FILE, NULL));
- }
- nautilus_file_set_directory (file, directory);
-
+ file = nautilus_directory_new_file_from_filename (directory, filename, self_owned);
file->details->name = eel_ref_str_new (filename);
#ifdef NAUTILUS_FILE_DEBUG_REF
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]