static void nemo_icon_container_get_drop_action (NemoIconContainer *container, GdkDragContext *context, int x, int y, int *action) { char *drop_target; gboolean icon_hit; double world_x, world_y; icon_hit = FALSE; if (!container->details->dnd_info->drag_info.got_drop_data_type) { /* drag_data_received_callback didn't get called yet */ return; } /* find out if we're over an icon */ canvas_widget_to_world (EEL_CANVAS (container), x, y, &world_x, &world_y); *action = 0; /* case out on the type of object being dragged */ switch (container->details->dnd_info->drag_info.data_type) { case NEMO_ICON_DND_GNOME_ICON_LIST: if (container->details->dnd_info->drag_info.selection_list == NULL) { return; } drop_target = nemo_icon_container_find_drop_target (container, context, x, y, &icon_hit, FALSE); if (!drop_target) { return; } nemo_drag_default_drop_action_for_icons (context, drop_target, container->details->dnd_info->drag_info.selection_list, action); g_free (drop_target); break; case NEMO_ICON_DND_URI_LIST: drop_target = nemo_icon_container_find_drop_target (container, context, x, y, &icon_hit, FALSE); *action = nemo_drag_default_drop_action_for_uri_list (context, drop_target); g_free (drop_target); break; case NEMO_ICON_DND_NETSCAPE_URL: *action = nemo_drag_default_drop_action_for_netscape_url (context); break; case NEMO_ICON_DND_ROOTWINDOW_DROP: *action = gdk_drag_context_get_suggested_action (context); break; case NEMO_ICON_DND_TEXT: case NEMO_ICON_DND_XDNDDIRECTSAVE: case NEMO_ICON_DND_RAW: *action = GDK_ACTION_COPY; break; } }
static gboolean slot_proxy_drag_motion (GtkWidget *widget, GdkDragContext *context, int x, int y, unsigned int time, gpointer user_data) { NemoDragSlotProxyInfo *drag_info; NemoWindowSlot *target_slot; GtkWidget *window; GdkAtom target; int action = 0; char *target_uri; if (gtk_drag_get_source_widget (context) == widget) { goto out; } drag_info = user_data; window = gtk_widget_get_toplevel (widget); g_assert (NEMO_IS_WINDOW (window)); if (!drag_info->have_data) { target = gtk_drag_dest_find_target (widget, context, NULL); if (target == GDK_NONE) { goto out; } gtk_drag_get_data (widget, context, target, time); } target_uri = NULL; if (drag_info->target_file != NULL) { target_uri = nemo_file_get_uri (drag_info->target_file); } else { if (drag_info->target_slot != NULL) { target_slot = drag_info->target_slot; } else { target_slot = nemo_window_get_active_slot (NEMO_WINDOW (window)); } if (target_slot != NULL) { target_uri = nemo_window_slot_get_current_uri (target_slot); } } if (drag_info->have_data && drag_info->have_valid_data) { if (drag_info->info == NEMO_ICON_DND_GNOME_ICON_LIST) { nemo_drag_default_drop_action_for_icons (context, target_uri, drag_info->data.selection_list, &action, &drag_info->desktop_dnd_source_fs, &drag_info->desktop_dnd_can_delete_source); } else if (drag_info->info == NEMO_ICON_DND_URI_LIST) { action = nemo_drag_default_drop_action_for_uri_list (context, target_uri); } else if (drag_info->info == NEMO_ICON_DND_NETSCAPE_URL) { action = nemo_drag_default_drop_action_for_netscape_url (context); } } g_free (target_uri); out: if (action != 0) { gtk_drag_highlight (widget); } else { gtk_drag_unhighlight (widget); } gdk_drag_status (context, action, time); return TRUE; }
static guint get_drop_action (NemoTreeViewDragDest *dest, GdkDragContext *context, GtkTreePath *path) { char *drop_target; int action; if (!dest->details->have_drag_data || (dest->details->drag_type == NEMO_ICON_DND_GNOME_ICON_LIST && dest->details->drag_list == NULL)) { return 0; } switch (dest->details->drag_type) { case NEMO_ICON_DND_GNOME_ICON_LIST : drop_target = get_drop_target_uri_for_path (dest, path); if (!drop_target) { return 0; } nemo_drag_default_drop_action_for_icons (context, drop_target, dest->details->drag_list, &action); g_free (drop_target); return action; case NEMO_ICON_DND_NETSCAPE_URL: drop_target = get_drop_target_uri_for_path (dest, path); if (drop_target == NULL) { return 0; } action = nemo_drag_default_drop_action_for_netscape_url (context); g_free (drop_target); return action; case NEMO_ICON_DND_URI_LIST : drop_target = get_drop_target_uri_for_path (dest, path); if (drop_target == NULL) { return 0; } g_free (drop_target); return gdk_drag_context_get_suggested_action (context); case NEMO_ICON_DND_TEXT: case NEMO_ICON_DND_RAW: case NEMO_ICON_DND_XDNDDIRECTSAVE: return GDK_ACTION_COPY; } return 0; }