more i18n and some code cleanups
This commit is contained in:
parent
adbcdfa80a
commit
201fdcb8e8
|
@ -28,11 +28,10 @@ class Dialog_Partition_Copy : public Dialog_Base_Partition
|
||||||
public:
|
public:
|
||||||
Dialog_Partition_Copy() ;
|
Dialog_Partition_Copy() ;
|
||||||
void Set_Data( Partition & selected_partition, Partition & copied_partition );
|
void Set_Data( Partition & selected_partition, Partition & copied_partition );
|
||||||
|
Partition Get_New_Partition() ;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}//GParted
|
}//GParted
|
||||||
|
|
|
@ -41,7 +41,6 @@ class Operation
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Operation( Device *device, Device *source_device, const Partition &, const Partition &,OperationType );
|
Operation( Device *device, Device *source_device, const Partition &, const Partition &,OperationType );
|
||||||
Glib::ustring Get_String();
|
|
||||||
|
|
||||||
//this one can be a little confusing, it *DOES NOT* change any visual representation. It only applies the operation to the list with partitions.
|
//this one can be a little confusing, it *DOES NOT* change any visual representation. It only applies the operation to the list with partitions.
|
||||||
//this new list can be used to change the visual representation. For real writing to disk, see Apply_To_Disk()
|
//this new list can be used to change the visual representation. For real writing to disk, see Apply_To_Disk()
|
||||||
|
@ -54,6 +53,7 @@ public:
|
||||||
Glib::ustring device_path, source_device_path ;
|
Glib::ustring device_path, source_device_path ;
|
||||||
OperationType operationtype;
|
OperationType operationtype;
|
||||||
Partition partition_new; //the new situation ( can be an whole new partition or simply the old one with a new size or.... )
|
Partition partition_new; //the new situation ( can be an whole new partition or simply the old one with a new size or.... )
|
||||||
|
Glib::ustring str_operation ;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<Partition> Apply_Delete_To_Visual( std::vector<Partition> & partitions );
|
std::vector<Partition> Apply_Delete_To_Visual( std::vector<Partition> & partitions );
|
||||||
|
@ -62,6 +62,7 @@ private:
|
||||||
std::vector<Partition> Apply_Resize_Move_Extended_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 );
|
std::vector<Partition> Apply_Convert_To_Visual( std::vector<Partition> & partitions );
|
||||||
|
|
||||||
|
Glib::ustring Get_String(); //only used during in c'tor
|
||||||
void Show_Error( const Glib::ustring & message ) ;
|
void Show_Error( const Glib::ustring & message ) ;
|
||||||
|
|
||||||
Partition partition_original; //the original situation
|
Partition partition_original; //the original situation
|
||||||
|
|
|
@ -63,6 +63,12 @@ enum PartitionType {
|
||||||
UNALLOCATED = 3
|
UNALLOCATED = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum PartitionStatus {
|
||||||
|
STAT_REAL = 1,
|
||||||
|
STAT_NEW = 2,
|
||||||
|
STAT_COPY = 3
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
enum FileSystem {
|
enum FileSystem {
|
||||||
ext2 = 0,
|
ext2 = 0,
|
||||||
|
@ -113,6 +119,7 @@ public:
|
||||||
Glib::ustring partition;//the symbolic path (e.g. /dev/hda1 )
|
Glib::ustring partition;//the symbolic path (e.g. /dev/hda1 )
|
||||||
int partition_number;
|
int partition_number;
|
||||||
PartitionType type;// UNALLOCATED, PRIMARY, LOGICAL, etc...
|
PartitionType type;// UNALLOCATED, PRIMARY, LOGICAL, etc...
|
||||||
|
PartitionStatus status; //STAT_REAL, STAT_NEW, etc..
|
||||||
Glib::ustring filesystem;// ext2, ext3, ntfs, etc....
|
Glib::ustring filesystem;// ext2, ext3, ntfs, etc....
|
||||||
Sector sector_start;
|
Sector sector_start;
|
||||||
Sector sector_end;
|
Sector sector_end;
|
||||||
|
|
|
@ -74,10 +74,19 @@ void Dialog_Partition_Copy::Set_Data( Partition & selected_partition, Partition
|
||||||
this ->selected_partition .inside_extended = selected_partition .inside_extended ;
|
this ->selected_partition .inside_extended = selected_partition .inside_extended ;
|
||||||
selected_partition .inside_extended ? this ->selected_partition .type = GParted::LOGICAL : this ->selected_partition .type = GParted::PRIMARY ;
|
selected_partition .inside_extended ? this ->selected_partition .type = GParted::LOGICAL : this ->selected_partition .type = GParted::PRIMARY ;
|
||||||
|
|
||||||
|
|
||||||
GRIP = false ;
|
GRIP = false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Partition Dialog_Partition_Copy::Get_New_Partition()
|
||||||
|
{
|
||||||
|
//first call baseclass to get the correct new partition
|
||||||
|
selected_partition = Dialog_Base_Partition::Get_New_Partition() ;
|
||||||
|
|
||||||
|
//set proper name and status for partition
|
||||||
|
// selected_partition.partition = String::ucompose( _("copy from %1"), selected_partition .partition );
|
||||||
|
selected_partition.status = GParted::STAT_COPY ;
|
||||||
|
|
||||||
|
return selected_partition ;
|
||||||
|
}
|
||||||
|
|
||||||
} //GParted
|
} //GParted
|
||||||
|
|
|
@ -155,11 +155,11 @@ void Dialog_Partition_Info::Display_Info()
|
||||||
|
|
||||||
label ->set_text( label ->get_text() + (Glib::ustring) _( "Flags:" ) + "\n\n" ) ; os << partition .flags << "\n\n";
|
label ->set_text( label ->get_text() + (Glib::ustring) _( "Flags:" ) + "\n\n" ) ; os << partition .flags << "\n\n";
|
||||||
|
|
||||||
if ( partition.type != GParted::UNALLOCATED && partition .partition.substr( 0, 3 ) != "New" )
|
if ( partition.type != GParted::UNALLOCATED && partition .status != GParted::STAT_NEW )
|
||||||
{
|
{
|
||||||
label ->set_text( label ->get_text() + (Glib::ustring) _("Path:" ) + "\n" ) ; os << partition.partition << "\n";
|
label ->set_text( label ->get_text() + (Glib::ustring) _("Path:" ) + "\n" ) ; os << partition.partition << "\n";
|
||||||
|
|
||||||
//get realpath
|
//get realpath (this sucks)
|
||||||
char real_path[4096] ;
|
char real_path[4096] ;
|
||||||
realpath( partition.partition.c_str() , real_path );
|
realpath( partition.partition.c_str() , real_path );
|
||||||
|
|
||||||
|
|
|
@ -135,10 +135,11 @@ Partition Dialog_Partition_New::Get_New_Partition()
|
||||||
if ( new_end > selected_partition.sector_end )
|
if ( new_end > selected_partition.sector_end )
|
||||||
new_end = selected_partition.sector_end ;
|
new_end = selected_partition.sector_end ;
|
||||||
|
|
||||||
os << "New Partition #" << new_count;
|
os << String::ucompose( _("New Partition #%1"), new_count ) ;
|
||||||
|
part_temp .status = GParted::STAT_NEW ;
|
||||||
part_temp .Set( os.str(), new_count, part_type , filesystems[ optionmenu_filesystem.get_history() ], new_start, new_end, -1, selected_partition.inside_extended, false) ; os.str("") ;
|
part_temp .Set( os.str(), new_count, part_type , filesystems[ optionmenu_filesystem.get_history() ], new_start, new_end, -1, selected_partition.inside_extended, false) ; os.str("") ;
|
||||||
|
|
||||||
//THIS SHOULD PROBABLY BE A SETTING IN USERSPACE! ( grow new partition a bit if freespaces are < 1 MB )
|
//grow new partition a bit if freespaces are < 1 MB
|
||||||
if ( (part_temp.sector_start - selected_partition.sector_start) < MEGABYTE )
|
if ( (part_temp.sector_start - selected_partition.sector_start) < MEGABYTE )
|
||||||
part_temp.sector_start = selected_partition.sector_start ;
|
part_temp.sector_start = selected_partition.sector_start ;
|
||||||
if ( (selected_partition.sector_end - part_temp.sector_end) < MEGABYTE )
|
if ( (selected_partition.sector_end - part_temp.sector_end) < MEGABYTE )
|
||||||
|
|
|
@ -31,6 +31,13 @@ Operation::Operation( Device *device, Device *source_device, const Partition & p
|
||||||
this->partition_original = partition_original;
|
this->partition_original = partition_original;
|
||||||
this->partition_new = partition_new;
|
this->partition_new = partition_new;
|
||||||
this->operationtype = operationtype;
|
this->operationtype = operationtype;
|
||||||
|
|
||||||
|
str_operation = Get_String() ;
|
||||||
|
|
||||||
|
//not the nicest place to put this, but definetly the most efficient :)
|
||||||
|
if ( operationtype == COPY )
|
||||||
|
this->partition_new .partition = String::ucompose( _("copy of %1"), this->partition_new .partition );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -172,7 +179,7 @@ std::vector<Partition> Operation::Apply_Delete_To_Visual( std::vector<Partition>
|
||||||
|
|
||||||
|
|
||||||
//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 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.partition.substr( 0, 3 ) != "New" )
|
if ( partition_original.type == GParted::LOGICAL && partition_original .status != GParted::STAT_NEW )
|
||||||
for ( t=0;t<partitions.size() ;t++)
|
for ( t=0;t<partitions.size() ;t++)
|
||||||
if ( partitions[t].type == GParted::LOGICAL && partitions[t].partition_number > partition_original.partition_number )
|
if ( partitions[t].type == GParted::LOGICAL && partitions[t].partition_number > partition_original.partition_number )
|
||||||
partitions[t].Update_Number( partitions[t].partition_number -1 );
|
partitions[t].Update_Number( partitions[t].partition_number -1 );
|
||||||
|
@ -236,10 +243,6 @@ std::vector<Partition> Operation::Apply_Create_To_Visual( std::vector<Partition>
|
||||||
partitions.insert( partitions.begin() + t +1, partition_temp );
|
partitions.insert( partitions.begin() + t +1, partition_temp );
|
||||||
}
|
}
|
||||||
|
|
||||||
//set proper name for partition if COPY
|
|
||||||
if ( operationtype == GParted::COPY )
|
|
||||||
partitions[ t ] .partition = "copy from " + partitions[ t ] .partition ;
|
|
||||||
|
|
||||||
return partitions;
|
return partitions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ namespace GParted
|
||||||
Partition::Partition( )
|
Partition::Partition( )
|
||||||
{
|
{
|
||||||
this ->error = ""; //just to be sure...
|
this ->error = ""; //just to be sure...
|
||||||
|
this ->status = GParted::STAT_REAL ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Partition::Set( const Glib::ustring & partition,
|
void Partition::Set( const Glib::ustring & partition,
|
||||||
|
@ -52,7 +53,9 @@ void Partition::Set( const Glib::ustring & partition,
|
||||||
void Partition::Set_Unallocated( Sector sector_start, Sector sector_end, bool inside_extended )
|
void Partition::Set_Unallocated( Sector sector_start, Sector sector_end, bool inside_extended )
|
||||||
{
|
{
|
||||||
this ->Set( "Unallocated", -1, GParted::UNALLOCATED, "unallocated", sector_start, sector_end , -1, inside_extended, false);
|
this ->Set( "Unallocated", -1, GParted::UNALLOCATED, "unallocated", sector_start, sector_end , -1, inside_extended, false);
|
||||||
this ->error = "" ;this ->flags = "" ;
|
this ->error = "" ;
|
||||||
|
this ->flags = "" ;
|
||||||
|
this ->status = GParted::STAT_REAL ;
|
||||||
}
|
}
|
||||||
|
|
||||||
Glib::ustring Partition::Get_Color( const Glib::ustring & filesystem )
|
Glib::ustring Partition::Get_Color( const Glib::ustring & filesystem )
|
||||||
|
|
|
@ -429,7 +429,7 @@ void Win_GParted::Refresh_Visual( )
|
||||||
|
|
||||||
treerow = *(liststore_operations->append());
|
treerow = *(liststore_operations->append());
|
||||||
treerow[ treeview_operations_columns.operation_number ] = t +1;
|
treerow[ treeview_operations_columns.operation_number ] = t +1;
|
||||||
treerow[ treeview_operations_columns.operation_description ] = operations[t].Get_String() ;
|
treerow[ treeview_operations_columns.operation_description ] = operations[t] .str_operation ;
|
||||||
switch ( operations[t].operationtype )
|
switch ( operations[t].operationtype )
|
||||||
{
|
{
|
||||||
case GParted::DELETE : treerow[ treeview_operations_columns.operation_icon ] =render_icon(Gtk::Stock::DELETE, Gtk::ICON_SIZE_MENU);
|
case GParted::DELETE : treerow[ treeview_operations_columns.operation_icon ] =render_icon(Gtk::Stock::DELETE, Gtk::ICON_SIZE_MENU);
|
||||||
|
@ -508,8 +508,7 @@ bool Win_GParted::Quit_Check_Operations()
|
||||||
if ( operations.size() )
|
if ( operations.size() )
|
||||||
{
|
{
|
||||||
os << "<span weight=\"bold\" size=\"larger\">" + (Glib::ustring) _( "Quit GParted?" ) + "</span>\n\n" ;
|
os << "<span weight=\"bold\" size=\"larger\">" + (Glib::ustring) _( "Quit GParted?" ) + "</span>\n\n" ;
|
||||||
// os << operations.size() << " ";
|
|
||||||
// operations.size() == 1 ? os << "operation is currently pending..." : os << "operations are currently pending..." ;
|
|
||||||
if ( operations .size() != 1 )
|
if ( operations .size() != 1 )
|
||||||
os << String::ucompose( _("%1 operations are currently pending."), operations .size() ) ;
|
os << String::ucompose( _("%1 operations are currently pending."), operations .size() ) ;
|
||||||
else
|
else
|
||||||
|
@ -570,7 +569,7 @@ void Win_GParted::Set_Valid_Operations()
|
||||||
allow_resize( true ) ;
|
allow_resize( true ) ;
|
||||||
|
|
||||||
//only allow copying of real partitions
|
//only allow copying of real partitions
|
||||||
if ( selected_partition .partition.substr( 0, 3 ) != "New" && selected_partition .partition.substr( 0, 4 ) != "copy" )
|
if ( selected_partition .status != GParted::STAT_NEW && selected_partition .status != GParted::STAT_COPY )
|
||||||
allow_copy( true ) ;
|
allow_copy( true ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -747,7 +746,7 @@ void Win_GParted::activate_resize()
|
||||||
dialog.hide() ;//i want to be sure the dialog is gone _before_ operationslist shows up (only matters if first operation)
|
dialog.hide() ;//i want to be sure the dialog is gone _before_ operationslist shows up (only matters if first operation)
|
||||||
|
|
||||||
//if selected_partition is NEW we simply remove the NEW operation from the list and add it again with the new size and position ( unless it's an EXTENDED )
|
//if selected_partition is NEW we simply remove the NEW operation from the list and add it again with the new size and position ( unless it's an EXTENDED )
|
||||||
if ( selected_partition .partition.substr( 0, 3 ) == "New" && selected_partition.type != GParted::EXTENDED )
|
if ( selected_partition .status == GParted::STAT_NEW && selected_partition.type != GParted::EXTENDED )
|
||||||
{
|
{
|
||||||
//remove operation which creates this partition
|
//remove operation which creates this partition
|
||||||
for ( unsigned int t=0;t<operations.size() ; t++ )
|
for ( unsigned int t=0;t<operations.size() ; t++ )
|
||||||
|
@ -836,7 +835,7 @@ 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
|
//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
|
//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.
|
//it seems best to check for this and prohibit deletion with some explanation to the user.
|
||||||
if ( selected_partition.type == GParted::LOGICAL && selected_partition .partition.substr( 0, 3 ) != "New" && selected_partition.partition_number < highest_logic_busy )
|
if ( selected_partition.type == GParted::LOGICAL && selected_partition .status != GParted::STAT_NEW && selected_partition.partition_number < highest_logic_busy )
|
||||||
{
|
{
|
||||||
os << "<span weight=\"bold\" size=\"larger\">" << _( "Unable to delete partition!") << "</span>\n\n" ;
|
os << "<span weight=\"bold\" size=\"larger\">" << _( "Unable to delete partition!") << "</span>\n\n" ;
|
||||||
os << String::ucompose( _("Please unmount any logical partitions having a number higher than %1"), selected_partition.partition_number ) ;
|
os << String::ucompose( _("Please unmount any logical partitions having a number higher than %1"), selected_partition.partition_number ) ;
|
||||||
|
@ -869,7 +868,7 @@ void Win_GParted::activate_delete()
|
||||||
|
|
||||||
//if deleted one is NEW, it doesn't make sense to add it to the operationslist, we erase its creation
|
//if deleted one is NEW, it doesn't make sense to add it to the operationslist, we erase its creation
|
||||||
//and possible modifications like resize etc.. from the operationslist. Calling Refresh_Visual will wipe every memory of its existence ;-)
|
//and possible modifications like resize etc.. from the operationslist. Calling Refresh_Visual will wipe every memory of its existence ;-)
|
||||||
if ( selected_partition .partition.substr( 0, 3 ) == "New" )
|
if ( selected_partition .status == GParted::STAT_NEW )
|
||||||
{
|
{
|
||||||
//remove all operations done on this new partition (this includes creation)
|
//remove all operations done on this new partition (this includes creation)
|
||||||
for ( int t=0;t<(int) operations.size() ; t++ ) //i removed the unsigned 'cause t will be negative at times...
|
for ( int t=0;t<(int) operations.size() ; t++ ) //i removed the unsigned 'cause t will be negative at times...
|
||||||
|
@ -885,7 +884,7 @@ void Win_GParted::activate_delete()
|
||||||
//determine lowest possible new_count
|
//determine lowest possible new_count
|
||||||
new_count = 0 ;
|
new_count = 0 ;
|
||||||
for ( unsigned int t=0;t<operations.size() ; t++ )
|
for ( unsigned int t=0;t<operations.size() ; t++ )
|
||||||
if ( operations[t] .partition_new .partition .substr( 0, 3 ) == "New" && operations[t] .partition_new .partition_number > new_count )
|
if ( operations[t] .partition_new .status == GParted::STAT_NEW && operations[t] .partition_new .partition_number > new_count )
|
||||||
new_count = operations[t] .partition_new .partition_number ;
|
new_count = operations[t] .partition_new .partition_number ;
|
||||||
|
|
||||||
new_count += 1 ;
|
new_count += 1 ;
|
||||||
|
@ -953,7 +952,7 @@ void Win_GParted::activate_convert( const Glib::ustring & new_fs )
|
||||||
|
|
||||||
|
|
||||||
//if selected_partition is NEW we simply remove the NEW operation from the list and add it again with the new filesystem
|
//if selected_partition is NEW we simply remove the NEW operation from the list and add it again with the new filesystem
|
||||||
if ( selected_partition .partition.substr( 0, 3 ) == "New" )
|
if ( selected_partition .status == GParted::STAT_NEW )
|
||||||
{
|
{
|
||||||
//remove operation which creates this partition
|
//remove operation which creates this partition
|
||||||
for ( unsigned int t=0;t<operations.size() ; t++ )
|
for ( unsigned int t=0;t<operations.size() ; t++ )
|
||||||
|
@ -1002,7 +1001,7 @@ void Win_GParted::activate_apply()
|
||||||
dialog.hide() ; //hide confirmationdialog
|
dialog.hide() ; //hide confirmationdialog
|
||||||
|
|
||||||
apply = true;
|
apply = true;
|
||||||
dialog_progress = new Dialog_Progress ( operations.size(), operations.front().Get_String() ) ;
|
dialog_progress = new Dialog_Progress ( operations.size(), operations.front() .str_operation ) ;
|
||||||
s3 = dispatcher_next_operation.connect( sigc::mem_fun(*dialog_progress, &Dialog_Progress::Set_Next_Operation) );
|
s3 = dispatcher_next_operation.connect( sigc::mem_fun(*dialog_progress, &Dialog_Progress::Set_Next_Operation) );
|
||||||
thread_operations = Glib::Thread::create(SigC::slot_class(*this, &Win_GParted::apply_operations_thread), true);
|
thread_operations = Glib::Thread::create(SigC::slot_class(*this, &Win_GParted::apply_operations_thread), true);
|
||||||
|
|
||||||
|
@ -1082,7 +1081,7 @@ void Win_GParted::apply_operations_thread()
|
||||||
|
|
||||||
if ( t < operations .size() -1 )
|
if ( t < operations .size() -1 )
|
||||||
{
|
{
|
||||||
dialog_progress ->current_operation = operations[ t +1 ] .Get_String() ;
|
dialog_progress ->current_operation = operations[ t +1 ] .str_operation ;
|
||||||
dispatcher_next_operation() ;
|
dispatcher_next_operation() ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue