Change partition alignment check box to a drop down menu
Also add signal handler to alignment menu to update file system minimum size. This enhancement is to prepare for adding a third alignment option to align to MiB.
This commit is contained in:
parent
3db6b074c9
commit
2cdfb4c55a
|
@ -29,6 +29,7 @@
|
|||
#include <gtkmm/table.h>
|
||||
#include <gtkmm/box.h>
|
||||
#include <gtkmm/tooltips.h>
|
||||
#include <gtkmm/optionmenu.h>
|
||||
|
||||
namespace GParted
|
||||
{
|
||||
|
@ -69,7 +70,8 @@ protected:
|
|||
|
||||
Gtk::HBox hbox_main ;
|
||||
Gtk::SpinButton spinbutton_before, spinbutton_size, spinbutton_after;
|
||||
Gtk::CheckButton checkbutton_round_to_cylinders ;
|
||||
Gtk::OptionMenu optionmenu_alignment ;
|
||||
Gtk::Menu menu_alignment ;
|
||||
|
||||
//used to enable/disable OKbutton...
|
||||
int ORIG_BEFORE, ORIG_SIZE, ORIG_AFTER ;
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include "../include/Dialog_Base_Partition.h"
|
||||
|
||||
#include <gtkmm/optionmenu.h>
|
||||
#include <gtkmm/checkbutton.h>
|
||||
|
||||
namespace GParted
|
||||
{
|
||||
|
|
|
@ -44,6 +44,12 @@ enum PartitionStatus {
|
|||
STAT_FORMATTED = 3
|
||||
};
|
||||
|
||||
enum PartitionAlignment {
|
||||
ALIGN_CYLINDER = 0, //Align to nearest cylinder
|
||||
ALIGN_STRICT = 1 //Strict alignment - no rounding
|
||||
// Indicator if start and end sectors must remain unchanged
|
||||
};
|
||||
|
||||
//FIXME: we should make a difference between partition- and file system size.
|
||||
//especially in the core this can make a difference when giving detailed feedback. With new cairosupport in gtkmm
|
||||
//it's even possible to make stuff like this visible in the GUI in a nice and clear way
|
||||
|
@ -101,6 +107,7 @@ public:
|
|||
int partition_number;
|
||||
PartitionType type;// UNALLOCATED, PRIMARY, LOGICAL, etc...
|
||||
PartitionStatus status; //STAT_REAL, STAT_NEW, etc..
|
||||
PartitionAlignment alignment; //ALIGN_CYLINDER, ALIGN_STRICT, etc
|
||||
FILESYSTEM filesystem ;
|
||||
Glib::ustring label ;
|
||||
Glib::ustring uuid ;
|
||||
|
@ -116,7 +123,6 @@ public:
|
|||
|
||||
std::vector<Partition> logicals ;
|
||||
|
||||
bool strict ; //Indicator if start and end sectors must stay unchanged
|
||||
bool strict_start ; //Indicator if start sector must stay unchanged
|
||||
|
||||
Byte_Value sector_size ; //Sector size of the disk device needed for converting to/from sectors and bytes.
|
||||
|
|
|
@ -79,11 +79,6 @@ Dialog_Base_Partition::Dialog_Base_Partition()
|
|||
if ( ! fixed_start )
|
||||
before_value = spinbutton_before .get_value() ;
|
||||
|
||||
//add checkbutton
|
||||
checkbutton_round_to_cylinders .set_label( _("Round to cylinders") ) ;
|
||||
checkbutton_round_to_cylinders .set_active( true ) ;
|
||||
table_resize.attach( checkbutton_round_to_cylinders, 0, 1, 3, 4 ) ;
|
||||
|
||||
//connect signalhandlers of the spinbuttons
|
||||
if ( ! fixed_start )
|
||||
spinbutton_before .signal_value_changed() .connect(
|
||||
|
@ -97,6 +92,21 @@ Dialog_Base_Partition::Dialog_Base_Partition()
|
|||
sigc::bind<SPINBUTTON>(
|
||||
sigc::mem_fun(*this, &Dialog_Base_Partition::on_spinbutton_value_changed), AFTER ) ) ;
|
||||
|
||||
//add alignment
|
||||
/*TO TRANSLATORS: used as label for a list of choices. Align to: <optionmenu with choices> */
|
||||
table_resize .attach( * Utils::mk_label( static_cast<Glib::ustring>( _("Align to:") ) + "\t" ),
|
||||
0, 1, 3, 4, Gtk::FILL );
|
||||
|
||||
//fill partition alignment menu
|
||||
/*TO TRANSLATORS: Menu option for drop down menu "Align to:" */
|
||||
menu_alignment .items() .push_back( Gtk::Menu_Helpers::MenuElem( _("Cylinder") ) ) ;
|
||||
/*TO TRANSLATORS: Menu option for drop down menu "Align to:" */
|
||||
menu_alignment .items() .push_back( Gtk::Menu_Helpers::MenuElem( _("None") ) ) ;
|
||||
|
||||
optionmenu_alignment .set_menu( menu_alignment );
|
||||
|
||||
table_resize .attach( optionmenu_alignment, 1, 2, 3, 4, Gtk::FILL );
|
||||
|
||||
this->add_button( Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL );
|
||||
this ->show_all_children() ;
|
||||
}
|
||||
|
@ -153,8 +163,14 @@ Partition Dialog_Base_Partition::Get_New_Partition( Byte_Value sector_size )
|
|||
if ( selected_partition .sectors_used != -1 )
|
||||
selected_partition .sectors_unused = selected_partition .get_sector_length() - selected_partition .sectors_used ;
|
||||
|
||||
//set indicator of whether to use strict sector values, or to round to cylinders
|
||||
selected_partition .strict = ! checkbutton_round_to_cylinders .get_active() ;
|
||||
//set alignment
|
||||
switch ( optionmenu_alignment .get_history() )
|
||||
{
|
||||
case 0 : selected_partition .alignment = ALIGN_CYLINDER; break;
|
||||
case 1 : selected_partition .alignment = ALIGN_STRICT; break;
|
||||
|
||||
default : selected_partition .alignment = ALIGN_CYLINDER ;
|
||||
}
|
||||
|
||||
//if the original before value has not changed, then set indicator to keep start sector unchanged
|
||||
if ( ORIG_BEFORE == spinbutton_before .get_value_as_int() )
|
||||
|
|
|
@ -157,7 +157,11 @@ void Dialog_Partition_New::Set_Data( const Partition & partition,
|
|||
//euhrm, this wil only happen when there's a very small free space (usually the effect of a bad partitionmanager)
|
||||
if ( TOTAL_MB * (MEBIBYTE / this ->selected_partition .sector_size) < this ->cylinder_size )
|
||||
frame_resizer_base ->set_sensitive( false ) ;
|
||||
|
||||
|
||||
//connect signal handler for Dialog_Base_Partiton optionmenu_alignment
|
||||
optionmenu_alignment .signal_changed() .connect(
|
||||
sigc::bind<bool>( sigc::mem_fun( *this, &Dialog_Partition_New::optionmenu_changed ), false ) );
|
||||
|
||||
this ->show_all_children() ;
|
||||
}
|
||||
|
||||
|
@ -218,8 +222,14 @@ Partition Dialog_Partition_New::Get_New_Partition( Byte_Value sector_size )
|
|||
part_temp .logicals .push_back( UNALLOCATED ) ;
|
||||
}
|
||||
|
||||
//set indicator of whether to use strict sector values, or to round to cylinders
|
||||
part_temp .strict = ! checkbutton_round_to_cylinders .get_active() ;
|
||||
//set alignment
|
||||
switch ( optionmenu_alignment .get_history() )
|
||||
{
|
||||
case 0 : part_temp .alignment = GParted::ALIGN_CYLINDER; break;
|
||||
case 1 : part_temp .alignment = GParted::ALIGN_STRICT; break;
|
||||
|
||||
default : part_temp .alignment = GParted::ALIGN_CYLINDER ;
|
||||
}
|
||||
|
||||
return part_temp;
|
||||
}
|
||||
|
@ -246,12 +256,12 @@ void Dialog_Partition_New::optionmenu_changed( bool type )
|
|||
}
|
||||
}
|
||||
|
||||
//optionmenu_filesystem
|
||||
//optionmenu_filesystem and optionmenu_alignment
|
||||
if ( ! type )
|
||||
{
|
||||
fs = FILESYSTEMS[ optionmenu_filesystem .get_history() ] ;
|
||||
|
||||
if ( checkbutton_round_to_cylinders .get_active() )
|
||||
if ( optionmenu_alignment .get_history() == ALIGN_CYLINDER )
|
||||
{
|
||||
if ( (fs .MIN / selected_partition .sector_size) < cylinder_size )
|
||||
fs .MIN = cylinder_size * selected_partition .sector_size ;
|
||||
|
|
|
@ -372,11 +372,11 @@ Glib::ustring GParted_Core::get_thread_status_message( )
|
|||
|
||||
bool GParted_Core::snap_to_cylinder( const Device & device, Partition & partition, Glib::ustring & error )
|
||||
{
|
||||
if ( ! partition .strict )
|
||||
if ( partition .alignment != ALIGN_STRICT )
|
||||
{
|
||||
Sector diff = 0;
|
||||
if ( partition.type == TYPE_LOGICAL ||
|
||||
partition.sector_start == device .sectors
|
||||
partition.sector_start == device .sectors
|
||||
) {
|
||||
//Must account the relative offset between:
|
||||
// (A) the Extended Boot Record sector and the next track of the
|
||||
|
@ -1375,7 +1375,7 @@ bool GParted_Core::create_partition( Partition & new_partition, OperationDetail
|
|||
|
||||
if ( lp_partition )
|
||||
{
|
||||
if ( new_partition .strict )
|
||||
if ( new_partition .alignment == ALIGN_STRICT )
|
||||
{
|
||||
PedGeometry *geom = ped_geometry_new( lp_device,
|
||||
new_partition .sector_start,
|
||||
|
@ -1547,9 +1547,9 @@ bool GParted_Core::resize_move( const Device & device,
|
|||
Partition & partition_new,
|
||||
OperationDetail & operationdetail )
|
||||
{
|
||||
if ( partition_new .strict
|
||||
|| partition_new .strict_start
|
||||
|| calculate_exact_geom( partition_old, partition_new, operationdetail )
|
||||
if ( (partition_new .alignment == ALIGN_STRICT)
|
||||
|| partition_new .strict_start
|
||||
|| calculate_exact_geom( partition_old, partition_new, operationdetail )
|
||||
)
|
||||
{
|
||||
if ( partition_old .type == TYPE_EXTENDED )
|
||||
|
@ -1576,9 +1576,10 @@ bool GParted_Core::resize_move( const Device & device,
|
|||
temp .sector_end = partition_old .sector_start + partition_new .get_sector_length() -1 ;
|
||||
}
|
||||
|
||||
temp .strict = true ;
|
||||
PartitionAlignment previous_alignment = temp .alignment ;
|
||||
temp .alignment = ALIGN_STRICT ;
|
||||
bool succes = resize_move( device, partition_old, temp, operationdetail ) ;
|
||||
temp .strict = false ;
|
||||
temp .alignment = previous_alignment ;
|
||||
|
||||
return succes && resize_move( device, temp, partition_new, operationdetail ) ;
|
||||
}
|
||||
|
@ -1889,7 +1890,7 @@ bool GParted_Core::resize_move_partition( const Partition & partition_old,
|
|||
|
||||
if ( lp_partition )
|
||||
{
|
||||
if ( partition_new .strict || partition_new .strict_start ) {
|
||||
if ( (partition_new .alignment == ALIGN_STRICT) || partition_new .strict_start ) {
|
||||
PedGeometry *geom = ped_geometry_new( lp_device,
|
||||
partition_new .sector_start,
|
||||
partition_new .get_sector_length() ) ;
|
||||
|
|
|
@ -45,7 +45,7 @@ void Partition::Reset()
|
|||
partition_number = sector_start = sector_end = sectors_used = sectors_unused = -1;
|
||||
sector_size = 0 ;
|
||||
color .set( "black" ) ;
|
||||
inside_extended = busy = strict = strict_start = false ;
|
||||
inside_extended = busy = strict_start = false ;
|
||||
logicals .clear() ;
|
||||
flags .clear() ;
|
||||
mountpoints .clear() ;
|
||||
|
|
Loading…
Reference in New Issue