[Xfce4-commits] [xfce/xfdesktop] 01/02: Retain icon relative position when moving a group
noreply at xfce.org
noreply at xfce.org
Mon Feb 27 07:12:20 CET 2017
This is an automated email from the git hooks/post-receive script.
eric pushed a commit to branch master
in repository xfce/xfdesktop.
commit ce4956ccfbc628b7db561b73300f9ac842486a4c
Author: ASL97 <asl97 at openmailbox.org>
Date: Fri Feb 24 03:24:38 2017 +0800
Retain icon relative position when moving a group
Signed-off-by: Eric Koegel <eric.koegel at gmail.com>
---
src/xfdesktop-icon-view.c | 35 ++++++++++++++++++++++-------------
1 file changed, 22 insertions(+), 13 deletions(-)
diff --git a/src/xfdesktop-icon-view.c b/src/xfdesktop-icon-view.c
index 46de229..0148bf6 100644
--- a/src/xfdesktop-icon-view.c
+++ b/src/xfdesktop-icon-view.c
@@ -1612,7 +1612,7 @@ xfdesktop_icon_view_drag_drop(GtkWidget *widget,
XfdesktopIconView *icon_view = XFDESKTOP_ICON_VIEW(widget);
GdkAtom target;
XfdesktopIcon *icon;
- gint16 old_row, old_col, row, col;
+ gint16 old_row, old_col, row, col, offset_col, offset_row;
GList *l;
XfdesktopIcon *icon_on_dest = NULL;
@@ -1669,13 +1669,17 @@ xfdesktop_icon_view_drag_drop(GtkWidget *widget,
icon = icon_view->priv->cursor;
g_return_val_if_fail(icon, FALSE);
- /* 1: Remove all the icons that are going to be moved from
+ /* 1: Get amount of offset between the old spot and new spot
+ * of the icon that's being dragged.
+ * 2: 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. */
+ * 3: We move all the icons using the offset. */
+ if(xfdesktop_icon_get_position(icon, &old_row, &old_col)) {
+ offset_col = old_col-col;
+ offset_row = old_row-row;
+ }
+
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);
@@ -1683,14 +1687,19 @@ xfdesktop_icon_view_drag_drop(GtkWidget *widget,
xfdesktop_grid_set_position_free(icon_view, old_row, old_col);
}
- /* Preserve order when moving multiple icons */
- icon_view->priv->selected_icons = g_list_sort(icon_view->priv->selected_icons,
- (GCompareFunc)xfdesktop_icon_view_compare_icon_positions);
-
- /* 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) {
- /* Find the next available spot for an icon */
+ /* use offset to figure out where to put the icon*/
+ if(xfdesktop_icon_get_position(l->data, &old_row, &old_col)) {
+ col = (old_col-offset_col) % icon_view->priv->ncols;
+ row = (old_row-offset_row) % icon_view->priv->nrows;
+ /* wrap around the view */
+ while(col < 0)
+ col += icon_view->priv->ncols;
+ while(row < 0)
+ row += icon_view->priv->nrows;
+ }
+
+ /* Find the next available spot for an icon if offset spot is not available */
while(!xfdesktop_grid_is_free_position(icon_view, row, col)) {
if(row + 1 >= icon_view->priv->nrows) {
if(col + 1 >= icon_view->priv->ncols)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list