mirror of
https://gitlab.gnome.org/GNOME/gparted
synced 2024-10-30 09:08:28 +00:00
Update ext2 create progress tracker to use the new ProgressBar (#760709)
Adapt the ext2 create file system progress tracker to used the new ProgressBar class. Also make it track when the text progress indicator completes so that the progress bar can be stopped as well as started when needed. Bug 760709 - Add progress bars to XFS and EXT2/3/4 file system specific copy methods
This commit is contained in:
parent
608060f82d
commit
ac949e3003
1 changed files with 15 additions and 9 deletions
24
src/ext2.cc
24
src/ext2.cc
|
@ -325,16 +325,22 @@ void ext2::resize_progress( OperationDetail *operationdetail )
|
|||
|
||||
void ext2::create_progress( OperationDetail *operationdetail )
|
||||
{
|
||||
Glib::ustring ss;
|
||||
size_t p = output.find_last_of('\n');
|
||||
// looks like "Writing inode tables: xx/yy"
|
||||
if ( p == output.npos )
|
||||
return;
|
||||
ss = output.substr( p );
|
||||
int x, y;
|
||||
if ( sscanf( ss.c_str(), "\nWriting inode tables: %d/%d", &x, &y ) == 2 )
|
||||
ProgressBar & progressbar = operationdetail->get_progressbar();
|
||||
Glib::ustring line = Utils::last_line( output );
|
||||
// Text progress on the LAST LINE looks like "Writing inode tables: 105/1600"
|
||||
long long progress, target;
|
||||
if ( sscanf( line.c_str(), "Writing inode tables: %Ld/%Ld", &progress, &target ) == 2 )
|
||||
{
|
||||
operationdetail->fraction = (double)x / y;
|
||||
if ( ! progressbar.running() )
|
||||
progressbar.start( (double)target );
|
||||
progressbar.update( (double)progress );
|
||||
operationdetail->signal_update( *operationdetail );
|
||||
}
|
||||
// Or when finished, on any line, ...
|
||||
else if ( output.find( "Writing inode tables: done" ) != output.npos )
|
||||
{
|
||||
if ( progressbar.running() )
|
||||
progressbar.stop();
|
||||
operationdetail->signal_update( *operationdetail );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue