[nautilus/wip/csoriano/destktop-split2: 24/50] desktop-directory: override creation of files
- From: Carlos Soriano Sánchez <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/csoriano/destktop-split2: 24/50] desktop-directory: override creation of files
- Date: Tue, 5 Apr 2016 13:16:17 +0000 (UTC)
commit ab9e9828d496ec488f0555649fb3611b89c0a9a3
Author: Carlos Soriano <csoriano gnome org>
Date: Tue Mar 29 21:57:59 2016 +0200
desktop-directory: override creation of files
So we use inheritance instead of special casing, making possible
to remove the desktop dependency for the creation of the desktop
files.
libnautilus-private/nautilus-desktop-directory.c | 26 ++++++++++++++++++++++
libnautilus-private/nautilus-directory.c | 11 +--------
2 files changed, 27 insertions(+), 10 deletions(-)
---
diff --git a/libnautilus-private/nautilus-desktop-directory.c
b/libnautilus-private/nautilus-desktop-directory.c
index 4064ed8..2b610c2 100644
--- a/libnautilus-private/nautilus-desktop-directory.c
+++ b/libnautilus-private/nautilus-desktop-directory.c
@@ -23,6 +23,7 @@
#include <config.h>
#include "nautilus-desktop-directory.h"
+#include "nautilus-desktop-directory-file.h"
#include "nautilus-directory-private.h"
#include "nautilus-file.h"
@@ -484,6 +485,30 @@ update_desktop_directory (NautilusDesktopDirectory *desktop)
desktop->details->real_directory = real_directory;
}
+static NautilusFile *
+real_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 (self_owned) {
+ file = NAUTILUS_FILE (g_object_new (NAUTILUS_TYPE_DESKTOP_DIRECTORY_FILE, NULL));
+ } else {
+ g_critical ("Accessing desktop uris directly is not supported.");
+
+ return NULL;
+ }
+
+ nautilus_file_set_directory (file, directory);
+
+ return file;
+}
+
static void
desktop_directory_changed_callback (gpointer data)
{
@@ -522,6 +547,7 @@ nautilus_desktop_directory_class_init (NautilusDesktopDirectoryClass *class)
directory_class->force_reload = desktop_force_reload;
directory_class->are_all_files_seen = desktop_are_all_files_seen;
directory_class->is_not_empty = desktop_is_not_empty;
+ directory_class->new_file_from_filename = real_new_file_from_filename;
/* Override get_file_list so that we can return the list of files
* in NautilusDesktopDirectory->details->real_directory,
* in addition to the list of standard desktop icons on the desktop.
diff --git a/libnautilus-private/nautilus-directory.c b/libnautilus-private/nautilus-directory.c
index 06cb6a7..3d4f985 100644
--- a/libnautilus-private/nautilus-directory.c
+++ b/libnautilus-private/nautilus-directory.c
@@ -568,16 +568,7 @@ real_new_file_from_filename (NautilusDirectory *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 (NAUTILUS_IS_SEARCH_DIRECTORY (directory)) {
if (self_owned) {
file = NAUTILUS_FILE (g_object_new (NAUTILUS_TYPE_SEARCH_DIRECTORY_FILE, NULL));
} else {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]