[gparted] Display progress from the single ProgressBar in the GUI (#760709)



commit b0d9d2de7e785493167db26ed131062f51f09e99
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Mon Jan 11 14:21:11 2016 +0000

    Display progress from the single ProgressBar in the GUI (#760709)
    
    Change the Applying pending operations dialog so that it takes it source
    of progress from the single ProgressBar object, rather than the fraction
    value in every OperationDetail object.  Also remove ProgressBar
    debugging now that it is being used to drive the UI.
    
    NOTE:
    This temporarily causes the existing file system specific progress bars
    to not be shown because they still update via the fraction member in
    each OperationDetail object, rather than the new ProgressBar.  This will
    be corrected in following commits.
    
    Bug 760709 - Add progress bars to XFS and EXT2/3/4 file system specific
                 copy methods

 src/Dialog_Progress.cc |   26 +++++++++++++++++++-------
 src/ProgressBar.cc     |    8 --------
 2 files changed, 19 insertions(+), 15 deletions(-)
---
diff --git a/src/Dialog_Progress.cc b/src/Dialog_Progress.cc
index 9526e64..8c328b5 100644
--- a/src/Dialog_Progress.cc
+++ b/src/Dialog_Progress.cc
@@ -16,6 +16,8 @@
  */
  
 #include "../include/Dialog_Progress.h"
+#include "../include/OperationDetail.h"
+#include "../include/ProgressBar.h"
 
 #include <gtkmm/stock.h>
 #include <gtkmm/main.h>
@@ -148,16 +150,26 @@ void Dialog_Progress::on_signal_update( const OperationDetail & operationdetail
                }
 
                //update the gui elements..
-               progress_text = operationdetail.progress_text;
-
                if ( operationdetail .get_status() == STATUS_EXECUTE )
                        label_current_sub_text = operationdetail .get_description() ;
 
-               if ( operationdetail.fraction >= 0 ) {
-                       pulsetimer.disconnect();
-                       progressbar_current.set_fraction( operationdetail.fraction > 1.0 ? 1.0 : 
operationdetail.fraction );
-               } else if( !pulsetimer.connected() )
-                       pulsetimer = Glib::signal_timeout().connect( sigc::mem_fun(*this, 
&Dialog_Progress::pulsebar_pulse), 100 );
+               ProgressBar & progressbar_src = operationdetail.get_progressbar();
+               if ( progressbar_src.running() )
+               {
+                       if ( pulsetimer.connected() )
+                               pulsetimer.disconnect();
+                       progressbar_current.set_fraction( progressbar_src.get_fraction() );
+                       progress_text = progressbar_src.get_text();
+               }
+               else
+               {
+                       if ( ! pulsetimer.connected() )
+                       {
+                               pulsetimer = Glib::signal_timeout().connect(
+                                               sigc::mem_fun( *this, &Dialog_Progress::pulsebar_pulse ), 100 
);
+                               progress_text.clear();
+                       }
+               }
                update_gui_elements();
        }
        else//it's an new od which needs to be added to the model.
diff --git a/src/ProgressBar.cc b/src/ProgressBar.cc
index 3daa96a..fa47fa5 100644
--- a/src/ProgressBar.cc
+++ b/src/ProgressBar.cc
@@ -33,10 +33,6 @@ ProgressBar::~ProgressBar()
 
 void ProgressBar::start( double target, ProgressBar_Text text_mode )
 {
-       std::cout << "DEBUG: ProgressBar::start(target=" << target
-                 << ", text_mode=" << (text_mode==PROGRESSBAR_TEXT_NONE ? "PROGRESSBAR_TEXT_NONE" :
-                                                                          "PROGRESSBAR_TEXT_BLOCK_COPY") << 
")"
-                 << std::endl;
        m_running = true;
        m_target = target;
        m_progress = 0.0;
@@ -47,19 +43,15 @@ void ProgressBar::start( double target, ProgressBar_Text text_mode )
 
 void ProgressBar::update( double progress )
 {
-       std::cout << "DEBUG: ProgressBar::update(progress=" << progress << ")";
        if ( m_running )
        {
                m_progress = progress;
                do_update();
-               std::cout << " m_fraction=" << m_fraction << " m_text=\"" << m_text << "\"";
        }
-       std::cout << std::endl;
 }
 
 void ProgressBar::stop()
 {
-       std::cout << "DEBUG: ProgressBar::stop()" << std::endl;
        m_running = false;
        m_timer.stop();
        do_update();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]