Commit a6a23a70 authored by Darin Adler's avatar Darin Adler

Fixed bugs in Nautilus link management, some other minor problems

	I encountered along the way, and did the first cut at a state
	machine for NautilusViewFrame based on Maciej's design that can
	mostly replace the super-complicated one for NautilusWindow.

	* README: We no longer can use the ORBit that comes with HC1.2
	with cvs HEAD, since warnings have been fixed in the code
	generated by the newer ORBit, so fix that line in the README.

	* libnautilus-extensions/nautilus-directory.c:
	(nautilus_directory_new): Use the new nautilus_uri_is_trash
	function to avoid hard-coding incorrect checks for "trash:".
	(nautilus_directory_copy_move_metadata_key): Make simple fix for
	empty metadata. This code gets replaced soon anyway.
	* libnautilus-extensions/nautilus-drag.c:
	(nautilus_drag_can_accept_item): Simplify code to get rid of
	illegal sync. I/O. It's OK to assume all NautilusLink objects
	point to directories for now, and if we make a change to do
	something fancier later, we have to do it with async.
	(nautilus_drag_default_drop_action_for_icons): Use the new
	nautilus_uri_is_trash function to avoid hard-coding incorrect
	checks for "trash:".
	* libnautilus-extensions/nautilus-drag.h: Fixed a typo.
	* libnautilus-extensions/nautilus-file-operations.c:
	(get_link_name): Fix unintialized variable warning in a simple
	way that avoids adding too much code.
	(get_duplicate_name): Fix unintialized variable warning in a
	simple way that avoids adding too much code.
	(nautilus_file_operations_copy_move): Use the new
	nautilus_uri_is_trash function to avoid hard-coding incorrect
	checks for "trash:".

	* libnautilus-extensions/nautilus-file-utilities.h:
	* libnautilus-extensions/nautilus-file-utilities.c:
	(nautilus_uri_is_trash): Add new function to avoid hard-coding
	incorrect checks for "trash:".
	(nautilus_make_uri_canonical), Use nautilus_uri_is_trash.

	* libnautilus-extensions/nautilus-icon-container.h:
	* libnautilus-extensions/nautilus-icon-container.c:
	Remove nautilus_icon_container_trash_link_is_in_selection for 3
	reasons. It doesn't belong in NautilusIconContainer, the use of it
	in drag code was incorrectly looking at the destination
	directory's selection, and it used sync. I/O.

	* libnautilus-extensions/nautilus-icon-dnd.c:
	(selection_includes_trash),
	(nautilus_icon_container_receive_dropped_icons):
	Changed code to actually check selection -- the old code would
	check the selection in the target window. Unfortunately this still
	uses sync. I/O, but that's now covered by bug 3020.

	* libnautilus-extensions/nautilus-icon-factory.c:
	(nautilus_icon_factory_get_icon_for_file): Change to use new
	"local" API for links to make it clear that it uses sync. I/O and
	only works on local files.

	* libnautilus-extensions/nautilus-link.h:
	* libnautilus-extensions/nautilus-link.c: (get_tag),
	(get_link_type): Added functions to handle tags internally as part
	of getting rid of tag string values from the API.
	(nautilus_link_local_create): Changed name to local to emphasize this
	takes a path not a URI and uses sync. I/O.
	(local_set_root_property): Share code among the set
	functions. Before there were a lot of copies of the same
	code. Also made sure that it does no rewrite of the file if called
	to set a property to the same value it already has.
	(nautilus_link_local_set_icon),
	(nautilus_link_local_set_link_uri),
	(nautilus_link_local_set_type): Changed name to local to emphasize
	these take a path not a URI and use sync. I/O.  Reimplement by
	calling local_set_root_property.
	(nautilus_link_local_get_additional_text): Change name to local
	and make it take a path instead of a URI to make it clear it uses
	sync.  I/O and doesn't work on remote URIs.
	(nautilus_link_local_get_image_uri): Change name to local and make
	it take a path instead of a URI to make it clear it uses sync.
	I/O and doesn't work on remote URIs.
	(nautilus_link_local_get_link_uri): Change name to local and make
	it take a path instead of a URI to make it clear it uses sync.
	I/O and doesn't work on remote URIs.
	(nautilus_link_local_get_link_type): Change return value to be the
	NautilusLinkType enum instead of the type tag string to make the
	interface cleaner. Also changed name to local to make it clear
	that it takes a path instead of a URI and uses sync. I/O.
	(nautilus_link_local_is_volume_link),
	(nautilus_link_local_is_home_link),
	(nautilus_link_local_is_trash_link): Changed all three of these to
	take advantage of the new simpler get_link_type, and changed name
	to local to make it clear that they take a path instead of a URI
	and use sync. I/O.

	* src/file-manager/fm-desktop-icon-view.c: (create_mount_link):
	Use call by new "local" name.
	(trash_link_is_selection): Call new "local" function, which now
	requires a path rather than a URI.
	(fm_desktop_icon_view_trash_state_changed_callback): Use call by
	new "local" name.
	(volume_unmounted_callback): Fix bug where the unmounted callback
	was using a path as a URI without converting.
	(find_and_update_home_link): Use call by new "local" name.
	(place_home_directory): Use call by new "local" name.
	(find_and_rename_trash_link): Use call by new "local" name.
	(create_or_rename_trash): Use call by new "local" name.
	(remove_old_mount_links): Use call by new "local" name.
	(get_sort_category): Use new get_link_type call and a case
	statement instead of the old one and a list of string compares.

	* src/file-manager/fm-directory-view.c:
	(fm_directory_trash_link_in_selection): Wrote a new version of
	this function. This is similar to what was in
	NautilusIconContainer, but the one in there didn't belong there,
	and didn't really work for other callers. Also, the one in there
	didn't work at all for the list view case. This new function works
	for either icon or list view. It still has the limitation that it
	won't recognize a trash link if it's not local.

	* src/file-manager/fm-icon-view.c:
	(get_icon_drop_target_uri_callback): Fix to use new local calls, but
	still does sync. I/O. Bug 3020 reported about that.
	(get_icon_text_callback): Changed to use new local calls. Still a
	problem that it works only locally and uses sync. I/O. Bug 2531 was
	already reported about that.

	* src/file-manager/fm-properties-window.c:
	(get_and_ref_file_to_display): Changed to use new local calls and the
	simpler link type interface.

	* src/nautilus-view-frame-private.h: Moved some private
	declarations here since they are for objects used in one file and
	declared in another.

	* src/nautilus-view-frame.h:
	* src/nautilus-view-frame.c: (nautilus_view_frame_destroy_client):
	Destroy the "check if view is gone" timeout here; makes more sense
	than the way it was managed before.
	(nautilus_view_frame_destroy): Don't destroy the timeout here any
	more. Also, label was moved into details.
	(nautilus_view_frame_handle_client_gone): Renamed from
	handle_client_destroy_2.
	(view_frame_wait), (view_frame_underway),
	(view_frame_wait_is_over), (view_frame_loaded),
	(view_frame_failed): Added functions to implement view frame state
	machine transitions.
	(check_if_view_is_gone): Moved code to check if view is gone here;
	it's now activated automatically without requiring an explicit
	call to turn it on, since all callers were turning it on at
	load_client time.
	(nautilus_view_frame_load_client): Add state management. Moved the
	code to turn on the object check timeout here.
	(nautilus_view_frame_load_location): Add state management.
	(nautilus_view_frame_open_location): Add state management.
	(nautilus_view_frame_open_location_in_new_window): Add state management.
	(nautilus_view_frame_open_in_new_window_and_select): Add state management.
	(nautilus_view_frame_report_location_change): Add state management.
	(nautilus_view_frame_report_selection_change): Add state management.
	(nautilus_view_frame_report_status): Add state management.
	(nautilus_view_frame_report_load_underway): Add state management.
	(nautilus_view_frame_report_load_progress): Add state management.
	(nautilus_view_frame_report_load_complete): Add state management.
	(nautilus_view_frame_report_load_failed): Add state management.
	(nautilus_view_frame_set_title): Add state management.
	(nautilus_view_frame_zoom_level_changed): Add state management.,
	(nautilus_view_frame_get_label), (nautilus_view_frame_set_label):
	Moved label into details structure.

	* src/nautilus-window-manage-views.c:
	(nautilus_window_load_sidebar_panel): Fixed code structure a bit
	(fixes bug 2463) and got rid of call to old
	nautilus_view_frame_set_active_errors function, which is no longer
	needed.
	(nautilus_window_load_content_view): Got rid of call to old
	nautilus_view_frame_set_active_errors function, which is no longer
	needed.
	* src/nautilus-window.c:
	(window_update_sidebar_panels_from_preferences): Got rid of call
	to old nautilus_view_frame_set_active_errors function, which is no
	longer needed.
