From 2331bd076329d1d3abe3d8cbcc63bc2c8cfe53a7 Mon Sep 17 00:00:00 2001 From: Curtis Gedak Date: Thu, 30 Oct 2008 18:50:38 +0000 Subject: [PATCH] Added set and get thread status message methods. Added thread status message updates in set_devices(). svn path=/trunk/; revision=943 --- ChangeLog | 6 ++++++ include/GParted_Core.h | 7 +++++-- src/GParted_Core.cc | 22 ++++++++++++++++++++-- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 01cfba66..502af6fb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-10-30 Curtis Gedak + + * include/GParted_Core.h, + src/GParted_Core.cc: Added set and get thread status message methods + - Added thread status message updates in set_devices() + 2008-10-28 Curtis Gedak * src/GParted_Core.cc: Remove std:: prefix from llabs() diff --git a/include/GParted_Core.h b/include/GParted_Core.h index 4992fff0..9896b27d 100644 --- a/include/GParted_Core.h +++ b/include/GParted_Core.h @@ -51,10 +51,12 @@ public: std::vector get_all_mountpoints() ; std::map get_available_flags( const Partition & partition ) ; Glib::ustring get_libparted_version() ; - + Glib::ustring get_thread_status_message() ; + private: //detectionstuff.. void init_maps() ; + void set_thread_status_message( Glib::ustring msg ) ; void read_mountpoints_from_file( const Glib::ustring & filename, std::map< Glib::ustring, std::vector > & map ) ; std::vector get_alternate_paths( const Glib::ustring & path ) ; @@ -70,7 +72,7 @@ private: void set_used_sectors( std::vector & partitions ) ; void LP_set_used_sectors( Partition & partition ); void set_flags( Partition & partition ) ; - + //operationstuff... bool create( const Device & device, Partition & new_partition, OperationDetail & operationdetail ) ; bool create_partition( Partition & new_partition, OperationDetail & operationdetail, Sector min_size = 0 ) ; @@ -185,6 +187,7 @@ private: FS fs ; std::vector device_paths ; bool probe_devices ; + Glib::ustring thread_status_message; //Used to pass data to show_pulsebar method std::map< Glib::ustring, std::vector > mount_info ; std::map< Glib::ustring, std::vector > fstab_info ; diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc index a4cafdb7..c1e19ed8 100644 --- a/src/GParted_Core.cc +++ b/src/GParted_Core.cc @@ -58,6 +58,7 @@ GParted_Core::GParted_Core() lp_disk = NULL ; lp_partition = NULL ; p_filesystem = NULL ; + set_thread_status_message("") ; ped_exception_set_handler( ped_exception_handler ) ; @@ -170,12 +171,14 @@ void GParted_Core::set_devices( std::vector & devices ) { //try to have libparted detect the device and add it to the list device = "/dev/" + device; + set_thread_status_message( String::ucompose ( _("Scanning %1 ..."), device ) ) ; ped_device_get( device .c_str() ) ; } } proc_partitions .close() ; - std::set dm_majors; + //Try to find dev mapper devices + std::set dm_majors; std::ifstream proc_devices( "/proc/devices" ) ; if ( proc_devices ) { @@ -215,6 +218,7 @@ void GParted_Core::set_devices( std::vector & devices ) continue; if ( dm_majors .find( major( st.st_rdev ) ) != dm_majors .end() ) //TODO avoid probing partition nodes for dmraid devices + set_thread_status_message( String::ucompose ( _("Scanning %1 ..."), mapper_name ) ) ; ped_device_get( mapper_name .c_str() ) ; } closedir( mapper_dir ) ; @@ -233,6 +237,7 @@ void GParted_Core::set_devices( std::vector & devices ) char * buf = static_cast( malloc( lp_device ->sector_size ) ) ; if ( buf ) { + set_thread_status_message( String::ucompose ( _("Reading %1 ..."), lp_device ->path ) ) ; if ( ped_device_open( lp_device ) ) { if ( ped_device_read( lp_device, buf, 0, 1 ) ) @@ -251,10 +256,11 @@ void GParted_Core::set_devices( std::vector & devices ) for ( unsigned int t = 0 ; t < device_paths .size() ; t++ ) { + set_thread_status_message( String::ucompose ( _("Scanning %1 for partitions ..."), device_paths[ t ] ) ) ; if ( open_device_and_disk( device_paths[ t ], false ) ) { temp_device .Reset() ; - + //device info.. temp_device .add_path( device_paths[ t ] ) ; temp_device .add_paths( get_alternate_paths( temp_device .get_path() ) ) ; @@ -305,10 +311,22 @@ void GParted_Core::set_devices( std::vector & devices ) //clear leftover information... //NOTE that we cannot clear mountinfo since it might be needed in get_all_mountpoints() + set_thread_status_message("") ; alternate_paths .clear() ; fstab_info .clear() ; } +void GParted_Core::set_thread_status_message( Glib::ustring msg ) +{ + //Remember to clear status message when finished with thread. + thread_status_message = msg ; +} + +Glib::ustring GParted_Core::get_thread_status_message( ) +{ + return thread_status_message ; +} + bool GParted_Core::snap_to_cylinder( const Device & device, Partition & partition, Glib::ustring & error ) { if ( ! partition .strict )