summaryrefslogtreecommitdiff
path: root/libnautilus-private/nautilus-file-dnd.c
diff options
context:
space:
mode:
authorRamiro Estrugo <ramiro@src.gnome.org>2001-04-04 15:51:58 +0000
committerRamiro Estrugo <ramiro@src.gnome.org>2001-04-04 15:51:58 +0000
commit3d2a9e54d508a93cc4c06297a434bb489ed57d6c (patch)
tree7b43f6bfe76350bf3655047fb9ac434cff84b8ca /libnautilus-private/nautilus-file-dnd.c
parent0e104cc00f42574cc6b0c806802babdbf6c12528 (diff)
downloadnautilus-3d2a9e54d508a93cc4c06297a434bb489ed57d6c.tar.gz
Remove nautilusclist cut-n-paste code.
* configure.in: Remove nautilusclist cut-n-paste code. * cut-n-paste-code/widgets/Makefile.am: * cut-n-paste-code/widgets/nautilusclist/.cvsignore: * cut-n-paste-code/widgets/nautilusclist/Makefile.am: * cut-n-paste-code/widgets/nautilusclist/nautilusclist.c: * cut-n-paste-code/widgets/nautilusclist/nautilusclist.h: Remove nautilusclist cut-n-paste code. * libnautilus-extensions/nautilus-file-dnd.h: * libnautilus-extensions/nautilus-file-dnd.c: New file with Drag and Drop code that operated on NautilusFile objects. * libnautilus-extensions/Makefile.am: * libnautilus-extensions/nautilus-list-column-title.c: * libnautilus-extensions/nautilus-list-column-title.h: * libnautilus-extensions/nautilus-list.c: * libnautilus-extensions/nautilus-list.h: * libnautilus-extensions/nautilus-ctree.c: * libnautilus-extensions/nautilus-ctree.h: * libnautilus-extensions/nautilus-drag.c: * libnautilus-extensions/nautilus-drag.h: Move these widget into eel. * libnautilus-extensions/nautilus-icon-dnd.h: * libnautilus-extensions/nautilus-icon-dnd.c: Update for eel dnd code move. * nautilus-installer/install-lib/Makefile.am: * nautilus-installer/libtrilobite/Makefile.am: Remove some voodoo that was needed for cut-n-paste code in trilobite that no longer is among us. * components/help/hyperbola-nav-tree.c: * components/music/nautilus-music-view.c: * components/rpmview/nautilus-rpm-verify-window.c: * components/rpmview/nautilus-rpm-view-private.h: * components/rpmview/nautilus-rpm-view.c: * components/tree/nautilus-tree-view-dnd.c: * components/tree/nautilus-tree-view-dnd.h: * components/tree/nautilus-tree-view-private.h: * components/tree/nautilus-tree-view.c: * src/file-manager/fm-directory-view.c: * src/file-manager/fm-list-view.c: (fm_list_view_initialize), * src/nautilus-sidebar.c: Update for clist, ctree, list and dnd code that now lives in eel. Also do more #include cleanup.
Diffstat (limited to 'libnautilus-private/nautilus-file-dnd.c')
-rw-r--r--libnautilus-private/nautilus-file-dnd.c109
1 files changed, 109 insertions, 0 deletions
diff --git a/libnautilus-private/nautilus-file-dnd.c b/libnautilus-private/nautilus-file-dnd.c
new file mode 100644
index 000000000..fe559b2d1
--- /dev/null
+++ b/libnautilus-private/nautilus-file-dnd.c
@@ -0,0 +1,109 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+
+/* nautilus-file-drag.c - Drag & drop handling code that operated on
+ NautilusFile objects.
+
+ Copyright (C) 2000 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
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The Gnome Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the Gnome Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+ Authors: Pavel Cisler <pavel@eazel.com>,
+*/
+
+#include <config.h>
+#include "nautilus-file-dnd.h"
+
+#include <eel/eel-glib-extensions.h>
+#include <eel/eel-string.h>
+
+gboolean
+nautilus_drag_can_accept_item (NautilusFile *drop_target_item,
+ const char *item_uri)
+{
+ if (nautilus_file_matches_uri (drop_target_item, item_uri)) {
+ /* can't accept itself */
+ return FALSE;
+ }
+
+ if (nautilus_file_is_directory (drop_target_item)) {
+ /* target is a directory, accept anything */
+ return TRUE;
+ }
+
+ /* 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;
+ }
+
+ return FALSE;
+}
+
+gboolean
+nautilus_drag_can_accept_items (NautilusFile *drop_target_item,
+ const GList *items)
+{
+ int max;
+
+ if (drop_target_item == NULL)
+ return FALSE;
+
+ g_assert (NAUTILUS_IS_FILE (drop_target_item));
+
+ /* Iterate through selection checking if item will get accepted by the
+ * drop target. If more than 100 items selected, return an over-optimisic
+ * result
+ */
+ 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;
+}
+
+void
+nautilus_drag_file_receive_dropped_keyword (NautilusFile *file, char *keyword)
+{
+ GList *keywords, *word;
+
+ g_return_if_fail (NAUTILUS_IS_FILE (file));
+ g_return_if_fail (keyword != NULL);
+
+ /* special case the erase emblem */
+ if (strcmp (keyword, ERASE_KEYWORD) == 0) {
+ keywords = NULL;
+ } else {
+ keywords = nautilus_file_get_keywords (file);
+ word = g_list_find_custom (keywords, keyword, (GCompareFunc) strcmp);
+ if (word == NULL) {
+ keywords = g_list_append (keywords, g_strdup (keyword));
+ } else {
+ keywords = g_list_remove_link (keywords, word);
+ g_free (word->data);
+ g_list_free_1 (word);
+ }
+ }
+
+ nautilus_file_set_keywords (file, keywords);
+ eel_g_list_free_deep (keywords);
+}