summaryrefslogtreecommitdiff
path: root/libnautilus-private/nautilus-dnd.c
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2003-05-15 17:19:27 +0000
committerAlexander Larsson <alexl@src.gnome.org>2003-05-15 17:19:27 +0000
commit119586813a7a7be9a0fd9fd6f2b654ee53779c38 (patch)
tree7e12c677652f3454f79a79823b3963207713d14b /libnautilus-private/nautilus-dnd.c
parent3d670f0cda514118e0762ed4ed170c2ae9659810 (diff)
downloadnautilus-119586813a7a7be9a0fd9fd6f2b654ee53779c38.tar.gz
Added new files.
2003-05-15 Alexander Larsson <alexl@redhat.com> * libnautilus-private/Makefile.am: Added new files. * libnautilus-private/apps_nautilus_preferences.schemas.in: * libnautilus-private/nautilus-global-preferences.[ch]: New prefs for home and trash links. * libnautilus-private/nautilus-desktop-directory.[ch]: New files. Implements the NautilusDesktop object for the virtual x-nautilus-desktop: uri. The directory merges the contents of the directory with the real desktop directory. * libnautilus-private/nautilus-desktop-directory-file.[ch]: New files. Implements the Nautilusfile corresponding to NautilusDestkopDirectory. * libnautilus-private/nautilus-desktop-icon-file.[ch]: New files. Implement NautilusFile for a virtual file in a NautilusDesktopDirectory. Gets all the actual file data from a NautilusDesktopLink. * libnautilus-private/nautilus-desktop-link-monitor.[ch]: New files. Keep track of home and trash visibility prefs and mounted volumes and create/destroy corresponding NautilusDesktopLink object. * libnautilus-private/nautilus-desktop-link.[ch]: New files. Keeps track of all the real information in a desktop icon link. These are home, trash and volume links at the moment. * libnautilus-private/nautilus-directory-async.c: Indentation correction. * libnautilus-private/nautilus-directory.c: (nautilus_directory_new): Create NautilusDesktopDirectory objects for x-nautilus-desktop: uris * libnautilus-private/nautilus-dnd.c: (nautilus_drag_items_local): Handle NULL GnomeVFSURIs. (nautilus_drag_items_on_desktop): New function to check if items are on the desktop. (nautilus_drag_default_drop_action_for_icons): Special case desktop uris. (nautilus_drag_selection_includes_special_link): Convert from old-style special links to current. * libnautilus-private/nautilus-dnd.h: New function nautilus_drag_items_on_desktop. * libnautilus-private/nautilus-file-operations.c: (is_special_link), (nautilus_file_operations_copy_move): Convert from old-style special links to current. (nautilus_file_operations_delete): Special case desktop links * libnautilus-private/nautilus-file-utilities.[ch]: (nautilus_get_desktop_directory): (nautilus_get_gmc_desktop_directory): Change desktop dir to ~/Desktop (nautilus_get_desktop_directory_uri): New function to return desktop dir as a uri. * libnautilus-private/nautilus-file.c: (nautilus_file_new_from_relative_uri), (nautilus_file_get_internal): Handle creation of desktop icon files. (nautilus_file_can_rename), (rename_guts), (nautilus_file_get_drop_target_uri): Update for new special links. (nautilus_file_is_in_desktop): Update for new desktop dir. (nautilus_file_get_uri): Fix uris for self owned files. This changed due to the new canonicalization rules for foo: * libnautilus-private/nautilus-icon-dnd.c: (nautilus_icon_container_selection_items_local), (handle_nonlocal_move): Handle desktop uri. * src/Nautilus_shell.server.in: icon view handles x-nautilus-desktop: uris * src/nautilus-application.c: (finish_startup): Initialize the desktop link monitor * src/nautilus-desktop-window.c: (nautilus_desktop_window_update_directory): Show x-nautilus-desktop: * src/file-manager/fm-desktop-icon-view.c: (fm_desktop_icon_view_finalize), (fm_desktop_icon_view_init), (volume_ops_callback), (trash_link_is_selection), (volume_link_is_selection), (volume_link_device_type), (real_supports_zooming): * src/file-manager/fm-directory-view.c: Remove lots of old support for desktop icon. Reimplement some of it with the new desktop icon support. * src/file-manager/fm-directory-view.h: New function fm_directory_view_get_backing_uri * src/file-manager/fm-icon-container.c: (fm_icon_container_get_icon_text): Don't show extra text for desktop icons (get_sort_category): Update for new desktop icons * src/file-manager/fm-icon-view.c: (icon_view_handle_uri_list): Use get_backing_uri() * src/file-manager/fm-properties-window.c: (get_target_file): Use the new desktop icon support. * libnautilus-private/nautilus-icon-container.c: (lay_down_icons_tblr): Don't loop forever if icon doesn't in the height of the container.
Diffstat (limited to 'libnautilus-private/nautilus-dnd.c')
-rw-r--r--libnautilus-private/nautilus-dnd.c99
1 files changed, 64 insertions, 35 deletions
diff --git a/libnautilus-private/nautilus-dnd.c b/libnautilus-private/nautilus-dnd.c
index 265387037..4612d8ccf 100644
--- a/libnautilus-private/nautilus-dnd.c
+++ b/libnautilus-private/nautilus-dnd.c
@@ -44,6 +44,7 @@
#include <libgnomevfs/gnome-vfs-types.h>
#include <libgnomevfs/gnome-vfs-uri.h>
#include <libgnomevfs/gnome-vfs-utils.h>
+#include <libnautilus-private/nautilus-file-utilities.h>
#include <stdio.h>
#include <string.h>
@@ -219,12 +220,19 @@ nautilus_drag_items_local (const char *target_uri_string, const GList *selection
target_uri = gnome_vfs_uri_new (target_uri_string);
- /* get the parent URI of the first item in the selection */
- item_uri = gnome_vfs_uri_new (((NautilusDragSelectionItem *)selection_list->data)->uri);
- result = gnome_vfs_uri_is_parent (target_uri, item_uri, FALSE);
-
- gnome_vfs_uri_unref (item_uri);
- gnome_vfs_uri_unref (target_uri);
+ if (target_uri != NULL) {
+ /* get the parent URI of the first item in the selection */
+ item_uri = gnome_vfs_uri_new (((NautilusDragSelectionItem *)selection_list->data)->uri);
+
+ if (item_uri != NULL) {
+ result = gnome_vfs_uri_is_parent (target_uri, item_uri, FALSE);
+
+ gnome_vfs_uri_unref (item_uri);
+ }
+
+ gnome_vfs_uri_unref (target_uri);
+ }
+
return result;
}
@@ -240,6 +248,39 @@ nautilus_drag_items_in_trash (const GList *selection_list)
return eel_uri_is_in_trash (((NautilusDragSelectionItem *)selection_list->data)->uri);
}
+gboolean
+nautilus_drag_items_on_desktop (const GList *selection_list)
+{
+ char *uri;
+ GnomeVFSURI *vfs_uri, *desktop_vfs_uri;
+ char *desktop_uri;
+ gboolean result;
+
+ /* check if the first item on the list is in trash.
+ * FIXME:
+ * we should really test each item but that would be slow for large selections
+ * and currently dropped items can only be from the same container
+ */
+ uri = ((NautilusDragSelectionItem *)selection_list->data)->uri;
+ if (eel_uri_is_desktop (uri)) {
+ return TRUE;
+ }
+
+ vfs_uri = gnome_vfs_uri_new (uri);
+ desktop_uri = nautilus_get_desktop_directory_uri ();
+ desktop_vfs_uri = gnome_vfs_uri_new (desktop_uri);
+ g_free (desktop_uri);
+
+ result = gnome_vfs_uri_is_parent (desktop_vfs_uri, vfs_uri, FALSE);
+
+ gnome_vfs_uri_unref (desktop_vfs_uri);
+ gnome_vfs_uri_unref (vfs_uri);
+
+ return result;
+
+}
+
+
void
nautilus_drag_default_drop_action_for_icons (GdkDragContext *context,
const char *target_uri_string, const GList *items,
@@ -293,10 +334,17 @@ nautilus_drag_default_drop_action_for_icons (GdkDragContext *context,
return;
- } else if (eel_str_has_prefix (target_uri_string, NAUTILUS_COMMAND_SPECIFIER)
- || eel_str_has_prefix (target_uri_string, NAUTILUS_DESKTOP_COMMAND_SPECIFIER)) {
+ } else if (g_str_has_prefix (target_uri_string, NAUTILUS_COMMAND_SPECIFIER)
+ || g_str_has_prefix (target_uri_string, NAUTILUS_DESKTOP_COMMAND_SPECIFIER)) {
+ if (actions & GDK_ACTION_MOVE) {
+ *action = GDK_ACTION_MOVE;
+ }
+ return;
+ } else if (eel_uri_is_desktop (target_uri_string)) {
if (actions & GDK_ACTION_MOVE) {
*action = GDK_ACTION_MOVE;
+ } else {
+ *action = context->suggested_action;
}
return;
} else {
@@ -312,8 +360,10 @@ nautilus_drag_default_drop_action_for_icons (GdkDragContext *context,
dropped_uri = gnome_vfs_uri_new (((NautilusDragSelectionItem *)items->data)->uri);
same_fs = TRUE;
- gnome_vfs_check_same_fs_uris (dropped_uri, target_uri, &same_fs);
- gnome_vfs_uri_unref (dropped_uri);
+ if (dropped_uri != NULL) {
+ gnome_vfs_check_same_fs_uris (dropped_uri, target_uri, &same_fs);
+ gnome_vfs_uri_unref (dropped_uri);
+ }
gnome_vfs_uri_unref (target_uri);
if (same_fs) {
@@ -790,36 +840,15 @@ gboolean
nautilus_drag_selection_includes_special_link (GList *selection_list)
{
GList *node;
- char *uri, *local_path;
- gboolean link_in_selection;
- GnomeVFSFileInfo *info;
-
- link_in_selection = FALSE;
+ char *uri;
for (node = selection_list; node != NULL; node = node->next) {
uri = ((NautilusDragSelectionItem *) node->data)->uri;
- /* FIXME bugzilla.gnome.org 43020: This does sync. I/O and works only locally. */
- local_path = gnome_vfs_get_local_path_from_uri (uri);
-
- if (local_path) {
- info = gnome_vfs_file_info_new ();
- gnome_vfs_get_file_info
- (local_path, info,
- GNOME_VFS_FILE_INFO_GET_MIME_TYPE |
- GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
- /* assume info is blank on failure */
- link_in_selection = (nautilus_link_local_is_trash_link (local_path, info) ||
- nautilus_link_local_is_home_link (local_path, info) ||
- nautilus_link_local_is_volume_link (local_path, info));
- gnome_vfs_file_info_unref (info);
- g_free (local_path);
- }
-
- if (link_in_selection) {
- break;
+ if (eel_uri_is_desktop (uri)) {
+ return TRUE;
}
}
- return link_in_selection;
+ return FALSE;
}