From 1e6ad5884af795391af31975f8572935f40555b1 Mon Sep 17 00:00:00 2001 From: Bart Hakvoort Date: Sat, 7 Jan 2006 21:23:09 +0000 Subject: [PATCH] removed separator in accordance to the HIG it's now possible to deactivate * src/Dialog_Partition_Info.cc: removed separator in accordance to the HIG * include/Win_GParted.h, src/Win_GParted.cc: it's now possible to deactivate swap from within gparted. * src/GParted_Core.cc: sleep one second after deletion of a partition to give the kernel some time to reread the partitiontable. --- ChangeLog | 10 ++++++ include/Win_GParted.h | 26 ++++++++------- src/Dialog_Partition_Info.cc | 3 +- src/GParted_Core.cc | 5 +-- src/Win_GParted.cc | 64 +++++++++++++++++++++++++++--------- 5 files changed, 78 insertions(+), 30 deletions(-) diff --git a/ChangeLog b/ChangeLog index c6be3668..d321bb39 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2006-01-07 Bart Hakvoort + + * src/Dialog_Partition_Info.cc: removed separator in accordance to the + HIG + * include/Win_GParted.h, + src/Win_GParted.cc: it's now possible to deactivate swap from within + gparted. + * src/GParted_Core.cc: sleep one second after deletion of a partition to + give the kernel some time to reread the partitiontable. + 2006-01-07 Bart Hakvoort * src/Utils.cc: commented 'ss .imbue( std::locale( "" ) )' (#157871) diff --git a/include/Win_GParted.h b/include/Win_GParted.h index f4bb3a28..dec1c4a2 100644 --- a/include/Win_GParted.h +++ b/include/Win_GParted.h @@ -102,8 +102,11 @@ private: void allow_unmount( bool b ) { menu_partition .items( )[ 10 ] .set_sensitive( b ); } + void allow_disable_swap( bool b ) { + menu_partition .items( )[ 11 ] .set_sensitive( b ); } + void allow_info( bool b ) { - menu_partition .items( )[ 12 ] .set_sensitive( b ); } + menu_partition .items( )[ 13 ] .set_sensitive( b ); } void allow_undo( bool b ) { toolbar_main .get_nth_item( 8 ) ->set_sensitive( b ); @@ -116,7 +119,7 @@ private: void find_devices_thread( ) { gparted_core .get_devices( devices ) ; pulse = false ; } - + //signal handlers void open_operationslist( ) ; void close_operationslist( ) ; @@ -137,15 +140,16 @@ private: bool max_amount_prim_reached( ) ; - void activate_resize( ); - void activate_copy( ); - void activate_paste( ); - void activate_new( ); - void activate_delete( ); - void activate_info( ); + void activate_resize(); + void activate_copy(); + void activate_paste(); + void activate_new(); + void activate_delete(); + void activate_info(); void activate_format( GParted::FILESYSTEM new_fs ); - void activate_unmount( ) ; - void activate_disklabel( ) ; + void activate_unmount() ; + void activate_disable_swap() ; + void activate_disklabel() ; void activate_undo( ); void activate_apply( ); @@ -175,7 +179,7 @@ private: Gtk::Button *button; Gtk::Table *table ; Gtk::MenuItem *menu_item; - Gtk::ProgressBar *pulsebar ; + Gtk::ProgressBar pulsebar ; Gtk::TreeRow treerow; VBox_VisualDisk vbox_visual_disk; diff --git a/src/Dialog_Partition_Info.cc b/src/Dialog_Partition_Info.cc index f07b1c2d..841b8d1d 100644 --- a/src/Dialog_Partition_Info.cc +++ b/src/Dialog_Partition_Info.cc @@ -24,7 +24,8 @@ Dialog_Partition_Info::Dialog_Partition_Info( const Partition & partition ) { this ->partition = partition ; - this ->set_resizable( false ); + this ->set_resizable( false ) ; + this ->set_has_separator( false ) ; /*TO TRANSLATORS: dialogtitle, looks like Information about /dev/hda3 */ this ->set_title( String::ucompose( _( "Information about %1"), partition .partition ) ); diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc index e08f9878..1b91a7fe 100644 --- a/src/GParted_Core.cc +++ b/src/GParted_Core.cc @@ -570,9 +570,10 @@ bool GParted_Core::Delete( const Partition & partition ) else lp_partition = ped_disk_get_partition_by_sector( lp_disk, (partition .sector_end + partition .sector_start) / 2 ) ; - return_value = ( ped_disk_delete_partition( lp_disk, lp_partition ) && commit( ) ) ; + return_value = ( ped_disk_delete_partition( lp_disk, lp_partition ) && commit() ) ; + sleep( 1 ) ; //give the kernel some time to reread the partitiontable - close_device_and_disk( ) ; + close_device_and_disk() ; } return return_value ; diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc index 69649efb..d702b3b6 100644 --- a/src/Win_GParted.cc +++ b/src/Win_GParted.cc @@ -19,6 +19,9 @@ #include +#include +#include + namespace GParted { @@ -75,9 +78,8 @@ Win_GParted::Win_GParted( ) vpaned_main .pack2( hbox_operations, true, true ) ; //statusbar... - pulsebar = manage( new Gtk::ProgressBar( ) ); - pulsebar ->set_pulse_step( 0.01 ); - statusbar .add( *pulsebar ); + pulsebar .set_pulse_step( 0.01 ); + statusbar .add( pulsebar ); vbox_main .pack_start( statusbar, Gtk::PACK_SHRINK ); this ->show_all_children( ); @@ -87,7 +89,7 @@ Win_GParted::Win_GParted( ) close_operationslist( ) ; conn = dispatcher .connect( sigc::mem_fun( *this, &Win_GParted::menu_gparted_refresh_devices ) ); - dispatcher( ) ; + dispatcher() ; } void Win_GParted::init_menubar( ) @@ -227,6 +229,10 @@ void Win_GParted::init_partition_menu( ) Gtk::Menu_Helpers::MenuElem( _("Unmount"), sigc::mem_fun( *this, &Win_GParted::activate_unmount ) ) ); + menu_partition .items() .push_back( + Gtk::Menu_Helpers::MenuElem( _("Deactivate"), + sigc::mem_fun( *this, &Win_GParted::activate_disable_swap ) ) ); + menu_partition .items() .push_back( Gtk::Menu_Helpers::SeparatorElem() ); menu_partition .items() .push_back( @@ -422,7 +428,7 @@ void Win_GParted::refresh_combo_devices() void Win_GParted::Show_Pulsebar( ) { - pulsebar ->show(); + pulsebar .show(); statusbar .push( _("Scanning all devices...") ) ; //disable all input stuff @@ -436,7 +442,7 @@ void Win_GParted::Show_Pulsebar( ) //the actual 'pulsing' while ( pulse ) { - pulsebar ->pulse(); + pulsebar .pulse(); while ( Gtk::Main::events_pending() ) Gtk::Main::iteration(); @@ -446,7 +452,7 @@ void Win_GParted::Show_Pulsebar( ) thread ->join() ; conn .disconnect() ; - pulsebar ->hide(); + pulsebar .hide(); statusbar .pop() ; //enable all disabled stuff @@ -622,9 +628,10 @@ void Win_GParted::Set_Valid_Operations( ) { allow_new( false ); allow_delete( false ); allow_resize( false ); allow_copy( false ); allow_paste( false ); allow_format( false ); allow_unmount( false ) ; allow_info( false ) ; + allow_disable_swap( false ) ; //no partition selected... - if ( selected_partition .partition .empty( ) ) + if ( selected_partition .partition .empty() ) return ; //if there's something, there's some info ;) @@ -633,8 +640,13 @@ void Win_GParted::Set_Valid_Operations( ) //only unmount is allowed if ( selected_partition .busy ) { - if ( selected_partition .filesystem != GParted::FS_LINUX_SWAP && selected_partition .type != GParted::TYPE_EXTENDED ) - allow_unmount( true ) ; + if ( selected_partition .type != GParted::TYPE_EXTENDED ) + { + if ( selected_partition .filesystem == GParted::FS_LINUX_SWAP ) + allow_disable_swap( true ) ; + else + allow_unmount( true ) ; + } return; } @@ -645,10 +657,10 @@ void Win_GParted::Set_Valid_Operations( ) allow_new( true ); //find out if there is a copied partition and if it fits inside this unallocated space - if ( ! copied_partition .partition .empty( ) && ! devices[ current_device ] .readonly ) + if ( ! copied_partition .partition .empty() && ! devices[ current_device ] .readonly ) { - if ( (copied_partition .Get_Length_MB( ) + devices[ current_device ] .cylsize) < selected_partition .Get_Length_MB( ) || - (copied_partition .filesystem == GParted::FS_XFS && (copied_partition .Get_Used_MB( ) + devices[ current_device ] .cylsize) < selected_partition .Get_Length_MB( ) ) + if ( (copied_partition .Get_Length_MB() + devices[ current_device ] .cylsize) < selected_partition .Get_Length_MB() || + (copied_partition .filesystem == GParted::FS_XFS && (copied_partition .Get_Used_MB() + devices[ current_device ] .cylsize) < selected_partition .Get_Length_MB() ) ) allow_paste( true ) ; } @@ -659,7 +671,7 @@ void Win_GParted::Set_Valid_Operations( ) //EXTENDED if ( selected_partition .type == GParted::TYPE_EXTENDED ) { - if ( ! any_logic ) //deletion is only allowed when there are no logical partitions inside. + if ( ! any_logic ) //deletion is only allowed when there are no logical partitions inside. allow_delete( true ) ; if ( ! devices[ current_device ] .readonly ) @@ -1253,8 +1265,28 @@ void Win_GParted::activate_unmount( ) Gtk::MessageDialog dialog( *this, str_temp + error, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true ); dialog.run( ) ; } - else - menu_gparted_refresh_devices( ) ; + + menu_gparted_refresh_devices() ; +} + +void Win_GParted::activate_disable_swap() +{ + if ( swapoff( selected_partition .partition .c_str() ) ) + { + str_temp = "" ; + str_temp += _("Could not deactivate swap") ; + str_temp += "\n\n" ; + + Gtk::MessageDialog dialog( *this, + str_temp + Glib::strerror( errno ), + true, + Gtk::MESSAGE_ERROR, + Gtk::BUTTONS_OK, + true ); + dialog.run() ; + } + + menu_gparted_refresh_devices() ; } void Win_GParted::activate_disklabel( )