construct operations in the activate*() functions instead of in
* include/Win_GParted.h, src/Win_GParted.cc: construct operations in the activate*() functions instead of in Add_Operation(). This approach allows for more customization of operations.
This commit is contained in:
parent
b0d6109ed0
commit
b42982b884
|
@ -1,3 +1,10 @@
|
||||||
|
2006-08-01 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||||
|
|
||||||
|
* include/Win_GParted.h,
|
||||||
|
src/Win_GParted.cc: construct operations in the activate*()
|
||||||
|
functions instead of in Add_Operation(). This approach allows for
|
||||||
|
more customization of operations.
|
||||||
|
|
||||||
2006-08-01 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
2006-08-01 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||||
|
|
||||||
* src/GParted_Core.cc: made set_partition_type() a bit more verbose
|
* src/GParted_Core.cc: made set_partition_type() a bit more verbose
|
||||||
|
|
|
@ -63,10 +63,7 @@ private:
|
||||||
//Fill txtview_device_info_buffer with some information about the selected device
|
//Fill txtview_device_info_buffer with some information about the selected device
|
||||||
void Fill_Label_Device_Info( bool clear = false );
|
void Fill_Label_Device_Info( bool clear = false );
|
||||||
|
|
||||||
void Add_Operation( OperationType operationtype,
|
void Add_Operation( Operation * operation, int index = -1 ) ;
|
||||||
const Partition & new_partition,
|
|
||||||
Sector block_size = -1,
|
|
||||||
int index = -1 ) ;
|
|
||||||
void Refresh_Visual();
|
void Refresh_Visual();
|
||||||
bool Quit_Check_Operations();
|
bool Quit_Check_Operations();
|
||||||
void set_valid_operations() ;
|
void set_valid_operations() ;
|
||||||
|
|
|
@ -575,49 +575,8 @@ bool Win_GParted::on_delete_event( GdkEventAny *event )
|
||||||
return ! Quit_Check_Operations();
|
return ! Quit_Check_Operations();
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIXME: i guess it's better if we just create the operations in the activate_* functions instead
|
void Win_GParted::Add_Operation( Operation * operation, int index )
|
||||||
//of doing it here. now we're adding more and more functionality (e.g. blocksize) to the operations
|
|
||||||
//the current approach doesn't suffice anymore.
|
|
||||||
void Win_GParted::Add_Operation( OperationType operationtype,
|
|
||||||
const Partition & new_partition,
|
|
||||||
Sector block_size,
|
|
||||||
int index )
|
|
||||||
{
|
{
|
||||||
Operation * operation ;
|
|
||||||
switch ( operationtype )
|
|
||||||
{
|
|
||||||
case OPERATION_DELETE :
|
|
||||||
operation = new OperationDelete( devices[ current_device ], selected_partition ) ;
|
|
||||||
operation ->icon = render_icon( Gtk::Stock::DELETE, Gtk::ICON_SIZE_MENU ) ;
|
|
||||||
break;
|
|
||||||
case OPERATION_CREATE :
|
|
||||||
operation = new OperationCreate( devices[ current_device ],
|
|
||||||
selected_partition,
|
|
||||||
new_partition ) ;
|
|
||||||
operation ->icon = render_icon( Gtk::Stock::NEW, Gtk::ICON_SIZE_MENU );
|
|
||||||
break;
|
|
||||||
case OPERATION_RESIZE_MOVE:
|
|
||||||
operation = new OperationResizeMove( devices[ current_device ],
|
|
||||||
selected_partition,
|
|
||||||
new_partition );
|
|
||||||
operation ->icon = render_icon( Gtk::Stock::GOTO_LAST, Gtk::ICON_SIZE_MENU );
|
|
||||||
break;
|
|
||||||
case OPERATION_FORMAT :
|
|
||||||
operation = new OperationFormat( devices[ current_device ],
|
|
||||||
selected_partition,
|
|
||||||
new_partition );
|
|
||||||
operation ->icon = render_icon( Gtk::Stock::CONVERT, Gtk::ICON_SIZE_MENU );
|
|
||||||
break;
|
|
||||||
case OPERATION_COPY :
|
|
||||||
operation = new OperationCopy( devices[ current_device ],
|
|
||||||
selected_partition,
|
|
||||||
new_partition,
|
|
||||||
copied_partition,
|
|
||||||
block_size ) ;
|
|
||||||
operation ->icon = render_icon( Gtk::Stock::COPY, Gtk::ICON_SIZE_MENU );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( operation )
|
if ( operation )
|
||||||
{
|
{
|
||||||
Glib::ustring error ;
|
Glib::ustring error ;
|
||||||
|
@ -1264,14 +1223,27 @@ void Win_GParted::activate_resize()
|
||||||
selected_partition .sector_start,
|
selected_partition .sector_start,
|
||||||
selected_partition .sector_end,
|
selected_partition .sector_end,
|
||||||
selected_partition .inside_extended ) ;
|
selected_partition .inside_extended ) ;
|
||||||
Add_Operation( OPERATION_CREATE, dialog .Get_New_Partition() );
|
|
||||||
|
Operation * operation = new OperationCreate( devices[ current_device ],
|
||||||
|
selected_partition,
|
||||||
|
dialog .Get_New_Partition() ) ;
|
||||||
|
operation ->icon = render_icon( Gtk::Stock::NEW, Gtk::ICON_SIZE_MENU );
|
||||||
|
|
||||||
|
Add_Operation( operation ) ;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else//normal move/resize on existing partition
|
else//normal move/resize on existing partition
|
||||||
Add_Operation( OPERATION_RESIZE_MOVE, dialog .Get_New_Partition() );
|
{
|
||||||
|
Operation * operation = new OperationResizeMove( devices[ current_device ],
|
||||||
|
selected_partition,
|
||||||
|
dialog .Get_New_Partition() );
|
||||||
|
operation ->icon = render_icon( Gtk::Stock::GOTO_LAST, Gtk::ICON_SIZE_MENU );
|
||||||
|
|
||||||
|
Add_Operation( operation ) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1298,7 +1270,16 @@ void Win_GParted::activate_paste()
|
||||||
if ( dialog .run() == Gtk::RESPONSE_OK )
|
if ( dialog .run() == Gtk::RESPONSE_OK )
|
||||||
{
|
{
|
||||||
dialog .hide() ;
|
dialog .hide() ;
|
||||||
Add_Operation( OPERATION_COPY, dialog .Get_New_Partition(), dialog .get_block_size() );
|
|
||||||
|
Operation * operation = new OperationCopy( devices[ current_device ],
|
||||||
|
selected_partition,
|
||||||
|
dialog .Get_New_Partition(),
|
||||||
|
copied_partition,
|
||||||
|
dialog .get_block_size() ) ;
|
||||||
|
operation ->icon = render_icon( Gtk::Stock::COPY, Gtk::ICON_SIZE_MENU );
|
||||||
|
|
||||||
|
Add_Operation( operation ) ;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1314,7 +1295,14 @@ void Win_GParted::activate_paste()
|
||||||
//i guess this means we have to present a window with the choice (maybe the copydialog, with everything
|
//i guess this means we have to present a window with the choice (maybe the copydialog, with everything
|
||||||
//except the blocksize disabled?
|
//except the blocksize disabled?
|
||||||
//bleh, this will be fixed as soon as the algorith to determine the optimal blocksize is in place
|
//bleh, this will be fixed as soon as the algorith to determine the optimal blocksize is in place
|
||||||
Add_Operation( OPERATION_COPY, partition_new, 32 ) ;
|
Operation * operation = new OperationCopy( devices[ current_device ],
|
||||||
|
selected_partition,
|
||||||
|
partition_new,
|
||||||
|
copied_partition,
|
||||||
|
32 ) ;
|
||||||
|
operation ->icon = render_icon( Gtk::Stock::COPY, Gtk::ICON_SIZE_MENU );
|
||||||
|
|
||||||
|
Add_Operation( operation ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1342,7 +1330,12 @@ void Win_GParted::activate_new()
|
||||||
dialog .hide() ;
|
dialog .hide() ;
|
||||||
|
|
||||||
new_count++ ;
|
new_count++ ;
|
||||||
Add_Operation( OPERATION_CREATE, dialog .Get_New_Partition() );
|
Operation *operation = new OperationCreate( devices[ current_device ],
|
||||||
|
selected_partition,
|
||||||
|
dialog .Get_New_Partition() ) ;
|
||||||
|
operation ->icon = render_icon( Gtk::Stock::NEW, Gtk::ICON_SIZE_MENU );
|
||||||
|
|
||||||
|
Add_Operation( operation );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1430,8 +1423,13 @@ void Win_GParted::activate_delete()
|
||||||
if ( ! operations .size() )
|
if ( ! operations .size() )
|
||||||
close_operationslist() ;
|
close_operationslist() ;
|
||||||
}
|
}
|
||||||
else //deletion of a real partition...(now selected_partition is just a dummy)
|
else //deletion of a real partition...
|
||||||
Add_Operation( OPERATION_DELETE, selected_partition );
|
{
|
||||||
|
Operation * operation = new OperationDelete( devices[ current_device ], selected_partition ) ;
|
||||||
|
operation ->icon = render_icon( Gtk::Stock::DELETE, Gtk::ICON_SIZE_MENU ) ;
|
||||||
|
|
||||||
|
Add_Operation( operation ) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Win_GParted::activate_info()
|
void Win_GParted::activate_info()
|
||||||
|
@ -1497,18 +1495,30 @@ void Win_GParted::activate_format( GParted::FILESYSTEM new_fs )
|
||||||
{
|
{
|
||||||
remove_operation( t ) ;
|
remove_operation( t ) ;
|
||||||
|
|
||||||
//And add the new partition to the end of the operations list
|
//And insert the new partition at the old position in the operations list
|
||||||
//(NOTE: in this case we set status to STAT_NEW)
|
//(NOTE: in this case we set status to STAT_NEW)
|
||||||
part_temp .status = STAT_NEW ;
|
part_temp .status = STAT_NEW ;
|
||||||
|
|
||||||
Add_Operation( OPERATION_CREATE, part_temp, -1, t );
|
Operation * operation = new OperationCreate( devices[ current_device ],
|
||||||
|
selected_partition,
|
||||||
|
part_temp ) ;
|
||||||
|
operation ->icon = render_icon( Gtk::Stock::NEW, Gtk::ICON_SIZE_MENU );
|
||||||
|
|
||||||
|
Add_Operation( operation, t ) ;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else//normal formatting of an existing partition
|
else//normal formatting of an existing partition
|
||||||
Add_Operation( OPERATION_FORMAT, part_temp ) ;
|
{
|
||||||
|
Operation *operation = new OperationFormat( devices[ current_device ],
|
||||||
|
selected_partition,
|
||||||
|
part_temp );
|
||||||
|
operation ->icon = render_icon( Gtk::Stock::CONVERT, Gtk::ICON_SIZE_MENU );
|
||||||
|
|
||||||
|
Add_Operation( operation ) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Win_GParted::thread_unmount_partition( bool * succes, Glib::ustring * error )
|
void Win_GParted::thread_unmount_partition( bool * succes, Glib::ustring * error )
|
||||||
|
|
Loading…
Reference in New Issue