Display partition table types in order (#711098)
In the Create Partition Table dialog display the entries in the combobox in order. Previously the default of MSDOS or GPT was moved to the first item in the combobox. Now the partition table types remain in order with just either MSDOS or GPT being selected as as the default as required. The partition table types are displayed in the order supplied by libparted, which is alphabetic except with "loop" last. Bug #711098 - Default partition table can not handle > 2 TiB disks
This commit is contained in:
parent
07bd72ba80
commit
7b43d52720
|
@ -20,6 +20,7 @@
|
|||
#define GPARTED_DIALOG_DISKLABEL_H
|
||||
|
||||
#include "../include/Utils.h"
|
||||
#include "../include/Device.h"
|
||||
|
||||
#include <gtkmm/dialog.h>
|
||||
#include <gtkmm/button.h>
|
||||
|
@ -33,8 +34,8 @@ namespace GParted
|
|||
class Dialog_Disklabel : public Gtk::Dialog
|
||||
{
|
||||
public:
|
||||
Dialog_Disklabel( const Glib::ustring & device_path, const std::vector<Glib::ustring> & disklabeltypes ) ;
|
||||
|
||||
Dialog_Disklabel( const Device & device ) ;
|
||||
|
||||
Glib::ustring Get_Disklabel( ) ;
|
||||
|
||||
private:
|
||||
|
|
|
@ -56,7 +56,7 @@ public:
|
|||
|
||||
const std::vector<FS> & get_filesystems() const ;
|
||||
const FS & get_fs( GParted::FILESYSTEM filesystem ) const ;
|
||||
std::vector<Glib::ustring> get_disklabeltypes( Device *device ) ;
|
||||
static std::vector<Glib::ustring> get_disklabeltypes() ;
|
||||
std::vector<Glib::ustring> get_all_mountpoints() ;
|
||||
std::map<Glib::ustring, bool> get_available_flags( const Partition & partition ) ;
|
||||
Glib::ustring get_libparted_version() ;
|
||||
|
|
|
@ -17,13 +17,16 @@
|
|||
*/
|
||||
|
||||
#include "../include/Dialog_Disklabel.h"
|
||||
#include "../include/GParted_Core.h"
|
||||
|
||||
namespace GParted
|
||||
{
|
||||
|
||||
Dialog_Disklabel::Dialog_Disklabel( const Glib::ustring & device_path, const std::vector<Glib::ustring> & disklabeltypes )
|
||||
Dialog_Disklabel::Dialog_Disklabel( const Device & device )
|
||||
: image(Gtk::Stock::DIALOG_WARNING, Gtk::ICON_SIZE_DIALOG)
|
||||
{
|
||||
const Glib::ustring device_path = device .get_path() ;
|
||||
|
||||
/*TO TRANSLATORS: dialogtitle, looks like Create partition table on /dev/hda */
|
||||
this ->set_title( String::ucompose( _("Create partition table on %1"), device_path ) );
|
||||
this ->set_has_separator( false ) ;
|
||||
|
@ -61,13 +64,33 @@ Dialog_Disklabel::Dialog_Disklabel( const Glib::ustring & device_path, const std
|
|||
vbox->pack_start(*hbox, Gtk::PACK_SHRINK);
|
||||
}
|
||||
|
||||
//Default to MSDOS partition table type for disks < 2^32 sectors
|
||||
// (2 TiB with 512 byte sectors) and GPT for larger disks.
|
||||
Glib::ustring default_label ;
|
||||
if ( device .length < 4LL * GIBIBYTE )
|
||||
default_label = "msdos" ;
|
||||
else
|
||||
default_label = "gpt" ;
|
||||
|
||||
//create and add combo with partition table types (label types)
|
||||
this ->labeltypes = disklabeltypes ;
|
||||
this ->labeltypes = GParted_Core::get_disklabeltypes() ;
|
||||
|
||||
for (unsigned int t = 0; t < labeltypes.size(); ++t)
|
||||
combo_labeltypes.append_text(labeltypes[t]);
|
||||
bool set_active = false ;
|
||||
for ( unsigned int t = 0 ; t < labeltypes .size() ; t ++ )
|
||||
{
|
||||
combo_labeltypes .append_text( labeltypes[ t ] ) ;
|
||||
if ( default_label == labeltypes[ t ] )
|
||||
{
|
||||
combo_labeltypes .set_active( t ) ;
|
||||
set_active = true ;
|
||||
}
|
||||
}
|
||||
//Should be impossible for libparted to not known about MSDOS and GPT
|
||||
// partition table types, but just in case fallback to activating the
|
||||
// first item in the combobox.
|
||||
if ( ! set_active && labeltypes .size() )
|
||||
combo_labeltypes .set_active( 0 ) ;
|
||||
|
||||
combo_labeltypes.set_active(0);
|
||||
hbox->pack_start(combo_labeltypes, Gtk::PACK_SHRINK);
|
||||
}
|
||||
|
||||
|
|
|
@ -824,23 +824,16 @@ const FS & GParted_Core::get_fs( GParted::FILESYSTEM filesystem ) const
|
|||
return FILESYSTEMS[ unknown ] ;
|
||||
}
|
||||
|
||||
std::vector<Glib::ustring> GParted_Core::get_disklabeltypes( Device *device )
|
||||
//Return all libparted's partition table types in it's preferred ordering,
|
||||
// alphabetic except with "loop" last.
|
||||
// Ref: parted >= 1.8 ./libparted/libparted.c init_disk_types()
|
||||
std::vector<Glib::ustring> GParted_Core::get_disklabeltypes()
|
||||
{
|
||||
std::vector<Glib::ustring> disklabeltypes ;
|
||||
const char *default_label ;
|
||||
|
||||
//Default to MSDOS partition table type for disks < 2^32 sectors
|
||||
// (2 TiB with 512 byte sectors) and GPT for larger disks.
|
||||
if ( device ->length < 4LL * GIBIBYTE )
|
||||
default_label = "msdos";
|
||||
else
|
||||
default_label = "gpt";
|
||||
disklabeltypes.push_back( default_label ) ;
|
||||
|
||||
PedDiskType *disk_type ;
|
||||
for ( disk_type = ped_disk_type_get_next( NULL ) ; disk_type ; disk_type = ped_disk_type_get_next( disk_type ) )
|
||||
if ( Glib::ustring( disk_type->name ) != default_label )
|
||||
disklabeltypes .push_back( disk_type->name ) ;
|
||||
|
||||
PedDiskType *disk_type ;
|
||||
for ( disk_type = ped_disk_type_get_next( NULL ) ; disk_type ; disk_type = ped_disk_type_get_next( disk_type ) )
|
||||
disklabeltypes .push_back( disk_type->name ) ;
|
||||
|
||||
return disklabeltypes ;
|
||||
}
|
||||
|
|
|
@ -2333,7 +2333,7 @@ void Win_GParted::activate_disklabel()
|
|||
}
|
||||
|
||||
//Display dialog for creating a new partition table.
|
||||
Dialog_Disklabel dialog( devices[ current_device ] .get_path(), gparted_core .get_disklabeltypes( &devices[ current_device ] ) ) ;
|
||||
Dialog_Disklabel dialog( devices[ current_device ] ) ;
|
||||
dialog .set_transient_for( *this );
|
||||
|
||||
if ( dialog .run() == Gtk::RESPONSE_APPLY )
|
||||
|
|
Loading…
Reference in New Issue