Rename Dialog_Base_Partition member to new_partition
The member variable was named selected_partition. It is assigned from Win_GParted::selected_partition_ptr (which is a pointer to a const partition object so is never updated). This gives connotations that it won't be modified. However it is updated freely as the new resultant partition object is prepared before being returned from the dialog, most notable in the Get_New_Partition() methods. Therefore rename from selected_partition to new_partition.
This commit is contained in:
parent
8b96f8409f
commit
32a5ace156
|
@ -64,8 +64,8 @@ protected:
|
||||||
double MB_PER_PIXEL ;
|
double MB_PER_PIXEL ;
|
||||||
Sector TOTAL_MB ;
|
Sector TOTAL_MB ;
|
||||||
Frame_Resizer_Base *frame_resizer_base;
|
Frame_Resizer_Base *frame_resizer_base;
|
||||||
Partition selected_partition ;
|
Partition new_partition;
|
||||||
|
|
||||||
Sector START; //the first sector of the first relevant partition ( this is either current or current -1 ) needed in Get_Resized_Partition()
|
Sector START; //the first sector of the first relevant partition ( this is either current or current -1 ) needed in Get_Resized_Partition()
|
||||||
Sector total_length ; //total amount of sectors ( this can be up to 3 partitions...)
|
Sector total_length ; //total amount of sectors ( this can be up to 3 partitions...)
|
||||||
|
|
||||||
|
|
|
@ -139,94 +139,92 @@ void Dialog_Base_Partition::Set_Resizer( bool extended )
|
||||||
Partition Dialog_Base_Partition::Get_New_Partition( Byte_Value sector_size )
|
Partition Dialog_Base_Partition::Get_New_Partition( Byte_Value sector_size )
|
||||||
{
|
{
|
||||||
prepare_new_partition( sector_size );
|
prepare_new_partition( sector_size );
|
||||||
return selected_partition;
|
return new_partition;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dialog_Base_Partition::prepare_new_partition( Byte_Value sector_size )
|
void Dialog_Base_Partition::prepare_new_partition( Byte_Value sector_size )
|
||||||
{
|
{
|
||||||
//set sector size of new partition
|
//set sector size of new partition
|
||||||
selected_partition .sector_size = sector_size;
|
new_partition.sector_size = sector_size;
|
||||||
Sector old_size = selected_partition .get_sector_length() ;
|
Sector old_size = new_partition.get_sector_length();
|
||||||
|
|
||||||
//FIXME: Partition size is limited to just less than 1024 TeraBytes due
|
//FIXME: Partition size is limited to just less than 1024 TeraBytes due
|
||||||
// to the maximum value of signed 4 byte integer.
|
// to the maximum value of signed 4 byte integer.
|
||||||
if ( ORIG_BEFORE != spinbutton_before .get_value_as_int() )
|
if ( ORIG_BEFORE != spinbutton_before .get_value_as_int() )
|
||||||
selected_partition .sector_start = START + Sector(spinbutton_before .get_value_as_int()) * (MEBIBYTE / sector_size) ;
|
new_partition.sector_start = START + Sector(spinbutton_before.get_value_as_int()) * (MEBIBYTE / sector_size);
|
||||||
|
|
||||||
if ( ORIG_AFTER != spinbutton_after .get_value_as_int() )
|
if ( ORIG_AFTER != spinbutton_after .get_value_as_int() )
|
||||||
selected_partition .sector_end =
|
new_partition.sector_end =
|
||||||
selected_partition .sector_start
|
new_partition.sector_start
|
||||||
+ Sector(spinbutton_size .get_value_as_int()) * (MEBIBYTE / sector_size)
|
+ Sector(spinbutton_size .get_value_as_int()) * (MEBIBYTE / sector_size)
|
||||||
- 1 /* one sector short of exact mebibyte multiple */;
|
- 1 /* one sector short of exact mebibyte multiple */;
|
||||||
|
|
||||||
//due to loss of precision during calcs from Sector -> MiB and back, it is possible
|
//due to loss of precision during calcs from Sector -> MiB and back, it is possible
|
||||||
//the new partition thinks it's bigger then it can be. Here we solve this.
|
//the new partition thinks it's bigger then it can be. Here we solve this.
|
||||||
if ( selected_partition .sector_start < START )
|
if ( new_partition.sector_start < START )
|
||||||
selected_partition .sector_start = START ;
|
new_partition.sector_start = START;
|
||||||
if ( selected_partition .sector_end > (START + total_length -1) )
|
if ( new_partition.sector_end > ( START + total_length - 1 ) )
|
||||||
selected_partition .sector_end = START + total_length -1 ;
|
new_partition.sector_end = START + total_length - 1;
|
||||||
|
|
||||||
//grow a bit into small freespace ( < 1MiB )
|
//grow a bit into small freespace ( < 1MiB )
|
||||||
if ( (selected_partition .sector_start - START) < (MEBIBYTE / sector_size) )
|
if ( (new_partition.sector_start - START) < (MEBIBYTE / sector_size) )
|
||||||
selected_partition .sector_start = START ;
|
new_partition.sector_start = START;
|
||||||
if ( ( START + total_length -1 - selected_partition .sector_end ) < (MEBIBYTE / sector_size) )
|
if ( ( START + total_length -1 - new_partition.sector_end ) < (MEBIBYTE / sector_size) )
|
||||||
selected_partition .sector_end = START + total_length -1 ;
|
new_partition.sector_end = START + total_length - 1;
|
||||||
|
|
||||||
//set alignment
|
//set alignment
|
||||||
switch ( optionmenu_alignment .get_history() )
|
switch ( optionmenu_alignment .get_history() )
|
||||||
{
|
{
|
||||||
case 0 : selected_partition .alignment = ALIGN_CYLINDER; break;
|
case 0 : new_partition.alignment = ALIGN_CYLINDER; break;
|
||||||
case 1 : selected_partition .alignment = ALIGN_MEBIBYTE;
|
case 1 : new_partition.alignment = ALIGN_MEBIBYTE;
|
||||||
{
|
{
|
||||||
//if partition size is not an integer multiple of MiB
|
//if partition size is not an integer multiple of MiB
|
||||||
// or the start or end sectors are not MiB aligned,
|
// or the start or end sectors are not MiB aligned,
|
||||||
// and space is available,
|
// and space is available,
|
||||||
// then add 1 MiB to partition so requested size is kept
|
// then add 1 MiB to partition so requested size is kept
|
||||||
// after GParted_Core::snap_to_mebibyte method rounding
|
// after GParted_Core::snap_to_mebibyte method rounding
|
||||||
Sector partition_size = selected_partition .sector_end - selected_partition .sector_start + Sector(1) ;
|
Sector partition_size = new_partition.sector_end - new_partition.sector_start + Sector(1);
|
||||||
Sector sectors_in_mib = MEBIBYTE / selected_partition .sector_size ;
|
Sector sectors_in_mib = MEBIBYTE / new_partition.sector_size;
|
||||||
if ( ( ( ( partition_size % sectors_in_mib ) > 0 )
|
if ( ( ( ( partition_size % sectors_in_mib ) > 0 )
|
||||||
|| ( ( selected_partition .sector_start % sectors_in_mib ) > 0 )
|
|| ( ( new_partition.sector_start % sectors_in_mib ) > 0 )
|
||||||
|| ( ( ( selected_partition .sector_end + Sector(1) ) % sectors_in_mib ) > 0 )
|
|| ( ( ( new_partition.sector_end + Sector(1) ) % sectors_in_mib ) > 0 )
|
||||||
)
|
)
|
||||||
&& ( ( partition_size + sectors_in_mib ) < total_length )
|
&& ( ( partition_size + sectors_in_mib ) < total_length )
|
||||||
)
|
)
|
||||||
selected_partition .sector_end += sectors_in_mib ;
|
new_partition.sector_end += sectors_in_mib;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2 : selected_partition .alignment = ALIGN_STRICT; break;
|
case 2 : new_partition.alignment = ALIGN_STRICT; break;
|
||||||
|
|
||||||
default : selected_partition .alignment = ALIGN_MEBIBYTE ;
|
default : new_partition.alignment = ALIGN_MEBIBYTE; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//update partition usage
|
//update partition usage
|
||||||
if ( selected_partition .sectors_used != -1 && selected_partition .sectors_unused != -1 )
|
if ( new_partition.sectors_used != -1 && new_partition.sectors_unused != -1 )
|
||||||
{
|
{
|
||||||
Sector new_size = selected_partition .get_sector_length() ;
|
Sector new_size = new_partition.get_sector_length();
|
||||||
if ( old_size == new_size )
|
if ( old_size == new_size )
|
||||||
{
|
{
|
||||||
//Pasting into new same sized partition or moving partition keeping the same size,
|
//Pasting into new same sized partition or moving partition keeping the same size,
|
||||||
// therefore only block copy operation will be performed maintaining file system size.
|
// therefore only block copy operation will be performed maintaining file system size.
|
||||||
selected_partition .set_sector_usage(
|
new_partition.set_sector_usage(
|
||||||
selected_partition .sectors_used + selected_partition .sectors_unused,
|
new_partition.sectors_used + new_partition.sectors_unused,
|
||||||
selected_partition .sectors_unused ) ;
|
new_partition.sectors_unused );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Pasting into new larger partition or (moving and) resizing partition larger or smaller,
|
//Pasting into new larger partition or (moving and) resizing partition larger or smaller,
|
||||||
// therefore block copy followed by file system grow or shrink operations will be
|
// therefore block copy followed by file system grow or shrink operations will be
|
||||||
// performed making the file system fill the partition.
|
// performed making the file system fill the partition.
|
||||||
selected_partition .set_sector_usage(
|
new_partition.set_sector_usage( new_size, new_size - new_partition.sectors_used );
|
||||||
new_size,
|
|
||||||
new_size - selected_partition .sectors_used ) ;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
selected_partition .free_space_before = Sector(spinbutton_before .get_value_as_int()) * (MEBIBYTE / sector_size) ;
|
new_partition.free_space_before = Sector(spinbutton_before .get_value_as_int()) * (MEBIBYTE / sector_size);
|
||||||
|
|
||||||
//if the original before value has not changed, then set indicator to keep start sector unchanged
|
//if the original before value has not changed, then set indicator to keep start sector unchanged
|
||||||
if ( ORIG_BEFORE == spinbutton_before .get_value_as_int() )
|
if ( ORIG_BEFORE == spinbutton_before .get_value_as_int() )
|
||||||
selected_partition .strict_start = TRUE ;
|
new_partition.strict_start = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dialog_Base_Partition::Set_Confirm_Button( CONFIRMBUTTON button_type )
|
void Dialog_Base_Partition::Set_Confirm_Button( CONFIRMBUTTON button_type )
|
||||||
|
|
|
@ -98,13 +98,12 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons
|
||||||
) ;
|
) ;
|
||||||
|
|
||||||
// Set member variable used in Dialog_Base_Partition::prepare_new_partition()
|
// Set member variable used in Dialog_Base_Partition::prepare_new_partition()
|
||||||
this ->selected_partition = copied_partition ;
|
new_partition = copied_partition;
|
||||||
this ->selected_partition .device_path = selected_partition .device_path ;
|
new_partition.device_path = selected_partition.device_path;
|
||||||
this ->selected_partition .inside_extended = selected_partition .inside_extended ;
|
new_partition.inside_extended = selected_partition.inside_extended;
|
||||||
this ->selected_partition .type =
|
new_partition.type = selected_partition.inside_extended ? TYPE_LOGICAL : TYPE_PRIMARY;
|
||||||
selected_partition .inside_extended ? GParted::TYPE_LOGICAL : GParted::TYPE_PRIMARY ;
|
|
||||||
//Handle situation where src sector size is smaller than dst sector size and an additional partial dst sector is required.
|
//Handle situation where src sector size is smaller than dst sector size and an additional partial dst sector is required.
|
||||||
this ->selected_partition .set_sector_usage(
|
new_partition.set_sector_usage(
|
||||||
( ( ( copied_partition .sectors_used + copied_partition .sectors_unused ) * copied_partition .sector_size )
|
( ( ( copied_partition .sectors_used + copied_partition .sectors_unused ) * copied_partition .sector_size )
|
||||||
+ ( selected_partition .sector_size - 1 )
|
+ ( selected_partition .sector_size - 1 )
|
||||||
) / selected_partition .sector_size,
|
) / selected_partition .sector_size,
|
||||||
|
@ -121,9 +120,9 @@ Partition Dialog_Partition_Copy::Get_New_Partition( Byte_Value sector_size )
|
||||||
Dialog_Base_Partition::prepare_new_partition( sector_size );
|
Dialog_Base_Partition::prepare_new_partition( sector_size );
|
||||||
|
|
||||||
//set proper name and status for partition
|
//set proper name and status for partition
|
||||||
selected_partition .status = GParted::STAT_COPY ;
|
new_partition.status = STAT_COPY;
|
||||||
|
|
||||||
return selected_partition ;
|
return new_partition;
|
||||||
}
|
}
|
||||||
|
|
||||||
} //GParted
|
} //GParted
|
||||||
|
|
|
@ -39,7 +39,7 @@ void Dialog_Partition_New::Set_Data( const Device & device,
|
||||||
const std::vector<FS> & FILESYSTEMS )
|
const std::vector<FS> & FILESYSTEMS )
|
||||||
{
|
{
|
||||||
this ->new_count = new_count;
|
this ->new_count = new_count;
|
||||||
this ->selected_partition = partition;
|
new_partition = partition;
|
||||||
|
|
||||||
// Copy only supported file systems from GParted_Core FILESYSTEMS vector. Add
|
// Copy only supported file systems from GParted_Core FILESYSTEMS vector. Add
|
||||||
// FS_CLEARED, FS_UNFORMATTED and FS_EXTENDED at the end. This decides the order
|
// FS_CLEARED, FS_UNFORMATTED and FS_EXTENDED at the end. This decides the order
|
||||||
|
@ -144,10 +144,10 @@ void Dialog_Partition_New::Set_Data( const Device & device,
|
||||||
table_create.attach( filesystem_label_entry, 1, 2, 3, 4, Gtk::FILL );
|
table_create.attach( filesystem_label_entry, 1, 2, 3, 4, Gtk::FILL );
|
||||||
|
|
||||||
//set some widely used values...
|
//set some widely used values...
|
||||||
MIN_SPACE_BEFORE_MB = Dialog_Base_Partition::MB_Needed_for_Boot_Record( selected_partition ) ;
|
MIN_SPACE_BEFORE_MB = Dialog_Base_Partition::MB_Needed_for_Boot_Record( new_partition );
|
||||||
START = partition.sector_start ;
|
START = partition.sector_start ;
|
||||||
total_length = partition.sector_end - partition.sector_start ;
|
total_length = partition.sector_end - partition.sector_start ;
|
||||||
TOTAL_MB = Utils::round( Utils::sector_to_unit( this ->selected_partition .get_sector_length(), this ->selected_partition .sector_size, UNIT_MIB ) ) ;
|
TOTAL_MB = Utils::round( Utils::sector_to_unit( new_partition.get_sector_length(), new_partition.sector_size, UNIT_MIB ) );
|
||||||
MB_PER_PIXEL = TOTAL_MB / 500.00 ;
|
MB_PER_PIXEL = TOTAL_MB / 500.00 ;
|
||||||
|
|
||||||
//set first enabled file system
|
//set first enabled file system
|
||||||
|
@ -192,19 +192,19 @@ Partition Dialog_Partition_New::Get_New_Partition( Byte_Value sector_size )
|
||||||
|
|
||||||
/* due to loss of precision during calcs from Sector -> MiB and back, it is possible the new
|
/* due to loss of precision during calcs from Sector -> MiB and back, it is possible the new
|
||||||
* partition thinks it's bigger then it can be. Here we try to solve this.*/
|
* partition thinks it's bigger then it can be. Here we try to solve this.*/
|
||||||
if ( new_start < selected_partition.sector_start )
|
if ( new_start < new_partition.sector_start )
|
||||||
new_start = selected_partition.sector_start ;
|
new_start = new_partition.sector_start;
|
||||||
if ( new_end > selected_partition.sector_end )
|
if ( new_end > new_partition.sector_end )
|
||||||
new_end = selected_partition.sector_end ;
|
new_end = new_partition.sector_end;
|
||||||
|
|
||||||
part_temp .status = GParted::STAT_NEW ;
|
part_temp .status = GParted::STAT_NEW ;
|
||||||
part_temp.Set( selected_partition.device_path,
|
part_temp.Set( new_partition.device_path,
|
||||||
String::ucompose( _("New Partition #%1"), new_count ),
|
String::ucompose( _("New Partition #%1"), new_count ),
|
||||||
new_count, part_type, selected_partition.whole_device,
|
new_count, part_type, new_partition.whole_device,
|
||||||
FILESYSTEMS[optionmenu_filesystem.get_history()].filesystem,
|
FILESYSTEMS[optionmenu_filesystem.get_history()].filesystem,
|
||||||
new_start, new_end,
|
new_start, new_end,
|
||||||
sector_size,
|
sector_size,
|
||||||
selected_partition.inside_extended, false );
|
new_partition.inside_extended, false );
|
||||||
|
|
||||||
// Retrieve partition name
|
// Retrieve partition name
|
||||||
part_temp.name = Utils::trim( partition_name_entry.get_text() );
|
part_temp.name = Utils::trim( partition_name_entry.get_text() );
|
||||||
|
@ -213,10 +213,10 @@ Partition Dialog_Partition_New::Get_New_Partition( Byte_Value sector_size )
|
||||||
part_temp.set_filesystem_label( Utils::trim( filesystem_label_entry.get_text() ) );
|
part_temp.set_filesystem_label( Utils::trim( filesystem_label_entry.get_text() ) );
|
||||||
|
|
||||||
//grow new partition a bit if freespaces are < 1 MiB
|
//grow new partition a bit if freespaces are < 1 MiB
|
||||||
if ( (part_temp.sector_start - selected_partition.sector_start) < (MEBIBYTE / sector_size) )
|
if ( (part_temp.sector_start - new_partition.sector_start) < (MEBIBYTE / sector_size) )
|
||||||
part_temp.sector_start = selected_partition.sector_start ;
|
part_temp.sector_start = new_partition.sector_start;
|
||||||
if ( (selected_partition.sector_end - part_temp.sector_end) < (MEBIBYTE / sector_size) )
|
if ( (new_partition.sector_end - part_temp.sector_end) < (MEBIBYTE / sector_size) )
|
||||||
part_temp.sector_end = selected_partition.sector_end ;
|
part_temp.sector_end = new_partition.sector_end;
|
||||||
|
|
||||||
//if new is extended...
|
//if new is extended...
|
||||||
if ( part_temp .type == GParted::TYPE_EXTENDED )
|
if ( part_temp .type == GParted::TYPE_EXTENDED )
|
||||||
|
@ -286,8 +286,8 @@ void Dialog_Partition_New::optionmenu_changed( bool type )
|
||||||
if ( fs .MIN < MEBIBYTE )
|
if ( fs .MIN < MEBIBYTE )
|
||||||
fs .MIN = MEBIBYTE ;
|
fs .MIN = MEBIBYTE ;
|
||||||
|
|
||||||
if ( selected_partition .get_byte_length() < fs .MIN )
|
if ( new_partition.get_byte_length() < fs.MIN )
|
||||||
fs .MIN = selected_partition .get_byte_length() ;
|
fs .MIN = new_partition.get_byte_length();
|
||||||
|
|
||||||
if ( ! fs .MAX || ( fs .MAX > ((TOTAL_MB - MIN_SPACE_BEFORE_MB) * MEBIBYTE) ) )
|
if ( ! fs .MAX || ( fs .MAX > ((TOTAL_MB - MIN_SPACE_BEFORE_MB) * MEBIBYTE) ) )
|
||||||
fs .MAX = ((TOTAL_MB - MIN_SPACE_BEFORE_MB) * MEBIBYTE) ;
|
fs .MAX = ((TOTAL_MB - MIN_SPACE_BEFORE_MB) * MEBIBYTE) ;
|
||||||
|
@ -345,7 +345,7 @@ void Dialog_Partition_New::Build_Filesystems_Menu( bool only_unformatted )
|
||||||
Gtk::Menu_Helpers::MenuElem( Utils::get_filesystem_string( FILESYSTEMS[ t ] .filesystem ) ) ) ;
|
Gtk::Menu_Helpers::MenuElem( Utils::get_filesystem_string( FILESYSTEMS[ t ] .filesystem ) ) ) ;
|
||||||
menu_filesystem .items() .back() .set_sensitive(
|
menu_filesystem .items() .back() .set_sensitive(
|
||||||
! only_unformatted && FILESYSTEMS[ t ] .create &&
|
! only_unformatted && FILESYSTEMS[ t ] .create &&
|
||||||
this ->selected_partition .get_byte_length() >= FILESYSTEMS[ t ] .MIN ) ;
|
new_partition.get_byte_length() >= FILESYSTEMS[t].MIN );
|
||||||
//use ext4/3/2 as first/second/third choice default file system
|
//use ext4/3/2 as first/second/third choice default file system
|
||||||
//(Depends on ordering in FILESYSTEMS for preference)
|
//(Depends on ordering in FILESYSTEMS for preference)
|
||||||
if ( ( FILESYSTEMS[ t ] .filesystem == FS_EXT2 ||
|
if ( ( FILESYSTEMS[ t ] .filesystem == FS_EXT2 ||
|
||||||
|
|
|
@ -30,9 +30,9 @@ void Dialog_Partition_Resize_Move::Set_Data( const Partition & selected_partitio
|
||||||
const std::vector<Partition> & partitions )
|
const std::vector<Partition> & partitions )
|
||||||
{
|
{
|
||||||
GRIP = true ; //prevents on spinbutton_changed from getting activated prematurely
|
GRIP = true ; //prevents on spinbutton_changed from getting activated prematurely
|
||||||
|
|
||||||
this ->selected_partition = selected_partition ;
|
new_partition = selected_partition;
|
||||||
|
|
||||||
if ( selected_partition .type == GParted::TYPE_EXTENDED )
|
if ( selected_partition .type == GParted::TYPE_EXTENDED )
|
||||||
{
|
{
|
||||||
Set_Resizer( true ) ;
|
Set_Resizer( true ) ;
|
||||||
|
@ -61,28 +61,28 @@ void Dialog_Partition_Resize_Move::Set_Data( const Partition & selected_partitio
|
||||||
void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector<Partition> & partitions )
|
void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector<Partition> & partitions )
|
||||||
{
|
{
|
||||||
//little bit of paranoia ;)
|
//little bit of paranoia ;)
|
||||||
if ( ! selected_partition .sector_usage_known() &&
|
if ( ! new_partition.sector_usage_known() &&
|
||||||
selected_partition .status != STAT_NEW &&
|
new_partition.status != STAT_NEW &&
|
||||||
selected_partition .filesystem != FS_LINUX_SWAP )
|
new_partition.filesystem != FS_LINUX_SWAP )
|
||||||
fs .shrink = GParted::FS::NONE ;
|
fs .shrink = GParted::FS::NONE ;
|
||||||
|
|
||||||
//Disable resizing as it's currently disallowed for the file system in this partition.
|
//Disable resizing as it's currently disallowed for the file system in this partition.
|
||||||
// (Updates this class's copy of file system support information).
|
// (Updates this class's copy of file system support information).
|
||||||
if ( GParted_Core::filesystem_resize_disallowed( selected_partition ) )
|
if ( GParted_Core::filesystem_resize_disallowed( new_partition ) )
|
||||||
{
|
{
|
||||||
fs .shrink = FS::NONE ;
|
fs .shrink = FS::NONE ;
|
||||||
fs .grow = FS::NONE ;
|
fs .grow = FS::NONE ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// See if we can allow the start of the file system to move
|
// See if we can allow the start of the file system to move
|
||||||
if ( fs.move && ! selected_partition.busy && ! selected_partition.whole_device )
|
if ( fs.move && ! new_partition.busy && ! new_partition.whole_device )
|
||||||
{
|
{
|
||||||
set_title( String::ucompose( _("Resize/Move %1"), selected_partition .get_path() ) ) ;
|
set_title( String::ucompose( _("Resize/Move %1"), new_partition.get_path() ) );
|
||||||
frame_resizer_base ->set_fixed_start( false ) ;
|
frame_resizer_base ->set_fixed_start( false ) ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
set_title( String::ucompose( _("Resize %1"), selected_partition .get_path() ) ) ;
|
set_title( String::ucompose( _("Resize %1"), new_partition.get_path() ) );
|
||||||
this ->fixed_start = true;
|
this ->fixed_start = true;
|
||||||
frame_resizer_base ->set_fixed_start( true ) ;
|
frame_resizer_base ->set_fixed_start( true ) ;
|
||||||
spinbutton_before .set_sensitive( false ) ;
|
spinbutton_before .set_sensitive( false ) ;
|
||||||
|
@ -92,7 +92,7 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector<Partiti
|
||||||
//first find index of partition
|
//first find index of partition
|
||||||
unsigned int t;
|
unsigned int t;
|
||||||
for ( t = 0 ; t < partitions .size() ; t++ )
|
for ( t = 0 ; t < partitions .size() ; t++ )
|
||||||
if ( partitions[ t ] == selected_partition )
|
if ( partitions[t] == new_partition )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
Sector previous, next ;
|
Sector previous, next ;
|
||||||
|
@ -104,7 +104,7 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector<Partiti
|
||||||
START = partitions[t -1] .sector_start ;
|
START = partitions[t -1] .sector_start ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
START = selected_partition .sector_start ;
|
START = new_partition.sector_start;
|
||||||
|
|
||||||
if ( t +1 < partitions .size() && partitions[t +1] .type == GParted::TYPE_UNALLOCATED )
|
if ( t +1 < partitions .size() && partitions[t +1] .type == GParted::TYPE_UNALLOCATED )
|
||||||
{
|
{
|
||||||
|
@ -113,8 +113,8 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector<Partiti
|
||||||
//If this is a logical partition and there is extra free space
|
//If this is a logical partition and there is extra free space
|
||||||
// then check if we need to reserve 1 MiB of space after for
|
// then check if we need to reserve 1 MiB of space after for
|
||||||
// the next logical partition Extended Boot Record.
|
// the next logical partition Extended Boot Record.
|
||||||
if ( selected_partition .type == TYPE_LOGICAL
|
if ( new_partition.type == TYPE_LOGICAL
|
||||||
&& next >= (MEBIBYTE / selected_partition .sector_size)
|
&& next >= (MEBIBYTE / new_partition.sector_size)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//Find maximum sector_end (allocated or unallocated) within list of
|
//Find maximum sector_end (allocated or unallocated) within list of
|
||||||
|
@ -127,8 +127,8 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector<Partiti
|
||||||
}
|
}
|
||||||
|
|
||||||
//If not within 1 MiB of the end of the extended partition, then reserve 1 MiB
|
//If not within 1 MiB of the end of the extended partition, then reserve 1 MiB
|
||||||
if ( ( max_sector_end - partitions[t+1] .sector_end ) > ( MEBIBYTE / selected_partition .sector_size ) )
|
if ( ( max_sector_end - partitions[t+1].sector_end ) > ( MEBIBYTE / new_partition.sector_size ) )
|
||||||
next -= MEBIBYTE / selected_partition .sector_size ;
|
next -= MEBIBYTE / new_partition.sector_size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,13 +139,13 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector<Partiti
|
||||||
MIN_SPACE_BEFORE_MB = 0 ;
|
MIN_SPACE_BEFORE_MB = 0 ;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( START <= (MEBIBYTE / selected_partition .sector_size) )
|
if ( START <= (MEBIBYTE / new_partition.sector_size) )
|
||||||
MIN_SPACE_BEFORE_MB = 1 ;
|
MIN_SPACE_BEFORE_MB = 1 ;
|
||||||
else
|
else
|
||||||
MIN_SPACE_BEFORE_MB = Dialog_Base_Partition::MB_Needed_for_Boot_Record( selected_partition ) ;
|
MIN_SPACE_BEFORE_MB = Dialog_Base_Partition::MB_Needed_for_Boot_Record( new_partition );
|
||||||
}
|
}
|
||||||
total_length = previous + selected_partition .get_sector_length() + next;
|
total_length = previous + new_partition.get_sector_length() + next;
|
||||||
TOTAL_MB = Utils::round( Utils::sector_to_unit( total_length, selected_partition .sector_size, UNIT_MIB ) ) ;
|
TOTAL_MB = Utils::round( Utils::sector_to_unit( total_length, new_partition.sector_size, UNIT_MIB ) );
|
||||||
|
|
||||||
MB_PER_PIXEL = TOTAL_MB / 500.00 ;
|
MB_PER_PIXEL = TOTAL_MB / 500.00 ;
|
||||||
|
|
||||||
|
@ -153,31 +153,31 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector<Partiti
|
||||||
frame_resizer_base ->set_x_min_space_before( Utils::round( MIN_SPACE_BEFORE_MB / MB_PER_PIXEL ) ) ;
|
frame_resizer_base ->set_x_min_space_before( Utils::round( MIN_SPACE_BEFORE_MB / MB_PER_PIXEL ) ) ;
|
||||||
frame_resizer_base ->set_x_start( Utils::round( previous / ( total_length / 500.00 ) ) ) ;
|
frame_resizer_base ->set_x_start( Utils::round( previous / ( total_length / 500.00 ) ) ) ;
|
||||||
frame_resizer_base ->set_x_end(
|
frame_resizer_base ->set_x_end(
|
||||||
Utils::round( selected_partition .get_sector_length() / ( total_length / 500.00 ) ) + frame_resizer_base ->get_x_start() ) ;
|
Utils::round( new_partition.get_sector_length() / ( total_length / 500.00 ) ) + frame_resizer_base->get_x_start() );
|
||||||
Sector min_resize = selected_partition .estimated_min_size() ;
|
Sector min_resize = new_partition.estimated_min_size();
|
||||||
frame_resizer_base ->set_used( Utils::round( min_resize / ( total_length / 500.00 ) ) ) ;
|
frame_resizer_base ->set_used( Utils::round( min_resize / ( total_length / 500.00 ) ) ) ;
|
||||||
|
|
||||||
//set MIN
|
//set MIN
|
||||||
if ( ( fs .shrink && ! selected_partition .busy )
|
if ( ( fs.shrink && ! new_partition.busy )
|
||||||
|| ( fs .online_shrink && selected_partition .busy )
|
|| ( fs.online_shrink && new_partition.busy )
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//since some file systems have lower limits we need to check for this
|
//since some file systems have lower limits we need to check for this
|
||||||
if ( min_resize > (fs .MIN / selected_partition .sector_size) )
|
if ( min_resize > (fs.MIN / new_partition.sector_size) )
|
||||||
fs .MIN = min_resize * selected_partition .sector_size ;
|
fs.MIN = min_resize * new_partition.sector_size;
|
||||||
|
|
||||||
//ensure that minimum size is at least one mebibyte
|
//ensure that minimum size is at least one mebibyte
|
||||||
if ( ! fs .MIN || fs .MIN < MEBIBYTE )
|
if ( ! fs .MIN || fs .MIN < MEBIBYTE )
|
||||||
fs .MIN = MEBIBYTE ;
|
fs .MIN = MEBIBYTE ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fs .MIN = selected_partition .get_byte_length() ;
|
fs.MIN = new_partition.get_byte_length();
|
||||||
|
|
||||||
//set MAX
|
//set MAX
|
||||||
if ( fs .grow )
|
if ( fs .grow )
|
||||||
fs .MAX = (TOTAL_MB - MIN_SPACE_BEFORE_MB) * MEBIBYTE ;
|
fs .MAX = (TOTAL_MB - MIN_SPACE_BEFORE_MB) * MEBIBYTE ;
|
||||||
else
|
else
|
||||||
fs .MAX = selected_partition .get_byte_length() ;
|
fs.MAX = new_partition.get_byte_length();
|
||||||
|
|
||||||
//set values of spinbutton_before
|
//set values of spinbutton_before
|
||||||
if ( ! fixed_start )
|
if ( ! fixed_start )
|
||||||
|
@ -186,7 +186,7 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector<Partiti
|
||||||
, TOTAL_MB - ceil( fs .MIN / double(MEBIBYTE) )
|
, TOTAL_MB - ceil( fs .MIN / double(MEBIBYTE) )
|
||||||
) ;
|
) ;
|
||||||
spinbutton_before .set_value(
|
spinbutton_before .set_value(
|
||||||
Utils::round( Utils::sector_to_unit( previous, selected_partition .sector_size, UNIT_MIB ) ) ) ;
|
Utils::round( Utils::sector_to_unit( previous, new_partition.sector_size, UNIT_MIB ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
//set values of spinbutton_size
|
//set values of spinbutton_size
|
||||||
|
@ -194,15 +194,15 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector<Partiti
|
||||||
, ceil( fs .MAX / double(MEBIBYTE) )
|
, ceil( fs .MAX / double(MEBIBYTE) )
|
||||||
) ;
|
) ;
|
||||||
spinbutton_size .set_value(
|
spinbutton_size .set_value(
|
||||||
Utils::round( Utils::sector_to_unit( selected_partition .get_sector_length(), selected_partition .sector_size, UNIT_MIB ) ) ) ;
|
Utils::round( Utils::sector_to_unit( new_partition.get_sector_length(), new_partition.sector_size, UNIT_MIB ) ) );
|
||||||
|
|
||||||
//set values of spinbutton_after
|
//set values of spinbutton_after
|
||||||
Sector after_min = ( ! fs .grow && ! fs .move ) ? next : 0 ;
|
Sector after_min = ( ! fs .grow && ! fs .move ) ? next : 0 ;
|
||||||
spinbutton_after .set_range(
|
spinbutton_after .set_range(
|
||||||
Utils::round( Utils::sector_to_unit( after_min, selected_partition .sector_size, UNIT_MIB ) ),
|
Utils::round( Utils::sector_to_unit( after_min, new_partition.sector_size, UNIT_MIB ) ),
|
||||||
TOTAL_MB - MIN_SPACE_BEFORE_MB - ceil( fs .MIN / double(MEBIBYTE) ) ) ;
|
TOTAL_MB - MIN_SPACE_BEFORE_MB - ceil( fs .MIN / double(MEBIBYTE) ) ) ;
|
||||||
spinbutton_after .set_value(
|
spinbutton_after .set_value(
|
||||||
Utils::round( Utils::sector_to_unit( next, selected_partition .sector_size, UNIT_MIB ) ) ) ;
|
Utils::round( Utils::sector_to_unit( next, new_partition.sector_size, UNIT_MIB ) ) );
|
||||||
|
|
||||||
frame_resizer_base ->set_size_limits( Utils::round( fs .MIN / (MB_PER_PIXEL * MEBIBYTE) ),
|
frame_resizer_base ->set_size_limits( Utils::round( fs .MIN / (MB_PER_PIXEL * MEBIBYTE) ),
|
||||||
Utils::round( fs .MAX / (MB_PER_PIXEL * MEBIBYTE) ) ) ;
|
Utils::round( fs .MAX / (MB_PER_PIXEL * MEBIBYTE) ) ) ;
|
||||||
|
@ -229,7 +229,7 @@ void Dialog_Partition_Resize_Move::Resize_Move_Extended( const std::vector<Parti
|
||||||
START = partitions[t -1] .sector_start ;
|
START = partitions[t -1] .sector_start ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
START = selected_partition .sector_start ;
|
START = new_partition.sector_start;
|
||||||
|
|
||||||
//calculate length of next
|
//calculate length of next
|
||||||
if ( t +1 < partitions .size() && partitions[ t +1 ] .type == GParted::TYPE_UNALLOCATED )
|
if ( t +1 < partitions .size() && partitions[ t +1 ] .type == GParted::TYPE_UNALLOCATED )
|
||||||
|
@ -242,32 +242,32 @@ void Dialog_Partition_Resize_Move::Resize_Move_Extended( const std::vector<Parti
|
||||||
if ( previous <= 0 )
|
if ( previous <= 0 )
|
||||||
MIN_SPACE_BEFORE_MB = 0 ;
|
MIN_SPACE_BEFORE_MB = 0 ;
|
||||||
else
|
else
|
||||||
MIN_SPACE_BEFORE_MB = Dialog_Base_Partition::MB_Needed_for_Boot_Record( selected_partition ) ;
|
MIN_SPACE_BEFORE_MB = Dialog_Base_Partition::MB_Needed_for_Boot_Record( new_partition );
|
||||||
total_length = previous + selected_partition .get_sector_length() + next;
|
total_length = previous + new_partition.get_sector_length() + next;
|
||||||
TOTAL_MB = Utils::round( Utils::sector_to_unit( total_length, selected_partition .sector_size, UNIT_MIB ) ) ;
|
TOTAL_MB = Utils::round( Utils::sector_to_unit( total_length, new_partition.sector_size, UNIT_MIB ) );
|
||||||
MB_PER_PIXEL = TOTAL_MB / 500.00 ;
|
MB_PER_PIXEL = TOTAL_MB / 500.00 ;
|
||||||
|
|
||||||
//calculate proportional length of partition ( in pixels )
|
//calculate proportional length of partition ( in pixels )
|
||||||
frame_resizer_base ->set_x_min_space_before( Utils::round( MIN_SPACE_BEFORE_MB / MB_PER_PIXEL ) ) ;
|
frame_resizer_base ->set_x_min_space_before( Utils::round( MIN_SPACE_BEFORE_MB / MB_PER_PIXEL ) ) ;
|
||||||
frame_resizer_base ->set_x_start( Utils::round( previous / ( total_length / 500.00 ) ) ) ;
|
frame_resizer_base ->set_x_start( Utils::round( previous / ( total_length / 500.00 ) ) ) ;
|
||||||
frame_resizer_base ->set_x_end( Utils::round( selected_partition .get_sector_length() / ( total_length / 500.00 ) ) + frame_resizer_base ->get_x_start() ) ;
|
frame_resizer_base ->set_x_end( Utils::round( new_partition.get_sector_length() / ( total_length / 500.00 ) ) + frame_resizer_base ->get_x_start() );
|
||||||
|
|
||||||
//used is a bit different here... we consider start of first logical to end last logical as used space
|
//used is a bit different here... we consider start of first logical to end last logical as used space
|
||||||
Sector first =0, last = 0, used =0 ;
|
Sector first =0, last = 0, used =0 ;
|
||||||
if ( ! ( selected_partition .logicals .size() == 1
|
if ( ! ( new_partition.logicals.size() == 1
|
||||||
&& selected_partition .logicals .back() .type == GParted::TYPE_UNALLOCATED
|
&& new_partition.logicals.back().type == TYPE_UNALLOCATED
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//logical partitions other than unallocated exist
|
//logical partitions other than unallocated exist
|
||||||
first = selected_partition .sector_end ;
|
first = new_partition.sector_end;
|
||||||
last = selected_partition .sector_start ;
|
last = new_partition.sector_start;
|
||||||
for ( unsigned int i = 0 ; i < partitions[ t ] .logicals .size() ; i++ )
|
for ( unsigned int i = 0 ; i < partitions[ t ] .logicals .size() ; i++ )
|
||||||
{
|
{
|
||||||
if ( partitions[ t ] .logicals[ i ] .type == GParted::TYPE_LOGICAL )
|
if ( partitions[ t ] .logicals[ i ] .type == GParted::TYPE_LOGICAL )
|
||||||
{
|
{
|
||||||
if ( partitions[ t ] .logicals[ i ] .sector_start < first )
|
if ( partitions[ t ] .logicals[ i ] .sector_start < first )
|
||||||
first = partitions[ t ] .logicals[ i ] .sector_start - (MEBIBYTE / selected_partition .sector_size) ;
|
first = partitions[ t ] .logicals[ i ] .sector_start - (MEBIBYTE / new_partition.sector_size);
|
||||||
if ( first < 0 )
|
if ( first < 0 )
|
||||||
first = 0 ;
|
first = 0 ;
|
||||||
if ( partitions[ t ] .logicals[ i ] .sector_end > last )
|
if ( partitions[ t ] .logicals[ i ] .sector_end > last )
|
||||||
|
@ -283,7 +283,7 @@ void Dialog_Partition_Resize_Move::Resize_Move_Extended( const std::vector<Parti
|
||||||
fs .MIN = MEBIBYTE ;
|
fs .MIN = MEBIBYTE ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fs .MIN = used * selected_partition .sector_size ;
|
fs.MIN = used * new_partition.sector_size;
|
||||||
|
|
||||||
//set MAX
|
//set MAX
|
||||||
fs .MAX = (TOTAL_MB - MIN_SPACE_BEFORE_MB) * MEBIBYTE ;
|
fs .MAX = (TOTAL_MB - MIN_SPACE_BEFORE_MB) * MEBIBYTE ;
|
||||||
|
@ -296,15 +296,15 @@ void Dialog_Partition_Resize_Move::Resize_Move_Extended( const std::vector<Parti
|
||||||
if ( first == 0 ) //no logicals
|
if ( first == 0 ) //no logicals
|
||||||
spinbutton_before .set_range( MIN_SPACE_BEFORE_MB, TOTAL_MB - MIN_SPACE_BEFORE_MB - ceil( fs .MIN / double(MEBIBYTE) ) ) ;
|
spinbutton_before .set_range( MIN_SPACE_BEFORE_MB, TOTAL_MB - MIN_SPACE_BEFORE_MB - ceil( fs .MIN / double(MEBIBYTE) ) ) ;
|
||||||
else
|
else
|
||||||
spinbutton_before .set_range( MIN_SPACE_BEFORE_MB, Utils::round( Utils::sector_to_unit( first - START, selected_partition .sector_size, UNIT_MIB ) ) ) ;
|
spinbutton_before .set_range( MIN_SPACE_BEFORE_MB, Utils::round( Utils::sector_to_unit( first - START, new_partition.sector_size, UNIT_MIB ) ) );
|
||||||
|
|
||||||
spinbutton_before .set_value( Utils::round( Utils::sector_to_unit( previous, selected_partition .sector_size, UNIT_MIB ) ) ) ;
|
spinbutton_before .set_value( Utils::round( Utils::sector_to_unit( previous, new_partition.sector_size, UNIT_MIB ) ) );
|
||||||
|
|
||||||
//set values of spinbutton_size
|
//set values of spinbutton_size
|
||||||
spinbutton_size .set_range( ceil( fs .MIN / double(MEBIBYTE) ), TOTAL_MB - MIN_SPACE_BEFORE_MB ) ;
|
spinbutton_size .set_range( ceil( fs .MIN / double(MEBIBYTE) ), TOTAL_MB - MIN_SPACE_BEFORE_MB ) ;
|
||||||
|
|
||||||
spinbutton_size .set_value(
|
spinbutton_size .set_value(
|
||||||
Utils::round( Utils::sector_to_unit( selected_partition .get_sector_length(), selected_partition .sector_size, UNIT_MIB ) ) ) ;
|
Utils::round( Utils::sector_to_unit( new_partition.get_sector_length(), new_partition.sector_size, UNIT_MIB ) ) );
|
||||||
|
|
||||||
//set values of spinbutton_after
|
//set values of spinbutton_after
|
||||||
if ( first == 0 ) //no logicals
|
if ( first == 0 ) //no logicals
|
||||||
|
@ -312,13 +312,13 @@ void Dialog_Partition_Resize_Move::Resize_Move_Extended( const std::vector<Parti
|
||||||
0, TOTAL_MB - ceil( fs .MIN / double(MEBIBYTE) ) - MIN_SPACE_BEFORE_MB ) ;
|
0, TOTAL_MB - ceil( fs .MIN / double(MEBIBYTE) ) - MIN_SPACE_BEFORE_MB ) ;
|
||||||
else
|
else
|
||||||
spinbutton_after .set_range(
|
spinbutton_after .set_range(
|
||||||
0, Utils::round( Utils::sector_to_unit( total_length + START - first - used, selected_partition .sector_size, UNIT_MIB ) ) ) ;
|
0, Utils::round( Utils::sector_to_unit( total_length + START - first - used, new_partition.sector_size, UNIT_MIB ) ) );
|
||||||
|
|
||||||
spinbutton_after .set_value( Utils::round( Utils::sector_to_unit( next, selected_partition .sector_size, UNIT_MIB ) ) ) ;
|
spinbutton_after .set_value( Utils::round( Utils::sector_to_unit( next, new_partition.sector_size, UNIT_MIB ) ) );
|
||||||
|
|
||||||
//set contents of label_minmax
|
//set contents of label_minmax
|
||||||
Set_MinMax_Text( ceil( fs .MIN / double(MEBIBYTE) )
|
Set_MinMax_Text( ceil( fs .MIN / double(MEBIBYTE) )
|
||||||
, Utils::round( Utils::sector_to_unit( total_length - (MIN_SPACE_BEFORE_MB * (MEBIBYTE / selected_partition .sector_size)), selected_partition .sector_size, UNIT_MIB ) ) ) ;
|
, Utils::round( Utils::sector_to_unit( total_length - (MIN_SPACE_BEFORE_MB * (MEBIBYTE / new_partition.sector_size)), new_partition.sector_size, UNIT_MIB ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
} //GParted
|
} //GParted
|
||||||
|
|
Loading…
Reference in New Issue