Overlapping icons, again



Hi,

I finally found the reason why volume icons overlap in the desktop
(http://bugzilla.gnome.org/show_bug.cgi?id=330298)

finish_adding_new_icons() was ignoring all lazily-positioned icons when
filling up the PlacemenGrid.  This caused the overlaps.  The fix is to
make icon_set_position() turn off that flag in the icon.

Also, once a lazily-positioned icon was moved to avoid overlaps, we
weren't emitting icon_position_changed so that the higher-level code
would save the new position metadata.  This caused potential overlaps
when restarting Nautilus.

Is this OK to commit?

[This needs a little change to apply to Manny's latest version of
nautilus-icon-container.c, which doesn't have separate scaling values
for x/y, but that's a trivial change I'll make when applying the patch.]

  Federico
2006-05-31  Federico Mena Quintero  <federico novell com>

	Fix the use of lazy positioning, and the saving of metadata for
	lazily-positioned icons.  Fixes
	http://bugzilla.novell.com/show_bug.cgi?id=174766.

	* libnautilus-private/nautilus-icon-container.c
	(icon_set_position): Clear icon->has_lazy_position, since the icon
	will be positioned once this function exits.
	(finish_adding_new_icons): Do not ignore already-placed lazy
	position icons when filling the placement grid!  Save the value of
	icon->has_lazy_position before calling assign_icon_position().
	Since that function may call icon_set_position() (which will clear
	the flag), we need to keep the original value of the flag.
	(finish_adding_new_icons): Don't clear icon->has_lazy_position
	here; let icon_set_position() do it.
	(finish_adding_new_icons): Emit the icon_position_changed signal
	so that the parent knows that we moved an icon under it.  This has
	the effect of updating/preserving the position metadata for
	has_lazy_position icons.

--- nautilus/libnautilus-private/nautilus-icon-container.c	2006-04-07 15:12:27.000000000 -0500
+++ nautilus/libnautilus-private/nautilus-icon-container.c	2006-05-31 15:30:50.000000000 -0500
@@ -277,6 +277,8 @@ icon_set_position (NautilusIcon *icon,
 	int x1, y1, x2, y2;
 	int container_x, container_y, container_width, container_height;
 
+	icon->has_lazy_position = FALSE;
+
 	if (icon->x == x && icon->y == y) {
 		return;
 	}
@@ -1304,6 +1306,7 @@ placement_grid_mark_icon (PlacementGrid 
 	canvas_position_to_grid_position (grid, 
 					  icon_pos,
 					  &grid_pos);
+
 	placement_grid_mark (grid, grid_pos);
 }
 
@@ -5166,9 +5169,13 @@ finish_adding_new_icons (NautilusIconCon
 	new_icons = g_list_reverse (new_icons);
 	no_position_icons = semi_position_icons = NULL;
 	for (p = new_icons; p != NULL; p = p->next) {
+		gboolean has_lazy_position;
+
 		icon = p->data;
+		has_lazy_position = icon->has_lazy_position;
+
 		if (assign_icon_position (container, icon)) {
-			if (!container->details->is_reloading && !container->details->auto_layout && icon->has_lazy_position) {
+			if (!container->details->is_reloading && !container->details->auto_layout && has_lazy_position) {
 				semi_position_icons = g_list_prepend (semi_position_icons, icon);
 			}
 		} else {
@@ -5201,6 +5208,7 @@ finish_adding_new_icons (NautilusIconCon
 		for (p = semi_position_icons; p != NULL; p = p->next) {
 			NautilusIcon *icon;
 			int x, y;
+			NautilusIconPosition position;
 
 			icon = p->data;
 			x = icon->x;
@@ -5213,9 +5221,12 @@ finish_adding_new_icons (NautilusIconCon
 
 			placement_grid_mark_icon (grid, icon);
 
-			/* ensure that next time we run this code, the formerly semi-positioned
-			 * icons are treated as being positioned. */
-			icon->has_lazy_position = FALSE;
+			position.x = icon->x;
+			position.y = icon->y;
+			position.scale_x = icon->scale_x;
+			position.scale_y = icon->scale_y;
+			g_signal_emit (container, signals[ICON_POSITION_CHANGED], 0,
+				       icon->data, &position);
 		}
 
 		placement_grid_free (grid);


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