gparted r943 - in trunk: . include src



Author: gedakc
Date: Thu Oct 30 18:50:38 2008
New Revision: 943
URL: http://svn.gnome.org/viewvc/gparted?rev=943&view=rev

Log:
Added set and get thread status message methods.
Added thread status message updates in set_devices().

Modified:
   trunk/ChangeLog
   trunk/include/GParted_Core.h
   trunk/src/GParted_Core.cc

Modified: trunk/include/GParted_Core.h
==============================================================================
--- trunk/include/GParted_Core.h	(original)
+++ trunk/include/GParted_Core.h	Thu Oct 30 18:50:38 2008
@@ -51,10 +51,12 @@
 	std::vector<Glib::ustring> get_all_mountpoints() ;
 	std::map<Glib::ustring, bool> 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<Glib::ustring> > & map ) ;
 	std::vector<Glib::ustring> get_alternate_paths( const Glib::ustring & path ) ;
@@ -70,7 +72,7 @@
 	void set_used_sectors( std::vector<Partition> & 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 @@
 	FS fs ;
 	std::vector<Glib::ustring> device_paths ;
 	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> > fstab_info ;

Modified: trunk/src/GParted_Core.cc
==============================================================================
--- trunk/src/GParted_Core.cc	(original)
+++ trunk/src/GParted_Core.cc	Thu Oct 30 18:50:38 2008
@@ -58,6 +58,7 @@
 	lp_disk = NULL ;
 	lp_partition = NULL ;
 	p_filesystem = NULL ;
+	set_thread_status_message("") ;
 
 	ped_exception_set_handler( ped_exception_handler ) ; 
 
@@ -170,12 +171,14 @@
     			{
     				//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<unsigned int> dm_majors;
+    		//Try to find dev mapper devices
+    		std::set<unsigned int> dm_majors;
 			std::ifstream proc_devices( "/proc/devices" ) ;
 			if ( proc_devices )
 			{
@@ -215,6 +218,7 @@
 						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 @@
 			char * buf = static_cast<char *>( 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 @@
 
 	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 @@
 
 	//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 )



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