[PATCH] Don't position volume/drives above other icons



Probably the most obvious/reported icon container glitch [1,2].
Proposed patch attached.

[1] http://bugzilla.gnome.org/show_bug.cgi?id=45953
[2] http://bugzilla.gnome.org/attachment.cgi?id=31279&action=view

-- 
Christian Neumair <chris gnome-de org>
Index: libnautilus-private/nautilus-icon-container.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-container.c,v
retrieving revision 1.393
diff -u -p -r1.393 nautilus-icon-container.c
--- libnautilus-private/nautilus-icon-container.c	12 Aug 2005 18:11:29 -0000	1.393
+++ libnautilus-private/nautilus-icon-container.c	14 Aug 2005 22:43:48 -0000
@@ -5152,7 +5152,7 @@ finish_adding_icon (NautilusIconContaine
 static void
 finish_adding_new_icons (NautilusIconContainer *container)
 {
-	GList *p, *new_icons, *no_position_icons;
+	GList *p, *new_icons, *no_position_icons, *semi_position_icons;
 	NautilusIcon *icon;
 	double bottom;
 
@@ -5161,16 +5161,57 @@ finish_adding_new_icons (NautilusIconCon
 
 	/* Position most icons (not unpositioned manual-layout icons). */
 	new_icons = g_list_reverse (new_icons);
-	no_position_icons = NULL;
+	no_position_icons = semi_position_icons = NULL;
 	for (p = new_icons; p != NULL; p = p->next) {
 		icon = p->data;
 		if (!assign_icon_position (container, icon)) {
 			no_position_icons = g_list_prepend (no_position_icons, icon);
+		} else if (!container->details->auto_layout &&
+			   icon->has_lazy_position) {
+			semi_position_icons = g_list_prepend (semi_position_icons, icon);
 		}
 		finish_adding_icon (container, icon);
 	}
 	g_list_free (new_icons);
 
+	if (semi_position_icons != NULL) {
+		PlacementGrid *grid;
+
+		g_assert (!container->details->auto_layout);
+
+		semi_position_icons = g_list_reverse (semi_position_icons);
+
+		grid = placement_grid_new (container, TRUE);
+
+		for (p = container->details->icons; p != NULL; p = p->next) {
+			icon = p->data;
+
+			if (icon_is_positioned (icon) && !icon->has_lazy_position) {
+				placement_grid_mark_icon (grid, icon);
+			}
+		}
+
+		for (p = semi_position_icons; p != NULL; p = p->next) {
+			NautilusIcon *icon;
+			int x, y;
+
+			icon = p->data;
+			x = icon->x;
+			y = icon->y;
+
+			find_empty_location (container, grid, 
+					     icon, x, y, &x, &y);
+
+			icon_set_position (icon, x, y);
+
+			placement_grid_mark_icon (grid, icon);
+		}
+
+		placement_grid_free (grid);
+
+		g_list_free (semi_position_icons);
+	}
+
 	/* Position the unpositioned manual layout icons. */
 	if (no_position_icons != NULL) {
 		g_assert (!container->details->auto_layout);
@@ -5186,13 +5227,18 @@ finish_adding_new_icons (NautilusIconCon
  * nautilus_icon_container_add:
  * @container: A NautilusIconContainer
  * @data: Icon data.
+ * @has_lazy_position: Whether the saved icon position should only be used
+ * 		       if the previous icon position is free. If the position
+ * 		       is occupied, another position near the last one will
+ * 		       be used.
  * 
  * Add icon to represent @data to container.
  * Returns FALSE if there was already such an icon.
  **/
 gboolean
 nautilus_icon_container_add (NautilusIconContainer *container,
-			     NautilusIconData *data)
+			     NautilusIconData *data,
+			     gboolean has_lazy_position)
 {
 	NautilusIconContainerDetails *details;
 	NautilusIcon *icon;
@@ -5212,6 +5258,7 @@ nautilus_icon_container_add (NautilusIco
 	icon->data = data;
 	icon->x = ICON_UNPOSITIONED_VALUE;
 	icon->y = ICON_UNPOSITIONED_VALUE;
+	icon->has_lazy_position = has_lazy_position;
 	icon->scale_x = 1.0;
 	icon->scale_y = 1.0;
  	icon->item = NAUTILUS_ICON_CANVAS_ITEM
Index: libnautilus-private/nautilus-icon-container.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-container.h,v
retrieving revision 1.87
diff -u -p -r1.87 nautilus-icon-container.h
--- libnautilus-private/nautilus-icon-container.h	5 Jul 2005 12:23:34 -0000	1.87
+++ libnautilus-private/nautilus-icon-container.h	14 Aug 2005 22:43:48 -0000
@@ -204,7 +204,8 @@ GtkWidget *       nautilus_icon_containe
 /* adding, removing, and managing icons */
 void              nautilus_icon_container_clear                         (NautilusIconContainer  *view);
 gboolean          nautilus_icon_container_add                           (NautilusIconContainer  *view,
-									 NautilusIconData       *data);
+									 NautilusIconData       *data,
+									 gboolean                has_lazy_position);
 void              nautilus_icon_container_layout_now                    (NautilusIconContainer *container);
 gboolean          nautilus_icon_container_remove                        (NautilusIconContainer  *view,
 									 NautilusIconData       *data);
Index: libnautilus-private/nautilus-icon-dnd.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-dnd.c,v
retrieving revision 1.148
diff -u -p -r1.148 nautilus-icon-dnd.c
--- libnautilus-private/nautilus-icon-dnd.c	13 Jul 2005 08:17:29 -0000	1.148
+++ libnautilus-private/nautilus-icon-dnd.c	14 Aug 2005 22:43:49 -0000
@@ -844,7 +844,8 @@ handle_local_move (NautilusIconContainer
 			g_free (screen_string);
 
 			nautilus_icon_container_add (container,
-					NAUTILUS_ICON_CONTAINER_ICON_DATA (file));
+					NAUTILUS_ICON_CONTAINER_ICON_DATA (file),
+					FALSE);
 			
 			icon = nautilus_icon_container_get_icon_by_uri
 				(container, item->uri);
Index: libnautilus-private/nautilus-icon-private.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-private.h,v
retrieving revision 1.77
diff -u -p -r1.77 nautilus-icon-private.h
--- libnautilus-private/nautilus-icon-private.h	6 Jul 2005 11:45:08 -0000	1.77
+++ libnautilus-private/nautilus-icon-private.h	14 Aug 2005 22:43:49 -0000
@@ -57,6 +57,7 @@ typedef struct {
 	/* Whether a monitor was set on this icon. */
 	eel_boolean_bit is_monitored : 1;
 
+	eel_boolean_bit has_lazy_position : 1;
 } NautilusIcon;
 
 
Index: src/file-manager/fm-icon-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-icon-view.c,v
retrieving revision 1.313
diff -u -p -r1.313 fm-icon-view.c
--- src/file-manager/fm-icon-view.c	12 Aug 2005 18:11:30 -0000	1.313
+++ src/file-manager/fm-icon-view.c	14 Aug 2005 22:44:00 -0000
@@ -535,7 +535,9 @@ fm_icon_view_add_file (FMDirectoryView *
 	}
 	
 	if (nautilus_icon_container_add (icon_container,
-					 NAUTILUS_ICON_CONTAINER_ICON_DATA (file))) {
+					 NAUTILUS_ICON_CONTAINER_ICON_DATA (file),
+					 nautilus_file_has_volume (file)
+					 || nautilus_file_has_drive (file))) {
 		nautilus_file_ref (file);
 	}
 }
@@ -2018,7 +2020,9 @@ fm_icon_view_screen_changed (GtkWidget *
 				fm_icon_view_remove_file (view, file);
 			} else {
 				if (nautilus_icon_container_add (icon_container,
-								 NAUTILUS_ICON_CONTAINER_ICON_DATA (file))) {
+								 NAUTILUS_ICON_CONTAINER_ICON_DATA (file),
+								 nautilus_file_has_volume (file)
+								 || nautilus_file_has_drive (file))) {
 					nautilus_file_ref (file);
 				}
 			}

Attachment: signature.asc
Description: This is a digitally signed message part



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