[gparted/psusi/refactor] fixup! Thread the internal copy algorithm (#685740)



commit 70190d03a032e7665bce6ba2bb303bfe7975a403
Author: Phillip Susi <psusi ubuntu com>
Date:   Tue Mar 5 19:52:05 2013 -0500

    fixup! Thread the internal copy algorithm (#685740)
    
    Fix the error message to show up in the right place in the tree, and only
    once, and fix the cancel signal propagating to future details.

 include/OperationDetail.h |    2 +-
 src/Copy_Blocks.cc        |   42 ++++++++++++++++++++++--------------------
 2 files changed, 23 insertions(+), 21 deletions(-)
---
diff --git a/include/OperationDetail.h b/include/OperationDetail.h
index 3c6dafb..fa9f806 100644
--- a/include/OperationDetail.h
+++ b/include/OperationDetail.h
@@ -70,10 +70,10 @@ public:
        
        sigc::signal< void, const OperationDetail & > signal_update ;
        sigc::signal< void, bool > signal_cancel;
+       char cancelflag;
 private:
        void on_update( const OperationDetail & operationdetail ) ;
        void cancel( bool force );
-       char cancelflag;
        Glib::ustring description ;
        OperationDetailStatus status ; 
 
diff --git a/src/Copy_Blocks.cc b/src/Copy_Blocks.cc
index e2005b1..4d22280 100644
--- a/src/Copy_Blocks.cc
+++ b/src/Copy_Blocks.cc
@@ -53,6 +53,8 @@ copy_blocks::copy_blocks( const Glib::ustring & in_src_device,
 {
        operationdetail.signal_cancel.connect(
                sigc::mem_fun(*this, &copy_blocks::set_cancel));
+       if (operationdetail.cancelflag)
+               set_cancel( operationdetail.cancelflag == 2 );
 }
 
 bool copy_blocks::set_progress_info()
@@ -81,26 +83,6 @@ bool copy_blocks::set_progress_info()
                                _("%1 of %2 copied"),
                                Utils::format_size( done, 1 ), Utils::format_size( length, 1 ) ),
                                FONT_ITALIC );
-       if (done == length || !success)
-       {
-               //reset fraction to -1 to make room for a new one (or a pulsebar)
-               operationdetail.fraction = -1;
-
-               //final description
-               operationdetail.set_description(
-                       String::ucompose( readonly ?
-                                         /*TO TRANSLATORS: looks like  1.00 MiB of 16.00 MiB read */
-                                         _("%1 of %2 read") :
-                                         /*TO TRANSLATORS: looks like  1.00 MiB of 16.00 MiB copied */
-                                         _("%1 of %2 copied"),
-                                         Utils::format_size( llabs( done ), 1 ),
-                                         Utils::format_size( length, 1 ) ),
-                       FONT_ITALIC );
-
-               if ( !success && !error_message.empty() )
-                       operationdetail.get_last_child().add_child(
-                               OperationDetail( error_message, STATUS_NONE, FONT_ITALIC ) );
-       }
        return false;
 }
 
@@ -203,6 +185,26 @@ bool copy_blocks::copy()
                Glib::Thread::create( sigc::mem_fun( *this, &copy_blocks::copy_thread ),
                                      false );
                Gtk::Main::run();
+               if (done == length || !success)
+               {
+                       //reset fraction to -1 to make room for a new one (or a pulsebar)
+                       operationdetail.get_last_child().get_last_child().fraction = -1;
+
+                       //final description
+                       operationdetail.get_last_child().get_last_child().set_description(
+                               String::ucompose( readonly ?
+                                                 /*TO TRANSLATORS: looks like  1.00 MiB of 16.00 MiB read */
+                                                 _("%1 of %2 read") :
+                                                 /*TO TRANSLATORS: looks like  1.00 MiB of 16.00 MiB copied 
*/
+                                                 _("%1 of %2 copied"),
+                                                 Utils::format_size( llabs( done ), 1 ),
+                                                 Utils::format_size( length, 1 ) ),
+                               FONT_ITALIC );
+
+                       if ( !success && !error_message.empty() )
+                               operationdetail.get_last_child().get_last_child().add_child(
+                                       OperationDetail( error_message, STATUS_NONE, FONT_ITALIC ) );
+               }
                free( buf ) ;
        }
        else


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