diff --git a/ChangeLog b/ChangeLog index e2755cec..874fcb7e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2006-02-17 Bart Hakvoort + + * 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 * include/Utils.h: added FIXME diff --git a/Makefile.am b/Makefile.am index d339055b..70076a81 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = include src po compose pixmaps +SUBDIRS = compose include pixmaps po src @INTLTOOL_DESKTOP_RULE@ diff --git a/include/GParted_Core.h b/include/GParted_Core.h index 91be41e1..6c95f315 100644 --- a/include/GParted_Core.h +++ b/include/GParted_Core.h @@ -76,10 +76,14 @@ private: void set_mountpoints( std::vector & partitions ) ; void set_short_paths( std::vector & partitions ) ; void set_used_sectors( std::vector & partitions ) ; - void insert_unallocated( const Glib::ustring & device_path, std::vector & partitions, Sector start, Sector end, bool inside_extended ) ; + void insert_unallocated( const Glib::ustring & device_path, + std::vector & 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 & operation_details, bool copy = false ) ; diff --git a/include/Partition.h b/include/Partition.h index e703e998..aa11eeb9 100644 --- a/include/Partition.h +++ b/include/Partition.h @@ -93,7 +93,7 @@ public: bool inside_extended; bool busy; Glib::ustring error; - Glib::ustring flags; + std::vector flags ; std::vector mountpoints ; std::vector logicals ; diff --git a/src/Dialog_Partition_Info.cc b/src/Dialog_Partition_Info.cc index 4cf47882..d6c8bca9 100644 --- a/src/Dialog_Partition_Info.cc +++ b/src/Dialog_Partition_Info.cc @@ -161,7 +161,10 @@ void Dialog_Partition_Info::Display_Info( ) if ( partition.type != GParted::TYPE_UNALLOCATED ) { table ->attach( * Utils::mk_label( "" + (Glib::ustring) _( "Flags:" ) + "" ), 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 diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc index 7b659175..bcb29f15 100644 --- a/src/GParted_Core.cc +++ b/src/GParted_Core.cc @@ -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 & partitions ) } } -void GParted_Core::insert_unallocated( const Glib::ustring & device_path, std::vector & partitions, Sector start, Sector end, bool inside_extended ) +void GParted_Core::insert_unallocated( const Glib::ustring & device_path, + std::vector & 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 & GParted_Core::get_filesystems( ) const +const std::vector & 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( 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 ) ) { diff --git a/src/Makefile.am b/src/Makefile.am index 02fe0679..88b5034b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,6 @@ INCLUDES = \ $(GTKMM_CFLAGS) \ - -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \ + -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \ -DGNOME_ICONDIR=\""$(datadir)/pixmaps"\" AM_CFLAGS = -Wall diff --git a/src/Partition.cc b/src/Partition.cc index 5dc80545..9c9212ec 100644 --- a/src/Partition.cc +++ b/src/Partition.cc @@ -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 ) diff --git a/src/TreeView_Detail.cc b/src/TreeView_Detail.cc index c5bf092d..8ac20c7b 100644 --- a/src/TreeView_Detail.cc +++ b/src/TreeView_Detail.cc @@ -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;