instead of listing all partition in one list, logical partitions are now
* instead of listing all partition in one list, logical partitions are now stored in a sublist in extended partition object. This makes partitionhandling in gparted more natural and transparant. It also allowed me to clean up this ugly Operation class ;)
This commit is contained in:
parent
4caae3dc85
commit
24dccdd8f3
|
@ -1,3 +1,8 @@
|
|||
2004-11-06 Bart Hakvoort <gparted@users.sf.net>
|
||||
|
||||
* instead of listing all partition in one list, logical partitions are now stored in a sublist in extended partition object.
|
||||
This makes partitionhandling in gparted more natural and transparant. It also allowed me to clean up this ugly Operation class ;)
|
||||
|
||||
2004-10-31 Bart Hakvoort <gparted@users.sf.net>
|
||||
|
||||
* include/Partition.h,
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
|
||||
#include <fstream>
|
||||
|
||||
|
||||
namespace GParted
|
||||
{
|
||||
|
||||
|
@ -73,6 +72,7 @@ public:
|
|||
Glib::ustring Get_DiskType() ;
|
||||
bool Get_any_busy() ;
|
||||
int Get_Max_Amount_Of_Primary_Partitions() ;
|
||||
int Get_Highest_Logical_Busy( ) ;
|
||||
|
||||
private:
|
||||
//make a try to get the amount of used sectors on a filesystem ( see comments in implementation )
|
||||
|
|
|
@ -55,11 +55,13 @@ public:
|
|||
Glib::ustring str_operation ;
|
||||
|
||||
private:
|
||||
std::vector<Partition> Apply_Delete_To_Visual( std::vector<Partition> & partitions );
|
||||
std::vector<Partition> Apply_Create_To_Visual( std::vector<Partition> & partitions );
|
||||
std::vector<Partition> Apply_Resize_Move_To_Visual( std::vector<Partition> & partitions );
|
||||
std::vector<Partition> Apply_Resize_Move_Extended_To_Visual( std::vector<Partition> & partitions );
|
||||
std::vector<Partition> Apply_Convert_To_Visual( std::vector<Partition> & partitions );
|
||||
void Insert_Unallocated( std::vector<Partition> & partitions, Sector start, Sector end );
|
||||
int Get_Index_Original( std::vector<Partition> & partitions ) ;
|
||||
|
||||
void Apply_Delete_To_Visual( std::vector<Partition> & partitions );
|
||||
void Apply_Create_To_Visual( std::vector<Partition> & partitions );
|
||||
void Apply_Resize_Move_To_Visual( std::vector<Partition> & partitions );
|
||||
void Apply_Resize_Move_Extended_To_Visual( std::vector<Partition> & partitions );
|
||||
|
||||
Glib::ustring Get_String(); //only used during in c'tor
|
||||
void Show_Error( Glib::ustring message ) ;
|
||||
|
|
|
@ -93,6 +93,8 @@ public:
|
|||
Glib::ustring error;
|
||||
Glib::ustring flags;
|
||||
|
||||
std::vector<Partition> logicals ;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
|
|
@ -132,7 +132,6 @@ inline Glib::ustring Get_Color( const Glib::ustring & filesystem )
|
|||
}
|
||||
|
||||
|
||||
|
||||
}//GParted
|
||||
|
||||
#endif //UTILS
|
||||
|
|
|
@ -63,7 +63,8 @@ public:
|
|||
|
||||
|
||||
private:
|
||||
void Build_Visual_Disk( int ) ; //i still dream of some fully resizeable visualdisk....
|
||||
void Build_Visual_Disk( ) ; //i still dream of some fully resizeable visualdisk....
|
||||
void Create_Visual_Partition( Partition & partition ) ;
|
||||
void Build_Legend( ) ;
|
||||
|
||||
//signal handlers
|
||||
|
@ -86,7 +87,7 @@ private:
|
|||
|
||||
|
||||
Glib::ustring str_temp ;
|
||||
int temp,selected_partition;
|
||||
int temp, selected_partition, SCREEN_WIDTH;
|
||||
};
|
||||
|
||||
} //GParted
|
||||
|
|
|
@ -105,6 +105,7 @@ private:
|
|||
void menu_help_about();
|
||||
|
||||
void mouse_click( GdkEventButton*, const Partition & );
|
||||
bool max_amount_prim_reached() ;
|
||||
|
||||
void activate_resize();
|
||||
void activate_copy();
|
||||
|
@ -168,7 +169,6 @@ private:
|
|||
|
||||
//usefull variables which are used by many different functions...
|
||||
bool any_logic,any_extended;//used in some checks (e.g. see optionmenu_devices_changed()
|
||||
unsigned short highest_logic_busy ;//highest_logic_busy contains the number of the highest logical which is busy ( 0 if none is busy)
|
||||
unsigned short primary_count ;//primary_count checks for max. of 4 pimary partitions
|
||||
unsigned short new_count;//new_count keeps track of the new created partitions
|
||||
Glib::ustring str_temp ; //mostly used for constructing dialogmessages
|
||||
|
|
|
@ -98,6 +98,7 @@ Device::Device( const Glib::ustring & device_path, std::vector<FS> *filesystems
|
|||
void Device::Read_Disk_Layout( bool deep_scan )
|
||||
{
|
||||
Glib::ustring part_path ;
|
||||
int EXT_INDEX = -1 ;
|
||||
|
||||
//clear partitions
|
||||
this ->device_partitions .clear( ) ;
|
||||
|
@ -139,6 +140,7 @@ void Device::Read_Disk_Layout( bool deep_scan )
|
|||
|
||||
partition_temp .flags = Get_Flags( c_partition ) ;
|
||||
partition_temp .error = this ->error ;//most likely useless, but paranoia me leaves it here.. =)
|
||||
|
||||
break ;
|
||||
|
||||
|
||||
|
@ -153,6 +155,7 @@ void Device::Read_Disk_Layout( bool deep_scan )
|
|||
ped_partition_is_busy( c_partition ) );
|
||||
|
||||
partition_temp .flags = Get_Flags( c_partition ) ;
|
||||
EXT_INDEX = device_partitions .size ( ) ;
|
||||
break ;
|
||||
|
||||
|
||||
|
@ -161,12 +164,28 @@ void Device::Read_Disk_Layout( bool deep_scan )
|
|||
partition_temp.Set_Unallocated( c_partition ->geom .start, c_partition ->geom .end, c_partition ->type == 4 ? false : true );
|
||||
break ;
|
||||
|
||||
case PED_PARTITION_METADATA:
|
||||
if ( device_partitions .size( ) && device_partitions .back( ) .type == GParted::UNALLOCATED )
|
||||
device_partitions .back( ) .sector_end = c_partition ->geom .end ;
|
||||
|
||||
break ;
|
||||
|
||||
case 9: //metadata inside extended (there's no enumvalue for that..)
|
||||
if ( device_partitions[ EXT_INDEX ] .logicals .size( ) && device_partitions[ EXT_INDEX ] .logicals .back( ) .type == GParted::UNALLOCATED )
|
||||
device_partitions[ EXT_INDEX ] .logicals .back( ) .sector_end = c_partition ->geom .end ;
|
||||
|
||||
break ;
|
||||
|
||||
default: break;
|
||||
}
|
||||
|
||||
if ( partition_temp .Get_Length_MB( ) >= 1 ) //paranoia check for unallocated < 1MB
|
||||
if ( partition_temp .Get_Length_MB( ) >= 1 ) // check for unallocated < 1MB, and metadatasituations (see PED_PARTITION_METADATA and 9 )
|
||||
{
|
||||
if ( ! partition_temp .inside_extended )
|
||||
device_partitions.push_back( partition_temp );
|
||||
else
|
||||
device_partitions[ EXT_INDEX ] .logicals .push_back( partition_temp ) ;
|
||||
}
|
||||
|
||||
//reset stuff..
|
||||
this ->error = error_message = "" ;
|
||||
|
@ -449,6 +468,23 @@ int Device::Get_Max_Amount_Of_Primary_Partitions()
|
|||
return ped_disk_get_max_primary_partition_count( disk ) ;
|
||||
}
|
||||
|
||||
int Device::Get_Highest_Logical_Busy( )
|
||||
{
|
||||
int highest_logic_busy = -1 ;
|
||||
|
||||
for ( unsigned int t = 0 ; t < device_partitions .size( ) ; t++ )
|
||||
if ( device_partitions [ t ] .type == GParted::EXTENDED )
|
||||
{
|
||||
for ( unsigned int i = 0 ; i < device_partitions[ t ] .logicals .size( ) ; i++ )
|
||||
if ( device_partitions[ t ] .logicals[ i ] .busy && device_partitions[ t ] .logicals[ i ] .partition_number > highest_logic_busy )
|
||||
highest_logic_busy = device_partitions[ t ] .logicals[ i ] .partition_number ;
|
||||
|
||||
break ;
|
||||
}
|
||||
|
||||
return highest_logic_busy ;
|
||||
}
|
||||
|
||||
Sector Device::Get_Used_Sectors( PedPartition *c_partition, const Glib::ustring & sym_path)
|
||||
{
|
||||
/* This is quite an unreliable process, atm i try two different methods, but since both are far from perfect the results are
|
||||
|
|
|
@ -144,6 +144,14 @@ Partition Dialog_Partition_New::Get_New_Partition()
|
|||
if ( (selected_partition.sector_end - part_temp.sector_end) < MEGABYTE )
|
||||
part_temp.sector_end = selected_partition.sector_end ;
|
||||
|
||||
//if new is extended...
|
||||
if ( part_temp .type == GParted::EXTENDED )
|
||||
{
|
||||
Partition UNALLOCATED ;
|
||||
UNALLOCATED .Set_Unallocated( part_temp .sector_start, part_temp .sector_end, true ) ;
|
||||
part_temp .logicals .push_back( UNALLOCATED ) ;
|
||||
}
|
||||
|
||||
return part_temp;
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,6 @@ void Dialog_Partition_Resize_Move::Set_Data( const Partition & selected_partitio
|
|||
|
||||
void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector <Partition> & partitions )
|
||||
{
|
||||
|
||||
//see if we need a fixed_start
|
||||
if ( selected_partition.filesystem == "ext2" || selected_partition.filesystem == "ext3" || selected_partition.filesystem == "reiserfs" )
|
||||
{
|
||||
|
@ -81,13 +80,16 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector <Partit
|
|||
//first find index of partition
|
||||
unsigned int t;
|
||||
for ( t=0;t< partitions.size(); t++ )
|
||||
if ( partitions[t].sector_start == selected_partition.sector_start && partitions[t].type != GParted::EXTENDED )
|
||||
if ( partitions[t].sector_start == selected_partition.sector_start )
|
||||
break;
|
||||
|
||||
Sector previous, next ;
|
||||
previous = next = 0 ;
|
||||
//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 )
|
||||
if ( t >= 1 && partitions[t -1].type == GParted::UNALLOCATED &&
|
||||
selected_partition.filesystem != "ext2" &&
|
||||
selected_partition.filesystem != "ext3" &&
|
||||
selected_partition.filesystem != "reiserfs" )
|
||||
{
|
||||
previous = partitions[t -1] .sector_end - partitions[t -1] .sector_start ;
|
||||
START = partitions[t -1] .sector_start ;
|
||||
|
@ -95,7 +97,7 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector <Partit
|
|||
else
|
||||
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 )
|
||||
next = partitions[t +1].sector_end - partitions[t +1].sector_start ;
|
||||
|
||||
total_length = previous + (selected_partition.sector_end - selected_partition.sector_start) + next;
|
||||
|
@ -154,10 +156,8 @@ void Dialog_Partition_Resize_Move::Resize_Move_Extended( const std::vector <Part
|
|||
{
|
||||
//calculate total size in MB's of previous, current and next partition
|
||||
//first find index of partition
|
||||
unsigned int t;
|
||||
for ( t=0;t< partitions.size(); t++ )
|
||||
if ( partitions[t].type == GParted::EXTENDED )
|
||||
break;
|
||||
unsigned int t = 0;
|
||||
while ( t < partitions .size( ) && partitions[ t ] .type != GParted::EXTENDED ) t++ ;
|
||||
|
||||
Sector previous, next ;
|
||||
previous = next = 0 ;
|
||||
|
@ -170,17 +170,9 @@ void Dialog_Partition_Resize_Move::Resize_Move_Extended( const std::vector <Part
|
|||
else
|
||||
START = selected_partition .sector_start ;
|
||||
|
||||
//calculate length of next (in this case next should be the first partition OUTSIDE the extended .. )
|
||||
for ( t+=1;t<partitions.size() ; t++ )
|
||||
{
|
||||
if ( ! partitions[t].inside_extended )
|
||||
{
|
||||
if ( partitions[t].type == GParted::UNALLOCATED )
|
||||
next = partitions[t].sector_end - partitions[t].sector_start ;
|
||||
|
||||
break ;
|
||||
}
|
||||
}
|
||||
//calculate length of next
|
||||
if ( t +1 < partitions .size( ) && partitions[ t +1 ] .type == GParted::UNALLOCATED )
|
||||
next = partitions[ t +1 ] .sector_end - partitions[ t +1 ] .sector_start ;
|
||||
|
||||
//now we have enough data to calculate some important values..
|
||||
total_length = previous + (selected_partition.sector_end - selected_partition.sector_start) + next;
|
||||
|
@ -193,14 +185,14 @@ void Dialog_Partition_Resize_Move::Resize_Move_Extended( const std::vector <Part
|
|||
|
||||
//used is a bit different here... we consider start of first logical to end last logical as used space
|
||||
Sector first =0, used =0 ;
|
||||
for ( t=0;t< partitions.size(); t++ )
|
||||
for ( unsigned int i = 0 ; i < partitions[ t ] .logicals .size( ) ; i++ )
|
||||
{
|
||||
if ( partitions[t].type == GParted::LOGICAL )
|
||||
if ( partitions[ t ] .logicals[ i ] .type == GParted::LOGICAL )
|
||||
{
|
||||
if ( first == 0 )
|
||||
first = partitions[t] .sector_start ;
|
||||
first = partitions[ t ] .logicals[ i ] .sector_start ;
|
||||
|
||||
used = partitions[t] .sector_end - first;
|
||||
used = partitions[ t ] .logicals[ i ] .sector_end - first;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
354
src/Operation.cc
354
src/Operation.cc
|
@ -103,11 +103,11 @@ std::vector<Partition> Operation::Apply_Operation_To_Visual( std::vector<Partiti
|
|||
{
|
||||
switch ( operationtype )
|
||||
{
|
||||
case DELETE : return Apply_Delete_To_Visual( partitions );
|
||||
case CREATE : return Apply_Create_To_Visual( partitions );
|
||||
case RESIZE_MOVE: return Apply_Resize_Move_To_Visual( partitions );
|
||||
case CONVERT : return Apply_Convert_To_Visual( partitions ) ;
|
||||
case COPY : return Apply_Create_To_Visual( partitions );
|
||||
case DELETE : Apply_Delete_To_Visual( partitions ) ; break ;
|
||||
case RESIZE_MOVE: Apply_Resize_Move_To_Visual( partitions ); break ;
|
||||
case CREATE :
|
||||
case CONVERT :
|
||||
case COPY : Apply_Create_To_Visual( partitions ); break ;
|
||||
}
|
||||
|
||||
return partitions;
|
||||
|
@ -149,272 +149,140 @@ void Operation::Apply_To_Disk( PedTimer * timer )
|
|||
|
||||
}
|
||||
|
||||
std::vector<Partition> Operation::Apply_Delete_To_Visual( std::vector<Partition> & partitions )
|
||||
void Operation::Insert_Unallocated( std::vector<Partition> & partitions, Sector start, Sector end )
|
||||
{
|
||||
unsigned int t ;
|
||||
Partition UNALLOCATED ;
|
||||
UNALLOCATED .Set_Unallocated( 0, 0, partitions .front( ) .inside_extended ) ;
|
||||
|
||||
for ( t=0;t<partitions.size();t++)
|
||||
//if there are no partitions at all..
|
||||
if ( partitions .empty( ) )
|
||||
{
|
||||
//since extended can only be deleted if there are no logicals left, we know for sure the next element in partitions is unallocated space
|
||||
//we simply remove the extended one and set the inside_extended flag from the unallocated space to false
|
||||
if (this ->partition_original.type == GParted::EXTENDED && partitions[t].type == GParted::EXTENDED )
|
||||
{
|
||||
partitions[t+1].inside_extended = false;
|
||||
partitions.erase( partitions.begin() + t );
|
||||
break;//we're done here ;-)
|
||||
UNALLOCATED .sector_start = start ;
|
||||
UNALLOCATED .sector_end = end ;
|
||||
|
||||
partitions .push_back( UNALLOCATED );
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
else if ( partitions[t].sector_start == this-> partition_original.sector_start )
|
||||
//start <---> first partition start
|
||||
if ( (partitions .front( ) .sector_start - start) >= MEGABYTE )
|
||||
{
|
||||
partitions[t].Set_Unallocated( partition_original.sector_start , partition_original.sector_end, partition_original.inside_extended );
|
||||
break;//we're done here ;-)
|
||||
UNALLOCATED .sector_start = start ;
|
||||
UNALLOCATED .sector_end = partitions .front( ) .sector_start -1 ;
|
||||
|
||||
partitions .insert( partitions .begin( ), UNALLOCATED );
|
||||
}
|
||||
|
||||
//look for gaps in between
|
||||
for ( unsigned int t =0 ; t < partitions .size( ) -1 ; t++ )
|
||||
if ( ( partitions[ t +1 ] .sector_start - partitions[ t ] .sector_end ) >= MEGABYTE )
|
||||
{
|
||||
UNALLOCATED .sector_start = partitions[ t ] .sector_end +1 ;
|
||||
UNALLOCATED .sector_end = partitions[ t +1 ] .sector_start -1 ;
|
||||
|
||||
partitions .insert( partitions .begin( ) + ++t, UNALLOCATED );
|
||||
}
|
||||
|
||||
//last partition end <---> end
|
||||
if ( (end - partitions .back( ) .sector_end ) >= MEGABYTE )
|
||||
{
|
||||
UNALLOCATED .sector_start = partitions .back( ) .sector_end +1 ;
|
||||
UNALLOCATED .sector_end = end ;
|
||||
|
||||
partitions .push_back( UNALLOCATED );
|
||||
}
|
||||
}
|
||||
|
||||
int Operation::Get_Index_Original( std::vector<Partition> & partitions )
|
||||
{
|
||||
for ( int t = 0 ; t < (int)partitions .size( ) ; t++ )
|
||||
if ( partition_original .sector_start >= partitions[ t ] .sector_start && partition_original .sector_end <= partitions[ t ] .sector_end )
|
||||
{
|
||||
//remove unallocated space preceding the original partition
|
||||
if ( t -1 >= 0 && partitions[ t -1 ] .type == GParted::UNALLOCATED )
|
||||
partitions .erase( partitions .begin( ) + --t );
|
||||
|
||||
//remove unallocated space following the original partition
|
||||
if ( t +1 < (int)partitions .size( ) && partitions[ t +1 ] .type == GParted::UNALLOCATED )
|
||||
partitions .erase( partitions .begin( ) + t +1 );
|
||||
|
||||
return t ;
|
||||
}
|
||||
|
||||
return -1 ;
|
||||
}
|
||||
|
||||
void Operation::Apply_Delete_To_Visual( std::vector<Partition> & partitions )
|
||||
{
|
||||
if ( ! partition_original .inside_extended )
|
||||
{
|
||||
partitions .erase( partitions .begin( ) + Get_Index_Original( partitions ) );
|
||||
|
||||
Insert_Unallocated( partitions, 0, device ->Get_Length( ) -1 ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
//unsigned int ext = Get_Index_Extended( partitions ) ;
|
||||
unsigned int ext = 0 ;
|
||||
while ( ext < partitions .size( ) && partitions[ ext ] .type != GParted::EXTENDED ) ext++ ;
|
||||
partitions[ ext ] .logicals .erase( partitions[ ext ] .logicals .begin( ) + Get_Index_Original( partitions[ ext ] .logicals ) );
|
||||
|
||||
|
||||
//if deleted partition was logical we have to decrease the partitionnumbers of the logicals with higher numbers by one (only if its a real partition)
|
||||
if ( partition_original.type == GParted::LOGICAL && partition_original .status != GParted::STAT_NEW )
|
||||
for ( t=0;t<partitions.size() ;t++)
|
||||
if ( partitions[t].type == GParted::LOGICAL && partitions[t].partition_number > partition_original.partition_number )
|
||||
partitions[t].Update_Number( partitions[t].partition_number -1 );
|
||||
if ( partition_original .status != GParted::STAT_NEW )
|
||||
for ( unsigned int t = 0 ; t < partitions[ ext ] .logicals .size( ) ; t++ )
|
||||
if ( partitions[ ext ] .logicals[ t ] .partition_number > partition_original .partition_number )
|
||||
partitions[ ext ] .logicals[ t ] .Update_Number( partitions[ ext ] .logicals[ t ] .partition_number -1 );
|
||||
|
||||
|
||||
//now we merge separate unallocated spaces next to each other together FIXME: more performance if we only check t -1 and t +1
|
||||
for ( t=0;t<partitions.size() -1;t++)
|
||||
{
|
||||
if ( partitions[t].type == GParted::UNALLOCATED && partitions[t +1].type == GParted::UNALLOCATED && partitions[t].inside_extended == partitions[t +1].inside_extended )
|
||||
{
|
||||
partitions[t].sector_end = partitions[t+1].sector_end;
|
||||
partitions.erase( partitions.begin() + t + 1 );
|
||||
t--;
|
||||
Insert_Unallocated( partitions[ ext ] .logicals, partitions[ ext ] .sector_start, partitions[ ext ] .sector_end ) ;
|
||||
}
|
||||
}
|
||||
|
||||
return partitions;
|
||||
void Operation::Apply_Create_To_Visual( std::vector<Partition> & partitions )
|
||||
{
|
||||
if ( ! partition_original .inside_extended )
|
||||
{
|
||||
partitions[ Get_Index_Original( partitions ) ] = partition_new ;
|
||||
|
||||
Insert_Unallocated( partitions, 0, device ->Get_Length( ) -1 ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned int ext = 0 ;
|
||||
while ( ext < partitions .size( ) && partitions[ ext ] .type != GParted::EXTENDED ) ext++ ;
|
||||
partitions[ ext ] .logicals[ Get_Index_Original( partitions[ ext ] .logicals ) ] = partition_new ;
|
||||
|
||||
Insert_Unallocated( partitions[ ext ] .logicals, partitions[ ext ] .sector_start, partitions[ ext ] .sector_end ) ;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<Partition> Operation::Apply_Create_To_Visual( std::vector<Partition> & partitions )
|
||||
void Operation::Apply_Resize_Move_To_Visual( std::vector<Partition> & partitions)
|
||||
{
|
||||
Partition partition_temp;
|
||||
|
||||
//find the original partition and replace it with the new one (original "partition" is unallocated space of course)
|
||||
unsigned int t;
|
||||
for ( t=0;t<partitions.size() ;t++)
|
||||
{
|
||||
//since the stored partition_original might have been changed (e.g. deletion of virtual partition) we look for the partition which contains the
|
||||
//startsector of te new one and set this partition as the original one.
|
||||
if ( partition_new.sector_start >= partitions[t].sector_start && partition_new.sector_start <= partitions[t].sector_end && partitions[t].type != GParted::EXTENDED )
|
||||
{
|
||||
partition_original = partitions[t] ;
|
||||
partitions.erase( partitions.begin() + t );
|
||||
partitions.insert( partitions.begin() + t, partition_new );
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//check borders and create new elements if necessary
|
||||
//BEFORE new partition
|
||||
if ( (partition_new.sector_start - partition_original.sector_start) >= MEGABYTE ) //at least 1 MB between begin new partition and begin original one
|
||||
{
|
||||
partition_temp.Set_Unallocated( partition_original.sector_start, partition_new.sector_start -1 , partition_new.inside_extended );
|
||||
partitions.insert( partitions.begin() + t, partition_temp );
|
||||
t++;
|
||||
}
|
||||
|
||||
//AFTER new partition
|
||||
if ( ( partition_original.sector_end - partition_new.sector_end) >= MEGABYTE ) //at least 1 MB between end new partition and end original one
|
||||
{
|
||||
partition_temp.Set_Unallocated( partition_new.sector_end +1, partition_original.sector_end ,partition_new.inside_extended );
|
||||
partitions.insert( partitions.begin() + t +1, partition_temp );
|
||||
}
|
||||
|
||||
//if new created partition is an extended partition, we need to add unallocated space of the same size to the list
|
||||
if ( partition_new.type == GParted::EXTENDED )
|
||||
{
|
||||
partition_temp.Set_Unallocated( partition_new.sector_start, partition_new.sector_end , true );
|
||||
partitions.insert( partitions.begin() + t +1, partition_temp );
|
||||
}
|
||||
|
||||
return partitions;
|
||||
}
|
||||
|
||||
std::vector<Partition> Operation::Apply_Resize_Move_To_Visual( std::vector<Partition> & partitions)
|
||||
{
|
||||
//extended handling is so different i decided to take it apart from normal handling
|
||||
if ( partition_original .type == GParted::EXTENDED )
|
||||
return Apply_Resize_Move_Extended_To_Visual( partitions ) ;
|
||||
|
||||
//normal partitions ( Primary and Logical )
|
||||
Partition partition_temp;
|
||||
|
||||
unsigned int t;
|
||||
for ( t=0;t<partitions.size() ;t++)
|
||||
{
|
||||
//since the stored partition_original might have been changed (e.g. deletion of virtual partition) we look for the partition which contains the
|
||||
//startsector of the original one
|
||||
if ( partition_original.sector_start >= partitions[t].sector_start && partition_original.sector_start <= partitions[t].sector_end && partitions[t].type != GParted::EXTENDED )
|
||||
{
|
||||
partition_original = partitions[t] ;
|
||||
partitions[t].sector_start = partition_new.sector_start ;
|
||||
partitions[t].sector_end = partition_new.sector_end ;
|
||||
partitions[t].sectors_unused = partition_new.sectors_unused ;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//determine correct perimeters of moving/resizing space
|
||||
Sector START = partition_original.sector_start ;
|
||||
Sector END = partition_original.sector_end ;
|
||||
|
||||
|
||||
//now we have the index of the original partition we can remove the surrounding partitions ( if UNALLOCATED and inside_extended is the same )
|
||||
if ( t > 0 && partitions[t -1].type == GParted::UNALLOCATED && partitions[t -1].inside_extended == partition_new.inside_extended )
|
||||
{
|
||||
START = partitions[t -1] .sector_start ;
|
||||
partitions.erase( partitions.begin() + t -1 );
|
||||
t-- ;
|
||||
}
|
||||
|
||||
if ( t +1 < partitions.size() && partitions[t +1].type == GParted::UNALLOCATED && partitions[t +1].inside_extended == partition_new.inside_extended)
|
||||
{
|
||||
END = partitions[t +1] .sector_end ;
|
||||
partitions.erase( partitions.begin() + t +1 );
|
||||
}
|
||||
|
||||
//now look for unallocated space > 1 MB and add to the list
|
||||
if ( (partition_new.sector_start - START) >= MEGABYTE )
|
||||
{
|
||||
partition_temp.Set_Unallocated( START, partition_new.sector_start -1 , partition_new.inside_extended );
|
||||
partitions.insert( partitions.begin() + t , partition_temp );
|
||||
t++;
|
||||
}
|
||||
|
||||
if ( (END - partition_new.sector_end) >= MEGABYTE )
|
||||
{
|
||||
partition_temp.Set_Unallocated( partition_new.sector_end +1, END , partition_new.inside_extended );
|
||||
partitions.insert( partitions.begin() + t +1, partition_temp );
|
||||
}
|
||||
|
||||
|
||||
return partitions;
|
||||
}
|
||||
|
||||
std::vector<Partition> Operation::Apply_Resize_Move_Extended_To_Visual( std::vector<Partition> & partitions )
|
||||
{
|
||||
unsigned int t, INDEX =0;
|
||||
|
||||
//look for index of partition and set the extended partition's new size.
|
||||
for ( t=0;t<partitions.size() ;t++)
|
||||
{
|
||||
if ( partitions[t].type == GParted::EXTENDED )
|
||||
{
|
||||
partition_original = partitions[t] ;
|
||||
partitions[t].sector_start = partition_new.sector_start ;
|
||||
partitions[t].sector_end = partition_new.sector_end ;
|
||||
INDEX = t ;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* remove all relevant unallocated spaces...
|
||||
* E.G. partitions looks like: P-P-U-E-U-L-L-U-U <--- last U is OUTSIDE extended!!
|
||||
* 1-2 - 3- 4- 5 -6-7- 8 - 9
|
||||
* now we check 3, 5, 8 and 9 . If any of them is unallocated we remove it. In this case all of them.. :)
|
||||
*/
|
||||
|
||||
//check 3
|
||||
if ( partitions[ INDEX -1 ] .type == GParted::UNALLOCATED )
|
||||
partitions .erase( partitions .begin() + --INDEX ) ;
|
||||
|
||||
//check 5
|
||||
if ( partitions[ INDEX +1 ] .type == GParted::UNALLOCATED )
|
||||
partitions .erase( partitions .begin() + INDEX +1 ) ;
|
||||
|
||||
//find index of last logic
|
||||
for ( t = partitions.size() -1 ; ! partitions[ t ] .inside_extended && t > INDEX ; t-- ) {}
|
||||
|
||||
//check 8
|
||||
if ( t > INDEX && partitions[ t ] .type == GParted::UNALLOCATED )
|
||||
partitions .erase( partitions .begin() + t ) ;
|
||||
Apply_Resize_Move_Extended_To_Visual( partitions ) ;
|
||||
else
|
||||
t++ ;
|
||||
|
||||
//check 9
|
||||
if ( t < partitions .size( ) && partitions[ t ] .type == GParted::UNALLOCATED )
|
||||
partitions .erase( partitions .begin() + t ) ;
|
||||
|
||||
|
||||
|
||||
//and insert new unallocated spaces at fitting places
|
||||
Sector TEMP ;
|
||||
Partition partition_temp ;
|
||||
|
||||
//check 3
|
||||
TEMP = INDEX > 0 ? partitions[ INDEX -1 ] .sector_end +1 : 0 ;
|
||||
if ( ( partitions[ INDEX ] .sector_start - TEMP ) > MEGABYTE )
|
||||
{
|
||||
partition_temp.Set_Unallocated( TEMP, partitions[ INDEX ] .sector_start -1, false ) ;
|
||||
partitions.insert( partitions.begin() + INDEX, partition_temp );
|
||||
INDEX++;
|
||||
Apply_Create_To_Visual( partitions ) ;
|
||||
}
|
||||
|
||||
//check 5
|
||||
if ( (INDEX +1) < partitions .size() && partitions[ INDEX +1 ] .type == GParted::LOGICAL )
|
||||
TEMP = partitions[ INDEX +1 ] .sector_start -1 ;
|
||||
else
|
||||
TEMP = partition_new .sector_end ;
|
||||
|
||||
if ( ( TEMP - partitions[ INDEX ] .sector_start ) > MEGABYTE )
|
||||
void Operation::Apply_Resize_Move_Extended_To_Visual( std::vector<Partition> & partitions )
|
||||
{
|
||||
partition_temp.Set_Unallocated( partitions[ INDEX ] .sector_start, TEMP, true ) ;
|
||||
partitions.insert( partitions.begin() +INDEX +1, partition_temp );
|
||||
}
|
||||
//stuff OUTSIDE extended partition
|
||||
partitions[ Get_Index_Original( partitions ) ] = partition_new ;
|
||||
Insert_Unallocated( partitions, 0, device ->Get_Length( ) -1 ) ;
|
||||
|
||||
//stuff INSIDE extended partition
|
||||
unsigned int ext = 0 ;
|
||||
while ( ext < partitions .size( ) && partitions[ ext ] .type != GParted::EXTENDED ) ext++ ;
|
||||
|
||||
//find index of last logic
|
||||
for ( t = partitions .size( ) -1 ; ! partitions[ t ] .inside_extended && t > INDEX ; t-- ) { }
|
||||
if ( partitions[ ext ] .logicals .size( ) && partitions[ ext ] .logicals .front( ) .type == GParted::UNALLOCATED )
|
||||
partitions[ ext ] .logicals .erase( partitions[ ext ] .logicals .begin( ) ) ;
|
||||
|
||||
//check 8
|
||||
if ( partitions[ t ] .type != GParted::UNALLOCATED && ( partition_new .sector_end - partitions[ t ] .sector_end ) > MEGABYTE )
|
||||
{
|
||||
partition_temp.Set_Unallocated( partitions[ t ] .sector_end +1, partition_new .sector_end, true ) ;
|
||||
partitions.insert( partitions.begin() +t +1, partition_temp );
|
||||
t++ ;
|
||||
}
|
||||
|
||||
//check 9
|
||||
t++ ;
|
||||
TEMP = t < partitions .size() ? partitions[ t ] .sector_start -1 : device ->Get_Length() -1;
|
||||
|
||||
if ( ( TEMP - partition_new .sector_end ) > MEGABYTE )
|
||||
{
|
||||
partition_temp.Set_Unallocated( partition_new .sector_end +1, TEMP -1, false ) ;
|
||||
partitions.insert( partitions.begin() +t, partition_temp );
|
||||
}
|
||||
|
||||
|
||||
return partitions ;
|
||||
}
|
||||
|
||||
std::vector<Partition> Operation::Apply_Convert_To_Visual( std::vector<Partition> & partitions )
|
||||
{
|
||||
for ( unsigned int t=0;t<partitions.size() ;t++)
|
||||
{
|
||||
//since the stored partition_original might have been changed (e.g. deletion of virtual partition) we look for the partition which contains the
|
||||
//startsector of the original one
|
||||
if ( partition_original.sector_start >= partitions[t].sector_start && partition_original.sector_start <= partitions[t].sector_end && partitions[t].type != GParted::EXTENDED )
|
||||
{
|
||||
partitions[ t ] = partition_new ;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return partitions;
|
||||
if ( partitions[ ext ] .logicals .size( ) && partitions[ ext ] .logicals .back( ) .type == GParted::UNALLOCATED )
|
||||
partitions[ ext ] .logicals .erase( partitions[ ext ] .logicals .end( ) -1 ) ;
|
||||
|
||||
Insert_Unallocated( partitions[ ext ] .logicals, partitions[ ext ] .sector_start, partitions[ ext ] .sector_end ) ;
|
||||
}
|
||||
|
||||
void Operation::Show_Error( Glib::ustring message )
|
||||
|
|
|
@ -33,6 +33,7 @@ void Partition::Reset( )
|
|||
partition_number = sector_start = sector_end = sectors_used = sectors_unused = -1;
|
||||
color.set( "black" ) ;
|
||||
inside_extended = busy = false ;
|
||||
logicals .clear( ) ;
|
||||
}
|
||||
|
||||
void Partition::Set( const Glib::ustring & partition,
|
||||
|
|
|
@ -74,7 +74,7 @@ void TreeView_Detail::Load_Partitions( std::vector<Partition> & partitions )
|
|||
{
|
||||
treestore_detail ->clear() ;
|
||||
|
||||
for ( unsigned int i=0;i<partitions.size();i++ )
|
||||
/* for ( unsigned int i=0;i<partitions.size();i++ )
|
||||
{
|
||||
if ( ! partitions[ i ] .inside_extended )
|
||||
{
|
||||
|
@ -87,6 +87,23 @@ void TreeView_Detail::Load_Partitions( std::vector<Partition> & partitions )
|
|||
Create_Row( childrow, partitions[i] );
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
for ( unsigned int i=0;i<partitions.size();i++ )
|
||||
{
|
||||
row = *(treestore_detail->append());
|
||||
Create_Row( row, partitions[i] );
|
||||
|
||||
if ( partitions[i] .type == GParted::EXTENDED )
|
||||
{
|
||||
for ( unsigned int t=0;t<partitions[i] .logicals .size();t++ )
|
||||
{
|
||||
childrow = *(treestore_detail->append( row.children() ));
|
||||
Create_Row( childrow, partitions[i] .logicals[ t ] );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//show logical partitions ( if any )
|
||||
this->expand_all();
|
||||
|
|
|
@ -62,17 +62,17 @@ VBox_VisualDisk::VBox_VisualDisk( const std::vector<Partition> & partitions, con
|
|||
}
|
||||
|
||||
//draw visual disk and its legend
|
||||
Build_Visual_Disk( 750 - Round( extra_pixels ) ) ;
|
||||
this ->SCREEN_WIDTH = 750 - Round( extra_pixels ) ;
|
||||
|
||||
Build_Visual_Disk( ) ;
|
||||
Build_Legend( ) ;
|
||||
|
||||
}
|
||||
|
||||
void VBox_VisualDisk::Build_Visual_Disk( int SCREEN_WIDTH )
|
||||
void VBox_VisualDisk::Build_Visual_Disk( )
|
||||
{
|
||||
//since there is a 5 pixel space between every partition.... ( extended adds 2 *5 more, but that doesn't matter that much.
|
||||
//NOTE that a part < 20 will also grow to 20, so length in pixels may vary across different devices..
|
||||
SCREEN_WIDTH -= ( (partitions .size() -1) *5 ) ;
|
||||
this ->SCREEN_WIDTH -= ( (partitions .size() -1) *5 ) ;
|
||||
|
||||
//create hbox_disk and add to frame
|
||||
hbox_disk = manage( new Gtk::HBox() ) ;
|
||||
|
@ -81,47 +81,67 @@ void VBox_VisualDisk::Build_Visual_Disk( int SCREEN_WIDTH )
|
|||
|
||||
|
||||
//walk through all partitions....
|
||||
int x,y;//for pango_layout check
|
||||
for ( unsigned int i=0;i<partitions.size();i++ )
|
||||
{
|
||||
Create_Visual_Partition( partitions[i] ) ;
|
||||
|
||||
if ( partitions[i].type != GParted::EXTENDED )
|
||||
hbox_disk ->pack_start( *( visual_partitions.back() ->drawingarea), Gtk::PACK_SHRINK ) ;
|
||||
}
|
||||
|
||||
this ->show_all_children() ;
|
||||
}
|
||||
|
||||
void VBox_VisualDisk::Create_Visual_Partition( Partition & partition )
|
||||
{
|
||||
int x,y;//for pango_layout check
|
||||
|
||||
visual_partition = new Visual_Partition() ;
|
||||
visual_partitions.push_back( visual_partition ) ;
|
||||
visual_partitions.back() ->index = i ;
|
||||
visual_partitions.back() ->sector_start = partitions[i].sector_start ;
|
||||
visual_partitions.back() ->index = visual_partitions .size() -1 ; // <---- BELACHELIJK!! DOE DAAR IETS AAN!!!
|
||||
visual_partitions.back() ->sector_start = partition .sector_start ;
|
||||
|
||||
if ( partitions[i].type == GParted::EXTENDED )
|
||||
if ( partition .type == GParted::EXTENDED )
|
||||
{
|
||||
visual_partitions.back() ->drawingarea = NULL ;//it's just a dummy ;-) ( see Set_Selected() )
|
||||
visual_partitions.back() ->length = 0 ; //keeps total_length clean
|
||||
|
||||
eventbox_extended = manage( new Gtk::EventBox() ) ;
|
||||
eventbox_extended ->set_size_request( -1, 60 );
|
||||
eventbox_extended ->modify_bg( eventbox_extended ->get_state(), partitions[i].color );
|
||||
eventbox_extended ->modify_bg( eventbox_extended ->get_state(), partition .color );
|
||||
hbox_disk ->pack_start( *eventbox_extended, Gtk::PACK_SHRINK ) ;
|
||||
|
||||
hbox_extended = manage( new Gtk::HBox() ) ;
|
||||
hbox_extended ->set_border_width( 5 );
|
||||
hbox_extended ->set_spacing( 5 );
|
||||
eventbox_extended ->add( *hbox_extended ) ;
|
||||
continue;
|
||||
|
||||
for ( unsigned int t=0;t<partition .logicals .size();t++ )
|
||||
{
|
||||
Create_Visual_Partition( partition .logicals[ t ] ) ;
|
||||
hbox_extended ->pack_start( *( visual_partitions.back() ->drawingarea), Gtk::PACK_SHRINK ) ;
|
||||
}
|
||||
|
||||
visual_partitions.back() ->length = (int) (SCREEN_WIDTH / (double) ( device_length / (double) ( partitions[i].sector_end - partitions[i].sector_start) ) );
|
||||
if ( visual_partitions.back() ->length < 20 )//we need a min. size. Otherwise some small partitions wouldn't be visible
|
||||
partitions[i] .type == GParted::UNALLOCATED ? visual_partitions.back() ->length = 15 : visual_partitions.back() ->length = 20 ;
|
||||
|
||||
if ( partitions[i].inside_extended )
|
||||
return ;
|
||||
}
|
||||
|
||||
visual_partitions.back() ->length = (int) (SCREEN_WIDTH / (double) ( device_length / (double) ( partition .sector_end - partition .sector_start) ) );
|
||||
if ( visual_partitions.back() ->length < 20 )//we need a min. size. Otherwise some small partitions wouldn't be visible
|
||||
partition .type == GParted::UNALLOCATED ? visual_partitions.back() ->length = 15 : visual_partitions.back() ->length = 20 ;
|
||||
|
||||
if ( partition .inside_extended )
|
||||
{ visual_partitions.back() ->height = 34 ; visual_partitions.back() ->text_y = 9 ; }
|
||||
else
|
||||
{ visual_partitions.back() ->height = 44 ;visual_partitions.back() ->text_y = 15 ; }
|
||||
|
||||
if ( partitions[i].type == GParted::UNALLOCATED )
|
||||
if ( partition .type == GParted::UNALLOCATED )
|
||||
visual_partitions.back() ->used = -1;
|
||||
else
|
||||
visual_partitions.back() ->used = (int) ( (visual_partitions.back() ->length - (BORDER *2)) / (double) ( ( partitions[i].sector_end - partitions[i].sector_start) / (double)partitions[i].sectors_used ) ) ;
|
||||
visual_partitions.back() ->used = (int) ( (visual_partitions.back() ->length - (BORDER *2)) / (double) ( ( partition .sector_end - partition .sector_start) / (double)partition .sectors_used ) ) ;
|
||||
|
||||
|
||||
visual_partitions.back() ->color_fs = partitions[i] .color;
|
||||
visual_partitions.back() ->color_fs = partition .color;
|
||||
this ->get_colormap() ->alloc_color(visual_partitions.back() ->color_fs);
|
||||
|
||||
visual_partitions.back() ->drawingarea = manage( new Gtk::DrawingArea() ) ;
|
||||
|
@ -129,12 +149,12 @@ void VBox_VisualDisk::Build_Visual_Disk( int SCREEN_WIDTH )
|
|||
visual_partitions.back() ->drawingarea ->set_events(Gdk::BUTTON_PRESS_MASK);
|
||||
|
||||
//connect signal handlers
|
||||
visual_partitions.back() ->drawingarea ->signal_button_press_event().connect( sigc::bind<Partition>(sigc::mem_fun(*this, &VBox_VisualDisk::on_drawingarea_button_press), partitions[i] ) );
|
||||
visual_partitions.back() ->drawingarea ->signal_button_press_event().connect( sigc::bind<Partition>(sigc::mem_fun(*this, &VBox_VisualDisk::on_drawingarea_button_press), partition ) );
|
||||
visual_partitions.back() ->drawingarea ->signal_realize().connect( sigc::bind<Visual_Partition *>(sigc::mem_fun(*this, &VBox_VisualDisk::drawingarea_on_realize), visual_partitions.back() ) );
|
||||
visual_partitions.back() ->drawingarea ->signal_expose_event().connect( sigc::bind<Visual_Partition *>(sigc::mem_fun(*this, &VBox_VisualDisk::drawingarea_on_expose), visual_partitions.back() ));
|
||||
|
||||
//create pangolayout and see if it fits in the visual partition
|
||||
str_temp = partitions[i] .partition + "\n" + String::ucompose( _("%1 MB"), partitions[i] .Get_Length_MB() ) ;
|
||||
str_temp = partition .partition + "\n" + String::ucompose( _("%1 MB"), partition .Get_Length_MB() ) ;
|
||||
visual_partitions.back() ->pango_layout = visual_partitions.back() ->drawingarea ->create_pango_layout ( str_temp ) ;
|
||||
|
||||
visual_partitions.back() ->pango_layout ->get_pixel_size( x, y ) ;
|
||||
|
@ -143,20 +163,11 @@ void VBox_VisualDisk::Build_Visual_Disk( int SCREEN_WIDTH )
|
|||
|
||||
//tooltip
|
||||
str_temp = "" ;
|
||||
if ( partitions[i].type != GParted::UNALLOCATED )
|
||||
str_temp = partitions[i] .filesystem + "\n" ;
|
||||
if ( partition .type != GParted::UNALLOCATED )
|
||||
str_temp = partition .filesystem + "\n" ;
|
||||
|
||||
str_temp += partitions[i] .partition + "\n" + String::ucompose( _("%1 MB"), partitions[i] .Get_Length_MB() ) ;
|
||||
str_temp += partition .partition + "\n" + String::ucompose( _("%1 MB"), partition .Get_Length_MB() ) ;
|
||||
tooltips.set_tip( *(visual_partitions.back() ->drawingarea), str_temp ) ;
|
||||
|
||||
if ( partitions[i] .inside_extended )
|
||||
hbox_extended ->pack_start( *(visual_partitions.back() ->drawingarea), Gtk::PACK_SHRINK ) ;
|
||||
else
|
||||
hbox_disk ->pack_start( *(visual_partitions.back() ->drawingarea), Gtk::PACK_SHRINK ) ;
|
||||
|
||||
}
|
||||
|
||||
this ->show_all_children() ;
|
||||
}
|
||||
|
||||
|
||||
|
@ -234,7 +245,6 @@ void VBox_VisualDisk::Set_Selected( const Partition & partition )
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -543,7 +543,7 @@ void Win_GParted::Refresh_Visual( )
|
|||
|
||||
//count primary's, check for extended and logic and see if any logical is busy
|
||||
any_logic = any_extended = false;
|
||||
primary_count = highest_logic_busy = 0;
|
||||
primary_count = 0;
|
||||
for ( unsigned int t = 0 ; t < partitions .size( ) ; t++ )
|
||||
{
|
||||
if ( partitions[ t ] .partition == copied_partition .partition )
|
||||
|
@ -555,10 +555,7 @@ void Win_GParted::Refresh_Visual( )
|
|||
break;
|
||||
case GParted::EXTENDED : any_extended = true;
|
||||
primary_count++;
|
||||
break;
|
||||
case GParted::LOGICAL : any_logic = true;
|
||||
if ( partitions[t].busy && partitions[t].partition_number > highest_logic_busy )
|
||||
highest_logic_busy = partitions[t].partition_number ;
|
||||
any_logic = partitions[ t ] .logicals .size( ) -1 ;
|
||||
break;
|
||||
default : break;
|
||||
}
|
||||
|
@ -826,6 +823,23 @@ void Win_GParted::mouse_click( GdkEventButton *event, const Partition & partitio
|
|||
}
|
||||
}
|
||||
|
||||
bool Win_GParted::max_amount_prim_reached( )
|
||||
{
|
||||
//Display error if user tries to create more primary partitions than the partition table can hold.
|
||||
if ( ! selected_partition .inside_extended && primary_count >= devices[ current_device ] ->Get_Max_Amount_Of_Primary_Partitions( ) )
|
||||
{
|
||||
str_temp = "<span weight=\"bold\" size=\"larger\">" ;
|
||||
str_temp += String::ucompose( _("It is not possible to create more than %1 primary partitions"), devices[ current_device ] ->Get_Max_Amount_Of_Primary_Partitions( ) ) ;
|
||||
str_temp += "</span>\n\n" ;
|
||||
str_temp += _( "If you want more partitions you should first create an extended partition. Such a partition can contain other partitions.") ;
|
||||
|
||||
Gtk::MessageDialog dialog( *this, str_temp, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true ) ;
|
||||
dialog.run( ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
return false ;
|
||||
}
|
||||
|
||||
void Win_GParted::activate_resize()
|
||||
{
|
||||
|
@ -865,7 +879,16 @@ void Win_GParted::activate_resize()
|
|||
|
||||
|
||||
Dialog_Partition_Resize_Move dialog;
|
||||
|
||||
if ( selected_partition .type == GParted::LOGICAL )
|
||||
{
|
||||
unsigned int ext = 0 ;
|
||||
while ( ext < partitions .size( ) && partitions[ ext ] .type != GParted::EXTENDED ) ext++ ;
|
||||
dialog .Set_Data( selected_partition, partitions[ ext ] .logicals );
|
||||
}
|
||||
else
|
||||
dialog .Set_Data( selected_partition, partitions );
|
||||
|
||||
dialog .set_transient_for( *this ) ;
|
||||
|
||||
if ( dialog.run() == Gtk::RESPONSE_OK )
|
||||
|
@ -903,19 +926,8 @@ void Win_GParted::activate_copy()
|
|||
|
||||
void Win_GParted::activate_paste()
|
||||
{
|
||||
//Display error if user tries to create more primary partitions than the partition table can hold.
|
||||
if ( ! selected_partition.inside_extended && primary_count >=devices[ current_device ] ->Get_Max_Amount_Of_Primary_Partitions() )
|
||||
if ( ! max_amount_prim_reached( ) )
|
||||
{
|
||||
str_temp = "<span weight=\"bold\" size=\"larger\">" ;
|
||||
str_temp += String::ucompose( _("It is not possible to create more than %1 primary partitions"), devices[ current_device ] ->Get_Max_Amount_Of_Primary_Partitions() ) ;
|
||||
str_temp += "</span>\n\n" ;
|
||||
str_temp += _( "If you want more partitions you should first create an extended partition. Such a partition can contain other partitions.") ;
|
||||
|
||||
Gtk::MessageDialog dialog( *this, str_temp, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
|
||||
dialog.run();
|
||||
return;
|
||||
}
|
||||
|
||||
Dialog_Partition_Copy dialog ;
|
||||
dialog .Set_Data( selected_partition, copied_partition ) ;
|
||||
dialog .set_transient_for( *this );
|
||||
|
@ -925,24 +937,13 @@ void Win_GParted::activate_paste()
|
|||
dialog .hide( ) ;//i want to be sure the dialog is gone _before_ operationslist shows up (only matters if first operation)
|
||||
Add_Operation( GParted::COPY, dialog .Get_New_Partition( ) );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void Win_GParted::activate_new()
|
||||
{
|
||||
//Display error if user tries to create more primary partitions than the partition table can hold.
|
||||
if ( ! selected_partition.inside_extended && primary_count >= devices[ current_device ] ->Get_Max_Amount_Of_Primary_Partitions() )
|
||||
if ( ! max_amount_prim_reached( ) )
|
||||
{
|
||||
str_temp = "<span weight=\"bold\" size=\"larger\">" ;
|
||||
str_temp += String::ucompose( _("It is not possible to create more than %1 primary partitions"), devices[ current_device ] ->Get_Max_Amount_Of_Primary_Partitions() ) ;
|
||||
str_temp += "</span>\n\n" ;
|
||||
str_temp += _( "If you want more partitions you should first create an extended partition. Such a partition can contain other partitions.") ;
|
||||
|
||||
Gtk::MessageDialog dialog( *this, str_temp, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
|
||||
dialog.run();
|
||||
return;
|
||||
}
|
||||
|
||||
Dialog_Partition_New dialog;
|
||||
dialog .Set_Data( selected_partition, any_extended, new_count, FILESYSTEMS ) ;
|
||||
dialog .set_transient_for( *this );
|
||||
|
@ -953,7 +954,7 @@ void Win_GParted::activate_new()
|
|||
new_count++ ;
|
||||
Add_Operation( GParted::CREATE, dialog .Get_New_Partition( ) );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void Win_GParted::activate_delete()
|
||||
|
@ -962,7 +963,9 @@ void Win_GParted::activate_delete()
|
|||
//e.g. consider /dev/hda5 /dev/hda6 /dev/hda7. Now after removal of /dev/hda6, /dev/hda7 is renumbered to /dev/hda6
|
||||
//the new situation is now /dev/hda5 /dev/hda6. If /dev/hda7 was mounted the OS cannot find /dev/hda7 anymore and the results aren't that pretty
|
||||
//it seems best to check for this and prohibit deletion with some explanation to the user.
|
||||
if ( selected_partition.type == GParted::LOGICAL && selected_partition .status != GParted::STAT_NEW && selected_partition.partition_number < highest_logic_busy )
|
||||
if ( selected_partition .type == GParted::LOGICAL &&
|
||||
selected_partition .status != GParted::STAT_NEW &&
|
||||
selected_partition .partition_number < devices [ current_device ] -> Get_Highest_Logical_Busy( ) )
|
||||
{
|
||||
str_temp = "<span weight=\"bold\" size=\"larger\">" ;
|
||||
str_temp += _( "Unable to delete partition!") ;
|
||||
|
@ -1029,8 +1032,6 @@ void Win_GParted::activate_delete()
|
|||
}
|
||||
else //deletion of a real partition...
|
||||
Add_Operation( GParted::DELETE, selected_partition ); //in this case selected_partition is just a "dummy"
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue