2009-11-05 11:08:32 -07:00
|
|
|
/* Copyright (C) 2004 Bart
|
2011-01-16 10:45:25 -07:00
|
|
|
* Copyright (C) 2008, 2009, 2010, 2011 Curtis Gedak
|
2004-09-19 14:24:53 -06:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2014-01-23 03:59:48 -07:00
|
|
|
* GNU General Public License for more details.
|
2004-09-19 14:24:53 -06:00
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2014-01-23 03:59:48 -07:00
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2004-09-19 14:24:53 -06:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "../include/Dialog_Base_Partition.h"
|
|
|
|
|
|
|
|
namespace GParted
|
|
|
|
{
|
|
|
|
|
2006-03-24 12:08:41 -07:00
|
|
|
Dialog_Base_Partition::Dialog_Base_Partition()
|
2004-09-19 14:24:53 -06:00
|
|
|
{
|
|
|
|
this ->set_has_separator( false ) ;
|
|
|
|
frame_resizer_base = NULL;
|
|
|
|
GRIP = false ;
|
2004-10-02 03:39:16 -06:00
|
|
|
this ->fixed_start = false ;
|
|
|
|
this ->set_resizable( false );
|
2005-01-22 10:23:52 -07:00
|
|
|
ORIG_BEFORE = ORIG_SIZE = ORIG_AFTER = -1 ;
|
2010-05-20 10:00:14 -06:00
|
|
|
MIN_SPACE_BEFORE_MB = -1 ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
//pack resizer hbox
|
2006-03-01 12:16:13 -07:00
|
|
|
this ->get_vbox() ->pack_start( hbox_resizer, Gtk::PACK_SHRINK );
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
//add label_minmax
|
2006-03-01 12:16:13 -07:00
|
|
|
this ->get_vbox() ->pack_start( label_minmax, Gtk::PACK_SHRINK );
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
//pack hbox_main
|
2006-03-01 12:16:13 -07:00
|
|
|
this ->get_vbox() ->pack_start( hbox_main, Gtk::PACK_SHRINK );
|
2008-06-15 11:18:26 -06:00
|
|
|
|
2004-09-19 14:24:53 -06:00
|
|
|
//put the vbox with resizer stuff (cool widget and spinbuttons) in the hbox_main
|
2005-01-22 10:23:52 -07:00
|
|
|
hbox_main .pack_start( vbox_resize_move, Gtk::PACK_EXPAND_PADDING );
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
//fill table
|
|
|
|
table_resize .set_border_width( 5 ) ;
|
|
|
|
table_resize .set_row_spacings( 5 ) ;
|
|
|
|
hbox_table.pack_start( table_resize, Gtk::PACK_EXPAND_PADDING ) ;
|
|
|
|
|
|
|
|
hbox_table .set_border_width( 5 ) ;
|
|
|
|
vbox_resize_move .pack_start( hbox_table, Gtk::PACK_SHRINK );
|
|
|
|
|
|
|
|
//add spinbutton_before
|
2006-03-01 12:16:13 -07:00
|
|
|
table_resize .attach(
|
2009-10-18 13:25:35 -06:00
|
|
|
* Utils::mk_label( static_cast<Glib::ustring>( _( "Free space preceding (MiB):") ) + " \t" ),
|
2006-03-01 12:16:13 -07:00
|
|
|
0, 1, 0, 1,
|
|
|
|
Gtk::SHRINK );
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
spinbutton_before .set_numeric( true );
|
|
|
|
spinbutton_before .set_increments( 1, 100 );
|
2005-01-22 10:23:52 -07:00
|
|
|
table_resize.attach( spinbutton_before, 1, 2, 0, 1, Gtk::FILL );
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
//add spinbutton_size
|
2009-10-18 13:25:35 -06:00
|
|
|
table_resize.attach( * Utils::mk_label( _( "New size (MiB):" ) ), 0, 1, 1, 2 );
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
spinbutton_size .set_numeric( true );
|
|
|
|
spinbutton_size .set_increments( 1, 100 );
|
2005-01-22 10:23:52 -07:00
|
|
|
table_resize.attach( spinbutton_size, 1, 2, 1, 2, Gtk::FILL );
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
//add spinbutton_after
|
2009-10-18 13:25:35 -06:00
|
|
|
table_resize.attach( * Utils::mk_label( _( "Free space following (MiB):") ), 0, 1, 2, 3 ) ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
spinbutton_after .set_numeric( true );
|
|
|
|
spinbutton_after .set_increments( 1, 100 );
|
2005-01-22 10:23:52 -07:00
|
|
|
table_resize.attach( spinbutton_after, 1, 2, 2, 3, Gtk::FILL );
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
if ( ! fixed_start )
|
2006-03-01 12:16:13 -07:00
|
|
|
before_value = spinbutton_before .get_value() ;
|
2008-06-15 11:18:26 -06:00
|
|
|
|
2004-09-19 14:24:53 -06:00
|
|
|
//connect signalhandlers of the spinbuttons
|
|
|
|
if ( ! fixed_start )
|
2012-08-29 07:35:47 -06:00
|
|
|
before_change_connection = spinbutton_before .signal_value_changed() .connect(
|
2006-03-01 12:16:13 -07:00
|
|
|
sigc::bind<SPINBUTTON>(
|
|
|
|
sigc::mem_fun(*this, &Dialog_Base_Partition::on_spinbutton_value_changed), BEFORE ) ) ;
|
2012-08-29 07:35:47 -06:00
|
|
|
else
|
|
|
|
//Initialise empty connection object for use in the destructor
|
|
|
|
before_change_connection = sigc::connection() ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2012-08-29 07:35:47 -06:00
|
|
|
size_change_connection = spinbutton_size .signal_value_changed() .connect(
|
2006-03-01 12:16:13 -07:00
|
|
|
sigc::bind<SPINBUTTON>(
|
|
|
|
sigc::mem_fun(*this, &Dialog_Base_Partition::on_spinbutton_value_changed), SIZE ) ) ;
|
2012-08-29 07:35:47 -06:00
|
|
|
after_change_connection = spinbutton_after .signal_value_changed() .connect(
|
2006-03-01 12:16:13 -07:00
|
|
|
sigc::bind<SPINBUTTON>(
|
|
|
|
sigc::mem_fun(*this, &Dialog_Base_Partition::on_spinbutton_value_changed), AFTER ) ) ;
|
2006-01-07 08:04:42 -07:00
|
|
|
|
2010-05-09 14:45:26 -06:00
|
|
|
//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") ) ) ;
|
2010-05-20 10:00:14 -06:00
|
|
|
/*TO TRANSLATORS: Menu option for label "Align to:" */
|
|
|
|
menu_alignment .items() .push_back( Gtk::Menu_Helpers::MenuElem( _("MiB") ) ) ;
|
2010-05-09 14:45:26 -06:00
|
|
|
/*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 );
|
2010-07-19 13:19:07 -06:00
|
|
|
optionmenu_alignment .set_history( ALIGN_MEBIBYTE ); //Default setting
|
2010-05-09 14:45:26 -06:00
|
|
|
|
|
|
|
table_resize .attach( optionmenu_alignment, 1, 2, 3, 4, Gtk::FILL );
|
|
|
|
|
2005-01-22 10:23:52 -07:00
|
|
|
this->add_button( Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL );
|
2006-03-01 12:16:13 -07:00
|
|
|
this ->show_all_children() ;
|
2004-09-19 14:24:53 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void Dialog_Base_Partition::Set_Resizer( bool extended )
|
|
|
|
{
|
|
|
|
if ( extended )
|
2006-03-01 12:16:13 -07:00
|
|
|
frame_resizer_base = new Frame_Resizer_Extended() ;
|
2004-09-19 14:24:53 -06:00
|
|
|
else
|
|
|
|
{
|
2006-03-01 12:16:13 -07:00
|
|
|
frame_resizer_base = new Frame_Resizer_Base() ;
|
2005-01-22 10:23:52 -07:00
|
|
|
frame_resizer_base ->signal_move .connect( sigc::mem_fun( this, &Dialog_Base_Partition::on_signal_move ) );
|
2004-09-19 14:24:53 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
frame_resizer_base ->set_border_width( 5 ) ;
|
2005-01-22 10:23:52 -07:00
|
|
|
frame_resizer_base ->set_shadow_type( Gtk::SHADOW_ETCHED_OUT );
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
//connect signals
|
2005-01-22 10:23:52 -07:00
|
|
|
frame_resizer_base ->signal_resize .connect( sigc::mem_fun( this, &Dialog_Base_Partition::on_signal_resize ) );
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2004-09-26 14:37:07 -06:00
|
|
|
hbox_resizer .pack_start( *frame_resizer_base, Gtk::PACK_EXPAND_PADDING );
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2006-03-01 12:16:13 -07:00
|
|
|
this ->show_all_children() ;
|
2004-09-19 14:24:53 -06:00
|
|
|
}
|
|
|
|
|
2015-11-05 02:00:09 -07:00
|
|
|
const Partition & Dialog_Base_Partition::Get_New_Partition( Byte_Value sector_size )
|
2015-05-26 14:52:04 -06:00
|
|
|
{
|
|
|
|
prepare_new_partition( sector_size );
|
2015-05-26 15:38:42 -06:00
|
|
|
return new_partition;
|
2015-05-26 14:52:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void Dialog_Base_Partition::prepare_new_partition( Byte_Value sector_size )
|
2008-04-21 11:08:43 -06:00
|
|
|
{
|
2010-05-04 15:19:49 -06:00
|
|
|
//set sector size of new partition
|
2015-05-26 15:38:42 -06:00
|
|
|
new_partition.sector_size = sector_size;
|
|
|
|
Sector old_size = new_partition.get_sector_length();
|
2010-05-04 15:19:49 -06:00
|
|
|
|
2008-06-15 11:18:26 -06:00
|
|
|
//FIXME: Partition size is limited to just less than 1024 TeraBytes due
|
2008-04-21 11:08:43 -06:00
|
|
|
// to the maximum value of signed 4 byte integer.
|
2006-03-01 12:16:13 -07:00
|
|
|
if ( ORIG_BEFORE != spinbutton_before .get_value_as_int() )
|
2015-05-26 15:38:42 -06:00
|
|
|
new_partition.sector_start = START + Sector(spinbutton_before.get_value_as_int()) * (MEBIBYTE / sector_size);
|
2008-06-15 11:18:26 -06:00
|
|
|
|
2006-03-01 12:16:13 -07:00
|
|
|
if ( ORIG_AFTER != spinbutton_after .get_value_as_int() )
|
2015-05-26 15:38:42 -06:00
|
|
|
new_partition.sector_end =
|
|
|
|
new_partition.sector_start
|
2010-05-20 10:00:14 -06:00
|
|
|
+ Sector(spinbutton_size .get_value_as_int()) * (MEBIBYTE / sector_size)
|
|
|
|
- 1 /* one sector short of exact mebibyte multiple */;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2006-03-01 12:16:13 -07:00
|
|
|
//due to loss of precision during calcs from Sector -> MiB and back, it is possible
|
|
|
|
//the new partition thinks it's bigger then it can be. Here we solve this.
|
2015-05-26 15:38:42 -06:00
|
|
|
if ( new_partition.sector_start < START )
|
|
|
|
new_partition.sector_start = START;
|
|
|
|
if ( new_partition.sector_end > ( START + total_length - 1 ) )
|
|
|
|
new_partition.sector_end = START + total_length - 1;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2006-03-24 12:08:41 -07:00
|
|
|
//grow a bit into small freespace ( < 1MiB )
|
2015-05-26 15:38:42 -06:00
|
|
|
if ( (new_partition.sector_start - START) < (MEBIBYTE / sector_size) )
|
|
|
|
new_partition.sector_start = START;
|
|
|
|
if ( ( START + total_length -1 - new_partition.sector_end ) < (MEBIBYTE / sector_size) )
|
|
|
|
new_partition.sector_end = START + total_length - 1;
|
|
|
|
|
2010-05-09 14:45:26 -06:00
|
|
|
//set alignment
|
|
|
|
switch ( optionmenu_alignment .get_history() )
|
|
|
|
{
|
2015-05-26 15:38:42 -06:00
|
|
|
case 0 : new_partition.alignment = ALIGN_CYLINDER; break;
|
|
|
|
case 1 : new_partition.alignment = ALIGN_MEBIBYTE;
|
2010-09-09 13:09:55 -06:00
|
|
|
{
|
2011-01-15 11:00:42 -07:00
|
|
|
//if partition size is not an integer multiple of MiB
|
|
|
|
// or the start or end sectors are not MiB aligned,
|
|
|
|
// and space is available,
|
|
|
|
// then add 1 MiB to partition so requested size is kept
|
|
|
|
// after GParted_Core::snap_to_mebibyte method rounding
|
2015-05-26 15:38:42 -06:00
|
|
|
Sector partition_size = new_partition.sector_end - new_partition.sector_start + Sector(1);
|
|
|
|
Sector sectors_in_mib = MEBIBYTE / new_partition.sector_size;
|
2011-01-15 11:00:42 -07:00
|
|
|
if ( ( ( ( partition_size % sectors_in_mib ) > 0 )
|
2015-05-26 15:38:42 -06:00
|
|
|
|| ( ( new_partition.sector_start % sectors_in_mib ) > 0 )
|
|
|
|
|| ( ( ( new_partition.sector_end + Sector(1) ) % sectors_in_mib ) > 0 )
|
2011-01-15 11:00:42 -07:00
|
|
|
)
|
|
|
|
&& ( ( partition_size + sectors_in_mib ) < total_length )
|
2010-09-09 13:09:55 -06:00
|
|
|
)
|
2015-05-26 15:38:42 -06:00
|
|
|
new_partition.sector_end += sectors_in_mib;
|
2010-09-09 13:09:55 -06:00
|
|
|
}
|
|
|
|
break;
|
2015-05-26 15:38:42 -06:00
|
|
|
case 2 : new_partition.alignment = ALIGN_STRICT; break;
|
2010-05-09 14:45:26 -06:00
|
|
|
|
2015-05-26 15:38:42 -06:00
|
|
|
default : new_partition.alignment = ALIGN_MEBIBYTE; break;
|
2010-05-09 14:45:26 -06:00
|
|
|
}
|
2008-06-15 11:18:26 -06:00
|
|
|
|
2012-03-28 05:47:48 -06:00
|
|
|
//update partition usage
|
2015-05-26 15:38:42 -06:00
|
|
|
if ( new_partition.sectors_used != -1 && new_partition.sectors_unused != -1 )
|
2012-03-28 05:47:48 -06:00
|
|
|
{
|
2015-05-26 15:38:42 -06:00
|
|
|
Sector new_size = new_partition.get_sector_length();
|
2012-03-28 05:47:48 -06:00
|
|
|
if ( old_size == new_size )
|
|
|
|
{
|
|
|
|
//Pasting into new same sized partition or moving partition keeping the same size,
|
|
|
|
// therefore only block copy operation will be performed maintaining file system size.
|
2015-05-26 15:38:42 -06:00
|
|
|
new_partition.set_sector_usage(
|
|
|
|
new_partition.sectors_used + new_partition.sectors_unused,
|
|
|
|
new_partition.sectors_unused );
|
2012-03-28 05:47:48 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//Pasting into new larger partition or (moving and) resizing partition larger or smaller,
|
|
|
|
// therefore block copy followed by file system grow or shrink operations will be
|
|
|
|
// performed making the file system fill the partition.
|
2015-05-26 15:38:42 -06:00
|
|
|
new_partition.set_sector_usage( new_size, new_size - new_partition.sectors_used );
|
2012-03-28 05:47:48 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-26 15:38:42 -06:00
|
|
|
new_partition.free_space_before = Sector(spinbutton_before .get_value_as_int()) * (MEBIBYTE / sector_size);
|
2010-05-20 10:00:14 -06:00
|
|
|
|
2009-02-16 12:53:43 -07:00
|
|
|
//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() )
|
2015-05-26 15:38:42 -06:00
|
|
|
new_partition.strict_start = TRUE;
|
2004-09-19 14:24:53 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void Dialog_Base_Partition::Set_Confirm_Button( CONFIRMBUTTON button_type )
|
|
|
|
{
|
|
|
|
switch( button_type )
|
|
|
|
{
|
2006-01-07 08:04:42 -07:00
|
|
|
case NEW :
|
|
|
|
this ->add_button( Gtk::Stock::ADD, Gtk::RESPONSE_OK );
|
|
|
|
|
|
|
|
break ;
|
|
|
|
case RESIZE_MOVE:
|
2011-06-26 06:03:37 -06:00
|
|
|
{
|
|
|
|
Gtk::Image* image_temp(manage(new Gtk::Image(Gtk::Stock::GOTO_LAST, Gtk::ICON_SIZE_BUTTON)));
|
2011-07-14 10:38:59 -06:00
|
|
|
Gtk::HBox* hbox_resize_move(manage(new Gtk::HBox()));
|
2011-06-26 06:03:37 -06:00
|
|
|
|
2011-07-14 10:38:59 -06:00
|
|
|
hbox_resize_move->pack_start(*image_temp, Gtk::PACK_EXPAND_PADDING);
|
|
|
|
hbox_resize_move->pack_start(*Utils::mk_label(fixed_start ? _("Resize") : _("Resize/Move")),
|
2011-06-26 06:03:37 -06:00
|
|
|
Gtk::PACK_EXPAND_PADDING);
|
2011-07-14 10:38:59 -06:00
|
|
|
button_resize_move.add(*hbox_resize_move);
|
2011-06-26 06:03:37 -06:00
|
|
|
}
|
|
|
|
|
2006-01-07 08:04:42 -07:00
|
|
|
this ->add_action_widget ( button_resize_move, Gtk::RESPONSE_OK ) ;
|
|
|
|
button_resize_move .set_sensitive( false ) ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2006-01-07 08:04:42 -07:00
|
|
|
break ;
|
|
|
|
case PASTE :
|
|
|
|
this ->add_button( Gtk::Stock::PASTE, Gtk::RESPONSE_OK );
|
|
|
|
|
|
|
|
break ;
|
2004-09-19 14:24:53 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-08 06:14:05 -07:00
|
|
|
void Dialog_Base_Partition::Set_MinMax_Text( Sector min, Sector max )
|
2004-10-02 05:34:18 -06:00
|
|
|
{
|
2011-06-26 06:03:37 -06:00
|
|
|
Glib::ustring str_temp(String::ucompose( _("Minimum size: %1 MiB"), min ) + "\t\t");
|
2009-10-18 13:25:35 -06:00
|
|
|
str_temp += String::ucompose( _("Maximum size: %1 MiB"), max ) ;
|
2004-10-02 05:34:18 -06:00
|
|
|
label_minmax .set_text( str_temp ) ;
|
|
|
|
}
|
|
|
|
|
2010-05-20 10:00:14 -06:00
|
|
|
int Dialog_Base_Partition::MB_Needed_for_Boot_Record( const Partition & partition )
|
|
|
|
{
|
|
|
|
//Determine if space is needed for the Master Boot Record or
|
|
|
|
// the Extended Boot Record. Generally an an additional track or MEBIBYTE
|
|
|
|
// is required so for our purposes reserve a MEBIBYTE in front of the partition.
|
|
|
|
// NOTE: This logic also contained in Win_GParted::set_valid_operations
|
|
|
|
if ( ( partition .inside_extended
|
|
|
|
&& partition .type == TYPE_UNALLOCATED
|
|
|
|
)
|
|
|
|
|| ( partition .type == TYPE_LOGICAL )
|
|
|
|
/* Beginning of disk device */
|
|
|
|
|| ( partition .sector_start <= (MEBIBYTE / partition .sector_size) )
|
|
|
|
)
|
|
|
|
return 1 ;
|
|
|
|
else
|
|
|
|
return 0 ;
|
|
|
|
}
|
|
|
|
|
2004-09-19 14:24:53 -06:00
|
|
|
void Dialog_Base_Partition::on_signal_move( int x_start, int x_end )
|
|
|
|
{
|
|
|
|
GRIP = true ;
|
|
|
|
|
2010-09-07 16:56:38 -06:00
|
|
|
spinbutton_before .set_value( x_start * MB_PER_PIXEL ) ;
|
|
|
|
|
2004-09-19 14:24:53 -06:00
|
|
|
if ( x_end == 500 )
|
|
|
|
{
|
2005-01-22 10:23:52 -07:00
|
|
|
spinbutton_after .set_value( 0 ) ;
|
2006-03-01 12:16:13 -07:00
|
|
|
spinbutton_before .set_value( TOTAL_MB - spinbutton_size .get_value() ) ;
|
2004-09-19 14:24:53 -06:00
|
|
|
}
|
|
|
|
else
|
2006-03-01 12:16:13 -07:00
|
|
|
spinbutton_after .set_value( TOTAL_MB - spinbutton_before .get_value() - spinbutton_size .get_value() ) ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2006-03-01 12:16:13 -07:00
|
|
|
Check_Change() ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
GRIP = false ;
|
|
|
|
}
|
|
|
|
|
2004-12-12 07:57:04 -07:00
|
|
|
void Dialog_Base_Partition::on_signal_resize( int x_start, int x_end, Frame_Resizer_Base::ArrowType arrow )
|
2004-09-19 14:24:53 -06:00
|
|
|
{
|
|
|
|
GRIP = true ;
|
2004-12-12 07:57:04 -07:00
|
|
|
|
2004-09-19 14:24:53 -06:00
|
|
|
spinbutton_size .set_value( ( x_end - x_start ) * MB_PER_PIXEL ) ;
|
|
|
|
|
2010-05-20 10:00:14 -06:00
|
|
|
before_value = fixed_start ? MIN_SPACE_BEFORE_MB : spinbutton_before .get_value() ;
|
2006-01-07 08:04:42 -07:00
|
|
|
|
2004-09-19 14:24:53 -06:00
|
|
|
if ( arrow == Frame_Resizer_Base::ARROW_RIGHT ) //don't touch freespace before, leave it as it is
|
|
|
|
{
|
|
|
|
if ( x_end == 500 )
|
|
|
|
{
|
2004-12-12 07:57:04 -07:00
|
|
|
spinbutton_after .set_value( 0 ) ;
|
2004-09-19 14:24:53 -06:00
|
|
|
spinbutton_size .set_value( TOTAL_MB - before_value ) ;
|
|
|
|
}
|
|
|
|
else
|
2006-03-01 12:16:13 -07:00
|
|
|
spinbutton_after .set_value( TOTAL_MB - before_value - spinbutton_size .get_value() ) ;
|
2004-09-19 14:24:53 -06:00
|
|
|
}
|
|
|
|
else if ( arrow == Frame_Resizer_Base::ARROW_LEFT ) //don't touch freespace after, leave it as it is
|
2010-09-07 16:56:38 -06:00
|
|
|
spinbutton_before .set_value( TOTAL_MB - spinbutton_size .get_value() - spinbutton_after .get_value() ) ;
|
|
|
|
|
2006-03-01 12:16:13 -07:00
|
|
|
Check_Change() ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
GRIP = false ;
|
|
|
|
}
|
|
|
|
|
2004-10-02 05:34:18 -06:00
|
|
|
void Dialog_Base_Partition::on_spinbutton_value_changed( SPINBUTTON spinbutton )
|
2004-09-19 14:24:53 -06:00
|
|
|
{
|
|
|
|
if ( ! GRIP )
|
|
|
|
{
|
2010-05-20 10:00:14 -06:00
|
|
|
before_value = fixed_start ? MIN_SPACE_BEFORE_MB : spinbutton_before .get_value() ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
//Balance the spinbuttons
|
|
|
|
switch ( spinbutton )
|
|
|
|
{
|
2006-01-07 08:04:42 -07:00
|
|
|
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() ) ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2006-01-07 08:04:42 -07:00
|
|
|
break ;
|
|
|
|
case SIZE :
|
|
|
|
spinbutton_after .set_value( TOTAL_MB - before_value - spinbutton_size .get_value() );
|
|
|
|
if ( ! fixed_start )
|
2006-03-01 12:16:13 -07:00
|
|
|
spinbutton_before .set_value(
|
|
|
|
TOTAL_MB - spinbutton_size .get_value() - spinbutton_after .get_value() );
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2006-01-07 08:04:42 -07:00
|
|
|
break;
|
|
|
|
case AFTER :
|
|
|
|
if ( ! fixed_start )
|
2006-03-01 12:16:13 -07:00
|
|
|
spinbutton_before .set_value(
|
|
|
|
TOTAL_MB - spinbutton_size .get_value() - spinbutton_after .get_value() );
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2006-01-07 08:04:42 -07:00
|
|
|
spinbutton_size .set_value( TOTAL_MB - before_value - spinbutton_after .get_value() ) ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2006-01-07 08:04:42 -07:00
|
|
|
break;
|
2004-09-19 14:24:53 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//And apply the changes to the visual view...
|
|
|
|
if ( ! fixed_start )
|
2006-03-28 05:40:29 -07:00
|
|
|
frame_resizer_base ->set_x_start( Utils::round( spinbutton_before .get_value() / MB_PER_PIXEL ) ) ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2006-03-28 05:40:29 -07:00
|
|
|
frame_resizer_base ->set_x_end( 500 - Utils::round( spinbutton_after .get_value() / MB_PER_PIXEL ) ) ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2006-01-07 08:04:42 -07:00
|
|
|
frame_resizer_base ->Draw_Partition() ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2006-01-07 08:04:42 -07:00
|
|
|
Check_Change() ;
|
2004-09-19 14:24:53 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-01 12:16:13 -07:00
|
|
|
void Dialog_Base_Partition::Check_Change()
|
2004-09-19 14:24:53 -06:00
|
|
|
{
|
2006-01-07 08:04:42 -07:00
|
|
|
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() ) ;
|
2004-09-19 14:24:53 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
Dialog_Base_Partition::~Dialog_Base_Partition()
|
|
|
|
{
|
2012-08-29 07:35:47 -06:00
|
|
|
before_change_connection .disconnect() ;
|
|
|
|
size_change_connection .disconnect() ;
|
|
|
|
after_change_connection .disconnect() ;
|
2010-06-24 09:36:20 -06:00
|
|
|
delete frame_resizer_base;
|
2004-09-19 14:24:53 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
} //GParted
|