[gparted] Set sector size and add to operation and dialog methods



commit 74ecd2ed3f01b482513664c230c3622bc58c92ab
Author: Curtis Gedak <gedakc gmail com>
Date:   Mon Apr 19 19:22:31 2010 -0600

    Set sector size and add to operation and dialog methods
    
    This change is in preparation for supporting sectors sizes > 512 bytes.

 include/Dialog_Base_Partition.h |    4 +-
 include/Dialog_Partition_Copy.h |    5 ++-
 include/Dialog_Partition_New.h  |    2 +-
 include/GParted_Core.h          |    1 +
 include/Operation.h             |    6 ++--
 include/Partition.h             |    4 ++-
 src/Dialog_Base_Partition.cc    |    4 +-
 src/Dialog_Partition_Copy.cc    |    8 +++---
 src/Dialog_Partition_New.cc     |    6 +++-
 src/GParted_Core.cc             |   11 +++++++--
 src/Operation.cc                |    5 ++-
 src/OperationCopy.cc            |    5 ++-
 src/OperationCreate.cc          |    5 ++-
 src/OperationDelete.cc          |    3 +-
 src/OperationResizeMove.cc      |   10 +++++---
 src/Partition.cc                |    6 ++++-
 src/Win_GParted.cc              |   45 ++++++++++++++++++++------------------
 17 files changed, 77 insertions(+), 53 deletions(-)
