Re: [PATCH] Desktop Icons with "Keep Aligned"

On Wed, 2010-01-20 at 16:36 +0100, Alexander Larsson wrote: 
> I think this kind of "lazy" fixup is gonna be problematic. We should
> just do the snapping and aligning as each single icon is added or moved.
> This means for instance that we always position the changing icon so
> there is no stacking, rather than risking the general schedule_align
> code moving some other icon to make place for the new icon or whatnot.
> It also means we don't move stuff unnecessarily, avoiding the rename
> issue you mention (we should have positioned it snapped before even
> enabling the rename.

I see your point. One way to do this could be to use
find_empty_position() by using the placement grid methods. For moving
icons (nautilus_icon_container_move_icon()), I'm thinking of something
like the attached. Does this seem closer to the desired icon behavior?

Similar code is used elsewhere in align_icons, etc. One possible issue
with this approach is that find_empty_location() puts icons in columns
for the purpose of align_icons, so the positioning might not be
intuitive when we find a position conflict. From what I can see,
applying this to icon adding might also be more involved. 
diff --git a/libnautilus-private/nautilus-icon-container.c b/libnautilus-private/nautilus-icon-container.c
index ae58a49..25aff64 100644
--- a/libnautilus-private/nautilus-icon-container.c
+++ b/libnautilus-private/nautilus-icon-container.c
@@ -2429,7 +2429,22 @@ nautilus_icon_container_move_icon (NautilusIconContainer *container,
 	if (!details->auto_layout) {
 		if (details->keep_aligned && snap) {
-			snap_position (container, icon, &x, &y);
+			PlacementGrid *grid;
+			GList *p;
+			NautilusIcon *current_icon;			
+			grid = placement_grid_new (container, TRUE);
+			for (p = container->details->icons; p != NULL; p = p->next) {
+				current_icon = p->data;
+				if (icon_is_positioned (current_icon) && !current_icon->has_lazy_position && current_icon != icon) {
+					placement_grid_mark_icon (grid, current_icon);
+				}
+			}
+			find_empty_location (container, grid, icon, x, y, &x, &y);
+			placement_grid_free (grid);
 		if (x != icon->x || y != icon->y) {

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]