did lots of work on the resizer, it's behaviour should be more natural and
* include/Frame_Resizer_Base.h, include/Frame_Resizer_Extended.h, src/Dialog_Base_Partition.cc, src/Dialog_Partition_Copy.cc, src/Dialog_Partition_New.cc, src/Dialog_Partition_Resize_Move.cc, src/Frame_Resizer_Base.cc, src/Frame_Resizer_Extended.cc: did lots of work on the resizer, it's behaviour should be more natural and satisfying now. (see also #331591) * src/Win_GParted.cc: extended partition was resizable even when it's busy. fixed. * src/ntfs.cc: made scan output more readable. * src/FrameVisualDisk.cc: added FIXME
This commit is contained in:
parent
810ff077d1
commit
9830c8f63e
17
ChangeLog
17
ChangeLog
|
@ -1,3 +1,20 @@
|
|||
2006-03-01 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||
|
||||
* include/Frame_Resizer_Base.h,
|
||||
include/Frame_Resizer_Extended.h,
|
||||
src/Dialog_Base_Partition.cc,
|
||||
src/Dialog_Partition_Copy.cc,
|
||||
src/Dialog_Partition_New.cc,
|
||||
src/Dialog_Partition_Resize_Move.cc,
|
||||
src/Frame_Resizer_Base.cc,
|
||||
src/Frame_Resizer_Extended.cc: did lots of work on the resizer, it's
|
||||
behaviour should be more natural and satisfying now. (see also
|
||||
#331591)
|
||||
* src/Win_GParted.cc: extended partition was resizable even when it's
|
||||
busy. fixed.
|
||||
* src/ntfs.cc: made scan output more readable.
|
||||
* src/FrameVisualDisk.cc: added FIXME
|
||||
|
||||
2006-02-25 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||
|
||||
* include/GParted_Core.h,
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef FRAME_RESIZER_BASE
|
||||
#define FRAME_RESIZER_BASE
|
||||
|
||||
|
@ -23,12 +22,9 @@
|
|||
#include <gtkmm/drawingarea.h>
|
||||
#include <gdkmm/cursor.h>
|
||||
|
||||
#define BORDER 8
|
||||
|
||||
class Frame_Resizer_Base : public Gtk::Frame
|
||||
{
|
||||
public:
|
||||
|
||||
enum ArrowType {
|
||||
ARROW_LEFT = 0,
|
||||
ARROW_RIGHT = 1
|
||||
|
@ -37,14 +33,13 @@ public:
|
|||
Frame_Resizer_Base() ;
|
||||
~Frame_Resizer_Base() ;
|
||||
|
||||
void set_rgb_partition_color( const Gdk::Color & ) ;
|
||||
void override_default_rgb_unused_color( const Gdk::Color & ) ;
|
||||
void set_rgb_partition_color( const Gdk::Color & color ) ;
|
||||
void override_default_rgb_unused_color( const Gdk::Color & color ) ;
|
||||
|
||||
void set_x_start( int ) ;
|
||||
void set_x_end( int ) ;
|
||||
void set_used( int );
|
||||
void set_fixed_start( bool ) ;
|
||||
void set_used_start( int used_start ) ;
|
||||
void set_x_start( int x_start ) ;
|
||||
void set_x_end( int x_end ) ;
|
||||
void set_used( int used );
|
||||
void set_fixed_start( bool fixed_start ) ;
|
||||
void set_size_limits( int min_size, int max_size ) ;
|
||||
|
||||
int get_used();
|
||||
|
@ -58,16 +53,17 @@ public:
|
|||
sigc::signal<void,int,int> signal_move;
|
||||
|
||||
protected:
|
||||
int X_START, USED, UNUSED, X_END, X_START_MOVE, USED_START, MIN_SIZE, MAX_SIZE;
|
||||
int BORDER, GRIPPER ;
|
||||
int X_START, USED, UNUSED, X_END, X_START_MOVE, MIN_SIZE, MAX_SIZE;
|
||||
bool GRIP_LEFT, GRIP_RIGHT, GRIP_MOVE ;
|
||||
|
||||
//signal handlers
|
||||
void drawingarea_on_realize();
|
||||
bool drawingarea_on_expose( GdkEventExpose * );
|
||||
virtual bool drawingarea_on_mouse_motion( GdkEventMotion* ) ;
|
||||
bool drawingarea_on_button_press_event( GdkEventButton* ) ;
|
||||
bool drawingarea_on_button_release_event( GdkEventButton* ) ;
|
||||
bool drawingarea_on_leave_notify( GdkEventCrossing* ) ;
|
||||
bool drawingarea_on_expose( GdkEventExpose * ev );
|
||||
virtual bool drawingarea_on_mouse_motion( GdkEventMotion * ev ) ;
|
||||
bool drawingarea_on_button_press_event( GdkEventButton * ev ) ;
|
||||
bool drawingarea_on_button_release_event( GdkEventButton * ev ) ;
|
||||
bool drawingarea_on_leave_notify( GdkEventCrossing * ev ) ;
|
||||
|
||||
void Draw_Resize_Grip( ArrowType ) ;
|
||||
|
||||
|
|
|
@ -26,10 +26,13 @@ class Frame_Resizer_Extended : public Frame_Resizer_Base
|
|||
public:
|
||||
Frame_Resizer_Extended() ;
|
||||
|
||||
void set_used_start( int used_start ) ;
|
||||
|
||||
private:
|
||||
int UNUSED_BEFORE ;
|
||||
int USED_START ;
|
||||
|
||||
//overridden signal handler
|
||||
virtual bool drawingarea_on_mouse_motion( GdkEventMotion* ) ;
|
||||
virtual bool drawingarea_on_mouse_motion( GdkEventMotion * ev ) ;
|
||||
|
||||
virtual void Draw_Partition() ;
|
||||
};
|
||||
|
|
|
@ -51,7 +51,10 @@ Dialog_Base_Partition::Dialog_Base_Partition( )
|
|||
vbox_resize_move .pack_start( hbox_table, Gtk::PACK_SHRINK );
|
||||
|
||||
//add spinbutton_before
|
||||
table_resize.attach( * Utils::mk_label( (Glib::ustring) _( "Free Space Preceding (MiB):") + " \t" ), 0, 1, 0, 1, Gtk::SHRINK );
|
||||
table_resize .attach(
|
||||
* Utils::mk_label( static_cast<Glib::ustring>( _( "Free Space Preceding (MiB):") ) + " \t" ),
|
||||
0, 1, 0, 1,
|
||||
Gtk::SHRINK );
|
||||
|
||||
spinbutton_before .set_numeric( true );
|
||||
spinbutton_before .set_increments( 1, 100 );
|
||||
|
@ -77,12 +80,15 @@ 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 ) ) ;
|
||||
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 ) ) ;
|
||||
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 ) ) ;
|
||||
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() ;
|
||||
|
@ -115,9 +121,11 @@ Partition Dialog_Base_Partition::Get_New_Partition( )
|
|||
selected_partition .sector_start = START + spinbutton_before .get_value_as_int() * MEBIBYTE ;
|
||||
|
||||
if ( ORIG_AFTER != spinbutton_after .get_value_as_int() )
|
||||
selected_partition .sector_end = selected_partition .sector_start + spinbutton_size .get_value_as_int( ) * MEBIBYTE ;
|
||||
selected_partition .sector_end =
|
||||
selected_partition .sector_start + spinbutton_size .get_value_as_int() * MEBIBYTE ;
|
||||
|
||||
//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.
|
||||
//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.
|
||||
if ( selected_partition .sector_start < START )
|
||||
selected_partition .sector_start = START ;
|
||||
if ( selected_partition .sector_end > (START + total_length) )
|
||||
|
@ -131,8 +139,7 @@ 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 .get_length() - selected_partition .sectors_used ;
|
||||
|
||||
return selected_partition ;
|
||||
}
|
||||
|
@ -148,7 +155,8 @@ void Dialog_Base_Partition::Set_Confirm_Button( CONFIRMBUTTON button_type )
|
|||
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 ) ;
|
||||
hbox_resize_move .pack_start( * Utils::mk_label( fixed_start ? _("Resize") : _("Resize/Move") ),
|
||||
Gtk::PACK_EXPAND_PADDING ) ;
|
||||
button_resize_move .add( hbox_resize_move ) ;
|
||||
|
||||
this ->add_action_widget ( button_resize_move, Gtk::RESPONSE_OK ) ;
|
||||
|
@ -214,7 +222,8 @@ void Dialog_Base_Partition::on_signal_resize( int x_start, int x_end, Frame_Resi
|
|||
spinbutton_size .set_value( TOTAL_MB - spinbutton_after.get_value() ) ;
|
||||
}
|
||||
else
|
||||
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() ) ;
|
||||
}
|
||||
|
||||
Check_Change() ;
|
||||
|
@ -239,12 +248,14 @@ void Dialog_Base_Partition::on_spinbutton_value_changed( SPINBUTTON spinbutton )
|
|||
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() );
|
||||
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_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() ) ;
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons
|
|||
GRIP = false ;
|
||||
|
||||
frame_resizer_base ->set_size_limits( Utils::Round( fs .MIN / (MB_PER_PIXEL * MEBIBYTE) ),
|
||||
Utils::Round( fs .MAX / (MB_PER_PIXEL * MEBIBYTE) ) +1 ) ;
|
||||
Utils::Round( fs .MAX / (MB_PER_PIXEL * MEBIBYTE) ) ) ;
|
||||
|
||||
//set contents of label_minmax
|
||||
Set_MinMax_Text(
|
||||
|
@ -87,7 +87,8 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons
|
|||
//set global selected_partition (see Dialog_Base_Partition::Get_New_Partition )
|
||||
this ->selected_partition = copied_partition ;
|
||||
this ->selected_partition .inside_extended = selected_partition .inside_extended ;
|
||||
this ->selected_partition .type = selected_partition .inside_extended ? GParted::TYPE_LOGICAL : GParted::TYPE_PRIMARY ;
|
||||
this ->selected_partition .type =
|
||||
selected_partition .inside_extended ? GParted::TYPE_LOGICAL : GParted::TYPE_PRIMARY ;
|
||||
}
|
||||
|
||||
Partition Dialog_Partition_Copy::Get_New_Partition()
|
||||
|
|
|
@ -227,7 +227,7 @@ void Dialog_Partition_New::optionmenu_changed( bool type )
|
|||
fs .MAX - cylinder_size : TOTAL_MB * MEBIBYTE ;
|
||||
|
||||
frame_resizer_base ->set_size_limits( Utils::Round( fs .MIN / (MB_PER_PIXEL * MEBIBYTE) ),
|
||||
Utils::Round( fs .MAX / (MB_PER_PIXEL * MEBIBYTE) ) +1 ) ;
|
||||
Utils::Round( fs .MAX / (MB_PER_PIXEL * MEBIBYTE) ) ) ;
|
||||
|
||||
//set new spinbutton ranges
|
||||
spinbutton_before .set_range(
|
||||
|
|
|
@ -79,7 +79,7 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector <Partit
|
|||
|
||||
//calculate total size in MiB's of previous, current and next partition
|
||||
//first find index of partition
|
||||
unsigned int t;
|
||||
unsigned int t;//FIXME: use Partition::== here
|
||||
for ( t = 0 ; t < partitions .size() ; t++ )
|
||||
if ( partitions[ t ] .sector_start == selected_partition .sector_start )
|
||||
break;
|
||||
|
@ -98,14 +98,15 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector <Partit
|
|||
if ( t +1 < partitions .size() && partitions[t +1] .type == GParted::TYPE_UNALLOCATED )
|
||||
next = partitions[t +1].sector_end - partitions[t +1].sector_start ;
|
||||
|
||||
total_length = previous + (selected_partition.sector_end - selected_partition.sector_start) + next;
|
||||
total_length = previous + selected_partition.get_length() + next;
|
||||
TOTAL_MB = Utils::Round( Utils::sector_to_unit( total_length, GParted::UNIT_MIB ) ) ;
|
||||
|
||||
MB_PER_PIXEL = TOTAL_MB / 500.00 ;
|
||||
|
||||
//now calculate proportional length of partition
|
||||
frame_resizer_base ->set_x_start( Utils::Round( previous / ( total_length / 500.00 ) ) ) ;
|
||||
frame_resizer_base ->set_x_end( Utils::Round( (selected_partition .sector_end - selected_partition .sector_start) / ( total_length / 500.00 ) ) + frame_resizer_base ->get_x_start( ) ) ;
|
||||
frame_resizer_base ->set_x_end(
|
||||
Utils::Round( selected_partition .get_length() / ( total_length / 500.00 ) ) + frame_resizer_base ->get_x_start() ) ;
|
||||
frame_resizer_base ->set_used( Utils::Round( selected_partition.sectors_used / ( total_length / 500.00 ) ) ) ;
|
||||
|
||||
if ( fs .shrink )
|
||||
|
@ -145,7 +146,7 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector <Partit
|
|||
spinbutton_after .set_value( Utils::Round( Utils::sector_to_unit( next, GParted::UNIT_MIB ) ) ) ;
|
||||
|
||||
frame_resizer_base ->set_size_limits( Utils::Round( fs .MIN / (MB_PER_PIXEL * MEBIBYTE) ),
|
||||
Utils::Round( fs .MAX / (MB_PER_PIXEL * MEBIBYTE) ) +1 ) ;
|
||||
Utils::Round( fs .MAX / (MB_PER_PIXEL * MEBIBYTE) ) ) ;
|
||||
|
||||
//set contents of label_minmax
|
||||
Set_MinMax_Text(
|
||||
|
@ -176,13 +177,13 @@ void Dialog_Partition_Resize_Move::Resize_Move_Extended( const std::vector <Part
|
|||
next = partitions[ t +1 ] .sector_end - partitions[ t +1 ] .sector_start ;
|
||||
|
||||
//now we have enough data to calculate some important values..
|
||||
total_length = previous + (selected_partition.sector_end - selected_partition.sector_start) + next;
|
||||
total_length = previous + selected_partition .get_length() + next;
|
||||
TOTAL_MB = Utils::Round( Utils::sector_to_unit( total_length, UNIT_MIB ) ) ;
|
||||
MB_PER_PIXEL = TOTAL_MB / 500.00 ;
|
||||
|
||||
//calculate proportional length of partition ( in pixels )
|
||||
frame_resizer_base ->set_x_start( Utils::Round( previous / ( total_length / 500.00 ) ) ) ;
|
||||
frame_resizer_base ->set_x_end( Utils::Round( (selected_partition .sector_end - selected_partition .sector_start) / ( total_length / 500.00 ) ) + frame_resizer_base ->get_x_start( ) ) ;
|
||||
frame_resizer_base ->set_x_end( Utils::Round( selected_partition .get_length() / ( 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 ;
|
||||
|
@ -197,7 +198,8 @@ void Dialog_Partition_Resize_Move::Resize_Move_Extended( const std::vector <Part
|
|||
}
|
||||
}
|
||||
|
||||
frame_resizer_base ->set_used_start( Utils::Round( (first - START) / ( total_length / 500.00 ) ) ) ;
|
||||
dynamic_cast<Frame_Resizer_Extended *>( frame_resizer_base ) ->
|
||||
set_used_start( Utils::Round( (first - START) / ( total_length / 500.00 ) ) ) ;
|
||||
frame_resizer_base ->set_used( Utils::Round( used / ( total_length / 500.00 ) ) ) ;
|
||||
|
||||
//set values of spinbutton_before (we assume there is no fixed start.)
|
||||
|
@ -219,9 +221,11 @@ void Dialog_Partition_Resize_Move::Resize_Move_Extended( const std::vector <Part
|
|||
|
||||
//set values of spinbutton_after
|
||||
if ( first == 0 ) //no logicals
|
||||
spinbutton_after .set_range( 0, TOTAL_MB - Utils::Round( Utils::sector_to_unit( BUF/2, GParted::UNIT_MIB ) ) ) ;
|
||||
spinbutton_after .set_range(
|
||||
0, TOTAL_MB - Utils::Round( Utils::sector_to_unit( BUF/2, GParted::UNIT_MIB ) ) ) ;
|
||||
else
|
||||
spinbutton_after .set_range( 0, Utils::Round( Utils::sector_to_unit( total_length + START - first - used, GParted::UNIT_MIB ) ) ) ;
|
||||
spinbutton_after .set_range(
|
||||
0, Utils::Round( Utils::sector_to_unit( total_length + START - first - used, GParted::UNIT_MIB ) ) ) ;
|
||||
|
||||
spinbutton_after .set_value( Utils::Round( Utils::sector_to_unit( next, GParted::UNIT_MIB ) ) ) ;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
namespace GParted
|
||||
{
|
||||
|
||||
//FIXME: left border of extended partition seems to be 1px bigger than it's rightborder..
|
||||
FrameVisualDisk::FrameVisualDisk()
|
||||
{
|
||||
this ->set_border_width( 5 ) ;
|
||||
|
|
|
@ -19,20 +19,29 @@
|
|||
|
||||
Frame_Resizer_Base::Frame_Resizer_Base()
|
||||
{
|
||||
this ->fixed_start = false ;
|
||||
BORDER = 8 ;
|
||||
GRIPPER = 10 ;
|
||||
|
||||
fixed_start = false ;
|
||||
init() ;
|
||||
}
|
||||
|
||||
void Frame_Resizer_Base::init()
|
||||
{
|
||||
drawingarea .set_size_request( 536, 50 );
|
||||
drawingarea .set_size_request( 500 + GRIPPER * 2 + BORDER *2, 50 );
|
||||
|
||||
drawingarea .signal_realize( ) .connect( sigc::mem_fun(*this, &Frame_Resizer_Base::drawingarea_on_realize) ) ;
|
||||
drawingarea .signal_expose_event( ) .connect( sigc::mem_fun(*this, &Frame_Resizer_Base::drawingarea_on_expose) ) ;
|
||||
drawingarea .signal_motion_notify_event( ) .connect( sigc::mem_fun(*this, &Frame_Resizer_Base::drawingarea_on_mouse_motion) ) ;
|
||||
drawingarea .signal_button_press_event( ) .connect( sigc::mem_fun(*this, &Frame_Resizer_Base::drawingarea_on_button_press_event) ) ;
|
||||
drawingarea .signal_button_release_event( ) .connect( sigc::mem_fun(*this, &Frame_Resizer_Base::drawingarea_on_button_release_event) ) ;
|
||||
drawingarea .signal_leave_notify_event( ) .connect( sigc::mem_fun(*this, &Frame_Resizer_Base::drawingarea_on_leave_notify) ) ;
|
||||
drawingarea .signal_realize() .connect(
|
||||
sigc::mem_fun(*this, &Frame_Resizer_Base::drawingarea_on_realize) ) ;
|
||||
drawingarea .signal_expose_event() .connect(
|
||||
sigc::mem_fun(*this, &Frame_Resizer_Base::drawingarea_on_expose) ) ;
|
||||
drawingarea .signal_motion_notify_event() .connect(
|
||||
sigc::mem_fun(*this, &Frame_Resizer_Base::drawingarea_on_mouse_motion) ) ;
|
||||
drawingarea .signal_button_press_event() .connect(
|
||||
sigc::mem_fun(*this, &Frame_Resizer_Base::drawingarea_on_button_press_event) ) ;
|
||||
drawingarea .signal_button_release_event() .connect(
|
||||
sigc::mem_fun(*this, &Frame_Resizer_Base::drawingarea_on_button_release_event) ) ;
|
||||
drawingarea .signal_leave_notify_event() .connect(
|
||||
sigc::mem_fun(*this, &Frame_Resizer_Base::drawingarea_on_leave_notify) ) ;
|
||||
|
||||
this ->add( drawingarea ) ;
|
||||
|
||||
|
@ -74,12 +83,12 @@ void Frame_Resizer_Base::override_default_rgb_unused_color( const Gdk::Color & c
|
|||
|
||||
void Frame_Resizer_Base::set_x_start( int x_start )
|
||||
{
|
||||
this ->X_START = x_start +10;//space for leftgripper
|
||||
this ->X_START = x_start + GRIPPER ;
|
||||
}
|
||||
|
||||
void Frame_Resizer_Base::set_x_end( int x_end )
|
||||
{
|
||||
this ->X_END = x_end +26 ; //space for leftgripper + 2 * BORDER
|
||||
this ->X_END = x_end + GRIPPER + BORDER * 2 ;
|
||||
}
|
||||
|
||||
void Frame_Resizer_Base::set_used( int used )
|
||||
|
@ -92,18 +101,10 @@ void Frame_Resizer_Base::set_fixed_start( bool fixed_start )
|
|||
this ->fixed_start = fixed_start ;
|
||||
}
|
||||
|
||||
void Frame_Resizer_Base::set_used_start( int used_start )
|
||||
{
|
||||
if ( used_start <= 0 )
|
||||
this ->USED_START = 10;
|
||||
else
|
||||
this ->USED_START = used_start +10;
|
||||
}
|
||||
|
||||
void Frame_Resizer_Base::set_size_limits( int min_size, int max_size )
|
||||
{
|
||||
this ->MIN_SIZE = min_size + 16 ;
|
||||
this ->MAX_SIZE = max_size + 16 ;
|
||||
this ->MIN_SIZE = min_size + BORDER * 2 ;
|
||||
this ->MAX_SIZE = max_size + BORDER * 2 ;
|
||||
}
|
||||
|
||||
int Frame_Resizer_Base::get_used()
|
||||
|
@ -113,18 +114,20 @@ int Frame_Resizer_Base::get_used( )
|
|||
|
||||
int Frame_Resizer_Base::get_x_start()
|
||||
{
|
||||
return X_START -10 ;
|
||||
return X_START - GRIPPER ;
|
||||
}
|
||||
|
||||
int Frame_Resizer_Base::get_x_end()
|
||||
{
|
||||
return X_END -26 ;
|
||||
return X_END - GRIPPER - BORDER * 2 ;
|
||||
}
|
||||
|
||||
void Frame_Resizer_Base::drawingarea_on_realize()
|
||||
{
|
||||
gc_drawingarea = Gdk::GC::create( drawingarea .get_window() );
|
||||
pixmap = Gdk::Pixmap::create( drawingarea .get_window( ), drawingarea .get_allocation( ). get_width( ), drawingarea. get_allocation( ). get_height( ) );
|
||||
pixmap = Gdk::Pixmap::create( drawingarea .get_window(),
|
||||
drawingarea .get_allocation() .get_width(),
|
||||
drawingarea .get_allocation() .get_height() );
|
||||
gc_pixmap = Gdk::GC::create( pixmap );
|
||||
|
||||
drawingarea .add_events( Gdk::POINTER_MOTION_MASK );
|
||||
|
@ -143,47 +146,162 @@ bool Frame_Resizer_Base::drawingarea_on_mouse_motion( GdkEventMotion *ev )
|
|||
{
|
||||
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 )
|
||||
if ( GRIP_LEFT )
|
||||
{
|
||||
if ( ev ->x > GRIPPER &&
|
||||
(X_END - ev ->x) < MAX_SIZE &&
|
||||
(X_END - ev ->x) > MIN_SIZE )
|
||||
{
|
||||
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 )
|
||||
|
||||
signal_resize .emit( X_START - GRIPPER, X_END - GRIPPER - 2 * BORDER, ARROW_LEFT ) ;
|
||||
}
|
||||
else if ( X_END - ev ->x >= MAX_SIZE )
|
||||
{
|
||||
if ( X_END - X_START < MAX_SIZE )
|
||||
{
|
||||
X_START = X_END - MAX_SIZE ;
|
||||
|
||||
if ( X_START < GRIPPER )
|
||||
X_START = GRIPPER ;
|
||||
|
||||
//-1 to force the spinbutton to its max.
|
||||
signal_resize .emit( X_START - GRIPPER -1,
|
||||
X_END - GRIPPER - BORDER * 2,
|
||||
ARROW_LEFT ) ;
|
||||
}
|
||||
}
|
||||
else if ( ev ->x <= GRIPPER )
|
||||
{
|
||||
if ( X_START > GRIPPER && X_END - X_START < MAX_SIZE )
|
||||
{
|
||||
X_START = GRIPPER ;
|
||||
|
||||
signal_resize .emit( X_START - GRIPPER,
|
||||
X_END - GRIPPER - BORDER * 2,
|
||||
ARROW_LEFT ) ;
|
||||
}
|
||||
}
|
||||
else if ( X_END - ev ->x <= MIN_SIZE )
|
||||
{
|
||||
if ( X_END - X_START > MIN_SIZE )
|
||||
{
|
||||
X_START = X_END - MIN_SIZE ;
|
||||
|
||||
//+1 to force the spinbutton to its min.
|
||||
signal_resize .emit( X_START - GRIPPER +1,
|
||||
X_END - GRIPPER - BORDER * 2,
|
||||
ARROW_LEFT ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 )
|
||||
else if ( GRIP_RIGHT )
|
||||
{
|
||||
if ( ev ->x < 500 + GRIPPER + BORDER * 2 &&
|
||||
(ev ->x - X_START) < MAX_SIZE &&
|
||||
(ev ->x - X_START) > MIN_SIZE )
|
||||
{
|
||||
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 )
|
||||
|
||||
signal_resize .emit( X_START - GRIPPER, X_END - GRIPPER - BORDER * 2, ARROW_RIGHT ) ;
|
||||
}
|
||||
else if ( ev ->x - X_START >= MAX_SIZE )
|
||||
{
|
||||
if ( X_END - X_START < MAX_SIZE )
|
||||
{
|
||||
X_END = X_START + MAX_SIZE ;
|
||||
|
||||
if ( X_END > 500 + GRIPPER + BORDER * 2 )
|
||||
X_END = 500 + GRIPPER + BORDER * 2 ;
|
||||
|
||||
//+1 to force the spinbutton to its min.
|
||||
signal_resize .emit( X_START - GRIPPER,
|
||||
X_END - GRIPPER - BORDER * 2 +1,
|
||||
ARROW_RIGHT ) ;
|
||||
}
|
||||
}
|
||||
else if ( ev ->x >= 500 + GRIPPER + BORDER * 2 )
|
||||
{
|
||||
if ( X_END < 500 + GRIPPER + BORDER * 2 && X_END - X_START < MAX_SIZE )
|
||||
{
|
||||
X_END = 500 + GRIPPER + BORDER * 2 ;
|
||||
|
||||
signal_resize .emit( X_START -GRIPPER,
|
||||
X_END - GRIPPER - BORDER * 2,
|
||||
ARROW_RIGHT ) ;
|
||||
}
|
||||
}
|
||||
else if ( ev ->x - X_START <= MIN_SIZE )
|
||||
{
|
||||
if ( X_END - X_START > MIN_SIZE )
|
||||
{
|
||||
X_END = X_START + MIN_SIZE ;
|
||||
|
||||
//-1 to force the spinbutton to its min.
|
||||
signal_resize .emit( X_START - GRIPPER,
|
||||
X_END - GRIPPER - BORDER * 2 -1,
|
||||
ARROW_RIGHT ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if ( GRIP_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 );
|
||||
temp_y = X_END - X_START ;
|
||||
|
||||
if ( temp_x >= 10 && temp_y <= 526 )
|
||||
if ( temp_x > GRIPPER && temp_x + temp_y < 500 + GRIPPER + BORDER * 2 )
|
||||
{
|
||||
X_START = temp_x ;
|
||||
X_END = temp_y ;
|
||||
X_END = X_START + temp_y ;
|
||||
}
|
||||
else if ( temp_x <= GRIPPER )
|
||||
{
|
||||
if ( X_START > GRIPPER )
|
||||
{
|
||||
X_START = GRIPPER ;
|
||||
X_END = X_START + temp_y ;
|
||||
}
|
||||
}
|
||||
else if ( temp_x + temp_y >= 500 + GRIPPER + BORDER * 2 )
|
||||
{
|
||||
if ( X_END < 500 + GRIPPER + BORDER * 2 )
|
||||
{
|
||||
X_END = 500 + GRIPPER + BORDER * 2 ;
|
||||
X_START = X_END - temp_y ;
|
||||
}
|
||||
}
|
||||
|
||||
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 )
|
||||
signal_move .emit( X_START - GRIPPER, X_END - GRIPPER - BORDER * 2 ) ;
|
||||
}
|
||||
|
||||
Draw_Partition() ;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
//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
|
||||
//left grip
|
||||
if ( ! fixed_start &&
|
||||
ev ->x >= X_START - GRIPPER &&
|
||||
ev ->x <= X_START &&
|
||||
ev ->y >= 5 &&
|
||||
ev ->y <= 45 )
|
||||
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
|
||||
//right grip
|
||||
else if ( ev ->x >= X_END &&
|
||||
ev ->x <= X_END + GRIPPER &&
|
||||
ev ->y >= 5 &&
|
||||
ev ->y <= 45 )
|
||||
drawingarea .get_parent_window() ->set_cursor( *cursor_resize ) ;
|
||||
else if ( ! fixed_start && ev ->x >= X_START && ev ->x <= X_END ) //move grip
|
||||
//move grip
|
||||
else if ( ! fixed_start &&
|
||||
ev ->x >= X_START &&
|
||||
ev ->x <= X_END )
|
||||
drawingarea .get_parent_window() ->set_cursor( *cursor_move ) ;
|
||||
else //normal pointer
|
||||
//normal pointer
|
||||
else
|
||||
drawingarea .get_parent_window() ->set_cursor( *cursor_normal ) ;
|
||||
}
|
||||
|
||||
|
@ -192,14 +310,29 @@ bool Frame_Resizer_Base::drawingarea_on_mouse_motion( GdkEventMotion *ev )
|
|||
|
||||
bool Frame_Resizer_Base::drawingarea_on_button_press_event( GdkEventButton *ev )
|
||||
{
|
||||
GRIP_MOVE = false; GRIP_RIGHT = false; GRIP_LEFT = false ;
|
||||
GRIP_LEFT = GRIP_RIGHT = GRIP_MOVE = false;
|
||||
|
||||
if ( ! fixed_start && ev ->x >= X_START -10 && ev ->x <= X_START && ev ->y >= 5 && ev ->y <= 45 ) //left grip
|
||||
//left grip
|
||||
if ( ! fixed_start &&
|
||||
ev ->x >= X_START - GRIPPER &&
|
||||
ev ->x <= X_START &&
|
||||
ev ->y >= 5 &&
|
||||
ev ->y <= 45 )
|
||||
GRIP_LEFT = true ;
|
||||
else if ( ev ->x >= X_END && ev ->x <= X_END + 10 && ev ->y >= 5 && ev ->y <= 45 ) //right grip
|
||||
//right grip
|
||||
else if ( ev ->x >= X_END &&
|
||||
ev ->x <= X_END + GRIPPER &&
|
||||
ev ->y >= 5 &&
|
||||
ev ->y <= 45 )
|
||||
GRIP_RIGHT = true ;
|
||||
else if ( ! fixed_start && ev ->x >= X_START && ev ->x <= X_END ) //move grip
|
||||
{ GRIP_MOVE = true ; X_START_MOVE = static_cast<int> ( ev ->x ); }
|
||||
//move grip
|
||||
else if ( ! fixed_start &&
|
||||
ev ->x >= X_START &&
|
||||
ev ->x <= X_END )
|
||||
{
|
||||
GRIP_MOVE = true ;
|
||||
X_START_MOVE = static_cast<int>( ev ->x );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -264,19 +397,24 @@ void Frame_Resizer_Base::Draw_Resize_Grip( ArrowType arrow_type )
|
|||
if ( arrow_type == ARROW_LEFT )
|
||||
{
|
||||
arrow_points[ 0 ] .set_x( X_START ) ;
|
||||
arrow_points[ 1 ] .set_x( X_START -10 ) ;
|
||||
arrow_points[ 1 ] .set_x( X_START - GRIPPER ) ;
|
||||
arrow_points[ 2 ] .set_x( X_START ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
arrow_points[ 0 ] .set_x( X_END ) ;
|
||||
arrow_points[ 1 ] .set_x( X_END +10 ) ;
|
||||
arrow_points[ 1 ] .set_x( X_END + GRIPPER ) ;
|
||||
arrow_points[ 2 ] .set_x( X_END ) ;
|
||||
}
|
||||
|
||||
//attach resize arrows to the partition
|
||||
gc_pixmap ->set_foreground( color_arrow_rectangle );
|
||||
pixmap ->draw_rectangle( gc_pixmap, false, arrow_type == ARROW_LEFT ? X_START -10 : X_END +1, 5, 9, 40 ) ;
|
||||
pixmap ->draw_rectangle( gc_pixmap,
|
||||
false,
|
||||
arrow_type == ARROW_LEFT ? X_START - GRIPPER : X_END +1,
|
||||
5,
|
||||
9,
|
||||
40 ) ;
|
||||
|
||||
gc_pixmap ->set_foreground( color_arrow );
|
||||
pixmap ->draw_polygon( gc_pixmap, true, arrow_points );
|
||||
|
|
|
@ -21,36 +21,132 @@ Frame_Resizer_Extended::Frame_Resizer_Extended( )
|
|||
{
|
||||
}
|
||||
|
||||
void Frame_Resizer_Extended::set_used_start( int used_start )
|
||||
{
|
||||
if ( used_start <= 0 )
|
||||
USED_START = GRIPPER ;
|
||||
else
|
||||
USED_START = used_start + GRIPPER ;
|
||||
}
|
||||
|
||||
bool Frame_Resizer_Extended::drawingarea_on_mouse_motion( GdkEventMotion * ev )
|
||||
{
|
||||
if ( ! GRIP_LEFT && ! GRIP_RIGHT ) //no need to check this while resizing
|
||||
if ( GRIP_LEFT || GRIP_RIGHT )
|
||||
{
|
||||
//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 ) ;
|
||||
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 ) ;
|
||||
else //normal pointer
|
||||
drawingarea .get_parent_window( ) ->set_cursor( *cursor_normal ) ;
|
||||
}
|
||||
|
||||
else if ( GRIP_LEFT || GRIP_RIGHT )
|
||||
if ( GRIP_LEFT )
|
||||
{
|
||||
if ( GRIP_LEFT && ev ->x >= 10 && ev ->x <= 510 && ev->x <= X_END - BORDER *2 && ( ev ->x <= USED_START || USED == 0 ) )
|
||||
if ( ev ->x > GRIPPER &&
|
||||
ev->x < X_END - BORDER *2 &&
|
||||
( ev ->x < USED_START || USED == 0 ) )
|
||||
{
|
||||
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 )
|
||||
signal_resize .emit( X_START - GRIPPER, X_END - GRIPPER - BORDER * 2, ARROW_LEFT ) ;
|
||||
}
|
||||
else if ( ev ->x <= GRIPPER )
|
||||
{
|
||||
if ( X_START > GRIPPER )
|
||||
{
|
||||
X_START = GRIPPER ;
|
||||
|
||||
signal_resize .emit( X_START - GRIPPER,
|
||||
X_END - GRIPPER - BORDER * 2,
|
||||
ARROW_LEFT ) ;
|
||||
}
|
||||
}
|
||||
else if ( USED != 0 && ev ->x >= USED_START )
|
||||
{
|
||||
if ( X_START < USED_START )
|
||||
{
|
||||
X_START = USED_START ;
|
||||
|
||||
//+1 to force the spinbutton to its min.
|
||||
signal_resize .emit( X_START - GRIPPER +1,
|
||||
X_END - GRIPPER - BORDER * 2,
|
||||
ARROW_LEFT ) ;
|
||||
}
|
||||
}
|
||||
else if ( USED == 0 && ev ->x >= X_END - BORDER * 2 )
|
||||
{
|
||||
if ( X_START < X_END - BORDER * 2 )
|
||||
{
|
||||
X_START = X_END - BORDER * 2 ;
|
||||
|
||||
signal_resize .emit( X_START - GRIPPER,
|
||||
X_END - GRIPPER - BORDER * 2,
|
||||
ARROW_LEFT ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( GRIP_RIGHT )
|
||||
{
|
||||
if ( ev ->x < 500 + GRIPPER + BORDER * 2 &&
|
||||
ev ->x > X_START + BORDER *2 &&
|
||||
( ev ->x > USED_START + USED + BORDER *2 || USED == 0 ) )
|
||||
{
|
||||
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 )
|
||||
|
||||
signal_resize .emit( X_START - GRIPPER, X_END - GRIPPER - BORDER * 2, ARROW_RIGHT ) ;
|
||||
}
|
||||
else if ( ev ->x >= 500 + GRIPPER + BORDER * 2 )
|
||||
{
|
||||
if ( X_END < 500 + GRIPPER + BORDER * 2 )
|
||||
{
|
||||
X_END = 500 + GRIPPER + BORDER * 2 ;
|
||||
|
||||
signal_resize .emit( X_START - GRIPPER,
|
||||
X_END - GRIPPER - BORDER * 2,
|
||||
ARROW_RIGHT ) ;
|
||||
}
|
||||
}
|
||||
else if ( USED != 0 && ev ->x <= USED_START + USED + BORDER *2 )
|
||||
{
|
||||
if ( X_END > USED_START + USED + BORDER *2 )
|
||||
{
|
||||
X_END = USED_START + USED + BORDER *2 ;
|
||||
|
||||
//-1 to force the spinbutton to its min.
|
||||
signal_resize .emit( X_START - GRIPPER,
|
||||
X_END - GRIPPER - BORDER * 2 -1, ARROW_RIGHT ) ;
|
||||
}
|
||||
}
|
||||
else if ( USED == 0 && ev ->x <= X_START + BORDER *2 )
|
||||
{
|
||||
if ( X_END > X_START + BORDER *2 )
|
||||
{
|
||||
X_END = X_START + BORDER *2 ;
|
||||
|
||||
signal_resize .emit( X_START - GRIPPER,
|
||||
X_END - GRIPPER - BORDER * 2,
|
||||
ARROW_RIGHT ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Draw_Partition() ;
|
||||
}
|
||||
|
||||
//check if pointer is over a gripper
|
||||
else
|
||||
{
|
||||
//left grip
|
||||
if ( ! fixed_start &&
|
||||
ev ->x >= X_START - GRIPPER &&
|
||||
ev ->x <= X_START &&
|
||||
ev ->y >= 5 &&
|
||||
ev ->y <= 45 )
|
||||
drawingarea .get_parent_window() ->set_cursor( *cursor_resize ) ;
|
||||
//right grip
|
||||
else if ( ev ->x >= X_END &&
|
||||
ev ->x <= X_END + GRIPPER &&
|
||||
ev ->y >= 5 &&
|
||||
ev ->y <= 45 )
|
||||
drawingarea .get_parent_window() ->set_cursor( *cursor_resize ) ;
|
||||
//normal pointer
|
||||
else
|
||||
drawingarea .get_parent_window() ->set_cursor( *cursor_normal ) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
|
|
@ -689,9 +689,10 @@ void Win_GParted::set_valid_operations()
|
|||
->set_label( _("swapon") ) ;
|
||||
}
|
||||
|
||||
//only unmount is allowed
|
||||
if ( selected_partition .busy && selected_partition .type != GParted::TYPE_EXTENDED )
|
||||
//only unmount/swapoff is allowed (if ! extended)
|
||||
if ( selected_partition .busy )
|
||||
{
|
||||
if ( selected_partition .type != GParted::TYPE_EXTENDED )
|
||||
allow_unmount( true ) ;
|
||||
|
||||
return ;
|
||||
|
|
|
@ -159,7 +159,8 @@ bool ntfs::Check_Repair( const Partition & partition, std::vector<OperationDetai
|
|||
{
|
||||
operation_details .push_back( OperationDetails( _("check filesystem for errors and (if possible) fix them") ) ) ;
|
||||
|
||||
if ( ! execute_command( "ntfsresize -i -f -v " + partition .partition, operation_details .back() .sub_details ) )
|
||||
if ( ! execute_command( "ntfsresize -P -i -f -v " + partition .partition,
|
||||
operation_details .back() .sub_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
|
|
Loading…
Reference in New Issue