reviewed by: Gene Ragan <gzr@eazel.com>

Fixed bug 5676 (Moving a directory with multiple nested
	directories causes improper locations to be displayed):

	* libnautilus-extensions/nautilus-directory-private.h:
	* libnautilus-extensions/nautilus-directory.c:
	(nautilus_directory_moved_internal): Made this build a list of the
	affected files.
	(nautilus_directory_moved): Send a changed notice to each affected
	file.
	(nautilus_directory_notify_files_moved): Send a changed notice to
	each affected file, but share code to avoid sending changed
	notices twice for any directory.

	Fixed some callers that were assuming a
	gnome_vfs_get_local_path_from_uri would return a non-NULL
	value. This is not safe to assume just because
	gnome_vfs_uri_get_local returns true.

	* components/music/nautilus-music-view.c: (read_id_tag): Use
	gnome_vfs_get_local_path_from_uri to define what a local path is.
	The old code used a mix.
	* libnautilus-extensions/nautilus-file.c:
	(nautilus_file_can_rename): Simplified code to use
	gnome_vfs_get_local_path_from_uri to define what a local path
	is. The old code used a mix.
	* libnautilus-extensions/nautilus-thumbnails.c: (make_thumbnails):
	Added NULL checks after calls to
	gnome_vfs_get_local_path_from_uri.
	* src/nautilus-sidebar.c: (uri_is_local_image): Took out redundant
	check. The definition of local image we want here is: "uses a
	standard file: URI".
	* src/file-manager/fm-directory-view.c:
	(fm_directory_link_type_in_selection): Fixed bug where it would
	only look at the first item in the selection. Simplified logic.
	(is_link_type_special): Added a new function.
	(special_link_in_selection): Instead of calling
	fm_directory_link_type_in_selection, copied it. The problem with
	the other approach is that it was reading each link file three
	time to rule out each of the three special link types.

	Other changes.

	* libnautilus-extensions/nautilus-volume-monitor.c:
	(nautilus_volume_monitor_get_volume_name),
	(modify_volume_name_for_display): Marked "Unknown" for
	localization.

	* libnautilus-extensions/nautilus-file-utilities.c:
	* libnautilus-extensions/nautilus-icon-factory.c:
	* src/file-manager/fm-icon-view.c:
	Added 2001 to the copyright since we modified these recently.
This commit is contained in:
Darin Adler 2001-02-21 00:13:57 +00:00
parent 2122e8e233
commit e70c6e46b7
20 changed files with 401 additions and 252 deletions

View file

@ -1,3 +1,59 @@
2001-02-20 Darin Adler <darin@eazel.com>
reviewed by: Gene Ragan <gzr@eazel.com>
Fixed bug 5676 (Moving a directory with multiple nested
directories causes improper locations to be displayed):
* libnautilus-extensions/nautilus-directory-private.h:
* libnautilus-extensions/nautilus-directory.c:
(nautilus_directory_moved_internal): Made this build a list of the
affected files.
(nautilus_directory_moved): Send a changed notice to each affected
file.
(nautilus_directory_notify_files_moved): Send a changed notice to
each affected file, but share code to avoid sending changed
notices twice for any directory.
Fixed some callers that were assuming a
gnome_vfs_get_local_path_from_uri would return a non-NULL
value. This is not safe to assume just because
gnome_vfs_uri_get_local returns true.
* components/music/nautilus-music-view.c: (read_id_tag): Use
gnome_vfs_get_local_path_from_uri to define what a local path is.
The old code used a mix.
* libnautilus-extensions/nautilus-file.c:
(nautilus_file_can_rename): Simplified code to use
gnome_vfs_get_local_path_from_uri to define what a local path
is. The old code used a mix.
* libnautilus-extensions/nautilus-thumbnails.c: (make_thumbnails):
Added NULL checks after calls to
gnome_vfs_get_local_path_from_uri.
* src/nautilus-sidebar.c: (uri_is_local_image): Took out redundant
check. The definition of local image we want here is: "uses a
standard file: URI".
* src/file-manager/fm-directory-view.c:
(fm_directory_link_type_in_selection): Fixed bug where it would
only look at the first item in the selection. Simplified logic.
(is_link_type_special): Added a new function.
(special_link_in_selection): Instead of calling
fm_directory_link_type_in_selection, copied it. The problem with
the other approach is that it was reading each link file three
time to rule out each of the three special link types.
Other changes.
* libnautilus-extensions/nautilus-volume-monitor.c:
(nautilus_volume_monitor_get_volume_name),
(modify_volume_name_for_display): Marked "Unknown" for
localization.
* libnautilus-extensions/nautilus-file-utilities.c:
* libnautilus-extensions/nautilus-icon-factory.c:
* src/file-manager/fm-icon-view.c:
Added 2001 to the copyright since we modified these recently.
2001-02-20 John Sullivan <sullivan@eazel.com>
reviewed by: Darin Adler <darin@eazel.com>

View file

@ -1,7 +1,7 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2000 Eazel, Inc.
* Copyright (C) 2000, 2001 Eazel, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@ -799,30 +799,21 @@ is_mp3_file (GnomeVFSFileInfo *file_info)
static gboolean
read_id_tag (const char *song_uri, SongInfo *song_info)
{
const char *path;
char *escaped_path;
GnomeVFSURI *uri;
char *path;
id3_t *id3;
struct id3v1tag_t id3v1tag;
struct id3tag_t tag;
FILE *file;
uri = gnome_vfs_uri_new (song_uri);
if (uri == NULL) {
return FALSE;
}
if (!gnome_vfs_uri_is_local (uri)) {
gnome_vfs_uri_unref (uri);
return FALSE;
}
path = gnome_vfs_uri_get_path (uri);
escaped_path = gnome_vfs_unescape_string_for_display (path);
file = fopen (escaped_path, "rb");
path = gnome_vfs_get_local_path_from_uri (song_uri);
if (path == NULL) {
return FALSE;
}
file = fopen (path, "rb");
g_free (path);
if (file == NULL) {
gnome_vfs_uri_unref (uri);
g_free (escaped_path);
return FALSE;
}
@ -839,9 +830,7 @@ read_id_tag (const char *song_uri, SongInfo *song_info)
mpg123_id3v1_to_id3v2 (&id3v1tag, &tag);
} else {
/* Failed to read any sort of tag */
gnome_vfs_uri_unref (uri);
fclose (file);
g_free (escaped_path);
return FALSE;
}
@ -854,9 +843,7 @@ read_id_tag (const char *song_uri, SongInfo *song_info)
song_info->track_number = atoi (tag.track);
/* Clean up */
g_free (escaped_path);
fclose (file);
gnome_vfs_uri_unref (uri);
return TRUE;
}

