removed sleep( 1 ). This isn't needed anymore now the layout is scanned
* src/GParted_Core.cc: removed sleep( 1 ). This isn't needed anymore now the layout is scanned before the re-readtest. (saves seconds at scantime :) ) * replaced C-style typeconversion with static_casts throughout the project.
This commit is contained in:
parent
fb4af15865
commit
fa255c48de
|
@ -1,4 +1,9 @@
|
|||
2005-01-11 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||
2005-01-19 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||
|
||||
* src/GParted_Core.cc: removed sleep( 1 ). This isn't needed anymore now the layout is scanned before the re-readtest. (saves seconds at scantime :) )
|
||||
* replaced C-style typeconversion with static_casts throughout the project.
|
||||
|
||||
2005-01-18 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||
|
||||
* include/Utils.h: used static_cast<> instead of C-style type conversion.
|
||||
* src/Makefile.am: install gparted binary in bin/ instead of sbin/ (as soon as i've time i want to implement a read-only modus)
|
||||
|
|
|
@ -41,7 +41,6 @@ Dialog_Base_Partition::Dialog_Base_Partition( )
|
|||
//put the vbox with resizer stuff (cool widget and spinbuttons) in the hbox_main
|
||||
hbox_main .pack_start( vbox_resize_move, Gtk::PACK_EXPAND_PADDING);
|
||||
|
||||
|
||||
//fill table
|
||||
table_resize .set_border_width( 5 ) ;
|
||||
table_resize .set_row_spacings( 5 ) ;
|
||||
|
@ -71,7 +70,6 @@ Dialog_Base_Partition::Dialog_Base_Partition( )
|
|||
spinbutton_after .set_increments( 1, 100 );
|
||||
table_resize.attach( spinbutton_after, 1, 2, 2, 3, Gtk::FILL);
|
||||
|
||||
|
||||
if ( ! fixed_start )
|
||||
before_value = spinbutton_before .get_value() ;
|
||||
|
||||
|
@ -114,13 +112,13 @@ void Dialog_Base_Partition::Set_Resizer( bool extended )
|
|||
this ->show_all_children( ) ;
|
||||
}
|
||||
|
||||
Partition Dialog_Base_Partition::Get_New_Partition()
|
||||
Partition Dialog_Base_Partition::Get_New_Partition( )
|
||||
{
|
||||
if ( ORIG_BEFORE != spinbutton_before .get_value_as_int() )
|
||||
if ( ORIG_BEFORE != spinbutton_before .get_value_as_int( ) )
|
||||
selected_partition .sector_start = START + (Sector) spinbutton_before .get_value() * MEGABYTE ;
|
||||
|
||||
if ( ORIG_AFTER != spinbutton_after .get_value_as_int() )
|
||||
selected_partition .sector_end = selected_partition .sector_start + (Sector) spinbutton_size .get_value() * MEGABYTE ;
|
||||
if ( ORIG_AFTER != spinbutton_after .get_value_as_int( ) )
|
||||
selected_partition .sector_end = selected_partition .sector_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 solve this.
|
||||
if ( selected_partition.sector_start < START )
|
||||
|
@ -161,7 +159,6 @@ void Dialog_Base_Partition::Set_Confirm_Button( CONFIRMBUTTON button_type )
|
|||
case PASTE : this->add_button( Gtk::Stock::PASTE,Gtk::RESPONSE_OK );
|
||||
break ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Dialog_Base_Partition::Set_MinMax_Text( long min, long max )
|
||||
|
@ -256,9 +253,9 @@ void Dialog_Base_Partition::on_spinbutton_value_changed( SPINBUTTON spinbutton )
|
|||
|
||||
//And apply the changes to the visual view...
|
||||
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( Round( spinbutton_before .get_value( ) / MB_PER_PIXEL ) ) ;
|
||||
|
||||
frame_resizer_base ->set_x_end( (int) ( 500 - ( (double) spinbutton_after .get_value( ) / MB_PER_PIXEL ) + 0.5 ) ) ;
|
||||
frame_resizer_base ->set_x_end( 500 - Round( spinbutton_after .get_value( ) / MB_PER_PIXEL ) ) ;
|
||||
|
||||
frame_resizer_base ->Draw_Partition( ) ;
|
||||
|
||||
|
@ -266,11 +263,11 @@ void Dialog_Base_Partition::on_spinbutton_value_changed( SPINBUTTON spinbutton )
|
|||
}
|
||||
}
|
||||
|
||||
void Dialog_Base_Partition::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()
|
||||
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
|
||||
|
|
|
@ -41,14 +41,15 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons
|
|||
START = selected_partition .sector_start ;
|
||||
total_length = selected_partition .sector_end - selected_partition .sector_start ;
|
||||
TOTAL_MB = selected_partition .Get_Length_MB( ) ;
|
||||
MB_PER_PIXEL = (double) TOTAL_MB / 500 ;
|
||||
MB_PER_PIXEL = TOTAL_MB / 500.00 ;
|
||||
|
||||
long COPIED_LENGTH_MB = copied_partition .Get_Length_MB( ) ;
|
||||
|
||||
//now calculate proportional length of partition
|
||||
frame_resizer_base ->set_x_start( 0 ) ;
|
||||
int x_end = Round( COPIED_LENGTH_MB / ( (double)TOTAL_MB/500 ) ) ; //> 500 px only possible with xfs...
|
||||
int x_end = Round( COPIED_LENGTH_MB / ( TOTAL_MB/500.00 ) ) ; //> 500 px only possible with xfs...
|
||||
frame_resizer_base ->set_x_end( x_end > 500 ? 500 : x_end ) ;
|
||||
frame_resizer_base ->set_used( Round( copied_partition .Get_Used_MB( ) / ( (double)TOTAL_MB/500) ) ) ;
|
||||
frame_resizer_base ->set_used( Round( copied_partition .Get_Used_MB( ) / ( TOTAL_MB/500.00) ) ) ;
|
||||
|
||||
fs .MAX = ( ! fs .MAX || fs .MAX > TOTAL_MB ) ? TOTAL_MB : fs .MAX -= BUF ;
|
||||
|
||||
|
@ -71,7 +72,7 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons
|
|||
spinbutton_after .set_value( TOTAL_MB - COPIED_LENGTH_MB ) ;
|
||||
GRIP = false ;
|
||||
|
||||
frame_resizer_base ->set_size_limits( (int) ( fs .MIN / MB_PER_PIXEL), (int) (fs .MAX / MB_PER_PIXEL) +1 ) ;
|
||||
frame_resizer_base ->set_size_limits( static_cast<int> (fs .MIN / MB_PER_PIXEL), static_cast<int> (fs .MAX / MB_PER_PIXEL) +1 ) ;
|
||||
|
||||
//set contents of label_minmax
|
||||
Set_MinMax_Text( fs .MIN, fs .MAX ) ;
|
||||
|
@ -82,10 +83,10 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons
|
|||
selected_partition .inside_extended ? this ->selected_partition .type = GParted::LOGICAL : this ->selected_partition .type = GParted::PRIMARY ;
|
||||
}
|
||||
|
||||
Partition Dialog_Partition_Copy::Get_New_Partition()
|
||||
Partition Dialog_Partition_Copy::Get_New_Partition( )
|
||||
{
|
||||
//first call baseclass to get the correct new partition
|
||||
selected_partition = Dialog_Base_Partition::Get_New_Partition() ;
|
||||
selected_partition = Dialog_Base_Partition::Get_New_Partition( ) ;
|
||||
|
||||
//set proper name and status for partition
|
||||
selected_partition.status = GParted::STAT_COPY ;
|
||||
|
|
|
@ -103,8 +103,8 @@ void Dialog_Partition_Info::init_drawingarea( )
|
|||
|
||||
//calculate proportional width of used and unused
|
||||
used = unused = 0 ;
|
||||
used = (int) ( ( (375 - BORDER *2) / ( (double) (partition .sector_end - partition .sector_start) / partition .sectors_used ) )+0.5 ) ;
|
||||
unused = 375 - used - (BORDER *2) ;
|
||||
used = Round( (375 - BORDER *2) / ( static_cast<double> (partition .sector_end - partition .sector_start) / partition .sectors_used ) ) ;
|
||||
unused = 375 - used - BORDER *2 ;
|
||||
|
||||
//allocate some colors
|
||||
color_used.set( "#F8F8BA" ); this ->get_colormap( ) ->alloc_color( color_used ) ;
|
||||
|
@ -117,7 +117,6 @@ void Dialog_Partition_Info::init_drawingarea( )
|
|||
|
||||
//set text of pangolayout
|
||||
pango_layout = drawingarea .create_pango_layout ( partition .partition + "\n" + String::ucompose( _("%1 MB"), partition .Get_Length_MB( ) ) ) ;
|
||||
|
||||
}
|
||||
|
||||
void Dialog_Partition_Info::Display_Info( )
|
||||
|
@ -140,7 +139,7 @@ void Dialog_Partition_Info::Display_Info( )
|
|||
if ( partition.sectors_used != -1 )
|
||||
{
|
||||
//calculate relative diskusage
|
||||
int percent_used = (int) ( (double) partition.Get_Used_MB( ) / partition .Get_Length_MB( ) *100 +0.5 ) ;
|
||||
int percent_used = Round( static_cast<double> (partition .Get_Used_MB( ) ) / partition .Get_Length_MB( ) *100 ) ;
|
||||
|
||||
//used
|
||||
table ->attach( * mk_label( "<b>" + (Glib::ustring) _( "Used:" ) + "</b>" ), 0,1, top, bottom,Gtk::FILL ) ;
|
||||
|
@ -218,14 +217,12 @@ Glib::ustring Dialog_Partition_Info::Find_Status( )
|
|||
else if ( partition .filesystem == "linux-swap" )
|
||||
return _("Active") ;
|
||||
|
||||
|
||||
//try to find the mountpoint in /proc/mounts
|
||||
//get realpath
|
||||
char real_path[ 4096 ] ;
|
||||
realpath( partition .partition .c_str( ), real_path );
|
||||
Glib::ustring mountpoint, partition_real_path = real_path ; //because root partition is listed as /dev/root we need te compare against te real path..
|
||||
|
||||
|
||||
std::ifstream file_mounts( "/proc/mounts" ) ;
|
||||
std::string line ;
|
||||
|
||||
|
@ -241,8 +238,6 @@ Glib::ustring Dialog_Partition_Info::Find_Status( )
|
|||
|
||||
break ;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
file_mounts .close( ) ;
|
||||
|
@ -252,7 +247,6 @@ Glib::ustring Dialog_Partition_Info::Find_Status( )
|
|||
mountpoint = "/" ;
|
||||
|
||||
return String::ucompose( _("Mounted on %1"), mountpoint ) ;
|
||||
|
||||
}
|
||||
|
||||
Dialog_Partition_Info::~Dialog_Partition_Info( )
|
||||
|
@ -263,5 +257,4 @@ Dialog_Partition_Info::~Dialog_Partition_Info( )
|
|||
this ->get_colormap( ) ->free_colors( color_partition, 1 ) ;
|
||||
}
|
||||
|
||||
|
||||
} //GParted
|
||||
|
|
|
@ -87,8 +87,8 @@ void Dialog_Partition_New::Set_Data( const Partition & partition, bool any_exten
|
|||
//set some widely used values...
|
||||
START = partition.sector_start ;
|
||||
total_length = partition.sector_end - partition.sector_start ;
|
||||
TOTAL_MB = this ->selected_partition .Get_Length_MB() ;
|
||||
MB_PER_PIXEL = (double) TOTAL_MB / 500 ;
|
||||
TOTAL_MB = this ->selected_partition .Get_Length_MB( ) ;
|
||||
MB_PER_PIXEL = TOTAL_MB / 500.00 ;
|
||||
|
||||
//set first enabled filesystem
|
||||
optionmenu_filesystem .set_history( first_creatable_fs ) ;
|
||||
|
@ -183,7 +183,7 @@ void Dialog_Partition_New::optionmenu_changed( bool type )
|
|||
|
||||
fs .MAX = ( fs .MAX && ( fs .MAX - cylinder_size ) < TOTAL_MB ) ? fs .MAX - cylinder_size : TOTAL_MB ;
|
||||
|
||||
frame_resizer_base ->set_size_limits( (int) (fs .MIN / MB_PER_PIXEL), (int) (fs .MAX / MB_PER_PIXEL) +1 ) ;
|
||||
frame_resizer_base ->set_size_limits( static_cast<int> (fs .MIN / MB_PER_PIXEL), static_cast<int> (fs .MAX / MB_PER_PIXEL) +1 ) ;
|
||||
|
||||
//set new spinbutton ranges
|
||||
spinbutton_before .set_range( 0, TOTAL_MB - fs .MIN ) ;
|
||||
|
@ -227,6 +227,4 @@ void Dialog_Partition_New::Build_Filesystems_Menu( bool only_unformatted )
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
} //GParted
|
||||
|
|
|
@ -80,8 +80,8 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector <Partit
|
|||
//calculate total size in MB's of previous, current and next partition
|
||||
//first find index of partition
|
||||
unsigned int t;
|
||||
for ( t=0;t< partitions.size(); t++ )
|
||||
if ( partitions[t].sector_start == selected_partition.sector_start )
|
||||
for ( t = 0 ; t < partitions .size( ) ; t++ )
|
||||
if ( partitions[ t ] .sector_start == selected_partition .sector_start )
|
||||
break;
|
||||
|
||||
Sector previous, next ;
|
||||
|
@ -101,12 +101,12 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector <Partit
|
|||
total_length = previous + (selected_partition.sector_end - selected_partition.sector_start) + next;
|
||||
TOTAL_MB = Sector_To_MB( total_length ) ;
|
||||
|
||||
MB_PER_PIXEL = (double) TOTAL_MB / 500 ;
|
||||
MB_PER_PIXEL = TOTAL_MB / 500.00 ;
|
||||
|
||||
//now calculate proportional length of partition
|
||||
frame_resizer_base ->set_x_start( Round( (double) previous / ( (double)total_length/500) ) ) ;
|
||||
frame_resizer_base ->set_x_end( ( Round( (double) (selected_partition.sector_end - selected_partition.sector_start) / ( (double)total_length/500) )) + frame_resizer_base ->get_x_start() ) ;
|
||||
frame_resizer_base ->set_used( Round( (double) selected_partition.sectors_used / ( (double)total_length/500) ) ) ;
|
||||
frame_resizer_base ->set_x_start( Round( previous / ( total_length / 500.00 ) ) ) ;
|
||||
frame_resizer_base ->set_x_end( Round( (selected_partition .sector_end - selected_partition .sector_start) / ( total_length / 500.00 ) ) + frame_resizer_base ->get_x_start( ) ) ;
|
||||
frame_resizer_base ->set_used( Round( selected_partition.sectors_used / ( total_length / 500.00 ) ) ) ;
|
||||
|
||||
if ( fs .shrink )
|
||||
{
|
||||
|
@ -141,13 +141,12 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector <Partit
|
|||
spinbutton_after .set_range( 0, TOTAL_MB - fs .MIN ) ;
|
||||
spinbutton_after .set_value( Sector_To_MB( next ) ) ;
|
||||
|
||||
frame_resizer_base ->set_size_limits( (int) (fs .MIN / MB_PER_PIXEL), (int) (fs .MAX / MB_PER_PIXEL) +1 ) ;
|
||||
frame_resizer_base ->set_size_limits( static_cast<int> (fs .MIN / MB_PER_PIXEL), static_cast<int> (fs .MAX / MB_PER_PIXEL) +1 ) ;
|
||||
|
||||
//set contents of label_minmax
|
||||
Set_MinMax_Text( fs .MIN, fs .MAX ) ;
|
||||
}
|
||||
|
||||
|
||||
void Dialog_Partition_Resize_Move::Resize_Move_Extended( const std::vector <Partition> & partitions )
|
||||
{
|
||||
//calculate total size in MB's of previous, current and next partition
|
||||
|
@ -173,11 +172,11 @@ void Dialog_Partition_Resize_Move::Resize_Move_Extended( const std::vector <Part
|
|||
//now we have enough data to calculate some important values..
|
||||
total_length = previous + (selected_partition.sector_end - selected_partition.sector_start) + next;
|
||||
TOTAL_MB = Sector_To_MB( total_length ) ;
|
||||
MB_PER_PIXEL = (double) TOTAL_MB / 500 ;
|
||||
MB_PER_PIXEL = TOTAL_MB / 500.00 ;
|
||||
|
||||
//calculate proportional length of partition ( in pixels )
|
||||
frame_resizer_base ->set_x_start( Round( (double) previous / ( (double)total_length/500) ) ) ;
|
||||
frame_resizer_base ->set_x_end( ( Round( (double) (selected_partition.sector_end - selected_partition.sector_start) / ( (double)total_length/500) ) ) + frame_resizer_base ->get_x_start() ) ;
|
||||
frame_resizer_base ->set_x_start( Round( previous / ( total_length / 500.00 ) ) ) ;
|
||||
frame_resizer_base ->set_x_end( Round( (selected_partition .sector_end - selected_partition .sector_start) / ( total_length / 500.00 ) ) + frame_resizer_base ->get_x_start( ) ) ;
|
||||
|
||||
//used is a bit different here... we consider start of first logical to end last logical as used space
|
||||
Sector first =0, used =0 ;
|
||||
|
@ -192,8 +191,8 @@ void Dialog_Partition_Resize_Move::Resize_Move_Extended( const std::vector <Part
|
|||
}
|
||||
}
|
||||
|
||||
frame_resizer_base ->set_used_start( Round( (double) (first - START) / ( (double)total_length/500) ) ) ;
|
||||
frame_resizer_base ->set_used( Round( (double) used / ( (double)total_length/500) ) ) ;
|
||||
frame_resizer_base ->set_used_start( Round( (first - START) / ( total_length / 500.00 ) ) ) ;
|
||||
frame_resizer_base ->set_used( Round( used / ( total_length / 500.00 ) ) ) ;
|
||||
|
||||
//set values of spinbutton_before (we assume there is no fixed start.)
|
||||
if ( first == 0 ) //no logicals
|
||||
|
@ -223,5 +222,4 @@ void Dialog_Partition_Resize_Move::Resize_Move_Extended( const std::vector <Part
|
|||
Set_MinMax_Text( first == 0 ? BUF/2 : Sector_To_MB( used ), Sector_To_MB( total_length ) ) ;
|
||||
}
|
||||
|
||||
|
||||
} //GParted
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
|
||||
#include "../include/Dialog_Progress.h"
|
||||
|
||||
#include <iostream>
|
||||
namespace GParted
|
||||
{
|
||||
|
||||
|
@ -29,7 +29,7 @@ Dialog_Progress::Dialog_Progress( int count_operations, Glib::RefPtr<Gtk::TextBu
|
|||
|
||||
this ->count_operations = count_operations ;
|
||||
current_operation_number = 0 ;
|
||||
fraction = (double) 1 / count_operations ;
|
||||
fraction = 1.00 / count_operations ;
|
||||
|
||||
Glib::ustring str_temp = "<span weight=\"bold\" size=\"larger\">" ;
|
||||
str_temp += _( "Applying pending operations" ) ;
|
||||
|
@ -94,7 +94,7 @@ void Dialog_Progress::Set_Operation( )
|
|||
|
||||
if ( TIME_LEFT > 0 )
|
||||
{
|
||||
fraction_current = (double) 1 / TIME_LEFT ;
|
||||
fraction_current = 1.00 / TIME_LEFT ;
|
||||
conn = Glib::signal_timeout( ) .connect( sigc::mem_fun( *this, &Dialog_Progress::Show_Progress ), 1000 );
|
||||
}
|
||||
else
|
||||
|
@ -138,7 +138,6 @@ void Dialog_Progress::signal_textbuffer_insert( const Gtk::TextBuffer::iterator
|
|||
textview_details .scroll_to( temp, 0 ) ;
|
||||
}
|
||||
|
||||
|
||||
Dialog_Progress::~Dialog_Progress()
|
||||
{
|
||||
conn .disconnect( ) ;
|
||||
|
|
|
@ -17,13 +17,13 @@
|
|||
|
||||
#include "../include/Frame_Resizer_Base.h"
|
||||
|
||||
Frame_Resizer_Base::Frame_Resizer_Base()
|
||||
Frame_Resizer_Base::Frame_Resizer_Base( )
|
||||
{
|
||||
this ->fixed_start = false ;
|
||||
init( ) ;
|
||||
}
|
||||
|
||||
void Frame_Resizer_Base::init()
|
||||
void Frame_Resizer_Base::init( )
|
||||
{
|
||||
drawingarea .set_size_request( 536, 50 );
|
||||
|
||||
|
@ -58,19 +58,18 @@ void Frame_Resizer_Base::init()
|
|||
this ->show_all_children( );
|
||||
}
|
||||
|
||||
|
||||
void Frame_Resizer_Base::set_rgb_partition_color( const Gdk::Color & color )
|
||||
{
|
||||
this ->get_colormap() ->free_colors( color_partition, 1 ) ;
|
||||
this ->get_colormap( ) ->free_colors( color_partition, 1 ) ;
|
||||
this ->color_partition = color ;
|
||||
this ->get_colormap() ->alloc_color( color_partition ) ;
|
||||
this ->get_colormap( ) ->alloc_color( color_partition ) ;
|
||||
}
|
||||
|
||||
void Frame_Resizer_Base::override_default_rgb_unused_color( const Gdk::Color & color )
|
||||
{
|
||||
this ->get_colormap() ->free_colors( color_unused, 1 ) ;
|
||||
this ->get_colormap( ) ->free_colors( color_unused, 1 ) ;
|
||||
this ->color_unused = color ;
|
||||
this ->get_colormap() ->alloc_color( color_unused ) ;
|
||||
this ->get_colormap( ) ->alloc_color( color_unused ) ;
|
||||
}
|
||||
|
||||
void Frame_Resizer_Base::set_x_start( int x_start)
|
||||
|
@ -107,36 +106,36 @@ void Frame_Resizer_Base::set_size_limits( int min_size, int max_size )
|
|||
this ->MAX_SIZE = max_size + 16 ;
|
||||
}
|
||||
|
||||
int Frame_Resizer_Base::get_used()
|
||||
int Frame_Resizer_Base::get_used( )
|
||||
{
|
||||
return USED ;
|
||||
}
|
||||
|
||||
int Frame_Resizer_Base::get_x_start()
|
||||
int Frame_Resizer_Base::get_x_start( )
|
||||
{
|
||||
return X_START -10 ;
|
||||
}
|
||||
|
||||
int Frame_Resizer_Base::get_x_end()
|
||||
int Frame_Resizer_Base::get_x_end( )
|
||||
{
|
||||
return X_END -26 ;
|
||||
}
|
||||
|
||||
void Frame_Resizer_Base::drawingarea_on_realize( )
|
||||
{
|
||||
gc = Gdk::GC::create( drawingarea .get_window() );
|
||||
gc = Gdk::GC::create( drawingarea .get_window( ) );
|
||||
|
||||
drawingarea .get_window() ->set_background(color_background);
|
||||
drawingarea .get_window( ) ->set_background( color_background );
|
||||
|
||||
drawingarea.add_events(Gdk::POINTER_MOTION_MASK );
|
||||
drawingarea.add_events(Gdk::BUTTON_PRESS_MASK );
|
||||
drawingarea.add_events(Gdk::BUTTON_RELEASE_MASK );
|
||||
drawingarea.add_events(Gdk::LEAVE_NOTIFY_MASK );
|
||||
drawingarea .add_events( Gdk::POINTER_MOTION_MASK );
|
||||
drawingarea .add_events( Gdk::BUTTON_PRESS_MASK );
|
||||
drawingarea .add_events( Gdk::BUTTON_RELEASE_MASK );
|
||||
drawingarea .add_events( Gdk::LEAVE_NOTIFY_MASK );
|
||||
}
|
||||
|
||||
bool Frame_Resizer_Base::drawingarea_on_expose( GdkEventExpose * ev )
|
||||
{
|
||||
Draw_Partition() ;
|
||||
Draw_Partition( ) ;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -146,35 +145,34 @@ bool Frame_Resizer_Base::drawingarea_on_mouse_motion( GdkEventMotion *ev )
|
|||
{
|
||||
//check if pointer is over a gripper
|
||||
if ( ! fixed_start && ev ->x >= X_START -10 && ev ->x <= X_START && ev ->y >= 5 && ev ->y <= 45 ) //left grip
|
||||
drawingarea .get_parent_window() ->set_cursor( *cursor_resize ) ;
|
||||
drawingarea .get_parent_window( ) ->set_cursor( *cursor_resize ) ;
|
||||
else if ( ev ->x >= X_END && ev ->x <= X_END + 10 && ev ->y >= 5 && ev ->y <= 45 ) //right grip
|
||||
drawingarea .get_parent_window() ->set_cursor( *cursor_resize ) ;
|
||||
drawingarea .get_parent_window( ) ->set_cursor( *cursor_resize ) ;
|
||||
else if ( ! fixed_start && ev ->x >= X_START && ev ->x <= X_END ) //move grip
|
||||
drawingarea .get_parent_window() ->set_cursor( *cursor_move ) ;
|
||||
drawingarea .get_parent_window( ) ->set_cursor( *cursor_move ) ;
|
||||
else //normal pointer
|
||||
drawingarea .get_parent_window() ->set_cursor( *cursor_normal ) ;
|
||||
drawingarea .get_parent_window( ) ->set_cursor( *cursor_normal ) ;
|
||||
}
|
||||
|
||||
|
||||
//here's where the real work is done ;-)
|
||||
if ( GRIP_LEFT || GRIP_RIGHT || GRIP_MOVE)
|
||||
if ( GRIP_LEFT || GRIP_RIGHT || GRIP_MOVE )
|
||||
{
|
||||
if ( GRIP_LEFT && ev ->x >= 10 && ev ->x <= X_END - USED - BORDER * 2 && (X_END - ev ->x) <= MAX_SIZE && (X_END - ev ->x) >= MIN_SIZE )
|
||||
{
|
||||
X_START =(int) ev -> x ;
|
||||
X_START = static_cast<int> ( ev ->x ) ;
|
||||
signal_resize.emit( X_START -10, X_END -26, ARROW_LEFT) ; //-10/-26 to get the real value ( this way gripper calculations are invisible outside this class )
|
||||
}
|
||||
|
||||
else if ( GRIP_RIGHT && ev ->x <= 526 && ev ->x >= X_START + USED + BORDER *2 && (ev ->x - X_START) <= MAX_SIZE && (ev ->x - X_START) >= MIN_SIZE )
|
||||
{
|
||||
X_END = (int) ev ->x ;
|
||||
X_END = static_cast<int> ( ev ->x ) ;
|
||||
signal_resize.emit( X_START -10, X_END -26, ARROW_RIGHT) ; //-10/-26 to get the real value ( this way gripper calculations are invisible outside this class )
|
||||
}
|
||||
|
||||
else if ( GRIP_MOVE )
|
||||
{
|
||||
temp_x = X_START + ((int) ev ->x - X_START_MOVE);
|
||||
temp_y = X_END + ( (int) ev ->x - X_START_MOVE);
|
||||
temp_x = X_START + static_cast<int> ( ev ->x - X_START_MOVE );
|
||||
temp_y = X_END + static_cast<int> ( ev ->x - X_START_MOVE );
|
||||
|
||||
if ( temp_x >= 10 && temp_y <= 526 )
|
||||
{
|
||||
|
@ -182,16 +180,15 @@ bool Frame_Resizer_Base::drawingarea_on_mouse_motion( GdkEventMotion *ev )
|
|||
X_END = temp_y ;
|
||||
}
|
||||
|
||||
X_START_MOVE = (int) ev ->x ;
|
||||
X_START_MOVE = static_cast<int> ( ev ->x ) ;
|
||||
|
||||
signal_move.emit( X_START -10, X_END -26) ; //-10/-26 to get the real value ( this way gripper calculations are invisible outside this class )
|
||||
}
|
||||
|
||||
Draw_Partition() ;
|
||||
Draw_Partition( ) ;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
bool Frame_Resizer_Base::drawingarea_on_button_press_event( GdkEventButton *ev )
|
||||
|
@ -203,7 +200,7 @@ bool Frame_Resizer_Base::drawingarea_on_button_press_event( GdkEventButton *ev )
|
|||
else if ( ev ->x >= X_END && ev ->x <= X_END + 10 && ev ->y >= 5 && ev ->y <= 45 ) //right grip
|
||||
GRIP_RIGHT = true ;
|
||||
else if ( ! fixed_start && ev ->x >= X_START && ev ->x <= X_END ) //move grip
|
||||
{ GRIP_MOVE = true ; X_START_MOVE = (int)ev ->x; }
|
||||
{ GRIP_MOVE = true ; X_START_MOVE = static_cast<int> ( ev ->x ); }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -218,7 +215,7 @@ bool Frame_Resizer_Base::drawingarea_on_button_release_event( GdkEventButton *ev
|
|||
bool Frame_Resizer_Base::drawingarea_on_leave_notify( GdkEventCrossing *ev )
|
||||
{
|
||||
if ( ev ->mode != GDK_CROSSING_GRAB && ! GRIP_LEFT && ! GRIP_RIGHT && ! GRIP_MOVE )
|
||||
drawingarea .get_parent_window() ->set_cursor( *cursor_normal ) ;
|
||||
drawingarea .get_parent_window( ) ->set_cursor( *cursor_normal ) ;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -231,24 +228,24 @@ void Frame_Resizer_Base::Draw_Partition( )
|
|||
|
||||
if ( drawingarea .get_window( ) )
|
||||
{
|
||||
drawingarea .get_window() ->clear() ;
|
||||
drawingarea .get_window( ) ->clear( ) ;
|
||||
|
||||
//the two rectangles on each side of the partition
|
||||
gc ->set_foreground( color_arrow_rectangle );
|
||||
drawingarea .get_window() ->draw_rectangle( gc, true, 0,0,10,50 );
|
||||
drawingarea .get_window() ->draw_rectangle( gc, true, 526,0,10,50 );
|
||||
drawingarea .get_window( ) ->draw_rectangle( gc, true, 0, 0, 10, 50 );
|
||||
drawingarea .get_window( ) ->draw_rectangle( gc, true, 526, 0, 10, 50 );
|
||||
|
||||
//partition
|
||||
gc ->set_foreground( color_partition );
|
||||
drawingarea .get_window() ->draw_rectangle( gc, true, X_START,0,X_END - X_START,50 );
|
||||
drawingarea .get_window( ) ->draw_rectangle( gc, true, X_START, 0, X_END - X_START, 50 );
|
||||
|
||||
//used
|
||||
gc ->set_foreground( color_used );
|
||||
drawingarea .get_window() ->draw_rectangle( gc, true, X_START + BORDER, BORDER, USED ,34 );
|
||||
drawingarea .get_window( ) ->draw_rectangle( gc, true, X_START +BORDER, BORDER, USED, 34 );
|
||||
|
||||
//unused
|
||||
gc ->set_foreground( color_unused );
|
||||
drawingarea .get_window() ->draw_rectangle( gc, true, X_START + BORDER +USED, BORDER, UNUSED,34 );
|
||||
drawingarea .get_window( ) ->draw_rectangle( gc, true, X_START +BORDER +USED, BORDER, UNUSED, 34 );
|
||||
|
||||
//resize grips
|
||||
if ( ! fixed_start )
|
||||
|
@ -256,7 +253,6 @@ void Frame_Resizer_Base::Draw_Partition( )
|
|||
|
||||
Draw_Resize_Grip( ARROW_RIGHT ) ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Frame_Resizer_Base::Draw_Resize_Grip( ArrowType arrow_type )
|
||||
|
@ -278,24 +274,22 @@ void Frame_Resizer_Base::Draw_Resize_Grip( ArrowType arrow_type )
|
|||
gc ->set_foreground( color_arrow_rectangle );
|
||||
|
||||
if ( arrow_type == ARROW_LEFT )
|
||||
drawingarea .get_window() ->draw_rectangle( gc, false, X_START -10 , 5, 9, 40 );
|
||||
drawingarea .get_window( ) ->draw_rectangle( gc, false, X_START -10 , 5, 9, 40 );
|
||||
else
|
||||
drawingarea .get_window() ->draw_rectangle( gc, false, X_END +1, 5, 9, 40 );
|
||||
drawingarea .get_window( ) ->draw_rectangle( gc, false, X_END +1, 5, 9, 40 );
|
||||
|
||||
gc ->set_foreground( color_arrow );
|
||||
drawingarea .get_window() ->draw_polygon( gc , true, arrow_points );
|
||||
|
||||
drawingarea .get_window( ) ->draw_polygon( gc , true, arrow_points );
|
||||
}
|
||||
|
||||
|
||||
Frame_Resizer_Base::~Frame_Resizer_Base()
|
||||
Frame_Resizer_Base::~Frame_Resizer_Base( )
|
||||
{
|
||||
this ->get_colormap() ->free_colors( color_used, 1 ) ;
|
||||
this ->get_colormap() ->free_colors( color_unused, 1 ) ;
|
||||
this ->get_colormap() ->free_colors( color_arrow, 1 ) ;
|
||||
this ->get_colormap() ->free_colors( color_background, 1 ) ;
|
||||
this ->get_colormap() ->free_colors( color_partition, 1 ) ;
|
||||
this ->get_colormap() ->free_colors( color_arrow_rectangle, 1 ) ;
|
||||
this ->get_colormap( ) ->free_colors( color_used, 1 ) ;
|
||||
this ->get_colormap( ) ->free_colors( color_unused, 1 ) ;
|
||||
this ->get_colormap( ) ->free_colors( color_arrow, 1 ) ;
|
||||
this ->get_colormap( ) ->free_colors( color_background, 1 ) ;
|
||||
this ->get_colormap( ) ->free_colors( color_partition, 1 ) ;
|
||||
this ->get_colormap( ) ->free_colors( color_arrow_rectangle, 1 ) ;
|
||||
|
||||
if ( cursor_resize )
|
||||
delete cursor_resize ;
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
Frame_Resizer_Extended::Frame_Resizer_Extended( )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool Frame_Resizer_Extended::drawingarea_on_mouse_motion( GdkEventMotion *ev )
|
||||
|
@ -28,52 +27,52 @@ bool Frame_Resizer_Extended::drawingarea_on_mouse_motion( GdkEventMotion *ev )
|
|||
{
|
||||
//check if pointer is over a gripper
|
||||
if ( ! fixed_start && ev ->x >= X_START -10 && ev ->x <= X_START && ev ->y >= 5 && ev ->y <= 45 ) //left grip
|
||||
drawingarea .get_parent_window() ->set_cursor( *cursor_resize ) ;
|
||||
drawingarea .get_parent_window( ) ->set_cursor( *cursor_resize ) ;
|
||||
else if ( ev ->x >= X_END && ev ->x <= X_END + 10 && ev ->y >= 5 && ev ->y <= 45 ) //right grip
|
||||
drawingarea .get_parent_window() ->set_cursor( *cursor_resize ) ;
|
||||
drawingarea .get_parent_window( ) ->set_cursor( *cursor_resize ) ;
|
||||
else //normal pointer
|
||||
drawingarea .get_parent_window() ->set_cursor( *cursor_normal ) ;
|
||||
drawingarea .get_parent_window( ) ->set_cursor( *cursor_normal ) ;
|
||||
}
|
||||
|
||||
if ( GRIP_LEFT || GRIP_RIGHT )
|
||||
else if ( GRIP_LEFT || GRIP_RIGHT )
|
||||
{
|
||||
if ( GRIP_LEFT && ev ->x >= 10 && ev ->x <= 510 && ev->x <= X_END - BORDER *2 && ( ev ->x <= USED_START || USED == 0 ) )
|
||||
{
|
||||
X_START =(int) ev -> x ;
|
||||
signal_resize.emit( X_START -10, X_END -26, ARROW_LEFT) ; //-10/-26 to get the real value ( this way gripper calculations are invisible outside this class )
|
||||
X_START = static_cast<int> ( ev ->x ) ;
|
||||
signal_resize .emit( X_START -10, X_END -26, ARROW_LEFT ) ; //-10/-26 to get the real value ( this way gripper calculations are invisible outside this class )
|
||||
}
|
||||
|
||||
else if ( GRIP_RIGHT && ev ->x <= 526 && ev->x >= X_START + BORDER *2 && ev ->x >= USED_START + USED + BORDER *2 )
|
||||
{
|
||||
X_END = (int) ev ->x ;
|
||||
signal_resize.emit( X_START -10, X_END -26, ARROW_RIGHT) ;//-10/-26 to get the real value ( this way gripper calculations are invisible outside this class )
|
||||
X_END = static_cast<int> ( ev ->x ) ;
|
||||
signal_resize .emit( X_START -10, X_END -26, ARROW_RIGHT ) ;//-10/-26 to get the real value ( this way gripper calculations are invisible outside this class )
|
||||
}
|
||||
|
||||
Draw_Partition() ;
|
||||
Draw_Partition( ) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
void Frame_Resizer_Extended::Draw_Partition()
|
||||
void Frame_Resizer_Extended::Draw_Partition( )
|
||||
{
|
||||
drawingarea .get_window() ->clear () ;
|
||||
drawingarea .get_window( ) ->clear( ) ;
|
||||
|
||||
//the two rectangles on each side of the partition
|
||||
gc ->set_foreground( color_arrow_rectangle );
|
||||
drawingarea .get_window() ->draw_rectangle( gc, true, 0,0,10,50 );
|
||||
drawingarea .get_window() ->draw_rectangle( gc, true, 526,0,10,50 );
|
||||
drawingarea .get_window( ) ->draw_rectangle( gc, true, 0, 0, 10, 50 );
|
||||
drawingarea .get_window( ) ->draw_rectangle( gc, true, 526, 0, 10, 50 );
|
||||
|
||||
//used
|
||||
gc ->set_foreground( color_used );
|
||||
drawingarea .get_window() ->draw_rectangle( gc, true, USED_START + BORDER, BORDER, USED ,34 );
|
||||
drawingarea .get_window( ) ->draw_rectangle( gc, true, USED_START + BORDER, BORDER, USED, 34 );
|
||||
|
||||
//partition
|
||||
gc ->set_foreground( color_partition );
|
||||
for( short t=0; t<9 ;t++ )
|
||||
drawingarea .get_window() ->draw_rectangle( gc, false, X_START +t,t,X_END - X_START -t*2,50 - t*2 );
|
||||
for( short t = 0; t < 9 ; t++ )
|
||||
drawingarea .get_window( ) ->draw_rectangle( gc, false, X_START +t, t, X_END - X_START -t*2, 50 - t*2 );
|
||||
|
||||
//resize grips
|
||||
Draw_Resize_Grip( ARROW_LEFT ) ;
|
||||
Draw_Resize_Grip( ARROW_RIGHT ) ;
|
||||
|
||||
}
|
||||
|
|
|
@ -113,10 +113,7 @@ void GParted_Core::get_devices( std::vector<Device> & devices )
|
|||
set_device_partitions( temp_device ) ;
|
||||
|
||||
if ( temp_device .highest_busy )
|
||||
{
|
||||
temp_device .readonly = ! ped_disk_commit_to_os( disk ) ;
|
||||
sleep( 1 ) ;//this sucks, but it seems that after the commit test, the paths are removed and added again (which takes time..)
|
||||
}
|
||||
}
|
||||
//harddisk without disklabel
|
||||
else
|
||||
|
|
|
@ -35,7 +35,6 @@ Operation::Operation( const Device & device, const Partition & partition_origina
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
Glib::ustring Operation::Get_String( )
|
||||
{
|
||||
Glib::ustring temp ;
|
||||
|
@ -93,7 +92,6 @@ Glib::ustring Operation::Get_String( )
|
|||
|
||||
}
|
||||
|
||||
|
||||
void Operation::Apply_Operation_To_Visual( std::vector<Partition> & partitions )
|
||||
{
|
||||
switch ( operationtype )
|
||||
|
@ -153,7 +151,7 @@ void Operation::Insert_Unallocated( std::vector<Partition> & partitions, Sector
|
|||
|
||||
int Operation::Get_Index_Original( std::vector<Partition> & partitions )
|
||||
{
|
||||
for ( int t = 0 ; t < (int)partitions .size( ) ; t++ )
|
||||
for ( int t = 0 ; t < static_cast<int> ( partitions .size( ) ) ; t++ )
|
||||
if ( partition_original .sector_start >= partitions[ t ] .sector_start && partition_original .sector_end <= partitions[ t ] .sector_end )
|
||||
{
|
||||
//remove unallocated space preceding the original partition
|
||||
|
@ -161,7 +159,7 @@ int Operation::Get_Index_Original( std::vector<Partition> & partitions )
|
|||
partitions .erase( partitions .begin( ) + --t );
|
||||
|
||||
//remove unallocated space following the original partition
|
||||
if ( t +1 < (int)partitions .size( ) && partitions[ t +1 ] .type == GParted::UNALLOCATED )
|
||||
if ( t +1 < static_cast<int> ( partitions .size( ) ) && partitions[ t +1 ] .type == GParted::UNALLOCATED )
|
||||
partitions .erase( partitions .begin( ) + t +1 );
|
||||
|
||||
return t ;
|
||||
|
|
|
@ -46,13 +46,13 @@ VBox_VisualDisk::VBox_VisualDisk( const std::vector<Partition> & partitions, con
|
|||
|
||||
|
||||
//since disksegments have minimal sizes ( unallocated 15 and partitions 20 pixels ) i do some checking to prevent the visual disk from growing to much
|
||||
Sector sectors_per_pixel = Round( (double) device_length / 750 ) ;
|
||||
Sector sectors_per_pixel = Round( device_length / 750.00 ) ;
|
||||
|
||||
double width, extra_pixels = 0 ;
|
||||
double extra_pixels = 0 ;
|
||||
|
||||
for ( unsigned int t = 0; t < partitions .size( ) ; t++ )
|
||||
{
|
||||
width = (double) (partitions[ t ] .sector_end - partitions[ t ] .sector_start) / sectors_per_pixel ;
|
||||
double width = static_cast<double> (partitions[ t ] .sector_end - partitions[ t ] .sector_start) / sectors_per_pixel ;
|
||||
|
||||
if ( (partitions[ t ] .type == GParted::PRIMARY || partitions[ t ] .type == GParted::LOGICAL) && width < 20 )
|
||||
extra_pixels += (20 - width) ;
|
||||
|
@ -121,11 +121,10 @@ void VBox_VisualDisk::Create_Visual_Partition( const Partition & partition )
|
|||
hbox_extended ->pack_start( *( visual_partitions .back( ) ->drawingarea ), Gtk::PACK_SHRINK ) ;
|
||||
}
|
||||
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
visual_partitions .back( ) ->length = (int) (SCREEN_WIDTH / (double) ( device_length / (double) ( partition .sector_end - partition .sector_start) ) );
|
||||
visual_partitions .back( ) ->length = static_cast<int> ( SCREEN_WIDTH / ( device_length / static_cast<double> (partition .sector_end - partition .sector_start) ) );
|
||||
if ( visual_partitions .back( ) ->length < 20 )//we need a min. size. Otherwise some small partitions wouldn't be visible
|
||||
visual_partitions .back( ) ->length = ( partition .type == GParted::UNALLOCATED ) ? 15 : 20 ;
|
||||
|
||||
|
@ -143,8 +142,7 @@ void VBox_VisualDisk::Create_Visual_Partition( const Partition & partition )
|
|||
if ( partition .type == GParted::UNALLOCATED )
|
||||
visual_partitions .back( ) ->used = -1;
|
||||
else
|
||||
visual_partitions .back( ) ->used = (int) ( (visual_partitions .back( ) ->length - (BORDER *2)) / (double) ( ( partition .sector_end - partition .sector_start) / (double)partition .sectors_used ) ) ;
|
||||
|
||||
visual_partitions .back( ) ->used = static_cast<int> ( (visual_partitions .back( ) ->length - (BORDER *2)) / ( static_cast<double> (partition .sector_end - partition .sector_start) / partition .sectors_used ) );
|
||||
|
||||
visual_partitions.back( ) ->color_fs = partition .color;
|
||||
this ->get_colormap( ) ->alloc_color( visual_partitions .back( ) ->color_fs );
|
||||
|
@ -250,24 +248,21 @@ void VBox_VisualDisk::Set_Selected( const Partition & partition )
|
|||
if ( temp >= 0 ) //prevent segfault at firsttime selection
|
||||
drawingarea_on_expose( NULL, visual_partitions[ temp ] ) ;
|
||||
|
||||
|
||||
if ( partition.type == GParted::EXTENDED )
|
||||
return; //extended can not be selected in visualdisk (yet )
|
||||
|
||||
//now set new selected one
|
||||
for ( unsigned int t = 0;t < visual_partitions.size() ; t++ )
|
||||
{
|
||||
if ( visual_partitions[t] ->sector_start == partition.sector_start && visual_partitions[t] ->drawingarea != NULL )
|
||||
if ( visual_partitions[ t ] ->sector_start == partition .sector_start && visual_partitions[ t ] ->drawingarea != NULL )
|
||||
{
|
||||
selected_partition = t;
|
||||
drawingarea_on_expose( NULL, visual_partitions[ t ] ) ;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void VBox_VisualDisk::drawingarea_on_realize( Visual_Partition* vp )
|
||||
{
|
||||
vp ->gc = Gdk::GC::create( vp ->drawingarea ->get_window( ) );
|
||||
|
@ -325,10 +320,6 @@ VBox_VisualDisk::~VBox_VisualDisk( )
|
|||
this ->get_colormap( ) ->free_colors( color_used, 1 ) ;
|
||||
this ->get_colormap( ) ->free_colors( color_unused, 1 ) ;
|
||||
this ->get_colormap( ) ->free_colors( color_text, 1 ) ;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} //GParted
|
||||
|
|
|
@ -995,7 +995,7 @@ void Win_GParted::activate_delete( )
|
|||
if ( selected_partition .status == GParted::STAT_NEW )
|
||||
{
|
||||
//remove all operations done on this new partition (this includes creation)
|
||||
for ( int t = 0 ; t < (int) operations .size( ) ; t++ ) //I removed the unsigned because t will be negative at times...
|
||||
for ( int t = 0 ; t < static_cast<int> ( operations .size( ) ) ; t++ ) //I removed the unsigned because t will be negative at times...
|
||||
if ( operations[ t ] .partition_new .partition == selected_partition .partition )
|
||||
operations.erase( operations .begin( ) + t-- ) ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue