Added cylsize to Device and made Operation contain a Device instead of

* Added cylsize to Device and made Operation contain a Device instead of only the path and lenght.
  This way i was able to dump Get_Cyl_Size in the Core. Besides that, i used cylsize in WinGparted and made a lot of
  cosmetic changes. Most of them were pretty useless, but hey, i'm bored ;)
This commit is contained in:
Bart Hakvoort 2004-12-27 12:08:01 +00:00
parent 2ed3e0e8c4
commit 174f0cff77
13 changed files with 198 additions and 235 deletions

View File

@ -1,3 +1,9 @@
2004-12-27 Bart Hakvoort <gparted@users.sf.net>
* Added cylsize to Device and made Operation contain a Device instead of only the path and lenght.
This way i was able to dump Get_Cyl_Size in the Core. Besides that, i used cylsize in WinGparted and made a lot of
cosmetic changes. Most of them were pretty useless, but hey, i'm bored ;)
2004-12-25 Bart Hakvoort <gparted@users.sf.net>
* src/GParted_Core.cc,

View File

@ -38,6 +38,7 @@ public:
long heads ;
long sectors ;
long cylinders ;
long cylsize ;
Glib::ustring model;
Glib::ustring path;
Glib::ustring realpath;

View File

@ -26,7 +26,7 @@ namespace GParted
class Dialog_Partition_Copy : public Dialog_Base_Partition
{
public:
Dialog_Partition_Copy( const FS & fs, Sector cylinder_size ) ;
Dialog_Partition_Copy( const FS & fs, long cylinder_size ) ;
void Set_Data( const Partition & selected_partition, const Partition & copied_partition );
Partition Get_New_Partition( ) ;

View File

@ -26,13 +26,12 @@ namespace GParted
class Dialog_Partition_Resize_Move : public Dialog_Base_Partition
{
public:
Dialog_Partition_Resize_Move( const FS & fs, Sector cylinder_size ) ;
Dialog_Partition_Resize_Move( const FS & fs, long cylinder_size ) ;
void Set_Data( const Partition & selected_partition, const std::vector <Partition> & partitions ) ;
private:
void Resize_Move_Normal( const std::vector <Partition> & partitions ) ;
void Resize_Move_Extended( const std::vector <Partition> & partitions ) ;
};
} //GParted

View File

@ -49,10 +49,10 @@ public:
void Apply_Operation_To_Disk( Operation & operation );
bool Create( const Glib::ustring & device_path, Partition & new_partition ) ;
bool Create( const Device & device, Partition & new_partition ) ;
bool Convert_FS( const Glib::ustring & device_path, const Partition & partition ) ;
bool Delete( const Glib::ustring & device_path, const Partition & partition ) ;
bool Resize( const Glib::ustring & device_path, const Partition & partition_old, const Partition & partition_new ) ;
bool Resize( const Device & device, const Partition & partition_old, const Partition & partition_new ) ;
bool Copy( const Glib::ustring & dest_device_path, const Glib::ustring & src_part_path, Partition & partition_dest ) ;
bool Set_Disklabel( const Glib::ustring & device_path, const Glib::ustring & disklabel ) ;
@ -73,7 +73,6 @@ private:
void Show_Error( Glib::ustring message ) ;
void set_proper_filesystem( const Glib::ustring & filesystem ) ;
long Get_Cylinder_Size( const Glib::ustring & device_path ) ;
Glib::RefPtr<Gtk::TextBuffer> textbuffer;

View File

@ -39,15 +39,14 @@ class Operation
{
public:
Operation( const Glib::ustring device_path, Sector device_length, const Partition &, const Partition &, OperationType );
Operation( const Device & device, const Partition &, const Partition &, OperationType );
//this one can be a little confusing, it *DOES NOT* change any visual representation. It only applies the operation to the list with partitions.
//this new list can be used to change the visual representation. For real writing to disk, see Apply_To_Disk()
void Apply_Operation_To_Visual( std::vector<Partition> & partitions );
//public variables
Glib::ustring device_path ;
Sector device_length ;
Device device ;
OperationType operationtype;
Partition partition_original; //the original situation
Partition partition_new; //the new situation ( can be an whole new partition or simply the old one with a new size or.... )

View File

@ -43,7 +43,6 @@
#include <gtkmm/radiobutton.h>
#include <gtkmm/liststore.h>
#include <dlfcn.h>
#include <unistd.h> //should be included by gtkmm headers. but decided to include it anyway after getting some bugreports..
namespace GParted
@ -55,13 +54,13 @@ public:
Win_GParted( );
private:
void init_menubar() ;
void init_toolbar() ;
void init_popupmenu() ;
void init_convert_menu() ;
void init_device_info() ;
void init_operationslist() ;
void init_hpaned_main() ;
void init_menubar( ) ;
void init_toolbar( ) ;
void init_popupmenu( ) ;
void init_convert_menu( ) ;
void init_device_info( ) ;
void init_operationslist( ) ;
void init_hpaned_main( ) ;
void Refresh_OptionMenu( ) ;
void Show_Pulsebar( ) ;
@ -74,54 +73,52 @@ private:
void Add_Operation( OperationType, const Partition & );
void Refresh_Visual( );
bool Quit_Check_Operations();
void Set_Valid_Operations() ; //determines which operations are allowed on selected_partition
void Set_Valid_Convert_Filesystems() ; //determines to which filesystems a partition can be converted
bool Quit_Check_Operations( );
void Set_Valid_Operations( ) ; //determines which operations are allowed on selected_partition
void Set_Valid_Convert_Filesystems( ) ; //determines to which filesystems a partition can be converted
//convenience functions
void allow_new( bool b ) { menu_popup.items()[0].set_sensitive( b ); toolbar_main.get_nth_item(0) ->set_sensitive( b ); }
void allow_delete( bool b ) { menu_popup.items()[1].set_sensitive( b ); toolbar_main.get_nth_item(1) ->set_sensitive( b ); }
void allow_resize( bool b ) { menu_popup.items()[3].set_sensitive( b ); toolbar_main.get_nth_item(3) ->set_sensitive( b ); }
void allow_copy( bool b ) { menu_popup.items()[5].set_sensitive( b ); toolbar_main.get_nth_item(5) ->set_sensitive( b ); }
void allow_paste( bool b ) { menu_popup.items()[6].set_sensitive( b ); toolbar_main.get_nth_item(6) ->set_sensitive( b ); }
void allow_convert( bool b ) { menu_popup.items()[8].set_sensitive( b ); }
void allow_unmount( bool b ) { menu_popup.items()[10].set_sensitive( b ); }
void allow_undo( bool b ) { toolbar_main.get_nth_item(8) ->set_sensitive( b ); }
void allow_apply( bool b ) { toolbar_main.get_nth_item(9) ->set_sensitive( b ); }
void allow_new( bool b ) { menu_popup .items( )[ 0 ] .set_sensitive( b ); toolbar_main .get_nth_item( 0 ) ->set_sensitive( b ); }
void allow_delete( bool b ) { menu_popup .items( )[ 1 ] .set_sensitive( b ); toolbar_main .get_nth_item( 1 ) ->set_sensitive( b ); }
void allow_resize( bool b ) { menu_popup .items( )[ 3 ] .set_sensitive( b ); toolbar_main .get_nth_item( 3 ) ->set_sensitive( b ); }
void allow_copy( bool b ) { menu_popup .items( )[ 5 ] .set_sensitive( b ); toolbar_main .get_nth_item( 5 ) ->set_sensitive( b ); }
void allow_paste( bool b ) { menu_popup .items( )[ 6 ] .set_sensitive( b ); toolbar_main .get_nth_item( 6 ) ->set_sensitive( b ); }
void allow_convert( bool b ) { menu_popup .items( )[ 8 ] .set_sensitive( b ); }
void allow_unmount( bool b ) { menu_popup .items( )[ 10 ] .set_sensitive( b ); }
void allow_undo( bool b ) { toolbar_main .get_nth_item( 8 ) ->set_sensitive( b ); }
void allow_apply( bool b ) { toolbar_main .get_nth_item( 9 ) ->set_sensitive( b ); }
void find_devices_thread( ) { gparted_core .get_devices( devices ) ; pulse = false ; }
//signal handlers
void open_operationslist() ;
void close_operationslist() ;
void clear_operationslist() ;
void open_operationslist( ) ;
void close_operationslist( ) ;
void clear_operationslist( ) ;
void optionmenu_devices_changed( );
void menu_gparted_refresh_devices();
void menu_gparted_filesystems();
void menu_gparted_quit();
void menu_view_harddisk_info();
void menu_view_operations();
void menu_help_contents();
void menu_help_about();
void menu_gparted_refresh_devices( );
void menu_gparted_filesystems( );
void menu_gparted_quit( );
void menu_view_harddisk_info( );
void menu_view_operations( );
void menu_help_contents( );
void menu_help_about( );
void mouse_click( GdkEventButton*, const Partition & );
bool max_amount_prim_reached() ;
bool max_amount_prim_reached( ) ;
void activate_resize();
void activate_copy();
void activate_paste();
void activate_new();
void activate_delete();
void activate_info();
void activate_resize( );
void activate_copy( );
void activate_paste( );
void activate_new( );
void activate_delete( );
void activate_info( );
void activate_convert( const Glib::ustring & new_fs );
void activate_unmount( ) ;
void activate_undo();
void activate_apply();
void apply_operations_thread();
void activate_undo( );
void activate_apply( );
void apply_operations_thread( );
//private variables
unsigned int current_device ;
@ -166,11 +163,10 @@ private:
Gtk::TreeModelColumn<Glib::ustring> operation_description;
Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > operation_icon;
treeview_operations_Columns() { add( operation_number ); add( operation_description ); add(operation_icon);}
treeview_operations_Columns( ) { add( operation_number ); add( operation_description ); add( operation_icon ); }
};
treeview_operations_Columns treeview_operations_columns;
//usefull variables which are used by many different functions...
bool any_logic,any_extended;//used in some checks (e.g. see optionmenu_devices_changed()
unsigned short primary_count ;//primary_count checks for max. of 4 pimary partitions
@ -188,7 +184,6 @@ private:
Glib::Dispatcher dispatcher;
sigc::connection conn ;
bool apply, pulse ;
};
} //GParted

View File

