33
33
#include "../include/OperationFormat.h"
34
34
#include "../include/OperationResizeMove.h"
35
35
#include "../include/OperationLabelPartition.h"
36
#include "../config.h"
37
38
#include <gtkmm/aboutdialog.h>
38
39
#include <gtkmm/messagedialog.h>
393
394
for ( unsigned int t =0; t < gparted_core .get_filesystems() .size() ; t++ )
395
//Skip btrfs, luks, lvm2, and unknown because these are not file systems
396
if ( gparted_core .get_filesystems()[ t ] .filesystem == GParted::FS_BTRFS ||
396
//Skip luks, lvm2, and unknown because these are not file systems
397
398
gparted_core .get_filesystems()[ t ] .filesystem == GParted::FS_LUKS ||
398
399
gparted_core .get_filesystems()[ t ] .filesystem == GParted::FS_LVM2 ||
399
400
gparted_core .get_filesystems()[ t ] .filesystem == GParted::FS_UNKNOWN
1342
1343
Gtk::MessageDialog dialog(
1344
String::ucompose( _("It is not possible to create more than %1 primary partitions"),
1345
devices[ current_device ] .max_prims ),
1345
String::ucompose( ngettext( "It is not possible to create more than %1 primary partition"
1346
, "It is not possible to create more than %1 primary partitions"
1347
, devices[ current_device ] .max_prims
1349
, devices[ current_device ] .max_prims
1347
1352
Gtk::MESSAGE_ERROR,
1348
1353
Gtk::BUTTONS_OK,
1424
1429
operation ->icon = render_icon( Gtk::Stock::GOTO_LAST, Gtk::ICON_SIZE_MENU );
1426
1431
Add_Operation( operation ) ;
1433
//Display notification if move operation has been queued
1434
if ( operation ->partition_original .sector_start != operation ->partition_new .sector_start )
1436
//Warn that move operation might break boot process
1437
Gtk::MessageDialog dialog( *this
1438
, _( "Moving a partition might cause your operating system to fail to boot." )
1440
, Gtk::MESSAGE_WARNING
1444
Glib::ustring tmp_msg =
1445
/*TO TRANSLATORS: looks like You queued an operation to move the start sector of partition /dev/sda3. */
1446
String::ucompose( _( "You have queued an operation to move the start sector of partition %1." )
1447
, operation ->partition_original .get_path()
1449
tmp_msg += " Failure to boot is most likely to occur if you move the GNU/Linux partition containing /boot, or if you move the Windows system partition C:." ;
1451
tmp_msg += _( "You can learn how to repair the boot configuration in the GParted FAQ." ) ;
1453
tmp_msg += "http://gparted.org/faq.php" ;
1455
tmp_msg += "Moving a partition might take a very long time to apply." ;
1456
dialog .set_secondary_text( tmp_msg ) ;
1643
1675
( fs .MAX && selected_partition .get_byte_length() > fs .MAX ) )
1645
1677
Gtk::MessageDialog dialog( *this,
1646
String::ucompose( _("Cannot format this file system to %1."),
1647
Utils::get_filesystem_string( new_fs ) ) ,
1679
/* TO TRANSLATORS: looks like
1680
* Cannot format this file system to fat16.
1682
_( "Cannot format this file system to %1." ),
1683
Utils::get_filesystem_string( new_fs ) ) ,
1649
1685
Gtk::MESSAGE_ERROR,
1650
1686
Gtk::BUTTONS_OK,
1653
1689
if ( selected_partition .get_byte_length() < fs .MIN )
1654
dialog .set_secondary_text( String::ucompose(
1690
dialog .set_secondary_text( String::ucompose(
1691
/* TO TRANSLATORS: looks like
1692
* A fat16 file system requires a partition of at least 16.00 MiB.
1655
1694
_( "A %1 file system requires a partition of at least %2."),
1656
1695
Utils::get_filesystem_string( new_fs ),
1657
1696
Utils::format_size( fs .MIN, 1 /* Byte */ ) ) );
1659
dialog .set_secondary_text( String::ucompose(
1698
dialog .set_secondary_text( String::ucompose(
1699
/* TO TRANSLATORS: looks like
1700
* A partition with a hfs file system has a maximum size of 2.00 GiB.
1660
1702
_( "A partition with a %1 file system has a maximum size of %2."),
1661
1703
Utils::get_filesystem_string( new_fs ),
1662
1704
Utils::format_size( fs .MAX, 1 /* Byte */ ) ) );
1781
1823
pulse = false ;
1784
1826
void Win_GParted::toggle_swap_mount_state()
1828
int operation_count = partition_in_operation_queue_count( selected_partition ) ;
1829
if ( operation_count > 0 )
1831
//Note that this situation will only occur when trying to swapon a partition.
1832
// This is because GParted does not permit queueing operations on partitions
1833
// that are currently active (i.e., swap enabled, or mounted). Hence this
1834
// situation will not occur for the swapoff or unmount actions that this
1837
/*TO TRANSLATORS: Singular case looks like 1 operation is currently pending for partition /dev/sdd8. */
1838
Glib::ustring tmp_msg =
1839
String::ucompose( ngettext( "%1 operation is currently pending for partition %2."
1840
, "%1 operations are currently pending for partition %2."
1844
, selected_partition .get_path()
1846
Gtk::MessageDialog dialog( *this
1853
tmp_msg = _( "The swapon action cannot be performed if an operation is pending for the partition." ) ;
1855
tmp_msg += _( "Use the Edit menu to undo, clear, or apply operations before using swapon with this partition." ) ;
1856
dialog .set_secondary_text( tmp_msg ) ;
1786
1861
bool succes = false ;
1787
1862
Glib::ustring error ;
1838
1913
menu_gparted_refresh_devices() ;
1841
1916
void Win_GParted::activate_mount_partition( unsigned int index )
1918
int operation_count = partition_in_operation_queue_count( selected_partition ) ;
1919
if ( operation_count > 0 )
1921
/*TO TRANSLATORS: Plural case looks like 4 operations are currently pending for partition /dev/sdd8. */
1922
Glib::ustring tmp_msg =
1923
String::ucompose( ngettext( "%1 operation is currently pending for partition %2."
1924
, "%1 operations are currently pending for partition %2."
1928
, selected_partition .get_path()
1930
Gtk::MessageDialog dialog( *this
1937
tmp_msg = _( "The mount action cannot be performed if an operation is pending for the partition." ) ;
1939
tmp_msg += _( "Use the Edit menu to undo, clear, or apply operations before using mount with this partition." ) ;
1940
dialog .set_secondary_text( tmp_msg ) ;
1843
1945
bool succes = false ;
1844
1946
Glib::ustring error ;
1848
1950
thread = Glib::Thread::create( sigc::bind<Glib::ustring, bool *, Glib::ustring *>(
1878
1980
void Win_GParted::activate_disklabel()
1982
//If there are active mounted partitions on the device then warn
1983
// the user that all partitions must be unactive before creating
1984
// a new partition table
1985
int active_count = active_partitions_on_device_count( devices[ current_device ] ) ;
1986
if ( active_count > 0 )
1988
Glib::ustring tmp_msg =
1989
String::ucompose( /*TO TRANSLATORS: Singular case looks like 1 partition is currently active on device /dev/sda. */
1990
ngettext( "%1 partition is currently active on device %2."
1991
/*TO TRANSLATORS: Plural case looks like 3 partitions are currently active on device /dev/sda. */
1992
, "%1 partitions are currently active on device %2."
1996
, devices[ current_device ] .get_path()
1998
Gtk::MessageDialog dialog( *this
2005
tmp_msg = _( "A new partition table cannot be created when there are active partitions." ) ;
2007
tmp_msg += _( "Active partitions are those that are in use, such as a mounted file system, or enabled swap space." ) ;
2009
tmp_msg += _( "Use Partition menu options, such as unmount or swapoff, to deactivate all partitions on this device before creating a new partition table." ) ;
2010
dialog .set_secondary_text( tmp_msg ) ;
1880
2015
//If there are pending operations then warn the user that these
1881
2016
// operations must either be applied or cleared before creating
1882
2017
// a new partition table.
2162
int Win_GParted::partition_in_operation_queue_count( const Partition & partition )
2164
int operation_count = 0 ;
2166
for ( unsigned int t = 0 ; t < operations .size() ; t++ )
2168
if ( partition .get_path() == operations[ t ] ->partition_original .get_path() )
2172
return operation_count ;
2175
int Win_GParted::active_partitions_on_device_count( const Device & device )
2177
int active_count = 0 ;
2179
//Count the active partitions on the device
2180
for ( unsigned int k=0; k < device .partitions .size(); k++ )
2182
//FIXME: Should also count other types of active partitions, such as LVM2 when we know how.
2184
//Count the active primary partitions
2185
if ( device .partitions[ k ] .busy
2186
&& device .partitions[ k ] .type != TYPE_EXTENDED
2187
&& device .partitions[ k ] .type != TYPE_UNALLOCATED
2191
//Count the active logical partitions
2192
if ( device .partitions[ k ] .busy
2193
&& device .partitions[ k ] .type == TYPE_EXTENDED
2196
for ( unsigned int j=0; j < device .partitions[ k ] .logicals .size(); j++ )
2198
if ( device .partitions[ k ] .logicals [ j ] .busy
2199
&& device .partitions[ k ] .logicals [ j ] .type != TYPE_UNALLOCATED
2206
return active_count ;
2027
2209
void Win_GParted::activate_apply()
2029
2211
Gtk::MessageDialog dialog( *this,