static gboolean panel_check_drop_forbidden (PanelWidget *panel, GdkDragContext *context, guint info, guint time_) { if (!panel) return FALSE; if (panel_lockdown_get_panels_locked_down_s ()) return FALSE; if (info == TARGET_ICON_INTERNAL || info == TARGET_APPLET_INTERNAL) { if (gdk_drag_context_get_actions (context) & GDK_ACTION_MOVE) gdk_drag_status (context, GDK_ACTION_MOVE, time_); else gdk_drag_status (context, gdk_drag_context_get_suggested_action (context), time_); } else if (gdk_drag_context_get_actions (context) & GDK_ACTION_COPY) gdk_drag_status (context, GDK_ACTION_COPY, time_); else gdk_drag_status (context, gdk_drag_context_get_suggested_action (context), time_); return TRUE; }
GdkDragAction athena_drag_default_drop_action_for_netscape_url (GdkDragContext *context) { /* Mozilla defaults to copy, but unless thats the only allowed thing (enforced by ctrl) we want to LINK */ if (gdk_drag_context_get_suggested_action (context) == GDK_ACTION_COPY && gdk_drag_context_get_actions (context) != GDK_ACTION_COPY) { return GDK_ACTION_LINK; } else if (gdk_drag_context_get_suggested_action (context) == GDK_ACTION_MOVE) { /* Don't support move */ return GDK_ACTION_COPY; } return gdk_drag_context_get_suggested_action (context); }
gboolean target_drag_motion (GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time) { GtkWidget *source_widget; GList *tmp_list; if (!have_drag) { have_drag = TRUE; gtk_image_set_from_pixbuf (GTK_IMAGE (widget), trashcan_open); } source_widget = gtk_drag_get_source_widget (context); g_print ("motion, source %s\n", source_widget ? G_OBJECT_TYPE_NAME (source_widget) : "NULL"); tmp_list = gdk_drag_context_list_targets (context); while (tmp_list) { char *name = gdk_atom_name (GDK_POINTER_TO_ATOM (tmp_list->data)); g_print ("%s\n", name); g_free (name); tmp_list = tmp_list->next; } gdk_drag_status (context, gdk_drag_context_get_suggested_action (context), time); return TRUE; }
/** * dnd_clarity_drag_motion: * * Used by the drag and drop of a jpg. While the jpg is being * dragged, this reports to the source widget whether it is an * acceptable location to allow a drop. * */ gboolean dnd_clarity_drag_motion(GtkWidget *widget, GdkDragContext *dc, gint x, gint y, guint time, gpointer user_data) { GdkAtom target; iTunesDB *itdb; ExtraiTunesDBData *eitdb; itdb = gp_get_selected_itdb(); /* no drop is possible if no playlist/repository is selected */ if (itdb == NULL) { gdk_drag_status(dc, 0, time); return FALSE; } eitdb = itdb->userdata; g_return_val_if_fail (eitdb, FALSE); /* no drop is possible if no repository is loaded */ if (!eitdb->itdb_imported) { gdk_drag_status(dc, 0, time); return FALSE; } target = gtk_drag_dest_find_target(widget, dc, NULL); /* no drop possible if no valid target can be found */ if (target == GDK_NONE) { gdk_drag_status(dc, 0, time); return FALSE; } gdk_drag_status(dc, gdk_drag_context_get_suggested_action(dc), time); return TRUE; }
static gboolean gpview_document_view_drag_motion_cb(GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time, GPViewSymbolView *view) { GPViewDocumentViewPrivate *privat = GPVIEW_DOCUMENT_VIEW_GET_PRIVATE(view); if (privat != NULL) { GdkAtom target; gtk_drag_highlight(widget); target = gtk_drag_dest_find_target(widget, context, NULL); if (target == GDK_NONE) { gdk_drag_status(context, 0, time); } else { gdk_drag_status(context, gdk_drag_context_get_suggested_action(context), time); } } return TRUE; }
static gboolean gth_file_list_drag_motion (GtkWidget *file_view, GdkDragContext *context, gint x, gint y, guint time, gpointer extra_data) { GthBrowser *browser = extra_data; BrowserData *data; GthFileData *location_data; data = g_object_get_data (G_OBJECT (browser), BROWSER_DATA_KEY); data->drop_pos = -1; if ((gtk_drag_get_source_widget (context) == file_view) && ! gth_file_source_is_reorderable (gth_browser_get_location_source (browser))) { gdk_drag_status (context, 0, time); return FALSE; } location_data = gth_browser_get_location_data (browser); if (! g_file_info_get_attribute_boolean (location_data->info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE)) { gdk_drag_status (context, 0, time); return FALSE; } if (gth_file_source_is_reorderable (gth_browser_get_location_source (browser))) { GtkAllocation allocation; if (gtk_drag_get_source_widget (context) == file_view) gdk_drag_status (context, GDK_ACTION_MOVE, time); else gdk_drag_status (context, GDK_ACTION_COPY, time); gth_file_view_set_drag_dest_pos (GTH_FILE_VIEW (file_view), context, x, y, time, &data->drop_pos); gtk_widget_get_allocation (file_view, &allocation); if (y < 10) data->scroll_diff = - (10 - y); else if (y > allocation.height - 10) data->scroll_diff = (10 - (allocation.height - y)); else data->scroll_diff = 0; if (data->scroll_diff != 0) { if (data->scroll_event == 0) data->scroll_event = gdk_threads_add_timeout (SCROLL_TIMEOUT, drag_motion_autoscroll_cb, browser); } else if (data->scroll_event != 0) { g_source_remove (data->scroll_event); data->scroll_event = 0; } } else if (gdk_drag_context_get_suggested_action (context) == GDK_ACTION_ASK) gdk_drag_status (context, GDK_ACTION_ASK, time); else gdk_drag_status (context, GDK_ACTION_COPY, time); return TRUE; }
gboolean panel_check_drop_forbidden (PanelWidget *panel, GdkDragContext *context, guint info, guint time_) { if (!panel) return FALSE; if (panel_lockdown_get_locked_down ()) return FALSE; if (info == TARGET_APPLET_INTERNAL) { GtkWidget *source_widget; source_widget = gtk_drag_get_source_widget (context); if (BUTTON_IS_WIDGET (source_widget)) { GSList *forb; forb = g_object_get_data (G_OBJECT (source_widget), MATE_PANEL_APPLET_FORBIDDEN_PANELS); if (g_slist_find (forb, panel)) return FALSE; } } if (info == TARGET_ICON_INTERNAL || info == TARGET_APPLET_INTERNAL) { if (gdk_drag_context_get_actions (context) & GDK_ACTION_MOVE) gdk_drag_status (context, GDK_ACTION_MOVE, time_); else gdk_drag_status (context, gdk_drag_context_get_suggested_action (context), time_); } else if (gdk_drag_context_get_actions (context) & GDK_ACTION_COPY) gdk_drag_status (context, GDK_ACTION_COPY, time_); else gdk_drag_status (context, gdk_drag_context_get_suggested_action (context), time_); return TRUE; }
wxDragResult wxDropTarget::GTKFigureOutSuggestedAction() { if (!m_dragContext) return wxDragError; // GTK+ always supposes that we want to copy the data by default while we // might want to move it, so examine not only suggested_action - which is // only good if we don't have our own preferences - but also the actions // field wxDragResult suggested_action = wxDragNone; const GdkDragAction actions = gdk_drag_context_get_actions(m_dragContext); if (GetDefaultAction() == wxDragNone) { // use default action set by wxDropSource::DoDragDrop() if ( (gs_flagsForDrag & wxDrag_DefaultMove) == wxDrag_DefaultMove && (actions & GDK_ACTION_MOVE)) { // move is requested by the program and allowed by GTK+ - do it, even // though suggested_action may be currently wxDragCopy suggested_action = wxDragMove; } else // use whatever GTK+ says we should { suggested_action = ConvertFromGTK(gdk_drag_context_get_suggested_action(m_dragContext)); #if 0 // RR: I don't understand the code below: if the drag comes from // a different app, the gs_flagsForDrag is invalid; if it // comes from the same wx app, then GTK+ hopefully won't // suggest something we didn't allow in the frist place // in DoDrop() if ( (suggested_action == wxDragMove) && !(gs_flagsForDrag & wxDrag_AllowMove) ) { // we're requested to move but we can't suggested_action = wxDragCopy; } #endif } } else if (GetDefaultAction() == wxDragMove && (actions & GDK_ACTION_MOVE)) { suggested_action = wxDragMove; } else { if (actions & GDK_ACTION_COPY) suggested_action = wxDragCopy; else if (actions & GDK_ACTION_MOVE) suggested_action = wxDragMove; else if (actions & GDK_ACTION_LINK) suggested_action = wxDragLink; else suggested_action = wxDragNone; } return suggested_action; }
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; } }
GdkDragAction athena_drag_default_drop_action_for_uri_list (GdkDragContext *context, const char *target_uri_string) { if (eel_uri_is_trash (target_uri_string) && (gdk_drag_context_get_actions (context) & GDK_ACTION_MOVE)) { /* Only move to Trash */ return GDK_ACTION_MOVE; } else { return gdk_drag_context_get_suggested_action (context); } }
static void dnd_received_cb (GtkWidget *widget, GdkDragContext *context, gint x, gint y, GtkSelectionData *selection_data, guint target_type, guint time, gpointer data) { GFile *file_uri; gchar **file_list; const guchar *file_data; STlinkGUI *gui = STLINK_GUI (data); GtkListStore *store; GtkTreeIter iter; if (selection_data != NULL && gtk_selection_data_get_length (selection_data) > 0) { switch (target_type) { case TARGET_FILENAME: if (gui->filename) { g_free (gui->filename); } file_data = gtk_selection_data_get_data (selection_data); file_list = g_strsplit ((gchar *)file_data, "\r\n", 0); file_uri = g_file_new_for_uri (file_list[0]); gui->filename = g_file_get_path (file_uri); g_strfreev (file_list); g_object_unref (file_uri); store = GTK_LIST_STORE (gtk_tree_view_get_model (gui->devmem_treeview)); if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter)) { gtk_list_store_clear (store); } stlink_gui_set_sensitivity (gui, FALSE); gtk_notebook_set_current_page (gui->notebook, PAGE_FILEMEM); gtk_widget_show (GTK_WIDGET (gui->progress.bar)); gtk_progress_bar_set_text (gui->progress.bar, "Reading file"); g_thread_new ("file", (GThreadFunc) stlink_gui_populate_filemem_view, gui); break; } } gtk_drag_finish (context, TRUE, gdk_drag_context_get_suggested_action (context) == GDK_ACTION_MOVE, time); }
static gboolean drag_motion (GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time_) { EmpathyPersonaView *self = EMPATHY_PERSONA_VIEW (widget); GdkAtom target; guint i; DndDragType drag_type = DND_DRAG_TYPE_UNKNOWN; target = gtk_drag_dest_find_target (GTK_WIDGET (self), context, NULL); /* Determine the DndDragType of the data */ for (i = 0; i < G_N_ELEMENTS (drag_atoms_dest); i++) { if (target == drag_atoms_dest[i]) { drag_type = drag_types_dest[i].info; break; } } if (drag_type == DND_DRAG_TYPE_INDIVIDUAL_ID) { GtkTreePath *path; /* FIXME: It doesn't make sense for us to highlight a specific row or * position to drop an Individual in, so just highlight the entire * widget. * Since I can't find a way to do this, just highlight the first possible * position in the tree. */ gdk_drag_status (context, gdk_drag_context_get_suggested_action (context), time_); path = gtk_tree_path_new_first (); gtk_tree_view_set_drag_dest_row (GTK_TREE_VIEW (self), path, GTK_TREE_VIEW_DROP_BEFORE); gtk_tree_path_free (path); return TRUE; } /* Unknown or unhandled drag target */ gdk_drag_status (context, GDK_ACTION_DEFAULT, time_); gtk_tree_view_set_drag_dest_row (GTK_TREE_VIEW (self), NULL, 0); return FALSE; }
void on_drag_data_received(GtkWidget* widget, GdkDragContext* context, gint x, gint y, GtkSelectionData *data, guint info, guint time, gpointer user_data) { FskGtkWindow gtkWin = user_data; gboolean dnd_success = FALSE; FskDragDropFile dropFileList = NULL; FskDragDropFile droppedFile = NULL; char* path = NULL; if (gdk_drag_context_get_suggested_action(context) == GDK_ACTION_COPY) { char* string = (char*)gtk_selection_data_get_data(data); char* end; FskFileInfo itemInfo; for (end = FskStrStr(string, "\r\n"); end; end = FskStrStr(string, "\r\n")) { BAIL_IF_ERR(FskMemPtrNewClear(sizeof(FskDragDropFileRecord), (FskMemPtr*)&droppedFile)); FskListAppend((FskList *)&dropFileList, droppedFile); *end = 0; BAIL_IF_ERR(KprURLToPath(string, &path)); BAIL_IF_ERR(FskFileGetFileInfo(path, &itemInfo)); if (itemInfo.filetype == kFskDirectoryItemIsDirectory) { int length = FskStrLen(path); BAIL_IF_ERR(FskMemPtrNew(length + 2, &droppedFile->fullPathName)); FskMemCopy(droppedFile->fullPathName, path, length); droppedFile->fullPathName[length] = '/'; droppedFile->fullPathName[length + 1] = 0; FskMemPtrDispose(path); } else { droppedFile->fullPathName = path; } path = NULL; string = end + 2; *end = '\r'; } (*gDropTargetProc)(kFskDragDropTargetEnterWindow, x, y, dropFileList, gtkWin->owner); (*gDropTargetProc)(kFskDragDropTargetDropInWindow, x, y, dropFileList, gtkWin->owner); dnd_success = TRUE; } bail: gtk_drag_finish(context, dnd_success, TRUE, time); FskMemPtrDispose(path); while (NULL != dropFileList) { droppedFile = dropFileList; FskListRemove((FskList *)&dropFileList, droppedFile); FskMemPtrDispose(droppedFile->fullPathName); FskMemPtrDispose(droppedFile); } }
static guint get_drop_action (NautilusTreeViewDragDest *dest, GdkDragContext *context, GtkTreePath *path) { char *drop_target; int action; if (!dest->details->have_drag_data || (dest->details->drag_type == NAUTILUS_ICON_DND_GNOME_ICON_LIST && dest->details->drag_list == NULL)) { return 0; } drop_target = get_drop_target_uri_for_path (dest, path); if (drop_target == NULL) { return 0; } action = 0; switch (dest->details->drag_type) { case NAUTILUS_ICON_DND_GNOME_ICON_LIST : nautilus_drag_default_drop_action_for_icons (context, drop_target, dest->details->drag_list, &action); break; case NAUTILUS_ICON_DND_NETSCAPE_URL: action = nautilus_drag_default_drop_action_for_netscape_url (context); break; case NAUTILUS_ICON_DND_URI_LIST : action = gdk_drag_context_get_suggested_action (context); break; case NAUTILUS_ICON_DND_TEXT: case NAUTILUS_ICON_DND_RAW: case NAUTILUS_ICON_DND_XDNDDIRECTSAVE: action = GDK_ACTION_COPY; break; } g_free (drop_target); return action; }
static gboolean gtkDragMotion(GtkWidget *widget, GdkDragContext *drag_context, gint x, gint y, guint time, Ihandle* ih) { GdkAtom targetAtom; /* The third argument must be NULL. Internally, GTK will use the list returned by the call gtk_drag_dest_get_target_list(widget), which is the list of targets that be destination widget can accept (defined in the gtkSetDropTargetAttrib IUP) */ targetAtom = gtk_drag_dest_find_target(widget, drag_context, NULL); if(targetAtom != GDK_NONE) { IFniis cbDropMotion = (IFniis)IupGetCallback(ih, "DROPMOTION_CB"); if(cbDropMotion) { char status[IUPKEY_STATUS_SIZE] = IUPKEY_STATUS_INIT; GdkModifierType mask; gdk_window_get_pointer(iupgtkGetWindow(widget), NULL, NULL, &mask); iupgtkButtonKeySetStatus(mask, 0, status, 0); cbDropMotion(ih, x, y, status); } #if GTK_CHECK_VERSION(2, 22, 0) gdk_drag_status(drag_context, gdk_drag_context_get_suggested_action(drag_context), time); #else gdk_drag_status(drag_context, drag_context->suggested_action, time); #endif return TRUE; } (void)ih; (void)x; (void)y; gdk_drag_status(drag_context, 0, time); return FALSE; }
static gboolean individual_view_drag_motion_cb (GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time_) { EmpathyIndividualView *view = EMPATHY_INDIVIDUAL_VIEW (widget); GdkAtom target; target = gtk_drag_dest_find_target (GTK_WIDGET (view), context, NULL); if (target == gdk_atom_intern_static_string ("text/x-persona-id")) { GtkTreePath *path; /* FIXME: It doesn't make sense for us to highlight a specific row or * position to drop a Persona in, so just highlight the entire widget. * Since I can't find a way to do this, just highlight the first possible * position in the tree. */ gdk_drag_status (context, gdk_drag_context_get_suggested_action (context), time_); path = gtk_tree_path_new_first (); gtk_tree_view_set_drag_dest_row (GTK_TREE_VIEW (view), path, GTK_TREE_VIEW_DROP_BEFORE); gtk_tree_path_free (path); return TRUE; } /* Unknown or unhandled drag target */ gdk_drag_status (context, GDK_ACTION_DEFAULT, time_); gtk_tree_view_set_drag_dest_row (GTK_TREE_VIEW (view), NULL, 0); return FALSE; }
void athena_drag_default_drop_action_for_icons (GdkDragContext *context, const char *target_uri_string, const GList *items, int *action) { gboolean same_fs; gboolean target_is_source_parent; gboolean source_deletable; const char *dropped_uri; GFile *target, *dropped, *dropped_directory; GdkDragAction actions; AthenaFile *dropped_file, *target_file; if (target_uri_string == NULL) { *action = 0; return; } actions = gdk_drag_context_get_actions (context) & (GDK_ACTION_MOVE | GDK_ACTION_COPY); if (actions == 0) { /* We can't use copy or move, just go with the suggested action. */ *action = gdk_drag_context_get_suggested_action (context); return; } if (gdk_drag_context_get_suggested_action (context) == GDK_ACTION_ASK) { /* Don't override ask */ *action = gdk_drag_context_get_suggested_action (context); return; } dropped_uri = ((AthenaDragSelectionItem *)items->data)->uri; dropped_file = athena_file_get_existing_by_uri (dropped_uri); target_file = athena_file_get_existing_by_uri (target_uri_string); /* * Check for trash URI. We do a find_directory for any Trash directory. * Passing 0 permissions as gnome-vfs would override the permissions * passed with 700 while creating .Trash directory */ if (eel_uri_is_trash (target_uri_string)) { /* Only move to Trash */ if (actions & GDK_ACTION_MOVE) { *action = GDK_ACTION_MOVE; } athena_file_unref (dropped_file); athena_file_unref (target_file); return; } else if (dropped_file != NULL && athena_file_is_launcher (dropped_file)) { if (actions & GDK_ACTION_MOVE) { *action = GDK_ACTION_MOVE; } athena_file_unref (dropped_file); athena_file_unref (target_file); return; } else if (eel_uri_is_desktop (target_uri_string)) { target = athena_get_desktop_location (); athena_file_unref (target_file); target_file = athena_file_get (target); if (eel_uri_is_desktop (dropped_uri)) { /* Only move to Desktop icons */ if (actions & GDK_ACTION_MOVE) { *action = GDK_ACTION_MOVE; } g_object_unref (target); athena_file_unref (dropped_file); athena_file_unref (target_file); return; } } else if (target_file != NULL && athena_file_is_archive (target_file)) { *action = GDK_ACTION_COPY; athena_file_unref (dropped_file); athena_file_unref (target_file); return; } else { target = g_file_new_for_uri (target_uri_string); } same_fs = check_same_fs (target_file, dropped_file); athena_file_unref (dropped_file); athena_file_unref (target_file); /* Compare the first dropped uri with the target uri for same fs match. */ dropped = g_file_new_for_uri (dropped_uri); dropped_directory = g_file_get_parent (dropped); target_is_source_parent = FALSE; if (dropped_directory != NULL) { /* If the dropped file is already in the same directory but is in another filesystem we still want to move, not copy as this is then just a move of a mountpoint to another position in the dir */ target_is_source_parent = g_file_equal (dropped_directory, target); g_object_unref (dropped_directory); } source_deletable = source_is_deletable (dropped); if ((same_fs && source_deletable) || target_is_source_parent || g_file_has_uri_scheme (dropped, "trash")) { if (actions & GDK_ACTION_MOVE) { *action = GDK_ACTION_MOVE; } else { *action = gdk_drag_context_get_suggested_action (context); } } else { if (actions & GDK_ACTION_COPY) { *action = GDK_ACTION_COPY; } else { *action = gdk_drag_context_get_suggested_action (context); } } g_object_unref (target); g_object_unref (dropped); }
static gboolean drag_motion_cb (GtkWidget *widget, GdkDragContext *context, int x, int y, guint32 time, EphyNodeView *view) { EphyNode *node; GdkAtom target; GtkTreePath *path; GtkTreeViewDropPosition pos; guint action = 0; int priority; gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget), x, y, &path, &pos); if (!view->priv->have_drag_data) { get_drag_data (view, context, time); } target = gtk_drag_dest_find_target (widget, context, NULL); node = get_node_from_path (view, path); if (target != GDK_NONE && node != NULL) { priority = ephy_node_get_property_int (node, view->priv->priority_prop_id); if (priority != EPHY_NODE_VIEW_ALL_PRIORITY && priority != EPHY_NODE_VIEW_SPECIAL_PRIORITY && ephy_node_get_is_drag_source (node)) { action = gdk_drag_context_get_suggested_action (context); } } if (action) { set_drag_dest_row (view, path); } else { clear_drag_dest_row (view); } if (path) { gtk_tree_path_free (path); } if (view->priv->scroll_id == 0) { view->priv->scroll_id = g_timeout_add (150, scroll_timeout, GTK_TREE_VIEW (view)); } gdk_drag_status (context, action, time); return TRUE; }
static void gth_file_list_drag_data_received (GtkWidget *file_view, GdkDragContext *context, int x, int y, GtkSelectionData *selection_data, guint info, guint time, gpointer user_data) { GthBrowser *browser = user_data; gboolean success = FALSE; char **uris; GList *selected_files; GdkDragAction action; g_signal_stop_emission_by_name (file_view, "drag-data-received"); action = gdk_drag_context_get_suggested_action (context); if (action == GDK_ACTION_COPY || action == GDK_ACTION_MOVE) { success = TRUE; } if (action == GDK_ACTION_ASK) { GdkDragAction actions = _gtk_menu_ask_drag_drop_action (file_view, gdk_drag_context_get_actions (context), time); gdk_drag_status (context, actions, time); success = gdk_drag_context_get_selected_action (context) != 0; } if (gtk_selection_data_get_data_type (selection_data) == XDND_ACTION_DIRECT_SAVE_ATOM) { const guchar *data; int format; int length; data = gtk_selection_data_get_data (selection_data); format = gtk_selection_data_get_format (selection_data); length = gtk_selection_data_get_length (selection_data); if ((format == 8) && (length == 1) && (data[0] == 'S')) { success = TRUE; } else { gdk_property_change (gdk_drag_context_get_dest_window (context), XDND_ACTION_DIRECT_SAVE_ATOM, TEXT_PLAIN_ATOM, 8, GDK_PROP_MODE_REPLACE, (const guchar *) "", 0); success = FALSE; } gtk_drag_finish (context, success, FALSE, time); return; } gtk_drag_finish (context, success, FALSE, time); if (! success) return; uris = gtk_selection_data_get_uris (selection_data); selected_files = _g_file_list_new_from_uriv (uris); if (selected_files != NULL) { if (gtk_drag_get_source_widget (context) == file_view) { GList *file_data_list; GList *visible_files; BrowserData *data; GthTask *task; file_data_list = gth_file_store_get_visibles (gth_browser_get_file_store (browser)); visible_files = gth_file_data_list_to_file_list (file_data_list); data = g_object_get_data (G_OBJECT (browser), BROWSER_DATA_KEY); task = gth_reorder_task_new (gth_browser_get_location_source (browser), gth_browser_get_location_data (browser), visible_files, selected_files, data->drop_pos); gth_browser_exec_task (browser, task, FALSE); g_object_unref (task); _g_object_list_unref (visible_files); _g_object_list_unref (file_data_list); } else { GthFileSource *file_source; gboolean cancel = FALSE; gboolean move; file_source = gth_browser_get_location_source (browser); move = gdk_drag_context_get_selected_action (context) == GDK_ACTION_MOVE; if (move && ! gth_file_source_can_cut (file_source, (GFile *) selected_files->data)) { GtkWidget *dialog; int response; dialog = _gtk_message_dialog_new (GTK_WINDOW (browser), GTK_DIALOG_MODAL, GTK_STOCK_DIALOG_QUESTION, _("Could not move the files"), _("Files cannot be moved to the current location, as alternative you can choose to copy them."), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_COPY, GTK_RESPONSE_OK, NULL); response = gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); if (response == GTK_RESPONSE_CANCEL) cancel = TRUE; move = FALSE; } if (! cancel) { GthFileSource *location_source; BrowserData *data; GthTask *task; location_source = gth_main_get_file_source (gth_browser_get_location (browser)); data = g_object_get_data (G_OBJECT (browser), BROWSER_DATA_KEY); task = gth_copy_task_new (location_source, gth_browser_get_location_data (browser), move, selected_files, data->drop_pos); gth_browser_exec_task (browser, task, FALSE); g_object_unref (task); g_object_unref (location_source); } } } _g_object_list_unref (selected_files); g_strfreev (uris); }