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> 2006-02-16 Bart Hakvoort <hakvoort@cvs.gnome.org>
* configure.in: bumped to gparted-0.2.1 * configure.in: bumped to gparted-0.2.1

View File

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

View File

@ -221,7 +221,6 @@ private:
bool any_extended;//used in some checks bool any_extended;//used in some checks
unsigned short primary_count ;//primary_count checks for max. of 4 pimary partitions 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 unsigned short new_count;//new_count keeps track of the new created partitions
Glib::ustring str_temp ; //mostly used for constructing dialogmessages
FS fs ; FS fs ;
GParted_Core gparted_core ; GParted_Core gparted_core ;

View File

@ -14,3 +14,4 @@ notexist
po2tbl.sed po2tbl.sed
po2tbl.sed.in po2tbl.sed.in
stamp-cat-id 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> 2006-02-16 Bart Hakvoort <hakvoort@cvs.gnome.org>
* bumped to gparted-0.2.1 * bumped to gparted-0.2.1

View File

@ -53,15 +53,15 @@ void GParted_Core::find_supported_filesystems( )
linux_swap fs_linux_swap; linux_swap fs_linux_swap;
FILESYSTEMS .push_back( fs_linux_swap .get_filesystem_support( ) ) ; FILESYSTEMS .push_back( fs_linux_swap .get_filesystem_support( ) ) ;
ntfs fs_ntfs;
FILESYSTEMS .push_back( fs_ntfs .get_filesystem_support( ) ) ;
reiser4 fs_reiser4; reiser4 fs_reiser4;
FILESYSTEMS .push_back( fs_reiser4 .get_filesystem_support( ) ) ; FILESYSTEMS .push_back( fs_reiser4 .get_filesystem_support( ) ) ;
reiserfs fs_reiserfs; reiserfs fs_reiserfs;
FILESYSTEMS .push_back( fs_reiserfs .get_filesystem_support( ) ) ; FILESYSTEMS .push_back( fs_reiserfs .get_filesystem_support( ) ) ;
ntfs fs_ntfs;
FILESYSTEMS .push_back( fs_ntfs .get_filesystem_support( ) ) ;
xfs fs_xfs; xfs fs_xfs;
FILESYSTEMS .push_back( fs_xfs .get_filesystem_support( ) ) ; 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 ) ) if ( open_device_and_disk( new_partition .device_path ) )
{ {
PedPartitionType type; PedPartitionType type;
PedPartition *c_part = NULL ; lp_partition = NULL ;
PedConstraint *constraint = NULL ; PedConstraint *constraint = NULL ;
//create new partition //create new partition
@ -771,8 +771,8 @@ int GParted_Core::create_empty_partition( Partition & new_partition,
type = PED_PARTITION_FREESPACE; type = PED_PARTITION_FREESPACE;
} }
c_part = 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 ( c_part ) if ( lp_partition )
{ {
if ( new_partition .strict ) if ( new_partition .strict )
{ {
@ -789,10 +789,23 @@ int GParted_Core::create_empty_partition( Partition & new_partition,
if ( copy ) if ( copy )
constraint ->min_size = new_partition .get_length() ; 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 = ped_partition_get_path( lp_partition ) ;
new_partition .partition_number = c_part ->num ; 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 ); 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 .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 ; bool return_value = false ;
PedConstraint *constraint = NULL ; PedConstraint *constraint = NULL ;
@ -840,15 +862,21 @@ bool GParted_Core::resize_container_partition( const Partition & partition_old,
if ( partition_old .type == GParted::TYPE_EXTENDED ) if ( partition_old .type == GParted::TYPE_EXTENDED )
lp_partition = ped_disk_extended_partition( lp_disk ) ; lp_partition = ped_disk_extended_partition( lp_disk ) ;
else 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 ) if ( lp_partition )
{ {
constraint = ped_constraint_any( lp_device ); 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 ); ped_constraint_destroy( constraint );
constraint = NULL ; constraint = NULL ;
@ -858,14 +886,35 @@ bool GParted_Core::resize_container_partition( const Partition & partition_old,
if ( constraint ) 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() ; return_value = commit() ;
ped_constraint_destroy( constraint ); ped_constraint_destroy( constraint );
} }
} }
close_device_and_disk( ) ; 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 ) if ( partition_old .type == GParted::TYPE_EXTENDED )
@ -899,33 +948,38 @@ bool GParted_Core::resize_normal_using_libparted( const Partition & partition_ol
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 ) if ( lp_partition )
{ {
fs = ped_file_system_open ( & lp_partition ->geom ); fs = ped_file_system_open( & lp_partition ->geom );
if ( fs ) if ( fs )
{ {
constraint = ped_file_system_get_resize_constraint ( fs ); constraint = ped_file_system_get_resize_constraint( fs );
if ( constraint ) 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,
ped_file_system_resize ( fs, & lp_partition ->geom, NULL ) lp_partition,
constraint,
partition_new .sector_start,
partition_new .sector_end )
&&
ped_file_system_resize( fs, & lp_partition ->geom, NULL )
) )
return_value = commit( ) ; return_value = commit() ;
ped_constraint_destroy ( constraint ); ped_constraint_destroy( constraint );
} }
ped_file_system_close ( fs ); ped_file_system_close( fs );
} }
} }
close_device_and_disk( ) ; close_device_and_disk() ;
} }
operation_details .back() .status = return_value ? OperationDetails::SUCCES : OperationDetails::ERROR ; operation_details .back() .status = return_value ? OperationDetails::SUCCES : OperationDetails::ERROR ;
return return_value ; return return_value ;
} }
Glib::ustring GParted_Core::Get_Flags( ) 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 = ""; temp = "";
for ( unsigned short t = 0; t < flags .size( ) ; t++ ) 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, bool GParted_Core::set_partition_type( const Partition & partition,
std::vector<OperationDetails> & operation_details ) std::vector<OperationDetails> & operation_details )
{ {
@ -979,11 +1032,11 @@ bool GParted_Core::set_partition_type( const Partition & partition,
{ {
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( ) ) if ( lp_partition && ped_partition_set_system( lp_partition, fs_type ) && commit() )
return_value = wait_for_node( partition .partition ) ; return_value = wait_for_node( partition .partition ) ;
} }
close_device_and_disk( ) ; close_device_and_disk() ;
} }
operation_details .back() .status = return_value ? OperationDetails::SUCCES : OperationDetails::ERROR ; operation_details .back() .status = return_value ? OperationDetails::SUCCES : OperationDetails::ERROR ;
@ -1027,7 +1080,7 @@ bool GParted_Core::erase_filesystem_signatures( const Partition & partition )
} }
} }
close_device_and_disk( ) ; close_device_and_disk() ;
} }
return return_value ; return return_value ;
@ -1035,7 +1088,7 @@ bool GParted_Core::erase_filesystem_signatures( const Partition & partition )
bool GParted_Core::open_device( const Glib::ustring & device_path ) bool GParted_Core::open_device( const Glib::ustring & device_path )
{ {
lp_device = ped_device_get( device_path .c_str( ) ); lp_device = ped_device_get( device_path .c_str() );
return lp_device ; return lp_device ;
} }
@ -1058,7 +1111,7 @@ bool GParted_Core::open_device_and_disk( const Glib::ustring & device_path, bool
return true ; return true ;
} }
void GParted_Core::close_device_and_disk( ) void GParted_Core::close_device_and_disk()
{ {
if ( lp_device ) if ( lp_device )
ped_device_destroy( lp_device ) ; ped_device_destroy( lp_device ) ;
@ -1070,7 +1123,7 @@ void GParted_Core::close_device_and_disk( )
lp_disk = NULL ; lp_disk = NULL ;
} }
bool GParted_Core::commit( ) bool GParted_Core::commit()
{ {
bool return_value = ped_disk_commit_to_dev( lp_disk ) ; bool return_value = ped_disk_commit_to_dev( lp_disk ) ;

View File

@ -641,7 +641,7 @@ void Win_GParted::Refresh_Visual( )
set_valid_operations() ; set_valid_operations() ;
} }
bool Win_GParted::Quit_Check_Operations( ) bool Win_GParted::Quit_Check_Operations()
{ {
if ( operations .size() ) if ( operations .size() )
{ {
@ -653,11 +653,9 @@ bool Win_GParted::Quit_Check_Operations( )
true ); true );
if ( operations .size() != 1 ) 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 else
str_temp = _("1 operation is currently pending."); dialog .set_secondary_text( _("1 operation is currently pending.") ) ;
dialog .set_secondary_text( str_temp ) ;
dialog .add_button( Gtk::Stock::QUIT, Gtk::RESPONSE_CLOSE ); dialog .add_button( Gtk::Stock::QUIT, Gtk::RESPONSE_CLOSE );
dialog .add_button( Gtk::Stock::CANCEL,Gtk::RESPONSE_CANCEL ); dialog .add_button( Gtk::Stock::CANCEL,Gtk::RESPONSE_CANCEL );
@ -669,7 +667,7 @@ bool Win_GParted::Quit_Check_Operations( )
return true; //close GParted return true; //close GParted
} }
void Win_GParted::set_valid_operations( ) void Win_GParted::set_valid_operations()
{ {
allow_new( false ); allow_delete( false ); allow_resize( false ); allow_copy( false ); allow_new( false ); allow_delete( false ); allow_resize( false ); allow_copy( false );
allow_paste( false ); allow_format( false ); allow_unmount( false ) ; allow_info( false ) ; allow_paste( false ); allow_format( false ); allow_unmount( false ) ; allow_info( false ) ;
@ -853,29 +851,29 @@ void Win_GParted::menu_gparted_refresh_devices( )
if ( ! readonly_paths .empty() ) if ( ! readonly_paths .empty() )
{ {
str_temp = "<span weight=\"bold\" size=\"larger\">" ; Gtk::MessageDialog dialog(
str_temp += _("The kernel is unable to re-read the partitiontables on the following devices:") ; *this,
str_temp += readonly_paths ; _("The kernel is unable to re-read the partitiontables on the following devices:") + readonly_paths,
str_temp += "</span>\n\n" ; false,
Gtk::MESSAGE_WARNING,
Gtk::BUTTONS_OK,
true ) ;
str_temp += _("Because of this you will only have limited access to these devices.") ; 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.") ) ;
str_temp += "\n" ;
str_temp += _("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() ;
dialog .run( ) ;
} }
//see if there are any pending operations on non-existent devices //see if there are any pending operations on non-existent devices
//NOTE that this isn't 100% foolproof since some stuff (e.g. sourcedevice of copy) may slip through. //NOTE that this isn't 100% foolproof since some stuff (e.g. sourcedevice of copy) may slip through.
//but anyone who removes the sourcedevice before applying the operations gets what he/she deserves :-) //but anyone who removes the sourcedevice before applying the operations gets what he/she deserves :-)
unsigned int i ; unsigned int i ;
for ( unsigned int t = 0 ; t < operations .size( ) ; t++ ) for ( unsigned int t = 0 ; t < operations .size() ; t++ )
{ {
for ( i = 0 ; i < devices .size( ) && devices[ i ] .path != operations[ t ] .device .path ; i++ ) {} for ( i = 0 ; i < devices .size() && devices[ i ] .path != operations[ t ] .device .path ; i++ ) {}
if ( i >= devices .size( ) ) if ( i >= devices .size() )
operations .erase( operations .begin( ) + t-- ) ;//decrease t bij one.. operations .erase( operations .begin() + t-- ) ;//decrease t bij one..
} }
//if no devices were detected we disable some stuff and show a message in the statusbar //if no devices were detected we disable some stuff and show a message in the statusbar
@ -942,55 +940,60 @@ void Win_GParted::menu_gparted_filesystems( )
} }
} }
void Win_GParted::menu_gparted_quit( ) void Win_GParted::menu_gparted_quit()
{ {
if ( Quit_Check_Operations( ) ) if ( Quit_Check_Operations() )
this ->hide( ); this ->hide();
} }
void Win_GParted::menu_view_harddisk_info( ) 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 { //open harddisk information
hpaned_main .get_child1( ) ->show( ) ; hpaned_main .get_child1() ->show() ;
for ( int t = hpaned_main .get_position( ) ; t < 250 ; t +=15 ) for ( int t = hpaned_main .get_position() ; t < 250 ; t += 15 )
{ {
hpaned_main .set_position( t ); hpaned_main .set_position( t );
while ( Gtk::Main::events_pending( ) ) while ( Gtk::Main::events_pending() )
Gtk::Main::iteration( ); Gtk::Main::iteration();
} }
} }
else else
{ //close harddisk information { //close harddisk information
for ( int t=hpaned_main .get_position( ) ; t > 0 ; t -=15 ) for ( int t = hpaned_main .get_position() ; t > 0 ; t -= 15 )
{ {
hpaned_main .set_position( t ); hpaned_main .set_position( t );
while ( Gtk::Main::events_pending( ) ) while ( Gtk::Main::events_pending() )
Gtk::Main::iteration( ); Gtk::Main::iteration();
} }
hpaned_main .get_child1( ) ->hide( ) ; hpaned_main .get_child1() ->hide() ;
} }
} }
void Win_GParted::menu_view_operations( ) 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( ) ; open_operationslist() ;
else else
close_operationslist( ) ; close_operationslist() ;
} }
void Win_GParted::menu_help_contents( ) void Win_GParted::menu_help_contents()
{ {
str_temp = _("Sorry, not yet implemented.") ; Gtk::MessageDialog dialog( *this,
str_temp += "\n" ; _("Sorry, not yet implemented."),
str_temp += _( "Please visit http://gparted.sf.net for more information and support.") ; false,
Gtk::MessageDialog dialog( *this, str_temp, false, Gtk::MESSAGE_INFO, Gtk::BUTTONS_OK, true ); Gtk::MESSAGE_INFO,
dialog .run( ); Gtk::BUTTONS_OK,
true );
dialog .set_secondary_text( _( "Please visit http://gparted.sf.net for more information and support.") ) ;
dialog .run();
} }
void Win_GParted::menu_help_about( ) void Win_GParted::menu_help_about()
{ {
std::vector<Glib::ustring> strings ; std::vector<Glib::ustring> strings ;
@ -998,7 +1001,7 @@ void Win_GParted::menu_help_about( )
dialog .set_transient_for( *this ) ; dialog .set_transient_for( *this ) ;
dialog .set_name( _("GParted") ) ; dialog .set_name( _("GParted") ) ;
dialog .set_logo( this ->get_icon( ) ) ; dialog .set_logo( this ->get_icon() ) ;
dialog .set_version( VERSION ) ; dialog .set_version( VERSION ) ;
dialog .set_comments( _( "GNOME Partition Editor" ) ) ; dialog .set_comments( _( "GNOME Partition Editor" ) ) ;
dialog .set_copyright( "Copyright © 2004-2005 Bart Hakvoort" ) ; dialog .set_copyright( "Copyright © 2004-2005 Bart Hakvoort" ) ;
@ -1006,12 +1009,12 @@ void Win_GParted::menu_help_about( )
//authors //authors
strings .push_back( "Bart Hakvoort <gparted@users.sf.net>" ) ; strings .push_back( "Bart Hakvoort <gparted@users.sf.net>" ) ;
dialog .set_authors( strings ) ; dialog .set_authors( strings ) ;
strings .clear( ) ; strings .clear() ;
//artists //artists
strings .push_back( "http://gparted.sourceforge.net/artwork.php" ) ; strings .push_back( "http://gparted.sourceforge.net/artwork.php" ) ;
dialog .set_artists( strings ) ; dialog .set_artists( strings ) ;
strings .clear( ) ; strings .clear() ;
/*TO TRANSLATORS: your name(s) here please, if there are more translators put newlines (\n) between the names. /*TO TRANSLATORS: your name(s) here please, if there are more translators put newlines (\n) between the names.
It's a good idea to provide the url of your translationteam as well. Thanks! */ It's a good idea to provide the url of your translationteam as well. Thanks! */
@ -1023,7 +1026,7 @@ void Win_GParted::menu_help_about( )
//the url is not clickable because this would introduce an new dep (gnome-vfsmm) //the url is not clickable because this would introduce an new dep (gnome-vfsmm)
dialog .set_website( "http://gparted.sourceforge.net" ) ; dialog .set_website( "http://gparted.sourceforge.net" ) ;
dialog .run( ) ; dialog .run() ;
} }
void Win_GParted::on_partition_selected( const Partition & partition, bool src_is_treeview ) void Win_GParted::on_partition_selected( const Partition & partition, bool src_is_treeview )
@ -1048,56 +1051,37 @@ void Win_GParted::on_partition_popup_menu( unsigned int button, unsigned int tim
menu_partition .popup( button, time ); menu_partition .popup( button, time );
} }
bool Win_GParted::max_amount_prim_reached( ) bool Win_GParted::max_amount_prim_reached()
{ {
//Display error if user tries to create more primary partitions than the partition table can hold. //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 ) if ( ! selected_partition .inside_extended && primary_count >= devices[ current_device ] .max_prims )
{ {
str_temp = "<span weight=\"bold\" size=\"larger\">" ; Gtk::MessageDialog dialog(
str_temp += String::ucompose( _("It is not possible to create more than %1 primary partitions"), devices[ current_device ] .max_prims ) ; *this,
str_temp += "</span>\n\n" ; String::ucompose( _("It is not possible to create more than %1 primary partitions"),
str_temp += _( "If you want more partitions you should first create an extended partition. Such a partition can contain other 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.") ) ;
dialog .run() ;
Gtk::MessageDialog dialog( *this, str_temp, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true ) ;
dialog .run( ) ;
return true ; return true ;
} }
return false ; return false ;
} }
void Win_GParted::activate_resize( ) 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 ; std::vector <Partition> partitions = devices[ current_device ] .partitions ;
if ( operations .size( ) ) if ( operations .size() )
for (unsigned int t = 0 ; t < operations .size( ) ; t++ ) for (unsigned int t = 0 ; t < operations .size() ; t++ )
if ( operations[ t ] .device .path == devices[ current_device ] .path ) if ( operations[ t ] .device .path == devices[ current_device ] .path )
operations[ t ] .Apply_Operation_To_Visual( partitions ) ; operations[ t ] .Apply_Operation_To_Visual( partitions ) ;
@ -1205,13 +1189,17 @@ void Win_GParted::activate_delete()
selected_partition .status != GParted::STAT_NEW && selected_partition .status != GParted::STAT_NEW &&
selected_partition .partition_number < devices[ current_device ] .highest_busy ) selected_partition .partition_number < devices[ current_device ] .highest_busy )
{ {
str_temp = "<span weight=\"bold\" size=\"larger\">" ; Gtk::MessageDialog dialog( *this,
str_temp += _( "Unable to delete partition!") ; String::ucompose( _( "Unable to delete %1!"), selected_partition .partition ),
str_temp += "</span>\n\n" ; false,
str_temp += String::ucompose( Gtk::MESSAGE_ERROR,
_("Please unmount any logical partitions having a number higher than %1"), Gtk::BUTTONS_OK,
selected_partition .partition_number ) ; true ) ;
Gtk::MessageDialog dialog( *this, str_temp, true, 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() ; dialog .run() ;
return; return;
} }
@ -1219,17 +1207,21 @@ void Win_GParted::activate_delete()
//if partition is on the clipboard... //if partition is on the clipboard...
if ( selected_partition .partition == copied_partition .partition ) if ( selected_partition .partition == copied_partition .partition )
{ {
str_temp = "<span weight=\"bold\" size=\"larger\">" ; Gtk::MessageDialog dialog( *this,
str_temp += String::ucompose( _( "Are you sure you want to delete %1?"), String::ucompose( _( "Are you sure you want to delete %1?"),
selected_partition .partition ) + "</span>\n\n" ; selected_partition .partition ),
str_temp += _( "After deletion this partition is no longer available for copying.") ; 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) */ /*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 .partition,
selected_partition .filesystem, Utils::Get_Filesystem_String( selected_partition .filesystem ),
selected_partition .Get_Length_MB() ) ); Utils::format_size( selected_partition .get_length() ) ) );
dialog .add_button( Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL ); dialog .add_button( Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL );
dialog .add_button( Gtk::Stock::DELETE, Gtk::RESPONSE_OK ); dialog .add_button( Gtk::Stock::DELETE, Gtk::RESPONSE_OK );
@ -1271,7 +1263,7 @@ void Win_GParted::activate_delete()
Add_Operation( GParted::DELETE, selected_partition ); Add_Operation( GParted::DELETE, selected_partition );
} }
void Win_GParted::activate_info( ) void Win_GParted::activate_info()
{ {
Dialog_Partition_Info dialog( selected_partition ); Dialog_Partition_Info dialog( selected_partition );
dialog .set_transient_for( *this ); dialog .set_transient_for( *this );
@ -1286,29 +1278,28 @@ void Win_GParted::activate_format( GParted::FILESYSTEM new_fs )
if ( selected_partition .Get_Length_MB() < fs .MIN || if ( selected_partition .Get_Length_MB() < fs .MIN ||
fs .MAX && selected_partition .Get_Length_MB() > fs .MAX ) fs .MAX && selected_partition .Get_Length_MB() > fs .MAX )
{ {
str_temp = "<span weight=\"bold\" size=\"larger\">" ; Gtk::MessageDialog dialog( *this,
str_temp += String::ucompose( String::ucompose( _("Cannot format this filesystem to %1."),
_("Cannot format this filesystem to %1."), Utils::Get_Filesystem_String( new_fs ) ) ,
Utils::Get_Filesystem_String( new_fs ) ) ; false,
str_temp += "</span>\n\n" ; Gtk::MESSAGE_ERROR,
Gtk::BUTTONS_OK,
true );
if ( selected_partition .Get_Length_MB( ) < fs .MIN ) if ( selected_partition .Get_Length_MB() < fs .MIN )
str_temp += String::ucompose( dialog .set_secondary_text( String::ucompose( _( "A %1 filesystem requires a partition of at least %2 MiB."),
_( "A %1 filesystem requires a partition of at least %2 MiB."),
Utils::Get_Filesystem_String( new_fs ), Utils::Get_Filesystem_String( new_fs ),
fs .MIN ) ; fs .MIN ) );
else else
str_temp += String::ucompose( dialog .set_secondary_text( String::ucompose( _( "A partition with a %1 filesystem has a maximum size of %2 MiB."),
_( "A partition with a %1 filesystem has a maximum size of %2 MiB."),
Utils::Get_Filesystem_String( new_fs ), 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() ; dialog .run() ;
return ; 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; Partition part_temp;
part_temp .Set( devices[ current_device ] .path, part_temp .Set( devices[ current_device ] .path,
selected_partition .partition, 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 ) void Win_GParted::thread_unmount_partition( bool * succes, Glib::ustring * error )
{ {
Glib::ustring dummy ;
*succes = true ; *succes = true ;
for ( unsigned int t = 0 ; t < selected_partition .mountpoints .size() && *succes ; t++ ) 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 ; pulse = false ;
} }
@ -1383,10 +1376,12 @@ void Win_GParted::activate_unmount()
void Win_GParted::thread_toggle_swap( bool * succes, Glib::ustring * error ) void Win_GParted::thread_toggle_swap( bool * succes, Glib::ustring * error )
{ {
Glib::ustring dummy ;
if ( selected_partition .busy ) 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 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 ; pulse = false ;
} }
@ -1423,49 +1418,61 @@ void Win_GParted::activate_toggle_swap()
menu_gparted_refresh_devices() ; menu_gparted_refresh_devices() ;
} }
void Win_GParted::activate_disklabel( ) void Win_GParted::activate_disklabel()
{ {
Dialog_Disklabel dialog( devices[ current_device ] .path, gparted_core .get_disklabeltypes( ) ) ; Dialog_Disklabel dialog( devices[ current_device ] .path, gparted_core .get_disklabeltypes() ) ;
dialog .set_transient_for( *this ); dialog .set_transient_for( *this );
if ( dialog .run( ) == Gtk::RESPONSE_OK ) if ( dialog .run() == Gtk::RESPONSE_OK )
{ {
str_temp = "<span weight=\"bold\" size=\"larger\">" ; Gtk::MessageDialog m_dialog( *this,
str_temp += String::ucompose( _("Are you sure you want to create a %1 disklabel on %2?"), dialog .Get_Disklabel( ), devices[ current_device ] .path ) ; String::ucompose( _("Are you sure you want to create a %1 disklabel on %2?"),
str_temp += "</span>\n\n" ; dialog .Get_Disklabel(),
str_temp += String::ucompose( _("This operation will destroy all data on %1"), devices[ current_device ] .path ) ; 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 ); 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,
dialog .run( ) ; _("Error while setting new disklabel"),
true,
Gtk::MESSAGE_ERROR,
Gtk::BUTTONS_OK,
true ) ;
dialog .run() ;
} }
menu_gparted_refresh_devices( ) ; menu_gparted_refresh_devices() ;
} }
} }
void Win_GParted::activate_undo( ) void Win_GParted::activate_undo()
{ {
//when undoing an creation it's safe to decrease the newcount by one //when undoing an creation it's safe to decrease the newcount by one
if ( operations .back( ) .operationtype == GParted::CREATE ) if ( operations .back() .operationtype == GParted::CREATE )
new_count-- ; new_count-- ;
operations.erase( operations .end( ) ); operations.erase( operations .end() );
Refresh_Visual( ); Refresh_Visual();
if ( ! operations .size( ) ) if ( ! operations .size() )
close_operationslist( ) ; close_operationslist() ;
} }
void Win_GParted::activate_apply( ) void Win_GParted::activate_apply()
{ {
Gtk::MessageDialog dialog( *this, Gtk::MessageDialog dialog( *this,
_( "Are you sure you want to apply the pending operations?" ), _("Are you sure you want to apply the pending operations?"),
false, false,
Gtk::MESSAGE_WARNING, Gtk::MESSAGE_WARNING,
Gtk::BUTTONS_NONE, Gtk::BUTTONS_NONE,