From 46d8d17c3e5c7f1b00091a29d7b1749fb73b6323 Mon Sep 17 00:00:00 2001 From: Eric Koegel Date: Sat, 19 Nov 2011 13:38:56 +0300 Subject: [PATCH] Modified xfdesktop_icon_view_drag_drop to allow all selected files to drag and drop. Fixes Bug #5025 --- src/xfdesktop-icon-view.c | 46 ++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 41 insertions(+), 5 deletions(-) diff --git a/src/xfdesktop-icon-view.c b/src/xfdesktop-icon-view.c index 0736006..5c56f34 100644 --- a/src/xfdesktop-icon-view.c +++ b/src/xfdesktop-icon-view.c @@ -1327,6 +1327,7 @@ xfdesktop_icon_view_drag_drop(GtkWidget *widget, GdkAtom target = GDK_NONE; XfdesktopIcon *icon; guint16 old_row, old_col, row, col; + GList *l; XfdesktopIcon *icon_on_dest = NULL; TRACE("entering: (%d,%d)", x, y); @@ -1346,7 +1347,6 @@ xfdesktop_icon_view_drag_drop(GtkWidget *widget, if(target == gdk_atom_intern("XFDESKTOP_ICON", FALSE)) { if(icon_on_dest) { - GList *l; gboolean ret = FALSE; for(l = icon_view->priv->selected_icons; l; l = l->next) { @@ -1366,10 +1366,20 @@ xfdesktop_icon_view_drag_drop(GtkWidget *widget, icon = icon_view->priv->cursor; g_return_val_if_fail(icon, FALSE); - /* clear out old position */ - xfdesktop_icon_view_invalidate_icon(icon_view, icon, FALSE); - if(xfdesktop_icon_get_position(icon, &old_row, &old_col)) - xfdesktop_grid_set_position_free(icon_view, old_row, old_col); + /* 1: Remove all the icons that are going to be moved from + * the desktop. That's in case the icons being moved + * want to rearrange themselves there. + * 2: We need to move the icon that's being dragged since the + * user explicitly wants to drop it in that spot. + * 3: We just append all the other icons in any spot that's + * open. */ + for(l = icon_view->priv->selected_icons; l; l = l->next) { + /* clear out old position */ + xfdesktop_icon_view_invalidate_icon(icon_view, l->data, FALSE); + if(xfdesktop_icon_get_position(l->data, &old_row, &old_col)) + xfdesktop_grid_set_position_free(icon_view, old_row, old_col); + } + /* set new position */ xfdesktop_icon_set_position(icon, row, col); xfdesktop_grid_unset_position_free(icon_view, icon); @@ -1379,6 +1389,32 @@ xfdesktop_icon_view_drag_drop(GtkWidget *widget, //xfdesktop_icon_mark_extents_dirty(icon); xfdesktop_icon_view_invalidate_icon(icon_view, icon, TRUE); + /* Now that we have moved the icon the user selected, + * append all the other selected icons after it. */ + for(l = icon_view->priv->selected_icons; l; l = l->next) { + if(l->data == icon) + continue; + + /* Find the next available spot for an icon */ + do { + if(row + 1 >= icon_view->priv->nrows) { + ++col; + row = 0; + } else { + ++row; + } + } while(!xfdesktop_grid_is_free_position(icon_view, row, col)); + + /* set new position */ + xfdesktop_icon_set_position(l->data, row, col); + xfdesktop_grid_unset_position_free(icon_view, l->data); + + /* clear out old extents, if any */ + /* FIXME: is this right? */ + //xfdesktop_icon_mark_extents_dirty(icon); + xfdesktop_icon_view_invalidate_icon(icon_view, l->data, TRUE); + } + DBG("drag succeeded"); gtk_drag_finish(context, TRUE, FALSE, time_); -- 1.7.5.4