diff --git a/ChangeLog b/ChangeLog index f2fa422b..0434535e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,26 +1,30 @@ +2004-12-12 Bart Hakvoort + + * The fixes from 12-09 unearthed a number of long forgotten issues and annoyances. Hopefully they're all resolved now. + 2004-12-09 Bart Hakvoort * Fixed a bunch of issues with min. and max. sizes of filesystems. 2004-12-10 Gil Osher - * configure.in: Added 'he' (Hebrew) to ALL_LINGUAS. + * configure.in: Added 'he' (Hebrew) to ALL_LINGUAS. 2004-12-09 Bart Hakvoort - * src/fat16: use mkdosfs -F16 instead of libparted to create fat16 filesystems + * src/fat16: use mkdosfs -F16 instead of libparted to create fat16 filesystems 2004-12-09 Bart Hakvoort - * src/ext2.cc, - src/ext3.cc, - src/ntfs.cc, - src/reiserfs.cc: added LANG=C to the commands which read the used space of a filesystem. This prevent errors with some locales. + * src/ext2.cc, + src/ext3.cc, + src/ntfs.cc, + src/reiserfs.cc: added LANG=C to the commands which read the used space of a filesystem. This prevent errors with some locales. 2004-12-09 Bart Hakvoort - * added MIN and MAX to filesystemstruct to set min. and max sizes of a filesystem. So instead of checking per filesystem - i now simply check the fs.MIN or fs.MAX. this results in less and cleaner code. Also this will come in handy when adding + * added MIN and MAX to filesystemstruct to set min. and max sizes of a filesystem. So instead of checking per filesystem + i now simply check the fs.MIN or fs.MAX. this results in less and cleaner code. Also this will come in handy when adding support for new filesystems. (This also fixed several minor bugs with filesystemsizes and gained some improvement in resizer performance) @@ -36,9 +40,9 @@ * README: updated description to reflect current situation. -2004-12-07 Amanpreet Singh Alam +2004-12-07 Amanpreet Singh Alam - *configure.in: pa is aeed ALL_LINGUAS + * configure.in: pa is aeed ALL_LINGUAS 2004-12-03 Bart Hakvoort diff --git a/include/Dialog_Base_Partition.h b/include/Dialog_Base_Partition.h index 98976d5a..0f1f1d6e 100644 --- a/include/Dialog_Base_Partition.h +++ b/include/Dialog_Base_Partition.h @@ -80,7 +80,6 @@ protected: std::vector FILESYSTEMS ; bool fixed_start, GRIP ; double before_value ; - int x_start, x_end ; FS fs ; private: diff --git a/include/Frame_Resizer_Base.h b/include/Frame_Resizer_Base.h index de48df33..2a9ac65d 100644 --- a/include/Frame_Resizer_Base.h +++ b/include/Frame_Resizer_Base.h @@ -45,6 +45,7 @@ public: void set_used( int ); void set_fixed_start( bool ) ; void set_used_start( int used_start ) ; + void set_size_limits( int min_size, int max_size ) ; int get_used(); int get_x_start() ; @@ -58,7 +59,7 @@ public: sigc::signal signal_move; protected: - int X_START, USED, UNUSED, X_END, X_START_MOVE, USED_START; + int X_START, USED, UNUSED, X_END, X_START_MOVE, USED_START, MIN_SIZE, MAX_SIZE; bool GRIP_LEFT, GRIP_RIGHT, GRIP_MOVE ; //signal handlers diff --git a/src/Dialog_Base_Partition.cc b/src/Dialog_Base_Partition.cc index 1bf7c01d..963d0b48 100644 --- a/src/Dialog_Base_Partition.cc +++ b/src/Dialog_Base_Partition.cc @@ -30,13 +30,13 @@ Dialog_Base_Partition::Dialog_Base_Partition( ) this ->set_resizable( false ); //pack resizer hbox - this ->get_vbox() ->pack_start( hbox_resizer, Gtk::PACK_SHRINK ); + this ->get_vbox( ) ->pack_start( hbox_resizer, Gtk::PACK_SHRINK ); //add label_minmax - this ->get_vbox() ->pack_start( label_minmax, Gtk::PACK_SHRINK ); + this ->get_vbox( ) ->pack_start( label_minmax, Gtk::PACK_SHRINK ); //pack hbox_main - this ->get_vbox() ->pack_start( hbox_main, Gtk::PACK_SHRINK ); + this ->get_vbox( ) ->pack_start( hbox_main, Gtk::PACK_SHRINK ); //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); @@ -77,18 +77,18 @@ Dialog_Base_Partition::Dialog_Base_Partition( ) //connect signalhandlers of the spinbuttons if ( ! fixed_start ) - spinbutton_before .signal_value_changed().connect( sigc::bind( sigc::mem_fun( *this, &Dialog_Base_Partition::on_spinbutton_value_changed), BEFORE) ) ; + spinbutton_before .signal_value_changed( ) .connect( sigc::bind( sigc::mem_fun( *this, &Dialog_Base_Partition::on_spinbutton_value_changed), BEFORE) ) ; - spinbutton_size .signal_value_changed().connect( sigc::bind( sigc::mem_fun( *this, &Dialog_Base_Partition::on_spinbutton_value_changed), SIZE) ) ; - spinbutton_after .signal_value_changed().connect( sigc::bind( sigc::mem_fun( *this, &Dialog_Base_Partition::on_spinbutton_value_changed), AFTER) ) ; + spinbutton_size .signal_value_changed( ) .connect( sigc::bind( sigc::mem_fun( *this, &Dialog_Base_Partition::on_spinbutton_value_changed), SIZE) ) ; + spinbutton_after .signal_value_changed( ) .connect( sigc::bind( sigc::mem_fun( *this, &Dialog_Base_Partition::on_spinbutton_value_changed), AFTER) ) ; //pack warning about small differences in values.. - this ->get_vbox() ->pack_start( * mk_label( "\n " + (Glib::ustring) _( "NOTE: values on disk may differ slightly from the values entered here.") + "" ), Gtk::PACK_SHRINK ); + this ->get_vbox( ) ->pack_start( * mk_label( "\n " + (Glib::ustring) _( "NOTE: values on disk may differ slightly from the values entered here.") + "" ), Gtk::PACK_SHRINK ); - this ->get_vbox() ->pack_start( * mk_label( "" ), Gtk::PACK_SHRINK ); //filler :-P + this ->get_vbox( ) ->pack_start( * mk_label( "" ), Gtk::PACK_SHRINK ); //filler :-P this->add_button( Gtk::Stock::CANCEL,Gtk::RESPONSE_CANCEL ); - this ->show_all_children() ; + this ->show_all_children( ) ; } void Dialog_Base_Partition::Set_Resizer( bool extended ) @@ -111,7 +111,7 @@ void Dialog_Base_Partition::Set_Resizer( bool extended ) hbox_resizer .pack_start( *frame_resizer_base, Gtk::PACK_EXPAND_PADDING ); - this ->show_all_children() ; + this ->show_all_children( ) ; } Partition Dialog_Base_Partition::Get_New_Partition() @@ -188,57 +188,41 @@ void Dialog_Base_Partition::on_signal_move( int x_start, int x_end ) else spinbutton_after .set_value( TOTAL_MB - spinbutton_before .get_value() - spinbutton_size .get_value() ) ; - this ->x_start = x_start ; - this ->x_end = x_end ; - - Check_Change() ; + Check_Change( ) ; GRIP = false ; } -void Dialog_Base_Partition::on_signal_resize( int x_start, int x_end, Frame_Resizer_Base::ArrowType arrow) +void Dialog_Base_Partition::on_signal_resize( int x_start, int x_end, Frame_Resizer_Base::ArrowType arrow ) { GRIP = true ; - - if ( ( x_end - x_start ) * MB_PER_PIXEL < fs .MIN || ( fs .MAX && ( x_end - x_start ) * MB_PER_PIXEL > fs .MAX ) ) - { - frame_resizer_base ->set_x_start( this ->x_start ); - frame_resizer_base ->set_x_end( this ->x_end ); - - frame_resizer_base ->Draw_Partition( ) ; - GRIP = false ; - return ; - } - + spinbutton_size .set_value( ( x_end - x_start ) * MB_PER_PIXEL ) ; - fixed_start ? before_value = 0 : before_value = spinbutton_before .get_value() ; + fixed_start ? before_value = 0 : before_value = spinbutton_before .get_value( ) ; if ( arrow == Frame_Resizer_Base::ARROW_RIGHT ) //don't touch freespace before, leave it as it is { if ( x_end == 500 ) { - spinbutton_after .set_value(0 ) ; + spinbutton_after .set_value( 0 ) ; spinbutton_size .set_value( TOTAL_MB - before_value ) ; } else - spinbutton_after .set_value( TOTAL_MB - before_value - spinbutton_size .get_value() ) ; + spinbutton_after .set_value( TOTAL_MB - before_value - spinbutton_size .get_value( ) ) ; } else if ( arrow == Frame_Resizer_Base::ARROW_LEFT ) //don't touch freespace after, leave it as it is { if ( x_start == 0 ) { spinbutton_before .set_value( 0 ); - spinbutton_size .set_value( TOTAL_MB - spinbutton_after.get_value() ) ; + 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( ) ) ; } - this ->x_start = x_start ; - this ->x_end = x_end ; - - Check_Change() ; + Check_Change( ) ; GRIP = false ; } @@ -247,24 +231,24 @@ void Dialog_Base_Partition::on_spinbutton_value_changed( SPINBUTTON spinbutton ) { if ( ! GRIP ) { - fixed_start ? before_value = 0 : before_value = spinbutton_before .get_value() ; + fixed_start ? before_value = 0 : before_value = spinbutton_before .get_value( ) ; //Balance the spinbuttons switch ( spinbutton ) { - 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( ) ) ; + 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( ) ) ; break; - case SIZE : spinbutton_after.set_value( TOTAL_MB - before_value - spinbutton_size.get_value() ); + 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( ) ) ; + spinbutton_size .set_value( TOTAL_MB - before_value - spinbutton_after .get_value( ) ) ; break; } @@ -272,16 +256,13 @@ 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( (int) ( spinbutton_before .get_value( ) / MB_PER_PIXEL + 0.5 ) ) ; - frame_resizer_base ->set_x_end( (int) ( 500 - ( (double) spinbutton_after .get_value() / MB_PER_PIXEL ) + 0.5 ) ) ; + frame_resizer_base ->set_x_end( (int) ( 500 - ( (double) spinbutton_after .get_value( ) / MB_PER_PIXEL ) + 0.5 ) ) ; - this ->x_start = frame_resizer_base ->get_x_start() ; - this ->x_end = frame_resizer_base ->get_x_end() ; + frame_resizer_base ->Draw_Partition( ) ; - frame_resizer_base ->Draw_Partition() ; - - Check_Change() ; + Check_Change( ) ; } } diff --git a/src/Dialog_Partition_Copy.cc b/src/Dialog_Partition_Copy.cc index 4bc1158f..1ecd610d 100644 --- a/src/Dialog_Partition_Copy.cc +++ b/src/Dialog_Partition_Copy.cc @@ -50,24 +50,25 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons frame_resizer_base ->set_x_end( ( Round( (double) (copied_partition .sector_end - copied_partition .sector_start) / ( (double)total_length/500) )) ) ; frame_resizer_base ->set_used( frame_resizer_base ->get_x_end( ) ) ; - //used to store current positions (see Dialog_Base_Partition::on_signal_resize) - this ->x_start = frame_resizer_base ->get_x_start( ) ; - this ->x_end = frame_resizer_base ->get_x_end( ) ; + if ( ! fs .MAX ) + fs .MAX = TOTAL_MB ; //set values of spinbutton_before spinbutton_before .set_range( 0, TOTAL_MB - copied_partition .Get_Length_MB( ) -1 ) ;//mind the -1 !! spinbutton_before .set_value( 0 ) ; //set values of spinbutton_size - spinbutton_size .set_range( copied_partition .Get_Length_MB( ) +1, fs .MAX ? fs .MAX : TOTAL_MB ) ; + spinbutton_size .set_range( copied_partition .Get_Length_MB( ) +1, fs .MAX ) ; spinbutton_size .set_value( copied_partition .Get_Length_MB( ) ) ; //set values of spinbutton_after spinbutton_after .set_range( 0, TOTAL_MB - copied_partition .Get_Length_MB( ) -1 ) ; spinbutton_after .set_value( TOTAL_MB - copied_partition .Get_Length_MB( ) ) ; + frame_resizer_base ->set_size_limits( (int) (fs .MIN / MB_PER_PIXEL), (int) (fs .MAX / MB_PER_PIXEL) +1 ) ; + //set contents of label_minmax - Set_MinMax_Text( copied_partition .Get_Length_MB( ) +1, fs .MAX ? fs .MAX : TOTAL_MB ) ; + Set_MinMax_Text( copied_partition .Get_Length_MB( ) +1, fs .MAX ) ; //set global selected_partition (see Dialog_Base_Partition::Get_New_Partition ) this ->selected_partition = copied_partition ; diff --git a/src/Dialog_Partition_New.cc b/src/Dialog_Partition_New.cc index acc8994d..8866afbe 100644 --- a/src/Dialog_Partition_New.cc +++ b/src/Dialog_Partition_New.cc @@ -27,13 +27,7 @@ Dialog_Partition_New::Dialog_Partition_New( ) Set_Resizer( false ) ; Set_Confirm_Button( NEW ) ; - //set partition color - color_temp .set( Get_Color( "ext2" ) ) ; - frame_resizer_base ->set_rgb_partition_color( color_temp ) ; - - //set the resizer.. - frame_resizer_base ->set_x_start( 0 ) ; - frame_resizer_base ->set_x_end( 500 ) ; + //set used (in pixels)... frame_resizer_base ->set_used( 0 ) ; } @@ -46,49 +40,49 @@ void Dialog_Partition_New::Set_Data( const Partition & partition, bool any_exten this ->FILESYSTEMS .back( ) .filesystem = _("Unformatted") ; this ->FILESYSTEMS .back( ) .create = true ; - FS fs ; fs.filesystem = "extended" ; - this ->FILESYSTEMS .push_back( fs ) ; + FS fs_tmp ; fs_tmp .filesystem = "extended" ; + this ->FILESYSTEMS .push_back( fs_tmp ) ; - //add table with selection menu;s... + //add table with selection menu's... table_create .set_border_width( 10 ) ; - table_create.set_row_spacings( 5 ) ; + table_create .set_row_spacings( 5 ) ; hbox_main .pack_start( table_create, Gtk::PACK_SHRINK ); /*TO TRANSLATORS: used as label for a list of choices. Create as: */ table_create.attach( * mk_label( (Glib::ustring) _("Create as:") + "\t" ), 0, 1, 0, 1, Gtk::FILL); //fill partitiontype menu - menu_type.items().push_back(Gtk::Menu_Helpers::MenuElem( _("Primary Partition") ) ) ; - menu_type.items().push_back(Gtk::Menu_Helpers::MenuElem( _("Logical Partition") ) ) ; - menu_type.items().push_back(Gtk::Menu_Helpers::MenuElem( _("Extended Partition") ) ) ; + menu_type .items( ) .push_back( Gtk::Menu_Helpers::MenuElem( _("Primary Partition") ) ) ; + menu_type .items( ) .push_back( Gtk::Menu_Helpers::MenuElem( _("Logical Partition") ) ) ; + menu_type .items( ) .push_back( Gtk::Menu_Helpers::MenuElem( _("Extended Partition") ) ) ; //determine which PartitionType is allowed - if ( partition.inside_extended ) + if ( partition .inside_extended ) { - menu_type.items()[0] .set_sensitive( false ); - menu_type.items()[2] .set_sensitive( false ); - menu_type.set_active( 1 ); + menu_type .items( )[ 0 ] .set_sensitive( false ); + menu_type .items( )[ 2 ] .set_sensitive( false ); + menu_type .set_active( 1 ); } else { - menu_type.items()[1] .set_sensitive( false ); + menu_type .items( )[ 1 ] .set_sensitive( false ); if ( any_extended ) - menu_type.items()[2] .set_sensitive( false ); + menu_type .items( )[ 2 ] .set_sensitive( false ); } - optionmenu_type.set_menu( menu_type ); - optionmenu_type.set_size_request( 160, -1 ); //160 is the ideal width for this table column, (when one widget is set, the rest wil take this width as well) - optionmenu_type.signal_changed().connect( sigc::bind(sigc::mem_fun(*this, &Dialog_Partition_New::optionmenu_changed), true) ); - table_create.attach( optionmenu_type, 1,2,0,1,Gtk::FILL); + optionmenu_type .set_menu( menu_type ); + optionmenu_type .set_size_request( 160, -1 ); //160 is the ideal width for this table column, (when one widget is set, the rest wil take this width as well) + optionmenu_type .signal_changed( ) .connect( sigc::bind( sigc::mem_fun( *this, &Dialog_Partition_New::optionmenu_changed ), true ) ); + table_create .attach( optionmenu_type, 1, 2, 0, 1, Gtk::FILL ); //filesystems to choose from - table_create.attach( * mk_label( (Glib::ustring) _("Filesystem:") + "\t" ), 0,1,1,2,Gtk::FILL); + table_create.attach( * mk_label( (Glib::ustring) _("Filesystem:") + "\t" ), 0, 1, 1, 2, Gtk::FILL ); Build_Filesystems_Menu( only_unformatted ) ; optionmenu_filesystem .set_menu( menu_filesystem ); - optionmenu_filesystem .signal_changed().connect( sigc::bind(sigc::mem_fun(*this, &Dialog_Partition_New::optionmenu_changed), false) ); - table_create.attach( optionmenu_filesystem, 1,2,1,2,Gtk::FILL); + optionmenu_filesystem .signal_changed( ) .connect( sigc::bind( sigc::mem_fun( *this, &Dialog_Partition_New::optionmenu_changed ), false ) ); + table_create .attach( optionmenu_filesystem, 1, 2, 1, 2, Gtk::FILL ); //set some widely used values... START = partition.sector_start ; @@ -96,26 +90,17 @@ void Dialog_Partition_New::Set_Data( const Partition & partition, bool any_exten TOTAL_MB = this ->selected_partition .Get_Length_MB() ; MB_PER_PIXEL = (double) TOTAL_MB / 500 ; - //set spinbuttons initial values( seems a bit redundant ) - GRIP = true ; //prevents on spinbutton_changed from getting activated prematurely - - spinbutton_before .set_range( 0, TOTAL_MB -1 ) ; - spinbutton_before .set_value( 0 ) ; - - spinbutton_size .set_range( 1, TOTAL_MB ) ; - spinbutton_size .set_value( TOTAL_MB ) ; - - spinbutton_after .set_range( 0, TOTAL_MB -1 ) ; - spinbutton_after .set_value( 0 ) ; - - GRIP = false ; - //set first enabled filesystem optionmenu_filesystem .set_history( first_creatable_fs ) ; optionmenu_changed( false ) ; + //set spinbuttons initial values + spinbutton_after .set_value( 0 ) ; + spinbutton_size .set_value( fs .MAX ) ; + spinbutton_before .set_value( 0 ) ; + //euhrm, this wil only happen when there's a very small free space (usually the effect of a bad partitionmanager) - if ( selected_partition .Get_Length_MB( ) < cylinder_size ) + if ( TOTAL_MB < cylinder_size ) frame_resizer_base ->set_sensitive( false ) ; this ->show_all_children( ) ; @@ -198,9 +183,8 @@ void Dialog_Partition_New::optionmenu_changed( bool type ) fs .MAX = ( fs .MAX && ( fs .MAX - cylinder_size ) < TOTAL_MB ) ? fs .MAX - cylinder_size : TOTAL_MB ; - //needed vor upper limit check (see also Dialog_Base_Partition::on_signal_resize ) - selected_partition .filesystem = fs .filesystem ; - + frame_resizer_base ->set_size_limits( (int) (fs .MIN / MB_PER_PIXEL), (int) (fs .MAX / MB_PER_PIXEL) +1 ) ; + //set new spinbutton ranges spinbutton_before .set_range( 0, TOTAL_MB - fs .MIN ) ; spinbutton_size .set_range( fs .MIN, fs .MAX ) ; diff --git a/src/Dialog_Partition_Resize_Move.cc b/src/Dialog_Partition_Resize_Move.cc index 7626d7fe..cbd68a38 100644 --- a/src/Dialog_Partition_Resize_Move.cc +++ b/src/Dialog_Partition_Resize_Move.cc @@ -51,10 +51,6 @@ void Dialog_Partition_Resize_Move::Set_Data( const Partition & selected_partitio //set partition color frame_resizer_base ->set_rgb_partition_color( selected_partition .color ) ; - //set some initial values... ( i believe i only use these for fat16 checks.. *sigh* ) - this ->x_start = frame_resizer_base ->get_x_start( ) ; - this ->x_end = frame_resizer_base ->get_x_end( ) ; - //store the original values ORIG_BEFORE = spinbutton_before .get_value_as_int( ) ; ORIG_SIZE = spinbutton_size .get_value_as_int( ) ; @@ -116,33 +112,41 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector set_used( Round( (double) selected_partition.sectors_used / ( (double)total_length/500) ) ) ; //since some filesystems have upper and lower limits we need to check for this - long LOWER = ( selected_partition .Get_Used_MB( ) < fs .MIN ) ? fs .MIN : selected_partition .Get_Used_MB( ) ; - - LOWER += BUF ; + if ( selected_partition .Get_Used_MB( ) > fs .MIN ) + fs .MIN = selected_partition .Get_Used_MB( ) ; - //in certain (rare) cases LOWER is a bit too high... - if ( LOWER > selected_partition .Get_Length_MB( ) ) - LOWER = selected_partition .Get_Length_MB( ) ; + //if fs. MIN is 0 here (means used == 0 as well) it's safe to have BUF / 2 + fs .MIN += fs .MIN ? BUF : BUF/2 ; + + //in certain (rare) cases fs .MIN is a bit too high... + if ( fs .MIN > selected_partition .Get_Length_MB( ) ) + fs .MIN = selected_partition .Get_Length_MB( ) ; + + if ( ! fs .MAX ) + fs .MAX = TOTAL_MB ; + + if ( fs .MAX > TOTAL_MB ) + fs .MAX = TOTAL_MB ; - long UPPER = fs .MAX ? fs .MAX : Sector_To_MB( total_length ) ; - //set values of spinbutton_before if ( ! fixed_start ) { - spinbutton_before .set_range( 0, Sector_To_MB( total_length ) - LOWER ) ; + spinbutton_before .set_range( 0, TOTAL_MB - fs .MIN ) ; spinbutton_before .set_value( Sector_To_MB( previous ) ) ; } //set values of spinbutton_size - spinbutton_size .set_range( LOWER, UPPER ) ; + spinbutton_size .set_range( fs .MIN, fs .MAX ) ; spinbutton_size .set_value( selected_partition .Get_Length_MB( ) ) ; //set values of spinbutton_after - spinbutton_after .set_range( 0, Sector_To_MB( total_length ) - LOWER ) ; + 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 ) ; + //set contents of label_minmax - Set_MinMax_Text( LOWER, UPPER ) ; + Set_MinMax_Text( fs .MIN, fs .MAX ) ; } @@ -195,7 +199,7 @@ void Dialog_Partition_Resize_Move::Resize_Move_Extended( const std::vector fixed_start = false ; - init() ; + init( ) ; } void Frame_Resizer_Base::init() { - drawingarea.set_size_request( 536, 50 ); + drawingarea .set_size_request( 536, 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 ) ; - color_used.set( "#F8F8BA" ); this ->get_colormap() ->alloc_color( color_used ) ; - color_unused.set( "white" ); this ->get_colormap() ->alloc_color( color_unused ) ; - color_arrow.set( "black" ); this ->get_colormap() ->alloc_color( color_arrow ) ; - color_background.set( "darkgrey" ); this ->get_colormap() ->alloc_color( color_background ) ; - color_arrow_rectangle.set( "lightgrey" ); this ->get_colormap() ->alloc_color( color_arrow_rectangle ) ; + color_used .set( "#F8F8BA" ); this ->get_colormap( ) ->alloc_color( color_used ) ; + color_unused .set( "white" ); this ->get_colormap( ) ->alloc_color( color_unused ) ; + color_arrow .set( "black" ); this ->get_colormap( ) ->alloc_color( color_arrow ) ; + color_background .set( "darkgrey" ); this ->get_colormap( ) ->alloc_color( color_background ) ; + color_arrow_rectangle .set( "lightgrey" ); this ->get_colormap( ) ->alloc_color( color_arrow_rectangle ) ; cursor_resize = new Gdk::Cursor( Gdk::SB_H_DOUBLE_ARROW ) ; cursor_normal = new Gdk::Cursor( Gdk::LEFT_PTR ) ; @@ -48,13 +48,14 @@ void Frame_Resizer_Base::init() GRIP_MOVE = GRIP_LEFT = GRIP_RIGHT = false; X_END = 0; - - Gdk::Point p; - p.set_y( 15); arrow_points.push_back( p ) ; - p.set_y( 25); arrow_points.push_back( p ) ; - p.set_y( 35); arrow_points.push_back( p ) ; + set_size_limits( 0, 500 ) ; - this ->show_all_children(); + Gdk::Point p; + p .set_y( 15 ); arrow_points .push_back( p ) ; + p .set_y( 25 ); arrow_points .push_back( p ) ; + p .set_y( 35 ); arrow_points .push_back( p ) ; + + this ->show_all_children( ); } @@ -100,6 +101,12 @@ void Frame_Resizer_Base::set_used_start( int used_start ) 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 ; +} + int Frame_Resizer_Base::get_used() { return USED ; @@ -152,13 +159,13 @@ bool Frame_Resizer_Base::drawingarea_on_mouse_motion( GdkEventMotion *ev ) //here's where the real work is done ;-) if ( GRIP_LEFT || GRIP_RIGHT || GRIP_MOVE) { - if ( GRIP_LEFT && ev ->x >= 10 && ev ->x <= X_END - USED - BORDER * 2 ) + 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 ; 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 >= X_START + USED + BORDER *2 && ev ->x <= 526 ) + 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 ; 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 ) diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc index cfa2d857..f0a3e968 100644 --- a/src/GParted_Core.cc +++ b/src/GParted_Core.cc @@ -172,7 +172,7 @@ void GParted_Core::set_device_partitions( Device & device, bool deep_scan ) { Set_Used_Sectors( partition_temp ) ; - //the 'Unknow' filesystem warning overrules this one + //the 'Unknown' filesystem warning overrules this one if ( partition_temp .sectors_used == -1 && partition_temp .error .empty( ) ) { partition_temp .error = _("Unable to read the contents of this filesystem!") ;