View file

@ -2,7 +2,7 @@
nautilus-directory-private.h: Nautilus directory model.
Copyright (C) 1999, 2000 Eazel, Inc.
Copyright (C) 1999, 2000, 2001 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

View file

@ -990,7 +990,8 @@ nautilus_directory_notify_files_removed (GList *uris)
/* Mark it gone and prepare to send the changed signal. */
nautilus_file_mark_gone (file);
hash_table_list_prepend (changed_lists,
file->details->directory, file);
file->details->directory,
file);
}
}
@ -1138,15 +1139,15 @@ str_replace_prefix (const char *str,
return g_strconcat (new_prefix, old_suffix, NULL);
}
void
nautilus_directory_moved (const char *old_uri,
const char *new_uri)
static GList *
nautilus_directory_moved_internal (const char *old_uri,
const char *new_uri)
{
char *canonical_old_uri, *canonical_new_uri;
CollectData collection;
NautilusDirectory *directory;
char *new_directory_uri;
GList *node;
GList *node, *affected_files;
canonical_old_uri = nautilus_directory_make_uri_canonical (old_uri);
canonical_new_uri = nautilus_directory_make_uri_canonical (new_uri);
@ -1154,16 +1155,33 @@ nautilus_directory_moved (const char *old_uri,
collection.uri_prefix = canonical_old_uri;
collection.directories = NULL;
g_hash_table_foreach (directories, collect_directories_by_prefix, &collection);
g_hash_table_foreach (directories,
collect_directories_by_prefix,
&collection);
affected_files = NULL;
for (node = collection.directories; node != NULL; node = node->next) {
directory = NAUTILUS_DIRECTORY (node->data);
/* Change the URI in the directory object. */
new_directory_uri = str_replace_prefix (directory->details->uri,
canonical_old_uri,
canonical_new_uri);
change_directory_uri (directory,
new_directory_uri);
g_free (new_directory_uri);
/* Collect affected files. */
if (directory->details->as_file != NULL) {
affected_files = g_list_prepend
(affected_files,
nautilus_file_ref (directory->details->as_file));
}
affected_files = g_list_concat
(affected_files,
nautilus_file_list_copy (directory->details->file_list));
nautilus_directory_unref (directory);
}
@ -1171,12 +1189,37 @@ nautilus_directory_moved (const char *old_uri,
g_free (canonical_old_uri);
g_free (canonical_new_uri);
return affected_files;
}
void
nautilus_directory_moved (const char *old_uri,
const char *new_uri)
{
GList *list, *node;
GHashTable *hash;
NautilusFile *file;
hash = g_hash_table_new (NULL, NULL);
list = nautilus_directory_moved_internal (old_uri, new_uri);
for (node = list; node != NULL; node = node->next) {
file = NAUTILUS_FILE (node->data);
hash_table_list_prepend (hash,
file->details->directory,
file);
}
nautilus_file_list_free (list);
g_hash_table_foreach (hash, call_files_changed_unref_free_list, NULL);
g_hash_table_destroy (hash);
}
void
nautilus_directory_notify_files_moved (GList *uri_pairs)
{
GList *p;
GList *p, *affected_files, *node;
URIPair *pair;
NautilusFile *file;
NautilusDirectory *old_directory, *new_directory;
@ -1211,7 +1254,15 @@ nautilus_directory_notify_files_moved (GList *uri_pairs)
}
/* Update any directory objects that are affected. */
nautilus_directory_moved (pair->from_uri, pair->to_uri);
affected_files = nautilus_directory_moved_internal (pair->from_uri,
pair->to_uri);
for (node = affected_files; node != NULL; node = node->next) {
file = NAUTILUS_FILE (node->data);
hash_table_list_prepend (changed_lists,
file->details->directory,
file);
}
unref_list = g_list_concat (unref_list, affected_files);
/* Move an existing file. */
file = nautilus_file_get_existing (pair->from_uri);
@ -1242,11 +1293,13 @@ nautilus_directory_notify_files_moved (GList *uri_pairs)
/* Update the file's directory. */
nautilus_file_set_directory (file, new_directory);
hash_table_list_prepend
(changed_lists, old_directory, file);
hash_table_list_prepend (changed_lists,
old_directory,
file);
if (old_directory != new_directory) {
hash_table_list_prepend
(added_lists, new_directory, file);
hash_table_list_prepend (added_lists,
new_directory,
file);
}
/* Unref each file once to balance out nautilus_file_get. */

View file

@ -2,7 +2,7 @@
/* nautilus-file-utilities..c - implementation of file manipulation routines.
Copyright (C) 1999, 2000 Eazel, Inc.
Copyright (C) 1999, 2000, 2001 Eazel, Inc.
The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as

View file

@ -2,7 +2,7 @@
nautilus-file.c: Nautilus file model.
Copyright (C) 1999, 2000 Eazel, Inc.
Copyright (C) 1999, 2000, 2001 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
@ -716,11 +716,8 @@ gboolean
nautilus_file_can_rename (NautilusFile *file)
{
NautilusFile *parent;
gboolean result;
const char *path;
char *text_uri, *unescaped_path;
GnomeVFSURI *uri;
gboolean can_rename_link;
gboolean can_rename;
char *uri, *path;
g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
@ -734,45 +731,37 @@ nautilus_file_can_rename (NautilusFile *file)
return FALSE;
}
can_rename = TRUE;
uri = nautilus_file_get_uri (file);
path = gnome_vfs_get_local_path_from_uri (uri);
/* Certain types of links can't be renamed */
if (nautilus_file_is_nautilus_link (file)) {
text_uri = nautilus_file_get_uri (file);
uri = gnome_vfs_uri_new (text_uri);
path = gnome_vfs_uri_get_path (uri);
unescaped_path = gnome_vfs_unescape_string_for_display (path);
switch (nautilus_link_local_get_link_type (unescaped_path)) {
case NAUTILUS_LINK_HOME:
case NAUTILUS_LINK_GENERIC:
can_rename_link = TRUE;
break;
case NAUTILUS_LINK_TRASH:
case NAUTILUS_LINK_MOUNT:
can_rename_link = FALSE;
break;
default:
can_rename_link = FALSE;
break;
}
if (path != NULL && nautilus_file_is_nautilus_link (file)) {
/* FIXME: This reads the link file every time -- seems
* bad to do that even though it's known to be local.
*/
switch (nautilus_link_local_get_link_type (path)) {
case NAUTILUS_LINK_TRASH:
case NAUTILUS_LINK_MOUNT:
can_rename = FALSE;
break;
g_free (text_uri);
gnome_vfs_uri_unref (uri);
if (!can_rename_link) {
return FALSE;
case NAUTILUS_LINK_HOME:
case NAUTILUS_LINK_GENERIC:
break;
}
}
/* Nautilus trash directories cannot be renamed */
if (nautilus_file_is_directory (file)) {
text_uri = nautilus_file_get_uri (file);
if (nautilus_uri_is_trash_folder (text_uri)) {
g_free (text_uri);
return FALSE;
}
g_free (text_uri);
if (nautilus_uri_is_trash_folder (uri)) {
can_rename = FALSE;
}
g_free (uri);
g_free (path);
if (!can_rename) {
return FALSE;
}
/* User must have write permissions for the parent directory. */
@ -785,11 +774,11 @@ nautilus_file_can_rename (NautilusFile *file)
return TRUE;
}
result = nautilus_file_can_write (parent);
can_rename = nautilus_file_can_write (parent);
nautilus_file_unref (parent);
return result;
return can_rename;
}
static GnomeVFSURI *

View file

@ -3,7 +3,7 @@
nautilus-icon-factory.c: Class for obtaining icons for files and other objects.
Copyright (C) 1999, 2000 Red Hat Inc.
Copyright (C) 1999, 2000 Eazel, Inc.
Copyright (C) 1999, 2000, 2001 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

View file

@ -2,7 +2,7 @@
nautilus-thumbnails.h: Thumbnail code for icon factory.
Copyright (C) 2000 Eazel, Inc.
Copyright (C) 2000, 2001 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
@ -52,7 +52,7 @@
GNOME_VFS_PERM_OTHER_READ)
/* thumbnail task state */
static GList *thumbnails;
static char *new_thumbnail_path;
static char *new_thumbnail_uri;
static gboolean thumbnail_in_progress;
/* id of timeout task for making thumbnails */
@ -72,8 +72,10 @@ vfs_file_exists (const char *file_uri)
return FALSE;
}
/* FIXME bugzilla.eazel.com 3137: the synchronous I/O here means this call is
unsuitable for use on anything that might be remote. */
/* FIXME bugzilla.eazel.com 3137: The synchronous I/O here
* means this call is unsuitable for use on anything that
* might be remote.
*/
result = gnome_vfs_uri_exists (uri);
gnome_vfs_uri_unref (uri);
@ -83,8 +85,8 @@ vfs_file_exists (const char *file_uri)
/* utility routine that, given the uri of an image, constructs the uri to the corresponding thumbnail */
static char *
make_thumbnail_path (const char *image_uri, gboolean directory_only, gboolean use_local_directory,
gboolean anti_aliased, gboolean create_parents_if_needed)
make_thumbnail_uri (const char *image_uri, gboolean directory_only, gboolean use_local_directory,
gboolean anti_aliased, gboolean create_parents_if_needed)
{
GnomeVFSURI *vfs_uri;
char *thumbnail_uri, *thumbnail_path;
@ -253,7 +255,7 @@ gboolean nautilus_thumbnail_has_invalid_thumbnail (NautilusFile *file,
uri_is_local = gnome_vfs_uri_is_local (temp_uri);
gnome_vfs_uri_unref (temp_uri);
thumbnail_uri = make_thumbnail_path (file_uri, FALSE, uri_is_local, anti_aliased, TRUE);
thumbnail_uri = make_thumbnail_uri (file_uri, FALSE, uri_is_local, anti_aliased, TRUE);
invalid_thumbnail_uri = make_invalid_thumbnail_uri (thumbnail_uri);
is_invalid = vfs_file_exists (invalid_thumbnail_uri);
@ -289,7 +291,7 @@ nautilus_get_thumbnail_uri (NautilusFile *file, gboolean anti_aliased)
uri_is_local = gnome_vfs_uri_is_local (temp_uri);
gnome_vfs_uri_unref (temp_uri);
thumbnail_uri = make_thumbnail_path (file_uri, FALSE, uri_is_local, anti_aliased, TRUE);
thumbnail_uri = make_thumbnail_uri (file_uri, FALSE, uri_is_local, anti_aliased, TRUE);
/* if the thumbnail file already exists locally, simply return the uri */
@ -315,7 +317,7 @@ nautilus_get_thumbnail_uri (NautilusFile *file, gboolean anti_aliased)
/* now try it globally */
if (!remake_thumbnail) {
g_free (thumbnail_uri);
thumbnail_uri = make_thumbnail_path (file_uri, FALSE, FALSE, anti_aliased, TRUE);
thumbnail_uri = make_thumbnail_uri (file_uri, FALSE, FALSE, anti_aliased, TRUE);
/* if the thumbnail file already exists in the common area, return that uri, */
/* the uri is guaranteed to be local */
@ -340,7 +342,7 @@ nautilus_get_thumbnail_uri (NautilusFile *file, gboolean anti_aliased)
/* make the thumbnail directory if necessary, at first try it locally */
g_free (thumbnail_uri);
local_flag = TRUE;
thumbnail_uri = make_thumbnail_path (file_uri, TRUE, local_flag, anti_aliased, TRUE);
thumbnail_uri = make_thumbnail_uri (file_uri, TRUE, local_flag, anti_aliased, TRUE);
/* FIXME bugzilla.eazel.com 3137: more potentially losing
synch I/O - this could be remote */
@ -359,7 +361,7 @@ nautilus_get_thumbnail_uri (NautilusFile *file, gboolean anti_aliased)
if (!can_write || (result != GNOME_VFS_OK && result != GNOME_VFS_ERROR_FILE_EXISTS)) {
g_free (thumbnail_uri);
local_flag = FALSE;
thumbnail_uri = make_thumbnail_path (file_uri, TRUE, local_flag, anti_aliased, TRUE);
thumbnail_uri = make_thumbnail_uri (file_uri, TRUE, local_flag, anti_aliased, TRUE);
/* this is guaranteed to be local, so synch I/O can be tolerated here */
result = gnome_vfs_make_directory (thumbnail_uri, THUMBNAIL_DIR_PERMISSIONS);
}
@ -408,9 +410,9 @@ nautilus_update_thumbnail_file_renamed_one (const char *old_file_name, const cha
is_local = gnome_vfs_uri_is_local (uri);
gnome_vfs_uri_unref (uri);
old_thumbnail_uri = make_thumbnail_path (old_file_name, FALSE, is_local, anti_aliased, FALSE);
old_thumbnail_uri = make_thumbnail_uri (old_file_name, FALSE, is_local, anti_aliased, FALSE);
if (old_thumbnail_uri != NULL && vfs_file_exists (old_thumbnail_uri)) {
new_thumbnail_uri = make_thumbnail_path (new_file_name, FALSE, is_local, anti_aliased, FALSE);
new_thumbnail_uri = make_thumbnail_uri (new_file_name, FALSE, is_local, anti_aliased, FALSE);
g_assert (new_thumbnail_uri != NULL);
@ -442,7 +444,7 @@ nautilus_remove_thumbnail_for_file_one (const char *old_file_name, gboolean anti
is_local = gnome_vfs_uri_is_local (uri);
gnome_vfs_uri_unref (uri);
thumbnail_uri = make_thumbnail_path (old_file_name, FALSE, is_local, anti_aliased, FALSE);
thumbnail_uri = make_thumbnail_uri (old_file_name, FALSE, is_local, anti_aliased, FALSE);
if (thumbnail_uri != NULL && vfs_file_exists (thumbnail_uri)) {
gnome_vfs_unlink (thumbnail_uri);
}
@ -483,7 +485,7 @@ check_for_thumbnails (void)
/* the thumbnail task has completed, so update the current entry from the list */
file = nautilus_file_get (info->thumbnail_uri);
current_thumbnail = make_thumbnail_path (info->thumbnail_uri, FALSE, info->is_local,
current_thumbnail = make_thumbnail_uri (info->thumbnail_uri, FALSE, info->is_local,
info->anti_aliased, TRUE);
/* if a thumbnail wasn't successfully made, create a placeholder to flag that we tried */
@ -567,9 +569,9 @@ make_thumbnails (gpointer data)
/* start up a task to make the thumbnail corresponding to the queue element. */
/* First, compute the path name of the target thumbnail */
g_free (new_thumbnail_path);
new_thumbnail_path = make_thumbnail_path (info->thumbnail_uri, FALSE, info->is_local,
info->anti_aliased, TRUE);
g_free (new_thumbnail_uri);
new_thumbnail_uri = make_thumbnail_uri (info->thumbnail_uri, FALSE, info->is_local,
info->anti_aliased, TRUE);
/* fork a task to make the thumbnail, using gdk-pixbuf to do the scaling */
if (!(info->thumbnail_task = fork())) {
@ -626,8 +628,9 @@ make_thumbnails (gpointer data)
framed_image = scaled_image;
}
thumbnail_path = gnome_vfs_get_local_path_from_uri (new_thumbnail_path);
if (!nautilus_gdk_pixbuf_save_to_file (framed_image, thumbnail_path)) {
thumbnail_path = gnome_vfs_get_local_path_from_uri (new_thumbnail_uri);
if (thumbnail_path == NULL
|| !nautilus_gdk_pixbuf_save_to_file (framed_image, thumbnail_path)) {
g_warning ("error saving thumbnail %s", thumbnail_path);
}
g_free (thumbnail_path);
@ -635,14 +638,19 @@ make_thumbnails (gpointer data)
} else {
/* gdk-pixbuf couldn't load the image, so trying using ImageMagick */
char *temp_str;
thumbnail_path = gnome_vfs_get_local_path_from_uri (new_thumbnail_path);
temp_str = g_strdup_printf ("png:%s", thumbnail_path);
g_free (thumbnail_path);
thumbnail_path = gnome_vfs_get_local_path_from_uri (info->thumbnail_uri);
/* scale the image */
execlp ("convert", "convert", "-geometry", "96x96", thumbnail_path, temp_str, NULL);
thumbnail_path = gnome_vfs_get_local_path_from_uri (new_thumbnail_uri);
if (thumbnail_path != NULL) {
temp_str = g_strdup_printf ("png:%s", thumbnail_path);
g_free (thumbnail_path);
thumbnail_path = gnome_vfs_get_local_path_from_uri (info->thumbnail_uri);
if (thumbnail_path != NULL) {
/* scale the image */
execlp ("convert", "convert", "-geometry", "96x96", thumbnail_path, temp_str, NULL);
}
}
/* we don't come back from this call, so no point in freeing anything up */
}

View file

@ -263,7 +263,8 @@ static gboolean
has_removable_mntent_options (struct mntent *ent)
{
/* Use "owner" or "user" or "users" as our way of determining a removable volume */
if (hasmntopt (ent, "user") != NULL || hasmntopt (ent, "users") != NULL
if (hasmntopt (ent, "user") != NULL
|| hasmntopt (ent, "users") != NULL
|| hasmntopt (ent, "owner") != NULL) {
return TRUE;
}
@ -371,7 +372,7 @@ char *
nautilus_volume_monitor_get_volume_name (const NautilusVolume *volume)
{
if (volume->volume_name == NULL) {
return g_strdup ("Unknown");
return g_strdup (_("Unknown"));
}
return g_strdup (volume->volume_name);
@ -390,7 +391,7 @@ modify_volume_name_for_display (NautilusVolume *volume)
char *name;
if (volume->volume_name == NULL) {
volume->volume_name = g_strdup ("Unknown");
volume->volume_name = g_strdup (_("Unknown"));
return;
}

View file

@ -2,7 +2,7 @@
nautilus-directory-private.h: Nautilus directory model.
Copyright (C) 1999, 2000 Eazel, Inc.
Copyright (C) 1999, 2000, 2001 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

View file

@ -990,7 +990,8 @@ nautilus_directory_notify_files_removed (GList *uris)
/* Mark it gone and prepare to send the changed signal. */
nautilus_file_mark_gone (file);
hash_table_list_prepend (changed_lists,
file->details->directory, file);
file->details->directory,
file);
}
}
@ -1138,15 +1139,15 @@ str_replace_prefix (const char *str,
return g_strconcat (new_prefix, old_suffix, NULL);
}
void
nautilus_directory_moved (const char *old_uri,
const char *new_uri)
static GList *
nautilus_directory_moved_internal (const char *old_uri,
const char *new_uri)
{
char *canonical_old_uri, *canonical_new_uri;
CollectData collection;
NautilusDirectory *directory;
char *new_directory_uri;
GList *node;
GList *node, *affected_files;
canonical_old_uri = nautilus_directory_make_uri_canonical (old_uri);
canonical_new_uri = nautilus_directory_make_uri_canonical (new_uri);
@ -1154,16 +1155,33 @@ nautilus_directory_moved (const char *old_uri,
collection.uri_prefix = canonical_old_uri;
collection.directories = NULL;
g_hash_table_foreach (directories, collect_directories_by_prefix, &collection);
g_hash_table_foreach (directories,
collect_directories_by_prefix,
&collection);
affected_files = NULL;
for (node = collection.directories; node != NULL; node = node->next) {
directory = NAUTILUS_DIRECTORY (node->data);
/* Change the URI in the directory object. */
new_directory_uri = str_replace_prefix (directory->details->uri,
canonical_old_uri,
canonical_new_uri);
change_directory_uri (directory,
new_directory_uri);
g_free (new_directory_uri);
/* Collect affected files. */
if (directory->details->as_file != NULL) {
affected_files = g_list_prepend
(affected_files,
nautilus_file_ref (directory->details->as_file));
}
affected_files = g_list_concat
(affected_files,
nautilus_file_list_copy (directory->details->file_list));
nautilus_directory_unref (directory);
}
@ -1171,12 +1189,37 @@ nautilus_directory_moved (const char *old_uri,
g_free (canonical_old_uri);
g_free (canonical_new_uri);
return affected_files;
}
void
nautilus_directory_moved (const char *old_uri,
const char *new_uri)
{
GList *list, *node;
GHashTable *hash;
NautilusFile *file;
hash = g_hash_table_new (NULL, NULL);
list = nautilus_directory_moved_internal (old_uri, new_uri);
for (node = list; node != NULL; node = node->next) {
file = NAUTILUS_FILE (node->data);
hash_table_list_prepend (hash,
file->details->directory,
file);
}
nautilus_file_list_free (list);
g_hash_table_foreach (hash, call_files_changed_unref_free_list, NULL);
g_hash_table_destroy (hash);
}
void
nautilus_directory_notify_files_moved (GList *uri_pairs)
{
GList *p;
GList *p, *affected_files, *node;
URIPair *pair;
NautilusFile *file;
NautilusDirectory *old_directory, *new_directory;
@ -1211,7 +1254,15 @@ nautilus_directory_notify_files_moved (GList *uri_pairs)
}
/* Update any directory objects that are affected. */
nautilus_directory_moved (pair->from_uri, pair->to_uri);
affected_files = nautilus_directory_moved_internal (pair->from_uri,
pair->to_uri);
for (node = affected_files; node != NULL; node = node->next) {
file = NAUTILUS_FILE (node->data);
hash_table_list_prepend (changed_lists,
file->details->directory,
file);
}
unref_list = g_list_concat (unref_list, affected_files);
/* Move an existing file. */
file = nautilus_file_get_existing (pair->from_uri);
@ -1242,11 +1293,13 @@ nautilus_directory_notify_files_moved (GList *uri_pairs)
/* Update the file's directory. */
nautilus_file_set_directory (file, new_directory);
hash_table_list_prepend
(changed_lists, old_directory, file);
hash_table_list_prepend (changed_lists,
old_directory,
file);
if (old_directory != new_directory) {
hash_table_list_prepend
(added_lists, new_directory, file);
hash_table_list_prepend (added_lists,
new_directory,
file);
}
/* Unref each file once to balance out nautilus_file_get. */

View file

@ -2,7 +2,7 @@
/* nautilus-file-utilities..c - implementation of file manipulation routines.
Copyright (C) 1999, 2000 Eazel, Inc.
Copyright (C) 1999, 2000, 2001 Eazel, Inc.
The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as

View file

@ -2,7 +2,7 @@
nautilus-file.c: Nautilus file model.
Copyright (C) 1999, 2000 Eazel, Inc.
Copyright (C) 1999, 2000, 2001 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
@ -716,11 +716,8 @@ gboolean
nautilus_file_can_rename (NautilusFile *file)
{
NautilusFile *parent;
gboolean result;
const char *path;
char *text_uri, *unescaped_path;
GnomeVFSURI *uri;
gboolean can_rename_link;
gboolean can_rename;
char *uri, *path;
g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
@ -734,45 +731,37 @@ nautilus_file_can_rename (NautilusFile *file)
return FALSE;
}
can_rename = TRUE;
uri = nautilus_file_get_uri (file);
path = gnome_vfs_get_local_path_from_uri (uri);
/* Certain types of links can't be renamed */
if (nautilus_file_is_nautilus_link (file)) {
text_uri = nautilus_file_get_uri (file);
uri = gnome_vfs_uri_new (text_uri);
path = gnome_vfs_uri_get_path (uri);
unescaped_path = gnome_vfs_unescape_string_for_display (path);
switch (nautilus_link_local_get_link_type (unescaped_path)) {
case NAUTILUS_LINK_HOME:
case NAUTILUS_LINK_GENERIC:
can_rename_link = TRUE;
break;
case NAUTILUS_LINK_TRASH:
case NAUTILUS_LINK_MOUNT:
can_rename_link = FALSE;
break;
default:
can_rename_link = FALSE;
break;
}
if (path != NULL && nautilus_file_is_nautilus_link (file)) {
/* FIXME: This reads the link file every time -- seems
* bad to do that even though it's known to be local.
*/
switch (nautilus_link_local_get_link_type (path)) {
case NAUTILUS_LINK_TRASH:
case NAUTILUS_LINK_MOUNT:
can_rename = FALSE;
break;
g_free (text_uri);
gnome_vfs_uri_unref (uri);
if (!can_rename_link) {
return FALSE;
case NAUTILUS_LINK_HOME:
case NAUTILUS_LINK_GENERIC:
break;
}
}
/* Nautilus trash directories cannot be renamed */
if (nautilus_file_is_directory (file)) {
text_uri = nautilus_file_get_uri (file);
if (nautilus_uri_is_trash_folder (text_uri)) {
g_free (text_uri);
return FALSE;
}
g_free (text_uri);
if (nautilus_uri_is_trash_folder (uri)) {
can_rename = FALSE;
}
g_free (uri);
g_free (path);
if (!can_rename) {
return FALSE;
}
/* User must have write permissions for the parent directory. */
@ -785,11 +774,11 @@ nautilus_file_can_rename (NautilusFile *file)
return TRUE;
}
result = nautilus_file_can_write (parent);
can_rename = nautilus_file_can_write (parent);
nautilus_file_unref (parent);
return result;
return can_rename;
}
static GnomeVFSURI *

View file

@ -3,7 +3,7 @@
nautilus-icon-factory.c: Class for obtaining icons for files and other objects.
Copyright (C) 1999, 2000 Red Hat Inc.
Copyright (C) 1999, 2000 Eazel, Inc.
Copyright (C) 1999, 2000, 2001 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

View file

@ -2,7 +2,7 @@
nautilus-thumbnails.h: Thumbnail code for icon factory.
Copyright (C) 2000 Eazel, Inc.
Copyright (C) 2000, 2001 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
@ -52,7 +52,7 @@
GNOME_VFS_PERM_OTHER_READ)
/* thumbnail task state */
static GList *thumbnails;
static char *new_thumbnail_path;
static char *new_thumbnail_uri;
static gboolean thumbnail_in_progress;
/* id of timeout task for making thumbnails */
@ -72,8 +72,10 @@ vfs_file_exists (const char *file_uri)
return FALSE;
}
/* FIXME bugzilla.eazel.com 3137: the synchronous I/O here means this call is
unsuitable for use on anything that might be remote. */
/* FIXME bugzilla.eazel.com 3137: The synchronous I/O here
* means this call is unsuitable for use on anything that
* might be remote.
*/
result = gnome_vfs_uri_exists (uri);
gnome_vfs_uri_unref (uri);
@ -83,8 +85,8 @@ vfs_file_exists (const char *file_uri)
/* utility routine that, given the uri of an image, constructs the uri to the corresponding thumbnail */
static char *
make_thumbnail_path (const char *image_uri, gboolean directory_only, gboolean use_local_directory,
gboolean anti_aliased, gboolean create_parents_if_needed)
make_thumbnail_uri (const char *image_uri, gboolean directory_only, gboolean use_local_directory,
gboolean anti_aliased, gboolean create_parents_if_needed)
{
GnomeVFSURI *vfs_uri;
char *thumbnail_uri, *thumbnail_path;
@ -253,7 +255,7 @@ gboolean nautilus_thumbnail_has_invalid_thumbnail (NautilusFile *file,
uri_is_local = gnome_vfs_uri_is_local (temp_uri);
gnome_vfs_uri_unref (temp_uri);
thumbnail_uri = make_thumbnail_path (file_uri, FALSE, uri_is_local, anti_aliased, TRUE);
thumbnail_uri = make_thumbnail_uri (file_uri, FALSE, uri_is_local, anti_aliased, TRUE);
invalid_thumbnail_uri = make_invalid_thumbnail_uri (thumbnail_uri);
is_invalid = vfs_file_exists (invalid_thumbnail_uri);
@ -289,7 +291,7 @@ nautilus_get_thumbnail_uri (NautilusFile *file, gboolean anti_aliased)
uri_is_local = gnome_vfs_uri_is_local (temp_uri);
gnome_vfs_uri_unref (temp_uri);
thumbnail_uri = make_thumbnail_path (file_uri, FALSE, uri_is_local, anti_aliased, TRUE);
thumbnail_uri = make_thumbnail_uri (file_uri, FALSE, uri_is_local, anti_aliased, TRUE);
/* if the thumbnail file already exists locally, simply return the uri */
@ -315,7 +317,7 @@ nautilus_get_thumbnail_uri (NautilusFile *file, gboolean anti_aliased)
/* now try it globally */
if (!remake_thumbnail) {
g_free (thumbnail_uri);
thumbnail_uri = make_thumbnail_path (file_uri, FALSE, FALSE, anti_aliased, TRUE);
thumbnail_uri = make_thumbnail_uri (file_uri, FALSE, FALSE, anti_aliased, TRUE);
/* if the thumbnail file already exists in the common area, return that uri, */
/* the uri is guaranteed to be local */
@ -340,7 +342,7 @@ nautilus_get_thumbnail_uri (NautilusFile *file, gboolean anti_aliased)
/* make the thumbnail directory if necessary, at first try it locally */
g_free (thumbnail_uri);
local_flag = TRUE;
thumbnail_uri = make_thumbnail_path (file_uri, TRUE, local_flag, anti_aliased, TRUE);
thumbnail_uri = make_thumbnail_uri (file_uri, TRUE, local_flag, anti_aliased, TRUE);
/* FIXME bugzilla.eazel.com 3137: more potentially losing
synch I/O - this could be remote */
@ -359,7 +361,7 @@ nautilus_get_thumbnail_uri (NautilusFile *file, gboolean anti_aliased)
if (!can_write || (result != GNOME_VFS_OK && result != GNOME_VFS_ERROR_FILE_EXISTS)) {
g_free (thumbnail_uri);
local_flag = FALSE;
thumbnail_uri = make_thumbnail_path (file_uri, TRUE, local_flag, anti_aliased, TRUE);
thumbnail_uri = make_thumbnail_uri (file_uri, TRUE, local_flag, anti_aliased, TRUE);
/* this is guaranteed to be local, so synch I/O can be tolerated here */
result = gnome_vfs_make_directory (thumbnail_uri, THUMBNAIL_DIR_PERMISSIONS);
}
@ -408,9 +410,9 @@ nautilus_update_thumbnail_file_renamed_one (const char *old_file_name, const cha
is_local = gnome_vfs_uri_is_local (uri);
gnome_vfs_uri_unref (uri);
old_thumbnail_uri = make_thumbnail_path (old_file_name, FALSE, is_local, anti_aliased, FALSE);
old_thumbnail_uri = make_thumbnail_uri (old_file_name, FALSE, is_local, anti_aliased, FALSE);
if (old_thumbnail_uri != NULL && vfs_file_exists (old_thumbnail_uri)) {
new_thumbnail_uri = make_thumbnail_path (new_file_name, FALSE, is_local, anti_aliased, FALSE);
new_thumbnail_uri = make_thumbnail_uri (new_file_name, FALSE, is_local, anti_aliased, FALSE);
g_assert (new_thumbnail_uri != NULL);
@ -442,7 +444,7 @@ nautilus_remove_thumbnail_for_file_one (const char *old_file_name, gboolean anti
is_local = gnome_vfs_uri_is_local (uri);
gnome_vfs_uri_unref (uri);
thumbnail_uri = make_thumbnail_path (old_file_name, FALSE, is_local, anti_aliased, FALSE);
thumbnail_uri = make_thumbnail_uri (old_file_name, FALSE, is_local, anti_aliased, FALSE);
if (thumbnail_uri != NULL && vfs_file_exists (thumbnail_uri)) {
gnome_vfs_unlink (thumbnail_uri);
}
@ -483,7 +485,7 @@ check_for_thumbnails (void)
/* the thumbnail task has completed, so update the current entry from the list */
file = nautilus_file_get (info->thumbnail_uri);
current_thumbnail = make_thumbnail_path (info->thumbnail_uri, FALSE, info->is_local,
current_thumbnail = make_thumbnail_uri (info->thumbnail_uri, FALSE, info->is_local,
info->anti_aliased, TRUE);
/* if a thumbnail wasn't successfully made, create a placeholder to flag that we tried */
@ -567,9 +569,9 @@ make_thumbnails (gpointer data)
/* start up a task to make the thumbnail corresponding to the queue element. */
/* First, compute the path name of the target thumbnail */
g_free (new_thumbnail_path);
new_thumbnail_path = make_thumbnail_path (info->thumbnail_uri, FALSE, info->is_local,
info->anti_aliased, TRUE);
g_free (new_thumbnail_uri);
new_thumbnail_uri = make_thumbnail_uri (info->thumbnail_uri, FALSE, info->is_local,
info->anti_aliased, TRUE);
/* fork a task to make the thumbnail, using gdk-pixbuf to do the scaling */
if (!(info->thumbnail_task = fork())) {
@ -626,8 +628,9 @@ make_thumbnails (gpointer data)
framed_image = scaled_image;
}
thumbnail_path = gnome_vfs_get_local_path_from_uri (new_thumbnail_path);
if (!nautilus_gdk_pixbuf_save_to_file (framed_image, thumbnail_path)) {
thumbnail_path = gnome_vfs_get_local_path_from_uri (new_thumbnail_uri);
if (thumbnail_path == NULL
|| !nautilus_gdk_pixbuf_save_to_file (framed_image, thumbnail_path)) {
g_warning ("error saving thumbnail %s", thumbnail_path);
}
g_free (thumbnail_path);
@ -635,14 +638,19 @@ make_thumbnails (gpointer data)
} else {
/* gdk-pixbuf couldn't load the image, so trying using ImageMagick */
char *temp_str;
thumbnail_path = gnome_vfs_get_local_path_from_uri (new_thumbnail_path);
temp_str = g_strdup_printf ("png:%s", thumbnail_path);
g_free (thumbnail_path);
thumbnail_path = gnome_vfs_get_local_path_from_uri (info->thumbnail_uri);
/* scale the image */
execlp ("convert", "convert", "-geometry", "96x96", thumbnail_path, temp_str, NULL);
thumbnail_path = gnome_vfs_get_local_path_from_uri (new_thumbnail_uri);
if (thumbnail_path != NULL) {
temp_str = g_strdup_printf ("png:%s", thumbnail_path);
g_free (thumbnail_path);
thumbnail_path = gnome_vfs_get_local_path_from_uri (info->thumbnail_uri);
if (thumbnail_path != NULL) {
/* scale the image */
execlp ("convert", "convert", "-geometry", "96x96", thumbnail_path, temp_str, NULL);
}
}
/* we don't come back from this call, so no point in freeing anything up */
}

View file

@ -263,7 +263,8 @@ static gboolean
has_removable_mntent_options (struct mntent *ent)
{
/* Use "owner" or "user" or "users" as our way of determining a removable volume */
if (hasmntopt (ent, "user") != NULL || hasmntopt (ent, "users") != NULL
if (hasmntopt (ent, "user") != NULL
|| hasmntopt (ent, "users") != NULL
|| hasmntopt (ent, "owner") != NULL) {
return TRUE;
}
@ -371,7 +372,7 @@ char *
nautilus_volume_monitor_get_volume_name (const NautilusVolume *volume)
{
if (volume->volume_name == NULL) {
return g_strdup ("Unknown");
return g_strdup (_("Unknown"));
}
return g_strdup (volume->volume_name);
@ -390,7 +391,7 @@ modify_volume_name_for_display (NautilusVolume *volume)
char *name;
if (volume->volume_name == NULL) {
volume->volume_name = g_strdup ("Unknown");
volume->volume_name = g_strdup (_("Unknown"));
return;
}

View file

@ -2439,7 +2439,8 @@ fm_directory_all_selected_items_in_trash (FMDirectoryView *view)
}
gboolean
fm_directory_link_type_in_selection (FMDirectoryView *view, NautilusLinkType link_type)
fm_directory_link_type_in_selection (FMDirectoryView *view,
NautilusLinkType link_type)
{
gboolean saw_link;
GList *selection, *node;
@ -2451,47 +2452,24 @@ fm_directory_link_type_in_selection (FMDirectoryView *view, NautilusLinkType lin
saw_link = FALSE;
selection = fm_directory_view_get_selection (FM_DIRECTORY_VIEW (view));
for (node = selection; node != NULL; node = node->next) {
file = NAUTILUS_FILE (selection->data);
if (!nautilus_file_is_nautilus_link (file)) {
continue;
}
for (node = selection; node != NULL; node = node->next) {
file = NAUTILUS_FILE (node->data);
uri = nautilus_file_get_uri (file);
path = gnome_vfs_get_local_path_from_uri (uri);
switch (link_type) {
case NAUTILUS_LINK_TRASH:
/* It's probably OK that this ignores trash links that
* are not local since the trash link we care about is
* on the desktop.
*/
saw_link = path != NULL && nautilus_link_local_is_trash_link (path);
if (saw_link) {
break;
}
break;
case NAUTILUS_LINK_MOUNT:
saw_link = path != NULL && nautilus_link_local_is_volume_link (path);
if (saw_link) {
break;
}
break;
case NAUTILUS_LINK_HOME:
saw_link = path != NULL && nautilus_link_local_is_home_link (path);
if (saw_link) {
break;
}
break;
default:
break;
}
/* FIXME: This reads the link file every single time. */
saw_link = path != NULL
&& nautilus_file_is_nautilus_link (file)
&& nautilus_link_local_get_link_type (path) == link_type;
g_free (path);
g_free (uri);
if (saw_link) {
break;
}
}
nautilus_file_list_free (selection);
@ -2499,6 +2477,20 @@ fm_directory_link_type_in_selection (FMDirectoryView *view, NautilusLinkType lin
return saw_link;
}
static gboolean
is_link_type_special (NautilusLinkType type)
{
switch (type) {
case NAUTILUS_LINK_TRASH:
case NAUTILUS_LINK_HOME:
case NAUTILUS_LINK_MOUNT:
return TRUE;
case NAUTILUS_LINK_GENERIC:
return FALSE;
}
return FALSE;
}
/* special_link_in_selection
*
* Return TRUE is one of our special links is the selection.
@ -2509,19 +2501,39 @@ fm_directory_link_type_in_selection (FMDirectoryView *view, NautilusLinkType lin
static gboolean
special_link_in_selection (FMDirectoryView *view)
{
if (fm_directory_link_type_in_selection (view, NAUTILUS_LINK_TRASH)) {
return TRUE;
}
gboolean saw_link;
GList *selection, *node;
NautilusFile *file;
char *uri, *path;
if (fm_directory_link_type_in_selection (view, NAUTILUS_LINK_HOME)) {
return TRUE;
}
g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), FALSE);
if (fm_directory_link_type_in_selection (view, NAUTILUS_LINK_MOUNT)) {
return TRUE;
}
saw_link = FALSE;
return FALSE;
selection = fm_directory_view_get_selection (FM_DIRECTORY_VIEW (view));
for (node = selection; node != NULL; node = node->next) {
file = NAUTILUS_FILE (node->data);
uri = nautilus_file_get_uri (file);
path = gnome_vfs_get_local_path_from_uri (uri);
/* FIXME: This reads the link file every single time. */
saw_link = path != NULL
&& nautilus_file_is_nautilus_link (file)
&& is_link_type_special (nautilus_link_local_get_link_type (path));
g_free (path);
g_free (uri);
if (saw_link) {
break;
}
}
nautilus_file_list_free (selection);
return saw_link;
}
static gboolean

View file

@ -2,7 +2,7 @@
/* fm-icon-view.c - implementation of icon view of directory.
Copyright (C) 2000 Eazel, Inc.
Copyright (C) 2000, 2001 Eazel, Inc.
The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as

View file

@ -604,10 +604,6 @@ uri_is_local_image (const char *uri)
GdkPixbuf *pixbuf;
char *image_path;
if (nautilus_is_remote_uri (uri)) {
return FALSE;
}
image_path = gnome_vfs_get_local_path_from_uri (uri);
if (image_path == NULL) {
return FALSE;

View file

@ -604,10 +604,6 @@ uri_is_local_image (const char *uri)
GdkPixbuf *pixbuf;
char *image_path;
if (nautilus_is_remote_uri (uri)) {
return FALSE;
}
image_path = gnome_vfs_get_local_path_from_uri (uri);
if (image_path == NULL) {
return FALSE;