Commit 14bc29ad authored by Gene Z. Ragan's avatar Gene Z. Ragan Committed by Gene Ragan
Browse files

Fixed bug 3017, should not be able to copy desktop items

2000-09-18  Gene Z. Ragan  <gzr@eazel.com>

	Fixed bug 3017, should not be able to copy desktop items

	Check for special desktop link types when specifying
	drag and drop actions.

	Disable Duplicate menu item.

	* libnautilus-extensions/nautilus-icon-dnd.c:
	(selection_includes_special_link),
	(nautilus_icon_container_receive_dropped_icons):
	* src/file-manager/fm-directory-view.c:
	(fm_directory_link_type_in_selection), (special_link_in_selection),
	(fm_directory_view_real_create_selection_context_menu_items):
	* src/file-manager/fm-directory-view.h:
	* src/file-manager/fm-icon-view.c:
	(fm_icon_view_create_selection_context_menu_items):
parent b368d87b
2000-09-18 Gene Z. Ragan <gzr@eazel.com>
Fixed bug 3017, should not be able to copy desktop items
Check for special desktop link types when specifying
drag and drop actions.
Disable Duplicate menu item.
* libnautilus-extensions/nautilus-icon-dnd.c:
(selection_includes_special_link),
(nautilus_icon_container_receive_dropped_icons):
* src/file-manager/fm-directory-view.c:
(fm_directory_link_type_in_selection), (special_link_in_selection),
(fm_directory_view_real_create_selection_context_menu_items):
* src/file-manager/fm-directory-view.h:
* src/file-manager/fm-icon-view.c:
(fm_icon_view_create_selection_context_menu_items):
2000-09-18 Josh Barrow <linuxfan@ionet.net>
* README:
......
......@@ -839,29 +839,30 @@ nautilus_icon_container_find_drop_target (NautilusIconContainer *container,
/* FIXME bugzilla.eazel.com 2485: This belongs in FMDirectoryView, not here. */
static gboolean
selection_includes_trash (GList *selection_list)
selection_includes_special_link (GList *selection_list)
{
GList *node;
char *uri, *local_path;
gboolean trash_in_selection;
gboolean link_in_selection;
trash_in_selection = FALSE;
link_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);
link_in_selection = local_path != NULL
&& (nautilus_link_local_is_trash_link (local_path) || nautilus_link_local_is_home_link (local_path) ||
nautilus_link_local_is_volume_link (local_path));
g_free (local_path);
if (trash_in_selection) {
if (link_in_selection) {
break;
}
}
return trash_in_selection;
return link_in_selection;
}
static void
......@@ -884,7 +885,7 @@ 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 (selection_includes_trash (container->details->dnd_info->drag_info.selection_list)) {
if (selection_includes_special_link (container->details->dnd_info->drag_info.selection_list)) {
/* We only want to move the trash */
action = GDK_ACTION_MOVE;
} else {
......
......@@ -839,29 +839,30 @@ nautilus_icon_container_find_drop_target (NautilusIconContainer *container,
/* FIXME bugzilla.eazel.com 2485: This belongs in FMDirectoryView, not here. */
static gboolean
selection_includes_trash (GList *selection_list)
selection_includes_special_link (GList *selection_list)
{
GList *node;
char *uri, *local_path;
gboolean trash_in_selection;
gboolean link_in_selection;
trash_in_selection = FALSE;
link_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);
link_in_selection = local_path != NULL
&& (nautilus_link_local_is_trash_link (local_path) || nautilus_link_local_is_home_link (local_path) ||
nautilus_link_local_is_volume_link (local_path));
g_free (local_path);
if (trash_in_selection) {
if (link_in_selection) {
break;
}
}
return trash_in_selection;
return link_in_selection;
}
static void
......@@ -884,7 +885,7 @@ 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 (selection_includes_trash (container->details->dnd_info->drag_info.selection_list)) {
if (selection_includes_special_link (container->details->dnd_info->drag_info.selection_list)) {
/* We only want to move the trash */
action = GDK_ACTION_MOVE;
} else {
......
......@@ -2037,16 +2037,16 @@ fm_directory_all_selected_items_in_trash (FMDirectoryView *view)
}
gboolean
fm_directory_trash_link_in_selection (FMDirectoryView *view)
fm_directory_link_type_in_selection (FMDirectoryView *view, NautilusLinkType link_type)
{
gboolean saw_trash_link;
gboolean saw_link;
GList *selection, *node;
NautilusFile *file;
char *uri, *path;
g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), FALSE);
saw_trash_link = FALSE;
saw_link = FALSE;
selection = fm_directory_view_get_selection (FM_DIRECTORY_VIEW (view));
for (node = selection; node != NULL; node = node->next) {
......@@ -2057,22 +2057,69 @@ fm_directory_trash_link_in_selection (FMDirectoryView *view)
}
uri = nautilus_file_get_uri (file);
path = gnome_vfs_get_local_path_from_uri (uri);
/* 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_trash_link = path != NULL
&& nautilus_link_local_is_trash_link (path);
g_free (path);
g_free (uri);
if (saw_trash_link) {
break;
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;
}
g_free (path);
g_free (uri);
}
nautilus_file_list_free (selection);
return saw_trash_link;
return saw_link;
}
/* special_link_in_selection
*
* Return TRUE is one of our special links is the selection.
* Special links include the following:
* NAUTILUS_LINK_TRASH, NAUTILUS_LINK_HOME, NAUTILUS_LINK_MOUNT
*/
static gboolean
special_link_in_selection (FMDirectoryView *view)
{
if (fm_directory_link_type_in_selection (view, NAUTILUS_LINK_TRASH)) {
return TRUE;
}
if (fm_directory_link_type_in_selection (view, NAUTILUS_LINK_HOME)) {
return TRUE;
}
if (fm_directory_link_type_in_selection (view, NAUTILUS_LINK_MOUNT)) {
return TRUE;
}
return FALSE;
}
static gboolean
......@@ -2848,9 +2895,10 @@ fm_directory_view_real_create_selection_context_menu_items (FMDirectoryView *vie
GtkMenu *menu,
GList *files)
{
gboolean trash_in_selection;
gboolean link_in_selection;
trash_in_selection = fm_directory_trash_link_in_selection (view);
/* Check for special links */
link_in_selection = special_link_in_selection (view);
append_gtk_menu_item (view, menu, files,
FM_DIRECTORY_VIEW_MENU_PATH_OPEN,
......@@ -2865,7 +2913,7 @@ fm_directory_view_real_create_selection_context_menu_items (FMDirectoryView *vie
nautilus_gtk_menu_append_separator (menu);
/* Don't add item if Trash link is in selection */
if (!trash_in_selection) {
if (!link_in_selection) {
/* Trash menu item handled specially. See comment above reset_bonobo_trash_delete_menu. */
if (!fm_directory_all_selected_items_in_trash (view)) {
append_gtk_menu_item (view, menu, files,
......@@ -2878,7 +2926,7 @@ fm_directory_view_real_create_selection_context_menu_items (FMDirectoryView *vie
}
}
if (!trash_in_selection) {
if (!link_in_selection) {
append_gtk_menu_item (view, menu, files,
FM_DIRECTORY_VIEW_MENU_PATH_DUPLICATE,
duplicate_callback);
......
......@@ -33,6 +33,7 @@
#include <libnautilus-extensions/nautilus-directory.h>
#include <libnautilus-extensions/nautilus-file.h>
#include <libnautilus-extensions/nautilus-icon-container.h>
#include <libnautilus-extensions/nautilus-link.h>
#include <libnautilus-extensions/nautilus-string-list.h>
typedef struct FMDirectoryView FMDirectoryView;
......@@ -314,7 +315,8 @@ void fm_directory_view_move_copy_items (const GList
FMDirectoryView *view);
gint fm_directory_view_get_context_menu_index (GtkMenu *menu,
const char *menu_name);
gboolean fm_directory_trash_link_in_selection (FMDirectoryView *view);
gboolean fm_directory_link_type_in_selection (FMDirectoryView *view,
NautilusLinkType link_type);
/* Wrappers for signal emitters. These are normally called
* only by FMDirectoryView itself. They have corresponding signals
......
......@@ -606,7 +606,8 @@ fm_icon_view_create_selection_context_menu_items (FMDirectoryView *view,
g_assert (FM_IS_ICON_VIEW (view));
g_assert (GTK_IS_MENU (menu));
trash_in_selection = fm_directory_trash_link_in_selection (view);
/* Check for special links */
trash_in_selection = fm_directory_link_type_in_selection (view, NAUTILUS_LINK_TRASH);
NAUTILUS_CALL_PARENT_CLASS
(FM_DIRECTORY_VIEW_CLASS,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment