added convenience function. Also fixed a small bug with incorrect labelvalue of fat16 upper limit

This commit is contained in:
Bart Hakvoort 2004-10-02 11:34:18 +00:00
parent 72f91cbc39
commit 05ee2f2254
6 changed files with 39 additions and 40 deletions

View File

@ -1,3 +1,11 @@
2004-10-0i2 Bart Hakvoort <gparted@users.sf.net>
* include/Dialog_Base_Partition.h,
src/Dialog_Base_Partition.cc: added void Set_MinMax_Text( long min, long max )
* src/Dialog_Partition_Copy.cc: fix incorrect upper limit for fat16 in label
* src/Dialog_Partition_New.cc: make use of this function, instead of accessing the label directly
* src/Dialog_Partition_Resize_Move.cc: fix incorrect upper limit for fat16 in label
2004-10-0i2 Bart Hakvoort <gparted@users.sf.net> 2004-10-0i2 Bart Hakvoort <gparted@users.sf.net>
* removed all stringstreams from the project (they were possibly responsible for rare chrashes in certain locales) * removed all stringstreams from the project (they were possibly responsible for rare chrashes in certain locales)

View File

@ -56,6 +56,7 @@ protected:
}; };
void Set_Confirm_Button( CONFIRMBUTTON button_type ) ; void Set_Confirm_Button( CONFIRMBUTTON button_type ) ;
void Set_MinMax_Text( long min, long max ) ;
double MB_PER_PIXEL ; double MB_PER_PIXEL ;
long TOTAL_MB ; long TOTAL_MB ;
@ -66,7 +67,6 @@ protected:
Sector total_length ; //total amount of sectors ( this can be up to 3 partitions...) Sector total_length ; //total amount of sectors ( this can be up to 3 partitions...)
Gtk::HBox hbox_main ; Gtk::HBox hbox_main ;
Gtk::Label label_minmax ;
Gtk::SpinButton spinbutton_before, spinbutton_size, spinbutton_after; Gtk::SpinButton spinbutton_before, spinbutton_size, spinbutton_after;
//used to enable/disable OKbutton... //used to enable/disable OKbutton...
@ -85,12 +85,14 @@ private:
void Check_Change() ; void Check_Change() ;
Gtk::VBox vbox_resize_move; Gtk::VBox vbox_resize_move;
Gtk::Label *label_temp; Gtk::Label label_minmax ;
Gtk::Table table_resize; Gtk::Table table_resize;
Gtk::HBox hbox_table, hbox_resizer, hbox_resize_move; Gtk::HBox hbox_table, hbox_resizer, hbox_resize_move;
Gtk::Tooltips tooltips; Gtk::Tooltips tooltips;
Gtk::Button button_resize_move ; Gtk::Button button_resize_move ;
Gtk::Image *image_temp ; Gtk::Image *image_temp ;
Glib::ustring str_temp ;
}; };
} //GParted } //GParted

View File

@ -51,26 +51,21 @@ Dialog_Base_Partition::Dialog_Base_Partition( )
vbox_resize_move .pack_start( hbox_table, Gtk::PACK_SHRINK ); vbox_resize_move .pack_start( hbox_table, Gtk::PACK_SHRINK );
//add spinbutton_before //add spinbutton_before
label_temp = manage( new Gtk::Label( (Glib::ustring) _( "Free Space Preceding (MB) :") + " \t" ) ) ; table_resize.attach( * mk_label( (Glib::ustring) _( "Free Space Preceding (MB) :") + " \t" ), 0, 1, 0, 1, Gtk::SHRINK);
table_resize.attach( *label_temp, 0, 1, 0, 1, Gtk::SHRINK);
spinbutton_before .set_numeric( true ); spinbutton_before .set_numeric( true );
spinbutton_before .set_increments( 1, 100 ); spinbutton_before .set_increments( 1, 100 );
table_resize.attach( spinbutton_before, 1, 2, 0, 1, Gtk::FILL); table_resize.attach( spinbutton_before, 1, 2, 0, 1, Gtk::FILL);
//add spinbutton_size //add spinbutton_size
label_temp = manage( new Gtk::Label( _( "New Size (MB) :") ) ) ; table_resize.attach( * mk_label( _( "New Size (MB) :" ) ), 0, 1, 1, 2 );
label_temp ->set_alignment( Gtk::ALIGN_LEFT );
table_resize.attach( *label_temp, 0, 1, 1, 2 );
spinbutton_size .set_numeric( true ); spinbutton_size .set_numeric( true );
spinbutton_size .set_increments( 1, 100 ); spinbutton_size .set_increments( 1, 100 );
table_resize.attach( spinbutton_size, 1, 2, 1, 2, Gtk::FILL); table_resize.attach( spinbutton_size, 1, 2, 1, 2, Gtk::FILL);
//add spinbutton_after //add spinbutton_after
label_temp = manage( new Gtk::Label( _( "Free Space Following (MB) :") ) ) ; table_resize.attach( * mk_label( _( "Free Space Following (MB) :") ), 0, 1, 2, 3 ) ;
label_temp ->set_alignment( Gtk::ALIGN_LEFT );
table_resize.attach( *label_temp, 0, 1, 2, 3 ) ;
spinbutton_after .set_numeric( true ); spinbutton_after .set_numeric( true );
spinbutton_after .set_increments( 1, 100 ); spinbutton_after .set_increments( 1, 100 );
@ -87,11 +82,8 @@ Dialog_Base_Partition::Dialog_Base_Partition( )
spinbutton_size .signal_value_changed().connect( sigc::bind<SPINBUTTON>( sigc::mem_fun( *this, &Dialog_Base_Partition::on_spinbutton_value_changed), SIZE) ) ; 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) ) ; spinbutton_after .signal_value_changed().connect( sigc::bind<SPINBUTTON>( sigc::mem_fun( *this, &Dialog_Base_Partition::on_spinbutton_value_changed), AFTER) ) ;
//pack label which warns about small differences in values.. //pack warning about small differences in values..
label_temp = manage( new Gtk::Label( ) ); this ->get_vbox() ->pack_start( * mk_label( "\n <i>" + (Glib::ustring) _( "NOTE: values on disk may differ slightly from the values entered here.") + "</i>" ), Gtk::PACK_SHRINK );
label_temp ->set_markup( "\n <i>" + (Glib::ustring) _( "NOTE: values on disk may differ slightly from the values entered here.") + "</i>" );
label_temp ->set_alignment( Gtk::ALIGN_LEFT ) ;
this ->get_vbox() ->pack_start( *label_temp, Gtk::PACK_SHRINK );
this ->get_vbox() ->pack_start( *( manage( new Gtk::Label( "") ) ), Gtk::PACK_SHRINK ); //filler :-P this ->get_vbox() ->pack_start( *( manage( new Gtk::Label( "") ) ), Gtk::PACK_SHRINK ); //filler :-P
@ -156,13 +148,13 @@ void Dialog_Base_Partition::Set_Confirm_Button( CONFIRMBUTTON button_type )
case NEW : this->add_button( Gtk::Stock::ADD,Gtk::RESPONSE_OK ); case NEW : this->add_button( Gtk::Stock::ADD,Gtk::RESPONSE_OK );
break ; break ;
case RESIZE_MOVE: if ( selected_partition.filesystem == "ext2" || selected_partition.filesystem == "ext3" ) case RESIZE_MOVE: if ( selected_partition.filesystem == "ext2" || selected_partition.filesystem == "ext3" )
label_temp = manage( new Gtk::Label( _("Resize") ) ) ; str_temp = _("Resize") ;
else else
label_temp = manage( new Gtk::Label( _("Resize/Move") ) ) ; str_temp = _("Resize/Move") ;
image_temp = manage( new Gtk::Image( Gtk::Stock::GOTO_LAST, Gtk::ICON_SIZE_BUTTON ) ); 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( *image_temp, Gtk::PACK_EXPAND_PADDING ) ;
hbox_resize_move .pack_start( *label_temp, Gtk::PACK_EXPAND_PADDING ) ; hbox_resize_move .pack_start( * mk_label( str_temp ), Gtk::PACK_EXPAND_PADDING ) ;
button_resize_move .add( hbox_resize_move ) ; button_resize_move .add( hbox_resize_move ) ;
this ->add_action_widget ( button_resize_move,Gtk::RESPONSE_OK ) ; this ->add_action_widget ( button_resize_move,Gtk::RESPONSE_OK ) ;
@ -175,6 +167,13 @@ void Dialog_Base_Partition::Set_Confirm_Button( CONFIRMBUTTON button_type )
} }
void Dialog_Base_Partition::Set_MinMax_Text( long min, long max )
{
str_temp = String::ucompose( _("Minimum Size: %1 MB"), min ) + "\t\t" ;
str_temp += String::ucompose( _("Maximum Size: %1 MB"), max ) ;
label_minmax .set_text( str_temp ) ;
}
void Dialog_Base_Partition::on_signal_move( int x_start, int x_end ) void Dialog_Base_Partition::on_signal_move( int x_start, int x_end )
{ {
GRIP = true ; GRIP = true ;
@ -261,7 +260,7 @@ void Dialog_Base_Partition::on_signal_resize( int x_start, int x_end, Frame_Resi
GRIP = false ; GRIP = false ;
} }
void Dialog_Base_Partition::on_spinbutton_value_changed( SPINBUTTON spinbutton ) void Dialog_Base_Partition::on_spinbutton_value_changed( SPINBUTTON spinbutton )
{ {
if ( ! GRIP ) if ( ! GRIP )
{ {
@ -283,7 +282,7 @@ void Dialog_Base_Partition::on_spinbutton_value_changed( SPINBUTTON spinbutton
case AFTER : if ( ! fixed_start ) case AFTER : if ( ! fixed_start )
spinbutton_before .set_value( TOTAL_MB - spinbutton_size.get_value() - spinbutton_after.get_value() ); 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;
} }
@ -291,7 +290,7 @@ void Dialog_Base_Partition::on_spinbutton_value_changed( SPINBUTTON spinbutton
//And apply the changes to the visual view... //And apply the changes to the visual view...
if ( ! fixed_start ) if ( ! fixed_start )
frame_resizer_base ->set_x_start( (int) (spinbutton_before .get_value() / MB_PER_PIXEL + 0.5) ) ; frame_resizer_base ->set_x_start( (int) (spinbutton_before .get_value() / MB_PER_PIXEL + 0.5) ) ;
frame_resizer_base ->set_x_end( (int) ( 500 - ( (double) spinbutton_after .get_value() / MB_PER_PIXEL ) + 0.5 ) ) ; frame_resizer_base ->set_x_end( (int) ( 500 - ( (double) spinbutton_after .get_value() / MB_PER_PIXEL ) + 0.5 ) ) ;

View File

@ -51,7 +51,7 @@ void Dialog_Partition_Copy::Set_Data( Partition & selected_partition, Partition
spinbutton_before .set_value( 0 ) ; spinbutton_before .set_value( 0 ) ;
//set values of spinbutton_size (check for fat16 maxsize of 1023 MB) //set values of spinbutton_size (check for fat16 maxsize of 1023 MB)
double UPPER; long UPPER;
if ( copied_partition.filesystem == "fat16" && Sector_To_MB( total_length ) > 1023 ) if ( copied_partition.filesystem == "fat16" && Sector_To_MB( total_length ) > 1023 )
UPPER = 1023 ; UPPER = 1023 ;
else else
@ -65,9 +65,7 @@ void Dialog_Partition_Copy::Set_Data( Partition & selected_partition, Partition
spinbutton_after .set_value( TOTAL_MB - copied_partition .Get_Length_MB() ) ; spinbutton_after .set_value( TOTAL_MB - copied_partition .Get_Length_MB() ) ;
//set contents of label_minmax //set contents of label_minmax
Glib::ustring str_temp = String::ucompose( _("Minimum Size: %1 MB"), copied_partition .Get_Length_MB() +1 ) + "\t\t" ; Set_MinMax_Text( copied_partition .Get_Length_MB() +1, UPPER ) ;
str_temp += String::ucompose( _("Maximum Size: %1 MB"), Sector_To_MB( total_length ) ) ;
label_minmax.set_text( str_temp ) ;
//set global selected_partition (see Dialog_Base_Partition::Get_New_Partition ) //set global selected_partition (see Dialog_Base_Partition::Get_New_Partition )
this ->selected_partition = copied_partition ; this ->selected_partition = copied_partition ;

View File

@ -108,9 +108,7 @@ void Dialog_Partition_New::Set_Data( const Partition & partition, bool any_exten
GRIP = false ; GRIP = false ;
//set contents of label_minmax //set contents of label_minmax
Glib::ustring str_temp = String::ucompose( _("Minimum Size: %1 MB"), 1 ) +"\t\t" ; Set_MinMax_Text( 1, TOTAL_MB ) ;
str_temp += String::ucompose( _("Maximum Size: %1 MB"), TOTAL_MB ) ;
label_minmax.set_text( str_temp ) ;
this ->show_all_children() ; this ->show_all_children() ;
} }
@ -195,9 +193,7 @@ void Dialog_Partition_New::optionmenu_changed( bool type )
spinbutton_after .set_range( 0, TOTAL_MB - MIN ) ; spinbutton_after .set_range( 0, TOTAL_MB - MIN ) ;
//set contents of label_minmax //set contents of label_minmax
Glib::ustring str_temp = String::ucompose( _("Minimum Size: %1 MB"), MIN ) + "\t\t" ; Set_MinMax_Text( MIN, MAX ) ;
str_temp += String::ucompose( _("Maximum Size: %1 MB"), MAX ) ;
label_minmax.set_text( str_temp ) ;
} }

View File

@ -116,7 +116,7 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector <Partit
//set values of spinbutton_size //set values of spinbutton_size
//since some filesystems have upper and lower limits we need to check for this //since some filesystems have upper and lower limits we need to check for this
double LOWER, UPPER; long LOWER, UPPER;
if ( selected_partition.filesystem == "fat16" && selected_partition .Get_Used_MB() < 32 ) if ( selected_partition.filesystem == "fat16" && selected_partition .Get_Used_MB() < 32 )
LOWER = 32 +1 ; LOWER = 32 +1 ;
else if ( selected_partition.filesystem == "fat32" && selected_partition .Get_Used_MB() < 256 ) else if ( selected_partition.filesystem == "fat32" && selected_partition .Get_Used_MB() < 256 )
@ -137,9 +137,7 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector <Partit
spinbutton_after .set_value( Sector_To_MB( next ) ) ; spinbutton_after .set_value( Sector_To_MB( next ) ) ;
//set contents of label_minmax //set contents of label_minmax
Glib::ustring str_temp = String::ucompose( _("Minimum Size: %1 MB"), LOWER ) + "\t\t" ; Set_MinMax_Text( LOWER, UPPER ) ;
str_temp += String::ucompose( _("Maximum Size: %1 MB"), Sector_To_MB( total_length ) ) ;
label_minmax.set_text( str_temp ) ;
} }
@ -225,9 +223,7 @@ void Dialog_Partition_Resize_Move::Resize_Move_Extended( const std::vector <Part
spinbutton_after .set_value( Sector_To_MB( next ) ) ; spinbutton_after .set_value( Sector_To_MB( next ) ) ;
//set contents of label_minmax //set contents of label_minmax
Glib::ustring str_temp = String::ucompose( _("Minimum Size: %1 MB"), Sector_To_MB( used ) +1 ) + "\t\t" ; Set_MinMax_Text( Sector_To_MB( used ) +1, Sector_To_MB( total_length ) ) ;
str_temp += String::ucompose( _("Maximum Size: %1 MB"), Sector_To_MB( total_length ) ) ;
label_minmax.set_text( str_temp ) ;
} }