@ -29,7 +29,7 @@ void Device::Reset( )
{
device_partitions .clear( ) ;
length = 0 ;
heads = sectors = cylinders = 0 ;
heads = sectors = cylinders = cylsize = 0 ;
model = path = realpath = disktype = "" ;
max_prims = 0 ;
busy = readonly = false ;

View File

@ -20,15 +20,11 @@
namespace GParted
{
Dialog_Partition_Copy::Dialog_Partition_Copy( const FS & fs, Sector cylinder_size )
Dialog_Partition_Copy::Dialog_Partition_Copy( const FS & fs, long cylinder_size )
{
this ->fs = fs ;
//some disk have a small cylindersize, for safetyreasons i keep this size at >=1
if ( cylinder_size < 2048 )
cylinder_size = 2048 ;
BUF = Sector_To_MB( cylinder_size ) ;
BUF = cylinder_size ;
Set_Resizer( false ) ;
Set_Confirm_Button( PASTE ) ;

View File

@ -20,15 +20,11 @@
namespace GParted
{
Dialog_Partition_Resize_Move::Dialog_Partition_Resize_Move( const FS & fs, Sector cylinder_size )
Dialog_Partition_Resize_Move::Dialog_Partition_Resize_Move( const FS & fs, long cylinder_size )
{
this ->fs = fs ;
//some disk have a small cylindersize, for safetyreasons i keep this size at >=1
if ( cylinder_size < 2048 )
cylinder_size = 2048 ;
BUF = Sector_To_MB( cylinder_size ) *2 ;
BUF = cylinder_size *2 ;
}
void Dialog_Partition_Resize_Move::Set_Data( const Partition & selected_partition, const std::vector <Partition> & partitions )

View File

@ -13,7 +13,7 @@ GParted_Core::GParted_Core( )
textbuffer = Gtk::TextBuffer::create( ) ;
//get valid flags ...
for ( PedPartitionFlag flag = ped_partition_flag_next ( (PedPartitionFlag) 0 ) ; flag ; flag = ped_partition_flag_next ( flag ) )
for ( PedPartitionFlag flag = ped_partition_flag_next( (PedPartitionFlag) NULL ) ; flag ; flag = ped_partition_flag_next( flag ) )
flags .push_back( flag ) ;
}
@ -93,8 +93,13 @@ void GParted_Core::get_devices( std::vector<Device> & devices )
temp_device .sectors = device ->bios_geom .sectors ;
temp_device .cylinders = device ->bios_geom .cylinders ;
temp_device .length = temp_device .heads * temp_device .sectors * temp_device .cylinders ;
temp_device .cylsize = Sector_To_MB( temp_device .heads * temp_device .sectors ) ;
//normal harddisk
//make sure cylsize is at least 1 MB
if ( temp_device .cylsize < 1 )
temp_device .cylsize = 1 ;
//normal harddisk
if ( disk )
{
temp_device .disktype = disk ->type ->name ;
@ -300,37 +305,37 @@ void GParted_Core::Apply_Operation_To_Disk( Operation & operation )
switch ( operation .operationtype )
{
case DELETE:
if ( ! Delete( operation .device_path, operation .partition_original ) )
if ( ! Delete( operation .device .path, operation .partition_original ) )
Show_Error( String::ucompose( _("Error while deleting %1"), operation .partition_original .partition ) ) ;
break;
case CREATE:
if ( ! Create( operation .device_path, operation .partition_new ) )
if ( ! Create( operation .device, operation .partition_new ) )
Show_Error( String::ucompose( _("Error while creating %1"), operation .partition_new .partition ) );
break;
case RESIZE_MOVE:
if ( ! Resize( operation .device_path, operation .partition_original, operation .partition_new ) )
if ( ! Resize( operation .device, operation .partition_original, operation .partition_new ) )
Show_Error( String::ucompose( _("Error while resizing/moving %1"), operation .partition_new .partition ) ) ;
break;
case CONVERT:
if ( ! Convert_FS( operation .device_path, operation .partition_new ) )
if ( ! Convert_FS( operation .device .path, operation .partition_new ) )
Show_Error( String::ucompose( _("Error while converting filesystem of %1"), operation .partition_new .partition ) ) ;
break;
case COPY:
if ( ! Copy( operation .device_path, operation .copied_partition_path, operation .partition_new ) )
if ( ! Copy( operation .device .path, operation .copied_partition_path, operation .partition_new ) )
Show_Error( String::ucompose( _("Error while copying %1"), operation .partition_new .partition ) ) ;
}
}
bool GParted_Core::Create( const Glib::ustring & device_path, Partition & new_partition )
bool GParted_Core::Create( const Device & device, Partition & new_partition )
{
if ( new_partition .type == GParted::EXTENDED )
return Create_Empty_Partition( device_path, new_partition ) ;
return Create_Empty_Partition( device .path, new_partition ) ;
else if ( Create_Empty_Partition( device_path, new_partition, ( new_partition .Get_Length_MB( ) - Get_Cylinder_Size( device_path ) ) < get_fs( new_partition .filesystem ) .MIN ) > 0 )
else if ( Create_Empty_Partition( device .path, new_partition, ( new_partition .Get_Length_MB( ) - device .cylsize ) < get_fs( new_partition .filesystem ) .MIN ) > 0 )
{
set_proper_filesystem( new_partition .filesystem ) ;
@ -338,7 +343,7 @@ bool GParted_Core::Create( const Glib::ustring & device_path, Partition & new_pa
if ( ! p_filesystem )
return true ;
return p_filesystem ->Create( device_path, new_partition ) ;
return p_filesystem ->Create( device .path, new_partition ) ;
}
return false ;
@ -382,17 +387,17 @@ bool GParted_Core::Delete( const Glib::ustring & device_path, const Partition &
return return_value ;
}
bool GParted_Core::Resize( const Glib::ustring & device_path, const Partition & partition_old, const Partition & partition_new )
bool GParted_Core::Resize( const Device & device, const Partition & partition_old, const Partition & partition_new )
{
if ( partition_old .type == GParted::EXTENDED )
return Resize_Container_Partition( device_path, partition_old, partition_new, false ) ;
return Resize_Container_Partition( device .path, partition_old, partition_new, false ) ;
//these 3 still use libparted's resizer.
else if ( partition_old .filesystem == "linux-swap" ||
partition_old .filesystem == "fat16" ||
partition_old .filesystem == "fat32"
)
return Resize_Normal_Using_Libparted( device_path, partition_old, partition_new ) ;
return Resize_Normal_Using_Libparted( device .path, partition_old, partition_new ) ;
//use custom resize tools..(afaik only resize, no moves)
else
@ -404,15 +409,15 @@ bool GParted_Core::Resize( const Glib::ustring & device_path, const Partition &
//shrinking
if ( partition_new .sector_end < partition_old .sector_end )
{
p_filesystem ->cylinder_size = Get_Cylinder_Size( device_path ) ;
p_filesystem ->cylinder_size = device .cylsize ;
if ( p_filesystem ->Resize( partition_new ) )
Resize_Container_Partition( device_path, partition_old, partition_new ) ;
Resize_Container_Partition( device .path, partition_old, partition_new ) ;
}
//growing
if ( partition_new .sector_end > partition_old .sector_end )
Resize_Container_Partition( device_path, partition_old, partition_new ) ;
Resize_Container_Partition( device .path, partition_old, partition_new ) ;
p_filesystem ->Check_Repair( partition_new ) ;
@ -729,18 +734,4 @@ void GParted_Core::set_proper_filesystem( const Glib::ustring & filesystem )
p_filesystem ->textbuffer = textbuffer ;
}
long GParted_Core::Get_Cylinder_Size( const Glib::ustring & device_path )
{
long cylinder_size = 0 ;
if ( open_device( device_path, device ) )
{
cylinder_size = Sector_To_MB( device ->bios_geom .heads * device ->bios_geom .sectors ) ;
close_device_and_disk( device, disk ) ;
}
return cylinder_size ;
}
} //GParted

View File

@ -19,11 +19,9 @@
namespace GParted
{
Operation::Operation( const Glib::ustring device_path, Sector device_length, const Partition & partition_original, const Partition & partition_new, OperationType operationtype )
Operation::Operation( const Device & device, const Partition & partition_original, const Partition & partition_new, OperationType operationtype )
{
this ->device_path = device_path ;
this ->device_length = device_length ;
this ->device = device ;
this ->partition_original = partition_original;
this ->partition_new = partition_new;
this ->operationtype = operationtype;
@ -51,7 +49,7 @@ Glib::ustring Operation::Get_String( )
temp = partition_original .partition ;
/*TO TRANSLATORS: looks like Delete /dev/hda2 (ntfs, 2345 MB) from /dev/hda */
return String::ucompose( _("Delete %1 (%2, %3 MB) from %4"), temp, partition_original .filesystem, partition_original .Get_Length_MB( ), device_path ) ;
return String::ucompose( _("Delete %1 (%2, %3 MB) from %4"), temp, partition_original .filesystem, partition_original .Get_Length_MB( ), device .path ) ;
case CREATE : switch( partition_new.type )
{
@ -61,7 +59,7 @@ Glib::ustring Operation::Get_String( )
default : break;
}
/*TO TRANSLATORS: looks like Create Logical Partition #1 (ntfs, 2345 MB) on /dev/hda */
return String::ucompose( _("Create %1 #%2 (%3, %4 MB) on %5"), temp, partition_new.partition_number, partition_new.filesystem , partition_new .Get_Length_MB( ), device_path ) ;
return String::ucompose( _("Create %1 #%2 (%3, %4 MB) on %5"), temp, partition_new.partition_number, partition_new.filesystem , partition_new .Get_Length_MB( ), device .path ) ;
case RESIZE_MOVE: //if startsector has changed >= 1 MB we consider it a move
diff = Abs( partition_new .sector_start - partition_original .sector_start ) ;
if ( diff >= MEGABYTE )
@ -89,7 +87,7 @@ Glib::ustring Operation::Get_String( )
case CONVERT : /*TO TRANSLATORS: looks like Convert /dev/hda4 from ntfs to linux-swap */
return String::ucompose( _( "Convert %1 from %2 to %3"), partition_original .partition, partition_original .filesystem, partition_new .filesystem ) ;
case COPY : /*TO TRANSLATORS: looks like Copy /dev/hda4 to /dev/hdd (start at 2500 MB) */
return String::ucompose( _("Copy %1 to %2 (start at %3 MB)"), partition_new .partition, device_path, Sector_To_MB( partition_new .sector_start ) ) ;
return String::ucompose( _("Copy %1 to %2 (start at %3 MB)"), partition_new .partition, device .path, Sector_To_MB( partition_new .sector_start ) ) ;
default : return "";
}
@ -178,7 +176,7 @@ void Operation::Apply_Delete_To_Visual( std::vector<Partition> & partitions )
{
partitions .erase( partitions .begin( ) + Get_Index_Original( partitions ) );
Insert_Unallocated( partitions, 0, device_length -1, false ) ;
Insert_Unallocated( partitions, 0, device .length -1, false ) ;
}
else
{
@ -204,7 +202,7 @@ void Operation::Apply_Create_To_Visual( std::vector<Partition> & partitions )
{
partitions[ Get_Index_Original( partitions ) ] = partition_new ;
Insert_Unallocated( partitions, 0, device_length -1, false ) ;
Insert_Unallocated( partitions, 0, device .length -1, false ) ;
}
else
{
@ -231,7 +229,7 @@ void Operation::Apply_Resize_Move_Extended_To_Visual( std::vector<Partition> & p
partitions[ ext ] .sector_start = partition_new .sector_start ;
partitions[ ext ] .sector_end = partition_new .sector_end ;
Insert_Unallocated( partitions, 0, device_length -1, false ) ;
Insert_Unallocated( partitions, 0, device .length -1, false ) ;
//stuff INSIDE extended partition
ext = 0 ;

View File

@ -157,7 +157,7 @@ void Win_GParted::init_popupmenu()
{
//fill menu_popup
menu_popup.items().push_back( Gtk::Menu_Helpers::StockMenuElem( Gtk::Stock::NEW, sigc::mem_fun(*this, &Win_GParted::activate_new) ) );
menu_popup.items().push_back( Gtk::Menu_Helpers::StockMenuElem( Gtk::Stock::DELETE, Gtk::AccelKey( 0xFFFF, Gdk::BUTTON1_MASK ), sigc::mem_fun(*this, &Win_GParted::activate_delete) ) );
menu_popup.items().push_back( Gtk::Menu_Helpers::StockMenuElem( Gtk::Stock::DELETE, Gtk::AccelKey( 0xFFFF, Gdk::BUTTON1_MASK ), sigc::mem_fun(*this, &Win_GParted::activate_delete) ) );
menu_popup.items().push_back( Gtk::Menu_Helpers::SeparatorElem() );
image = manage( new Gtk::Image( Gtk::Stock::GOTO_LAST, Gtk::ICON_SIZE_MENU ) );
menu_popup.items().push_back( Gtk::Menu_Helpers::ImageMenuElem( _("Resize/Move"), *image, sigc::mem_fun(*this, &Win_GParted::activate_resize) ) );
@ -237,124 +237,124 @@ void Win_GParted::init_device_info()
vbox_info .pack_start( *table, Gtk::PACK_SHRINK );
//DETAILED DEVICE INFO
top =0; bottom = 1;
table = manage( new Gtk::Table() ) ;
table ->set_col_spacings(10 ) ;
top = 0; bottom = 1;
table = manage( new Gtk::Table( ) ) ;
table ->set_col_spacings( 10 ) ;
//one blank line
table ->attach( * mk_label( "" ), 1,2, top++, bottom++,Gtk::FILL);
table ->attach( * mk_label( "" ), 1, 2, top++, bottom++, Gtk::FILL );
//disktype
table ->attach( * mk_label( " <b>" + (Glib::ustring) _( "DiskType:" ) + "</b>" ) , 0,1,top, bottom ,Gtk::FILL);
table ->attach( * mk_label( " <b>" + (Glib::ustring) _( "DiskType:" ) + "</b>" ) , 0, 1, top, bottom, Gtk::FILL );
device_info .push_back( mk_label( "" ) ) ;
table ->attach( * device_info .back(), 1,2, top++, bottom++, Gtk::FILL);
table ->attach( * device_info .back( ), 1, 2, top++, bottom++, Gtk::FILL );
//heads
table ->attach( * mk_label( " <b>" + (Glib::ustring) _( "Heads:" ) + "</b>" ) , 0,1,top, bottom ,Gtk::FILL);
table ->attach( * mk_label( " <b>" + (Glib::ustring) _( "Heads:" ) + "</b>" ) , 0, 1, top, bottom, Gtk::FILL );
device_info .push_back( mk_label( "" ) ) ;
table ->attach( * device_info .back(), 1,2, top++, bottom++, Gtk::FILL);
table ->attach( * device_info .back( ), 1, 2, top++, bottom++, Gtk::FILL );
//sectors/track
table ->attach( * mk_label( " <b>" + (Glib::ustring) _( "Sectors/Track:" ) + "</b>" ) , 0,1,top, bottom ,Gtk::FILL);
table ->attach( * mk_label( " <b>" + (Glib::ustring) _( "Sectors/Track:" ) + "</b>" ) , 0, 1, top, bottom, Gtk::FILL );
device_info .push_back( mk_label( "" ) ) ;
table ->attach( * device_info .back(), 1,2, top++, bottom++, Gtk::FILL);
table ->attach( * device_info .back( ), 1, 2, top++, bottom++, Gtk::FILL );
//cylinders
table ->attach( * mk_label( " <b>" + (Glib::ustring) _( "Cylinders:" ) + "</b>" ) , 0,1,top, bottom ,Gtk::FILL);
table ->attach( * mk_label( " <b>" + (Glib::ustring) _( "Cylinders:" ) + "</b>" ) , 0, 1, top, bottom, Gtk::FILL );
device_info .push_back( mk_label( "" ) ) ;
table ->attach( * device_info .back(), 1,2, top++, bottom++, Gtk::FILL);
table ->attach( * device_info .back( ), 1, 2, top++, bottom++, Gtk::FILL );
//total sectors
table ->attach( * mk_label( " <b>" + (Glib::ustring) _( "Total Sectors:" ) + "</b>" ) , 0,1,top, bottom ,Gtk::FILL);
table ->attach( * mk_label( " <b>" + (Glib::ustring) _( "Total Sectors:" ) + "</b>" ) , 0, 1, top, bottom, Gtk::FILL );
device_info .push_back( mk_label( "" ) ) ;
table ->attach( * device_info .back(), 1,2, top++, bottom++, Gtk::FILL);
table ->attach( * device_info .back( ), 1, 2, top++, bottom++, Gtk::FILL );
vbox_info .pack_start( *table, Gtk::PACK_SHRINK );
}
void Win_GParted::init_operationslist()
void Win_GParted::init_operationslist( )
{
//create listview for pending operations
liststore_operations = Gtk::ListStore::create( treeview_operations_columns );
treeview_operations.set_model( liststore_operations );
treeview_operations.set_headers_visible( false );
treeview_operations.append_column( "", treeview_operations_columns.operation_number );
treeview_operations.append_column( "", treeview_operations_columns.operation_description );
treeview_operations.get_column( 0 ) ->pack_start( treeview_operations_columns.operation_icon,false );
treeview_operations.get_selection() -> set_mode( Gtk::SELECTION_NONE );
treeview_operations .set_model( liststore_operations );
treeview_operations .set_headers_visible( false );
treeview_operations .append_column( "", treeview_operations_columns .operation_number );
treeview_operations .append_column( "", treeview_operations_columns .operation_description );
treeview_operations .get_column( 0 ) ->pack_start( treeview_operations_columns .operation_icon, false );
treeview_operations .get_selection( ) ->set_mode( Gtk::SELECTION_NONE );
//init scrollwindow_operations
scrollwindow = manage( new Gtk::ScrolledWindow() ) ;
scrollwindow ->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
scrollwindow ->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
scrollwindow = manage( new Gtk::ScrolledWindow( ) ) ;
scrollwindow ->set_shadow_type( Gtk::SHADOW_ETCHED_IN );
scrollwindow ->set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC );
scrollwindow ->add ( treeview_operations ) ;
//set up the close and clear buttons and pack them in a vbox
vbox = manage( new Gtk::VBox() ) ;
vbox = manage( new Gtk::VBox( ) ) ;
//CLOSE
button = manage( new Gtk::Button() );
button = manage( new Gtk::Button( ) );
image = manage( new Gtk::Image( Gtk::Stock::CLOSE, Gtk::ICON_SIZE_MENU ) );
button ->add( *image ) ;
button ->set_relief( Gtk::RELIEF_NONE );
tooltips .set_tip( *button, _("Hide operationslist") );
button ->signal_clicked().connect( sigc::mem_fun( *this, &Win_GParted::close_operationslist ) );
button ->signal_clicked( ) .connect( sigc::mem_fun( *this, &Win_GParted::close_operationslist ) );
vbox ->pack_start( *button, Gtk::PACK_SHRINK );
//CLEAR
button = manage( new Gtk::Button() );
button = manage( new Gtk::Button( ) );
image = manage( new Gtk::Image( Gtk::Stock::CLEAR, Gtk::ICON_SIZE_MENU ) );
button ->add( *image ) ;
button ->set_relief( Gtk::RELIEF_NONE );
tooltips .set_tip( *button, _("Clear operationslist") );
button ->signal_clicked().connect( sigc::mem_fun( *this, &Win_GParted::clear_operationslist ) );
button ->signal_clicked( ) .connect( sigc::mem_fun( *this, &Win_GParted::clear_operationslist ) );
vbox ->pack_start( *button, Gtk::PACK_SHRINK );
//add vbox and scrollwindow_operations to hbox_operations
hbox_operations .pack_start( *vbox, Gtk::PACK_SHRINK );
hbox_operations .pack_start( *scrollwindow, Gtk::PACK_EXPAND_WIDGET );
hbox_operations .pack_start( *scrollwindow, Gtk::PACK_EXPAND_WIDGET );
}
void Win_GParted::init_hpaned_main()
void Win_GParted::init_hpaned_main( )
{
//left scrollwindow (holds device info)
scrollwindow = manage( new Gtk::ScrolledWindow() ) ;
scrollwindow ->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
scrollwindow ->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
scrollwindow = manage( new Gtk::ScrolledWindow( ) ) ;
scrollwindow ->set_shadow_type( Gtk::SHADOW_ETCHED_IN );
scrollwindow ->set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC );
hpaned_main.pack1( *scrollwindow, true,true );
hpaned_main.pack1( *scrollwindow, true, true );
scrollwindow ->add( vbox_info );
//right scrollwindow (holds treeview with partitions)
scrollwindow = manage( new Gtk::ScrolledWindow() ) ;
scrollwindow ->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
scrollwindow ->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
scrollwindow = manage( new Gtk::ScrolledWindow( ) ) ;
scrollwindow ->set_shadow_type( Gtk::SHADOW_ETCHED_IN );
scrollwindow ->set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC );
//connect signal and add treeview_detail
treeview_detail .signal_mouse_click.connect( sigc::mem_fun( this, &Win_GParted::mouse_click) );
scrollwindow ->add ( treeview_detail );
treeview_detail .signal_mouse_click .connect( sigc::mem_fun( this, &Win_GParted::mouse_click ) );
scrollwindow ->add( treeview_detail );
hpaned_main.pack2( *scrollwindow, true,true );
}
void Win_GParted::Refresh_OptionMenu( )
{
//fill optionmenu_devices
menu_devices.items() .clear() ;
for ( unsigned int i=0;i<devices.size();i++ )
menu_devices .items( ) .clear( ) ;
for ( unsigned int i = 0 ; i < devices .size( ) ; i++ )
{
hbox = manage( new Gtk::HBox() );
hbox = manage( new Gtk::HBox( ) );
//the image...
image = manage( new Gtk::Image( "/usr/share/icons/gnome/24x24/devices/gnome-dev-harddisk.png" ) );
hbox ->pack_start( *image, Gtk::PACK_SHRINK );
//the label...
hbox ->pack_start( *mk_label( " " + devices[i] .path + "\t(" + String::ucompose( _("%1 MB"), Sector_To_MB( devices[i] .length ) ) + ")" ), Gtk::PACK_SHRINK );
hbox ->pack_start( *mk_label( " " + devices[ i ] .path + "\t(" + String::ucompose( _("%1 MB"), Sector_To_MB( devices[ i ] .length ) ) + ")" ), Gtk::PACK_SHRINK );
menu_item = manage( new Gtk::MenuItem( *hbox ) ) ;
menu_devices .items().push_back( *menu_item );
}
menu_devices .show_all_children();
menu_devices .show_all_children( );
optionmenu_devices .set_history( current_device ) ;
}
@ -412,14 +412,14 @@ void Win_GParted::Fill_Label_Device_Info( )
device_info[ t++ ] ->set_text( num_to_str( devices[ current_device ] .length ) );
}
bool Win_GParted::on_delete_event(GdkEventAny *event)
bool Win_GParted::on_delete_event( GdkEventAny *event )
{
return ! Quit_Check_Operations();
return ! Quit_Check_Operations( );
}
void Win_GParted::Add_Operation( OperationType operationtype, const Partition & new_partition)
{
Operation operation( devices[ current_device ] .path, devices[ current_device ] .length, selected_partition, new_partition, operationtype );
Operation operation( devices[ current_device ], selected_partition, new_partition, operationtype );
operations.push_back( operation );
@ -428,7 +428,7 @@ void Win_GParted::Add_Operation( OperationType operationtype, const Partition &
Refresh_Visual( );
if ( operations.size() == 1 ) //first operation, open operationslist
if ( operations .size( ) == 1 ) //first operation, open operationslist
open_operationslist( ) ;
//make scrollwindow focus on the last operation in the list
@ -439,16 +439,16 @@ void Win_GParted::Add_Operation( OperationType operationtype, const Partition &
void Win_GParted::Refresh_Visual( )
{
std::vector<Partition> partitions = devices[current_device] .device_partitions ;
liststore_operations ->clear();
std::vector<Partition> partitions = devices[ current_device ] .device_partitions ;
liststore_operations ->clear( );
//make all operations visible
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 ) ;
treerow = *(liststore_operations ->append( ));
treerow = *( liststore_operations ->append( ) );
treerow[ treeview_operations_columns .operation_number ] = t +1;
treerow[ treeview_operations_columns .operation_description ] = operations[ t ] .str_operation ;
switch ( operations[ t ] .operationtype )
@ -518,7 +518,7 @@ void Win_GParted::Refresh_Visual( )
allow_new( false ); allow_delete( false ); allow_resize( false ); allow_copy( false ); allow_paste( false );
}
bool Win_GParted::Quit_Check_Operations()
bool Win_GParted::Quit_Check_Operations( )
{
if ( operations .size( ) )
{
@ -540,7 +540,7 @@ bool Win_GParted::Quit_Check_Operations()
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_paste( false ); allow_convert( false ); allow_unmount( false ) ;
@ -562,13 +562,8 @@ void Win_GParted::Set_Valid_Operations()
//find out if there is a copied partition and if it fits inside this unallocated space
if ( copied_partition .partition != "NONE" && ! devices[ current_device ] .readonly )
{
//calculate cylindersize
long cylinder_size = Sector_To_MB( devices[ current_device ] .heads * devices[ current_device ] .sectors ) ;
if ( cylinder_size < 1 )
cylinder_size = 1 ;
if ( (copied_partition .Get_Length_MB( ) + cylinder_size) < selected_partition .Get_Length_MB( ) ||
(copied_partition .filesystem == "xfs" && (copied_partition .Get_Used_MB( ) + cylinder_size) < selected_partition .Get_Length_MB( ) )
if ( (copied_partition .Get_Length_MB( ) + devices[ current_device ] .cylsize) < selected_partition .Get_Length_MB( ) ||
(copied_partition .filesystem == "xfs" && (copied_partition .Get_Used_MB( ) + devices[ current_device ] .cylsize) < selected_partition .Get_Length_MB( ) )
)
allow_paste( true ) ;
}
@ -608,7 +603,7 @@ void Win_GParted::Set_Valid_Operations()
}
}
void Win_GParted::Set_Valid_Convert_Filesystems()
void Win_GParted::Set_Valid_Convert_Filesystems( )
{
//disable conversion to the same filesystem
for ( unsigned int t = 0 ; t < gparted_core .get_filesystems( ) .size( ) -1 ; t++ )
@ -620,7 +615,7 @@ void Win_GParted::Set_Valid_Convert_Filesystems()
}
}
void Win_GParted::open_operationslist()
void Win_GParted::open_operationslist( )
{
hbox_operations .show( ) ;
int x,y; this ->get_size( x, y );
@ -636,7 +631,7 @@ void Win_GParted::open_operationslist()
( (Gtk::CheckMenuItem *) & menubar_main .items( ) [ 1 ] .get_submenu( ) ->items( ) [ 1 ] ) ->set_active( true ) ;
}
void Win_GParted::close_operationslist()
void Win_GParted::close_operationslist( )
{
int x,y; this ->get_size( x, y );
y -= 210 ; //height of whole app - menubar - visualdisk - statusbar ....
@ -651,7 +646,7 @@ void Win_GParted::close_operationslist()
( (Gtk::CheckMenuItem *) & menubar_main .items( ) [ 1 ] .get_submenu( ) ->items() [ 1 ] ) ->set_active( false ) ;
}
void Win_GParted::clear_operationslist()
void Win_GParted::clear_operationslist( )
{
operations .clear( ) ;
Refresh_Visual( ) ;
@ -669,7 +664,7 @@ void Win_GParted::optionmenu_devices_changed( )
Refresh_Visual( );
}
void Win_GParted::menu_gparted_refresh_devices()
void Win_GParted::menu_gparted_refresh_devices( )
{
//find out if there was any change in available devices (think about flexible media like zipdisks/usbsticks/whatever ;-) )
thread = Glib::Thread::create( SigC::slot_class( *this, &Win_GParted::find_devices_thread ), true );
@ -701,7 +696,7 @@ void Win_GParted::menu_gparted_refresh_devices()
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( ) ;
}
}
@ -718,13 +713,13 @@ void Win_GParted::menu_gparted_filesystems( )
}
}
void Win_GParted::menu_gparted_quit()
void Win_GParted::menu_gparted_quit( )
{
if ( Quit_Check_Operations( ) )
this ->hide( );
}
void Win_GParted::menu_view_harddisk_info()
void Win_GParted::menu_view_harddisk_info( )
{
if ( ( (Gtk::CheckMenuItem *) & menubar_main .items( ) [ 1 ] .get_submenu( ) ->items( ) [ 0 ] ) ->get_active( ) )
{ //open harddisk information
@ -748,7 +743,7 @@ void Win_GParted::menu_view_harddisk_info()
}
}
void Win_GParted::menu_view_operations()
void Win_GParted::menu_view_operations( )
{
if ( ( (Gtk::CheckMenuItem *) & menubar_main .items( ) [ 1 ] .get_submenu( ) ->items( ) [ 1 ] ) ->get_active( ) )
open_operationslist( ) ;
@ -756,7 +751,7 @@ void Win_GParted::menu_view_operations()
close_operationslist( ) ;
}
void Win_GParted::menu_help_contents()
void Win_GParted::menu_help_contents( )
{
str_temp = _("Sorry, not yet implemented.") ;
str_temp += "\n" ;
@ -766,7 +761,7 @@ void Win_GParted::menu_help_contents()
}
void Win_GParted::menu_help_about()
void Win_GParted::menu_help_about( )
{
Dialog_About dialog ;
dialog .set_transient_for( *this ) ;
@ -806,7 +801,7 @@ bool Win_GParted::max_amount_prim_reached( )
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, str_temp, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true ) ;
dialog.run( ) ;
dialog .run( ) ;
return true ;
}
@ -845,10 +840,10 @@ void Win_GParted::activate_resize()
if ( operations .size( ) )
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 ) ;
Dialog_Partition_Resize_Move dialog( gparted_core .get_fs( selected_partition .filesystem ), devices[ current_device ] .heads * devices[ current_device ] .sectors ) ;
Dialog_Partition_Resize_Move dialog( gparted_core .get_fs( selected_partition .filesystem ), devices[ current_device ] .cylsize ) ;
if ( selected_partition .type == GParted::LOGICAL )
{
@ -887,16 +882,16 @@ void Win_GParted::activate_resize()
}
}
void Win_GParted::activate_copy()
void Win_GParted::activate_copy( )
{
copied_partition = selected_partition ;
}
void Win_GParted::activate_paste()
void Win_GParted::activate_paste( )
{
if ( ! max_amount_prim_reached( ) )
{
Dialog_Partition_Copy dialog( gparted_core .get_fs( selected_partition .filesystem ), devices[ current_device ] .heads * devices[ current_device ] .sectors ) ;
Dialog_Partition_Copy dialog( gparted_core .get_fs( copied_partition .filesystem ), devices[ current_device ] .cylsize ) ;
copied_partition .error .clear( ) ; //we don't need the errors of the source partition.
dialog .Set_Data( selected_partition, copied_partition ) ;
dialog .set_transient_for( *this );
@ -933,12 +928,7 @@ void Win_GParted::activate_new()
{
Dialog_Partition_New dialog;
//calculate cylindersize
long cylinder_size = Sector_To_MB( devices[ current_device ] .heads * devices[ current_device ] .sectors ) ;
if ( cylinder_size < 1 )
cylinder_size = 1 ;
dialog .Set_Data( selected_partition, any_extended, new_count, gparted_core .get_filesystems( ), devices [ current_device ] .readonly, cylinder_size ) ;
dialog .Set_Data( selected_partition, any_extended, new_count, gparted_core .get_filesystems( ), devices [ current_device ] .readonly, devices [ current_device ] .cylsize ) ;
dialog .set_transient_for( *this );
if ( dialog .run( ) == Gtk::RESPONSE_OK )
@ -963,7 +953,7 @@ void Win_GParted::activate_delete()
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 ) ;
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 ) ;
dialog .run( ) ;
return;
@ -980,13 +970,13 @@ void Win_GParted::activate_delete()
Gtk::MessageDialog dialog( *this, str_temp, true, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_NONE, true);
/*TO TRANSLATORS: dialogtitle, looks like Delete /dev/hda2 (ntfs, 2345 MB) */
dialog .set_title( String::ucompose( _("Delete %1 (%2, %3 MB)"), selected_partition .partition, selected_partition .filesystem, selected_partition .Get_Length_MB() ) );
dialog.add_button( Gtk::Stock::CANCEL,Gtk::RESPONSE_CANCEL );
dialog.add_button( Gtk::Stock::DELETE, Gtk::RESPONSE_OK );
dialog .add_button( Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL );
dialog .add_button( Gtk::Stock::DELETE, Gtk::RESPONSE_OK );
dialog.show_all_children();
if ( dialog.run() == Gtk::RESPONSE_OK )
dialog .show_all_children( );
if ( dialog .run( ) == Gtk::RESPONSE_OK )
{
dialog.hide() ;//i want to be sure the dialog is gone _before_ operationslist shows up (only matters if first operation)
dialog .hide( ) ;//i want to be sure the dialog is gone _before_ operationslist shows up (only matters if first operation)
//if deleted partition was on the clipboard we erase it...
if ( selected_partition .partition == copied_partition .partition )
@ -997,39 +987,33 @@ void Win_GParted::activate_delete()
if ( selected_partition .status == GParted::STAT_NEW )
{
//remove all operations done on this new partition (this includes creation)
for ( int t=0;t<(int) operations.size() ; t++ ) //i removed the unsigned 'cause t will be negative at times...
{
if ( operations[t] .partition_new .partition == selected_partition .partition )
{
operations.erase( operations .begin( ) + t ) ;
t-- ;
}
}
for ( int t = 0 ; t < (int) operations .size( ) ; t++ ) //I removed the unsigned because t will be negative at times...
if ( operations[ t ] .partition_new .partition == selected_partition .partition )
operations.erase( operations .begin( ) + t-- ) ;
//determine lowest possible new_count
new_count = 0 ;
for ( unsigned int t=0;t<operations.size() ; t++ )
if ( operations[t] .partition_new .status == GParted::STAT_NEW && operations[t] .partition_new .partition_number > new_count )
new_count = operations[t] .partition_new .partition_number ;
for ( unsigned int t = 0 ; t < operations .size( ) ; t++ )
if ( operations[ t ] .partition_new .status == GParted::STAT_NEW && operations[ t ] .partition_new .partition_number > new_count )
new_count = operations[ t ] .partition_new .partition_number ;
new_count += 1 ;
Refresh_Visual( );
if ( ! operations .size() )
close_operationslist() ;
if ( ! operations .size( ) )
close_operationslist( ) ;
}
else //deletion of a real partition...
Add_Operation( GParted::DELETE, selected_partition ); //in this case selected_partition is just a "dummy"
}
}
void Win_GParted::activate_info()
void Win_GParted::activate_info( )
{
Dialog_Partition_Info dialog( selected_partition );
dialog.set_transient_for( *this );
dialog.run();
dialog .set_transient_for( *this );
dialog .run( );
}
void Win_GParted::activate_convert( const Glib::ustring & new_fs )
@ -1078,15 +1062,15 @@ void Win_GParted::activate_convert( const Glib::ustring & new_fs )
if ( selected_partition .status == GParted::STAT_NEW )
{
//remove operation which creates this partition
for ( unsigned int t=0;t<operations.size() ; t++ )
for ( unsigned int t = 0 ; t < operations .size( ) ; t++ )
{
if ( operations[t] .partition_new .partition == selected_partition .partition )
if ( operations[ t ] .partition_new .partition == selected_partition .partition )
{
operations.erase( operations .begin() +t ) ;
operations .erase( operations .begin( ) +t ) ;
//And add the new partition to the end of the operations list (NOTE: in this case we set status to STAT_NEW)
part_temp .status = STAT_NEW ;
Add_Operation( GParted::CREATE, part_temp);
Add_Operation( GParted::CREATE, part_temp );
break;
}
@ -1121,29 +1105,28 @@ void Win_GParted::activate_unmount( )
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
if ( operations.back() .operationtype == GParted::CREATE )
if ( operations .back( ) .operationtype == GParted::CREATE )
new_count-- ;
operations.erase( operations.end() );
operations.erase( operations .end( ) );
Refresh_Visual();
if ( ! operations .size() )
close_operationslist() ;
Refresh_Visual( );
if ( ! operations .size( ) )
close_operationslist( ) ;
}
void Win_GParted::activate_apply()
void Win_GParted::activate_apply( )
{
str_temp = "<span weight=\"bold\" size=\"larger\">" ;
str_temp += _( "Are you sure you want to apply the pending operations?" ) ;
str_temp += "</span>\n\n" ;
str_temp += _( "It is recommended to backup valueable data before proceeding.") ;
Gtk::MessageDialog dialog( *this, str_temp, true, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE, true);
Gtk::MessageDialog dialog( *this, str_temp, true, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE, true );
dialog .set_title( _( "Apply operations to harddisk" ) );
dialog .add_button( Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL );
@ -1159,7 +1142,7 @@ void Win_GParted::activate_apply()
conn = dispatcher .connect( sigc::mem_fun(*dialog_progress, &Dialog_Progress::Set_Operation) );
thread = Glib::Thread::create(SigC::slot_class(*this, &Win_GParted::apply_operations_thread), true);
thread = Glib::Thread::create( SigC::slot_class( *this, &Win_GParted::apply_operations_thread ), true );
dialog_progress ->set_transient_for( *this );
while ( dialog_progress ->run( ) != Gtk::RESPONSE_OK )
@ -1170,12 +1153,12 @@ void Win_GParted::activate_apply()
thread ->join( ) ;
conn .disconnect( ) ;
//find out if any of the involved devices is busy
//find out if any of the involved devices is busy
bool any_busy = false ;
for ( unsigned int t = 0; t < devices .size( ) && ! any_busy; t++ )
if ( devices[ t ] .busy )
for (unsigned int i = 0; i < operations .size( ) && ! any_busy; i++ )
if ( operations[ i ] .device_path == devices[ t ] .path )
if ( operations[ i ] .device .path == devices[ t ] .path )
any_busy = true ;
//show warning if necessary