store flags in a list instead of a string. cleanups
* include/GParted_Core.h, include/Partition.h, src/Dialog_Partition_Info.cc, src/GParted_Core.cc, src/Partition.cc, src/TreeView_Detail.cc: store flags in a list instead of a string. * Makefile.am, src/Makefile.am: cleanups
This commit is contained in:
parent
f6b01f342f
commit
c2eb2f7cad
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2006-02-17 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||
|
||||
* include/GParted_Core.h,
|
||||
include/Partition.h,
|
||||
src/Dialog_Partition_Info.cc,
|
||||
src/GParted_Core.cc,
|
||||
src/Partition.cc,
|
||||
src/TreeView_Detail.cc: store flags in a list instead of a string.
|
||||
* Makefile.am,
|
||||
src/Makefile.am: cleanups
|
||||
|
||||
2006-02-17 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||
|
||||
* include/Utils.h: added FIXME
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
SUBDIRS = include src po compose pixmaps
|
||||
SUBDIRS = compose include pixmaps po src
|
||||
|
||||
@INTLTOOL_DESKTOP_RULE@
|
||||
|
||||
|
|
|
@ -76,10 +76,14 @@ private:
|
|||
void set_mountpoints( std::vector<Partition> & partitions ) ;
|
||||
void set_short_paths( std::vector<Partition> & partitions ) ;
|
||||
void set_used_sectors( std::vector<Partition> & partitions ) ;
|
||||
void insert_unallocated( const Glib::ustring & device_path, std::vector<Partition> & partitions, Sector start, Sector end, bool inside_extended ) ;
|
||||
void insert_unallocated( const Glib::ustring & device_path,
|
||||
std::vector<Partition> & partitions,
|
||||
Sector start,
|
||||
Sector end,
|
||||
bool inside_extended ) ;
|
||||
Glib::ustring get_short_path( const Glib::ustring & real_path ) ;
|
||||
void LP_Set_Used_Sectors( Partition & partition );
|
||||
Glib::ustring Get_Flags( ) ;
|
||||
void set_flags( Partition & partition ) ;
|
||||
int create_empty_partition( Partition & new_partition,
|
||||
std::vector<OperationDetails> & operation_details,
|
||||
bool copy = false ) ;
|
||||
|
|
|
@ -93,7 +93,7 @@ public:
|
|||
bool inside_extended;
|
||||
bool busy;
|
||||
Glib::ustring error;
|
||||
Glib::ustring flags;
|
||||
std::vector<Glib::ustring> flags ;
|
||||
std::vector<Glib::ustring> mountpoints ;
|
||||
|
||||
std::vector<Partition> logicals ;
|
||||
|
|
|
@ -161,7 +161,10 @@ void Dialog_Partition_Info::Display_Info( )
|
|||
if ( partition.type != GParted::TYPE_UNALLOCATED )
|
||||
{
|
||||
table ->attach( * Utils::mk_label( "<b>" + (Glib::ustring) _( "Flags:" ) + "</b>" ), 0, 1, top, bottom, Gtk::FILL ) ;
|
||||
table ->attach( * Utils::mk_label( partition .flags ), 1, 2, top++, bottom++, Gtk::FILL ) ;
|
||||
table ->attach( * Utils::mk_label( Glib::build_path( ", ", partition .flags ) ),
|
||||
1, 2,
|
||||
top++, bottom++,
|
||||
Gtk::FILL ) ;
|
||||
}
|
||||
|
||||
//one blank line
|
||||
|
|
|
@ -321,7 +321,8 @@ void GParted_Core::set_device_partitions( Device & device )
|
|||
lp_partition ->type,
|
||||
ped_partition_is_busy( lp_partition ) );
|
||||
|
||||
partition_temp .flags = Get_Flags() ;
|
||||
set_flags( partition_temp ) ;
|
||||
|
||||
if ( partition_temp .busy && partition_temp .partition_number > device .highest_busy )
|
||||
device .highest_busy = partition_temp .partition_number ;
|
||||
|
||||
|
@ -338,7 +339,7 @@ void GParted_Core::set_device_partitions( Device & device )
|
|||
false,
|
||||
ped_partition_is_busy( lp_partition ) );
|
||||
|
||||
partition_temp .flags = Get_Flags() ;
|
||||
set_flags( partition_temp ) ;
|
||||
EXT_INDEX = device .partitions .size() ;
|
||||
break ;
|
||||
|
||||
|
@ -463,13 +464,17 @@ void GParted_Core::set_used_sectors( std::vector<Partition> & partitions )
|
|||
}
|
||||
}
|
||||
|
||||
void GParted_Core::insert_unallocated( const Glib::ustring & device_path, std::vector<Partition> & partitions, Sector start, Sector end, bool inside_extended )
|
||||
void GParted_Core::insert_unallocated( const Glib::ustring & device_path,
|
||||
std::vector<Partition> & partitions,
|
||||
Sector start,
|
||||
Sector end,
|
||||
bool inside_extended )
|
||||
{
|
||||
partition_temp .Reset( ) ;
|
||||
partition_temp .Reset() ;
|
||||
partition_temp .Set_Unallocated( device_path, 0, 0, inside_extended ) ;
|
||||
|
||||
//if there are no partitions at all..
|
||||
if ( partitions .empty( ) )
|
||||
if ( partitions .empty() )
|
||||
{
|
||||
partition_temp .sector_start = start ;
|
||||
partition_temp .sector_end = end ;
|
||||
|
@ -582,9 +587,11 @@ bool GParted_Core::Delete( const Partition & partition, std::vector<OperationDet
|
|||
if ( partition .type == GParted::TYPE_EXTENDED )
|
||||
lp_partition = ped_disk_extended_partition( lp_disk ) ;
|
||||
else
|
||||
lp_partition = ped_disk_get_partition_by_sector( lp_disk, (partition .sector_end + partition .sector_start) / 2 ) ;
|
||||
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() ;
|
||||
|
@ -667,22 +674,22 @@ bool GParted_Core::Set_Disklabel( const Glib::ustring & device_path, const Glib:
|
|||
if ( open_device_and_disk( device_path, false ) )
|
||||
{
|
||||
PedDiskType *type = NULL ;
|
||||
type = ped_disk_type_get( disklabel .c_str( ) ) ;
|
||||
type = ped_disk_type_get( disklabel .c_str() ) ;
|
||||
|
||||
if ( type )
|
||||
{
|
||||
lp_disk = ped_disk_new_fresh ( lp_device, type);
|
||||
lp_disk = ped_disk_new_fresh( lp_device, type );
|
||||
|
||||
return_value = commit( ) ;
|
||||
return_value = commit() ;
|
||||
}
|
||||
|
||||
close_device_and_disk( ) ;
|
||||
close_device_and_disk() ;
|
||||
}
|
||||
|
||||
return return_value ;
|
||||
}
|
||||
|
||||
const std::vector<FS> & GParted_Core::get_filesystems( ) const
|
||||
const std::vector<FS> & GParted_Core::get_filesystems() const
|
||||
{
|
||||
return FILESYSTEMS ;
|
||||
}
|
||||
|
@ -718,7 +725,9 @@ void GParted_Core::LP_Set_Used_Sectors( Partition & partition )
|
|||
|
||||
if ( lp_disk )
|
||||
{
|
||||
lp_partition = ped_disk_get_partition_by_sector( lp_disk, (partition .sector_end + partition .sector_start) / 2 ) ;
|
||||
lp_partition = ped_disk_get_partition_by_sector(
|
||||
lp_disk,
|
||||
(partition .sector_end + partition .sector_start) / 2 ) ;
|
||||
|
||||
if ( lp_partition )
|
||||
{
|
||||
|
@ -729,7 +738,8 @@ void GParted_Core::LP_Set_Used_Sectors( Partition & partition )
|
|||
constraint = ped_file_system_get_resize_constraint( fs ) ;
|
||||
if ( constraint )
|
||||
{
|
||||
partition .Set_Unused( (partition .sector_end - partition .sector_start) - constraint ->min_size ) ;
|
||||
partition .Set_Unused(
|
||||
(partition .sector_end - partition .sector_start) - constraint ->min_size ) ;
|
||||
|
||||
ped_constraint_destroy( constraint );
|
||||
}
|
||||
|
@ -771,12 +781,18 @@ int GParted_Core::create_empty_partition( Partition & new_partition,
|
|||
type = PED_PARTITION_FREESPACE;
|
||||
}
|
||||
|
||||
lp_partition = ped_partition_new( lp_disk, type, NULL, new_partition .sector_start, new_partition .sector_end ) ;
|
||||
lp_partition = ped_partition_new( lp_disk,
|
||||
type,
|
||||
NULL,
|
||||
new_partition .sector_start,
|
||||
new_partition .sector_end ) ;
|
||||
if ( lp_partition )
|
||||
{
|
||||
if ( new_partition .strict )
|
||||
{
|
||||
PedGeometry *geom = ped_geometry_new( lp_device, new_partition .sector_start, new_partition .get_length() ) ;
|
||||
PedGeometry *geom = ped_geometry_new( lp_device,
|
||||
new_partition .sector_start,
|
||||
new_partition .get_length() ) ;
|
||||
|
||||
if ( geom )
|
||||
constraint = ped_constraint_exact( geom ) ;
|
||||
|
@ -862,8 +878,9 @@ bool GParted_Core::resize_container_partition( const Partition & partition_old,
|
|||
if ( partition_old .type == GParted::TYPE_EXTENDED )
|
||||
lp_partition = ped_disk_extended_partition( lp_disk ) ;
|
||||
else
|
||||
lp_partition = ped_disk_get_partition_by_sector( lp_disk,
|
||||
(partition_old .sector_end + partition_old .sector_start) / 2 ) ;
|
||||
lp_partition = ped_disk_get_partition_by_sector(
|
||||
lp_disk,
|
||||
(partition_old .sector_end + partition_old .sector_start) / 2 ) ;
|
||||
|
||||
if ( lp_partition )
|
||||
{
|
||||
|
@ -871,7 +888,7 @@ bool GParted_Core::resize_container_partition( const Partition & partition_old,
|
|||
|
||||
if ( fixed_start && constraint )
|
||||
{
|
||||
//create a constraint which keeps de startpoint intact and rounds the end to a cylinderboundary
|
||||
//create a constraint which keeps de startpoint intact and rounds the end to a cylinder
|
||||
ped_disk_set_partition_geom( lp_disk,
|
||||
lp_partition,
|
||||
constraint,
|
||||
|
@ -945,7 +962,9 @@ bool GParted_Core::resize_normal_using_libparted( const Partition & partition_ol
|
|||
|
||||
if ( open_device_and_disk( partition_old .device_path ) )
|
||||
{
|
||||
lp_partition = ped_disk_get_partition_by_sector( lp_disk, (partition_old .sector_end + partition_old .sector_start) / 2 ) ;
|
||||
lp_partition = ped_disk_get_partition_by_sector(
|
||||
lp_disk,
|
||||
(partition_old .sector_end + partition_old .sector_start) / 2 ) ;
|
||||
if ( lp_partition )
|
||||
{
|
||||
fs = ped_file_system_open( & lp_partition ->geom );
|
||||
|
@ -978,15 +997,11 @@ bool GParted_Core::resize_normal_using_libparted( const Partition & partition_ol
|
|||
return return_value ;
|
||||
}
|
||||
|
||||
Glib::ustring GParted_Core::Get_Flags()
|
||||
{//FIXME: this is ugly, i guess we'd better use a vector in partition to store the flags..
|
||||
temp = "";
|
||||
|
||||
for ( unsigned short t = 0; t < flags .size( ) ; t++ )
|
||||
if ( ped_partition_get_flag ( lp_partition, flags[ t ] ) )
|
||||
temp += static_cast<Glib::ustring>( ped_partition_flag_get_name( flags[ t ] ) ) + " ";
|
||||
|
||||
return temp ;
|
||||
void GParted_Core::set_flags( Partition & partition )
|
||||
{
|
||||
for ( unsigned int t = 0 ; t < flags .size() ; t++ )
|
||||
if ( ped_partition_get_flag( lp_partition, flags[ t ] ) )
|
||||
partition .flags .push_back( ped_partition_flag_get_name( flags[ t ] ) ) ;
|
||||
}
|
||||
|
||||
void GParted_Core::set_proper_filesystem( const FILESYSTEM & filesystem )
|
||||
|
@ -1022,7 +1037,8 @@ bool GParted_Core::set_partition_type( const Partition & partition,
|
|||
|
||||
if ( open_device_and_disk( partition .device_path ) )
|
||||
{
|
||||
PedFileSystemType * fs_type = ped_file_system_type_get( Utils::Get_Filesystem_String( partition .filesystem ) .c_str() ) ;
|
||||
PedFileSystemType * fs_type =
|
||||
ped_file_system_type_get( Utils::Get_Filesystem_String( partition .filesystem ) .c_str() ) ;
|
||||
|
||||
//default is Linux (83)
|
||||
if ( ! fs_type )
|
||||
|
@ -1030,7 +1046,9 @@ bool GParted_Core::set_partition_type( const Partition & partition,
|
|||
|
||||
if ( fs_type )
|
||||
{
|
||||
lp_partition = ped_disk_get_partition_by_sector( lp_disk, (partition .sector_end + partition .sector_start) / 2 ) ;
|
||||
lp_partition = ped_disk_get_partition_by_sector(
|
||||
lp_disk,
|
||||
(partition .sector_end + partition .sector_start) / 2 ) ;
|
||||
|
||||
if ( lp_partition && ped_partition_set_system( lp_partition, fs_type ) && commit() )
|
||||
return_value = wait_for_node( partition .partition ) ;
|
||||
|
@ -1066,7 +1084,9 @@ bool GParted_Core::erase_filesystem_signatures( const Partition & partition )
|
|||
|
||||
if ( open_device_and_disk( partition .device_path ) )
|
||||
{
|
||||
lp_partition = ped_disk_get_partition_by_sector( lp_disk, (partition .sector_end + partition .sector_start) / 2 ) ;
|
||||
lp_partition = ped_disk_get_partition_by_sector(
|
||||
lp_disk,
|
||||
(partition .sector_end + partition .sector_start) / 2 ) ;
|
||||
|
||||
if ( lp_partition && ped_file_system_clobber( & lp_partition ->geom ) )
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
INCLUDES = \
|
||||
$(GTKMM_CFLAGS) \
|
||||
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
|
||||
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
|
||||
-DGNOME_ICONDIR=\""$(datadir)/pixmaps"\"
|
||||
|
||||
AM_CFLAGS = -Wall
|
||||
|
|
|
@ -27,7 +27,7 @@ Partition::Partition()
|
|||
|
||||
void Partition::Reset()
|
||||
{
|
||||
partition = realpath = error = flags = "" ;
|
||||
partition = realpath = error = "" ;
|
||||
status = GParted::STAT_REAL ;
|
||||
type = GParted::TYPE_UNALLOCATED ;
|
||||
filesystem = GParted::FS_UNALLOCATED ;
|
||||
|
@ -35,6 +35,7 @@ void Partition::Reset()
|
|||
color .set( "black" ) ;
|
||||
inside_extended = busy = strict = false ;
|
||||
logicals .clear() ;
|
||||
flags .clear() ;
|
||||
mountpoints .clear() ;
|
||||
}
|
||||
|
||||
|
@ -72,18 +73,19 @@ void Partition::Set_Unused( Sector sectors_unused )
|
|||
|
||||
void Partition::Set_Unallocated( const Glib::ustring & device_path, Sector sector_start, Sector sector_end, bool inside_extended )
|
||||
{
|
||||
this ->Set( device_path,
|
||||
Utils::Get_Filesystem_String( GParted::FS_UNALLOCATED ),
|
||||
-1,
|
||||
GParted::TYPE_UNALLOCATED,
|
||||
GParted::FS_UNALLOCATED,
|
||||
sector_start,
|
||||
sector_end,
|
||||
inside_extended,
|
||||
false );
|
||||
Reset() ;
|
||||
|
||||
Set( device_path,
|
||||
Utils::Get_Filesystem_String( GParted::FS_UNALLOCATED ),
|
||||
-1,
|
||||
GParted::TYPE_UNALLOCATED,
|
||||
GParted::FS_UNALLOCATED,
|
||||
sector_start,
|
||||
sector_end,
|
||||
inside_extended,
|
||||
false );
|
||||
|
||||
this ->error = this ->flags = "" ;
|
||||
this ->status = GParted::STAT_REAL ;
|
||||
status = GParted::STAT_REAL ;
|
||||
}
|
||||
|
||||
void Partition::Update_Number( int new_number )
|
||||
|
|
|
@ -176,7 +176,8 @@ void TreeView_Detail::create_row( const Gtk::TreeRow & treerow, const Partition
|
|||
partition .sectors_unused == -1 ? "---" : Utils::format_size( partition .sectors_unused ) ;
|
||||
|
||||
//flags
|
||||
treerow[ treeview_detail_columns .flags ] = " " + partition .flags ;
|
||||
treerow[ treeview_detail_columns .flags ] =
|
||||
Glib::build_path( ", ", partition .flags ) ;
|
||||
|
||||
//hidden column (partition object)
|
||||
treerow[ treeview_detail_columns .partition_struct ] = partition;
|
||||
|
|
Loading…
Reference in New Issue