fixed some bugs with minimum size of resizable partition + some

* include/Dialog_Partition_Resize_Move.h,
  src/Dialog_Partition_Resize_Move.cc: fixed some bugs with minimum size of resizable partition + some codecleanups.
This commit is contained in:
Bart Hakvoort 2004-10-21 11:13:37 +00:00
parent 641c4504bf
commit 32cd2f2548
3 changed files with 54 additions and 40 deletions

View File

@ -1,3 +1,8 @@
2004-10-21 Bart Hakvoort <gparted@users.sf.net>
* include/Dialog_Partition_Resize_Move.h,
src/Dialog_Partition_Resize_Move.cc: fixed some bugs with minimum size of resizable partition + some codecleanups.
2004-10-20 Bart Hakvoort <gparted@users.sf.net>
* src/Dialog_Base_Partition.cc (Get_New_Partition): Tweaked resizingbehaviour a bit. This solved some minor annoyances.

View File

@ -33,6 +33,8 @@ private:
void Resize_Move_Normal( const std::vector <Partition> & partitions ) ;
void Resize_Move_Extended( const std::vector <Partition> & partitions ) ;
short BUF ; //added to the min. size a filesystem can be..( safety reasons )
};
} //GParted

View File

@ -22,6 +22,7 @@ namespace GParted
Dialog_Partition_Resize_Move::Dialog_Partition_Resize_Move( )
{
BUF = 5 ;
}
void Dialog_Partition_Resize_Move::Set_Data( const Partition & selected_partition, const std::vector <Partition> & partitions )
@ -45,18 +46,18 @@ void Dialog_Partition_Resize_Move::Set_Data( const Partition & selected_partitio
frame_resizer_base ->set_rgb_partition_color( selected_partition .color ) ;
//set some initial values... ( i believe i only use these for fat16 checks.. *sigh* )
this ->x_start = frame_resizer_base ->get_x_start() ;
this ->x_end = frame_resizer_base ->get_x_end() ;
this ->x_start = frame_resizer_base ->get_x_start( ) ;
this ->x_end = frame_resizer_base ->get_x_end( ) ;
//store the original values
ORIG_BEFORE = spinbutton_before .get_value_as_int() ;
ORIG_SIZE = spinbutton_size .get_value_as_int() ;
ORIG_AFTER = spinbutton_after .get_value_as_int() ;
ORIG_BEFORE = spinbutton_before .get_value_as_int( ) ;
ORIG_SIZE = spinbutton_size .get_value_as_int( ) ;
ORIG_AFTER = spinbutton_after .get_value_as_int( ) ;
GRIP = false ;
Set_Confirm_Button( RESIZE_MOVE ) ;
this ->show_all_children() ;
this ->show_all_children( ) ;
}
void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector <Partition> & partitions )
@ -88,13 +89,13 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector <Partit
//also check the partitions filesystem ( if this is ext2/3 or reiserfs then previous should be 0 )
if ( t >= 1 && partitions[t -1].type == GParted::UNALLOCATED && selected_partition.filesystem != "ext2" && selected_partition.filesystem != "ext3" && selected_partition.filesystem != "reiserfs" && partitions[t -1] .inside_extended == selected_partition.inside_extended )
{
previous = partitions[t -1].sector_end - partitions[t -1].sector_start ;
START = partitions[t -1].sector_start ;
previous = partitions[t -1] .sector_end - partitions[t -1] .sector_start ;
START = partitions[t -1] .sector_start ;
}
else
START = selected_partition.sector_start ;
START = selected_partition .sector_start ;
if ( t +1 < partitions.size() && partitions[t +1].type == GParted::UNALLOCATED && partitions[t +1] .inside_extended == selected_partition.inside_extended )
if ( t +1 < partitions .size() && partitions[t +1] .type == GParted::UNALLOCATED && partitions[t +1] .inside_extended == selected_partition .inside_extended )
next = partitions[t +1].sector_end - partitions[t +1].sector_start ;
total_length = previous + (selected_partition.sector_end - selected_partition.sector_start) + next;
@ -107,31 +108,37 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector <Partit
frame_resizer_base ->set_x_end( ( Round( (double) (selected_partition.sector_end - selected_partition.sector_start) / ( (double)total_length/500) )) + frame_resizer_base ->get_x_start() ) ;
frame_resizer_base ->set_used( Round( (double) selected_partition.sectors_used / ( (double)total_length/500) ) ) ;
//set values of spinbutton_before
if ( ! fixed_start )
{
spinbutton_before .set_range( 0, Sector_To_MB(total_length - selected_partition.sectors_used) -1 ) ;//mind the -1 !!
spinbutton_before .set_value( Sector_To_MB( previous ) ) ;
}
//set values of spinbutton_size
//since some filesystems have upper and lower limits we need to check for this
long LOWER, UPPER;
if ( selected_partition.filesystem == "fat16" && selected_partition .Get_Used_MB() < 32 )
LOWER = 32 +1 ;
LOWER = 32 +BUF ;
else if ( selected_partition.filesystem == "fat32" && selected_partition .Get_Used_MB() < 256 )
LOWER = 256 +1; //when shrinking to 256 the filesystem converts to fat16, thats why i added the 1
LOWER = 256 +BUF;
else if ( selected_partition.filesystem == "reiserfs" && selected_partition .Get_Used_MB() < 40 )
LOWER = 40 ;
else
LOWER = selected_partition .Get_Used_MB() +1;
LOWER = selected_partition .Get_Used_MB() +BUF;
//in certain (rare) case LOWER is a bit too high...
if ( LOWER > selected_partition .Get_Length_MB( ) )
LOWER = selected_partition .Get_Length_MB( ) ;
if ( selected_partition.filesystem == "fat16" && Sector_To_MB( total_length ) > 1023 )
UPPER = 1023 ;
else
UPPER = Sector_To_MB( total_length ) ;
spinbutton_size .set_range( LOWER , UPPER ) ;
//set values of spinbutton_before
if ( ! fixed_start )
{
spinbutton_before .set_range( 0, Sector_To_MB( total_length ) - LOWER ) ;
spinbutton_before .set_value( Sector_To_MB( previous ) ) ;
}
//set values of spinbutton_size
spinbutton_size .set_range( LOWER, UPPER ) ;
spinbutton_size .set_value( selected_partition .Get_Length_MB() ) ;
//set values of spinbutton_after
@ -182,7 +189,7 @@ void Dialog_Partition_Resize_Move::Resize_Move_Extended( const std::vector <Part
//calculate proportional length of partition ( in pixels )
frame_resizer_base ->set_x_start( Round( (double) previous / ( (double)total_length/500) ) ) ;
frame_resizer_base ->set_x_end( ( Round( (double) (selected_partition.sector_end - selected_partition.sector_start) / ( (double)total_length/500) )) + frame_resizer_base ->get_x_start() ) ;
frame_resizer_base ->set_x_end( ( Round( (double) (selected_partition.sector_end - selected_partition.sector_start) / ( (double)total_length/500) ) ) + 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
Sector first =0, used =0 ;
@ -202,7 +209,7 @@ void Dialog_Partition_Resize_Move::Resize_Move_Extended( const std::vector <Part
//set values of spinbutton_before (we assume there is no fixed start.)
if ( first == 0 ) //no logicals
spinbutton_before .set_range( 0, TOTAL_MB - 1) ;
spinbutton_before .set_range( 0, TOTAL_MB - 1 ) ;
else
spinbutton_before .set_range( 0, Sector_To_MB (first - START) ) ;
@ -210,9 +217,9 @@ void Dialog_Partition_Resize_Move::Resize_Move_Extended( const std::vector <Part
//set values of spinbutton_size
if ( first == 0 ) //no logicals
spinbutton_size .set_range( 1 , TOTAL_MB ) ;
spinbutton_size .set_range( 1, TOTAL_MB ) ;
else
spinbutton_size .set_range( Sector_To_MB( used ) , TOTAL_MB ) ;
spinbutton_size .set_range( Sector_To_MB( used ), TOTAL_MB ) ;
spinbutton_size .set_value( selected_partition .Get_Length_MB() ) ;