diff options
author | Carlos Soriano <csoriano@gnome.org> | 2016-03-29 21:58:56 +0200 |
---|---|---|
committer | Carlos Soriano <csoriano@gnome.org> | 2016-04-14 10:35:15 +0200 |
commit | 3d254047281eb1fdcab7d9c67c70c24fb195d73d (patch) | |
tree | cbc0ed4f679e5a6574349cc577d2dc1c6f279a02 /libnautilus-private | |
parent | f9d53f5c0d13d8d82328f1b0ab9d6e963cebc4b7 (diff) | |
download | nautilus-3d254047281eb1fdcab7d9c67c70c24fb195d73d.tar.gz |
desktop: ensure desktop directory on application init
Until now we were creating the desktop directory in a lazy way, like
any other cached directory.
However, we have the problem that at some point we have to dispatch
between different types of files, when creating them for the cache.
We cannot know when we will need to create the desktop directory for
first time in order to discern between that type of directory, or the
regular one.
What we can do is ensure that we created the desktop directory before
any other part of nautilus request it. In this way, we can create it
on our subclasses of the desktop, and after that, nautilus will request
the cache as a regular use, without the need to special case the
desktop.
For that, create the desktop directory when the desktop application
starts, holding the reference so the cache doesn't release it, and then
let nautilus work as expected.
For that, in previous commits we moved the file dispatching to be inside
the directory, so now any file creation happens inside the directory,
and therefore we can control, when creating the desktop directory, what
subclass will be called.
https://bugzilla.gnome.org/show_bug.cgi?id=712620
Diffstat (limited to 'libnautilus-private')
-rw-r--r-- | libnautilus-private/nautilus-directory.c | 25 | ||||
-rw-r--r-- | libnautilus-private/nautilus-directory.h | 2 |
2 files changed, 22 insertions, 5 deletions
diff --git a/libnautilus-private/nautilus-directory.c b/libnautilus-private/nautilus-directory.c index 3d4f9858b..f28d713b0 100644 --- a/libnautilus-private/nautilus-directory.c +++ b/libnautilus-private/nautilus-directory.c @@ -33,8 +33,6 @@ #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> @@ -455,6 +453,25 @@ nautilus_directory_get_for_file (NautilusFile *file) return directory; } +void +nautilus_directory_add_to_cache (NautilusDirectory *directory) +{ + NautilusDirectory *existing_directory; + GFile *location; + + location = nautilus_directory_get_location (directory); + existing_directory = nautilus_directory_get_existing (location); + if (existing_directory == NULL) { + /* Put it in the hash table. */ + g_hash_table_insert (directories, + directory->details->location, + directory); + } else { + nautilus_directory_unref (existing_directory); + } +} + + /* Returns a reffed NautilusFile object for this directory. */ NautilusFile * @@ -593,9 +610,7 @@ nautilus_directory_new (GFile *location) uri = g_file_get_uri (location); - if (eel_uri_is_desktop (uri)) { - type = NAUTILUS_TYPE_DESKTOP_DIRECTORY; - } else if (eel_uri_is_search (uri)) { + if (eel_uri_is_search (uri)) { type = NAUTILUS_TYPE_SEARCH_DIRECTORY; } else { type = NAUTILUS_TYPE_VFS_DIRECTORY; diff --git a/libnautilus-private/nautilus-directory.h b/libnautilus-private/nautilus-directory.h index de3c0d91d..3fa92f25e 100644 --- a/libnautilus-private/nautilus-directory.h +++ b/libnautilus-private/nautilus-directory.h @@ -238,6 +238,8 @@ gboolean nautilus_directory_is_editable (NautilusDirector void nautilus_directory_dump (NautilusDirectory *directory); +void nautilus_directory_add_to_cache (NautilusDirectory *directory); + NautilusFile * nautilus_directory_new_file_from_filename (NautilusDirectory *directory, const char *filename, gboolean self_owned); |