Commit 1dc711f7 authored by Gene Z. Ragan's avatar Gene Z. Ragan Committed by Gene Ragan
Browse files

Fixed bug 2992, Should not be able to context drag Trash to link or

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

	Fixed bug 2992, Should not be able to context drag
	Trash to link or duplicate

	* libnautilus-extensions/nautilus-icon-container.c:
	* libnautilus-extensions/nautilus-icon-container.h:
	(nautilus_icon_container_trash_link_is_in_selection):
	Renamed function and pass in NautilusIconContainer
	that selection is retrieved from.

	* libnautilus-extensions/nautilus-icon-dnd.c:
	(nautilus_icon_container_receive_dropped_icons):
	Check and see if any special cases are in the
	selection.  For now, this is only the Trash link.

	* src/file-manager/fm-directory-view.c:
	(fm_directory_trash_link_in_selection):
	Changed function internal to call
	nautilus_icon_container_trash_link_is_in_selection
parent 7a6d8a28
2000-09-12 Gene Z. Ragan <gzr@eazel.com>
Fixed bug 2992, Should not be able to context drag
Trash to link or duplicate
* libnautilus-extensions/nautilus-icon-container.c:
* libnautilus-extensions/nautilus-icon-container.h:
(nautilus_icon_container_trash_link_is_in_selection):
Renamed function and pass in NautilusIconContainer
that selection is retrieved from.
* libnautilus-extensions/nautilus-icon-dnd.c:
(nautilus_icon_container_receive_dropped_icons):
Check and see if any special cases are in the
selection. For now, this is only the Trash link.
* src/file-manager/fm-directory-view.c:
(fm_directory_trash_link_in_selection):
Changed function internal to call
nautilus_icon_container_trash_link_is_in_selection
2000-09-12 John Sullivan <sullivan@eazel.com>
Fixed bug 2668 (Switching to Search mode should move the
......
......@@ -37,6 +37,7 @@
#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>
......@@ -4405,6 +4406,32 @@ 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,6 +204,7 @@ 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 */
......@@ -845,6 +845,7 @@ nautilus_icon_container_receive_dropped_icons (NautilusIconContainer *container,
gboolean local_move_only;
double world_x, world_y;
gboolean icon_hit;
GdkDragAction action;
drop_target = NULL;
......@@ -853,8 +854,14 @@ nautilus_icon_container_receive_dropped_icons (NautilusIconContainer *container,
}
if (context->action == GDK_ACTION_ASK) {
context->action = nautilus_drag_drop_action_ask
(GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK);
/* Check for special case items in selection list */
if (nautilus_icon_container_trash_link_is_in_selection (container)) {
/* We only want to move the trash */
action = GDK_ACTION_MOVE;
} else {
action = GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK;
}
context->action = nautilus_drag_drop_action_ask (action);
}
if (context->action > 0) {
......
......@@ -37,6 +37,7 @@
#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>
......@@ -4405,6 +4406,32 @@ 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,6 +204,7 @@ 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 */
......@@ -845,6 +845,7 @@ nautilus_icon_container_receive_dropped_icons (NautilusIconContainer *container,
gboolean local_move_only;
double world_x, world_y;
gboolean icon_hit;
GdkDragAction action;
drop_target = NULL;
......@@ -853,8 +854,14 @@ nautilus_icon_container_receive_dropped_icons (NautilusIconContainer *container,
}
if (context->action == GDK_ACTION_ASK) {
context->action = nautilus_drag_drop_action_ask
(GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK);
/* Check for special case items in selection list */
if (nautilus_icon_container_trash_link_is_in_selection (container)) {
/* We only want to move the trash */
action = GDK_ACTION_MOVE;
} else {
action = GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK;
}
context->action = nautilus_drag_drop_action_ask (action);
}
if (context->action > 0) {
......
......@@ -1993,41 +1993,18 @@ fm_directory_all_selected_items_in_trash (FMDirectoryView *view)
return result;
}
static gboolean
trash_link_is_in_files (GList *files)
{
GList *node;
char *uri;
/* Result is ambiguous if called on NULL, so disallow. */
g_return_val_if_fail (files != NULL, FALSE);
for (node = files; 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);
}
}
return FALSE;
}
gboolean
fm_directory_trash_link_in_selection (FMDirectoryView *view)
{
GList *selection;
gboolean result;
NautilusIconContainer *container;
selection = fm_directory_view_get_selection (view);
g_return_val_if_fail (NAUTILUS_IS_ICON_CONTAINER (GTK_BIN (view)->child), FALSE);
result = trash_link_is_in_files (selection);
nautilus_file_list_free (selection);
container = NAUTILUS_ICON_CONTAINER (GTK_BIN (view)->child);
result = nautilus_icon_container_trash_link_is_in_selection (container);
return result;
}
......
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