---
diff --git a/include/Dialog_Base_Partition.h b/include/Dialog_Base_Partition.h
index f6f37d6..7bff0b2 100644
--- a/include/Dialog_Base_Partition.h
+++ b/include/Dialog_Base_Partition.h
@@ -1,5 +1,5 @@
 /* Copyright (C) 2004 Bart
- * Copyright (C) 2008 Curtis Gedak
+ * Copyright (C) 2008, 2009, 2010 Curtis Gedak
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -41,7 +41,7 @@ public:
 	~Dialog_Base_Partition( ) ;
 
 	void Set_Resizer( bool extended ) ;
-	Partition Get_New_Partition( ) ;
+	Partition Get_New_Partition( Byte_Value sector_size ) ;
 	
 protected:
 	enum SPINBUTTON {
diff --git a/include/Dialog_Partition_Copy.h b/include/Dialog_Partition_Copy.h
index 74b6347..c34ff15 100644
--- a/include/Dialog_Partition_Copy.h
+++ b/include/Dialog_Partition_Copy.h
@@ -1,4 +1,5 @@
-/*  Copyright (C) 2004 Bart
+/* Copyright (C) 2004 Bart
+ * Copyright (C) 2010 Curtis Gedak
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -29,7 +30,7 @@ public:
 	Dialog_Partition_Copy( const FS & fs, Sector cylinder_size ) ;
 	void Set_Data( const Partition & selected_partition, const Partition & copied_partition );
 
-	Partition Get_New_Partition() ;
+	Partition Get_New_Partition( Byte_Value sector_size ) ;
 
 private:
 };
diff --git a/include/Dialog_Partition_New.h b/include/Dialog_Partition_New.h
index d0a5934..be7c55c 100644
--- a/include/Dialog_Partition_New.h
+++ b/include/Dialog_Partition_New.h
@@ -38,7 +38,7 @@ public:
 		       bool only_unformatted,
 		       Sector cylinder_size,
 		       Glib::ustring disktype );
-	Partition Get_New_Partition() ;//overridden function
+	Partition Get_New_Partition( Byte_Value sector_size ) ;//overridden function
 
 private:
 	void Build_Filesystems_Menu( bool only_unformatted ) ;
diff --git a/include/GParted_Core.h b/include/GParted_Core.h
index 7d111e8..f06e82c 100644
--- a/include/GParted_Core.h
+++ b/include/GParted_Core.h
@@ -71,6 +71,7 @@ private:
 				 std::vector<Partition> & partitions,
 				 Sector start,
 				 Sector end,
+				 Byte_Value sector_size,
 				 bool inside_extended ) ;
 	void set_mountpoints( std::vector<Partition> & partitions ) ;
 	void set_used_sectors( std::vector<Partition> & partitions ) ;
diff --git a/include/Operation.h b/include/Operation.h
index 2f92005..936618b 100644
--- a/include/Operation.h
+++ b/include/Operation.h
@@ -1,5 +1,5 @@
 /* Copyright (C) 2004 Bart
- * Copyright (C) 2008 Curtis Gedak
+ * Copyright (C) 2008, 2009, 2010 Curtis Gedak
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -59,8 +59,8 @@ public:
 protected:
 	int find_index_original( const std::vector<Partition> & partitions ) ;
 	int find_index_extended( const std::vector<Partition> & partitions ) ;
-	void insert_unallocated( std::vector<Partition> & partitions, Sector start, Sector end, bool inside_extended );
-	
+	void insert_unallocated( std::vector<Partition> & partitions, Sector start, Sector end, Byte_Value sector_size, bool inside_extended );
+
 	int index ;
 	int index_extended ;
 };
diff --git a/include/Partition.h b/include/Partition.h
index ce070b1..3037e14 100644
--- a/include/Partition.h
+++ b/include/Partition.h
@@ -1,5 +1,5 @@
 /* Copyright (C) 2004 Bart
- * Copyright (C) 2008, 2009 Curtis Gedak
+ * Copyright (C) 2008, 2009, 2010 Curtis Gedak
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -64,6 +64,7 @@ public:
 			FILESYSTEM filesystem,
 			Sector sector_start,
 			Sector sector_end,
+			Byte_Value sector_size,
 			bool inside_extended,
 			bool busy ) ;
 
@@ -73,6 +74,7 @@ public:
 	void Set_Unallocated( const Glib::ustring & device_path, 
 			      Sector sector_start,
 			      Sector sector_end,
+			      Byte_Value sector_size,
 			      bool inside_extended );
 
 	//update partition number (used when a logical partition is deleted) 
diff --git a/src/Dialog_Base_Partition.cc b/src/Dialog_Base_Partition.cc
index 2001e19..f5f8263 100644
--- a/src/Dialog_Base_Partition.cc
+++ b/src/Dialog_Base_Partition.cc
@@ -1,5 +1,5 @@
 /* Copyright (C) 2004 Bart
- * Copyright (C) 2008, 2009 Curtis Gedak
+ * Copyright (C) 2008, 2009, 2010 Curtis Gedak
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -122,7 +122,7 @@ void Dialog_Base_Partition::Set_Resizer( bool extended )
 	this ->show_all_children() ;
 }
 
-Partition Dialog_Base_Partition::Get_New_Partition() 
+Partition Dialog_Base_Partition::Get_New_Partition( Byte_Value sector_size ) 
 {
 	//FIXME:  Partition size is limited to just less than 1024 TeraBytes due
 	//        to the maximum value of signed 4 byte integer.
diff --git a/src/Dialog_Partition_Copy.cc b/src/Dialog_Partition_Copy.cc
index 7220fa7..89f4847 100644
--- a/src/Dialog_Partition_Copy.cc
+++ b/src/Dialog_Partition_Copy.cc
@@ -143,14 +143,14 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons
 	this ->show_all_children() ;
 }
 
-Partition Dialog_Partition_Copy::Get_New_Partition() 
+Partition Dialog_Partition_Copy::Get_New_Partition( Byte_Value sector_size )
 {
 	//first call baseclass to get the correct new partition
-	selected_partition = Dialog_Base_Partition::Get_New_Partition() ;
-	
+	selected_partition = Dialog_Base_Partition::Get_New_Partition( sector_size ) ;
+
 	//set proper name and status for partition
 	selected_partition .status = GParted::STAT_COPY ;
-	
+
 	return selected_partition ;
 }
 
diff --git a/src/Dialog_Partition_New.cc b/src/Dialog_Partition_New.cc
index 5999c33..492c265 100644
--- a/src/Dialog_Partition_New.cc
+++ b/src/Dialog_Partition_New.cc
@@ -161,7 +161,7 @@ void Dialog_Partition_New::Set_Data( const Partition & partition,
 	this ->show_all_children() ;
 }
 
-Partition Dialog_Partition_New::Get_New_Partition()
+Partition Dialog_Partition_New::Get_New_Partition( Byte_Value sector_size )
 {
 	Partition part_temp ;
 	PartitionType part_type ;
@@ -193,7 +193,8 @@ Partition Dialog_Partition_New::Get_New_Partition()
 			String::ucompose( _("New Partition #%1"), new_count ),
 			new_count, part_type,
 			FILESYSTEMS[ optionmenu_filesystem .get_history() ] .filesystem,
-			new_start, new_end, 
+			new_start, new_end,
+			sector_size,
 			selected_partition .inside_extended, false ) ;
 
 	//Retrieve Label info
@@ -212,6 +213,7 @@ Partition Dialog_Partition_New::Get_New_Partition()
 		UNALLOCATED .Set_Unallocated( part_temp .device_path,
 					      part_temp .sector_start,
 					      part_temp .sector_end,
+					      sector_size,
 					      true ) ;
 		part_temp .logicals .push_back( UNALLOCATED ) ;
 	}
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index 0acd82c..0a1453e 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -336,6 +336,7 @@ void GParted_Core::set_devices( std::vector<Device> & devices )
 				partition_temp .Set_Unallocated( temp_device .get_path(),
 								 0,
 								 temp_device .length,
+								 temp_device .sector_size,
 								 false );
 				//Place libparted messages in this unallocated partition
 				partition_temp .messages .insert( partition_temp .messages .end(),
@@ -794,6 +795,7 @@ void GParted_Core::set_device_partitions( Device & device )
 						     get_filesystem(),
 						     lp_partition ->geom .start,
 						     lp_partition ->geom .end,
+						     device .sector_size,
 						     lp_partition ->type,
 						     partition_is_busy ) ;
 				free( lp_path ) ;
@@ -836,6 +838,7 @@ void GParted_Core::set_device_partitions( Device & device )
 						     GParted::FS_EXTENDED,
 						     lp_partition ->geom .start,
 						     lp_partition ->geom .end,
+						     device .sector_size,
 						     false,
 						     partition_is_busy ) ;
 				free( lp_path ) ;
@@ -883,9 +886,10 @@ void GParted_Core::set_device_partitions( Device & device )
 				    device .partitions[ EXT_INDEX ] .logicals,
 				    device .partitions[ EXT_INDEX ] .sector_start,
 				    device .partitions[ EXT_INDEX ] .sector_end,
+				    device .sector_size,
 				    true ) ;
-	
-	insert_unallocated( device .get_path(), device .partitions, 0, device .length -1, false ) ; 
+
+	insert_unallocated( device .get_path(), device .partitions, 0, device .length -1, device .sector_size, false ) ; 
 }
 
 GParted::FILESYSTEM GParted_Core::get_filesystem() 
@@ -1079,10 +1083,11 @@ void GParted_Core::insert_unallocated( const Glib::ustring & device_path,
 				       std::vector<Partition> & partitions,
 				       Sector start,
 				       Sector end,
+				       Byte_Value sector_size,
 				       bool inside_extended )
 {
 	partition_temp .Reset() ;
-	partition_temp .Set_Unallocated( device_path, 0, 0, inside_extended ) ;
+	partition_temp .Set_Unallocated( device_path, 0, 0, sector_size, inside_extended ) ;
 	
 	//if there are no partitions at all..
 	if ( partitions .empty() )
diff --git a/src/Operation.cc b/src/Operation.cc
index c2ca581..cf87157 100644
--- a/src/Operation.cc
+++ b/src/Operation.cc
@@ -1,4 +1,5 @@
 /* Copyright (C) 2004 Bart
+ * Copyright (C) 2010 Curtis Gedak
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -42,10 +43,10 @@ int Operation::find_index_extended( const std::vector<Partition> & partitions )
 	return -1 ;
 }
 
-void Operation::insert_unallocated( std::vector<Partition> & partitions, Sector start, Sector end, bool inside_extended )
+void Operation::insert_unallocated( std::vector<Partition> & partitions, Sector start, Sector end, Byte_Value sector_size, bool inside_extended )
 {
 	Partition UNALLOCATED ;
-	UNALLOCATED .Set_Unallocated( device .get_path(), 0, 0, inside_extended ) ;
+	UNALLOCATED .Set_Unallocated( device .get_path(), 0, 0, sector_size, inside_extended ) ;
 	
 	//if there are no partitions at all..
 	if ( partitions .empty() )
diff --git a/src/OperationCopy.cc b/src/OperationCopy.cc
index b1684a9..332825a 100644
--- a/src/OperationCopy.cc
+++ b/src/OperationCopy.cc
@@ -55,7 +55,8 @@ void OperationCopy::apply_to_visual( std::vector<Partition> & partitions )
 			insert_unallocated( partitions[ index_extended ] .logicals,
 					    partitions[ index_extended ] .sector_start,
 					    partitions[ index_extended ] .sector_end,
-				    	    true ) ;
+					    device .sector_size,
+					    true ) ;
 		}
 	}
 	else
@@ -66,7 +67,7 @@ void OperationCopy::apply_to_visual( std::vector<Partition> & partitions )
 		{
 			partitions[ index ] = partition_new ;
 		
-			insert_unallocated( partitions, 0, device .length -1, false ) ;
+			insert_unallocated( partitions, 0, device .length -1, device .sector_size, false ) ;
 		}
 	}
 }
diff --git a/src/OperationCreate.cc b/src/OperationCreate.cc
index 1bd378c..9c7616d 100644
--- a/src/OperationCreate.cc
+++ b/src/OperationCreate.cc
@@ -50,7 +50,8 @@ void OperationCreate::apply_to_visual( std::vector<Partition> & partitions )
 			insert_unallocated( partitions[ index_extended ] .logicals,
 					    partitions[ index_extended ] .sector_start,
 					    partitions[ index_extended ] .sector_end,
-				    	    true ) ;
+					    device .sector_size,
+					    true ) ;
 		}
 	}
 	else
@@ -61,7 +62,7 @@ void OperationCreate::apply_to_visual( std::vector<Partition> & partitions )
 		{
 			partitions[ index ] = partition_new ;
 		
-			insert_unallocated( partitions, 0, device .length -1, false ) ;
+			insert_unallocated( partitions, 0, device .length -1, device .sector_size, false ) ;
 		}
 	}
 }
diff --git a/src/OperationDelete.cc b/src/OperationDelete.cc
index b74a657..659eef1 100644
--- a/src/OperationDelete.cc
+++ b/src/OperationDelete.cc
@@ -45,6 +45,7 @@ void OperationDelete::apply_to_visual( std::vector<Partition> & partitions )
 			insert_unallocated( partitions[ index_extended ] .logicals,
 					    partitions[ index_extended ] .sector_start,
 					    partitions[ index_extended ] .sector_end,
+					    device .sector_size,
 					    true ) ;
 		
 			//if deleted partition was logical we have to decrease the partitionnumbers of the logicals
@@ -65,7 +66,7 @@ void OperationDelete::apply_to_visual( std::vector<Partition> & partitions )
 		{
 			remove_original_and_adjacent_unallocated( partitions, index ) ;
 			
-			insert_unallocated( partitions, 0, device .length -1, false ) ;
+			insert_unallocated( partitions, 0, device .length -1, device .sector_size, false ) ;
 		}
 	}
 }
diff --git a/src/OperationResizeMove.cc b/src/OperationResizeMove.cc
index ffcdf17..57e31a6 100644
--- a/src/OperationResizeMove.cc
+++ b/src/OperationResizeMove.cc
@@ -136,8 +136,9 @@ void OperationResizeMove::apply_normal_to_visual( std::vector<Partition> & parti
 			 remove_adjacent_unallocated( partitions[ index_extended ] .logicals, index ) ;
 
 			 insert_unallocated( partitions[ index_extended ] .logicals,
-				    	     partitions[ index_extended ] .sector_start,
-				    	     partitions[ index_extended ] .sector_end,
+					     partitions[ index_extended ] .sector_start,
+					     partitions[ index_extended ] .sector_end,
+					     device .sector_size,
 					     true ) ;
 		}
 	}
@@ -150,7 +151,7 @@ void OperationResizeMove::apply_normal_to_visual( std::vector<Partition> & parti
 			partitions[ index ] = partition_new ;
 			remove_adjacent_unallocated( partitions, index ) ;
 
-			insert_unallocated( partitions, 0, device .length -1, false ) ;
+			insert_unallocated( partitions, 0, device .length -1, device .sector_size, false ) ;
 		}
 	}
 }
@@ -171,7 +172,7 @@ void OperationResizeMove::apply_extended_to_visual( std::vector<Partition> & par
 			partitions[ index_extended ] .sector_end = partition_new .sector_end ;
 		}
 	
-		insert_unallocated( partitions, 0, device .length -1, false ) ;
+		insert_unallocated( partitions, 0, device .length -1, device .sector_size, false ) ;
 	}
 	
 	//stuff INSIDE extended partition
@@ -190,6 +191,7 @@ void OperationResizeMove::apply_extended_to_visual( std::vector<Partition> & par
 		insert_unallocated( partitions[ index_extended ] .logicals,
 				    partitions[ index_extended ] .sector_start,
 				    partitions[ index_extended ] .sector_end,
+				    device .sector_size,
 				    true ) ;
 	}
 }
diff --git a/src/Partition.cc b/src/Partition.cc
index 33facd3..ab22fb6 100644
--- a/src/Partition.cc
+++ b/src/Partition.cc
@@ -1,5 +1,5 @@
 /* Copyright (C) 2004 Bart
- * Copyright (C) 2008, 2009 Curtis Gedak
+ * Copyright (C) 2008, 2009, 2010 Curtis Gedak
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -58,6 +58,7 @@ void Partition::Set(	const Glib::ustring & device_path,
 			FILESYSTEM filesystem,
 			Sector sector_start,
 			Sector sector_end,
+			Byte_Value sector_size,
 			bool inside_extended,
 			bool busy )
 {
@@ -70,6 +71,7 @@ void Partition::Set(	const Glib::ustring & device_path,
 	this ->filesystem = filesystem;
 	this ->sector_start = sector_start;
 	this ->sector_end = sector_end;
+	this ->sector_size = sector_size;
 	this ->inside_extended = inside_extended;
 	this ->busy = busy;
 	
@@ -97,6 +99,7 @@ void Partition::set_used( Sector sectors_used )
 void Partition::Set_Unallocated( const Glib::ustring & device_path,
 				 Sector sector_start,
 				 Sector sector_end,
+				 Byte_Value sector_size,
 				 bool inside_extended )
 {
 	Reset() ;
@@ -108,6 +111,7 @@ void Partition::Set_Unallocated( const Glib::ustring & device_path,
 	     GParted::FS_UNALLOCATED,
 	     sector_start,
 	     sector_end,
+	     sector_size,
 	     inside_extended,
 	     false ); 
 	
diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc
index f53a1dc..9e012a9 100644
--- a/src/Win_GParted.cc
+++ b/src/Win_GParted.cc
@@ -1404,11 +1404,12 @@ void Win_GParted::activate_resize()
 					selected_partition .Set_Unallocated( devices[ current_device ] .get_path(),
 									     selected_partition .sector_start,
 									     selected_partition .sector_end,
+									     devices[current_device] .sector_size,
 									     selected_partition .inside_extended ) ;
 
 					Operation * operation = new OperationCreate( devices[ current_device ],
-							 			     selected_partition,
-							 			     dialog .Get_New_Partition() ) ;
+										     selected_partition,
+										     dialog .Get_New_Partition( devices[ current_device ] .sector_size ) ) ;
 					operation ->icon = render_icon( Gtk::Stock::NEW, Gtk::ICON_SIZE_MENU );
 
 					Add_Operation( operation ) ;
@@ -1420,8 +1421,8 @@ void Win_GParted::activate_resize()
 		else//normal move/resize on existing partition
 		{
 			Operation * operation = new OperationResizeMove( devices[ current_device ],
-					 			         selected_partition,
-							     		 dialog .Get_New_Partition() );
+								         selected_partition,
+								         dialog .Get_New_Partition( devices[ current_device ] .sector_size) );
 			operation ->icon = render_icon( Gtk::Stock::GOTO_LAST, Gtk::ICON_SIZE_MENU );
 
 			Add_Operation( operation ) ;
@@ -1460,9 +1461,9 @@ void Win_GParted::activate_paste()
 				dialog .hide() ;
 
 				Operation * operation = new OperationCopy( devices[ current_device ],
-					 	       			   selected_partition,
-						       			   dialog .Get_New_Partition(),
-						       			   copied_partition ) ;
+									   selected_partition,
+									   dialog .Get_New_Partition( devices[ current_device ] .sector_size ),
+									   copied_partition ) ;
 				operation ->icon = render_icon( Gtk::Stock::COPY, Gtk::ICON_SIZE_MENU );
 
 				Add_Operation( operation ) ;
@@ -1527,8 +1528,8 @@ void Win_GParted::activate_new()
 			
 			new_count++ ;
 			Operation *operation = new OperationCreate( devices[ current_device ],
-							 	    selected_partition,
-							 	    dialog .Get_New_Partition() ) ;
+								    selected_partition,
+								    dialog .Get_New_Partition( devices[ current_device ] .sector_size ) ) ;
 			operation ->icon = render_icon( Gtk::Stock::NEW, Gtk::ICON_SIZE_MENU );
 
 			Add_Operation( operation );
@@ -1668,14 +1669,15 @@ void Win_GParted::activate_format( GParted::FILESYSTEM new_fs )
 	
 	//ok we made it.  lets create an fitting partition object
 	Partition part_temp ;
-	part_temp .Set( devices[ current_device ] .get_path(), 
-			selected_partition .get_path(), 
-			selected_partition .partition_number, 
+	part_temp .Set( devices[ current_device ] .get_path(),
+			selected_partition .get_path(),
+			selected_partition .partition_number,
 			selected_partition .type,
-			new_fs, 
+			new_fs,
 			selected_partition .sector_start,
-			selected_partition .sector_end, 
-			selected_partition .inside_extended, 
+			selected_partition .sector_end,
+			devices[ current_device ] .sector_size,
+			selected_partition .inside_extended,
 			false ) ;
 	 
 	part_temp .status = GParted::STAT_FORMATTED ;
@@ -1969,14 +1971,15 @@ void Win_GParted::activate_label_partition()
 		dialog .hide() ;
 		//Make a duplicate of the selected partition (used in UNDO)
 		Partition part_temp ;
-		part_temp .Set( devices[ current_device ] .get_path(), 
-				selected_partition .get_path(), 
-				selected_partition .partition_number, 
+		part_temp .Set( devices[ current_device ] .get_path(),
+				selected_partition .get_path(),
+				selected_partition .partition_number,
 				selected_partition .type,
-				selected_partition .filesystem, 
+				selected_partition .filesystem,
 				selected_partition .sector_start,
-				selected_partition .sector_end, 
-				selected_partition .inside_extended, 
+				selected_partition .sector_end,
+				devices[ current_device ] .sector_size,
+				selected_partition .inside_extended,
 				false ) ;
 
 		part_temp .label = dialog .get_new_label();



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