[gparted] Localise checking for an extended partition into activate_new()



commit 26dc3dffa741fb3b8fc21620b6439bbaf7e16b67
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Thu Sep 10 18:24:49 2015 +0100

    Localise checking for an extended partition into activate_new()
    
    As previous commit, display_partitions is now a Win_GParted member
    variable so checking for the existence of an extended partition can be
    localised where it is used.
    
    Remove index_extended member variable and localise the same checking in
    activate_new().

 include/Win_GParted.h |    1 -
 src/Win_GParted.cc    |   22 +++++++++++++++-------
 2 files changed, 15 insertions(+), 8 deletions(-)
---
diff --git a/include/Win_GParted.h b/include/Win_GParted.h
index ddeb6b3..8c2cbc8 100644
--- a/include/Win_GParted.h
+++ b/include/Win_GParted.h
@@ -255,7 +255,6 @@ private:
         TOOLBAR_APPLY ;
 
        //usefull variables which are used by many different functions...
-       int index_extended ; //position of the extended partition (-1 means there isn't one)
        unsigned short new_count;//new_count keeps track of the new created partitions
        FS fs ;
        bool OPERATIONSLIST_OPEN ;
diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc
index d60de13..6dffde7 100644
--- a/src/Win_GParted.cc
+++ b/src/Win_GParted.cc
@@ -929,10 +929,8 @@ void Win_GParted::Refresh_Visual()
        if ( ! operations .size() ) 
                allow_undo_clear_apply( false ) ;
 
-       // Check for an extended partition, refresh copy partition source as necessary and
-       // select the largest unallocated partition if there is one.
-       index_extended = -1 ;
-
+       // Refresh copy partition source as necessary and select the largest unallocated
+       // partition if there is one.
        selected_partition_ptr = NULL;
        Sector largest_unalloc_size = -1 ;
        Sector current_size ;
@@ -945,8 +943,6 @@ void Win_GParted::Refresh_Visual()
                switch ( display_partitions[t].type )
                {
                        case TYPE_EXTENDED:
-                               index_extended = t ;
-
                                for ( unsigned int u = 0 ; u < display_partitions[t].logicals.size() ; u ++ )
                                {
                                        if ( display_partitions[t].logicals[u].get_path() == 
copied_partition.get_path() )
@@ -1953,9 +1949,21 @@ void Win_GParted::activate_new()
        }
        else if ( ! max_amount_prim_reached() )
        {
+               // Check if an extended partition already exist; so that the dialog can
+               // decide whether to allow the creation of the only extended partition
+               // type or not.
+               bool any_extended = false;
+               for ( unsigned int i = 0 ; i < display_partitions.size() ; i ++ )
+               {
+                       if ( display_partitions[i].type == TYPE_EXTENDED )
+                       {
+                               any_extended = true;
+                               break;
+                       }
+               }
                Dialog_Partition_New dialog( devices[current_device],
                                             *selected_partition_ptr,
-                                            index_extended > -1,
+                                            any_extended,
                                             new_count,
                                             gparted_core.get_filesystems() );
                dialog .set_transient_for( *this );


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]