[nautilus] icon-view: Only resort during relayout if necessary



commit 41c7cb2ae8fb98fab2cd9b0cfb59cf6dee4d476c
Author: Alexander Larsson <alexl redhat com>
Date:   Tue May 3 16:54:40 2011 +0200

    icon-view: Only resort during relayout if necessary
    
    We don't need to resort unless e.g. a file changed or was added.
    
    Additionally, for weird reason this makes the keyboard focus handling
    work when deleting a file (file after deleted gets focus). This was
    broken due to a relayout happening due to a size_allocate due to
    a style set due to a focus change when going to/from the "are you sure"
    dialog.

 libnautilus-private/nautilus-icon-container.c |   12 +++++++++++-
 libnautilus-private/nautilus-icon-private.h   |    1 +
 2 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/libnautilus-private/nautilus-icon-container.c b/libnautilus-private/nautilus-icon-container.c
index 3c931a8..0f6633a 100644
--- a/libnautilus-private/nautilus-icon-container.c
+++ b/libnautilus-private/nautilus-icon-container.c
@@ -2147,7 +2147,10 @@ redo_layout_internal (NautilusIconContainer *container)
 	 */
 	if (container->details->auto_layout
 	    && container->details->drag_state != DRAG_STATE_STRETCH) {
-		resort (container);
+		if (container->details->needs_resort) {
+			resort (container);
+			container->details->needs_resort = FALSE;
+		}
 		lay_down_icons (container, container->details->icons, 0);
 	}
 
@@ -7193,6 +7196,8 @@ nautilus_icon_container_add (NautilusIconContainer *container,
 
 	g_hash_table_insert (details->icon_set, data, icon);
 
+	details->needs_resort = TRUE;
+
 	/* Run an idle function to add the icons. */
 	schedule_redo_layout (container);
 	
@@ -7265,6 +7270,7 @@ nautilus_icon_container_request_update (NautilusIconContainer *container,
 
 	if (icon != NULL) {
 		nautilus_icon_container_update_icon (container, icon);
+		container->details->needs_resort = TRUE;
 		schedule_redo_layout (container);
 	}
 }
@@ -7329,6 +7335,7 @@ nautilus_icon_container_request_update_all (NautilusIconContainer *container)
 		nautilus_icon_container_update_icon (container, icon);
 	}
 
+	container->details->needs_resort = TRUE;
 	redo_layout (container);
 }
 
@@ -7896,6 +7903,7 @@ nautilus_icon_container_set_auto_layout (NautilusIconContainer *container,
 		nautilus_icon_container_freeze_icon_positions (container);
 	}
 
+	container->details->needs_resort = TRUE;
 	redo_layout (container);
 
 	g_signal_emit (container, signals[LAYOUT_CHANGED], 0);
@@ -7962,6 +7970,7 @@ nautilus_icon_container_set_layout_mode (NautilusIconContainer *container,
 	container->details->layout_mode = mode;
 	invalidate_labels (container);
 
+	container->details->needs_resort = TRUE;
 	redo_layout (container);
 
 	g_signal_emit (container, signals[LAYOUT_CHANGED], 0);
@@ -8023,6 +8032,7 @@ nautilus_icon_container_sort (NautilusIconContainer *container)
 	container->details->auto_layout = TRUE;
 
 	reset_scroll_region_if_not_empty (container);
+	container->details->needs_resort = TRUE;
 	redo_layout (container);
 
 	if (changed) {
diff --git a/libnautilus-private/nautilus-icon-private.h b/libnautilus-private/nautilus-icon-private.h
index 8f94d6c..9b0a3d7 100644
--- a/libnautilus-private/nautilus-icon-private.h
+++ b/libnautilus-private/nautilus-icon-private.h
@@ -274,6 +274,7 @@ struct NautilusIconContainerDetails {
 	GQueue* a11y_item_action_queue;
 
 	eel_boolean_bit is_loading : 1;
+	eel_boolean_bit needs_resort : 1;
 
 	eel_boolean_bit store_layout_timestamps : 1;
 	eel_boolean_bit store_layout_timestamps_when_finishing_new_icons : 1;



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