gparted/src/ProgressBar.cc

135 lines
3.6 KiB
C++
Raw Permalink Normal View History

Write a generic progress bar class (#760709) Write a generic progress bar class. Has the following features: * Has separate progress and target numbers, rather than a single completion fraction, to enable the the next feature. * Optionally generates text reporting the amount of data copied using the progress and target numbers like this: "1.00 MiB of 16.00 MiB copied" * After running for 5 seconds, also add estimated remaining time. (Waits to allow the data copying rate to settle down a little before estimating the remaining time). Looks like this: "1.00 MiB of 16.00 MiB copied (00:01:59) remaining)" The ProgressBar class is not driving the visual progress bar yet. It has just been added into the internal block copy algorithm and generates debug messages showing the progress bar is operating correctly. Debugging looks like this: DEBUG: ProgressBar::start(target=2.0636e+09, text_mode=PROGRESSBAR_TEXT_COPY_BYTES) DEBUG: ProgressBar::update(progress=1.30023e+08) m_fraction=0.0630081 m_text="124.00 MiB of 1.92 GiB copied" DEBUG: ProgressBar::update(progress=2.67387e+08) m_fraction=0.129573 m_text="255.00 MiB of 1.92 GiB copied" DEBUG: ProgressBar::update(progress=4.0475e+08) m_fraction=0.196138 m_text="386.00 MiB of 1.92 GiB copied" ... DEBUG: ProgressBar::update(progress=1.13351e+09) m_fraction=0.549289 m_text="1.06 GiB of 1.92 GiB copied (00:00:04 remaining)" DEBUG: ProgressBar::update(progress=1.26249e+09) m_fraction=0.611789 m_text="1.18 GiB of 1.92 GiB copied (00:00:04 remaining)" DEBUG: ProgressBar::update(progress=1.39041e+09) m_fraction=0.67378 m_text="1.29 GiB of 1.92 GiB copied (00:00:03 remaining)" ... DEBUG: ProgressBar::update(progress=1.97552e+09) m_fraction=0.957317 m_text="1.84 GiB of 1.92 GiB copied (00:00:00 remaining)" DEBUG: ProgressBar::update(progress=2.0636e+09) m_fraction=1 m_text="1.92 GiB of 1.92 GiB copied" DEBUG: ProgressBar::stop() Bug 760709 - Add progress bars to XFS and EXT2/3/4 file system specific copy methods
2016-01-11 05:19:05 -07:00
/* Copyright (C) 2016 Mike Fleetwood
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include "ProgressBar.h"
#include "Utils.h"
Write a generic progress bar class (#760709) Write a generic progress bar class. Has the following features: * Has separate progress and target numbers, rather than a single completion fraction, to enable the the next feature. * Optionally generates text reporting the amount of data copied using the progress and target numbers like this: "1.00 MiB of 16.00 MiB copied" * After running for 5 seconds, also add estimated remaining time. (Waits to allow the data copying rate to settle down a little before estimating the remaining time). Looks like this: "1.00 MiB of 16.00 MiB copied (00:01:59) remaining)" The ProgressBar class is not driving the visual progress bar yet. It has just been added into the internal block copy algorithm and generates debug messages showing the progress bar is operating correctly. Debugging looks like this: DEBUG: ProgressBar::start(target=2.0636e+09, text_mode=PROGRESSBAR_TEXT_COPY_BYTES) DEBUG: ProgressBar::update(progress=1.30023e+08) m_fraction=0.0630081 m_text="124.00 MiB of 1.92 GiB copied" DEBUG: ProgressBar::update(progress=2.67387e+08) m_fraction=0.129573 m_text="255.00 MiB of 1.92 GiB copied" DEBUG: ProgressBar::update(progress=4.0475e+08) m_fraction=0.196138 m_text="386.00 MiB of 1.92 GiB copied" ... DEBUG: ProgressBar::update(progress=1.13351e+09) m_fraction=0.549289 m_text="1.06 GiB of 1.92 GiB copied (00:00:04 remaining)" DEBUG: ProgressBar::update(progress=1.26249e+09) m_fraction=0.611789 m_text="1.18 GiB of 1.92 GiB copied (00:00:04 remaining)" DEBUG: ProgressBar::update(progress=1.39041e+09) m_fraction=0.67378 m_text="1.29 GiB of 1.92 GiB copied (00:00:03 remaining)" ... DEBUG: ProgressBar::update(progress=1.97552e+09) m_fraction=0.957317 m_text="1.84 GiB of 1.92 GiB copied (00:00:00 remaining)" DEBUG: ProgressBar::update(progress=2.0636e+09) m_fraction=1 m_text="1.92 GiB of 1.92 GiB copied" DEBUG: ProgressBar::stop() Bug 760709 - Add progress bars to XFS and EXT2/3/4 file system specific copy methods
2016-01-11 05:19:05 -07:00
#include <glibmm/ustring.h>
namespace GParted
{
ProgressBar::ProgressBar() : m_running( false ), m_target( 1.0 ), m_progress( 0.0 ), m_fraction( 0.0 ),
m_text_mode(PROGRESSBAR_TEXT_TIME_REMAINING)
Write a generic progress bar class (#760709) Write a generic progress bar class. Has the following features: * Has separate progress and target numbers, rather than a single completion fraction, to enable the the next feature. * Optionally generates text reporting the amount of data copied using the progress and target numbers like this: "1.00 MiB of 16.00 MiB copied" * After running for 5 seconds, also add estimated remaining time. (Waits to allow the data copying rate to settle down a little before estimating the remaining time). Looks like this: "1.00 MiB of 16.00 MiB copied (00:01:59) remaining)" The ProgressBar class is not driving the visual progress bar yet. It has just been added into the internal block copy algorithm and generates debug messages showing the progress bar is operating correctly. Debugging looks like this: DEBUG: ProgressBar::start(target=2.0636e+09, text_mode=PROGRESSBAR_TEXT_COPY_BYTES) DEBUG: ProgressBar::update(progress=1.30023e+08) m_fraction=0.0630081 m_text="124.00 MiB of 1.92 GiB copied" DEBUG: ProgressBar::update(progress=2.67387e+08) m_fraction=0.129573 m_text="255.00 MiB of 1.92 GiB copied" DEBUG: ProgressBar::update(progress=4.0475e+08) m_fraction=0.196138 m_text="386.00 MiB of 1.92 GiB copied" ... DEBUG: ProgressBar::update(progress=1.13351e+09) m_fraction=0.549289 m_text="1.06 GiB of 1.92 GiB copied (00:00:04 remaining)" DEBUG: ProgressBar::update(progress=1.26249e+09) m_fraction=0.611789 m_text="1.18 GiB of 1.92 GiB copied (00:00:04 remaining)" DEBUG: ProgressBar::update(progress=1.39041e+09) m_fraction=0.67378 m_text="1.29 GiB of 1.92 GiB copied (00:00:03 remaining)" ... DEBUG: ProgressBar::update(progress=1.97552e+09) m_fraction=0.957317 m_text="1.84 GiB of 1.92 GiB copied (00:00:00 remaining)" DEBUG: ProgressBar::update(progress=2.0636e+09) m_fraction=1 m_text="1.92 GiB of 1.92 GiB copied" DEBUG: ProgressBar::stop() Bug 760709 - Add progress bars to XFS and EXT2/3/4 file system specific copy methods
2016-01-11 05:19:05 -07:00
{
}
ProgressBar::~ProgressBar()
{
}
void ProgressBar::start( double target, ProgressBar_Text text_mode )
{
m_running = true;
m_target = target;
m_progress = 0.0;
m_text_mode = text_mode;
Clear progress bar text when starting it (#230) These operations use steps which generate progress bar bytes copied information text: * Partition move or copy using GParted's internal block copy * EXT2/3/4 partition move or copy * XFS partition copy The bytes copied text looks like this (after the copy completes and the time remaining is no longer included): 1.00 GiB of 1.00 GiB copied And these operations use steps which generate progress bar information without text (because the progress bar data only represents a fraction complete): * EXT2/3/4 partition resize * EXT2/3/4 partition create * EXT2/3/4 partition format * EXT2/3/4 partition check * NTFS partition resize * NTFS partition copy In the Applying pending operations dialog, while an operation is being applied there are 2 progress bars. The top progress bar displays either a pulse bar or the progress bar data for the current step. Additionally for the relevant steps the progress bar generates the bytes copied text. This text, when available, is displayed in small grey characters just above the progress bar itself. Copy a FAT partition and apply. Bytes copied text is displayed just above the top progress bar. Copy an NTFS partition and apply. The left behind bytes copied text from the previous operation is displayed, instead of nothing. Restart GParted and copy an NTFS partition and apply. As intended, this time there is no bytes copied text displayed just above the top progress bar. As there is just a single ProgressBar object, single_progressbar, fix this by clearing the progress bar text each time it is started. Closes #230 - Missing progress bar text reset when applying operation
2023-06-12 09:23:39 -06:00
m_text.clear();
Write a generic progress bar class (#760709) Write a generic progress bar class. Has the following features: * Has separate progress and target numbers, rather than a single completion fraction, to enable the the next feature. * Optionally generates text reporting the amount of data copied using the progress and target numbers like this: "1.00 MiB of 16.00 MiB copied" * After running for 5 seconds, also add estimated remaining time. (Waits to allow the data copying rate to settle down a little before estimating the remaining time). Looks like this: "1.00 MiB of 16.00 MiB copied (00:01:59) remaining)" The ProgressBar class is not driving the visual progress bar yet. It has just been added into the internal block copy algorithm and generates debug messages showing the progress bar is operating correctly. Debugging looks like this: DEBUG: ProgressBar::start(target=2.0636e+09, text_mode=PROGRESSBAR_TEXT_COPY_BYTES) DEBUG: ProgressBar::update(progress=1.30023e+08) m_fraction=0.0630081 m_text="124.00 MiB of 1.92 GiB copied" DEBUG: ProgressBar::update(progress=2.67387e+08) m_fraction=0.129573 m_text="255.00 MiB of 1.92 GiB copied" DEBUG: ProgressBar::update(progress=4.0475e+08) m_fraction=0.196138 m_text="386.00 MiB of 1.92 GiB copied" ... DEBUG: ProgressBar::update(progress=1.13351e+09) m_fraction=0.549289 m_text="1.06 GiB of 1.92 GiB copied (00:00:04 remaining)" DEBUG: ProgressBar::update(progress=1.26249e+09) m_fraction=0.611789 m_text="1.18 GiB of 1.92 GiB copied (00:00:04 remaining)" DEBUG: ProgressBar::update(progress=1.39041e+09) m_fraction=0.67378 m_text="1.29 GiB of 1.92 GiB copied (00:00:03 remaining)" ... DEBUG: ProgressBar::update(progress=1.97552e+09) m_fraction=0.957317 m_text="1.84 GiB of 1.92 GiB copied (00:00:00 remaining)" DEBUG: ProgressBar::update(progress=2.0636e+09) m_fraction=1 m_text="1.92 GiB of 1.92 GiB copied" DEBUG: ProgressBar::stop() Bug 760709 - Add progress bars to XFS and EXT2/3/4 file system specific copy methods
2016-01-11 05:19:05 -07:00
m_timer.start();
do_update();
}
void ProgressBar::update( double progress )
{
if ( m_running )
{
m_progress = progress;
do_update();
}
}
void ProgressBar::stop()
{
m_running = false;
m_timer.stop();
do_update();
}
bool ProgressBar::running() const
{
return m_running;
}
double ProgressBar::get_fraction() const
{
return m_fraction;
}
const Glib::ustring& ProgressBar::get_text() const
Write a generic progress bar class (#760709) Write a generic progress bar class. Has the following features: * Has separate progress and target numbers, rather than a single completion fraction, to enable the the next feature. * Optionally generates text reporting the amount of data copied using the progress and target numbers like this: "1.00 MiB of 16.00 MiB copied" * After running for 5 seconds, also add estimated remaining time. (Waits to allow the data copying rate to settle down a little before estimating the remaining time). Looks like this: "1.00 MiB of 16.00 MiB copied (00:01:59) remaining)" The ProgressBar class is not driving the visual progress bar yet. It has just been added into the internal block copy algorithm and generates debug messages showing the progress bar is operating correctly. Debugging looks like this: DEBUG: ProgressBar::start(target=2.0636e+09, text_mode=PROGRESSBAR_TEXT_COPY_BYTES) DEBUG: ProgressBar::update(progress=1.30023e+08) m_fraction=0.0630081 m_text="124.00 MiB of 1.92 GiB copied" DEBUG: ProgressBar::update(progress=2.67387e+08) m_fraction=0.129573 m_text="255.00 MiB of 1.92 GiB copied" DEBUG: ProgressBar::update(progress=4.0475e+08) m_fraction=0.196138 m_text="386.00 MiB of 1.92 GiB copied" ... DEBUG: ProgressBar::update(progress=1.13351e+09) m_fraction=0.549289 m_text="1.06 GiB of 1.92 GiB copied (00:00:04 remaining)" DEBUG: ProgressBar::update(progress=1.26249e+09) m_fraction=0.611789 m_text="1.18 GiB of 1.92 GiB copied (00:00:04 remaining)" DEBUG: ProgressBar::update(progress=1.39041e+09) m_fraction=0.67378 m_text="1.29 GiB of 1.92 GiB copied (00:00:03 remaining)" ... DEBUG: ProgressBar::update(progress=1.97552e+09) m_fraction=0.957317 m_text="1.84 GiB of 1.92 GiB copied (00:00:00 remaining)" DEBUG: ProgressBar::update(progress=2.0636e+09) m_fraction=1 m_text="1.92 GiB of 1.92 GiB copied" DEBUG: ProgressBar::stop() Bug 760709 - Add progress bars to XFS and EXT2/3/4 file system specific copy methods
2016-01-11 05:19:05 -07:00
{
return m_text;
}
// Private methods
// Update m_fraction and m_text as required.
void ProgressBar::do_update()
{
m_fraction = m_progress / m_target;
if ( m_fraction < 0.0 )
m_fraction = 0.0;
else if ( m_fraction > 1.0 )
m_fraction = 1.0;
double elapsed = m_timer.elapsed();
Write a generic progress bar class (#760709) Write a generic progress bar class. Has the following features: * Has separate progress and target numbers, rather than a single completion fraction, to enable the the next feature. * Optionally generates text reporting the amount of data copied using the progress and target numbers like this: "1.00 MiB of 16.00 MiB copied" * After running for 5 seconds, also add estimated remaining time. (Waits to allow the data copying rate to settle down a little before estimating the remaining time). Looks like this: "1.00 MiB of 16.00 MiB copied (00:01:59) remaining)" The ProgressBar class is not driving the visual progress bar yet. It has just been added into the internal block copy algorithm and generates debug messages showing the progress bar is operating correctly. Debugging looks like this: DEBUG: ProgressBar::start(target=2.0636e+09, text_mode=PROGRESSBAR_TEXT_COPY_BYTES) DEBUG: ProgressBar::update(progress=1.30023e+08) m_fraction=0.0630081 m_text="124.00 MiB of 1.92 GiB copied" DEBUG: ProgressBar::update(progress=2.67387e+08) m_fraction=0.129573 m_text="255.00 MiB of 1.92 GiB copied" DEBUG: ProgressBar::update(progress=4.0475e+08) m_fraction=0.196138 m_text="386.00 MiB of 1.92 GiB copied" ... DEBUG: ProgressBar::update(progress=1.13351e+09) m_fraction=0.549289 m_text="1.06 GiB of 1.92 GiB copied (00:00:04 remaining)" DEBUG: ProgressBar::update(progress=1.26249e+09) m_fraction=0.611789 m_text="1.18 GiB of 1.92 GiB copied (00:00:04 remaining)" DEBUG: ProgressBar::update(progress=1.39041e+09) m_fraction=0.67378 m_text="1.29 GiB of 1.92 GiB copied (00:00:03 remaining)" ... DEBUG: ProgressBar::update(progress=1.97552e+09) m_fraction=0.957317 m_text="1.84 GiB of 1.92 GiB copied (00:00:00 remaining)" DEBUG: ProgressBar::update(progress=2.0636e+09) m_fraction=1 m_text="1.92 GiB of 1.92 GiB copied" DEBUG: ProgressBar::stop() Bug 760709 - Add progress bars to XFS and EXT2/3/4 file system specific copy methods
2016-01-11 05:19:05 -07:00
if ( m_text_mode == PROGRESSBAR_TEXT_COPY_BYTES )
{
if ( m_running && elapsed >= 5.0 )
{
/* Only show "(00:01:59 remaining)" when a progress bar has been
* running for at least 5 seconds to allow the data copying rate
* to settle down a little before estimating the time remaining.
Write a generic progress bar class (#760709) Write a generic progress bar class. Has the following features: * Has separate progress and target numbers, rather than a single completion fraction, to enable the the next feature. * Optionally generates text reporting the amount of data copied using the progress and target numbers like this: "1.00 MiB of 16.00 MiB copied" * After running for 5 seconds, also add estimated remaining time. (Waits to allow the data copying rate to settle down a little before estimating the remaining time). Looks like this: "1.00 MiB of 16.00 MiB copied (00:01:59) remaining)" The ProgressBar class is not driving the visual progress bar yet. It has just been added into the internal block copy algorithm and generates debug messages showing the progress bar is operating correctly. Debugging looks like this: DEBUG: ProgressBar::start(target=2.0636e+09, text_mode=PROGRESSBAR_TEXT_COPY_BYTES) DEBUG: ProgressBar::update(progress=1.30023e+08) m_fraction=0.0630081 m_text="124.00 MiB of 1.92 GiB copied" DEBUG: ProgressBar::update(progress=2.67387e+08) m_fraction=0.129573 m_text="255.00 MiB of 1.92 GiB copied" DEBUG: ProgressBar::update(progress=4.0475e+08) m_fraction=0.196138 m_text="386.00 MiB of 1.92 GiB copied" ... DEBUG: ProgressBar::update(progress=1.13351e+09) m_fraction=0.549289 m_text="1.06 GiB of 1.92 GiB copied (00:00:04 remaining)" DEBUG: ProgressBar::update(progress=1.26249e+09) m_fraction=0.611789 m_text="1.18 GiB of 1.92 GiB copied (00:00:04 remaining)" DEBUG: ProgressBar::update(progress=1.39041e+09) m_fraction=0.67378 m_text="1.29 GiB of 1.92 GiB copied (00:00:03 remaining)" ... DEBUG: ProgressBar::update(progress=1.97552e+09) m_fraction=0.957317 m_text="1.84 GiB of 1.92 GiB copied (00:00:00 remaining)" DEBUG: ProgressBar::update(progress=2.0636e+09) m_fraction=1 m_text="1.92 GiB of 1.92 GiB copied" DEBUG: ProgressBar::stop() Bug 760709 - Add progress bars to XFS and EXT2/3/4 file system specific copy methods
2016-01-11 05:19:05 -07:00
*/
std::time_t remaining = Utils::round( (m_target - m_progress) /
(m_progress / elapsed) );
m_text = Glib::ustring::compose( /* TO TRANSLATORS: looks like 1.00 MiB of 16.00 MiB copied (00:01:59 remaining) */
Write a generic progress bar class (#760709) Write a generic progress bar class. Has the following features: * Has separate progress and target numbers, rather than a single completion fraction, to enable the the next feature. * Optionally generates text reporting the amount of data copied using the progress and target numbers like this: "1.00 MiB of 16.00 MiB copied" * After running for 5 seconds, also add estimated remaining time. (Waits to allow the data copying rate to settle down a little before estimating the remaining time). Looks like this: "1.00 MiB of 16.00 MiB copied (00:01:59) remaining)" The ProgressBar class is not driving the visual progress bar yet. It has just been added into the internal block copy algorithm and generates debug messages showing the progress bar is operating correctly. Debugging looks like this: DEBUG: ProgressBar::start(target=2.0636e+09, text_mode=PROGRESSBAR_TEXT_COPY_BYTES) DEBUG: ProgressBar::update(progress=1.30023e+08) m_fraction=0.0630081 m_text="124.00 MiB of 1.92 GiB copied" DEBUG: ProgressBar::update(progress=2.67387e+08) m_fraction=0.129573 m_text="255.00 MiB of 1.92 GiB copied" DEBUG: ProgressBar::update(progress=4.0475e+08) m_fraction=0.196138 m_text="386.00 MiB of 1.92 GiB copied" ... DEBUG: ProgressBar::update(progress=1.13351e+09) m_fraction=0.549289 m_text="1.06 GiB of 1.92 GiB copied (00:00:04 remaining)" DEBUG: ProgressBar::update(progress=1.26249e+09) m_fraction=0.611789 m_text="1.18 GiB of 1.92 GiB copied (00:00:04 remaining)" DEBUG: ProgressBar::update(progress=1.39041e+09) m_fraction=0.67378 m_text="1.29 GiB of 1.92 GiB copied (00:00:03 remaining)" ... DEBUG: ProgressBar::update(progress=1.97552e+09) m_fraction=0.957317 m_text="1.84 GiB of 1.92 GiB copied (00:00:00 remaining)" DEBUG: ProgressBar::update(progress=2.0636e+09) m_fraction=1 m_text="1.92 GiB of 1.92 GiB copied" DEBUG: ProgressBar::stop() Bug 760709 - Add progress bars to XFS and EXT2/3/4 file system specific copy methods
2016-01-11 05:19:05 -07:00
_("%1 of %2 copied (%3 remaining)"),
Utils::format_size( (long long)m_progress, 1 ),
Utils::format_size( (long long)m_target, 1 ),
Utils::format_time( remaining ) );
}
else
{
m_text = Glib::ustring::compose( /* TO TRANSLATORS: looks like 1.00 MiB of 16.00 MiB copied */
Write a generic progress bar class (#760709) Write a generic progress bar class. Has the following features: * Has separate progress and target numbers, rather than a single completion fraction, to enable the the next feature. * Optionally generates text reporting the amount of data copied using the progress and target numbers like this: "1.00 MiB of 16.00 MiB copied" * After running for 5 seconds, also add estimated remaining time. (Waits to allow the data copying rate to settle down a little before estimating the remaining time). Looks like this: "1.00 MiB of 16.00 MiB copied (00:01:59) remaining)" The ProgressBar class is not driving the visual progress bar yet. It has just been added into the internal block copy algorithm and generates debug messages showing the progress bar is operating correctly. Debugging looks like this: DEBUG: ProgressBar::start(target=2.0636e+09, text_mode=PROGRESSBAR_TEXT_COPY_BYTES) DEBUG: ProgressBar::update(progress=1.30023e+08) m_fraction=0.0630081 m_text="124.00 MiB of 1.92 GiB copied" DEBUG: ProgressBar::update(progress=2.67387e+08) m_fraction=0.129573 m_text="255.00 MiB of 1.92 GiB copied" DEBUG: ProgressBar::update(progress=4.0475e+08) m_fraction=0.196138 m_text="386.00 MiB of 1.92 GiB copied" ... DEBUG: ProgressBar::update(progress=1.13351e+09) m_fraction=0.549289 m_text="1.06 GiB of 1.92 GiB copied (00:00:04 remaining)" DEBUG: ProgressBar::update(progress=1.26249e+09) m_fraction=0.611789 m_text="1.18 GiB of 1.92 GiB copied (00:00:04 remaining)" DEBUG: ProgressBar::update(progress=1.39041e+09) m_fraction=0.67378 m_text="1.29 GiB of 1.92 GiB copied (00:00:03 remaining)" ... DEBUG: ProgressBar::update(progress=1.97552e+09) m_fraction=0.957317 m_text="1.84 GiB of 1.92 GiB copied (00:00:00 remaining)" DEBUG: ProgressBar::update(progress=2.0636e+09) m_fraction=1 m_text="1.92 GiB of 1.92 GiB copied" DEBUG: ProgressBar::stop() Bug 760709 - Add progress bars to XFS and EXT2/3/4 file system specific copy methods
2016-01-11 05:19:05 -07:00
_("%1 of %2 copied"),
Utils::format_size( m_progress, 1 ),
Utils::format_size( m_target, 1 ) );
}
}
else /* (m_text_mode == PROGRESSBAR_TEXT_TIME_REMAINING) */
{
if (m_running && elapsed >= 5.0)
{
/* Only show "(00:01:59 remaining)" when a progress bar has been
* running for at least 5 seconds to allow the progress rate to
* settle down a little before estimating the time remaining.
*/
std::time_t remaining = Utils::round((m_target - m_progress) /
(m_progress / elapsed) );
m_text = Glib::ustring::compose( /* TO TRANSLATORS: looks like (00:01:59 remaining) */
_("(%1 remaining)"),
Utils::format_time(remaining));
}
else
{
m_text.clear();
}
}
Write a generic progress bar class (#760709) Write a generic progress bar class. Has the following features: * Has separate progress and target numbers, rather than a single completion fraction, to enable the the next feature. * Optionally generates text reporting the amount of data copied using the progress and target numbers like this: "1.00 MiB of 16.00 MiB copied" * After running for 5 seconds, also add estimated remaining time. (Waits to allow the data copying rate to settle down a little before estimating the remaining time). Looks like this: "1.00 MiB of 16.00 MiB copied (00:01:59) remaining)" The ProgressBar class is not driving the visual progress bar yet. It has just been added into the internal block copy algorithm and generates debug messages showing the progress bar is operating correctly. Debugging looks like this: DEBUG: ProgressBar::start(target=2.0636e+09, text_mode=PROGRESSBAR_TEXT_COPY_BYTES) DEBUG: ProgressBar::update(progress=1.30023e+08) m_fraction=0.0630081 m_text="124.00 MiB of 1.92 GiB copied" DEBUG: ProgressBar::update(progress=2.67387e+08) m_fraction=0.129573 m_text="255.00 MiB of 1.92 GiB copied" DEBUG: ProgressBar::update(progress=4.0475e+08) m_fraction=0.196138 m_text="386.00 MiB of 1.92 GiB copied" ... DEBUG: ProgressBar::update(progress=1.13351e+09) m_fraction=0.549289 m_text="1.06 GiB of 1.92 GiB copied (00:00:04 remaining)" DEBUG: ProgressBar::update(progress=1.26249e+09) m_fraction=0.611789 m_text="1.18 GiB of 1.92 GiB copied (00:00:04 remaining)" DEBUG: ProgressBar::update(progress=1.39041e+09) m_fraction=0.67378 m_text="1.29 GiB of 1.92 GiB copied (00:00:03 remaining)" ... DEBUG: ProgressBar::update(progress=1.97552e+09) m_fraction=0.957317 m_text="1.84 GiB of 1.92 GiB copied (00:00:00 remaining)" DEBUG: ProgressBar::update(progress=2.0636e+09) m_fraction=1 m_text="1.92 GiB of 1.92 GiB copied" DEBUG: ProgressBar::stop() Bug 760709 - Add progress bars to XFS and EXT2/3/4 file system specific copy methods
2016-01-11 05:19:05 -07:00
}
}//GParted