added FIXME cleanups (mostly messagebox related) added some more

* include/Utils.h: added FIXME
* include/Win_GParted.h,
  src/Win_GParted.cc: cleanups (mostly messagebox related)
* src/GParted_Core.cc: added some more progressfeedback to create and
  resize
This commit is contained in:
Bart Hakvoort 2006-02-17 21:18:07 +00:00
parent 99a87a8c09
commit f6b01f342f
9 changed files with 253 additions and 179 deletions

View File

@ -1,3 +1,11 @@
2006-02-17 Bart Hakvoort <hakvoort@cvs.gnome.org>
* include/Utils.h: added FIXME
* include/Win_GParted.h,
src/Win_GParted.cc: cleanups (mostly messagebox related)
* src/GParted_Core.cc: added some more progressfeedback to create and
resize
2006-02-16 Bart Hakvoort <hakvoort@cvs.gnome.org>
* configure.in: bumped to gparted-0.2.1

View File

@ -96,6 +96,8 @@ struct FS
Support move ; //startpoint and endpoint
Support check ; //some checktool available?
Support copy ;
//FIXME: these 2 should hold 'Sectors' instead if MiB's
int MIN ;
int MAX ;

View File

@ -221,7 +221,6 @@ private:
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
FS fs ;
GParted_Core gparted_core ;

View File

@ -14,3 +14,4 @@ notexist
po2tbl.sed
po2tbl.sed.in
stamp-cat-id
stamp-it

View File

@ -1,3 +1,7 @@
2006-02-17 Bart Hakvoort <hakvoort@cvs.gnome.org>
* .cvsignore: silence CVS
2006-02-16 Bart Hakvoort <hakvoort@cvs.gnome.org>
* bumped to gparted-0.2.1

View File

