Select largest 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. Bug 667365 - Free space should be selected by default
This commit is contained in:
parent
92f4947618
commit
5b53c12f6e
|
@ -842,9 +842,16 @@ void Win_GParted::Refresh_Visual()
|
||||||
if ( ! operations .size() )
|
if ( ! operations .size() )
|
||||||
allow_undo_clear_apply( false ) ;
|
allow_undo_clear_apply( false ) ;
|
||||||
|
|
||||||
//count primary's and check for extended
|
//Count primary partitions for check in max_amount_prim_reached(),
|
||||||
|
// check for an extended partition and select the largest unallocated
|
||||||
|
// partition if there is one.
|
||||||
index_extended = -1 ;
|
index_extended = -1 ;
|
||||||
primary_count = 0;
|
primary_count = 0;
|
||||||
|
|
||||||
|
selected_partition .Reset() ;
|
||||||
|
Sector largest_unalloc_size = -1 ;
|
||||||
|
Sector current_size ;
|
||||||
|
|
||||||
for ( unsigned int t = 0 ; t < partitions .size() ; t++ )
|
for ( unsigned int t = 0 ; t < partitions .size() ; t++ )
|
||||||
{
|
{
|
||||||
if ( partitions[ t ] .get_path() == copied_partition .get_path() )
|
if ( partitions[ t ] .get_path() == copied_partition .get_path() )
|
||||||
|
@ -852,13 +859,40 @@ void Win_GParted::Refresh_Visual()
|
||||||
|
|
||||||
switch ( partitions[ t ] .type )
|
switch ( partitions[ t ] .type )
|
||||||
{
|
{
|
||||||
case GParted::TYPE_PRIMARY :
|
case TYPE_PRIMARY:
|
||||||
primary_count++;
|
primary_count++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GParted::TYPE_EXTENDED :
|
case TYPE_EXTENDED:
|
||||||
index_extended = t ;
|
index_extended = t ;
|
||||||
primary_count++;
|
primary_count++;
|
||||||
|
|
||||||
|
for ( unsigned int u = 0 ; u < partitions[ t ] .logicals .size() ; u ++ )
|
||||||
|
{
|
||||||
|
switch ( partitions[ t ] .logicals[ u ] .type )
|
||||||
|
{
|
||||||
|
case TYPE_UNALLOCATED:
|
||||||
|
current_size = partitions[ t ]. logicals[ u ] .get_sector_length() ;
|
||||||
|
if ( current_size > largest_unalloc_size )
|
||||||
|
{
|
||||||
|
largest_unalloc_size = current_size ;
|
||||||
|
selected_partition = partitions[ t ] .logicals[ u ] ;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TYPE_UNALLOCATED:
|
||||||
|
current_size = partitions[ t ] .get_sector_length() ;
|
||||||
|
if ( current_size > largest_unalloc_size )
|
||||||
|
{
|
||||||
|
largest_unalloc_size = current_size ;
|
||||||
|
selected_partition = partitions[ t ] ;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default :
|
default :
|
||||||
|
@ -872,10 +906,15 @@ void Win_GParted::Refresh_Visual()
|
||||||
//treeview details
|
//treeview details
|
||||||
treeview_detail .load_partitions( partitions ) ;
|
treeview_detail .load_partitions( partitions ) ;
|
||||||
|
|
||||||
//no partition can be selected after a refresh..
|
|
||||||
selected_partition .Reset() ;
|
|
||||||
set_valid_operations() ;
|
set_valid_operations() ;
|
||||||
|
|
||||||
|
if ( largest_unalloc_size >= 0 )
|
||||||
|
{
|
||||||
|
//Inform visuals of selection of the largest unallocated partition
|
||||||
|
drawingarea_visualdisk .set_selected( selected_partition ) ;
|
||||||
|
treeview_detail .set_selected( selected_partition ) ;
|
||||||
|
}
|
||||||
|
|
||||||
while ( Gtk::Main::events_pending() )
|
while ( Gtk::Main::events_pending() )
|
||||||
Gtk::Main::iteration() ;
|
Gtk::Main::iteration() ;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue