2004-09-19 14:24:53 -06:00
|
|
|
/* Copyright (C) 2004 Bart
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* GNU Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "../include/Dialog_Partition_Copy.h"
|
|
|
|
|
|
|
|
namespace GParted
|
|
|
|
{
|
|
|
|
|
2004-12-15 13:43:58 -07:00
|
|
|
Dialog_Partition_Copy::Dialog_Partition_Copy( std::vector<FS> FILESYSTEMS, Sector cylinder_size )
|
2004-09-19 14:24:53 -06:00
|
|
|
{
|
2004-12-09 15:56:33 -07:00
|
|
|
this ->FILESYSTEMS = FILESYSTEMS ;
|
|
|
|
|
2004-12-15 13:43:58 -07:00
|
|
|
//some disk have a small cylindersize, for safetyreasons i keep this size at >=1
|
|
|
|
if ( cylinder_size < 2048 )
|
|
|
|
cylinder_size = 2048 ;
|
|
|
|
|
|
|
|
BUF = Sector_To_MB( cylinder_size ) ;
|
|
|
|
|
2004-09-19 14:24:53 -06:00
|
|
|
Set_Resizer( false ) ;
|
|
|
|
Set_Confirm_Button( PASTE ) ;
|
|
|
|
}
|
|
|
|
|
2004-11-21 14:49:38 -07:00
|
|
|
void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, const Partition & copied_partition )
|
2004-09-19 14:24:53 -06:00
|
|
|
{
|
2004-12-09 15:56:33 -07:00
|
|
|
fs = Get_FS( copied_partition .filesystem, FILESYSTEMS ) ;
|
|
|
|
|
2004-09-19 14:24:53 -06:00
|
|
|
GRIP = true ; //prevents on spinbutton_changed from getting activated prematurely
|
|
|
|
|
2004-09-24 19:10:21 -06:00
|
|
|
this ->set_title( String::ucompose( _("Paste %1"), copied_partition .partition ) ) ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
//set partition color
|
|
|
|
frame_resizer_base ->set_rgb_partition_color( copied_partition .color ) ;
|
|
|
|
|
|
|
|
//set some widely used values...
|
2004-11-21 14:49:38 -07:00
|
|
|
START = selected_partition .sector_start ;
|
|
|
|
total_length = selected_partition .sector_end - selected_partition .sector_start ;
|
2004-12-15 04:02:54 -07:00
|
|
|
TOTAL_MB = selected_partition .Get_Length_MB( ) ;
|
2004-10-08 13:53:35 -06:00
|
|
|
MB_PER_PIXEL = (double) TOTAL_MB / 500 ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
//now calculate proportional length of partition
|
|
|
|
frame_resizer_base ->set_x_start( 0 ) ;
|
2004-11-21 14:49:38 -07:00
|
|
|
frame_resizer_base ->set_x_end( ( Round( (double) (copied_partition .sector_end - copied_partition .sector_start) / ( (double)total_length/500) )) ) ;
|
2004-12-15 04:02:54 -07:00
|
|
|
frame_resizer_base ->set_used( Round( (double) copied_partition .sectors_used / ( (double)total_length/500) ) ) ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2004-12-15 13:43:58 -07:00
|
|
|
fs .MAX = ( ! fs .MAX || fs .MAX > TOTAL_MB ) ? TOTAL_MB : fs .MAX -= BUF ;
|
2004-10-08 13:53:35 -06:00
|
|
|
|
2004-12-15 04:02:54 -07:00
|
|
|
fs .MIN = copied_partition .Get_Length_MB( ) +1 ;
|
|
|
|
|
2004-09-19 14:24:53 -06:00
|
|
|
//set values of spinbutton_before
|
2004-12-15 04:02:54 -07:00
|
|
|
spinbutton_before .set_range( 0, TOTAL_MB - fs .MIN ) ;
|
2004-09-19 14:24:53 -06:00
|
|
|
spinbutton_before .set_value( 0 ) ;
|
|
|
|
|
2004-12-09 15:56:33 -07:00
|
|
|
//set values of spinbutton_size
|
2004-12-15 04:02:54 -07:00
|
|
|
spinbutton_size .set_range( fs .MIN, fs .MAX ) ;
|
|
|
|
spinbutton_size .set_value( fs .MIN ) ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
//set values of spinbutton_after
|
2004-12-15 04:02:54 -07:00
|
|
|
spinbutton_after .set_range( 0, TOTAL_MB - fs .MIN ) ;
|
|
|
|
spinbutton_after .set_value( TOTAL_MB - fs .MIN ) ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2004-12-15 04:02:54 -07:00
|
|
|
frame_resizer_base ->set_size_limits( (int) ( fs .MIN / MB_PER_PIXEL), (int) (fs .MAX / MB_PER_PIXEL) +1 ) ;
|
2004-12-12 07:57:04 -07:00
|
|
|
|
2004-09-19 14:24:53 -06:00
|
|
|
//set contents of label_minmax
|
2004-12-15 04:02:54 -07:00
|
|
|
Set_MinMax_Text( fs .MIN, fs .MAX ) ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
//set global selected_partition (see Dialog_Base_Partition::Get_New_Partition )
|
|
|
|
this ->selected_partition = copied_partition ;
|
2004-10-02 03:39:16 -06:00
|
|
|
this ->selected_partition .inside_extended = selected_partition .inside_extended ;
|
2004-09-19 14:24:53 -06:00
|
|
|
selected_partition .inside_extended ? this ->selected_partition .type = GParted::LOGICAL : this ->selected_partition .type = GParted::PRIMARY ;
|
|
|
|
|
|
|
|
GRIP = false ;
|
|
|
|
}
|
|
|
|
|
2004-09-25 08:12:07 -06:00
|
|
|
Partition Dialog_Partition_Copy::Get_New_Partition()
|
|
|
|
{
|
|
|
|
//first call baseclass to get the correct new partition
|
|
|
|
selected_partition = Dialog_Base_Partition::Get_New_Partition() ;
|
|
|
|
|
|
|
|
//set proper name and status for partition
|
|
|
|
selected_partition.status = GParted::STAT_COPY ;
|
|
|
|
|
|
|
|
return selected_partition ;
|
|
|
|
}
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
} //GParted
|