[gparted/psusi/refactor: 10/19] Select unallocated partition by default (#667365)



commit eb4036c9087b825f57eadfa7530173eb7e9bada9
Author: Phillip Susi <psusi ubuntu com>
Date:   Sun Jan 20 22:54:02 2013 -0500

    Select unallocated partition by default (#667365)
    
    After a refresh, instead of having no partition selected, default to the
    largest unallocated partition.  This allows immediate creation of a new
    partition in the unallocated space.
    
    Closes Bug 667365 - Free space should be selected by default

 src/Win_GParted.cc |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc
index 79a07db..e318531 100644
--- a/src/Win_GParted.cc
+++ b/src/Win_GParted.cc
@@ -820,6 +820,7 @@ bool Win_GParted::Merge_Operations( unsigned int first, unsigned int second )
 void Win_GParted::Refresh_Visual()
 {
 	std::vector<Partition> partitions = devices[ current_device ] .partitions ; 
+	int largest_unallocated = -1;
 	
 	//make all operations visible
 	for ( unsigned int t = 0 ; t < operations .size(); t++ )
@@ -859,7 +860,12 @@ void Win_GParted::Refresh_Visual()
 				index_extended = t ;
 				primary_count++;
 				break;
-				
+			case GParted::TYPE_UNALLOCATED  :
+				if (largest_unallocated == -1)
+					largest_unallocated = t;
+				else if( (partitions[t].sector_end - partitions[t].sector_start) >
+					 (partitions[largest_unallocated].sector_end - partitions[largest_unallocated].sector_start))
+					largest_unallocated = t;
 			default				:
 				break;
 		}
@@ -873,6 +879,12 @@ void Win_GParted::Refresh_Visual()
 	
 	//no partition can be selected after a refresh..
 	selected_partition .Reset() ;
+	if( largest_unallocated != -1 )
+	{
+		selected_partition = partitions[largest_unallocated];
+		treeview_detail.set_selected( selected_partition );
+		drawingarea_visualdisk.set_selected( selected_partition );
+	}
 	set_valid_operations() ; 
 			
 	while ( Gtk::Main::events_pending() ) 


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