Added set and get thread status message methods.

Added thread status message updates in set_devices().

svn path=/trunk/; revision=943
This commit is contained in:
Curtis Gedak 2008-10-30 18:50:38 +00:00
parent a622e6fefd
commit 2331bd0763
3 changed files with 31 additions and 4 deletions

View File

@ -1,3 +1,9 @@
2008-10-30 Curtis Gedak <gedakc@gmail.com>
* 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 <gedakc@gmail.com> 2008-10-28 Curtis Gedak <gedakc@gmail.com>
* src/GParted_Core.cc: Remove std:: prefix from llabs() * src/GParted_Core.cc: Remove std:: prefix from llabs()

View File

@ -51,10 +51,12 @@ public:
std::vector<Glib::ustring> get_all_mountpoints() ; std::vector<Glib::ustring> get_all_mountpoints() ;
std::map<Glib::ustring, bool> get_available_flags( const Partition & partition ) ; std::map<Glib::ustring, bool> get_available_flags( const Partition & partition ) ;
Glib::ustring get_libparted_version() ; Glib::ustring get_libparted_version() ;
Glib::ustring get_thread_status_message() ;
private: private:
//detectionstuff.. //detectionstuff..
void init_maps() ; void init_maps() ;
void set_thread_status_message( Glib::ustring msg ) ;
void read_mountpoints_from_file( const Glib::ustring & filename, void read_mountpoints_from_file( const Glib::ustring & filename,
std::map< Glib::ustring, std::vector<Glib::ustring> > & map ) ; std::map< Glib::ustring, std::vector<Glib::ustring> > & map ) ;
std::vector<Glib::ustring> get_alternate_paths( const Glib::ustring & path ) ; std::vector<Glib::ustring> get_alternate_paths( const Glib::ustring & path ) ;
@ -185,6 +187,7 @@ private:
FS fs ; FS fs ;
std::vector<Glib::ustring> device_paths ; std::vector<Glib::ustring> device_paths ;
bool probe_devices ; bool probe_devices ;
Glib::ustring thread_status_message; //Used to pass data to show_pulsebar method
std::map< Glib::ustring, std::vector<Glib::ustring> > mount_info ; std::map< Glib::ustring, std::vector<Glib::ustring> > mount_info ;
std::map< Glib::ustring, std::vector<Glib::ustring> > fstab_info ; std::map< Glib::ustring, std::vector<Glib::ustring> > fstab_info ;

View File

@ -58,6 +58,7 @@ GParted_Core::GParted_Core()
lp_disk = NULL ; lp_disk = NULL ;
lp_partition = NULL ; lp_partition = NULL ;
p_filesystem = NULL ; p_filesystem = NULL ;
set_thread_status_message("") ;
ped_exception_set_handler( ped_exception_handler ) ; ped_exception_set_handler( ped_exception_handler ) ;
@ -170,11 +171,13 @@ void GParted_Core::set_devices( std::vector<Device> & devices )
{ {
//try to have libparted detect the device and add it to the list //try to have libparted detect the device and add it to the list
device = "/dev/" + device; device = "/dev/" + device;
set_thread_status_message( String::ucompose ( _("Scanning %1 ..."), device ) ) ;
ped_device_get( device .c_str() ) ; ped_device_get( device .c_str() ) ;
} }
} }
proc_partitions .close() ; proc_partitions .close() ;
//Try to find dev mapper devices
std::set<unsigned int> dm_majors; std::set<unsigned int> dm_majors;
std::ifstream proc_devices( "/proc/devices" ) ; std::ifstream proc_devices( "/proc/devices" ) ;
if ( proc_devices ) if ( proc_devices )
@ -215,6 +218,7 @@ void GParted_Core::set_devices( std::vector<Device> & devices )
continue; continue;
if ( dm_majors .find( major( st.st_rdev ) ) != dm_majors .end() ) if ( dm_majors .find( major( st.st_rdev ) ) != dm_majors .end() )
//TODO avoid probing partition nodes for dmraid devices //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() ) ; ped_device_get( mapper_name .c_str() ) ;
} }
closedir( mapper_dir ) ; closedir( mapper_dir ) ;
@ -233,6 +237,7 @@ void GParted_Core::set_devices( std::vector<Device> & devices )
char * buf = static_cast<char *>( malloc( lp_device ->sector_size ) ) ; char * buf = static_cast<char *>( malloc( lp_device ->sector_size ) ) ;
if ( buf ) if ( buf )
{ {
set_thread_status_message( String::ucompose ( _("Reading %1 ..."), lp_device ->path ) ) ;
if ( ped_device_open( lp_device ) ) if ( ped_device_open( lp_device ) )
{ {
if ( ped_device_read( lp_device, buf, 0, 1 ) ) if ( ped_device_read( lp_device, buf, 0, 1 ) )
@ -251,6 +256,7 @@ void GParted_Core::set_devices( std::vector<Device> & devices )
for ( unsigned int t = 0 ; t < device_paths .size() ; t++ ) 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 ) ) if ( open_device_and_disk( device_paths[ t ], false ) )
{ {
temp_device .Reset() ; temp_device .Reset() ;
@ -305,10 +311,22 @@ void GParted_Core::set_devices( std::vector<Device> & devices )
//clear leftover information... //clear leftover information...
//NOTE that we cannot clear mountinfo since it might be needed in get_all_mountpoints() //NOTE that we cannot clear mountinfo since it might be needed in get_all_mountpoints()
set_thread_status_message("") ;
alternate_paths .clear() ; alternate_paths .clear() ;
fstab_info .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 ) bool GParted_Core::snap_to_cylinder( const Device & device, Partition & partition, Glib::ustring & error )
{ {
if ( ! partition .strict ) if ( ! partition .strict )