commented 'ss .imbue( std::locale( "" ) )' (#157871) cleanups allow forced

* src/Utils.cc: commented 'ss .imbue( std::locale( "" ) )' (#157871)
* src/Win_GParted.cc,
  src/TreeView_Detail.cc,
  src/Dialog_Base_Partition.cc: cleanups
* include/Dialog_Partition_New.h,
  include/Partition.h,
  src/Dialog_Partition_New.cc,
  src/GParted_Core.cc,
  src/Partition.cc: allow forced partitionsizes (aka: do not round to
  cylinder). (#169486)
This commit is contained in:
Bart Hakvoort 2006-01-07 15:04:42 +00:00
parent 9565c28d56
commit f9ab3cdd3c
10 changed files with 109 additions and 65 deletions

View File

@ -1,3 +1,16 @@
2006-01-07 Bart Hakvoort <hakvoort@cvs.gnome.org>
* src/Utils.cc: commented 'ss .imbue( std::locale( "" ) )' (#157871)
* src/Win_GParted.cc,
src/TreeView_Detail.cc,
src/Dialog_Base_Partition.cc: cleanups
* include/Dialog_Partition_New.h,
include/Partition.h,
src/Dialog_Partition_New.cc,
src/GParted_Core.cc,
src/Partition.cc: allow forced partitionsizes (aka: do not round to
cylinder). (#169486)
2006-01-06 Bart Hakvoort <hakvoort@cvs.gnome.org>
* src/VBox_VisualDisk.cc: replaced free_color() with deprecated

View File

@ -20,8 +20,8 @@
#include "../include/Dialog_Base_Partition.h"
#include <gtkmm/messagedialog.h>
#include <gtkmm/optionmenu.h>
#include <gtkmm/checkbutton.h>
namespace GParted
{
@ -30,7 +30,7 @@ class Dialog_Partition_New : public Dialog_Base_Partition
{
public:
Dialog_Partition_New() ;
void Set_Data( const Partition & partition, bool any_extended, unsigned short new_count, const std::vector <FS> & FILESYSTEMS, bool only_unformatted, int cylinder_size );
void Set_Data( const Partition & partition, bool any_extended, unsigned short new_count, const std::vector<FS> & FILESYSTEMS, bool only_unformatted, int cylinder_size );
Partition Get_New_Partition() ;//overridden function
private:
@ -38,6 +38,7 @@ private:
Gtk::Table table_create;
Gtk::OptionMenu optionmenu_type, optionmenu_filesystem;
Gtk::CheckButton checkbutton_round_to_cylinders ;
Gtk::Menu menu_type, menu_filesystem;
std::vector<FS> FILESYSTEMS ;

View File

@ -97,6 +97,8 @@ public:
std::vector<Partition> logicals ;
bool strict ;
private:

View File

@ -76,15 +76,13 @@ Dialog_Base_Partition::Dialog_Base_Partition( )
//connect signalhandlers of the spinbuttons
if ( ! fixed_start )
spinbutton_before .signal_value_changed( ) .connect( sigc::bind<SPINBUTTON>( sigc::mem_fun( *this, &Dialog_Base_Partition::on_spinbutton_value_changed), BEFORE) ) ;
spinbutton_before .signal_value_changed() .connect(
sigc::bind<SPINBUTTON>( sigc::mem_fun(*this, &Dialog_Base_Partition::on_spinbutton_value_changed), BEFORE ) ) ;
spinbutton_size .signal_value_changed( ) .connect( sigc::bind<SPINBUTTON>( sigc::mem_fun( *this, &Dialog_Base_Partition::on_spinbutton_value_changed), SIZE) ) ;
spinbutton_after .signal_value_changed( ) .connect( sigc::bind<SPINBUTTON>( sigc::mem_fun( *this, &Dialog_Base_Partition::on_spinbutton_value_changed), AFTER) ) ;
//pack warning about small differences in values..
this ->get_vbox( ) ->pack_start( * Utils::mk_label( "\n <i>" + (Glib::ustring) _( "NOTE: values on disk may differ slightly from the values entered here.") + "</i>" ), Gtk::PACK_SHRINK );
this ->get_vbox( ) ->pack_start( * Utils::mk_label( "" ), Gtk::PACK_SHRINK ); //filler :-P
spinbutton_size .signal_value_changed() .connect(
sigc::bind<SPINBUTTON>( sigc::mem_fun(*this, &Dialog_Base_Partition::on_spinbutton_value_changed), SIZE ) ) ;
spinbutton_after .signal_value_changed() .connect(
sigc::bind<SPINBUTTON>( sigc::mem_fun(*this, &Dialog_Base_Partition::on_spinbutton_value_changed), AFTER ) ) ;
this->add_button( Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL );
this ->show_all_children( ) ;
@ -133,7 +131,8 @@ Partition Dialog_Base_Partition::Get_New_Partition( )
//set new value of unused..
if ( selected_partition .sectors_used != -1 )
selected_partition .sectors_unused = ( selected_partition .sector_end - selected_partition .sector_start) - selected_partition .sectors_used ;
selected_partition .sectors_unused =
(selected_partition .sector_end - selected_partition .sector_start) - selected_partition .sectors_used ;
return selected_partition ;
}
@ -142,19 +141,24 @@ void Dialog_Base_Partition::Set_Confirm_Button( CONFIRMBUTTON button_type )
{
switch( button_type )
{
case NEW : this ->add_button( Gtk::Stock::ADD, Gtk::RESPONSE_OK );
break ;
case RESIZE_MOVE: image_temp = manage( new Gtk::Image( Gtk::Stock::GOTO_LAST, Gtk::ICON_SIZE_BUTTON ) );
hbox_resize_move .pack_start( *image_temp, Gtk::PACK_EXPAND_PADDING ) ;
hbox_resize_move .pack_start( * Utils::mk_label( fixed_start ? _("Resize") : _("Resize/Move") ), Gtk::PACK_EXPAND_PADDING ) ;
button_resize_move .add( hbox_resize_move ) ;
case NEW :
this ->add_button( Gtk::Stock::ADD, Gtk::RESPONSE_OK );
this ->add_action_widget ( button_resize_move, Gtk::RESPONSE_OK ) ;
button_resize_move .set_sensitive( false ) ;
break ;
break ;
case RESIZE_MOVE:
image_temp = manage( new Gtk::Image( Gtk::Stock::GOTO_LAST, Gtk::ICON_SIZE_BUTTON ) );
hbox_resize_move .pack_start( *image_temp, Gtk::PACK_EXPAND_PADDING ) ;
hbox_resize_move .pack_start( * Utils::mk_label( fixed_start ? _("Resize") : _("Resize/Move") ), Gtk::PACK_EXPAND_PADDING ) ;
button_resize_move .add( hbox_resize_move ) ;
case PASTE : this ->add_button( Gtk::Stock::PASTE, Gtk::RESPONSE_OK );
break ;
this ->add_action_widget ( button_resize_move, Gtk::RESPONSE_OK ) ;
button_resize_move .set_sensitive( false ) ;
break ;
case PASTE :
this ->add_button( Gtk::Stock::PASTE, Gtk::RESPONSE_OK );
break ;
}
}
@ -190,7 +194,7 @@ void Dialog_Base_Partition::on_signal_resize( int x_start, int x_end, Frame_Resi
spinbutton_size .set_value( ( x_end - x_start ) * MB_PER_PIXEL ) ;
fixed_start ? before_value = 0 : before_value = spinbutton_before .get_value( ) ;
before_value = fixed_start ? 0 : spinbutton_before .get_value() ;
if ( arrow == Frame_Resizer_Base::ARROW_RIGHT ) //don't touch freespace before, leave it as it is
{
@ -222,50 +226,49 @@ void Dialog_Base_Partition::on_spinbutton_value_changed( SPINBUTTON spinbutton )
{
if ( ! GRIP )
{
fixed_start ? before_value = 0 : before_value = spinbutton_before .get_value( ) ;
before_value = fixed_start ? 0 : spinbutton_before .get_value() ;
//Balance the spinbuttons
switch ( spinbutton )
{
case BEFORE : spinbutton_after .set_value( TOTAL_MB - spinbutton_size .get_value( ) - before_value) ;
spinbutton_size .set_value( TOTAL_MB - before_value - spinbutton_after .get_value( ) ) ;
case BEFORE :
spinbutton_after .set_value( TOTAL_MB - spinbutton_size .get_value() - before_value ) ;
spinbutton_size .set_value( TOTAL_MB - before_value - spinbutton_after .get_value() ) ;
break;
case SIZE : spinbutton_after .set_value( TOTAL_MB - before_value - spinbutton_size .get_value( ) );
if ( ! fixed_start )
spinbutton_before .set_value( TOTAL_MB - spinbutton_size .get_value( ) - spinbutton_after .get_value( ) );
break ;
case SIZE :
spinbutton_after .set_value( TOTAL_MB - before_value - spinbutton_size .get_value() );
if ( ! fixed_start )
spinbutton_before .set_value( TOTAL_MB - spinbutton_size .get_value() - spinbutton_after .get_value() );
break;
case AFTER : if ( ! fixed_start )
spinbutton_before .set_value( TOTAL_MB - spinbutton_size .get_value( ) - spinbutton_after .get_value( ) );
break;
case AFTER :
if ( ! fixed_start )
spinbutton_before .set_value( TOTAL_MB - spinbutton_size .get_value() - spinbutton_after .get_value() );
spinbutton_size .set_value( TOTAL_MB - before_value - spinbutton_after .get_value( ) ) ;
spinbutton_size .set_value( TOTAL_MB - before_value - spinbutton_after .get_value() ) ;
break;
break;
}
//And apply the changes to the visual view...
if ( ! fixed_start )
frame_resizer_base ->set_x_start( Utils::Round( spinbutton_before .get_value( ) / MB_PER_PIXEL ) ) ;
frame_resizer_base ->set_x_start( Utils::Round( spinbutton_before .get_value() / MB_PER_PIXEL ) ) ;
frame_resizer_base ->set_x_end( 500 - Utils::Round( spinbutton_after .get_value( ) / MB_PER_PIXEL ) ) ;
frame_resizer_base ->set_x_end( 500 - Utils::Round( spinbutton_after .get_value() / MB_PER_PIXEL ) ) ;
frame_resizer_base ->Draw_Partition( ) ;
frame_resizer_base ->Draw_Partition() ;
Check_Change( ) ;
Check_Change() ;
}
}
void Dialog_Base_Partition::Check_Change( )
{
if ( ORIG_BEFORE == spinbutton_before .get_value_as_int( ) &&
ORIG_SIZE == spinbutton_size .get_value_as_int( ) &&
ORIG_AFTER == spinbutton_after .get_value_as_int( )
)
button_resize_move .set_sensitive( false ) ;
else
button_resize_move .set_sensitive( true ) ;
button_resize_move .set_sensitive(
ORIG_BEFORE != spinbutton_before .get_value_as_int() ||
ORIG_SIZE != spinbutton_size .get_value_as_int() ||
ORIG_AFTER != spinbutton_after .get_value_as_int() ) ;
}
Dialog_Base_Partition::~Dialog_Base_Partition()

View File

@ -29,6 +29,14 @@ Dialog_Partition_New::Dialog_Partition_New( )
//set used (in pixels)...
frame_resizer_base ->set_used( 0 ) ;
//checkbutton..
checkbutton_round_to_cylinders .set_label( _("Round to cylinders") ) ;
checkbutton_round_to_cylinders .set_active( true ) ;
checkbutton_round_to_cylinders .signal_clicked() .connect(
sigc::bind<bool>( sigc::mem_fun(*this, &Dialog_Partition_New::optionmenu_changed), false ) ) ;
this ->get_vbox() ->pack_start( checkbutton_round_to_cylinders, Gtk::PACK_SHRINK ) ;
}
void Dialog_Partition_New::Set_Data( const Partition & partition, bool any_extended, unsigned short new_count, const std::vector<FS> & FILESYSTEMS, bool only_unformatted, int cylinder_size )
@ -125,7 +133,8 @@ Partition Dialog_Partition_New::Get_New_Partition()
new_start = START + (Sector) (spinbutton_before .get_value( ) * MEGABYTE) ;
new_end = new_start + (Sector) (spinbutton_size .get_value( ) * MEGABYTE) ;
//due to loss of precision during calcs from Sector -> MB and back, it is possible the new partition thinks it's bigger then it can be. Here we try to solve this.
/* due to loss of precision during calcs from Sector -> MB and back, it is possible the new
* partition thinks it's bigger then it can be. Here we try to solve this.*/
if ( new_start < selected_partition.sector_start )
new_start = selected_partition.sector_start ;
if ( new_end > selected_partition.sector_end )
@ -153,6 +162,8 @@ Partition Dialog_Partition_New::Get_New_Partition()
part_temp .logicals .push_back( UNALLOCATED ) ;
}
part_temp .strict = ! checkbutton_round_to_cylinders .get_active() ;
return part_temp;
}
@ -178,9 +189,15 @@ void Dialog_Partition_New::optionmenu_changed( bool type )
//optionmenu_filesystem
if ( ! type )
{
fs = FILESYSTEMS[ optionmenu_filesystem .get_history( ) ] ;
if ( fs .MIN < cylinder_size )
fs .MIN = cylinder_size ;
fs = FILESYSTEMS[ optionmenu_filesystem .get_history() ] ;
if ( checkbutton_round_to_cylinders .get_active() )
{
if ( fs .MIN < cylinder_size )
fs .MIN = cylinder_size ;
}
else if ( fs .MIN < 1 )
fs .MIN = 1 ;
if ( selected_partition .Get_Length_MB( ) < fs .MIN )
fs .MIN = selected_partition .Get_Length_MB( ) ;
@ -200,7 +217,7 @@ void Dialog_Partition_New::optionmenu_changed( bool type )
//set fitting resizer colors
//backgroundcolor..
optionmenu_type .get_history( ) == 2 ? color_temp .set( "darkgrey" ) : color_temp .set( "white" ) ;
color_temp .set( optionmenu_type .get_history() == 2 ? "darkgrey" : "white" ) ;
frame_resizer_base ->override_default_rgb_unused_color( color_temp );
//partitioncolor..

View File

@ -745,7 +745,15 @@ int GParted_Core::Create_Empty_Partition( Partition & new_partition, bool copy )
c_part = ped_partition_new( lp_disk, type, NULL, new_partition .sector_start, new_partition .sector_end ) ;
if ( c_part )
{
constraint = ped_constraint_any( lp_device );
if ( new_partition .strict )
{
PedGeometry *geom = ped_geometry_new( lp_device, new_partition .sector_start, new_partition .get_length() ) ;
if ( geom )
constraint = ped_constraint_exact( geom ) ;
}
else
constraint = ped_constraint_any( lp_device );
if ( constraint )
{

View File

@ -33,7 +33,7 @@ void Partition::Reset()
filesystem = GParted::FS_UNALLOCATED ;
partition_number = sector_start = sector_end = sectors_used = sectors_unused = -1;
color .set( "black" ) ;
inside_extended = busy = false ;
inside_extended = busy = strict = false ;
logicals .clear() ;
}

View File

@ -57,8 +57,8 @@ TreeView_Detail::TreeView_Detail( )
treeview_detail_columns .text_color );
//pixbuf and text are both left aligned
get_column( 1 ) ->get_first_cell_renderer() ->property_xalign() = 0 ;
cell_renderer_text ->property_xalign() = 0 ;
get_column( 1 ) ->get_first_cell_renderer() ->property_xalign() = Gtk::ALIGN_LEFT ;
cell_renderer_text ->property_xalign() = Gtk::ALIGN_LEFT ;
//set alignment of numeric columns to right
for( short t = 2 ; t < 5 ; t++ )

View File

@ -243,7 +243,7 @@ Glib::ustring Utils::format_size( Sector size )
{
size *= 512 ;
std::stringstream ss ;
ss .imbue( std::locale( "" ) ) ;
//ss .imbue( std::locale( "" ) ) ; see #157871
ss << std::setiosflags( std::ios::fixed ) << std::setprecision( 2 ) ;
if ( size < 1073741824 )

View File

@ -497,15 +497,15 @@ void Win_GParted::Add_Operation( OperationType operationtype, const Partition &
allow_undo( true );
allow_apply( true );
Refresh_Visual( );
Refresh_Visual();
if ( operations .size( ) == 1 ) //first operation, open operationslist
open_operationslist( ) ;
if ( operations .size() == 1 ) //first operation, open operationslist
open_operationslist() ;
//make scrollwindow focus on the last operation in the list
Gtk::TreeIter iter = liststore_operations ->children( ) .end( ) ;
Gtk::TreeIter iter = liststore_operations ->children() .end() ;
iter-- ;
treeview_operations .set_cursor( static_cast <Gtk::TreePath> ( static_cast <Gtk::TreeRow> ( *iter ) ) ) ;
treeview_operations .set_cursor( static_cast<Gtk::TreePath>( static_cast<Gtk::TreeRow>( *iter ) ) ) ;
}
void Win_GParted::Refresh_Visual( )