@ -53,15 +53,15 @@ void GParted_Core::find_supported_filesystems( )
linux_swap fs_linux_swap;
FILESYSTEMS .push_back( fs_linux_swap .get_filesystem_support( ) ) ;
ntfs fs_ntfs;
FILESYSTEMS .push_back( fs_ntfs .get_filesystem_support( ) ) ;
reiser4 fs_reiser4;
FILESYSTEMS .push_back( fs_reiser4 .get_filesystem_support( ) ) ;
reiserfs fs_reiserfs;
FILESYSTEMS .push_back( fs_reiserfs .get_filesystem_support( ) ) ;
ntfs fs_ntfs;
FILESYSTEMS .push_back( fs_ntfs .get_filesystem_support( ) ) ;
xfs fs_xfs;
FILESYSTEMS .push_back( fs_xfs .get_filesystem_support( ) ) ;
@ -751,7 +751,7 @@ int GParted_Core::create_empty_partition( Partition & new_partition,
if ( open_device_and_disk( new_partition .device_path ) )
{
PedPartitionType type;
PedPartition *c_part = NULL ;
lp_partition = NULL ;
PedConstraint *constraint = NULL ;
//create new partition
@ -771,8 +771,8 @@ int GParted_Core::create_empty_partition( Partition & new_partition,
type = PED_PARTITION_FREESPACE;
}
c_part = ped_partition_new( lp_disk, type, NULL, new_partition .sector_start, new_partition .sector_end ) ;
if ( c_part )
lp_partition = ped_partition_new( lp_disk, type, NULL, new_partition .sector_start, new_partition .sector_end ) ;
if ( lp_partition )
{
if ( new_partition .strict )
{
@ -789,10 +789,23 @@ int GParted_Core::create_empty_partition( Partition & new_partition,
if ( copy )
constraint ->min_size = new_partition .get_length() ;
if ( ped_disk_add_partition( lp_disk, c_part, constraint ) && commit() )
if ( ped_disk_add_partition( lp_disk, lp_partition, constraint ) && commit() )
{
new_partition .partition = ped_partition_get_path( c_part ) ;
new_partition .partition_number = c_part ->num ;
new_partition .partition = ped_partition_get_path( lp_partition ) ;
new_partition .partition_number = lp_partition ->num ;
Sector start = lp_partition ->geom .start ;
Sector end = lp_partition ->geom .end ;
operation_details .back() .sub_details .push_back(
OperationDetails(
"<i>" +
String::ucompose( _("path: %1"), new_partition .partition ) + "\n" +
String::ucompose( _("start: %1"), start ) + "\n" +
String::ucompose( _("end: %1"), end ) + "\n" +
String::ucompose( _("size: %1"), Utils::format_size( end - start + 1 ) ) +
"</i>",
OperationDetails::NONE ) ) ;
}
ped_constraint_destroy( constraint );
@ -830,6 +843,15 @@ bool GParted_Core::resize_container_partition( const Partition & partition_old,
{
operation_details .push_back( OperationDetails( _("resize partition") ) ) ;
operation_details .back() .sub_details .push_back(
OperationDetails(
"<i>" +
String::ucompose( _("old start: %1"), partition_old .sector_start ) + "\n" +
String::ucompose( _("old end: %1"), partition_old .sector_end ) + "\n" +
String::ucompose( _("old size: %1"), Utils::format_size( partition_old .get_length() ) ) +
"</i>",
OperationDetails::NONE ) ) ;
bool return_value = false ;
PedConstraint *constraint = NULL ;
@ -840,15 +862,21 @@ 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 )
{
constraint = ped_constraint_any( lp_device );
if ( fixed_start && constraint ) //create a constraint which keeps de startpoint intact and rounds the end to a cylinderboundary
if ( fixed_start && constraint )
{
ped_disk_set_partition_geom( lp_disk, lp_partition, constraint, partition_new .sector_start, partition_new .sector_end ) ;
//create a constraint which keeps de startpoint intact and rounds the end to a cylinderboundary
ped_disk_set_partition_geom( lp_disk,
lp_partition,
constraint,
partition_new .sector_start,
partition_new .sector_end ) ;
ped_constraint_destroy( constraint );
constraint = NULL ;
@ -858,7 +886,11 @@ bool GParted_Core::resize_container_partition( const Partition & partition_old,
if ( constraint )
{
if ( ped_disk_set_partition_geom( lp_disk, lp_partition, constraint, partition_new .sector_start, partition_new .sector_end ) )
if ( ped_disk_set_partition_geom( lp_disk,
lp_partition,
constraint,
partition_new .sector_start,
partition_new .sector_end ) )
return_value = commit() ;
ped_constraint_destroy( constraint );
@ -868,6 +900,23 @@ bool GParted_Core::resize_container_partition( const Partition & partition_old,
close_device_and_disk() ;
}
if ( return_value )
{
//use start/end vars since lp_partition ->geom loses his values after a functioncall :/
//this is actually quite weird, but i don't have time to investigate it more thorough.
Sector start = lp_partition ->geom .start ;
Sector end = lp_partition ->geom .end ;
operation_details .back() .sub_details .push_back(
OperationDetails(
"<i>" +
String::ucompose( _("new start: %1"), start ) + "\n" +
String::ucompose( _("new end: %1"), end ) + "\n" +
String::ucompose( _("new size: %1"), Utils::format_size( end - start + 1 ) ) +
"</i>",
OperationDetails::NONE ) ) ;
}
if ( partition_old .type == GParted::TYPE_EXTENDED )
{
operation_details .back() .status = return_value ? OperationDetails::SUCCES : OperationDetails::ERROR ;
@ -905,7 +954,12 @@ bool GParted_Core::resize_normal_using_libparted( const Partition & partition_ol
constraint = ped_file_system_get_resize_constraint( fs );
if ( constraint )
{
if ( ped_disk_set_partition_geom ( lp_disk, lp_partition, constraint, partition_new .sector_start, partition_new .sector_end ) &&
if ( ped_disk_set_partition_geom( lp_disk,
lp_partition,
constraint,
partition_new .sector_start,
partition_new .sector_end )
&&
ped_file_system_resize( fs, & lp_partition ->geom, NULL )
)
return_value = commit() ;
@ -925,7 +979,7 @@ bool GParted_Core::resize_normal_using_libparted( const Partition & partition_ol
}
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++ )
@ -959,7 +1013,6 @@ void GParted_Core::set_proper_filesystem( const FILESYSTEM & filesystem )
}
}
bool GParted_Core::set_partition_type( const Partition & partition,
std::vector<OperationDetails> & operation_details )
{

View File

@ -653,11 +653,9 @@ bool Win_GParted::Quit_Check_Operations( )
true );
if ( operations .size() != 1 )
str_temp = String::ucompose( _("%1 operations are currently pending."), operations .size() ) ;
dialog .set_secondary_text( String::ucompose( _("%1 operations are currently pending."), operations .size() ) ) ;
else
str_temp = _("1 operation is currently pending.");
dialog .set_secondary_text( str_temp ) ;
dialog .set_secondary_text( _("1 operation is currently pending.") ) ;
dialog .add_button( Gtk::Stock::QUIT, Gtk::RESPONSE_CLOSE );
dialog .add_button( Gtk::Stock::CANCEL,Gtk::RESPONSE_CANCEL );
@ -853,16 +851,16 @@ void Win_GParted::menu_gparted_refresh_devices( )
if ( ! readonly_paths .empty() )
{
str_temp = "<span weight=\"bold\" size=\"larger\">" ;
str_temp += _("The kernel is unable to re-read the partitiontables on the following devices:") ;
str_temp += readonly_paths ;
str_temp += "</span>\n\n" ;
Gtk::MessageDialog dialog(
*this,
_("The kernel is unable to re-read the partitiontables on the following devices:") + readonly_paths,
false,
Gtk::MESSAGE_WARNING,
Gtk::BUTTONS_OK,
true ) ;
str_temp += _("Because of this you will only have limited access to these devices.") ;
str_temp += "\n" ;
str_temp += _("Unmount all mounted partitions on a device to get full access.") ;
dialog .set_secondary_text( _("Because of this you will only have limited access to these devices. Unmount all mounted partitions on a device to get full access.") ) ;
Gtk::MessageDialog dialog( *this, str_temp, true, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK, true ) ;
dialog .run() ;
}
@ -950,7 +948,7 @@ void Win_GParted::menu_gparted_quit( )
void Win_GParted::menu_view_harddisk_info( )
{
if ( ( (Gtk::CheckMenuItem *) & menubar_main .items( ) [ 2 ] .get_submenu( ) ->items( ) [ 0 ] ) ->get_active( ) )
if ( static_cast<Gtk::CheckMenuItem *>( & menubar_main .items()[ 2 ] .get_submenu() ->items()[ 0 ] ) ->get_active() )
{ //open harddisk information
hpaned_main .get_child1() ->show() ;
for ( int t = hpaned_main .get_position() ; t < 250 ; t += 15 )
@ -974,7 +972,7 @@ void Win_GParted::menu_view_harddisk_info( )
void Win_GParted::menu_view_operations()
{
if ( ( (Gtk::CheckMenuItem *) & menubar_main .items( ) [ 2 ] .get_submenu( ) ->items( ) [ 1 ] ) ->get_active( ) )
if ( static_cast<Gtk::CheckMenuItem *>( & menubar_main .items()[ 2 ] .get_submenu() ->items()[ 1 ] ) ->get_active() )
open_operationslist() ;
else
close_operationslist() ;
@ -982,10 +980,15 @@ void Win_GParted::menu_view_operations( )
void Win_GParted::menu_help_contents()
{
str_temp = _("Sorry, not yet implemented.") ;
str_temp += "\n" ;
str_temp += _( "Please visit http://gparted.sf.net for more information and support.") ;
Gtk::MessageDialog dialog( *this, str_temp, false, Gtk::MESSAGE_INFO, Gtk::BUTTONS_OK, true );
Gtk::MessageDialog dialog( *this,
_("Sorry, not yet implemented."),
false,
Gtk::MESSAGE_INFO,
Gtk::BUTTONS_OK,
true );
dialog .set_secondary_text( _( "Please visit http://gparted.sf.net for more information and support.") ) ;
dialog .run();
}
@ -1053,13 +1056,20 @@ bool Win_GParted::max_amount_prim_reached( )
//Display error if user tries to create more primary partitions than the partition table can hold.
if ( ! selected_partition .inside_extended && primary_count >= devices[ current_device ] .max_prims )
{
str_temp = "<span weight=\"bold\" size=\"larger\">" ;
str_temp += String::ucompose( _("It is not possible to create more than %1 primary partitions"), devices[ current_device ] .max_prims ) ;
str_temp += "</span>\n\n" ;
str_temp += _( "If you want more partitions you should first create an extended partition. Such a partition can contain other partitions.") ;
Gtk::MessageDialog dialog(
*this,
String::ucompose( _("It is not possible to create more than %1 primary partitions"),
devices[ current_device ] .max_prims ),
false,
Gtk::MESSAGE_ERROR,
Gtk::BUTTONS_OK,
true ) ;
dialog .set_secondary_text(
_( "If you want more partitions you should first create an extended partition. Such a partition can contain other partitions.") ) ;
Gtk::MessageDialog dialog( *this, str_temp, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true ) ;
dialog .run() ;
return true ;
}
@ -1068,32 +1078,6 @@ bool Win_GParted::max_amount_prim_reached( )
void Win_GParted::activate_resize()
{
//show warning when one tries to resize a fat16 filesystem
if ( selected_partition .filesystem == GParted::FS_FAT16 )
{
str_temp = "<span weight=\"bold\" size=\"larger\">" ;
str_temp += _( "Are you sure you want to resize/move this partition?" ) ;
str_temp += "</span>\n\n" ;
str_temp += _( "Resizing a fat16 partition can be quite tricky! Especially growing such a partition is very error-prone. It is advisable to first convert the filesystem to fat32.") ;
str_temp += "\n";
Gtk::MessageDialog dialog( *this, str_temp, true, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_CANCEL, true) ;
//pffff this whole mess only for this f*cked up filesystem :-(
Gtk::Button button_resize_move ;
Gtk::HBox hbox_resize_move;
image = manage( new Gtk::Image( Gtk::Stock::GOTO_LAST, Gtk::ICON_SIZE_BUTTON ) );
hbox_resize_move .pack_start( *image, Gtk::PACK_SHRINK ) ;
hbox_resize_move .pack_start( * Utils::mk_label( _("Resize/Move") ), Gtk::PACK_SHRINK ) ;
button_resize_move .add( hbox_resize_move ) ;
dialog .add_action_widget( button_resize_move, Gtk::RESPONSE_OK ) ;
dialog .show_all_children( ) ;
if ( dialog .run( ) == Gtk::RESPONSE_CANCEL )
return ;
}
std::vector <Partition> partitions = devices[ current_device ] .partitions ;
if ( operations .size() )
@ -1205,13 +1189,17 @@ void Win_GParted::activate_delete()
selected_partition .status != GParted::STAT_NEW &&
selected_partition .partition_number < devices[ current_device ] .highest_busy )
{
str_temp = "<span weight=\"bold\" size=\"larger\">" ;
str_temp += _( "Unable to delete partition!") ;
str_temp += "</span>\n\n" ;
str_temp += String::ucompose(
_("Please unmount any logical partitions having a number higher than %1"),
selected_partition .partition_number ) ;
Gtk::MessageDialog dialog( *this, str_temp, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true ) ;
Gtk::MessageDialog dialog( *this,
String::ucompose( _( "Unable to delete %1!"), selected_partition .partition ),
false,
Gtk::MESSAGE_ERROR,
Gtk::BUTTONS_OK,
true ) ;
dialog .set_secondary_text(
String::ucompose( _("Please unmount any logical partitions having a number higher than %1"),
selected_partition .partition_number ) ) ;
dialog .run() ;
return;
}
@ -1219,17 +1207,21 @@ void Win_GParted::activate_delete()
//if partition is on the clipboard...
if ( selected_partition .partition == copied_partition .partition )
{
str_temp = "<span weight=\"bold\" size=\"larger\">" ;
str_temp += String::ucompose( _( "Are you sure you want to delete %1?"),
selected_partition .partition ) + "</span>\n\n" ;
str_temp += _( "After deletion this partition is no longer available for copying.") ;
Gtk::MessageDialog dialog( *this,
String::ucompose( _( "Are you sure you want to delete %1?"),
selected_partition .partition ),
false,
Gtk::MESSAGE_QUESTION,
Gtk::BUTTONS_NONE,
true ) ;
dialog .set_secondary_text( _("After deletion this partition is no longer available for copying.") ) ;
Gtk::MessageDialog dialog( *this, str_temp, true, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_NONE, true );
/*TO TRANSLATORS: dialogtitle, looks like Delete /dev/hda2 (ntfs, 2345 MiB) */
dialog .set_title( String::ucompose( _("Delete %1 (%2, %3 MiB)"),
dialog .set_title( String::ucompose( _("Delete %1 (%2, %3)"),
selected_partition .partition,
selected_partition .filesystem,
selected_partition .Get_Length_MB() ) );
Utils::Get_Filesystem_String( selected_partition .filesystem ),
Utils::format_size( selected_partition .get_length() ) ) );
dialog .add_button( Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL );
dialog .add_button( Gtk::Stock::DELETE, Gtk::RESPONSE_OK );
@ -1286,29 +1278,28 @@ void Win_GParted::activate_format( GParted::FILESYSTEM new_fs )
if ( selected_partition .Get_Length_MB() < fs .MIN ||
fs .MAX && selected_partition .Get_Length_MB() > fs .MAX )
{
str_temp = "<span weight=\"bold\" size=\"larger\">" ;
str_temp += String::ucompose(
_("Cannot format this filesystem to %1."),
Utils::Get_Filesystem_String( new_fs ) ) ;
str_temp += "</span>\n\n" ;
Gtk::MessageDialog dialog( *this,
String::ucompose( _("Cannot format this filesystem to %1."),
Utils::Get_Filesystem_String( new_fs ) ) ,
false,
Gtk::MESSAGE_ERROR,
Gtk::BUTTONS_OK,
true );
if ( selected_partition .Get_Length_MB() < fs .MIN )
str_temp += String::ucompose(
_( "A %1 filesystem requires a partition of at least %2 MiB."),
dialog .set_secondary_text( String::ucompose( _( "A %1 filesystem requires a partition of at least %2 MiB."),
Utils::Get_Filesystem_String( new_fs ),
fs .MIN ) ;
fs .MIN ) );
else
str_temp += String::ucompose(
_( "A partition with a %1 filesystem has a maximum size of %2 MiB."),
dialog .set_secondary_text( String::ucompose( _( "A partition with a %1 filesystem has a maximum size of %2 MiB."),
Utils::Get_Filesystem_String( new_fs ),
fs .MAX ) ;
fs .MAX ) );
Gtk::MessageDialog dialog( *this, str_temp, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true );
dialog .run() ;
return ;
}
//ok we made it :P lets create an fitting partition object
//ok we made it. lets create an fitting partition object
Partition part_temp;
part_temp .Set( devices[ current_device ] .path,
selected_partition .partition,
@ -1346,9 +1337,11 @@ void Win_GParted::activate_format( GParted::FILESYSTEM new_fs )
void Win_GParted::thread_unmount_partition( bool * succes, Glib::ustring * error )
{
Glib::ustring dummy ;
*succes = true ;
for ( unsigned int t = 0 ; t < selected_partition .mountpoints .size() && *succes ; t++ )
*succes = ! Utils::execute_command( "umount -v " + selected_partition .mountpoints[ t ], str_temp, *error ) ;
*succes = ! Utils::execute_command( "umount -v " + selected_partition .mountpoints[ t ], dummy, *error ) ;
pulse = false ;
}
@ -1383,10 +1376,12 @@ void Win_GParted::activate_unmount()
void Win_GParted::thread_toggle_swap( bool * succes, Glib::ustring * error )
{
Glib::ustring dummy ;
if ( selected_partition .busy )
*succes = ! Utils::execute_command( "swapoff -v " + selected_partition .partition + " && sync", str_temp, *error ) ;
*succes = ! Utils::execute_command( "swapoff -v " + selected_partition .partition + " && sync", dummy, *error ) ;
else
*succes = ! Utils::execute_command( "swapon -v " + selected_partition .partition + " && sync", str_temp, *error ) ;
*succes = ! Utils::execute_command( "swapon -v " + selected_partition .partition + " && sync", dummy, *error ) ;
pulse = false ;
}
@ -1430,17 +1425,29 @@ void Win_GParted::activate_disklabel( )
if ( dialog .run() == Gtk::RESPONSE_OK )
{
str_temp = "<span weight=\"bold\" size=\"larger\">" ;
str_temp += String::ucompose( _("Are you sure you want to create a %1 disklabel on %2?"), dialog .Get_Disklabel( ), devices[ current_device ] .path ) ;
str_temp += "</span>\n\n" ;
str_temp += String::ucompose( _("This operation will destroy all data on %1"), devices[ current_device ] .path ) ;
Gtk::MessageDialog m_dialog( *this,
String::ucompose( _("Are you sure you want to create a %1 disklabel on %2?"),
dialog .Get_Disklabel(),
devices[ current_device ] .path ),
false,
Gtk::MESSAGE_QUESTION,
Gtk::BUTTONS_CANCEL,
true ) ;
m_dialog .set_secondary_text( String::ucompose( _("This operation will destroy all data on %1!"),
devices[ current_device ] .path ) ) ;
Gtk::MessageDialog m_dialog( *this, str_temp, true, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_CANCEL, true ) ;
m_dialog .add_button( _("Create"), Gtk::RESPONSE_OK );
if ( m_dialog .run( ) == Gtk::RESPONSE_OK && ! gparted_core .Set_Disklabel( devices[ current_device ] .path, dialog .Get_Disklabel( ) ) )
if ( m_dialog .run() == Gtk::RESPONSE_OK &&
! gparted_core .Set_Disklabel( devices[ current_device ] .path, dialog .Get_Disklabel() ) )
{
Gtk::MessageDialog dialog( *this, _("Error while setting new disklabel"), true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true ) ;
Gtk::MessageDialog dialog( *this,
_("Error while setting new disklabel"),
true,
Gtk::MESSAGE_ERROR,
Gtk::BUTTONS_OK,
true ) ;
dialog .run() ;
}