added format_time() keep track of elapsed time between STATUS_EXECUTE and
* include/Utils.h, src/Utils.cc: added format_time() * include/OperationDetail.h, src/OperationDetail.cc: keep track of elapsed time between STATUS_EXECUTE and STATUS_[ERROR|SUCCES] * include/Dialog_Progress.h, src/Dialog_Progress.cc: show elapsed time in the details per (sub) process * src/GParted_Core.cc: use Utils::format_time()
This commit is contained in:
parent
82e6f6b132
commit
8abc8bf2e5
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
2006-08-21 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||
|
||||
* include/Utils.h,
|
||||
src/Utils.cc: added format_time()
|
||||
* include/OperationDetail.h,
|
||||
src/OperationDetail.cc: keep track of elapsed time between
|
||||
STATUS_EXECUTE and STATUS_[ERROR|SUCCES]
|
||||
* include/Dialog_Progress.h,
|
||||
src/Dialog_Progress.cc: show elapsed time in the details per (sub)
|
||||
process
|
||||
* src/GParted_Core.cc: use Utils::format_time()
|
||||
|
||||
2006-08-21 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||
|
||||
* src/FileSystem.cc: added nice -n 19, so that all extensive
|
||||
|
|
|
@ -75,16 +75,14 @@ private:
|
|||
struct treeview_operations_Columns : public Gtk::TreeModelColumnRecord
|
||||
{
|
||||
Gtk::TreeModelColumn<Glib::ustring> operation_description;
|
||||
Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > operation_icon;
|
||||
Gtk::TreeModelColumn<Glib::ustring> elapsed_time ;
|
||||
Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > status_icon;
|
||||
Gtk::TreeModelColumn<OperationDetailStatus> hidden_status ;
|
||||
|
||||
treeview_operations_Columns()
|
||||
{
|
||||
add( operation_description );
|
||||
add( operation_icon );
|
||||
add( elapsed_time );
|
||||
add( status_icon ) ;
|
||||
add( hidden_status ) ;
|
||||
}
|
||||
};
|
||||
treeview_operations_Columns treeview_operations_columns;
|
||||
|
|
|
@ -55,6 +55,7 @@ public:
|
|||
OperationDetailStatus get_status() const ;
|
||||
void set_treepath( const Glib::ustring & treepath ) ;
|
||||
Glib::ustring get_treepath() const ;
|
||||
Glib::ustring get_elapsed_time() const ;
|
||||
|
||||
void add_child( const OperationDetail & operationdetail ) ;
|
||||
std::vector<OperationDetail> & get_childs() ;
|
||||
|
@ -75,6 +76,7 @@ private:
|
|||
Glib::ustring treepath ;
|
||||
|
||||
std::vector<OperationDetail> sub_details ;
|
||||
std::time_t time_start, time_elapsed ;
|
||||
};
|
||||
|
||||
} //GParted
|
||||
|
|
|
@ -124,6 +124,7 @@ public:
|
|||
static Glib::RefPtr<Gdk::Pixbuf> get_color_as_pixbuf( FILESYSTEM filesystem, int width, int height ) ;
|
||||
static Glib::ustring get_filesystem_string( FILESYSTEM filesystem ) ;
|
||||
static Glib::ustring format_size( Sector size ) ;
|
||||
static Glib::ustring format_time( std::time_t seconds ) ;
|
||||
static double sector_to_unit( Sector sectors, SIZE_UNIT size_unit ) ;
|
||||
static int execute_command( const Glib::ustring & command ) ;
|
||||
static int execute_command( const Glib::ustring & command,
|
||||
|
|
|
@ -71,11 +71,16 @@ Dialog_Progress::Dialog_Progress( const std::vector<Operation *> & operations )
|
|||
treestore_operations = Gtk::TreeStore::create( treeview_operations_columns );
|
||||
treeview_operations .set_model( treestore_operations );
|
||||
treeview_operations .set_headers_visible( false );
|
||||
treeview_operations .append_column( "", treeview_operations_columns .operation_icon );
|
||||
treeview_operations .append_column( "", treeview_operations_columns .operation_description );
|
||||
treeview_operations .append_column( "", treeview_operations_columns .status_icon );
|
||||
treeview_operations .set_size_request( 500, 250 ) ;
|
||||
treeview_operations .set_rules_hint( true ) ;
|
||||
treeview_operations .set_size_request( 500, 250 ) ;
|
||||
treeview_operations .append_column( "", treeview_operations_columns .operation_description );
|
||||
treeview_operations .append_column( "", treeview_operations_columns .elapsed_time );
|
||||
treeview_operations .append_column( "", treeview_operations_columns .status_icon );
|
||||
|
||||
treeview_operations .get_column( 0 ) ->set_expand( true ) ;
|
||||
treeview_operations .get_column( 0 ) ->set_cell_data_func(
|
||||
* ( treeview_operations .get_column( 0 ) ->get_first_cell_renderer() ),
|
||||
sigc::mem_fun(*this, &Dialog_Progress::on_cell_data_description) ) ;
|
||||
|
||||
//fill 'er up
|
||||
for ( unsigned int t = 0 ; t < operations .size() ; t++ )
|
||||
|
@ -84,17 +89,10 @@ Dialog_Progress::Dialog_Progress( const std::vector<Operation *> & operations )
|
|||
this ->operations[ t ] ->operation_detail .set_treepath( Utils::num_to_str( t ) ) ;
|
||||
|
||||
treerow = *( treestore_operations ->append() );
|
||||
treerow[ treeview_operations_columns .operation_icon ] = operations[ t ] ->icon ;
|
||||
treerow[ treeview_operations_columns .operation_description ] =
|
||||
this ->operations[ t ] ->operation_detail .get_description() ;
|
||||
treerow[ treeview_operations_columns .hidden_status ] = STATUS_NONE ;
|
||||
}
|
||||
|
||||
treeview_operations .get_column( 1 ) ->set_expand( true ) ;
|
||||
treeview_operations .get_column( 1 ) ->set_cell_data_func(
|
||||
* ( treeview_operations .get_column( 1 ) ->get_first_cell_renderer() ),
|
||||
sigc::mem_fun(*this, &Dialog_Progress::on_cell_data_description) ) ;
|
||||
|
||||
scrolledwindow .set_shadow_type( Gtk::SHADOW_ETCHED_IN ) ;
|
||||
scrolledwindow .set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC ) ;
|
||||
scrolledwindow .add( treeview_operations ) ;
|
||||
|
@ -123,6 +121,7 @@ void Dialog_Progress::on_signal_update( const OperationDetail & operationdetail
|
|||
Gtk::TreeRow treerow = *iter ;
|
||||
|
||||
treerow[ treeview_operations_columns .operation_description ] = operationdetail .get_description() ;
|
||||
treerow[ treeview_operations_columns .elapsed_time ] = operationdetail .get_elapsed_time() ;
|
||||
|
||||
switch ( operationdetail .get_status() )
|
||||
{
|
||||
|
@ -161,11 +160,10 @@ void Dialog_Progress::on_signal_update( const OperationDetail & operationdetail
|
|||
{
|
||||
unsigned int pos = operationdetail .get_treepath() .rfind( ":" ) ;
|
||||
if ( pos >= 0 && pos < operationdetail .get_treepath() .length() )
|
||||
iter= treestore_operations ->get_iter(
|
||||
operationdetail .get_treepath() .substr( 0,
|
||||
operationdetail .get_treepath() .rfind( ":" ) ) ) ;
|
||||
iter = treestore_operations ->get_iter( operationdetail .get_treepath()
|
||||
.substr( 0, operationdetail .get_treepath() .rfind( ":" ) ) ) ;
|
||||
else
|
||||
iter= treestore_operations ->get_iter( operationdetail .get_treepath() ) ;
|
||||
iter = treestore_operations ->get_iter( operationdetail .get_treepath() ) ;
|
||||
|
||||
if ( iter)
|
||||
{
|
||||
|
@ -361,6 +359,8 @@ void Dialog_Progress::echo_operation_details( const OperationDetail & operationd
|
|||
out << "<TR>" << std::endl ;
|
||||
out << "<TD colspan=2>" << std::endl ;
|
||||
out << temp ;
|
||||
if ( ! operationdetail .get_elapsed_time() .empty() )
|
||||
out << " " << operationdetail .get_elapsed_time() ;
|
||||
|
||||
//show status...
|
||||
if ( operationdetail .get_status() != STATUS_NONE )
|
||||
|
|
|
@ -1639,29 +1639,10 @@ void GParted_Core::set_progress_info( Sector total,
|
|||
|
||||
std::time_t time_remaining = Utils::round( (1.0 - operationdetail .fraction) * sec_per_frac ) ;
|
||||
|
||||
//format it a bit..
|
||||
Glib::ustring time ;
|
||||
|
||||
int unit = static_cast<int>( time_remaining / 3600 ) ;
|
||||
if ( unit < 10 )
|
||||
time += "0" ;
|
||||
time += Utils::num_to_str( unit ) + ":" ;
|
||||
time_remaining %= 3600 ;
|
||||
|
||||
unit = static_cast<int>( time_remaining / 60 ) ;
|
||||
if ( unit < 10 )
|
||||
time += "0" ;
|
||||
time += Utils::num_to_str( unit ) + ":" ;
|
||||
time_remaining %= 60 ;
|
||||
|
||||
if ( time_remaining < 10 )
|
||||
time += "0" ;
|
||||
time += Utils::num_to_str( time_remaining ) ;
|
||||
|
||||
operationdetail .progress_text = String::ucompose( _("%1 of %2 copied (%3 remaining)"),
|
||||
Utils::format_size( done ),
|
||||
Utils::format_size( total ),
|
||||
time ) ;
|
||||
Utils::format_time( time_remaining) ) ;
|
||||
|
||||
operationdetail .set_description( String::ucompose( _("%1 of %2 copied"), done, total ), FONT_ITALIC ) ;
|
||||
}
|
||||
|
|
|
@ -24,16 +24,18 @@ namespace GParted
|
|||
|
||||
OperationDetail::OperationDetail()
|
||||
{
|
||||
status = STATUS_NONE ;
|
||||
set_status( STATUS_NONE ) ;
|
||||
fraction = -1 ;
|
||||
time_elapsed = -1 ;
|
||||
}
|
||||
|
||||
OperationDetail::OperationDetail( const Glib::ustring & description, OperationDetailStatus status, Font font )
|
||||
{
|
||||
set_description( description, font ) ;
|
||||
this ->status = status ;
|
||||
set_status( status ) ;
|
||||
|
||||
fraction = -1 ;
|
||||
time_elapsed = -1 ;
|
||||
}
|
||||
|
||||
void OperationDetail::set_description( const Glib::ustring & description, Font font )
|
||||
|
@ -54,8 +56,7 @@ void OperationDetail::set_description( const Glib::ustring & description, Font f
|
|||
break ;
|
||||
}
|
||||
|
||||
if ( ! treepath .empty() )
|
||||
on_update( *this ) ;
|
||||
on_update( *this ) ;
|
||||
}
|
||||
|
||||
Glib::ustring OperationDetail::get_description() const
|
||||
|
@ -64,9 +65,24 @@ Glib::ustring OperationDetail::get_description() const
|
|||
}
|
||||
|
||||
void OperationDetail::set_status( OperationDetailStatus status )
|
||||
{
|
||||
{
|
||||
if ( this ->status != STATUS_ERROR )
|
||||
{
|
||||
switch ( status )
|
||||
{
|
||||
case STATUS_EXECUTE:
|
||||
time_elapsed = -1 ;
|
||||
time_start = std::time( NULL ) ;
|
||||
break ;
|
||||
case STATUS_ERROR:
|
||||
case STATUS_SUCCES:
|
||||
time_elapsed = std::time( NULL ) - time_start ;
|
||||
break ;
|
||||
|
||||
default:
|
||||
break ;
|
||||
}
|
||||
|
||||
this ->status = status ;
|
||||
on_update( *this ) ;
|
||||
}
|
||||
|
@ -86,6 +102,14 @@ Glib::ustring OperationDetail::get_treepath() const
|
|||
{
|
||||
return treepath ;
|
||||
}
|
||||
|
||||
Glib::ustring OperationDetail::get_elapsed_time() const
|
||||
{
|
||||
if ( time_elapsed >= 0 )
|
||||
return Utils::format_time( time_elapsed ) ;
|
||||
|
||||
return "" ;
|
||||
}
|
||||
|
||||
void OperationDetail::add_child( const OperationDetail & operationdetail )
|
||||
{
|
||||
|
@ -118,7 +142,8 @@ OperationDetail & OperationDetail::get_last_child()
|
|||
|
||||
void OperationDetail::on_update( const OperationDetail & operationdetail )
|
||||
{
|
||||
signal_update .emit( operationdetail ) ;
|
||||
if ( ! treepath .empty() )
|
||||
signal_update .emit( operationdetail ) ;
|
||||
}
|
||||
|
||||
} //GParted
|
||||
|
|
26
src/Utils.cc
26
src/Utils.cc
|
@ -163,6 +163,32 @@ Glib::ustring Utils::format_size( Sector size )
|
|||
return String::ucompose( _("%1 TiB"), ss .str() ) ;
|
||||
}
|
||||
}
|
||||
|
||||
Glib::ustring Utils::format_time( std::time_t seconds )
|
||||
{
|
||||
Glib::ustring time ;
|
||||
|
||||
int unit = static_cast<int>( seconds / 3600 ) ;
|
||||
if ( unit > 0 )
|
||||
{
|
||||
if ( unit < 10 )
|
||||
time += "0" ;
|
||||
time += num_to_str( unit ) + ":" ;
|
||||
seconds %= 3600 ;
|
||||
}
|
||||
|
||||
unit = static_cast<int>( seconds / 60 ) ;
|
||||
if ( unit < 10 )
|
||||
time += "0" ;
|
||||
time += num_to_str( unit ) + ":" ;
|
||||
seconds %= 60 ;
|
||||
|
||||
if ( seconds < 10 )
|
||||
time += "0" ;
|
||||
time += num_to_str( seconds ) ;
|
||||
|
||||
return time ;
|
||||
}
|
||||
|
||||
double Utils::sector_to_unit( Sector sectors, SIZE_UNIT size_unit )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue