summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarin Adler <darin@src.gnome.org>2000-08-14 23:45:21 +0000
committerDarin Adler <darin@src.gnome.org>2000-08-14 23:45:21 +0000
commit5baaa578051f2f1249a518c256d84d04f221011a (patch)
tree3139949fb03b25f6575af40503e931ad763913fe
parent925ddd403d4a4f4ed4042b4e1171ddefc9aa5257 (diff)
downloadnautilus-5baaa578051f2f1249a518c256d84d04f221011a.tar.gz
More prep work for the trash directory.
* libnautilus-extensions/Makefile.am: * libnautilus-extensions/nautilus-trash-directory.c: (nautilus_trash_directory_initialize_class), (nautilus_trash_directory_initialize), (nautilus_trash_directory_destroy): * libnautilus-extensions/nautilus-trash-directory.h: * libnautilus-extensions/nautilus-vfs-directory.c: (nautilus_vfs_directory_initialize_class), (nautilus_vfs_directory_initialize), (nautilus_vfs_directory_destroy): * libnautilus-extensions/nautilus-vfs-directory.h: Add subclasses for the trash and for general VFS directories. Using refactoring techniques to move code down into these subclasses. This is not intended to be a general framework, but should be good enough to handle both these cases. * libnautilus-extensions/nautilus-directory-async.c: (can_use_public_metafile), (metafile_read_check_for_directory), (metafile_read_failed), (metafile_read_start), (allow_metafile), (metafile_write_success_close_callback), (nautilus_metafile_write_start), (start_monitoring_file_list), (get_corresponding_file), (start_getting_file_info): * libnautilus-extensions/nautilus-directory-private.h: * libnautilus-extensions/nautilus-directory.c: (nautilus_directory_destroy), (make_uri_canonical), (nautilus_directory_get_internal), (nautilus_directory_get_uri), (construct_private_metafile_uri), (nautilus_directory_new), (nautilus_directory_is_local), (nautilus_directory_is_not_empty), (nautilus_self_check_directory): * libnautilus-extensions/nautilus-directory.h: * libnautilus-extensions/nautilus-file.c: (nautilus_file_get_internal), (nautilus_file_rename), (nautilus_file_get_gnome_vfs_uri), (nautilus_file_matches_uri), (nautilus_file_compare_by_name), (nautilus_file_compare_by_directory_name), (nautilus_file_compare_for_sort), (nautilus_file_get_uri), (nautilus_file_set_permissions), (nautilus_file_get_string_attribute), (nautilus_file_get_mime_type), (nautilus_file_is_in_trash), (nautilus_file_contains_text), (nautilus_file_get_directory_name), (nautilus_file_mark_gone), (nautilus_file_changed): * libnautilus-extensions/nautilus-file.h: Add code to handle case of directory that can't be handled by gnome-vfs. Mostly some NULL checks. Also renamed fields to make it clear that the text URI is the "real" one. Added code to handle the "gnome-trash:" and "trash:" schemes specially in the code to make URIs canonical. * libnautilus-extensions/nautilus-mime-actions.c: (get_mime_type_from_uri): Return "application/octet-stream" instead of NULL for unknown MIME type. * src/file-manager/fm-directory-view.c: (fm_directory_view_display_selection_info): Eliminated the nautilus_file_get_real_name call. * src/nautilus-switchable-navigation-bar.c: (nautilus_switchable_navigation_bar_set_location): Eliminated the nautilus_directory_is_search_directory call. * src/file-manager/fm-search-list-view.c: (real_adding_file): Fixed formatting mistake. * src/nautilus-view-frame.c: (set_up_for_new_location): Emit the title_changed signal for each change in location.
-rw-r--r--ChangeLog69
-rw-r--r--libnautilus-extensions/Makefile.am24
-rw-r--r--libnautilus-extensions/nautilus-directory-async.c73
-rw-r--r--libnautilus-extensions/nautilus-directory-private.h8
-rw-r--r--libnautilus-extensions/nautilus-directory.c150
-rw-r--r--libnautilus-extensions/nautilus-directory.h131
-rw-r--r--libnautilus-extensions/nautilus-file.c310
-rw-r--r--libnautilus-extensions/nautilus-file.h4
-rw-r--r--libnautilus-extensions/nautilus-mime-actions.c90
-rw-r--r--libnautilus-extensions/nautilus-trash-directory.c67
-rw-r--r--libnautilus-extensions/nautilus-trash-directory.h56
-rw-r--r--libnautilus-extensions/nautilus-vfs-directory.c67
-rw-r--r--libnautilus-extensions/nautilus-vfs-directory.h55
-rw-r--r--libnautilus-private/Makefile.am24
-rw-r--r--libnautilus-private/nautilus-directory-async.c73
-rw-r--r--libnautilus-private/nautilus-directory-private.h8
-rw-r--r--libnautilus-private/nautilus-directory.c150
-rw-r--r--libnautilus-private/nautilus-directory.h131
-rw-r--r--libnautilus-private/nautilus-file.c310
-rw-r--r--libnautilus-private/nautilus-file.h4
-rw-r--r--libnautilus-private/nautilus-mime-actions.c90
-rw-r--r--libnautilus-private/nautilus-trash-directory.c67
-rw-r--r--libnautilus-private/nautilus-trash-directory.h56
-rw-r--r--libnautilus-private/nautilus-vfs-directory.c67
-rw-r--r--libnautilus-private/nautilus-vfs-directory.h55
-rw-r--r--src/file-manager/fm-directory-view.c2
-rw-r--r--src/file-manager/fm-search-list-view.c3
-rw-r--r--src/nautilus-switchable-navigation-bar.c19
-rw-r--r--src/nautilus-view-frame.c1
29 files changed, 1319 insertions, 845 deletions
diff --git a/ChangeLog b/ChangeLog
index 1a5604979..f47b73d9a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,72 @@
+2000-08-14 Darin Adler <darin@eazel.com>
+
+ More prep work for the trash directory.
+
+ * libnautilus-extensions/Makefile.am:
+ * libnautilus-extensions/nautilus-trash-directory.c:
+ (nautilus_trash_directory_initialize_class),
+ (nautilus_trash_directory_initialize),
+ (nautilus_trash_directory_destroy):
+ * libnautilus-extensions/nautilus-trash-directory.h:
+ * libnautilus-extensions/nautilus-vfs-directory.c:
+ (nautilus_vfs_directory_initialize_class),
+ (nautilus_vfs_directory_initialize),
+ (nautilus_vfs_directory_destroy):
+ * libnautilus-extensions/nautilus-vfs-directory.h:
+ Add subclasses for the trash and for general VFS directories.
+ Using refactoring techniques to move code down into these
+ subclasses. This is not intended to be a general framework,
+ but should be good enough to handle both these cases.
+
+ * libnautilus-extensions/nautilus-directory-async.c:
+ (can_use_public_metafile), (metafile_read_check_for_directory),
+ (metafile_read_failed), (metafile_read_start), (allow_metafile),
+ (metafile_write_success_close_callback),
+ (nautilus_metafile_write_start), (start_monitoring_file_list),
+ (get_corresponding_file), (start_getting_file_info):
+ * libnautilus-extensions/nautilus-directory-private.h:
+ * libnautilus-extensions/nautilus-directory.c:
+ (nautilus_directory_destroy), (make_uri_canonical),
+ (nautilus_directory_get_internal), (nautilus_directory_get_uri),
+ (construct_private_metafile_uri), (nautilus_directory_new),
+ (nautilus_directory_is_local), (nautilus_directory_is_not_empty),
+ (nautilus_self_check_directory):
+ * libnautilus-extensions/nautilus-directory.h:
+ * libnautilus-extensions/nautilus-file.c:
+ (nautilus_file_get_internal), (nautilus_file_rename),
+ (nautilus_file_get_gnome_vfs_uri), (nautilus_file_matches_uri),
+ (nautilus_file_compare_by_name),
+ (nautilus_file_compare_by_directory_name),
+ (nautilus_file_compare_for_sort), (nautilus_file_get_uri),
+ (nautilus_file_set_permissions),
+ (nautilus_file_get_string_attribute),
+ (nautilus_file_get_mime_type), (nautilus_file_is_in_trash),
+ (nautilus_file_contains_text), (nautilus_file_get_directory_name),
+ (nautilus_file_mark_gone), (nautilus_file_changed):
+ * libnautilus-extensions/nautilus-file.h:
+ Add code to handle case of directory that can't be handled by
+ gnome-vfs. Mostly some NULL checks. Also renamed fields to make
+ it clear that the text URI is the "real" one. Added code to
+ handle the "gnome-trash:" and "trash:" schemes specially in the
+ code to make URIs canonical.
+
+ * libnautilus-extensions/nautilus-mime-actions.c:
+ (get_mime_type_from_uri): Return "application/octet-stream"
+ instead of NULL for unknown MIME type.
+
+ * src/file-manager/fm-directory-view.c:
+ (fm_directory_view_display_selection_info): Eliminated the
+ nautilus_file_get_real_name call.
+ * src/nautilus-switchable-navigation-bar.c:
+ (nautilus_switchable_navigation_bar_set_location): Eliminated
+ the nautilus_directory_is_search_directory call.
+
+ * src/file-manager/fm-search-list-view.c: (real_adding_file):
+ Fixed formatting mistake.
+
+ * src/nautilus-view-frame.c: (set_up_for_new_location): Emit
+ the title_changed signal for each change in location.
+
2000-08-14 Gene Z. Ragan <gzr@eazel.com>
* libnautilus-extensions/nautilus-icon-container.c:
diff --git a/libnautilus-extensions/Makefile.am b/libnautilus-extensions/Makefile.am
index 753910af6..8a66c98e7 100644
--- a/libnautilus-extensions/Makefile.am
+++ b/libnautilus-extensions/Makefile.am
@@ -98,6 +98,7 @@ libnautilus_extensions_la_SOURCES = \
nautilus-string-picker.c \
nautilus-string.c \
nautilus-text-caption.c \
+ nautilus-trash-directory.c \
nautilus-theme.c \
nautilus-undo-context.c \
nautilus-undo-manager.c \
@@ -105,6 +106,7 @@ libnautilus_extensions_la_SOURCES = \
nautilus-user-level-manager.c \
nautilus-view-identifier.c \
nautilus-volume-monitor.c \
+ nautilus-vfs-directory.c \
nautilus-xml-extensions.c \
$(NULL)
@@ -115,22 +117,23 @@ noinst_HEADERS = \
nautilus-background.h \
nautilus-bonobo-extensions.h \
nautilus-bookmark.h \
- nautilus-caption-table.h \
nautilus-caption.h \
+ nautilus-caption-table.h \
+ nautilus-cdrom-extensions.h \
nautilus-debug.h \
nautilus-default-file-icon.h \
nautilus-directory-background.h \
+ nautilus-directory.h \
nautilus-directory-metafile.h \
nautilus-directory-notify.h \
nautilus-directory-private.h \
- nautilus-directory.h \
nautilus-drag.h \
nautilus-entry.h \
nautilus-file-attributes.h \
nautilus-file-changes-queue.h \
+ nautilus-file.h \
nautilus-file-private.h \
nautilus-file-utilities.h \
- nautilus-file.h \
nautilus-font-factory.h \
nautilus-gdk-extensions.h \
nautilus-gdk-pixbuf-extensions.h \
@@ -149,10 +152,11 @@ noinst_HEADERS = \
nautilus-icon-private.h \
nautilus-icon-text-item.h \
nautilus-image.h \
+ nautilus-iso9660.h \
nautilus-keep-last-vertical-box.h \
nautilus-lib-self-check-functions.h \
- nautilus-link-set.h \
nautilus-link.h \
+ nautilus-link-set.h \
nautilus-list-column-title.h \
nautilus-list.h \
nautilus-metadata.h \
@@ -162,28 +166,28 @@ noinst_HEADERS = \
nautilus-preferences-box.h \
nautilus-preferences-dialog.h \
nautilus-preferences-group.h \
+ nautilus-preferences.h \
nautilus-preferences-item.h \
nautilus-preferences-pane.h \
- nautilus-preferences.h \
nautilus-program-chooser.h \
nautilus-program-choosing.h \
nautilus-radio-button-group.h \
nautilus-search-bar-criterion.h \
+ nautilus-search-bar-criterion-private.h \
nautilus-self-checks.h \
nautilus-stock-dialogs.h \
+ nautilus-string.h \
nautilus-string-list.h \
nautilus-string-picker.h \
- nautilus-string.h \
nautilus-text-caption.h \
nautilus-theme.h \
+ nautilus-trash-directory.h \
nautilus-undo-context.h \
nautilus-undo-manager.h \
nautilus-undo-signal-handlers.h \
nautilus-user-level-manager.h \
+ nautilus-vfs-directory.h \
nautilus-view-identifier.h \
- nautilus-xml-extensions.h \
- nautilus-cdrom-extensions.h \
- nautilus-iso9660.h \
- nautilus-search-bar-criterion-private.h \
nautilus-volume-monitor.h \
+ nautilus-xml-extensions.h \
$(NULL)
diff --git a/libnautilus-extensions/nautilus-directory-async.c b/libnautilus-extensions/nautilus-directory-async.c
index f7a115041..6b6b8df9b 100644
--- a/libnautilus-extensions/nautilus-directory-async.c
+++ b/libnautilus-extensions/nautilus-directory-async.c
@@ -197,6 +197,10 @@ can_use_public_metafile (NautilusDirectory *directory)
g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), FALSE);
+ if (directory->details->public_metafile_vfs_uri == NULL) {
+ return FALSE;
+ }
+
preference_value = nautilus_preferences_get_enum
(NAUTILUS_PREFERENCES_USE_PUBLIC_METADATA,
NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY);
@@ -270,9 +274,15 @@ static void
metafile_read_check_for_directory (NautilusDirectory *directory)
{
GList fake_list;
+
+ /* We only get here if the public metafile is in question,
+ * which in turn only happens if the URI is one that gnome-vfs
+ * can handle.
+ */
+ g_assert (directory->details->vfs_uri != NULL);
/* We have to do a get_info call to check if this a directory. */
- fake_list.data = directory->details->uri;
+ fake_list.data = directory->details->vfs_uri;
fake_list.next = NULL;
fake_list.prev = NULL;
gnome_vfs_async_get_file_info
@@ -301,7 +311,7 @@ metafile_read_failed (NautilusDirectory *directory)
*/
/* First, check if we already know if it a directory. */
- file = nautilus_file_get (directory->details->uri_text);
+ file = nautilus_file_get (directory->details->uri);
if (file == NULL || file->details->is_gone) {
need_directory_check = FALSE;
is_directory = FALSE;
@@ -374,8 +384,8 @@ metafile_read_start (NautilusDirectory *directory)
text_uri = gnome_vfs_uri_to_string
(directory->details->metafile_read_state->use_public_metafile
- ? directory->details->public_metafile_uri
- : directory->details->private_metafile_uri,
+ ? directory->details->public_metafile_vfs_uri
+ : directory->details->private_metafile_vfs_uri,
GNOME_VFS_URI_HIDE_NONE);
directory->details->metafile_read_state->handle = nautilus_read_entire_file_async
@@ -387,7 +397,9 @@ metafile_read_start (NautilusDirectory *directory)
static gboolean
allow_metafile (NautilusDirectory *directory)
{
- const char *scheme;
+ const char *uri;
+
+ g_assert (NAUTILUS_IS_DIRECTORY (directory));
/* Note that this inhibits both reading and writing metadata
* completely. In the future we may want to inhibit writing to
@@ -395,8 +407,6 @@ allow_metafile (NautilusDirectory *directory)
* metadata.
*/
- g_assert (NAUTILUS_IS_DIRECTORY (directory));
-
/* For now, hard-code these schemes. Perhaps we should
* hardcode the schemes that are good for metadata instead of
* the schemes that are bad for it.
@@ -405,13 +415,13 @@ allow_metafile (NautilusDirectory *directory)
* better way can wait until we have support for metadata
* access inside gnome-vfs.
*/
- scheme = gnome_vfs_uri_get_scheme (directory->details->uri);
- if (nautilus_strcasecmp (scheme, "info") == 0
- || nautilus_strcasecmp (scheme, "help") == 0
- || nautilus_strcasecmp (scheme, "man") == 0
- || nautilus_strcasecmp (scheme, "pipe") == 0
- || nautilus_strcasecmp (scheme, "search") == 0
- || nautilus_strcasecmp (scheme, "gnome-search") == 0) {
+ uri = directory->details->uri;
+ if (nautilus_istr_has_prefix (uri, "info:")
+ || nautilus_istr_has_prefix (uri, "help:")
+ || nautilus_istr_has_prefix (uri, "man:")
+ || nautilus_istr_has_prefix (uri, "pipe:")
+ || nautilus_istr_has_prefix (uri, "search:")
+ || nautilus_istr_has_prefix (uri, "gnome-search:")) {
return FALSE;
}
@@ -498,7 +508,7 @@ metafile_write_success_close_callback (GnomeVFSAsyncHandle *handle,
/* A synchronous unlink is OK here because the private
* metafiles are local, so an unlink is very fast.
*/
- gnome_vfs_unlink_from_uri (directory->details->private_metafile_uri);
+ gnome_vfs_unlink_from_uri (directory->details->private_metafile_vfs_uri);
}
metafile_write_done (directory);
@@ -561,8 +571,8 @@ nautilus_metafile_write_start (NautilusDirectory *directory)
gnome_vfs_async_create_uri
(&directory->details->metafile_write_state->handle,
directory->details->metafile_write_state->use_public_metafile
- ? directory->details->public_metafile_uri
- : directory->details->private_metafile_uri,
+ ? directory->details->public_metafile_vfs_uri
+ : directory->details->private_metafile_vfs_uri,
GNOME_VFS_OPEN_WRITE, FALSE, METAFILE_PERMISSIONS,
metafile_write_create_callback, directory);
}
@@ -1605,13 +1615,13 @@ start_monitoring_file_list (NautilusDirectory *directory)
mark_all_files_unconfirmed (directory);
- g_assert (directory->details->uri_text != NULL);
+ g_assert (directory->details->uri != NULL);
directory->details->directory_load_list_last_handled
= GNOME_VFS_DIRECTORY_LIST_POSITION_NONE;
gnome_vfs_async_load_directory
(&directory->details->directory_load_in_progress, /* handle */
- directory->details->uri_text, /* uri */
+ directory->details->uri, /* uri */
(GNOME_VFS_FILE_INFO_GET_MIME_TYPE /* options */
| GNOME_VFS_FILE_INFO_FOLLOW_LINKS),
NULL, /* sort_rules */
@@ -1650,7 +1660,7 @@ get_corresponding_file (NautilusDirectory *directory)
return file;
}
- return nautilus_file_get_existing (directory->details->uri_text);
+ return nautilus_file_get_existing (directory->details->uri);
}
void
@@ -2199,15 +2209,24 @@ start_getting_file_info (NautilusDirectory *directory)
}
/* Figure out which file to get file info for. */
- file = select_needy_file (directory, lacks_info, wants_info);
- if (file == NULL) {
- return;
- }
+ do {
+ file = select_needy_file (directory, lacks_info, wants_info);
+ if (file == NULL) {
+ return;
+ }
+
+ uri = nautilus_file_get_uri (file);
+ vfs_uri = gnome_vfs_uri_new (uri);
+ g_free (uri);
+
+ if (vfs_uri == NULL) {
+ file->details->get_info_failed = TRUE;
+ start_getting_file_info (directory);
+ }
+ } while (vfs_uri == NULL);
+ /* Found one we need to get the info for. */
directory->details->get_info_file = file;
- uri = nautilus_file_get_uri (file);
- vfs_uri = gnome_vfs_uri_new (uri);
- g_free (uri);
fake_list.data = vfs_uri;
fake_list.prev = NULL;
fake_list.next = NULL;
diff --git a/libnautilus-extensions/nautilus-directory-private.h b/libnautilus-extensions/nautilus-directory-private.h
index 8f1f5d679..77ac9bf0d 100644
--- a/libnautilus-extensions/nautilus-directory-private.h
+++ b/libnautilus-extensions/nautilus-directory-private.h
@@ -41,10 +41,10 @@ typedef struct TopLeftTextReadState TopLeftTextReadState;
struct NautilusDirectoryDetails
{
/* The location. */
- char *uri_text;
- GnomeVFSURI *uri;
- GnomeVFSURI *private_metafile_uri;
- GnomeVFSURI *public_metafile_uri;
+ char *uri;
+ GnomeVFSURI *vfs_uri;
+ GnomeVFSURI *private_metafile_vfs_uri;
+ GnomeVFSURI *public_metafile_vfs_uri;
/* The file objects. */
NautilusFile *as_file;
diff --git a/libnautilus-extensions/nautilus-directory.c b/libnautilus-extensions/nautilus-directory.c
index d600be4b0..b1ddb61c2 100644
--- a/libnautilus-extensions/nautilus-directory.c
+++ b/libnautilus-extensions/nautilus-directory.c
@@ -33,6 +33,8 @@
#include "nautilus-gtk-macros.h"
#include "nautilus-lib-self-check-functions.h"
#include "nautilus-string.h"
+#include "nautilus-trash-directory.h"
+#include "nautilus-vfs-directory.h"
#include <ctype.h>
#include <gtk/gtkmain.h>
#include <gtk/gtksignal.h>
@@ -60,7 +62,6 @@ static guint signals[LAST_SIGNAL];
static GHashTable *directories;
-static GnomeVFSURI * construct_private_metafile_uri (GnomeVFSURI *uri);
static void nautilus_directory_destroy (GtkObject *object);
static void nautilus_directory_initialize (gpointer object,
gpointer klass);
@@ -166,16 +167,20 @@ nautilus_directory_destroy (GtkObject *object)
nautilus_g_list_free_deep (directory->details->monitor_list);
}
- g_hash_table_remove (directories, directory->details->uri_text);
+ g_hash_table_remove (directories, directory->details->uri);
if (directory->details->dequeue_pending_idle_id != 0) {
gtk_idle_remove (directory->details->dequeue_pending_idle_id);
}
- g_free (directory->details->uri_text);
- gnome_vfs_uri_unref (directory->details->uri);
- gnome_vfs_uri_unref (directory->details->private_metafile_uri);
- gnome_vfs_uri_unref (directory->details->public_metafile_uri);
+ g_free (directory->details->uri);
+ gnome_vfs_uri_unref (directory->details->private_metafile_vfs_uri);
+ if (directory->details->vfs_uri != NULL) {
+ gnome_vfs_uri_unref (directory->details->vfs_uri);
+ }
+ if (directory->details->public_metafile_vfs_uri != NULL) {
+ gnome_vfs_uri_unref (directory->details->public_metafile_vfs_uri);
+ }
g_assert (directory->details->files == NULL);
nautilus_directory_metafile_destroy (directory);
g_assert (directory->details->directory_load_in_progress == NULL);
@@ -195,6 +200,14 @@ make_uri_canonical (const char *uri)
size_t length;
char *canonical_uri, *old_uri, *with_slashes, *p;
+ /* Convert "gnome-trash:<anything>" and "trash:<anything>" to
+ * "gnome-trash:<anything>".
+ */
+ if (nautilus_istr_has_prefix (uri, "trash:")
+ || nautilus_istr_has_prefix (uri, "gnome-trash:")) {
+ return g_strdup ("gnome-trash:");
+ }
+
/* FIXME bugzilla.eazel.com 648:
* This currently ignores the issue of two uris that are not identical but point
* to the same data except for the specific cases of trailing '/' characters,
@@ -317,11 +330,11 @@ nautilus_directory_get_internal (const char *uri, gboolean create)
return NULL;
}
- g_assert (strcmp (directory->details->uri_text, canonical_uri) == 0);
+ g_assert (strcmp (directory->details->uri, canonical_uri) == 0);
/* Put it in the hash table. */
g_hash_table_insert (directories,
- directory->details->uri_text,
+ directory->details->uri,
directory);
}
@@ -347,7 +360,7 @@ nautilus_directory_get_uri (NautilusDirectory *directory)
{
g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), NULL);
- return g_strdup (directory->details->uri_text);
+ return g_strdup (directory->details->uri);
}
static GnomeVFSResult
@@ -387,21 +400,21 @@ nautilus_make_directory_and_parents (GnomeVFSURI *uri, guint permissions)
}
static GnomeVFSURI *
-construct_private_metafile_uri (GnomeVFSURI *uri)
+construct_private_metafile_uri (const char *uri)
{
GnomeVFSResult result;
- GnomeVFSURI *nautilus_directory_uri, *metafiles_directory_uri, *alternate_uri;
- char *uri_as_string, *escaped_uri, *file_name;
char *user_directory;
+ GnomeVFSURI *user_directory_uri, *metafiles_directory_uri, *alternate_uri;
+ char *escaped_uri, *file_name;
/* Ensure that the metafiles directory exists. */
user_directory = nautilus_get_user_directory ();
- nautilus_directory_uri = gnome_vfs_uri_new (user_directory);
+ user_directory_uri = gnome_vfs_uri_new (user_directory);
g_free (user_directory);
- metafiles_directory_uri = gnome_vfs_uri_append_file_name (nautilus_directory_uri,
+ metafiles_directory_uri = gnome_vfs_uri_append_file_name (user_directory_uri,
METAFILES_DIRECTORY_NAME);
- gnome_vfs_uri_unref (nautilus_directory_uri);
+ gnome_vfs_uri_unref (user_directory_uri);
result = nautilus_make_directory_and_parents (metafiles_directory_uri,
METAFILES_DIRECTORY_PERMISSIONS);
if (result != GNOME_VFS_OK && result != GNOME_VFS_ERROR_FILE_EXISTS) {
@@ -410,9 +423,7 @@ construct_private_metafile_uri (GnomeVFSURI *uri)
}
/* Construct a file name from the URI. */
- uri_as_string = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE);
- escaped_uri = nautilus_str_escape_slashes (uri_as_string);
- g_free (uri_as_string);
+ escaped_uri = nautilus_str_escape_slashes (uri);
file_name = g_strconcat (escaped_uri, ".xml", NULL);
g_free (escaped_uri);
@@ -425,27 +436,27 @@ construct_private_metafile_uri (GnomeVFSURI *uri)
}
static NautilusDirectory *
-nautilus_directory_new (const char* uri)
+nautilus_directory_new (const char *uri)
{
NautilusDirectory *directory;
GnomeVFSURI *vfs_uri;
- GnomeVFSURI *private_metafile_uri;
- GnomeVFSURI *public_metafile_uri;
- vfs_uri = gnome_vfs_uri_new (uri);
- if (vfs_uri == NULL) {
- return NULL;
+ g_assert (uri != NULL);
+
+ if (strcmp (uri, "gnome-trash:") == 0) {
+ directory = NAUTILUS_DIRECTORY (gtk_type_new (NAUTILUS_TYPE_TRASH_DIRECTORY));
+ } else {
+ directory = NAUTILUS_DIRECTORY (gtk_type_new (NAUTILUS_TYPE_VFS_DIRECTORY));
}
- private_metafile_uri = construct_private_metafile_uri (vfs_uri);
- public_metafile_uri = gnome_vfs_uri_append_file_name (vfs_uri, METAFILE_NAME);
+ directory->details->uri = g_strdup (uri);
+ directory->details->private_metafile_vfs_uri = construct_private_metafile_uri (uri);
- directory = gtk_type_new (NAUTILUS_TYPE_DIRECTORY);
+ vfs_uri = gnome_vfs_uri_new (uri);
- directory->details->uri_text = g_strdup (uri);
- directory->details->uri = vfs_uri;
- directory->details->private_metafile_uri = private_metafile_uri;
- directory->details->public_metafile_uri = public_metafile_uri;
+ directory->details->vfs_uri = vfs_uri;
+ directory->details->public_metafile_vfs_uri = vfs_uri == NULL ? NULL
+ : gnome_vfs_uri_append_file_name (vfs_uri, METAFILE_NAME);
return directory;
}
@@ -455,53 +466,10 @@ nautilus_directory_is_local (NautilusDirectory *directory)
{
g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), FALSE);
- return gnome_vfs_uri_is_local (directory->details->uri);
-}
-
-/* FIXME: I think this should be named _is_virtual_directory. */
-gboolean
-nautilus_directory_is_search_directory (NautilusDirectory *directory)
-{
- if (directory == NULL) {
- return FALSE;
+ if (directory->details->vfs_uri == NULL) {
+ return TRUE;
}
-
- g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), FALSE);
-
- /* Two hard-coded schemes for now. */
- /* FIXME: Later we gnome-vfs will tell us somehow that this is
- * a virtual directory.
- */
- return nautilus_istr_has_prefix (directory->details->uri_text, "search:")
- || nautilus_istr_has_prefix (directory->details->uri_text, "gnome-search:");
-
-#if 0
- GnomeVFSFileInfo *info;
- gboolean is_search_directory;
- GnomeVFSResult result;
-
- info = gnome_vfs_file_info_new ();
-
- g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), FALSE);
-
- /* FIXME bugzilla.eazel.com 1263: We can't just do sync. I/O
- * here! The model is that get_ functions in
- * NautilusDirectory/File are supposed to do no I/O. The
- * aforementioned bug talks about this a bit.
- */
- /* FIXME bugzilla.eazel.com 1263: Should make use of some sort
- * of NautilusDirectory cover for getting the mime type.
- */
- result = gnome_vfs_get_file_info_uri (directory->details->uri,
- info,
- GNOME_VFS_FILE_INFO_GET_MIME_TYPE);
- is_search_directory = result == GNOME_VFS_OK &&
- nautilus_strcasecmp (info->mime_type, "x-directory/search") == 0;
-
- gnome_vfs_file_info_unref (info);
-
- return is_search_directory;
-#endif
+ return gnome_vfs_uri_is_local (directory->details->vfs_uri);
}
gboolean
@@ -576,7 +544,6 @@ nautilus_directory_emit_done_loading (NautilusDirectory *directory)
signals[DONE_LOADING]);
}
-
static char *
uri_get_directory_part (const char *uri)
{
@@ -1016,7 +983,7 @@ any_non_metafile_item (gconstpointer item, gconstpointer callback_data)
gboolean
nautilus_directory_is_not_empty (NautilusDirectory *directory)
{
- char *public_metafile_uri_string;
+ char *public_metafile_uri;
gboolean not_empty;
g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), FALSE);
@@ -1024,16 +991,20 @@ nautilus_directory_is_not_empty (NautilusDirectory *directory)
/* Directory must be monitored for this call to be correct. */
g_return_val_if_fail (nautilus_directory_is_file_list_monitored (directory), FALSE);
- public_metafile_uri_string = gnome_vfs_uri_to_string
- (directory->details->public_metafile_uri,
- GNOME_VFS_URI_HIDE_NONE);
-
- /* Return TRUE if the directory contains anything besides a metafile. */
- not_empty = g_list_find_custom (directory->details->files,
- public_metafile_uri_string,
- any_non_metafile_item) != NULL;
-
- g_free (public_metafile_uri_string);
+ if (directory->details->public_metafile_vfs_uri == NULL) {
+ not_empty = directory->details->files != NULL;
+ } else {
+ public_metafile_uri = gnome_vfs_uri_to_string
+ (directory->details->public_metafile_vfs_uri,
+ GNOME_VFS_URI_HIDE_NONE);
+
+ /* Return TRUE if the directory contains anything besides a metafile. */
+ not_empty = g_list_find_custom (directory->details->files,
+ public_metafile_uri,
+ any_non_metafile_item) != NULL;
+
+ g_free (public_metafile_uri);
+ }
return not_empty;
}
@@ -1194,6 +1165,7 @@ nautilus_self_check_directory (void)
NAUTILUS_CHECK_STRING_RESULT (make_uri_canonical (""), "file:");
NAUTILUS_CHECK_STRING_RESULT (make_uri_canonical ("file:/"), "file:///");
NAUTILUS_CHECK_STRING_RESULT (make_uri_canonical ("file:///"), "file:///");
+ NAUTILUS_CHECK_STRING_RESULT (make_uri_canonical ("TRASH:XXX"), "gnome-trash:");
}
#endif /* !NAUTILUS_OMIT_SELF_CHECK */
diff --git a/libnautilus-extensions/nautilus-directory.h b/libnautilus-extensions/nautilus-directory.h
index 7abf9e41e..95fb68589 100644
--- a/libnautilus-extensions/nautilus-directory.h
+++ b/libnautilus-extensions/nautilus-directory.h
@@ -42,9 +42,6 @@
information available from other means.
*/
-typedef struct NautilusDirectory NautilusDirectory;
-typedef struct NautilusDirectoryClass NautilusDirectoryClass;
-
#define NAUTILUS_TYPE_DIRECTORY \
(nautilus_directory_get_type ())
#define NAUTILUS_DIRECTORY(obj) \
@@ -62,10 +59,78 @@ typedef struct NautilusDirectoryClass NautilusDirectoryClass;
typedef struct NautilusFile NautilusFile;
#endif
+typedef struct NautilusDirectoryDetails NautilusDirectoryDetails;
+
+typedef struct
+{
+ GtkObject object;
+ NautilusDirectoryDetails *details;
+} NautilusDirectory;
+
typedef void (*NautilusDirectoryCallback) (NautilusDirectory *directory,
GList *files,
gpointer callback_data);
+typedef struct
+{
+ GtkObjectClass parent_class;
+
+ /*** Notification signals for clients to connect to. ***/
+
+ /* The files_added signal is emitted as the directory model
+ * discovers new files.
+ */
+ void (* files_added) (NautilusDirectory *directory,
+ GList *added_files);
+
+ /* The files_changed signal is emitted as changes occur to
+ * existing files that are noticed by the synchronization framework,
+ * including when an old file has been deleted. When an old file
+ * has been deleted, this is the last chance to forget about these
+ * file objects, which are about to be unref'd. Use a call to
+ * nautilus_file_is_gone () to test for this case.
+ */
+ void (* files_changed) (NautilusDirectory *directory,
+ GList *changed_files);
+
+ /* The metadata_changed signal is emitted when changes to the metadata
+ * for the directory itself are made. Changes to file metadata just
+ * result in calls to files_changed.
+ */
+ void (* metadata_changed) (NautilusDirectory *directory);
+
+ /* The done_loading signal is emitted when a directory load
+ * request completes. This is needed because, at least in the
+ * case where the directory is empty, the caller will receive
+ * no kind of notification at all when a directory load
+ * initiated by `nautilus_directory_file_monitor_add' completes.
+ */
+ void (* done_loading) (NautilusDirectory *directory);
+
+ /*** Virtual functions for subclasses to override. ***/
+ gboolean (* contains_file) (NautilusDirectory *directory,
+ NautilusFile *file);
+ void (* call_when_ready) (NautilusDirectory *directory,
+ GList *file_attributes,
+ gboolean wait_for_metadata,
+ NautilusDirectoryCallback callback,
+ gpointer callback_data);
+ void (* cancel_callback) (NautilusDirectory *directory,
+ NautilusDirectoryCallback callback,
+ gpointer callback_data);
+ void (* file_monitor_add) (NautilusDirectory *directory,
+ gconstpointer client,
+ GList *monitor_attributes,
+ gboolean monitor_metadata,
+ gboolean force_reload,
+ NautilusDirectoryCallback initial_files_callback,
+ gpointer callback_data);
+ void (* file_monitor_remove) (NautilusDirectory *directory,
+ gconstpointer client);
+ gboolean (* are_all_files_seen) (NautilusDirectory *directory);
+ gboolean (* is_not_empty) (NautilusDirectory *directory);
+} NautilusDirectoryClass;
+
/* Basic GtkObject requirements. */
GtkType nautilus_directory_get_type (void);
@@ -152,68 +217,12 @@ void nautilus_directory_file_monitor_remove (NautilusDirectory
*/
gboolean nautilus_directory_are_all_files_seen (NautilusDirectory *directory);
-/* Return true if the directory metadata has been loaded.
- * Until this is true, get_metadata calls will return defaults.
- * (We could have another way to indicate "don't know".)
- */
-gboolean nautilus_directory_metadata_loaded (NautilusDirectory *directory);
-
/* Return true if the directory is local. */
gboolean nautilus_directory_is_local (NautilusDirectory *directory);
-gboolean nautilus_directory_is_search_directory (NautilusDirectory *directory);
-
-/* Return false if directory contains anything besides a nautilus metafile.
- * Only valid if directory is monitored.
- * Used by the Trash monitor
+/* Return false if directory contains anything besides a Nautilus metafile.
+ * Only valid if directory is monitored. Used by the Trash monitor.
*/
gboolean nautilus_directory_is_not_empty (NautilusDirectory *directory);
-typedef struct NautilusDirectoryDetails NautilusDirectoryDetails;
-
-struct NautilusDirectory
-{
- GtkObject object;
- NautilusDirectoryDetails *details;
-};
-
-struct NautilusDirectoryClass
-{
- GtkObjectClass parent_class;
-
- /*** Notification signals for clients to connect to. ***/
-
- /* The files_added signal is emitted as the directory model
- * discovers new files.
- */
- void (* files_added) (NautilusDirectory *directory,
- GList *added_files);
-
- /* The files_changed signal is emitted as changes occur to
- * existing files that are noticed by the synchronization framework,
- * including when an old file has been deleted. When an old file
- * has been deleted, this is the last chance to forget about these
- * file objects, which are about to be unref'd. Use a call to
- * nautilus_file_is_gone () to test for this case.
- */
- void (* files_changed) (NautilusDirectory *directory,
- GList *changed_files);
-
- /* The metadata_changed signal is emitted when changes to the metadata
- * for the directory itself are made. Changes to file metadata just
- * result in calls to files_changed.
- */
- void (* metadata_changed) (NautilusDirectory *directory);
-
-
- /* The done_loading signal is emitted when a directory load
- * request completes. This is needed because, at least in the
- * case where the directory is empty, the caller will receive
- * no kind of notification at all when a directory load
- * initiated by `nautilus_directory_file_monitor_add' completes.
- */
-
- void (* done_loading) (NautilusDirectory *directory);
-};
-
#endif /* NAUTILUS_DIRECTORY_H */
diff --git a/libnautilus-extensions/nautilus-file.c b/libnautilus-extensions/nautilus-file.c
index 1343be088..f2ec39b8d 100644
--- a/libnautilus-extensions/nautilus-file.c
+++ b/libnautilus-extensions/nautilus-file.c
@@ -67,9 +67,9 @@ static GHashTable *symbolic_links;
static void nautilus_file_initialize_class (NautilusFileClass *klass);
static void nautilus_file_initialize (NautilusFile *file);
static void destroy (GtkObject *object);
-static int nautilus_file_compare_by_real_name (NautilusFile *file_1,
+static int nautilus_file_compare_by_name (NautilusFile *file_1,
NautilusFile *file_2);
-static int nautilus_file_compare_by_real_directory (NautilusFile *file_1,
+static int nautilus_file_compare_by_directory_name (NautilusFile *file_1,
NautilusFile *file_2);
static int nautilus_file_compare_by_emblems (NautilusFile *file_1,
NautilusFile *file_2);
@@ -82,7 +82,7 @@ static char *nautilus_file_get_owner_as_string (NautilusFile *file
static char *nautilus_file_get_permissions_as_string (NautilusFile *file);
static char *nautilus_file_get_size_as_string (NautilusFile *file);
static char *nautilus_file_get_type_as_string (NautilusFile *file);
-static char *nautilus_file_get_real_directory (NautilusFile *file);
+static char *nautilus_file_get_directory_name (NautilusFile *file);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusFile, nautilus_file, GTK_TYPE_OBJECT)
@@ -252,19 +252,17 @@ nautilus_file_get_internal (const char *uri, gboolean create)
GnomeVFSURI *vfs_uri, *directory_vfs_uri;
char *directory_uri;
NautilusDirectory *directory;
- char *file_name_escaped, *file_name;
+ char *file_name_escaped, *file_name, *colon;
NautilusFile *file;
g_return_val_if_fail (uri != NULL, NULL);
/* Make VFS version of URI. */
vfs_uri = gnome_vfs_uri_new (uri);
- if (vfs_uri == NULL) {
- return NULL;
- }
/* Make VFS version of directory URI. */
- directory_vfs_uri = gnome_vfs_uri_get_parent (vfs_uri);
+ directory_vfs_uri = vfs_uri == NULL ? NULL
+ : gnome_vfs_uri_get_parent (vfs_uri);
self_owned = directory_vfs_uri == NULL;
if (self_owned) {
/* Use the item itself if we have no parent. */
@@ -280,24 +278,41 @@ nautilus_file_get_internal (const char *uri, gboolean create)
/* Get object that represents the directory. */
directory = nautilus_directory_get_internal (directory_uri, create);
g_free (directory_uri);
- if (directory == NULL) {
+
+ /* Get the name for the file. */
+ if (vfs_uri == NULL) {
+ g_assert (self_owned);
+ if (directory == NULL) {
+ file_name = NULL;
+ } else {
+ /* Name is URI (from directory in case it's
+ * made canonical), but scheme part only if
+ * it's there.
+ */
+ directory_uri = directory->details->uri;
+ colon = strchr (directory_uri, ':');
+ if (colon == NULL) {
+ file_name = g_strdup (directory_uri);
+ } else {
+ file_name = g_strndup (directory_uri,
+ colon - directory_uri);
+ }
+ }
+ } else {
+ file_name_escaped = gnome_vfs_uri_extract_short_path_name (vfs_uri);
gnome_vfs_uri_unref (vfs_uri);
- return NULL;
+ file_name = gnome_vfs_unescape_string (file_name_escaped, NULL);
+ g_free (file_name_escaped);
}
/* Check to see if it's a file that's already known. */
- file_name_escaped = gnome_vfs_uri_extract_short_path_name (vfs_uri);
- gnome_vfs_uri_unref (vfs_uri);
- file_name = gnome_vfs_unescape_string (file_name_escaped, NULL);
- g_free (file_name_escaped);
- if (file_name == NULL) {
- return NULL;
- }
if (self_owned) {
- file = directory->details->as_file;
+ file = directory == NULL ? NULL : directory->details->as_file;
} else {
file = nautilus_directory_find_file (directory, file_name);
}
+
+ /* Ref or create the file. */
if (file != NULL) {
nautilus_file_ref (file);
} else if (create) {
@@ -310,10 +325,10 @@ nautilus_file_get_internal (const char *uri, gboolean create)
g_list_prepend (directory->details->files, file);
}
}
- g_free (file_name);
+ g_free (file_name);
nautilus_directory_unref (directory);
-
+
return file;
}
@@ -777,7 +792,7 @@ nautilus_file_rename (NautilusFile *file,
NautilusFileOperationCallback callback,
gpointer callback_data)
{
- char *directory_uri_text;
+ char *directory_uri;
GList *source_name_list, *target_name_list;
GnomeVFSResult result;
Operation *op;
@@ -836,19 +851,19 @@ nautilus_file_rename (NautilusFile *file,
/* FIXME: This call could use gnome_vfs_async_set_file_info
* instead and it might be simpler.
*/
- directory_uri_text = nautilus_directory_get_uri (file->details->directory);
+ directory_uri = nautilus_directory_get_uri (file->details->directory);
source_name_list = g_list_prepend (NULL, file->details->name);
target_name_list = g_list_prepend (NULL, (char *) new_name);
result = gnome_vfs_async_xfer
(&op->handle,
- directory_uri_text, source_name_list,
- directory_uri_text, target_name_list,
+ directory_uri, source_name_list,
+ directory_uri, target_name_list,
GNOME_VFS_XFER_SAMEFS | GNOME_VFS_XFER_REMOVESOURCE,
GNOME_VFS_XFER_ERROR_MODE_QUERY,
GNOME_VFS_XFER_OVERWRITE_MODE_ABORT,
rename_callback, op,
NULL, NULL);
- g_free (directory_uri_text);
+ g_free (directory_uri);
g_list_free (source_name_list);
g_list_free (target_name_list);
@@ -880,35 +895,48 @@ nautilus_file_cancel (NautilusFile *file,
static GnomeVFSURI *
nautilus_file_get_gnome_vfs_uri (NautilusFile *file)
{
+ GnomeVFSURI *vfs_uri;
+
+ vfs_uri = file->details->directory->details->vfs_uri;
+ if (vfs_uri == NULL) {
+ return NULL;
+ }
+
if (nautilus_file_is_self_owned (file)) {
- gnome_vfs_uri_ref (file->details->directory->details->uri);
- return file->details->directory->details->uri;
+ gnome_vfs_uri_ref (vfs_uri);
+ return vfs_uri;
}
return gnome_vfs_uri_append_file_name
- (file->details->directory->details->uri,
- file->details->name);
+ (vfs_uri, file->details->name);
}
gboolean
-nautilus_file_matches_uri (NautilusFile *file, const char *uri_string)
+nautilus_file_matches_uri (NautilusFile *file, const char *match_uri)
{
- GnomeVFSURI *match_uri;
- GnomeVFSURI *file_uri;
+ GnomeVFSURI *match_vfs_uri, *file_vfs_uri;
+ char *file_uri;
gboolean result;
g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
- g_return_val_if_fail (uri_string != NULL, FALSE);
+ g_return_val_if_fail (match_uri != NULL, FALSE);
- match_uri = gnome_vfs_uri_new (uri_string);
- if (match_uri == NULL) {
- return FALSE;
+ match_vfs_uri = gnome_vfs_uri_new (match_uri);
+ file_vfs_uri = nautilus_file_get_gnome_vfs_uri (file);
+
+ if (match_vfs_uri == NULL || file_vfs_uri == NULL) {
+ file_uri = nautilus_file_get_uri (file);
+ result = strcmp (match_uri, file_uri) == 0;
+ } else {
+ result = gnome_vfs_uri_equal (file_vfs_uri, match_vfs_uri);
}
- file_uri = nautilus_file_get_gnome_vfs_uri (file);
- result = gnome_vfs_uri_equal (file_uri, match_uri);
- gnome_vfs_uri_unref (file_uri);
- gnome_vfs_uri_unref (match_uri);
+ if (file_vfs_uri != NULL) {
+ gnome_vfs_uri_unref (file_vfs_uri);
+ }
+ if (match_vfs_uri != NULL) {
+ gnome_vfs_uri_unref (match_vfs_uri);
+ }
return result;
}
@@ -1149,14 +1177,14 @@ compare_emblem_names (const char *name_1, const char *name_2)
}
static int
-nautilus_file_compare_by_real_name (NautilusFile *file_1, NautilusFile *file_2)
+nautilus_file_compare_by_name (NautilusFile *file_1, NautilusFile *file_2)
{
char *name_1;
char *name_2;
int compare;
- name_1 = nautilus_file_get_real_name (file_1);
- name_2 = nautilus_file_get_real_name (file_2);
+ name_1 = nautilus_file_get_name (file_1);
+ name_2 = nautilus_file_get_name (file_2);
compare = nautilus_strcasecmp (name_1, name_2);
@@ -1167,25 +1195,21 @@ nautilus_file_compare_by_real_name (NautilusFile *file_1, NautilusFile *file_2)
}
static int
-nautilus_file_compare_by_real_directory (NautilusFile *file_1, NautilusFile *file_2)
+nautilus_file_compare_by_directory_name (NautilusFile *file_1, NautilusFile *file_2)
{
char *directory_1;
char *directory_2;
int compare;
- directory_1 = nautilus_file_get_real_directory (file_1);
- directory_2 = nautilus_file_get_real_directory (file_2);
+ directory_1 = nautilus_file_get_directory_name (file_1);
+ directory_2 = nautilus_file_get_directory_name (file_2);
compare = nautilus_strcasecmp (directory_1, directory_2);
g_free (directory_1);
g_free (directory_2);
- if (compare != 0) {
- return compare;
- }
-
- return nautilus_file_compare_by_real_name (file_1, file_2);
+ return compare;
}
static int
@@ -1304,17 +1328,17 @@ nautilus_file_compare_for_sort (NautilusFile *file_1,
* but I can imagine discussing this further.
* John Sullivan <sullivan@eazel.com>
*/
- compare = nautilus_file_compare_by_real_name (file_1, file_2);
+ compare = nautilus_file_compare_by_name (file_1, file_2);
if (compare != 0) {
return compare;
}
- return nautilus_file_compare_by_real_directory (file_1, file_2);
+ return nautilus_file_compare_by_directory_name (file_1, file_2);
case NAUTILUS_FILE_SORT_BY_DIRECTORY:
- compare = nautilus_file_compare_by_real_directory (file_1, file_2);
+ compare = nautilus_file_compare_by_directory_name (file_1, file_2);
if (compare != 0) {
return compare;
}
- return nautilus_file_compare_by_real_name (file_1, file_2);
+ return nautilus_file_compare_by_name (file_1, file_2);
case NAUTILUS_FILE_SORT_BY_SIZE:
/* Compare directory sizes ourselves, then if necessary
* use GnomeVFS to compare file sizes.
@@ -1559,19 +1583,26 @@ nautilus_file_get_activation_uri (NautilusFile *file)
char *
nautilus_file_get_uri (NautilusFile *file)
{
- GnomeVFSURI *uri;
- char *uri_text;
+ GnomeVFSURI *vfs_uri;
+ char *uri;
g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);
if (nautilus_file_is_self_owned (file)) {
- return g_strdup (file->details->directory->details->uri_text);
+ return g_strdup (file->details->directory->details->uri);
}
- uri = nautilus_file_get_gnome_vfs_uri (file);
- uri_text = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE);
- gnome_vfs_uri_unref (uri);
- return uri_text;
+ vfs_uri = nautilus_file_get_gnome_vfs_uri (file);
+ if (vfs_uri != NULL) {
+ uri = gnome_vfs_uri_to_string (vfs_uri, GNOME_VFS_URI_HIDE_NONE);
+ gnome_vfs_uri_unref (vfs_uri);
+ return uri;
+ }
+
+ return g_strconcat (file->details->directory->details->uri,
+ "/",
+ file->details->name,
+ NULL);
}
/**
@@ -1906,7 +1937,7 @@ nautilus_file_set_permissions (NautilusFile *file,
gpointer callback_data)
{
Operation *op;
- GnomeVFSURI *uri;
+ GnomeVFSURI *vfs_uri;
GnomeVFSFileInfo *partial_file_info;
if (!nautilus_file_can_set_permissions (file)) {
@@ -1935,14 +1966,14 @@ nautilus_file_set_permissions (NautilusFile *file,
/* Change the file-on-disk permissions. */
partial_file_info = gnome_vfs_file_info_new ();
partial_file_info->permissions = new_permissions;
- uri = nautilus_file_get_gnome_vfs_uri (file);
+ vfs_uri = nautilus_file_get_gnome_vfs_uri (file);
gnome_vfs_async_set_file_info (&op->handle,
- uri, partial_file_info,
+ vfs_uri, partial_file_info,
GNOME_VFS_SET_FILE_INFO_PERMISSIONS,
GNOME_VFS_FILE_INFO_DEFAULT,
set_permissions_callback, op);
gnome_vfs_file_info_unref (partial_file_info);
- gnome_vfs_uri_unref (uri);
+ gnome_vfs_uri_unref (vfs_uri);
}
static char *
@@ -2657,30 +2688,6 @@ nautilus_file_get_owner_as_string (NautilusFile *file, gboolean include_real_nam
return g_strdup_printf ("%d", file->details->info->uid);
}
-/**
- * nautilus_file_get_mime_type_as_string_attribute:
- *
- * Get a user-displayable string representing a file's MIME type.
- * This string will be displayed in file manager views and thus
- * will not be blank even if the MIME type is unknown. The caller
- * is responsible for g_free-ing this string.
- * @file: NautilusFile representing the file in question.
- *
- * Returns: Newly allocated string ready to display to the user.
- *
- **/
-static char *
-nautilus_file_get_mime_type_as_string_attribute (NautilusFile *file)
-{
- char *mime_string;
-
- mime_string = nautilus_file_get_mime_type (file);
- if (mime_string != NULL) {
- return mime_string;
- }
- return NULL;
-}
-
static char *
format_item_count_for_display (guint item_count,
gboolean includes_directories,
@@ -2902,7 +2909,7 @@ nautilus_file_get_string_attribute (NautilusFile *file, const char *attribute_na
*/
if (strcmp (attribute_name, "name") == 0) {
- return nautilus_file_get_real_name (file);
+ return nautilus_file_get_name (file);
}
if (strcmp (attribute_name, "type") == 0) {
@@ -2910,7 +2917,7 @@ nautilus_file_get_string_attribute (NautilusFile *file, const char *attribute_na
}
if (strcmp (attribute_name, "mime_type") == 0) {
- return nautilus_file_get_mime_type_as_string_attribute (file);
+ return nautilus_file_get_mime_type (file);
}
if (strcmp (attribute_name, "size") == 0) {
@@ -2978,7 +2985,7 @@ nautilus_file_get_string_attribute (NautilusFile *file, const char *attribute_na
}
if (strcmp (attribute_name, "directory") == 0) {
- return nautilus_file_get_real_directory (file);
+ return nautilus_file_get_directory_name (file);
}
return NULL;
@@ -3126,7 +3133,8 @@ char *
nautilus_file_get_mime_type (NautilusFile *file)
{
return info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_MIME_TYPE)
- ? NULL : g_strdup (file->details->info->mime_type);
+ ? g_strdup ("application/octet-stream")
+ : g_strdup (file->details->info->mime_type);
}
/**
@@ -3357,32 +3365,31 @@ nautilus_file_is_directory (NautilusFile *file)
gboolean
nautilus_file_is_in_trash (NautilusFile *file)
{
- GnomeVFSURI *file_uri, *trash_dir_uri;
- char *uri_string;
+ GnomeVFSURI *file_vfs_uri, *trash_vfs_uri;
gboolean result;
g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
- uri_string = nautilus_file_get_uri (file);
- file_uri = gnome_vfs_uri_new (uri_string);
- g_free (uri_string);
-
- /* Start with NULL so we don't try to unref uninitialized garbage later */
- trash_dir_uri = NULL;
-
- result = gnome_vfs_find_directory (file_uri, GNOME_VFS_DIRECTORY_KIND_TRASH,
- &trash_dir_uri, FALSE, FALSE, 0777) == GNOME_VFS_OK;
+ file_vfs_uri = nautilus_file_get_gnome_vfs_uri (file);
+ if (file_vfs_uri == NULL) {
+ return FALSE;
+ }
+ /* FIXME: Is it OK to do I/O here? Don't we need to keep a
+ * cached list of trash directories somewhere to guarantee we
+ * don't do sync. I/O in this case?
+ */
+ result = gnome_vfs_find_directory
+ (file_vfs_uri, GNOME_VFS_DIRECTORY_KIND_TRASH,
+ &trash_vfs_uri, FALSE, FALSE, 0777)
+ == GNOME_VFS_OK;
if (result) {
- result = (gnome_vfs_uri_equal (trash_dir_uri, file_uri)
- || gnome_vfs_uri_is_parent (trash_dir_uri, file_uri, TRUE));
+ result = gnome_vfs_uri_equal (trash_vfs_uri, file_vfs_uri)
+ || gnome_vfs_uri_is_parent (trash_vfs_uri, file_vfs_uri, TRUE);
+ gnome_vfs_uri_unref (trash_vfs_uri);
}
- if (trash_dir_uri) {
- gnome_vfs_uri_unref (trash_dir_uri);
- }
- gnome_vfs_uri_unref (file_uri);
-
+ gnome_vfs_uri_unref (file_vfs_uri);
return result;
}
@@ -3411,7 +3418,7 @@ nautilus_file_contains_text (NautilusFile *file)
mime_type = nautilus_file_get_mime_type (file);
contains_text = nautilus_istr_has_prefix (mime_type, "text/")
- || (mime_type == NULL
+ || (g_strcasecmp (mime_type, "application/octet-stream") == 0
&& nautilus_file_get_file_type (file) == GNOME_VFS_FILE_TYPE_REGULAR);
g_free (mime_type);
@@ -3474,84 +3481,25 @@ nautilus_file_get_top_left_text (NautilusFile *file)
return g_strdup (file->details->top_left_text);
}
-
-gboolean
-nautilus_file_is_search_result (NautilusFile *file)
-{
- if (file == NULL) {
- return FALSE;
- }
- g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
-
- if (file->details->directory == NULL) {
- return FALSE;
- }
- /* FIXME: Perhaps we should cache this value,
- since we check it a lot, and it doesn't change
- throughout a file's existence */
- return nautilus_directory_is_search_directory (file->details->directory);
-}
-
-char *
-nautilus_file_get_real_name (NautilusFile *file)
-{
- char *name;
- char *decoded_name;
- GnomeVFSURI *vfs_uri;
-
- if (file == NULL) {
- return NULL;
- }
- g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);
-
- name = nautilus_file_get_name (file);
-
- if (nautilus_file_is_search_result (file)) {
- decoded_name = gnome_vfs_unescape_string (name, NULL);
- g_free (name);
-
- vfs_uri = gnome_vfs_uri_new (decoded_name);
- /* FIXME: This can be NULL if the search result URI is bad.
- * I think a core dump is a bit too much here, so we might
- * have to add a bit more checking.
- */
- g_free (decoded_name);
- name = gnome_vfs_uri_extract_short_path_name (vfs_uri);
- gnome_vfs_uri_unref (vfs_uri);
- }
-
- return name;
-}
-
-
static char *
-nautilus_file_get_real_directory (NautilusFile *file)
+nautilus_file_get_directory_name (NautilusFile *file)
{
- char *escaped_uri;
- char *uri;
GnomeVFSURI *vfs_uri;
- char *dir;
+ char *directory_name;
if (file == NULL) {
return NULL;
}
g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);
- if (nautilus_file_is_search_result (file)) {
- escaped_uri = nautilus_file_get_name (file);
- uri = gnome_vfs_unescape_string (escaped_uri, NULL);
- g_free (escaped_uri);
-
- } else {
- uri = nautilus_file_get_uri (file);
+ vfs_uri = nautilus_file_get_gnome_vfs_uri (file);
+ if (vfs_uri == NULL) {
+ return NULL;
}
-
- vfs_uri = gnome_vfs_uri_new (uri);
- g_free (uri);
- dir = gnome_vfs_uri_extract_dirname (vfs_uri);
+ directory_name = gnome_vfs_uri_extract_dirname (vfs_uri);
gnome_vfs_uri_unref (vfs_uri);
- return dir;
+ return directory_name;
}
void
@@ -3577,8 +3525,6 @@ nautilus_file_mark_gone (NautilusFile *file)
}
/* Let the directory know it's gone. */
- /* FIXME: I think the real and the search directories need to
- know in the case of the file being in a search directory */
directory = file->details->directory;
if (directory->details->as_file != file) {
files = &directory->details->files;
@@ -3609,8 +3555,6 @@ nautilus_file_changed (NautilusFile *file)
fake_list.data = file;
fake_list.next = NULL;
fake_list.prev = NULL;
- /* FIXME: I think here for search directories we may need
- to notify both the real directory and the virtual directory */
nautilus_directory_emit_files_changed (file->details->directory, &fake_list);
}
}
diff --git a/libnautilus-extensions/nautilus-file.h b/libnautilus-extensions/nautilus-file.h
index 461b269f9..e4e1bb71c 100644
--- a/libnautilus-extensions/nautilus-file.h
+++ b/libnautilus-extensions/nautilus-file.h
@@ -142,10 +142,6 @@ GList * nautilus_file_get_emblem_names (NautilusFile
char * nautilus_file_get_top_left_text (NautilusFile *file);
-/* Attributes that behave specially for search results */
-gboolean nautilus_file_is_search_result (NautilusFile *file);
-char * nautilus_file_get_real_name (NautilusFile *file);
-
/* Permissions. */
gboolean nautilus_file_can_get_permissions (NautilusFile *file);
gboolean nautilus_file_can_set_permissions (NautilusFile *file);
diff --git a/libnautilus-extensions/nautilus-mime-actions.c b/libnautilus-extensions/nautilus-mime-actions.c
index 2731a4e27..da20596e3 100644
--- a/libnautilus-extensions/nautilus-mime-actions.c
+++ b/libnautilus-extensions/nautilus-mime-actions.c
@@ -424,9 +424,13 @@ nautilus_mime_get_short_list_applications_for_uri (const char *uri)
nautilus_directory_wait_for_metadata (directory);
metadata_application_add_ids = nautilus_directory_get_metadata_list
- (directory, NAUTILUS_METADATA_KEY_SHORT_LIST_APPLICATION_ADD, NAUTILUS_METADATA_SUBKEY_APPLICATION_ID);
+ (directory,
+ NAUTILUS_METADATA_KEY_SHORT_LIST_APPLICATION_ADD,
+ NAUTILUS_METADATA_SUBKEY_APPLICATION_ID);
metadata_application_remove_ids = nautilus_directory_get_metadata_list
- (directory, NAUTILUS_METADATA_KEY_SHORT_LIST_APPLICATION_REMOVE, NAUTILUS_METADATA_SUBKEY_APPLICATION_ID);
+ (directory,
+ NAUTILUS_METADATA_KEY_SHORT_LIST_APPLICATION_REMOVE,
+ NAUTILUS_METADATA_SUBKEY_APPLICATION_ID);
nautilus_directory_unref (directory);
mime_type = get_mime_type_from_uri (uri);
@@ -495,9 +499,13 @@ nautilus_mime_get_short_list_components_for_uri (const char *uri)
g_list_free (attributes);
metadata_component_add_ids = nautilus_directory_get_metadata_list
- (directory, NAUTILUS_METADATA_KEY_SHORT_LIST_COMPONENT_ADD, NAUTILUS_METADATA_SUBKEY_COMPONENT_IID);
+ (directory,
+ NAUTILUS_METADATA_KEY_SHORT_LIST_COMPONENT_ADD,
+ NAUTILUS_METADATA_SUBKEY_COMPONENT_IID);
metadata_component_remove_ids = nautilus_directory_get_metadata_list
- (directory, NAUTILUS_METADATA_KEY_SHORT_LIST_COMPONENT_REMOVE, NAUTILUS_METADATA_SUBKEY_COMPONENT_IID);
+ (directory,
+ NAUTILUS_METADATA_KEY_SHORT_LIST_COMPONENT_REMOVE,
+ NAUTILUS_METADATA_SUBKEY_COMPONENT_IID);
nautilus_directory_unref (directory);
mime_type = get_mime_type_from_uri (uri);
@@ -586,7 +594,9 @@ nautilus_mime_get_all_applications_for_uri (const char *uri)
nautilus_directory_wait_for_metadata (directory);
metadata_application_ids = nautilus_directory_get_metadata_list
- (directory, NAUTILUS_METADATA_KEY_EXPLICIT_APPLICATION, NAUTILUS_METADATA_SUBKEY_APPLICATION_ID);
+ (directory,
+ NAUTILUS_METADATA_KEY_EXPLICIT_APPLICATION,
+ NAUTILUS_METADATA_SUBKEY_APPLICATION_ID);
nautilus_directory_unref (directory);
mime_type = get_mime_type_from_uri (uri);
@@ -779,9 +789,15 @@ nautilus_mime_set_short_list_applications_for_uri (const char *uri,
nautilus_directory_wait_for_metadata (directory);
nautilus_directory_set_metadata_list
- (directory, NAUTILUS_METADATA_KEY_SHORT_LIST_APPLICATION_ADD, NAUTILUS_METADATA_SUBKEY_APPLICATION_ID, add_list);
+ (directory,
+ NAUTILUS_METADATA_KEY_SHORT_LIST_APPLICATION_ADD,
+ NAUTILUS_METADATA_SUBKEY_APPLICATION_ID,
+ add_list);
nautilus_directory_set_metadata_list
- (directory, NAUTILUS_METADATA_KEY_SHORT_LIST_APPLICATION_REMOVE, NAUTILUS_METADATA_SUBKEY_APPLICATION_ID, remove_list);
+ (directory,
+ NAUTILUS_METADATA_KEY_SHORT_LIST_APPLICATION_REMOVE,
+ NAUTILUS_METADATA_SUBKEY_APPLICATION_ID,
+ remove_list);
nautilus_directory_unref (directory);
/* FIXME bugzilla.eazel.com 1269:
@@ -823,9 +839,15 @@ nautilus_mime_set_short_list_components_for_uri (const char *uri,
nautilus_directory_wait_for_metadata (directory);
nautilus_directory_set_metadata_list
- (directory, NAUTILUS_METADATA_KEY_SHORT_LIST_COMPONENT_ADD, NAUTILUS_METADATA_SUBKEY_COMPONENT_IID, add_list);
+ (directory,
+ NAUTILUS_METADATA_KEY_SHORT_LIST_COMPONENT_ADD,
+ NAUTILUS_METADATA_SUBKEY_COMPONENT_IID,
+ add_list);
nautilus_directory_set_metadata_list
- (directory, NAUTILUS_METADATA_KEY_SHORT_LIST_COMPONENT_REMOVE, NAUTILUS_METADATA_SUBKEY_COMPONENT_IID, remove_list);
+ (directory,
+ NAUTILUS_METADATA_KEY_SHORT_LIST_COMPONENT_REMOVE,
+ NAUTILUS_METADATA_SUBKEY_COMPONENT_IID,
+ remove_list);
nautilus_directory_unref (directory);
/* FIXME bugzilla.eazel.com 1269:
@@ -1064,7 +1086,9 @@ get_explicit_content_view_iids_from_metafile (NautilusDirectory *directory)
{
if (directory != NULL) {
return nautilus_directory_get_metadata_list
- (directory, NAUTILUS_METADATA_KEY_EXPLICIT_COMPONENT, NAUTILUS_METADATA_SUBKEY_COMPONENT_IID);
+ (directory,
+ NAUTILUS_METADATA_KEY_EXPLICIT_COMPONENT,
+ NAUTILUS_METADATA_SUBKEY_COMPONENT_IID);
} else {
return NULL;
}
@@ -1457,42 +1481,34 @@ get_mime_type_from_uri (const char *text_uri)
GnomeVFSURI *vfs_uri;
GnomeVFSFileInfo *file_info;
GnomeVFSResult result;
- const char *ctype;
char *type;
- if (text_uri == NULL) {
- return NULL;
- }
-
type = NULL;
- /* FIXME bugzilla.eazel.com 1263:
- A better way would be to get this info using
- NautilusFile or NautilusDirectory or something, having
- previously ensured that the info has been computed
- async. */
-
- vfs_uri = gnome_vfs_uri_new (text_uri);
-
- if (vfs_uri != NULL) {
- file_info = gnome_vfs_file_info_new ();
+ if (text_uri != NULL) {
+ /* FIXME bugzilla.eazel.com 1263:
+ A better way would be to get this info using
+ NautilusFile or NautilusDirectory or something, having
+ previously ensured that the info has been computed
+ async. */
- result = gnome_vfs_get_file_info_uri (vfs_uri, file_info,
- GNOME_VFS_FILE_INFO_GET_MIME_TYPE
- | GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
- if (result == GNOME_VFS_OK) {
- ctype = gnome_vfs_file_info_get_mime_type (file_info);
+ vfs_uri = gnome_vfs_uri_new (text_uri);
+
+ if (vfs_uri != NULL) {
+ file_info = gnome_vfs_file_info_new ();
- if (ctype != NULL) {
- type = g_strdup (ctype);
+ result = gnome_vfs_get_file_info_uri (vfs_uri, file_info,
+ GNOME_VFS_FILE_INFO_GET_MIME_TYPE
+ | GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
+ if (result == GNOME_VFS_OK) {
+ type = g_strdup (gnome_vfs_file_info_get_mime_type (file_info));
+ gnome_vfs_file_info_unref (file_info);
+ gnome_vfs_uri_unref (vfs_uri);
}
-
- gnome_vfs_file_info_unref (file_info);
- gnome_vfs_uri_unref (vfs_uri);
- }
+ }
}
- return type;
+ return type == NULL ? g_strdup ("application/octet-stream") : type;
}
static int
diff --git a/libnautilus-extensions/nautilus-trash-directory.c b/libnautilus-extensions/nautilus-trash-directory.c
new file mode 100644
index 000000000..269162c81
--- /dev/null
+++ b/libnautilus-extensions/nautilus-trash-directory.c
@@ -0,0 +1,67 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
+
+ nautilus-trash-directory.c: Subclass of NautilusDirectory to implement the
+ virtual trash directory.
+
+ Copyright (C) 1999, 2000 Eazel, Inc.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+ Author: Darin Adler <darin@eazel.com>
+*/
+
+#include <config.h>
+#include "nautilus-trash-directory.h"
+
+#include "nautilus-gtk-macros.h"
+
+struct NautilusTrashDirectoryDetails {
+};
+
+static void nautilus_trash_directory_destroy (GtkObject *object);
+static void nautilus_trash_directory_initialize (gpointer object,
+ gpointer klass);
+static void nautilus_trash_directory_initialize_class (gpointer klass);
+
+NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusTrashDirectory,
+ nautilus_trash_directory,
+ NAUTILUS_TYPE_DIRECTORY)
+
+static void
+nautilus_trash_directory_initialize_class (gpointer klass)
+{
+ GtkObjectClass *object_class;
+
+ object_class = GTK_OBJECT_CLASS (klass);
+
+ object_class->destroy = nautilus_trash_directory_destroy;
+}
+
+static void
+nautilus_trash_directory_initialize (gpointer object, gpointer klass)
+{
+ NautilusTrashDirectory *directory;
+
+ directory = NAUTILUS_TRASH_DIRECTORY (object);
+
+ directory->details = g_new0 (NautilusTrashDirectoryDetails, 1);
+}
+
+static void
+nautilus_trash_directory_destroy (GtkObject *object)
+{
+ NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object));
+}
diff --git a/libnautilus-extensions/nautilus-trash-directory.h b/libnautilus-extensions/nautilus-trash-directory.h
new file mode 100644
index 000000000..73f53d492
--- /dev/null
+++ b/libnautilus-extensions/nautilus-trash-directory.h
@@ -0,0 +1,56 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
+
+ nautilus-trash-directory.h: Subclass of NautilusDirectory to implement the
+ virtual trash directory.
+
+ Copyright (C) 1999, 2000 Eazel, Inc.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+ Author: Darin Adler <darin@eazel.com>
+*/
+
+#ifndef NAUTILUS_TRASH_DIRECTORY_H
+#define NAUTILUS_TRASH_DIRECTORY_H
+
+#include "nautilus-directory.h"
+
+#define NAUTILUS_TYPE_TRASH_DIRECTORY \
+ (nautilus_trash_directory_get_type ())
+#define NAUTILUS_TRASH_DIRECTORY(obj) \
+ (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_TRASH_DIRECTORY, NautilusTrashDirectory))
+#define NAUTILUS_TRASH_DIRECTORY_CLASS(klass) \
+ (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_TRASH_DIRECTORY, NautilusTrashDirectoryClass))
+#define NAUTILUS_IS_TRASH_DIRECTORY(obj) \
+ (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_TRASH_DIRECTORY))
+#define NAUTILUS_IS_TRASH_DIRECTORY_CLASS(klass) \
+ (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_TRASH_DIRECTORY))
+
+typedef struct NautilusTrashDirectoryDetails NautilusTrashDirectoryDetails;
+
+typedef struct {
+ NautilusDirectory parent_slot;
+ NautilusTrashDirectoryDetails *details;
+} NautilusTrashDirectory;
+
+typedef struct {
+ NautilusDirectoryClass parent_slot;
+} NautilusTrashDirectoryClass;
+
+GtkType nautilus_trash_directory_get_type (void);
+NautilusTrashDirectory *nautilus_trash_directory_get (void);
+
+#endif /* NAUTILUS_TRASH_DIRECTORY_H */
diff --git a/libnautilus-extensions/nautilus-vfs-directory.c b/libnautilus-extensions/nautilus-vfs-directory.c
new file mode 100644
index 000000000..424e55827
--- /dev/null
+++ b/libnautilus-extensions/nautilus-vfs-directory.c
@@ -0,0 +1,67 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
+
+ nautilus-vfs-directory.c: Subclass of NautilusDirectory to help implement the
+ virtual trash directory.
+
+ Copyright (C) 1999, 2000 Eazel, Inc.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+ Author: Darin Adler <darin@eazel.com>
+*/
+
+#include <config.h>
+#include "nautilus-vfs-directory.h"
+
+#include "nautilus-gtk-macros.h"
+
+struct NautilusVFSDirectoryDetails {
+};
+
+static void nautilus_vfs_directory_destroy (GtkObject *object);
+static void nautilus_vfs_directory_initialize (gpointer object,
+ gpointer klass);
+static void nautilus_vfs_directory_initialize_class (gpointer klass);
+
+NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusVFSDirectory,
+ nautilus_vfs_directory,
+ NAUTILUS_TYPE_DIRECTORY)
+
+static void
+nautilus_vfs_directory_initialize_class (gpointer klass)
+{
+ GtkObjectClass *object_class;
+
+ object_class = GTK_OBJECT_CLASS (klass);
+
+ object_class->destroy = nautilus_vfs_directory_destroy;
+}
+
+static void
+nautilus_vfs_directory_initialize (gpointer object, gpointer klass)
+{
+ NautilusVFSDirectory *directory;
+
+ directory = NAUTILUS_VFS_DIRECTORY (object);
+
+ directory->details = g_new0 (NautilusVFSDirectoryDetails, 1);
+}
+
+static void
+nautilus_vfs_directory_destroy (GtkObject *object)
+{
+ NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object));
+}
diff --git a/libnautilus-extensions/nautilus-vfs-directory.h b/libnautilus-extensions/nautilus-vfs-directory.h
new file mode 100644
index 000000000..922b768bb
--- /dev/null
+++ b/libnautilus-extensions/nautilus-vfs-directory.h
@@ -0,0 +1,55 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
+
+ nautilus-vfs-directory.h: Subclass of NautilusDirectory to implement the
+ the case of a VFS directory.
+
+ Copyright (C) 1999, 2000 Eazel, Inc.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+ Author: Darin Adler <darin@eazel.com>
+*/
+
+#ifndef NAUTILUS_VFS_DIRECTORY_H
+#define NAUTILUS_VFS_DIRECTORY_H
+
+#include "nautilus-directory.h"
+
+#define NAUTILUS_TYPE_VFS_DIRECTORY \
+ (nautilus_vfs_directory_get_type ())
+#define NAUTILUS_VFS_DIRECTORY(obj) \
+ (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_VFS_DIRECTORY, NautilusVFSDirectory))
+#define NAUTILUS_VFS_DIRECTORY_CLASS(klass) \
+ (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_VFS_DIRECTORY, NautilusVFSDirectoryClass))
+#define NAUTILUS_IS_VFS_DIRECTORY(obj) \
+ (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_VFS_DIRECTORY))
+#define NAUTILUS_IS_VFS_DIRECTORY_CLASS(klass) \
+ (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_VFS_DIRECTORY))
+
+typedef struct NautilusVFSDirectoryDetails NautilusVFSDirectoryDetails;
+
+typedef struct {
+ NautilusDirectory parent_slot;
+ NautilusVFSDirectoryDetails *details;
+} NautilusVFSDirectory;
+
+typedef struct {
+ NautilusDirectoryClass parent_slot;
+} NautilusVFSDirectoryClass;
+
+GtkType nautilus_vfs_directory_get_type (void);
+
+#endif /* NAUTILUS_VFS_DIRECTORY_H */
diff --git a/libnautilus-private/Makefile.am b/libnautilus-private/Makefile.am
index 753910af6..8a66c98e7 100644
--- a/libnautilus-private/Makefile.am
+++ b/libnautilus-private/Makefile.am
@@ -98,6 +98,7 @@ libnautilus_extensions_la_SOURCES = \
nautilus-string-picker.c \
nautilus-string.c \
nautilus-text-caption.c \
+ nautilus-trash-directory.c \
nautilus-theme.c \
nautilus-undo-context.c \
nautilus-undo-manager.c \
@@ -105,6 +106,7 @@ libnautilus_extensions_la_SOURCES = \
nautilus-user-level-manager.c \
nautilus-view-identifier.c \
nautilus-volume-monitor.c \
+ nautilus-vfs-directory.c \
nautilus-xml-extensions.c \
$(NULL)
@@ -115,22 +117,23 @@ noinst_HEADERS = \
nautilus-background.h \
nautilus-bonobo-extensions.h \
nautilus-bookmark.h \
- nautilus-caption-table.h \
nautilus-caption.h \
+ nautilus-caption-table.h \
+ nautilus-cdrom-extensions.h \
nautilus-debug.h \
nautilus-default-file-icon.h \
nautilus-directory-background.h \
+ nautilus-directory.h \
nautilus-directory-metafile.h \
nautilus-directory-notify.h \
nautilus-directory-private.h \
- nautilus-directory.h \
nautilus-drag.h \
nautilus-entry.h \
nautilus-file-attributes.h \
nautilus-file-changes-queue.h \
+ nautilus-file.h \
nautilus-file-private.h \
nautilus-file-utilities.h \
- nautilus-file.h \
nautilus-font-factory.h \
nautilus-gdk-extensions.h \
nautilus-gdk-pixbuf-extensions.h \
@@ -149,10 +152,11 @@ noinst_HEADERS = \
nautilus-icon-private.h \
nautilus-icon-text-item.h \
nautilus-image.h \
+ nautilus-iso9660.h \
nautilus-keep-last-vertical-box.h \
nautilus-lib-self-check-functions.h \
- nautilus-link-set.h \
nautilus-link.h \
+ nautilus-link-set.h \
nautilus-list-column-title.h \
nautilus-list.h \
nautilus-metadata.h \
@@ -162,28 +166,28 @@ noinst_HEADERS = \
nautilus-preferences-box.h \
nautilus-preferences-dialog.h \
nautilus-preferences-group.h \
+ nautilus-preferences.h \
nautilus-preferences-item.h \
nautilus-preferences-pane.h \
- nautilus-preferences.h \
nautilus-program-chooser.h \
nautilus-program-choosing.h \
nautilus-radio-button-group.h \
nautilus-search-bar-criterion.h \
+ nautilus-search-bar-criterion-private.h \
nautilus-self-checks.h \
nautilus-stock-dialogs.h \
+ nautilus-string.h \
nautilus-string-list.h \
nautilus-string-picker.h \
- nautilus-string.h \
nautilus-text-caption.h \
nautilus-theme.h \
+ nautilus-trash-directory.h \
nautilus-undo-context.h \
nautilus-undo-manager.h \
nautilus-undo-signal-handlers.h \
nautilus-user-level-manager.h \
+ nautilus-vfs-directory.h \
nautilus-view-identifier.h \
- nautilus-xml-extensions.h \
- nautilus-cdrom-extensions.h \
- nautilus-iso9660.h \
- nautilus-search-bar-criterion-private.h \
nautilus-volume-monitor.h \
+ nautilus-xml-extensions.h \
$(NULL)
diff --git a/libnautilus-private/nautilus-directory-async.c b/libnautilus-private/nautilus-directory-async.c
index f7a115041..6b6b8df9b 100644
--- a/libnautilus-private/nautilus-directory-async.c
+++ b/libnautilus-private/nautilus-directory-async.c
@@ -197,6 +197,10 @@ can_use_public_metafile (NautilusDirectory *directory)
g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), FALSE);
+ if (directory->details->public_metafile_vfs_uri == NULL) {
+ return FALSE;
+ }
+
preference_value = nautilus_preferences_get_enum
(NAUTILUS_PREFERENCES_USE_PUBLIC_METADATA,
NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY);
@@ -270,9 +274,15 @@ static void
metafile_read_check_for_directory (NautilusDirectory *directory)
{
GList fake_list;
+
+ /* We only get here if the public metafile is in question,
+ * which in turn only happens if the URI is one that gnome-vfs
+ * can handle.
+ */
+ g_assert (directory->details->vfs_uri != NULL);
/* We have to do a get_info call to check if this a directory. */
- fake_list.data = directory->details->uri;
+ fake_list.data = directory->details->vfs_uri;
fake_list.next = NULL;
fake_list.prev = NULL;
gnome_vfs_async_get_file_info
@@ -301,7 +311,7 @@ metafile_read_failed (NautilusDirectory *directory)
*/
/* First, check if we already know if it a directory. */
- file = nautilus_file_get (directory->details->uri_text);
+ file = nautilus_file_get (directory->details->uri);
if (file == NULL || file->details->is_gone) {
need_directory_check = FALSE;
is_directory = FALSE;
@@ -374,8 +384,8 @@ metafile_read_start (NautilusDirectory *directory)
text_uri = gnome_vfs_uri_to_string
(directory->details->metafile_read_state->use_public_metafile
- ? directory->details->public_metafile_uri
- : directory->details->private_metafile_uri,
+ ? directory->details->public_metafile_vfs_uri
+ : directory->details->private_metafile_vfs_uri,
GNOME_VFS_URI_HIDE_NONE);
directory->details->metafile_read_state->handle = nautilus_read_entire_file_async
@@ -387,7 +397,9 @@ metafile_read_start (NautilusDirectory *directory)
static gboolean
allow_metafile (NautilusDirectory *directory)
{
- const char *scheme;
+ const char *uri;
+
+ g_assert (NAUTILUS_IS_DIRECTORY (directory));
/* Note that this inhibits both reading and writing metadata
* completely. In the future we may want to inhibit writing to
@@ -395,8 +407,6 @@ allow_metafile (NautilusDirectory *directory)
* metadata.
*/
- g_assert (NAUTILUS_IS_DIRECTORY (directory));
-
/* For now, hard-code these schemes. Perhaps we should
* hardcode the schemes that are good for metadata instead of
* the schemes that are bad for it.
@@ -405,13 +415,13 @@ allow_metafile (NautilusDirectory *directory)
* better way can wait until we have support for metadata
* access inside gnome-vfs.
*/
- scheme = gnome_vfs_uri_get_scheme (directory->details->uri);
- if (nautilus_strcasecmp (scheme, "info") == 0
- || nautilus_strcasecmp (scheme, "help") == 0
- || nautilus_strcasecmp (scheme, "man") == 0
- || nautilus_strcasecmp (scheme, "pipe") == 0
- || nautilus_strcasecmp (scheme, "search") == 0
- || nautilus_strcasecmp (scheme, "gnome-search") == 0) {
+ uri = directory->details->uri;
+ if (nautilus_istr_has_prefix (uri, "info:")
+ || nautilus_istr_has_prefix (uri, "help:")
+ || nautilus_istr_has_prefix (uri, "man:")
+ || nautilus_istr_has_prefix (uri, "pipe:")
+ || nautilus_istr_has_prefix (uri, "search:")
+ || nautilus_istr_has_prefix (uri, "gnome-search:")) {
return FALSE;
}
@@ -498,7 +508,7 @@ metafile_write_success_close_callback (GnomeVFSAsyncHandle *handle,
/* A synchronous unlink is OK here because the private
* metafiles are local, so an unlink is very fast.
*/
- gnome_vfs_unlink_from_uri (directory->details->private_metafile_uri);
+ gnome_vfs_unlink_from_uri (directory->details->private_metafile_vfs_uri);
}
metafile_write_done (directory);
@@ -561,8 +571,8 @@ nautilus_metafile_write_start (NautilusDirectory *directory)
gnome_vfs_async_create_uri
(&directory->details->metafile_write_state->handle,
directory->details->metafile_write_state->use_public_metafile
- ? directory->details->public_metafile_uri
- : directory->details->private_metafile_uri,
+ ? directory->details->public_metafile_vfs_uri
+ : directory->details->private_metafile_vfs_uri,
GNOME_VFS_OPEN_WRITE, FALSE, METAFILE_PERMISSIONS,
metafile_write_create_callback, directory);
}
@@ -1605,13 +1615,13 @@ start_monitoring_file_list (NautilusDirectory *directory)
mark_all_files_unconfirmed (directory);
- g_assert (directory->details->uri_text != NULL);
+ g_assert (directory->details->uri != NULL);
directory->details->directory_load_list_last_handled
= GNOME_VFS_DIRECTORY_LIST_POSITION_NONE;
gnome_vfs_async_load_directory
(&directory->details->directory_load_in_progress, /* handle */
- directory->details->uri_text, /* uri */
+ directory->details->uri, /* uri */
(GNOME_VFS_FILE_INFO_GET_MIME_TYPE /* options */
| GNOME_VFS_FILE_INFO_FOLLOW_LINKS),
NULL, /* sort_rules */
@@ -1650,7 +1660,7 @@ get_corresponding_file (NautilusDirectory *directory)
return file;
}
- return nautilus_file_get_existing (directory->details->uri_text);
+ return nautilus_file_get_existing (directory->details->uri);
}
void
@@ -2199,15 +2209,24 @@ start_getting_file_info (NautilusDirectory *directory)
}
/* Figure out which file to get file info for. */
- file = select_needy_file (directory, lacks_info, wants_info);
- if (file == NULL) {
- return;
- }
+ do {
+ file = select_needy_file (directory, lacks_info, wants_info);
+ if (file == NULL) {
+ return;
+ }
+
+ uri = nautilus_file_get_uri (file);
+ vfs_uri = gnome_vfs_uri_new (uri);
+ g_free (uri);
+
+ if (vfs_uri == NULL) {
+ file->details->get_info_failed = TRUE;
+ start_getting_file_info (directory);
+ }
+ } while (vfs_uri == NULL);
+ /* Found one we need to get the info for. */
directory->details->get_info_file = file;
- uri = nautilus_file_get_uri (file);
- vfs_uri = gnome_vfs_uri_new (uri);
- g_free (uri);
fake_list.data = vfs_uri;
fake_list.prev = NULL;
fake_list.next = NULL;
diff --git a/libnautilus-private/nautilus-directory-private.h b/libnautilus-private/nautilus-directory-private.h
index 8f1f5d679..77ac9bf0d 100644
--- a/libnautilus-private/nautilus-directory-private.h
+++ b/libnautilus-private/nautilus-directory-private.h
@@ -41,10 +41,10 @@ typedef struct TopLeftTextReadState TopLeftTextReadState;
struct NautilusDirectoryDetails
{
/* The location. */
- char *uri_text;
- GnomeVFSURI *uri;
- GnomeVFSURI *private_metafile_uri;
- GnomeVFSURI *public_metafile_uri;
+ char *uri;
+ GnomeVFSURI *vfs_uri;
+ GnomeVFSURI *private_metafile_vfs_uri;
+ GnomeVFSURI *public_metafile_vfs_uri;
/* The file objects. */
NautilusFile *as_file;
diff --git a/libnautilus-private/nautilus-directory.c b/libnautilus-private/nautilus-directory.c
index d600be4b0..b1ddb61c2 100644
--- a/libnautilus-private/nautilus-directory.c
+++ b/libnautilus-private/nautilus-directory.c
@@ -33,6 +33,8 @@
#include "nautilus-gtk-macros.h"
#include "nautilus-lib-self-check-functions.h"
#include "nautilus-string.h"
+#include "nautilus-trash-directory.h"
+#include "nautilus-vfs-directory.h"
#include <ctype.h>
#include <gtk/gtkmain.h>
#include <gtk/gtksignal.h>
@@ -60,7 +62,6 @@ static guint signals[LAST_SIGNAL];
static GHashTable *directories;
-static GnomeVFSURI * construct_private_metafile_uri (GnomeVFSURI *uri);
static void nautilus_directory_destroy (GtkObject *object);
static void nautilus_directory_initialize (gpointer object,
gpointer klass);
@@ -166,16 +167,20 @@ nautilus_directory_destroy (GtkObject *object)
nautilus_g_list_free_deep (directory->details->monitor_list);
}
- g_hash_table_remove (directories, directory->details->uri_text);
+ g_hash_table_remove (directories, directory->details->uri);
if (directory->details->dequeue_pending_idle_id != 0) {
gtk_idle_remove (directory->details->dequeue_pending_idle_id);
}
- g_free (directory->details->uri_text);
- gnome_vfs_uri_unref (directory->details->uri);
- gnome_vfs_uri_unref (directory->details->private_metafile_uri);
- gnome_vfs_uri_unref (directory->details->public_metafile_uri);
+ g_free (directory->details->uri);
+ gnome_vfs_uri_unref (directory->details->private_metafile_vfs_uri);
+ if (directory->details->vfs_uri != NULL) {
+ gnome_vfs_uri_unref (directory->details->vfs_uri);
+ }
+ if (directory->details->public_metafile_vfs_uri != NULL) {
+ gnome_vfs_uri_unref (directory->details->public_metafile_vfs_uri);
+ }
g_assert (directory->details->files == NULL);
nautilus_directory_metafile_destroy (directory);
g_assert (directory->details->directory_load_in_progress == NULL);
@@ -195,6 +200,14 @@ make_uri_canonical (const char *uri)
size_t length;
char *canonical_uri, *old_uri, *with_slashes, *p;
+ /* Convert "gnome-trash:<anything>" and "trash:<anything>" to
+ * "gnome-trash:<anything>".
+ */
+ if (nautilus_istr_has_prefix (uri, "trash:")
+ || nautilus_istr_has_prefix (uri, "gnome-trash:")) {
+ return g_strdup ("gnome-trash:");
+ }
+
/* FIXME bugzilla.eazel.com 648:
* This currently ignores the issue of two uris that are not identical but point
* to the same data except for the specific cases of trailing '/' characters,
@@ -317,11 +330,11 @@ nautilus_directory_get_internal (const char *uri, gboolean create)
return NULL;
}
- g_assert (strcmp (directory->details->uri_text, canonical_uri) == 0);
+ g_assert (strcmp (directory->details->uri, canonical_uri) == 0);
/* Put it in the hash table. */
g_hash_table_insert (directories,
- directory->details->uri_text,
+ directory->details->uri,
directory);
}
@@ -347,7 +360,7 @@ nautilus_directory_get_uri (NautilusDirectory *directory)
{
g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), NULL);
- return g_strdup (directory->details->uri_text);
+ return g_strdup (directory->details->uri);
}
static GnomeVFSResult
@@ -387,21 +400,21 @@ nautilus_make_directory_and_parents (GnomeVFSURI *uri, guint permissions)
}
static GnomeVFSURI *
-construct_private_metafile_uri (GnomeVFSURI *uri)
+construct_private_metafile_uri (const char *uri)
{
GnomeVFSResult result;
- GnomeVFSURI *nautilus_directory_uri, *metafiles_directory_uri, *alternate_uri;
- char *uri_as_string, *escaped_uri, *file_name;
char *user_directory;
+ GnomeVFSURI *user_directory_uri, *metafiles_directory_uri, *alternate_uri;
+ char *escaped_uri, *file_name;
/* Ensure that the metafiles directory exists. */
user_directory = nautilus_get_user_directory ();
- nautilus_directory_uri = gnome_vfs_uri_new (user_directory);
+ user_directory_uri = gnome_vfs_uri_new (user_directory);
g_free (user_directory);
- metafiles_directory_uri = gnome_vfs_uri_append_file_name (nautilus_directory_uri,
+ metafiles_directory_uri = gnome_vfs_uri_append_file_name (user_directory_uri,
METAFILES_DIRECTORY_NAME);
- gnome_vfs_uri_unref (nautilus_directory_uri);
+ gnome_vfs_uri_unref (user_directory_uri);
result = nautilus_make_directory_and_parents (metafiles_directory_uri,
METAFILES_DIRECTORY_PERMISSIONS);
if (result != GNOME_VFS_OK && result != GNOME_VFS_ERROR_FILE_EXISTS) {
@@ -410,9 +423,7 @@ construct_private_metafile_uri (GnomeVFSURI *uri)
}
/* Construct a file name from the URI. */
- uri_as_string = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE);
- escaped_uri = nautilus_str_escape_slashes (uri_as_string);
- g_free (uri_as_string);
+ escaped_uri = nautilus_str_escape_slashes (uri);
file_name = g_strconcat (escaped_uri, ".xml", NULL);
g_free (escaped_uri);
@@ -425,27 +436,27 @@ construct_private_metafile_uri (GnomeVFSURI *uri)
}
static NautilusDirectory *
-nautilus_directory_new (const char* uri)
+nautilus_directory_new (const char *uri)
{
NautilusDirectory *directory;
GnomeVFSURI *vfs_uri;
- GnomeVFSURI *private_metafile_uri;
- GnomeVFSURI *public_metafile_uri;
- vfs_uri = gnome_vfs_uri_new (uri);
- if (vfs_uri == NULL) {
- return NULL;
+ g_assert (uri != NULL);
+
+ if (strcmp (uri, "gnome-trash:") == 0) {
+ directory = NAUTILUS_DIRECTORY (gtk_type_new (NAUTILUS_TYPE_TRASH_DIRECTORY));
+ } else {
+ directory = NAUTILUS_DIRECTORY (gtk_type_new (NAUTILUS_TYPE_VFS_DIRECTORY));
}
- private_metafile_uri = construct_private_metafile_uri (vfs_uri);
- public_metafile_uri = gnome_vfs_uri_append_file_name (vfs_uri, METAFILE_NAME);
+ directory->details->uri = g_strdup (uri);
+ directory->details->private_metafile_vfs_uri = construct_private_metafile_uri (uri);
- directory = gtk_type_new (NAUTILUS_TYPE_DIRECTORY);
+ vfs_uri = gnome_vfs_uri_new (uri);
- directory->details->uri_text = g_strdup (uri);
- directory->details->uri = vfs_uri;
- directory->details->private_metafile_uri = private_metafile_uri;
- directory->details->public_metafile_uri = public_metafile_uri;
+ directory->details->vfs_uri = vfs_uri;
+ directory->details->public_metafile_vfs_uri = vfs_uri == NULL ? NULL
+ : gnome_vfs_uri_append_file_name (vfs_uri, METAFILE_NAME);
return directory;
}
@@ -455,53 +466,10 @@ nautilus_directory_is_local (NautilusDirectory *directory)
{
g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), FALSE);
- return gnome_vfs_uri_is_local (directory->details->uri);
-}
-
-/* FIXME: I think this should be named _is_virtual_directory. */
-gboolean
-nautilus_directory_is_search_directory (NautilusDirectory *directory)
-{
- if (directory == NULL) {
- return FALSE;
+ if (directory->details->vfs_uri == NULL) {
+ return TRUE;
}
-
- g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), FALSE);
-
- /* Two hard-coded schemes for now. */
- /* FIXME: Later we gnome-vfs will tell us somehow that this is
- * a virtual directory.
- */
- return nautilus_istr_has_prefix (directory->details->uri_text, "search:")
- || nautilus_istr_has_prefix (directory->details->uri_text, "gnome-search:");
-
-#if 0
- GnomeVFSFileInfo *info;
- gboolean is_search_directory;
- GnomeVFSResult result;
-
- info = gnome_vfs_file_info_new ();
-
- g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), FALSE);
-
- /* FIXME bugzilla.eazel.com 1263: We can't just do sync. I/O
- * here! The model is that get_ functions in
- * NautilusDirectory/File are supposed to do no I/O. The
- * aforementioned bug talks about this a bit.
- */
- /* FIXME bugzilla.eazel.com 1263: Should make use of some sort
- * of NautilusDirectory cover for getting the mime type.
- */
- result = gnome_vfs_get_file_info_uri (directory->details->uri,
- info,
- GNOME_VFS_FILE_INFO_GET_MIME_TYPE);
- is_search_directory = result == GNOME_VFS_OK &&
- nautilus_strcasecmp (info->mime_type, "x-directory/search") == 0;
-
- gnome_vfs_file_info_unref (info);
-
- return is_search_directory;
-#endif
+ return gnome_vfs_uri_is_local (directory->details->vfs_uri);
}
gboolean
@@ -576,7 +544,6 @@ nautilus_directory_emit_done_loading (NautilusDirectory *directory)
signals[DONE_LOADING]);
}
-
static char *
uri_get_directory_part (const char *uri)
{
@@ -1016,7 +983,7 @@ any_non_metafile_item (gconstpointer item, gconstpointer callback_data)
gboolean
nautilus_directory_is_not_empty (NautilusDirectory *directory)
{
- char *public_metafile_uri_string;
+ char *public_metafile_uri;
gboolean not_empty;
g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), FALSE);
@@ -1024,16 +991,20 @@ nautilus_directory_is_not_empty (NautilusDirectory *directory)
/* Directory must be monitored for this call to be correct. */
g_return_val_if_fail (nautilus_directory_is_file_list_monitored (directory), FALSE);
- public_metafile_uri_string = gnome_vfs_uri_to_string
- (directory->details->public_metafile_uri,
- GNOME_VFS_URI_HIDE_NONE);
-
- /* Return TRUE if the directory contains anything besides a metafile. */
- not_empty = g_list_find_custom (directory->details->files,
- public_metafile_uri_string,
- any_non_metafile_item) != NULL;
-
- g_free (public_metafile_uri_string);
+ if (directory->details->public_metafile_vfs_uri == NULL) {
+ not_empty = directory->details->files != NULL;
+ } else {
+ public_metafile_uri = gnome_vfs_uri_to_string
+ (directory->details->public_metafile_vfs_uri,
+ GNOME_VFS_URI_HIDE_NONE);
+
+ /* Return TRUE if the directory contains anything besides a metafile. */
+ not_empty = g_list_find_custom (directory->details->files,
+ public_metafile_uri,
+ any_non_metafile_item) != NULL;
+
+ g_free (public_metafile_uri);
+ }
return not_empty;
}
@@ -1194,6 +1165,7 @@ nautilus_self_check_directory (void)
NAUTILUS_CHECK_STRING_RESULT (make_uri_canonical (""), "file:");
NAUTILUS_CHECK_STRING_RESULT (make_uri_canonical ("file:/"), "file:///");
NAUTILUS_CHECK_STRING_RESULT (make_uri_canonical ("file:///"), "file:///");
+ NAUTILUS_CHECK_STRING_RESULT (make_uri_canonical ("TRASH:XXX"), "gnome-trash:");
}
#endif /* !NAUTILUS_OMIT_SELF_CHECK */
diff --git a/libnautilus-private/nautilus-directory.h b/libnautilus-private/nautilus-directory.h
index 7abf9e41e..95fb68589 100644
--- a/libnautilus-private/nautilus-directory.h
+++ b/libnautilus-private/nautilus-directory.h
@@ -42,9 +42,6 @@
information available from other means.
*/
-typedef struct NautilusDirectory NautilusDirectory;
-typedef struct NautilusDirectoryClass NautilusDirectoryClass;
-
#define NAUTILUS_TYPE_DIRECTORY \
(nautilus_directory_get_type ())
#define NAUTILUS_DIRECTORY(obj) \
@@ -62,10 +59,78 @@ typedef struct NautilusDirectoryClass NautilusDirectoryClass;
typedef struct NautilusFile NautilusFile;
#endif
+typedef struct NautilusDirectoryDetails NautilusDirectoryDetails;
+
+typedef struct
+{
+ GtkObject object;
+ NautilusDirectoryDetails *details;
+} NautilusDirectory;
+
typedef void (*NautilusDirectoryCallback) (NautilusDirectory *directory,
GList *files,
gpointer callback_data);
+typedef struct
+{
+ GtkObjectClass parent_class;
+
+ /*** Notification signals for clients to connect to. ***/
+
+ /* The files_added signal is emitted as the directory model
+ * discovers new files.
+ */
+ void (* files_added) (NautilusDirectory *directory,
+ GList *added_files);
+
+ /* The files_changed signal is emitted as changes occur to
+ * existing files that are noticed by the synchronization framework,
+ * including when an old file has been deleted. When an old file
+ * has been deleted, this is the last chance to forget about these
+ * file objects, which are about to be unref'd. Use a call to
+ * nautilus_file_is_gone () to test for this case.
+ */
+ void (* files_changed) (NautilusDirectory *directory,
+ GList *changed_files);
+
+ /* The metadata_changed signal is emitted when changes to the metadata
+ * for the directory itself are made. Changes to file metadata just
+ * result in calls to files_changed.
+ */
+ void (* metadata_changed) (NautilusDirectory *directory);
+
+ /* The done_loading signal is emitted when a directory load
+ * request completes. This is needed because, at least in the
+ * case where the directory is empty, the caller will receive
+ * no kind of notification at all when a directory load
+ * initiated by `nautilus_directory_file_monitor_add' completes.
+ */
+ void (* done_loading) (NautilusDirectory *directory);
+
+ /*** Virtual functions for subclasses to override. ***/
+ gboolean (* contains_file) (NautilusDirectory *directory,
+ NautilusFile *file);
+ void (* call_when_ready) (NautilusDirectory *directory,
+ GList *file_attributes,
+ gboolean wait_for_metadata,
+ NautilusDirectoryCallback callback,
+ gpointer callback_data);
+ void (* cancel_callback) (NautilusDirectory *directory,
+ NautilusDirectoryCallback callback,
+ gpointer callback_data);
+ void (* file_monitor_add) (NautilusDirectory *directory,
+ gconstpointer client,
+ GList *monitor_attributes,
+ gboolean monitor_metadata,
+ gboolean force_reload,
+ NautilusDirectoryCallback initial_files_callback,
+ gpointer callback_data);
+ void (* file_monitor_remove) (NautilusDirectory *directory,
+ gconstpointer client);
+ gboolean (* are_all_files_seen) (NautilusDirectory *directory);
+ gboolean (* is_not_empty) (NautilusDirectory *directory);
+} NautilusDirectoryClass;
+
/* Basic GtkObject requirements. */
GtkType nautilus_directory_get_type (void);
@@ -152,68 +217,12 @@ void nautilus_directory_file_monitor_remove (NautilusDirectory
*/
gboolean nautilus_directory_are_all_files_seen (NautilusDirectory *directory);
-/* Return true if the directory metadata has been loaded.
- * Until this is true, get_metadata calls will return defaults.
- * (We could have another way to indicate "don't know".)
- */
-gboolean nautilus_directory_metadata_loaded (NautilusDirectory *directory);
-
/* Return true if the directory is local. */
gboolean nautilus_directory_is_local (NautilusDirectory *directory);
-gboolean nautilus_directory_is_search_directory (NautilusDirectory *directory);
-
-/* Return false if directory contains anything besides a nautilus metafile.
- * Only valid if directory is monitored.
- * Used by the Trash monitor
+/* Return false if directory contains anything besides a Nautilus metafile.
+ * Only valid if directory is monitored. Used by the Trash monitor.
*/
gboolean nautilus_directory_is_not_empty (NautilusDirectory *directory);
-typedef struct NautilusDirectoryDetails NautilusDirectoryDetails;
-
-struct NautilusDirectory
-{
- GtkObject object;
- NautilusDirectoryDetails *details;
-};
-
-struct NautilusDirectoryClass
-{
- GtkObjectClass parent_class;
-
- /*** Notification signals for clients to connect to. ***/
-
- /* The files_added signal is emitted as the directory model
- * discovers new files.
- */
- void (* files_added) (NautilusDirectory *directory,
- GList *added_files);
-
- /* The files_changed signal is emitted as changes occur to
- * existing files that are noticed by the synchronization framework,
- * including when an old file has been deleted. When an old file
- * has been deleted, this is the last chance to forget about these
- * file objects, which are about to be unref'd. Use a call to
- * nautilus_file_is_gone () to test for this case.
- */
- void (* files_changed) (NautilusDirectory *directory,
- GList *changed_files);
-
- /* The metadata_changed signal is emitted when changes to the metadata
- * for the directory itself are made. Changes to file metadata just
- * result in calls to files_changed.
- */
- void (* metadata_changed) (NautilusDirectory *directory);
-
-
- /* The done_loading signal is emitted when a directory load
- * request completes. This is needed because, at least in the
- * case where the directory is empty, the caller will receive
- * no kind of notification at all when a directory load
- * initiated by `nautilus_directory_file_monitor_add' completes.
- */
-
- void (* done_loading) (NautilusDirectory *directory);
-};
-
#endif /* NAUTILUS_DIRECTORY_H */
diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c
index 1343be088..f2ec39b8d 100644
--- a/libnautilus-private/nautilus-file.c
+++ b/libnautilus-private/nautilus-file.c
@@ -67,9 +67,9 @@ static GHashTable *symbolic_links;
static void nautilus_file_initialize_class (NautilusFileClass *klass);
static void nautilus_file_initialize (NautilusFile *file);
static void destroy (GtkObject *object);
-static int nautilus_file_compare_by_real_name (NautilusFile *file_1,
+static int nautilus_file_compare_by_name (NautilusFile *file_1,
NautilusFile *file_2);
-static int nautilus_file_compare_by_real_directory (NautilusFile *file_1,
+static int nautilus_file_compare_by_directory_name (NautilusFile *file_1,
NautilusFile *file_2);
static int nautilus_file_compare_by_emblems (NautilusFile *file_1,
NautilusFile *file_2);
@@ -82,7 +82,7 @@ static char *nautilus_file_get_owner_as_string (NautilusFile *file
static char *nautilus_file_get_permissions_as_string (NautilusFile *file);
static char *nautilus_file_get_size_as_string (NautilusFile *file);
static char *nautilus_file_get_type_as_string (NautilusFile *file);
-static char *nautilus_file_get_real_directory (NautilusFile *file);
+static char *nautilus_file_get_directory_name (NautilusFile *file);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusFile, nautilus_file, GTK_TYPE_OBJECT)
@@ -252,19 +252,17 @@ nautilus_file_get_internal (const char *uri, gboolean create)
GnomeVFSURI *vfs_uri, *directory_vfs_uri;
char *directory_uri;
NautilusDirectory *directory;
- char *file_name_escaped, *file_name;
+ char *file_name_escaped, *file_name, *colon;
NautilusFile *file;
g_return_val_if_fail (uri != NULL, NULL);
/* Make VFS version of URI. */
vfs_uri = gnome_vfs_uri_new (uri);
- if (vfs_uri == NULL) {
- return NULL;
- }
/* Make VFS version of directory URI. */
- directory_vfs_uri = gnome_vfs_uri_get_parent (vfs_uri);
+ directory_vfs_uri = vfs_uri == NULL ? NULL
+ : gnome_vfs_uri_get_parent (vfs_uri);
self_owned = directory_vfs_uri == NULL;
if (self_owned) {
/* Use the item itself if we have no parent. */
@@ -280,24 +278,41 @@ nautilus_file_get_internal (const char *uri, gboolean create)
/* Get object that represents the directory. */
directory = nautilus_directory_get_internal (directory_uri, create);
g_free (directory_uri);
- if (directory == NULL) {
+
+ /* Get the name for the file. */
+ if (vfs_uri == NULL) {
+ g_assert (self_owned);
+ if (directory == NULL) {
+ file_name = NULL;
+ } else {
+ /* Name is URI (from directory in case it's
+ * made canonical), but scheme part only if
+ * it's there.
+ */
+ directory_uri = directory->details->uri;
+ colon = strchr (directory_uri, ':');
+ if (colon == NULL) {
+ file_name = g_strdup (directory_uri);
+ } else {
+ file_name = g_strndup (directory_uri,
+ colon - directory_uri);
+ }
+ }
+ } else {
+ file_name_escaped = gnome_vfs_uri_extract_short_path_name (vfs_uri);
gnome_vfs_uri_unref (vfs_uri);
- return NULL;
+ file_name = gnome_vfs_unescape_string (file_name_escaped, NULL);
+ g_free (file_name_escaped);
}
/* Check to see if it's a file that's already known. */
- file_name_escaped = gnome_vfs_uri_extract_short_path_name (vfs_uri);
- gnome_vfs_uri_unref (vfs_uri);
- file_name = gnome_vfs_unescape_string (file_name_escaped, NULL);
- g_free (file_name_escaped);
- if (file_name == NULL) {
- return NULL;
- }
if (self_owned) {
- file = directory->details->as_file;
+ file = directory == NULL ? NULL : directory->details->as_file;
} else {
file = nautilus_directory_find_file (directory, file_name);
}
+
+ /* Ref or create the file. */
if (file != NULL) {
nautilus_file_ref (file);
} else if (create) {
@@ -310,10 +325,10 @@ nautilus_file_get_internal (const char *uri, gboolean create)
g_list_prepend (directory->details->files, file);
}
}
- g_free (file_name);
+ g_free (file_name);
nautilus_directory_unref (directory);
-
+
return file;
}
@@ -777,7 +792,7 @@ nautilus_file_rename (NautilusFile *file,
NautilusFileOperationCallback callback,
gpointer callback_data)
{
- char *directory_uri_text;
+ char *directory_uri;
GList *source_name_list, *target_name_list;
GnomeVFSResult result;
Operation *op;
@@ -836,19 +851,19 @@ nautilus_file_rename (NautilusFile *file,
/* FIXME: This call could use gnome_vfs_async_set_file_info
* instead and it might be simpler.
*/
- directory_uri_text = nautilus_directory_get_uri (file->details->directory);
+ directory_uri = nautilus_directory_get_uri (file->details->directory);
source_name_list = g_list_prepend (NULL, file->details->name);
target_name_list = g_list_prepend (NULL, (char *) new_name);
result = gnome_vfs_async_xfer
(&op->handle,
- directory_uri_text, source_name_list,
- directory_uri_text, target_name_list,
+ directory_uri, source_name_list,
+ directory_uri, target_name_list,
GNOME_VFS_XFER_SAMEFS | GNOME_VFS_XFER_REMOVESOURCE,
GNOME_VFS_XFER_ERROR_MODE_QUERY,
GNOME_VFS_XFER_OVERWRITE_MODE_ABORT,
rename_callback, op,
NULL, NULL);
- g_free (directory_uri_text);
+ g_free (directory_uri);
g_list_free (source_name_list);
g_list_free (target_name_list);
@@ -880,35 +895,48 @@ nautilus_file_cancel (NautilusFile *file,
static GnomeVFSURI *
nautilus_file_get_gnome_vfs_uri (NautilusFile *file)
{
+ GnomeVFSURI *vfs_uri;
+
+ vfs_uri = file->details->directory->details->vfs_uri;
+ if (vfs_uri == NULL) {
+ return NULL;
+ }
+
if (nautilus_file_is_self_owned (file)) {
- gnome_vfs_uri_ref (file->details->directory->details->uri);
- return file->details->directory->details->uri;
+ gnome_vfs_uri_ref (vfs_uri);
+ return vfs_uri;
}
return gnome_vfs_uri_append_file_name
- (file->details->directory->details->uri,
- file->details->name);
+ (vfs_uri, file->details->name);
}
gboolean
-nautilus_file_matches_uri (NautilusFile *file, const char *uri_string)
+nautilus_file_matches_uri (NautilusFile *file, const char *match_uri)
{
- GnomeVFSURI *match_uri;
- GnomeVFSURI *file_uri;
+ GnomeVFSURI *match_vfs_uri, *file_vfs_uri;
+ char *file_uri;
gboolean result;
g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
- g_return_val_if_fail (uri_string != NULL, FALSE);
+ g_return_val_if_fail (match_uri != NULL, FALSE);
- match_uri = gnome_vfs_uri_new (uri_string);
- if (match_uri == NULL) {
- return FALSE;
+ match_vfs_uri = gnome_vfs_uri_new (match_uri);
+ file_vfs_uri = nautilus_file_get_gnome_vfs_uri (file);
+
+ if (match_vfs_uri == NULL || file_vfs_uri == NULL) {
+ file_uri = nautilus_file_get_uri (file);
+ result = strcmp (match_uri, file_uri) == 0;
+ } else {
+ result = gnome_vfs_uri_equal (file_vfs_uri, match_vfs_uri);
}
- file_uri = nautilus_file_get_gnome_vfs_uri (file);
- result = gnome_vfs_uri_equal (file_uri, match_uri);
- gnome_vfs_uri_unref (file_uri);
- gnome_vfs_uri_unref (match_uri);
+ if (file_vfs_uri != NULL) {
+ gnome_vfs_uri_unref (file_vfs_uri);
+ }
+ if (match_vfs_uri != NULL) {
+ gnome_vfs_uri_unref (match_vfs_uri);
+ }
return result;
}
@@ -1149,14 +1177,14 @@ compare_emblem_names (const char *name_1, const char *name_2)
}
static int
-nautilus_file_compare_by_real_name (NautilusFile *file_1, NautilusFile *file_2)
+nautilus_file_compare_by_name (NautilusFile *file_1, NautilusFile *file_2)
{
char *name_1;
char *name_2;
int compare;
- name_1 = nautilus_file_get_real_name (file_1);
- name_2 = nautilus_file_get_real_name (file_2);
+ name_1 = nautilus_file_get_name (file_1);
+ name_2 = nautilus_file_get_name (file_2);
compare = nautilus_strcasecmp (name_1, name_2);
@@ -1167,25 +1195,21 @@ nautilus_file_compare_by_real_name (NautilusFile *file_1, NautilusFile *file_2)
}
static int
-nautilus_file_compare_by_real_directory (NautilusFile *file_1, NautilusFile *file_2)
+nautilus_file_compare_by_directory_name (NautilusFile *file_1, NautilusFile *file_2)
{
char *directory_1;
char *directory_2;
int compare;
- directory_1 = nautilus_file_get_real_directory (file_1);
- directory_2 = nautilus_file_get_real_directory (file_2);
+ directory_1 = nautilus_file_get_directory_name (file_1);
+ directory_2 = nautilus_file_get_directory_name (file_2);
compare = nautilus_strcasecmp (directory_1, directory_2);
g_free (directory_1);
g_free (directory_2);
- if (compare != 0) {
- return compare;
- }
-
- return nautilus_file_compare_by_real_name (file_1, file_2);
+ return compare;
}
static int
@@ -1304,17 +1328,17 @@ nautilus_file_compare_for_sort (NautilusFile *file_1,
* but I can imagine discussing this further.
* John Sullivan <sullivan@eazel.com>
*/
- compare = nautilus_file_compare_by_real_name (file_1, file_2);
+ compare = nautilus_file_compare_by_name (file_1, file_2);
if (compare != 0) {
return compare;
}
- return nautilus_file_compare_by_real_directory (file_1, file_2);
+ return nautilus_file_compare_by_directory_name (file_1, file_2);
case NAUTILUS_FILE_SORT_BY_DIRECTORY:
- compare = nautilus_file_compare_by_real_directory (file_1, file_2);
+ compare = nautilus_file_compare_by_directory_name (file_1, file_2);
if (compare != 0) {
return compare;
}
- return nautilus_file_compare_by_real_name (file_1, file_2);
+ return nautilus_file_compare_by_name (file_1, file_2);
case NAUTILUS_FILE_SORT_BY_SIZE:
/* Compare directory sizes ourselves, then if necessary
* use GnomeVFS to compare file sizes.
@@ -1559,19 +1583,26 @@ nautilus_file_get_activation_uri (NautilusFile *file)
char *
nautilus_file_get_uri (NautilusFile *file)
{
- GnomeVFSURI *uri;
- char *uri_text;
+ GnomeVFSURI *vfs_uri;
+ char *uri;
g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);
if (nautilus_file_is_self_owned (file)) {
- return g_strdup (file->details->directory->details->uri_text);
+ return g_strdup (file->details->directory->details->uri);
}
- uri = nautilus_file_get_gnome_vfs_uri (file);
- uri_text = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE);
- gnome_vfs_uri_unref (uri);
- return uri_text;
+ vfs_uri = nautilus_file_get_gnome_vfs_uri (file);
+ if (vfs_uri != NULL) {
+ uri = gnome_vfs_uri_to_string (vfs_uri, GNOME_VFS_URI_HIDE_NONE);
+ gnome_vfs_uri_unref (vfs_uri);
+ return uri;
+ }
+
+ return g_strconcat (file->details->directory->details->uri,
+ "/",
+ file->details->name,
+ NULL);
}
/**
@@ -1906,7 +1937,7 @@ nautilus_file_set_permissions (NautilusFile *file,
gpointer callback_data)
{
Operation *op;
- GnomeVFSURI *uri;
+ GnomeVFSURI *vfs_uri;
GnomeVFSFileInfo *partial_file_info;
if (!nautilus_file_can_set_permissions (file)) {
@@ -1935,14 +1966,14 @@ nautilus_file_set_permissions (NautilusFile *file,
/* Change the file-on-disk permissions. */
partial_file_info = gnome_vfs_file_info_new ();
partial_file_info->permissions = new_permissions;
- uri = nautilus_file_get_gnome_vfs_uri (file);
+ vfs_uri = nautilus_file_get_gnome_vfs_uri (file);
gnome_vfs_async_set_file_info (&op->handle,
- uri, partial_file_info,
+ vfs_uri, partial_file_info,
GNOME_VFS_SET_FILE_INFO_PERMISSIONS,
GNOME_VFS_FILE_INFO_DEFAULT,
set_permissions_callback, op);
gnome_vfs_file_info_unref (partial_file_info);
- gnome_vfs_uri_unref (uri);
+ gnome_vfs_uri_unref (vfs_uri);
}
static char *
@@ -2657,30 +2688,6 @@ nautilus_file_get_owner_as_string (NautilusFile *file, gboolean include_real_nam
return g_strdup_printf ("%d", file->details->info->uid);
}
-/**
- * nautilus_file_get_mime_type_as_string_attribute:
- *
- * Get a user-displayable string representing a file's MIME type.
- * This string will be displayed in file manager views and thus
- * will not be blank even if the MIME type is unknown. The caller
- * is responsible for g_free-ing this string.
- * @file: NautilusFile representing the file in question.
- *
- * Returns: Newly allocated string ready to display to the user.
- *
- **/
-static char *
-nautilus_file_get_mime_type_as_string_attribute (NautilusFile *file)
-{
- char *mime_string;
-
- mime_string = nautilus_file_get_mime_type (file);
- if (mime_string != NULL) {
- return mime_string;
- }
- return NULL;
-}
-
static char *
format_item_count_for_display (guint item_count,
gboolean includes_directories,
@@ -2902,7 +2909,7 @@ nautilus_file_get_string_attribute (NautilusFile *file, const char *attribute_na
*/
if (strcmp (attribute_name, "name") == 0) {
- return nautilus_file_get_real_name (file);
+ return nautilus_file_get_name (file);
}
if (strcmp (attribute_name, "type") == 0) {
@@ -2910,7 +2917,7 @@ nautilus_file_get_string_attribute (NautilusFile *file, const char *attribute_na
}
if (strcmp (attribute_name, "mime_type") == 0) {
- return nautilus_file_get_mime_type_as_string_attribute (file);
+ return nautilus_file_get_mime_type (file);
}
if (strcmp (attribute_name, "size") == 0) {
@@ -2978,7 +2985,7 @@ nautilus_file_get_string_attribute (NautilusFile *file, const char *attribute_na
}
if (strcmp (attribute_name, "directory") == 0) {
- return nautilus_file_get_real_directory (file);
+ return nautilus_file_get_directory_name (file);
}
return NULL;
@@ -3126,7 +3133,8 @@ char *
nautilus_file_get_mime_type (NautilusFile *file)
{
return info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_MIME_TYPE)
- ? NULL : g_strdup (file->details->info->mime_type);
+ ? g_strdup ("application/octet-stream")
+ : g_strdup (file->details->info->mime_type);
}
/**
@@ -3357,32 +3365,31 @@ nautilus_file_is_directory (NautilusFile *file)
gboolean
nautilus_file_is_in_trash (NautilusFile *file)
{
- GnomeVFSURI *file_uri, *trash_dir_uri;
- char *uri_string;
+ GnomeVFSURI *file_vfs_uri, *trash_vfs_uri;
gboolean result;
g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
- uri_string = nautilus_file_get_uri (file);
- file_uri = gnome_vfs_uri_new (uri_string);
- g_free (uri_string);
-
- /* Start with NULL so we don't try to unref uninitialized garbage later */
- trash_dir_uri = NULL;
-
- result = gnome_vfs_find_directory (file_uri, GNOME_VFS_DIRECTORY_KIND_TRASH,
- &trash_dir_uri, FALSE, FALSE, 0777) == GNOME_VFS_OK;
+ file_vfs_uri = nautilus_file_get_gnome_vfs_uri (file);
+ if (file_vfs_uri == NULL) {
+ return FALSE;
+ }
+ /* FIXME: Is it OK to do I/O here? Don't we need to keep a
+ * cached list of trash directories somewhere to guarantee we
+ * don't do sync. I/O in this case?
+ */
+ result = gnome_vfs_find_directory
+ (file_vfs_uri, GNOME_VFS_DIRECTORY_KIND_TRASH,
+ &trash_vfs_uri, FALSE, FALSE, 0777)
+ == GNOME_VFS_OK;
if (result) {
- result = (gnome_vfs_uri_equal (trash_dir_uri, file_uri)
- || gnome_vfs_uri_is_parent (trash_dir_uri, file_uri, TRUE));
+ result = gnome_vfs_uri_equal (trash_vfs_uri, file_vfs_uri)
+ || gnome_vfs_uri_is_parent (trash_vfs_uri, file_vfs_uri, TRUE);
+ gnome_vfs_uri_unref (trash_vfs_uri);
}
- if (trash_dir_uri) {
- gnome_vfs_uri_unref (trash_dir_uri);
- }
- gnome_vfs_uri_unref (file_uri);
-
+ gnome_vfs_uri_unref (file_vfs_uri);
return result;
}
@@ -3411,7 +3418,7 @@ nautilus_file_contains_text (NautilusFile *file)
mime_type = nautilus_file_get_mime_type (file);
contains_text = nautilus_istr_has_prefix (mime_type, "text/")
- || (mime_type == NULL
+ || (g_strcasecmp (mime_type, "application/octet-stream") == 0
&& nautilus_file_get_file_type (file) == GNOME_VFS_FILE_TYPE_REGULAR);
g_free (mime_type);
@@ -3474,84 +3481,25 @@ nautilus_file_get_top_left_text (NautilusFile *file)
return g_strdup (file->details->top_left_text);
}
-
-gboolean
-nautilus_file_is_search_result (NautilusFile *file)
-{
- if (file == NULL) {
- return FALSE;
- }
- g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
-
- if (file->details->directory == NULL) {
- return FALSE;
- }
- /* FIXME: Perhaps we should cache this value,
- since we check it a lot, and it doesn't change
- throughout a file's existence */
- return nautilus_directory_is_search_directory (file->details->directory);
-}
-
-char *
-nautilus_file_get_real_name (NautilusFile *file)
-{
- char *name;
- char *decoded_name;
- GnomeVFSURI *vfs_uri;
-
- if (file == NULL) {
- return NULL;
- }
- g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);
-
- name = nautilus_file_get_name (file);
-
- if (nautilus_file_is_search_result (file)) {
- decoded_name = gnome_vfs_unescape_string (name, NULL);
- g_free (name);
-
- vfs_uri = gnome_vfs_uri_new (decoded_name);
- /* FIXME: This can be NULL if the search result URI is bad.
- * I think a core dump is a bit too much here, so we might
- * have to add a bit more checking.
- */
- g_free (decoded_name);
- name = gnome_vfs_uri_extract_short_path_name (vfs_uri);
- gnome_vfs_uri_unref (vfs_uri);
- }
-
- return name;
-}
-
-
static char *
-nautilus_file_get_real_directory (NautilusFile *file)
+nautilus_file_get_directory_name (NautilusFile *file)
{
- char *escaped_uri;
- char *uri;
GnomeVFSURI *vfs_uri;
- char *dir;
+ char *directory_name;
if (file == NULL) {
return NULL;
}
g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);
- if (nautilus_file_is_search_result (file)) {
- escaped_uri = nautilus_file_get_name (file);
- uri = gnome_vfs_unescape_string (escaped_uri, NULL);
- g_free (escaped_uri);
-
- } else {
- uri = nautilus_file_get_uri (file);
+ vfs_uri = nautilus_file_get_gnome_vfs_uri (file);
+ if (vfs_uri == NULL) {
+ return NULL;
}
-
- vfs_uri = gnome_vfs_uri_new (uri);
- g_free (uri);
- dir = gnome_vfs_uri_extract_dirname (vfs_uri);
+ directory_name = gnome_vfs_uri_extract_dirname (vfs_uri);
gnome_vfs_uri_unref (vfs_uri);
- return dir;
+ return directory_name;
}
void
@@ -3577,8 +3525,6 @@ nautilus_file_mark_gone (NautilusFile *file)
}
/* Let the directory know it's gone. */
- /* FIXME: I think the real and the search directories need to
- know in the case of the file being in a search directory */
directory = file->details->directory;
if (directory->details->as_file != file) {
files = &directory->details->files;
@@ -3609,8 +3555,6 @@ nautilus_file_changed (NautilusFile *file)
fake_list.data = file;
fake_list.next = NULL;
fake_list.prev = NULL;
- /* FIXME: I think here for search directories we may need
- to notify both the real directory and the virtual directory */
nautilus_directory_emit_files_changed (file->details->directory, &fake_list);
}
}
diff --git a/libnautilus-private/nautilus-file.h b/libnautilus-private/nautilus-file.h
index 461b269f9..e4e1bb71c 100644
--- a/libnautilus-private/nautilus-file.h
+++ b/libnautilus-private/nautilus-file.h
@@ -142,10 +142,6 @@ GList * nautilus_file_get_emblem_names (NautilusFile
char * nautilus_file_get_top_left_text (NautilusFile *file);
-/* Attributes that behave specially for search results */
-gboolean nautilus_file_is_search_result (NautilusFile *file);
-char * nautilus_file_get_real_name (NautilusFile *file);
-
/* Permissions. */
gboolean nautilus_file_can_get_permissions (NautilusFile *file);
gboolean nautilus_file_can_set_permissions (NautilusFile *file);
diff --git a/libnautilus-private/nautilus-mime-actions.c b/libnautilus-private/nautilus-mime-actions.c
index 2731a4e27..da20596e3 100644
--- a/libnautilus-private/nautilus-mime-actions.c
+++ b/libnautilus-private/nautilus-mime-actions.c
@@ -424,9 +424,13 @@ nautilus_mime_get_short_list_applications_for_uri (const char *uri)
nautilus_directory_wait_for_metadata (directory);
metadata_application_add_ids = nautilus_directory_get_metadata_list
- (directory, NAUTILUS_METADATA_KEY_SHORT_LIST_APPLICATION_ADD, NAUTILUS_METADATA_SUBKEY_APPLICATION_ID);
+ (directory,
+ NAUTILUS_METADATA_KEY_SHORT_LIST_APPLICATION_ADD,
+ NAUTILUS_METADATA_SUBKEY_APPLICATION_ID);
metadata_application_remove_ids = nautilus_directory_get_metadata_list
- (directory, NAUTILUS_METADATA_KEY_SHORT_LIST_APPLICATION_REMOVE, NAUTILUS_METADATA_SUBKEY_APPLICATION_ID);
+ (directory,
+ NAUTILUS_METADATA_KEY_SHORT_LIST_APPLICATION_REMOVE,
+ NAUTILUS_METADATA_SUBKEY_APPLICATION_ID);
nautilus_directory_unref (directory);
mime_type = get_mime_type_from_uri (uri);
@@ -495,9 +499,13 @@ nautilus_mime_get_short_list_components_for_uri (const char *uri)
g_list_free (attributes);
metadata_component_add_ids = nautilus_directory_get_metadata_list
- (directory, NAUTILUS_METADATA_KEY_SHORT_LIST_COMPONENT_ADD, NAUTILUS_METADATA_SUBKEY_COMPONENT_IID);
+ (directory,
+ NAUTILUS_METADATA_KEY_SHORT_LIST_COMPONENT_ADD,
+ NAUTILUS_METADATA_SUBKEY_COMPONENT_IID);
metadata_component_remove_ids = nautilus_directory_get_metadata_list
- (directory, NAUTILUS_METADATA_KEY_SHORT_LIST_COMPONENT_REMOVE, NAUTILUS_METADATA_SUBKEY_COMPONENT_IID);
+ (directory,
+ NAUTILUS_METADATA_KEY_SHORT_LIST_COMPONENT_REMOVE,
+ NAUTILUS_METADATA_SUBKEY_COMPONENT_IID);
nautilus_directory_unref (directory);
mime_type = get_mime_type_from_uri (uri);
@@ -586,7 +594,9 @@ nautilus_mime_get_all_applications_for_uri (const char *uri)
nautilus_directory_wait_for_metadata (directory);
metadata_application_ids = nautilus_directory_get_metadata_list
- (directory, NAUTILUS_METADATA_KEY_EXPLICIT_APPLICATION, NAUTILUS_METADATA_SUBKEY_APPLICATION_ID);
+ (directory,
+ NAUTILUS_METADATA_KEY_EXPLICIT_APPLICATION,
+ NAUTILUS_METADATA_SUBKEY_APPLICATION_ID);
nautilus_directory_unref (directory);
mime_type = get_mime_type_from_uri (uri);
@@ -779,9 +789,15 @@ nautilus_mime_set_short_list_applications_for_uri (const char *uri,
nautilus_directory_wait_for_metadata (directory);
nautilus_directory_set_metadata_list
- (directory, NAUTILUS_METADATA_KEY_SHORT_LIST_APPLICATION_ADD, NAUTILUS_METADATA_SUBKEY_APPLICATION_ID, add_list);
+ (directory,
+ NAUTILUS_METADATA_KEY_SHORT_LIST_APPLICATION_ADD,
+ NAUTILUS_METADATA_SUBKEY_APPLICATION_ID,
+ add_list);
nautilus_directory_set_metadata_list
- (directory, NAUTILUS_METADATA_KEY_SHORT_LIST_APPLICATION_REMOVE, NAUTILUS_METADATA_SUBKEY_APPLICATION_ID, remove_list);
+ (directory,
+ NAUTILUS_METADATA_KEY_SHORT_LIST_APPLICATION_REMOVE,
+ NAUTILUS_METADATA_SUBKEY_APPLICATION_ID,
+ remove_list);
nautilus_directory_unref (directory);
/* FIXME bugzilla.eazel.com 1269:
@@ -823,9 +839,15 @@ nautilus_mime_set_short_list_components_for_uri (const char *uri,
nautilus_directory_wait_for_metadata (directory);
nautilus_directory_set_metadata_list
- (directory, NAUTILUS_METADATA_KEY_SHORT_LIST_COMPONENT_ADD, NAUTILUS_METADATA_SUBKEY_COMPONENT_IID, add_list);
+ (directory,
+ NAUTILUS_METADATA_KEY_SHORT_LIST_COMPONENT_ADD,
+ NAUTILUS_METADATA_SUBKEY_COMPONENT_IID,
+ add_list);
nautilus_directory_set_metadata_list
- (directory, NAUTILUS_METADATA_KEY_SHORT_LIST_COMPONENT_REMOVE, NAUTILUS_METADATA_SUBKEY_COMPONENT_IID, remove_list);
+ (directory,
+ NAUTILUS_METADATA_KEY_SHORT_LIST_COMPONENT_REMOVE,
+ NAUTILUS_METADATA_SUBKEY_COMPONENT_IID,
+ remove_list);
nautilus_directory_unref (directory);
/* FIXME bugzilla.eazel.com 1269:
@@ -1064,7 +1086,9 @@ get_explicit_content_view_iids_from_metafile (NautilusDirectory *directory)
{
if (directory != NULL) {
return nautilus_directory_get_metadata_list
- (directory, NAUTILUS_METADATA_KEY_EXPLICIT_COMPONENT, NAUTILUS_METADATA_SUBKEY_COMPONENT_IID);
+ (directory,
+ NAUTILUS_METADATA_KEY_EXPLICIT_COMPONENT,
+ NAUTILUS_METADATA_SUBKEY_COMPONENT_IID);
} else {
return NULL;
}
@@ -1457,42 +1481,34 @@ get_mime_type_from_uri (const char *text_uri)
GnomeVFSURI *vfs_uri;
GnomeVFSFileInfo *file_info;
GnomeVFSResult result;
- const char *ctype;
char *type;
- if (text_uri == NULL) {
- return NULL;
- }
-
type = NULL;
- /* FIXME bugzilla.eazel.com 1263:
- A better way would be to get this info using
- NautilusFile or NautilusDirectory or something, having
- previously ensured that the info has been computed
- async. */
-
- vfs_uri = gnome_vfs_uri_new (text_uri);
-
- if (vfs_uri != NULL) {
- file_info = gnome_vfs_file_info_new ();
+ if (text_uri != NULL) {
+ /* FIXME bugzilla.eazel.com 1263:
+ A better way would be to get this info using
+ NautilusFile or NautilusDirectory or something, having
+ previously ensured that the info has been computed
+ async. */
- result = gnome_vfs_get_file_info_uri (vfs_uri, file_info,
- GNOME_VFS_FILE_INFO_GET_MIME_TYPE
- | GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
- if (result == GNOME_VFS_OK) {
- ctype = gnome_vfs_file_info_get_mime_type (file_info);
+ vfs_uri = gnome_vfs_uri_new (text_uri);
+
+ if (vfs_uri != NULL) {
+ file_info = gnome_vfs_file_info_new ();
- if (ctype != NULL) {
- type = g_strdup (ctype);
+ result = gnome_vfs_get_file_info_uri (vfs_uri, file_info,
+ GNOME_VFS_FILE_INFO_GET_MIME_TYPE
+ | GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
+ if (result == GNOME_VFS_OK) {
+ type = g_strdup (gnome_vfs_file_info_get_mime_type (file_info));
+ gnome_vfs_file_info_unref (file_info);
+ gnome_vfs_uri_unref (vfs_uri);
}
-
- gnome_vfs_file_info_unref (file_info);
- gnome_vfs_uri_unref (vfs_uri);
- }
+ }
}
- return type;
+ return type == NULL ? g_strdup ("application/octet-stream") : type;
}
static int
diff --git a/libnautilus-private/nautilus-trash-directory.c b/libnautilus-private/nautilus-trash-directory.c
new file mode 100644
index 000000000..269162c81
--- /dev/null
+++ b/libnautilus-private/nautilus-trash-directory.c
@@ -0,0 +1,67 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
+
+ nautilus-trash-directory.c: Subclass of NautilusDirectory to implement the
+ virtual trash directory.
+
+ Copyright (C) 1999, 2000 Eazel, Inc.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+ Author: Darin Adler <darin@eazel.com>
+*/
+
+#include <config.h>
+#include "nautilus-trash-directory.h"
+
+#include "nautilus-gtk-macros.h"
+
+struct NautilusTrashDirectoryDetails {
+};
+
+static void nautilus_trash_directory_destroy (GtkObject *object);
+static void nautilus_trash_directory_initialize (gpointer object,
+ gpointer klass);
+static void nautilus_trash_directory_initialize_class (gpointer klass);
+
+NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusTrashDirectory,
+ nautilus_trash_directory,
+ NAUTILUS_TYPE_DIRECTORY)
+
+static void
+nautilus_trash_directory_initialize_class (gpointer klass)
+{
+ GtkObjectClass *object_class;
+
+ object_class = GTK_OBJECT_CLASS (klass);
+
+ object_class->destroy = nautilus_trash_directory_destroy;
+}
+
+static void
+nautilus_trash_directory_initialize (gpointer object, gpointer klass)
+{
+ NautilusTrashDirectory *directory;
+
+ directory = NAUTILUS_TRASH_DIRECTORY (object);
+
+ directory->details = g_new0 (NautilusTrashDirectoryDetails, 1);
+}
+
+static void
+nautilus_trash_directory_destroy (GtkObject *object)
+{
+ NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object));
+}
diff --git a/libnautilus-private/nautilus-trash-directory.h b/libnautilus-private/nautilus-trash-directory.h
new file mode 100644
index 000000000..73f53d492
--- /dev/null
+++ b/libnautilus-private/nautilus-trash-directory.h
@@ -0,0 +1,56 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
+
+ nautilus-trash-directory.h: Subclass of NautilusDirectory to implement the
+ virtual trash directory.
+
+ Copyright (C) 1999, 2000 Eazel, Inc.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+ Author: Darin Adler <darin@eazel.com>
+*/
+
+#ifndef NAUTILUS_TRASH_DIRECTORY_H
+#define NAUTILUS_TRASH_DIRECTORY_H
+
+#include "nautilus-directory.h"
+
+#define NAUTILUS_TYPE_TRASH_DIRECTORY \
+ (nautilus_trash_directory_get_type ())
+#define NAUTILUS_TRASH_DIRECTORY(obj) \
+ (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_TRASH_DIRECTORY, NautilusTrashDirectory))
+#define NAUTILUS_TRASH_DIRECTORY_CLASS(klass) \
+ (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_TRASH_DIRECTORY, NautilusTrashDirectoryClass))
+#define NAUTILUS_IS_TRASH_DIRECTORY(obj) \
+ (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_TRASH_DIRECTORY))
+#define NAUTILUS_IS_TRASH_DIRECTORY_CLASS(klass) \
+ (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_TRASH_DIRECTORY))
+
+typedef struct NautilusTrashDirectoryDetails NautilusTrashDirectoryDetails;
+
+typedef struct {
+ NautilusDirectory parent_slot;
+ NautilusTrashDirectoryDetails *details;
+} NautilusTrashDirectory;
+
+typedef struct {
+ NautilusDirectoryClass parent_slot;
+} NautilusTrashDirectoryClass;
+
+GtkType nautilus_trash_directory_get_type (void);
+NautilusTrashDirectory *nautilus_trash_directory_get (void);
+
+#endif /* NAUTILUS_TRASH_DIRECTORY_H */
diff --git a/libnautilus-private/nautilus-vfs-directory.c b/libnautilus-private/nautilus-vfs-directory.c
new file mode 100644
index 000000000..424e55827
--- /dev/null
+++ b/libnautilus-private/nautilus-vfs-directory.c
@@ -0,0 +1,67 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
+
+ nautilus-vfs-directory.c: Subclass of NautilusDirectory to help implement the
+ virtual trash directory.
+
+ Copyright (C) 1999, 2000 Eazel, Inc.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+ Author: Darin Adler <darin@eazel.com>
+*/
+
+#include <config.h>
+#include "nautilus-vfs-directory.h"
+
+#include "nautilus-gtk-macros.h"
+
+struct NautilusVFSDirectoryDetails {
+};
+
+static void nautilus_vfs_directory_destroy (GtkObject *object);
+static void nautilus_vfs_directory_initialize (gpointer object,
+ gpointer klass);
+static void nautilus_vfs_directory_initialize_class (gpointer klass);
+
+NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusVFSDirectory,
+ nautilus_vfs_directory,
+ NAUTILUS_TYPE_DIRECTORY)
+
+static void
+nautilus_vfs_directory_initialize_class (gpointer klass)
+{
+ GtkObjectClass *object_class;
+
+ object_class = GTK_OBJECT_CLASS (klass);
+
+ object_class->destroy = nautilus_vfs_directory_destroy;
+}
+
+static void
+nautilus_vfs_directory_initialize (gpointer object, gpointer klass)
+{
+ NautilusVFSDirectory *directory;
+
+ directory = NAUTILUS_VFS_DIRECTORY (object);
+
+ directory->details = g_new0 (NautilusVFSDirectoryDetails, 1);
+}
+
+static void
+nautilus_vfs_directory_destroy (GtkObject *object)
+{
+ NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object));
+}
diff --git a/libnautilus-private/nautilus-vfs-directory.h b/libnautilus-private/nautilus-vfs-directory.h
new file mode 100644
index 000000000..922b768bb
--- /dev/null
+++ b/libnautilus-private/nautilus-vfs-directory.h
@@ -0,0 +1,55 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
+
+ nautilus-vfs-directory.h: Subclass of NautilusDirectory to implement the
+ the case of a VFS directory.
+
+ Copyright (C) 1999, 2000 Eazel, Inc.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+ Author: Darin Adler <darin@eazel.com>
+*/
+
+#ifndef NAUTILUS_VFS_DIRECTORY_H
+#define NAUTILUS_VFS_DIRECTORY_H
+
+#include "nautilus-directory.h"
+
+#define NAUTILUS_TYPE_VFS_DIRECTORY \
+ (nautilus_vfs_directory_get_type ())
+#define NAUTILUS_VFS_DIRECTORY(obj) \
+ (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_VFS_DIRECTORY, NautilusVFSDirectory))
+#define NAUTILUS_VFS_DIRECTORY_CLASS(klass) \
+ (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_VFS_DIRECTORY, NautilusVFSDirectoryClass))
+#define NAUTILUS_IS_VFS_DIRECTORY(obj) \
+ (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_VFS_DIRECTORY))
+#define NAUTILUS_IS_VFS_DIRECTORY_CLASS(klass) \
+ (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_VFS_DIRECTORY))
+
+typedef struct NautilusVFSDirectoryDetails NautilusVFSDirectoryDetails;
+
+typedef struct {
+ NautilusDirectory parent_slot;
+ NautilusVFSDirectoryDetails *details;
+} NautilusVFSDirectory;
+
+typedef struct {
+ NautilusDirectoryClass parent_slot;
+} NautilusVFSDirectoryClass;
+
+GtkType nautilus_vfs_directory_get_type (void);
+
+#endif /* NAUTILUS_VFS_DIRECTORY_H */
diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c
index 864b0d71e..d001a3157 100644
--- a/src/file-manager/fm-directory-view.c
+++ b/src/file-manager/fm-directory-view.c
@@ -1013,7 +1013,7 @@ fm_directory_view_display_selection_info (FMDirectoryView *view)
}
if (first_item_name == NULL) {
- first_item_name = nautilus_file_get_real_name (file);
+ first_item_name = nautilus_file_get_name (file);
}
}
diff --git a/src/file-manager/fm-search-list-view.c b/src/file-manager/fm-search-list-view.c
index fb1ecdbf2..12f6e0b6e 100644
--- a/src/file-manager/fm-search-list-view.c
+++ b/src/file-manager/fm-search-list-view.c
@@ -366,7 +366,8 @@ real_adding_file (FMListView *view, NautilusFile *file)
*/
attributes = nautilus_icon_factory_get_required_file_attributes ();
attributes = g_list_prepend (attributes,
- NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_COUNT); nautilus_file_monitor_add (file, view, attributes, TRUE);
+ NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_COUNT);
+ nautilus_file_monitor_add (file, view, attributes, TRUE);
g_list_free (attributes);
}
diff --git a/src/nautilus-switchable-navigation-bar.c b/src/nautilus-switchable-navigation-bar.c
index f37946255..a2b4bbed1 100644
--- a/src/nautilus-switchable-navigation-bar.c
+++ b/src/nautilus-switchable-navigation-bar.c
@@ -27,23 +27,19 @@
* that can switch between the location bar and the search bar.
*/
-
#include <config.h>
#include "nautilus-switchable-navigation-bar.h"
-#include "nautilus-switchable-search-bar.h"
-
-#include <libgnome/gnome-defs.h>
-#include <libgnome/gnome-i18n.h>
+#include "nautilus-switchable-search-bar.h"
#include <gtk/gtklabel.h>
#include <gtk/gtksignal.h>
-
+#include <libgnome/gnome-defs.h>
+#include <libgnome/gnome-i18n.h>
#include <libnautilus-extensions/nautilus-directory.h>
#include <libnautilus-extensions/nautilus-gtk-macros.h>
-
+#include <libnautilus-extensions/nautilus-string.h>
#include <stdio.h>
-
enum {
MODE_CHANGED,
LAST_SIGNAL
@@ -168,7 +164,6 @@ nautilus_switchable_navigation_bar_set_location (NautilusNavigationBar *navigati
const char *location)
{
NautilusSwitchableNavigationBar *bar;
- NautilusDirectory *directory;
bar = NAUTILUS_SWITCHABLE_NAVIGATION_BAR (navigation_bar);
@@ -181,8 +176,8 @@ nautilus_switchable_navigation_bar_set_location (NautilusNavigationBar *navigati
location);
/* Toggle the search button on and off appropriately */
- directory = nautilus_directory_get (location);
- if (nautilus_directory_is_search_directory (directory)) {
+ if (nautilus_istr_has_prefix (location, "search:")
+ || nautilus_istr_has_prefix (location, "gnome-search:")) {
nautilus_switchable_navigation_bar_set_mode
(bar, NAUTILUS_SWITCHABLE_NAVIGATION_BAR_MODE_SEARCH);
}
@@ -190,6 +185,4 @@ nautilus_switchable_navigation_bar_set_location (NautilusNavigationBar *navigati
nautilus_switchable_navigation_bar_set_mode
(bar, NAUTILUS_SWITCHABLE_NAVIGATION_BAR_MODE_LOCATION);
}
-
- nautilus_directory_unref (directory);
}
diff --git a/src/nautilus-view-frame.c b/src/nautilus-view-frame.c
index 402223a29..79d373705 100644
--- a/src/nautilus-view-frame.c
+++ b/src/nautilus-view-frame.c
@@ -395,6 +395,7 @@ set_up_for_new_location (NautilusViewFrame *view)
{
g_free (view->details->title);
view->details->title = NULL;
+ gtk_signal_emit (GTK_OBJECT (view), signals[TITLE_CHANGED]);
}
void