From a764f10df7b477f9f7de3d221bd15fb49474b627 Mon Sep 17 00:00:00 2001 From: Bart Hakvoort Date: Thu, 9 Feb 2006 17:02:40 +0000 Subject: [PATCH] it shouldn't be possible to remove an extended partition which contains * include/Win_GParted.h, src/Win_GParted.cc: it shouldn't be possible to remove an extended partition which contains logicals. * src/TreeView_Detail.cc: only show mountpoint column when there is mountinfo. --- ChangeLog | 8 ++++++++ include/Win_GParted.h | 2 +- src/TreeView_Detail.cc | 9 +++++++++ src/Win_GParted.cc | 31 +++++++++++++++++++------------ 4 files changed, 37 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7c44000b..c40863e7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-02-09 Bart Hakvoort + + * include/Win_GParted.h, + src/Win_GParted.cc: it shouldn't be possible to remove an extended + partition which contains logicals. + * src/TreeView_Detail.cc: only show mountpoint column when there is + mountinfo. + 2006-02-08 Bart Hakvoort * include/Win_GParted.h, diff --git a/include/Win_GParted.h b/include/Win_GParted.h index ff513bd0..86417362 100644 --- a/include/Win_GParted.h +++ b/include/Win_GParted.h @@ -219,7 +219,7 @@ private: treeview_operations_Columns treeview_operations_columns; //usefull variables which are used by many different functions... - bool any_logic,any_extended;//used in some checks + bool any_extended;//used in some checks unsigned short primary_count ;//primary_count checks for max. of 4 pimary partitions unsigned short new_count;//new_count keeps track of the new created partitions Glib::ustring str_temp ; //mostly used for constructing dialogmessages diff --git a/src/TreeView_Detail.cc b/src/TreeView_Detail.cc index 7adecfda..926d9329 100644 --- a/src/TreeView_Detail.cc +++ b/src/TreeView_Detail.cc @@ -75,6 +75,7 @@ TreeView_Detail::TreeView_Detail( ) void TreeView_Detail::load_partitions( const std::vector & partitions ) { + bool mount_info = false ; treestore_detail ->clear() ; for ( unsigned int i = 0 ; i < partitions .size() ; i++ ) @@ -88,9 +89,17 @@ void TreeView_Detail::load_partitions( const std::vector & partitions { childrow = *( treestore_detail ->append( row.children() ) ); create_row( childrow, partitions[ i ] .logicals[ t ] ); + + if ( ! partitions[ i ] .logicals[ t ] .mountpoint .empty() ) + mount_info = true ; } } + + if ( ! partitions[ i ] .mountpoint .empty() ) + mount_info = true ; } + + get_column( 2 ) ->set_visible( mount_info ) ; //show logical partitions ( if any ) expand_all(); diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc index a87f12e8..84cce987 100644 --- a/src/Win_GParted.cc +++ b/src/Win_GParted.cc @@ -605,8 +605,8 @@ void Win_GParted::Refresh_Visual( ) allow_apply( false ); } - //count primary's, check for extended and logic and see if any logical is busy - any_logic = any_extended = false; + //count primary's and check for extended + any_extended = false; primary_count = 0; for ( unsigned int t = 0 ; t < partitions .size() ; t++ ) { @@ -622,7 +622,6 @@ void Win_GParted::Refresh_Visual( ) case GParted::TYPE_EXTENDED : any_extended = true; primary_count++; - any_logic = partitions[ t ] .logicals .size() -1 ; break; default : @@ -724,7 +723,9 @@ 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. + //deletion is only allowed when there are no logical partitions inside. + if ( selected_partition .logicals .size() == 1 && + selected_partition .logicals .back() .type == GParted::TYPE_UNALLOCATED ) allow_delete( true ) ; if ( ! devices[ current_device ] .readonly ) @@ -1024,7 +1025,7 @@ void Win_GParted::menu_help_about( ) void Win_GParted::on_partition_selected( const Partition & partition, bool src_is_treeview ) { selected_partition = partition; - + set_valid_operations() ; if ( src_is_treeview ) @@ -1159,24 +1160,30 @@ void Win_GParted::activate_paste( ) } } -void Win_GParted::activate_new( ) +void Win_GParted::activate_new() { //if max_prims == -1 the current device has an unrecognised disklabel (see also GParted_Core::get_devices) if ( devices [ current_device ] .max_prims == -1 ) - activate_disklabel( ) ; + activate_disklabel() ; - else if ( ! max_amount_prim_reached( ) ) + else if ( ! max_amount_prim_reached() ) { Dialog_Partition_New dialog; - dialog .Set_Data( selected_partition, any_extended, new_count, gparted_core .get_filesystems( ), devices[ current_device ] .readonly, devices[ current_device ] .cylsize ) ; + dialog .Set_Data( selected_partition, + any_extended, + new_count, + gparted_core .get_filesystems(), + devices[ current_device ] .readonly, + devices[ current_device ] .cylsize ) ; + dialog .set_transient_for( *this ); - if ( dialog .run( ) == Gtk::RESPONSE_OK ) + if ( dialog .run() == Gtk::RESPONSE_OK ) { - dialog .hide( ) ;//make sure the dialog is gone _before_ operationslist shows up (only matters if first operation) + dialog .hide() ;//make sure the dialog is gone _before_ operationslist shows up (only matters if first operation) new_count++ ; - Add_Operation( GParted::CREATE, dialog .Get_New_Partition( ) ); + Add_Operation( GParted::CREATE, dialog .Get_New_Partition() ); } } }