parent 705c7630
2000-09-13 Darin Adler <darin@eazel.com>
Fixed bugs in Nautilus link management, some other minor problems
I encountered along the way, and did the first cut at a state
machine for NautilusViewFrame based on Maciej's design that can
mostly replace the super-complicated one for NautilusWindow.
* README: We no longer can use the ORBit that comes with HC1.2
with cvs HEAD, since warnings have been fixed in the code
generated by the newer ORBit, so fix that line in the README.
* libnautilus-extensions/nautilus-directory.c:
(nautilus_directory_new): Use the new nautilus_uri_is_trash
function to avoid hard-coding incorrect checks for "trash:".
(nautilus_directory_copy_move_metadata_key): Make simple fix for
empty metadata. This code gets replaced soon anyway.
* libnautilus-extensions/nautilus-drag.c:
(nautilus_drag_can_accept_item): Simplify code to get rid of
illegal sync. I/O. It's OK to assume all NautilusLink objects
point to directories for now, and if we make a change to do
something fancier later, we have to do it with async.
(nautilus_drag_default_drop_action_for_icons): Use the new
nautilus_uri_is_trash function to avoid hard-coding incorrect
checks for "trash:".
* libnautilus-extensions/nautilus-drag.h: Fixed a typo.
* libnautilus-extensions/nautilus-file-operations.c:
(get_link_name): Fix unintialized variable warning in a simple
way that avoids adding too much code.
(get_duplicate_name): Fix unintialized variable warning in a
simple way that avoids adding too much code.
(nautilus_file_operations_copy_move): Use the new
nautilus_uri_is_trash function to avoid hard-coding incorrect
checks for "trash:".
* libnautilus-extensions/nautilus-file-utilities.h:
* libnautilus-extensions/nautilus-file-utilities.c:
(nautilus_uri_is_trash): Add new function to avoid hard-coding
incorrect checks for "trash:".
(nautilus_make_uri_canonical), Use nautilus_uri_is_trash.
* libnautilus-extensions/nautilus-icon-container.h:
* libnautilus-extensions/nautilus-icon-container.c:
Remove nautilus_icon_container_trash_link_is_in_selection for 3
reasons. It doesn't belong in NautilusIconContainer, the use of it
in drag code was incorrectly looking at the destination
directory's selection, and it used sync. I/O.
* libnautilus-extensions/nautilus-icon-dnd.c:
(selection_includes_trash),
(nautilus_icon_container_receive_dropped_icons):
Changed code to actually check selection -- the old code would
check the selection in the target window. Unfortunately this still
uses sync. I/O, but that's now covered by bug 3020.
* libnautilus-extensions/nautilus-icon-factory.c:
(nautilus_icon_factory_get_icon_for_file): Change to use new
"local" API for links to make it clear that it uses sync. I/O and
only works on local files.
* libnautilus-extensions/nautilus-link.h:
* libnautilus-extensions/nautilus-link.c: (get_tag),
(get_link_type): Added functions to handle tags internally as part
of getting rid of tag string values from the API.
(nautilus_link_local_create): Changed name to local to emphasize this
takes a path not a URI and uses sync. I/O.
(local_set_root_property): Share code among the set
functions. Before there were a lot of copies of the same
code. Also made sure that it does no rewrite of the file if called
to set a property to the same value it already has.
(nautilus_link_local_set_icon),
(nautilus_link_local_set_link_uri),
(nautilus_link_local_set_type): Changed name to local to emphasize
these take a path not a URI and use sync. I/O. Reimplement by
calling local_set_root_property.
(nautilus_link_local_get_additional_text): Change name to local
and make it take a path instead of a URI to make it clear it uses
sync. I/O and doesn't work on remote URIs.
(nautilus_link_local_get_image_uri): Change name to local and make
it take a path instead of a URI to make it clear it uses sync.
I/O and doesn't work on remote URIs.
(nautilus_link_local_get_link_uri): Change name to local and make
it take a path instead of a URI to make it clear it uses sync.
I/O and doesn't work on remote URIs.
(nautilus_link_local_get_link_type): Change return value to be the
NautilusLinkType enum instead of the type tag string to make the
interface cleaner. Also changed name to local to make it clear
that it takes a path instead of a URI and uses sync. I/O.
(nautilus_link_local_is_volume_link),
(nautilus_link_local_is_home_link),
(nautilus_link_local_is_trash_link): Changed all three of these to
take advantage of the new simpler get_link_type, and changed name
to local to make it clear that they take a path instead of a URI
and use sync. I/O.
* src/file-manager/fm-desktop-icon-view.c: (create_mount_link):
Use call by new "local" name.
(trash_link_is_selection): Call new "local" function, which now
requires a path rather than a URI.
(fm_desktop_icon_view_trash_state_changed_callback): Use call by
new "local" name.
(volume_unmounted_callback): Fix bug where the unmounted callback
was using a path as a URI without converting.
(find_and_update_home_link): Use call by new "local" name.
(place_home_directory): Use call by new "local" name.
(find_and_rename_trash_link): Use call by new "local" name.
(create_or_rename_trash): Use call by new "local" name.
(remove_old_mount_links): Use call by new "local" name.
(get_sort_category): Use new get_link_type call and a case
statement instead of the old one and a list of string compares.
* src/file-manager/fm-directory-view.c:
(fm_directory_trash_link_in_selection): Wrote a new version of
this function. This is similar to what was in
NautilusIconContainer, but the one in there didn't belong there,
and didn't really work for other callers. Also, the one in there
didn't work at all for the list view case. This new function works
for either icon or list view. It still has the limitation that it
won't recognize a trash link if it's not local.
* src/file-manager/fm-icon-view.c:
(get_icon_drop_target_uri_callback): Fix to use new local calls, but
still does sync. I/O. Bug 3020 reported about that.
(get_icon_text_callback): Changed to use new local calls. Still a
problem that it works only locally and uses sync. I/O. Bug 2531 was
already reported about that.
* src/file-manager/fm-properties-window.c:
(get_and_ref_file_to_display): Changed to use new local calls and the
simpler link type interface.
* src/nautilus-view-frame-private.h: Moved some private
declarations here since they are for objects used in one file and
declared in another.
* src/nautilus-view-frame.h:
* src/nautilus-view-frame.c: (nautilus_view_frame_destroy_client):
Destroy the "check if view is gone" timeout here; makes more sense
than the way it was managed before.
(nautilus_view_frame_destroy): Don't destroy the timeout here any
more. Also, label was moved into details.
(nautilus_view_frame_handle_client_gone): Renamed from
handle_client_destroy_2.
(view_frame_wait), (view_frame_underway),
(view_frame_wait_is_over), (view_frame_loaded),
(view_frame_failed): Added functions to implement view frame state
machine transitions.
(check_if_view_is_gone): Moved code to check if view is gone here;
it's now activated automatically without requiring an explicit
call to turn it on, since all callers were turning it on at
load_client time.
(nautilus_view_frame_load_client): Add state management. Moved the
code to turn on the object check timeout here.
(nautilus_view_frame_load_location): Add state management.
(nautilus_view_frame_open_location): Add state management.
(nautilus_view_frame_open_location_in_new_window): Add state management.
(nautilus_view_frame_open_in_new_window_and_select): Add state management.
(nautilus_view_frame_report_location_change): Add state management.
(nautilus_view_frame_report_selection_change): Add state management.
(nautilus_view_frame_report_status): Add state management.
(nautilus_view_frame_report_load_underway): Add state management.
(nautilus_view_frame_report_load_progress): Add state management.
(nautilus_view_frame_report_load_complete): Add state management.
(nautilus_view_frame_report_load_failed): Add state management.
(nautilus_view_frame_set_title): Add state management.
(nautilus_view_frame_zoom_level_changed): Add state management.,
(nautilus_view_frame_get_label), (nautilus_view_frame_set_label):
Moved label into details structure.
* src/nautilus-window-manage-views.c:
(nautilus_window_load_sidebar_panel): Fixed code structure a bit
(fixes bug 2463) and got rid of call to old
nautilus_view_frame_set_active_errors function, which is no longer
needed.
(nautilus_window_load_content_view): Got rid of call to old
nautilus_view_frame_set_active_errors function, which is no longer
needed.
* src/nautilus-window.c:
(window_update_sidebar_panels_from_preferences): Got rid of call
to old nautilus_view_frame_set_active_errors function, which is no
longer needed.
2000-09-13 Pavel Cisler <pavel@eazel.com>
* libnautilus-extensions/nautilus-file-operations.c:
......
......@@ -168,7 +168,7 @@ The following lists the packages and the versions that are required.
gtk+: gtk-1-2 HC1.2
imlib: HEAD HC1.2
gnome-xml: LIB_XML_1_BRANCH
ORBit: orbit-stable-0-5 HC1.2
ORBit: orbit-stable-0-5
gnome-libs: gnome-libs-1-0 --enable-prefer-db1 HC1.2
gnome-http: HEAD
oaf: HEAD
......
......@@ -385,7 +385,7 @@ nautilus_directory_new (const char *uri)
g_assert (uri != NULL);
if (strcmp (uri, "trash:") == 0) {
if (nautilus_uri_is_trash (uri)) {
directory = NAUTILUS_DIRECTORY (gtk_type_new (NAUTILUS_TYPE_TRASH_DIRECTORY));
} else {
directory = NAUTILUS_DIRECTORY (gtk_type_new (NAUTILUS_TYPE_VFS_DIRECTORY));
......@@ -806,45 +806,51 @@ nautilus_directory_notify_files_moved (GList *uri_pairs)
}
static void
nautilus_direcotry_copy_move_metadata_key (NautilusDirectory *source_directory,
const char *source_file, NautilusDirectory *destination_directory,
const char *destination_file, const char *key, gboolean move)
nautilus_directory_copy_move_metadata_key (NautilusDirectory *source_directory,
const char *source_file_name,
NautilusDirectory *destination_directory,
const char *destination_file_name,
const char *key,
gboolean move)
{
char *metadata;
metadata = nautilus_directory_get_file_metadata (source_directory,
source_file, key, NULL);
if (metadata == NULL) {
return;
}
source_file_name, key, NULL);
nautilus_directory_set_file_metadata (destination_directory,
destination_file, key, NULL, metadata);
destination_file_name, key, NULL, metadata);
/* FIXME bugzilla.eazel.com 2807:
* add metadata removal here
*/
g_free (metadata);
}
static void
nautilus_directory_copy_metadata_key (NautilusDirectory *source_directory,
const char *source_file, NautilusDirectory *destination_directory,
const char *destination_file, const char *key)
const char *source_file_name,
NautilusDirectory *destination_directory,
const char *destination_file_name,
const char *key)
{
nautilus_direcotry_copy_move_metadata_key (source_directory,
source_file, destination_directory, destination_file,
key, FALSE);
nautilus_directory_copy_move_metadata_key
(source_directory, source_file_name,
destination_directory, destination_file_name,
key, FALSE);
}
static void
nautilus_directory_move_metadata_key (NautilusDirectory *source_directory,
const char *source_file, NautilusDirectory *destination_directory,
const char *destination_file, const char *key)
const char *source_file_name,
NautilusDirectory *destination_directory,
const char *destination_file_name,
const char *key)
{
nautilus_direcotry_copy_move_metadata_key (source_directory,
source_file, destination_directory, destination_file,
key, TRUE);
nautilus_directory_copy_move_metadata_key
(source_directory, source_file_name,
destination_directory, destination_file_name,
key, TRUE);
}
static void
......@@ -853,7 +859,6 @@ nautilus_directory_move_metadata (const char *source_uri, const char *dest_uri)
NautilusDirectory *source_directory, *destination_directory;
char *source_file_name, *destination_file_name;
source_directory = get_parent_directory (source_uri);
destination_directory = get_parent_directory (dest_uri);
......@@ -876,6 +881,7 @@ nautilus_directory_move_metadata (const char *source_uri, const char *dest_uri)
g_free (destination_file_name);
g_free (source_file_name);
nautilus_directory_unref (source_directory);
nautilus_directory_unref (destination_directory);
}
......@@ -886,7 +892,6 @@ nautilus_directory_copy_metadata (const char *source_uri, const char *dest_uri)
NautilusDirectory *source_directory, *destination_directory;
char *source_file_name, *destination_file_name;
source_directory = get_parent_directory (source_uri);
destination_directory = get_parent_directory (dest_uri);
......@@ -909,6 +914,7 @@ nautilus_directory_copy_metadata (const char *source_uri, const char *dest_uri)
g_free (destination_file_name);
g_free (source_file_name);
nautilus_directory_unref (source_directory);
nautilus_directory_unref (destination_directory);
}
......@@ -924,15 +930,16 @@ nautilus_directory_set_icon_position (const char *uri, GdkPoint point)
destination_file_name = uri_get_basename (uri);
position_string = g_strdup_printf ("%d,%d", point.x, point.y);
nautilus_directory_set_file_metadata (destination_directory,
destination_file_name, NAUTILUS_METADATA_KEY_ICON_POSITION, NULL, position_string);
nautilus_directory_set_file_metadata
(destination_directory, destination_file_name,
NAUTILUS_METADATA_KEY_ICON_POSITION,
NULL, position_string);
g_free (position_string);
g_free (destination_file_name);
nautilus_directory_unref (destination_directory);
}
#undef METADATA_COPY_DEBUG
void
nautilus_directory_schedule_metadata_copy (GList *uri_pairs)
{
......@@ -940,7 +947,7 @@ nautilus_directory_schedule_metadata_copy (GList *uri_pairs)
URIPair *pair;
for (p = uri_pairs; p != NULL; p = p->next) {
pair = (URIPair *)p->data;
pair = (URIPair *) p->data;
nautilus_directory_copy_metadata (pair->from_uri, pair->to_uri);
}
}
......@@ -952,7 +959,7 @@ nautilus_directory_schedule_metadata_move (GList *uri_pairs)
URIPair *pair;
for (p = uri_pairs; p != NULL; p = p->next) {
pair = (URIPair *)p->data;
pair = (URIPair *) p->data;
nautilus_directory_move_metadata (pair->from_uri, pair->to_uri);
}
}
......@@ -964,10 +971,7 @@ nautilus_directory_schedule_metadata_remove (GList *uris)
const char *uri;
for (p = uris; p != NULL; p = p->next) {
uri = (const char *)p->data;
#ifdef METADATA_COPY_DEBUG
g_print ("removing metadata from %s\n", uri);
#endif
uri = (const char *) p->data;
/* FIXME bugzilla.eazel.com 2807:
* call the metadata removal call here
*/
......@@ -981,7 +985,7 @@ nautilus_directory_schedule_position_setting (GList *position_setting_list)
const NautilusFileChangesQueuePositionSetting *item;
for (p = position_setting_list; p != NULL; p = p->next) {
item = (const NautilusFileChangesQueuePositionSetting *)p->data;
item = (const NautilusFileChangesQueuePositionSetting *) p->data;
nautilus_directory_set_icon_position (item->uri, item->point);
}
}
......
......@@ -38,6 +38,7 @@
#include "nautilus-glib-extensions.h"
#include "nautilus-link.h"
#include <libnautilus-extensions/nautilus-file-utilities.h>
#include <libnautilus-extensions/nautilus-string.h>
void
......@@ -212,10 +213,6 @@ gboolean
nautilus_drag_can_accept_item (NautilusFile *drop_target_item,
const char *item_uri)
{
char *link_uri, *file_uri;
GnomeVFSURI *vfs_uri;
gboolean retval;
if (nautilus_file_matches_uri (drop_target_item, item_uri)) {
/* can't accept itself */
return FALSE;
......@@ -226,39 +223,17 @@ nautilus_drag_can_accept_item (NautilusFile *drop_target_item,
return TRUE;
}
/* Handle local NautilusLink files */
if (!nautilus_file_is_local (drop_target_item)
|| !nautilus_file_is_nautilus_link (drop_target_item)) {
return FALSE;
}
file_uri = nautilus_file_get_uri (drop_target_item);
if (file_uri == NULL) {
return FALSE;
}
if (nautilus_link_is_trash_link (file_uri)) {
/* Trash always accepts drops */
/* All Nautilus links are assumed to be links to directories.
* Therefore, they all can accept drags, like all other
* directories to. As with other directories, there can be
* errors when the actual copy is attempted due to
* permissions.
*/
if (nautilus_file_is_nautilus_link (drop_target_item)) {
return TRUE;
}
vfs_uri = gnome_vfs_uri_new (file_uri);
link_uri = nautilus_link_get_link_uri (file_uri);
if (vfs_uri == NULL || link_uri == NULL) {
g_free (file_uri);
g_free (link_uri);
return FALSE;
}
/* Check and see if it is a link that can accept a drag */
retval = nautilus_link_can_accept_drag (gnome_vfs_uri_get_path (vfs_uri));
gnome_vfs_uri_unref (vfs_uri);
g_free (file_uri);
g_free (link_uri);
return retval;
return FALSE;
}
gboolean
......@@ -276,14 +251,14 @@ nautilus_drag_can_accept_items (NautilusFile *drop_target_item,
* drop target. If more than 100 items selected, return an over-optimisic
* result
*/
for (max = 100; items != NULL && max >=0 ; items = items->next, max--) {
for (max = 100; items != NULL && max >= 0; items = items->next, max--) {
if (!nautilus_drag_can_accept_item (drop_target_item,
((DragSelectionItem *)items->data)->uri)) {
return FALSE;
}
}
return TRUE;
return TRUE;
}
void
......@@ -320,7 +295,7 @@ nautilus_drag_default_drop_action_for_icons (GdkDragContext *context,
}
/* Check for trash: URI. We do a find_directory for any Trash directory. */
if (strcmp (target_uri_string, "trash:") == 0) {
if (nautilus_uri_is_trash (target_uri_string)) {
result = gnome_vfs_find_directory (NULL, GNOME_VFS_DIRECTORY_KIND_TRASH,
&target_uri, FALSE, FALSE, 0777);
if (result != GNOME_VFS_OK) {
......
......@@ -66,7 +66,7 @@ typedef struct {
/* Start of the drag, in world coordinates. */
gdouble start_x, start_y;
/* List of DndSelectionItems, representing items being dragged, or NULL
/* List of DragSelectionItems, representing items being dragged, or NULL
* if data about them has not been received from the source yet.
*/
GList *selection_list;
......
......@@ -32,6 +32,7 @@
#include "nautilus-file-operations.h"
#include "nautilus-file-operations-progress.h"
#include <libnautilus-extensions/nautilus-file-changes-queue.h>
#include <libnautilus-extensions/nautilus-file-utilities.h>
#include <libnautilus-extensions/nautilus-glib-extensions.h>
#include <libnautilus-extensions/nautilus-stock-dialogs.h>
#include "fm-directory-view.h"
......@@ -490,6 +491,9 @@ get_link_name (char *name, int count)
* Perhaps for some locales we will need to add more.
*/
switch (count) {
default:
g_assert_not_reached ();
/* fall through */
case 1:
format = _("link to %s");
break;
......@@ -547,6 +551,9 @@ get_duplicate_name (char *name, int count)
* Perhaps for some locales we will need to add more.
*/
switch (count) {
default:
g_assert_not_reached ();
/* fall through */
case 1:
format = _("%s (copy)");
break;
......@@ -806,7 +813,7 @@ nautilus_file_operations_copy_move (const GList *item_uris,
g_assert (copy_action != GDK_ACTION_MOVE);
move_options |= GNOME_VFS_XFER_USE_UNIQUE_NAMES;
} else {
if (strcmp (target_dir, "trash:") == 0) {
if (nautilus_uri_is_trash (target_dir)) {
is_trash_move = TRUE;
} else {
target_dir_uri = gnome_vfs_uri_new (target_dir);
......
......@@ -142,6 +142,12 @@ nautilus_make_uri_from_input (const char *location)
return toreturn;
}
gboolean
nautilus_uri_is_trash (const char *uri)
{
return nautilus_istr_has_prefix (uri, "trash:")
|| nautilus_istr_has_prefix (uri, "gnome-trash:");
}
char *
nautilus_make_uri_canonical (const char *uri)
......@@ -152,8 +158,7 @@ nautilus_make_uri_canonical (const char *uri)
/* Convert "gnome-trash:<anything>" and "trash:<anything>" to
* "trash:".
*/
if (nautilus_istr_has_prefix (uri, "trash:")
|| nautilus_istr_has_prefix (uri, "gnome-trash:")) {
if (nautilus_uri_is_trash (uri)) {
return g_strdup ("trash:");
}
......@@ -405,9 +410,9 @@ nautilus_get_user_main_directory (void)
g_free (image_uri);
/* install the default link set */
nautilus_link_set_install(user_main_directory, "apps");
nautilus_link_set_install (user_main_directory, "apps");
/*
nautilus_link_set_install(user_main_directory, "search_engines");
nautilus_link_set_install (user_main_directory, "search_engines");
*/
}
......
......@@ -38,6 +38,7 @@ typedef struct NautilusReadFileHandle NautilusReadFileHandle;
char * nautilus_format_uri_for_display (const char *uri);
char * nautilus_make_uri_from_input (const char *location);
gboolean nautilus_uri_is_trash (const char *uri);
char * nautilus_make_uri_canonical (const char *uri);
gboolean nautilus_uris_match (const char *uri_1,
const char *uri_2);
......
......@@ -37,7 +37,6 @@
#include "nautilus-icon-private.h"
#include "nautilus-icon-text-item.h"
#include "nautilus-lib-self-check-functions.h"
#include "nautilus-link.h"
#include "nautilus-theme.h"
#include <ctype.h>
#include <gdk-pixbuf/gnome-canvas-pixbuf.h>
......@@ -4410,32 +4409,6 @@ nautilus_icon_container_set_is_fixed_size (NautilusIconContainer *container,
container->details->is_fixed_size = is_fixed_size;
}
gboolean
nautilus_icon_container_trash_link_is_in_selection (NautilusIconContainer *container)
{
GList *selection, *node;
char *uri;
selection = nautilus_icon_container_get_selection (container);
/* Result is ambiguous if called on NULL, so disallow. */
g_return_val_if_fail (selection != NULL, FALSE);
for (node = selection; node != NULL; node = node->next) {
if (nautilus_file_is_nautilus_link (NAUTILUS_FILE (node->data))) {
uri = nautilus_file_get_uri (NAUTILUS_FILE (node->data));
if (nautilus_link_is_trash_link (uri)) {
g_free (uri);
return TRUE;
}
g_free (uri);
}
}
g_list_free (selection);
return FALSE;
}
#if ! defined (NAUTILUS_OMIT_SELF_CHECK)
static char *
......
......@@ -204,7 +204,5 @@ void nautilus_icon_container_set_smooth_label_font (NautilusIconCo
gboolean nautilus_icon_container_get_is_fixed_size (NautilusIconContainer *container);
void nautilus_icon_container_set_is_fixed_size (NautilusIconContainer *container,
gboolean is_fixed_size);
gboolean nautilus_icon_container_trash_link_is_in_selection (NautilusIconContainer *container);
#endif /* NAUTILUS_ICON_CONTAINER_H */
......@@ -30,29 +30,30 @@
#include <config.h>
#include "nautilus-icon-dnd.h"
#include <math.h>
#include <string.h>
#include <stdio.h>
#include <gdk/gdkx.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtksignal.h>
#include <gtk/gtkmain.h>
#include <libgnomevfs/gnome-vfs-uri.h>
#include <libgnome/gnome-i18n.h>
#include <libgnomeui/gnome-stock.h>
#include <libgnomeui/gnome-canvas-rect-ellipse.h>
#include "nautilus-background.h"
#include <libnautilus-extensions/nautilus-gdk-pixbuf-extensions.h>
#include "nautilus-file-utilities.h"
#include "nautilus-gdk-pixbuf-extensions.h"
#include "nautilus-glib-extensions.h"
#include "nautilus-gtk-extensions.h"
#include "nautilus-gtk-macros.h"
#include "nautilus-gnome-extensions.h"
#include "nautilus-graphic-effects.h"
#include "nautilus-gtk-extensions.h"
#include "nautilus-gtk-macros.h"
#include "nautilus-icon-private.h"
#include "nautilus-link.h"
#include "nautilus-stock-dialogs.h"
#include "nautilus-string.h"
#include "nautilus-icon-private.h"
#include <gdk/gdkkeysyms.h>
#include <gdk/gdkx.h>
#include <gtk/gtkmain.h>
#include <gtk/gtksignal.h>
#include <libgnome/gnome-i18n.h>
#include <libgnomeui/gnome-canvas-rect-ellipse.h>
#include <libgnomeui/gnome-stock.h>
#include <libgnomevfs/gnome-vfs-uri.h>
#include <libgnomevfs/gnome-vfs-utils.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
static gboolean drag_drop_callback (GtkWidget *widget,
GdkDragContext *context,
......@@ -836,6 +837,33 @@ nautilus_icon_container_find_drop_target (NautilusIconContainer *container,
return nautilus_icon_container_get_icon_drop_target_uri (container, drop_target_icon);
}
/* FIXME bugzilla.eazel.com 2485: This belongs in FMDirectoryView, not here. */
static gboolean
selection_includes_trash (GList *selection_list)
{
GList *node;
char *uri, *local_path;
gboolean trash_in_selection;
trash_in_selection = FALSE;
for (node = selection_list; node != NULL; node = node->next) {
uri = ((DragSelectionItem *) node->data)->uri;
/* FIXME bugzilla.eazel.com 3020: This does sync. I/O and works only locally. */
local_path = gnome_vfs_get_local_path_from_uri (uri);
trash_in_selection = local_path != NULL
|| nautilus_link_local_is_trash_link (local_path);
g_free (local_path);
if (trash_in_selection) {
break;
}
}
return trash_in_selection;
}
static void
nautilus_icon_container_receive_dropped_icons (NautilusIconContainer *container,
GdkDragContext *context,
......@@ -854,8 +882,9 @@ nautilus_icon_container_receive_dropped_icons (NautilusIconContainer *container,
}
if (context->action == GDK_ACTION_ASK) {
/* FIXME bugzilla.eazel.com 2485: This belongs in FMDirectoryView, not here. */
/* Check for special case items in selection list */
if (nautilus_icon_container_trash_link_is_in_selection (container)) {
if (selection_includes_trash (container->details->dnd_info->drag_info.selection_list)) {
/* We only want to move the trash */
action = GDK_ACTION_MOVE;
} else {
......
......@@ -1044,7 +1044,7 @@ should_display_image_file_as_itself (NautilusFile *file)
NautilusScalableIcon *
nautilus_icon_factory_get_icon_for_file (NautilusFile *file, const char* modifier, gboolean anti_aliased)
{
char *uri, *file_uri, *image_uri, *icon_name, *mime_type, *top_left_text;
char *uri, *file_uri, *file_path, *image_uri, *icon_name, *mime_type, *top_left_text;
NautilusScalableIcon *scalable_icon;
if (file == NULL) {
......@@ -1075,19 +1075,23 @@ nautilus_icon_factory_get_icon_for_file (NautilusFile *file, const char* modifie
/* Handle nautilus link xml files, which may specify their own image */
icon_name = NULL;
if (nautilus_file_is_nautilus_link (file)) {
/* FIXME bugzilla.eazel.com 2563: This does sync. I/O. */
image_uri = nautilus_link_get_image_uri (file_uri);
if (image_uri != NULL) {
/* FIXME bugzilla.eazel.com 2564: Lame hack. We only support file:// URIs? */
if (nautilus_istr_has_prefix (image_uri, "file://")) {
if (uri == NULL) {
uri = image_uri;
/* FIXME bugzilla.eazel.com 2563: This does sync. I/O and only works for local paths. */
file_path = gnome_vfs_get_local_path_from_uri (file_uri);
if (file_path != NULL) {
image_uri = nautilus_link_local_get_image_uri (file_path);
if (image_uri != NULL) {
/* FIXME bugzilla.eazel.com 2564: Lame hack. We only support file:// URIs? */