diff --git a/ChangeLog b/ChangeLog index f3b7084b..45b6dfe5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2006-01-02 Bart Hakvoort + + * happy new year ;) + * src/TreeView_Detail.cc: fixed some alignment issues + * include/GParted_Core.h, + src/GParted_Core.cc, + include/Operation.h, + src/Operation.cc, + include/Win_GParted.h, + src/Win_GParted.cc: removed confirmationdialogs for delete and + convert partitions (#319841). + Also renamed 'convert' to 'format' to reflect the actual + functionality. + 2005-12-30 Bart Hakvoort * src/Win_GParted.cc: fixed alignments of cells in combo_devices diff --git a/include/GParted_Core.h b/include/GParted_Core.h index f9fea1e6..23ca5b6d 100644 --- a/include/GParted_Core.h +++ b/include/GParted_Core.h @@ -52,7 +52,7 @@ public: void Apply_Operation_To_Disk( Operation & operation ); bool Create( const Device & device, Partition & new_partition ) ; - bool Convert_FS( const Partition & partition ) ; + bool format( const Partition & partition ) ; bool Delete( const Partition & partition ) ; bool Resize( const Device & device, const Partition & partition_old, const Partition & partition_new ) ; bool Copy( const Glib::ustring & src_part_path, Partition & partition_dest ) ; diff --git a/include/Operation.h b/include/Operation.h index 9aed6045..a2b1df0d 100644 --- a/include/Operation.h +++ b/include/Operation.h @@ -31,7 +31,7 @@ enum OperationType { DELETE = 0, CREATE = 1, RESIZE_MOVE = 2, - CONVERT = 3, + FORMAT = 3, COPY = 4 }; diff --git a/include/Win_GParted.h b/include/Win_GParted.h index e1d40d2b..f4bb3a28 100644 --- a/include/Win_GParted.h +++ b/include/Win_GParted.h @@ -56,7 +56,7 @@ private: void init_menubar( ) ; void init_toolbar( ) ; void init_partition_menu( ) ; - void init_convert_menu( ) ; + Gtk::Menu * create_format_menu( ) ; void init_device_info( ) ; void init_operationslist( ) ; void init_hpaned_main( ) ; @@ -74,7 +74,6 @@ private: 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 //convenience functions void allow_new( bool b ) { @@ -97,7 +96,7 @@ private: menu_partition .items( )[ 6 ] .set_sensitive( b ); toolbar_main .get_nth_item( 6 ) ->set_sensitive( b ); } - void allow_convert( bool b ) { + void allow_format( bool b ) { menu_partition .items( )[ 8 ] .set_sensitive( b ); } void allow_unmount( bool b ) { @@ -144,7 +143,7 @@ private: void activate_new( ); void activate_delete( ); void activate_info( ); - void activate_convert( GParted::FILESYSTEM new_fs ); + void activate_format( GParted::FILESYSTEM new_fs ); void activate_unmount( ) ; void activate_disklabel( ) ; @@ -155,8 +154,8 @@ private: //private variables unsigned int current_device ; Partition selected_partition, copied_partition; - std::vector devices; - std::vector operations; + std::vector devices; + std::vector operations; //gui stuff Gtk::HPaned hpaned_main; @@ -166,7 +165,7 @@ private: Gtk::Toolbar toolbar_main; Gtk::MenuBar menubar_main; Gtk::ComboBox combo_devices ; - Gtk::Menu menu_partition, menu_convert, *menu ; + Gtk::Menu menu_partition, *menu ; Gtk::ToolButton *toolbutton; Gtk::Statusbar statusbar; Gtk::Image *image ; diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc index fa7db41e..69a7135a 100644 --- a/src/GParted_Core.cc +++ b/src/GParted_Core.cc @@ -427,7 +427,7 @@ int GParted_Core::get_estimated_time( const Operation & operation ) return 2 ; //i guess it'll never take more then 2 secs to delete a partition ;) case GParted::CREATE: - case GParted::CONVERT: + case GParted::FORMAT: set_proper_filesystem( operation .partition_new .filesystem ) ; if ( p_filesystem ) return p_filesystem ->get_estimated_time( operation .partition_new .Get_Length_MB( ) ) ; @@ -468,9 +468,9 @@ void GParted_Core::Apply_Operation_To_Disk( Operation & operation ) Show_Error( String::ucompose( _("Error while resizing/moving %1"), operation .partition_new .partition ) ) ; break; - case CONVERT: - if ( ! Convert_FS( operation .partition_new ) ) - Show_Error( String::ucompose( _("Error while converting filesystem of %1"), operation .partition_new .partition ) ) ; + case FORMAT: + if ( ! format( operation .partition_new ) ) + Show_Error( String::ucompose( _("Error while formattting filesystem of %1"), operation .partition_new .partition ) ) ; break; case COPY: @@ -499,7 +499,7 @@ bool GParted_Core::Create( const Device & device, Partition & new_partition ) return false ; } -bool GParted_Core::Convert_FS( const Partition & partition ) +bool GParted_Core::format( const Partition & partition ) { //remove all filesystem signatures... erase_filesystem_signatures( partition ) ; diff --git a/src/Operation.cc b/src/Operation.cc index 60183071..a7a392f8 100644 --- a/src/Operation.cc +++ b/src/Operation.cc @@ -112,11 +112,10 @@ Glib::ustring Operation::Get_String( ) return temp; - case CONVERT : - /*TO TRANSLATORS: looks like Convert /dev/hda4 from ntfs to linux-swap */ - return String::ucompose( _( "Convert %1 from %2 to %3"), + case FORMAT : + /*TO TRANSLATORS: looks like Format /dev/hda4 as linux-swap */ + return String::ucompose( _("Format %1 as %2"), partition_original .partition, - Utils::Get_Filesystem_String( partition_original .filesystem ), Utils::Get_Filesystem_String( partition_new .filesystem ) ) ; case COPY : @@ -139,7 +138,7 @@ void Operation::Apply_Operation_To_Visual( std::vector & partitions ) case DELETE : Apply_Delete_To_Visual( partitions ) ; break ; case RESIZE_MOVE: Apply_Resize_Move_To_Visual( partitions ); break ; case CREATE : - case CONVERT : + case FORMAT : case COPY : Apply_Create_To_Visual( partitions ); break ; } } diff --git a/src/TreeView_Detail.cc b/src/TreeView_Detail.cc index 86565dda..2eed7d21 100644 --- a/src/TreeView_Detail.cc +++ b/src/TreeView_Detail.cc @@ -45,17 +45,24 @@ TreeView_Detail::TreeView_Detail( ) get_column( 1 ) ->pack_start( treeview_detail_columns .filesystem, true ); //colored text in Partition column - Gtk::CellRendererText *cell_renderer_text = dynamic_cast( get_column( 0 ) ->get_first_cell_renderer( ) ); - get_column( 0 ) ->add_attribute( cell_renderer_text ->property_foreground(), treeview_detail_columns .text_color ); - - //colored text in Filesystem column - std::vector renderers = get_column( 1 ) ->get_cell_renderers() ; - cell_renderer_text = dynamic_cast( renderers .back() ) ; - get_column( 1 ) ->add_attribute( cell_renderer_text ->property_foreground(), treeview_detail_columns .text_color ); + Gtk::CellRendererText *cell_renderer_text = + dynamic_cast( get_column( 0 ) ->get_first_cell_renderer() ); + get_column( 0 ) ->add_attribute( cell_renderer_text ->property_foreground(), + treeview_detail_columns .text_color ); + //colored text in Filesystem column + std::vector renderers = get_column( 1 ) ->get_cell_renderers() ; + cell_renderer_text = dynamic_cast( renderers .back() ) ; + get_column( 1 ) ->add_attribute( cell_renderer_text ->property_foreground(), + treeview_detail_columns .text_color ); + + //pixbuf and text are both left aligned + get_column( 1 ) ->get_first_cell_renderer() ->property_xalign() = 0 ; + cell_renderer_text ->property_xalign() = 0 ; + //set alignment of numeric columns to right for( short t = 2 ; t < 5 ; t++ ) - dynamic_cast( get_column( t ) ->get_first_cell_renderer() ) ->property_xalign() = 1 ; + get_column_cell_renderer( t ) ->property_xalign() = 1 ; } void TreeView_Detail::load_partitions( const std::vector & partitions ) diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc index 14917c80..dadd87fa 100644 --- a/src/Win_GParted.cc +++ b/src/Win_GParted.cc @@ -186,46 +186,86 @@ void Win_GParted::init_toolbar( ) void Win_GParted::init_partition_menu( ) { //fill menu_partition - menu_partition .items( ) .push_back( Gtk::Menu_Helpers::StockMenuElem( Gtk::Stock::NEW, sigc::mem_fun(*this, &Win_GParted::activate_new) ) ); - menu_partition .items( ) .push_back( Gtk::Menu_Helpers::StockMenuElem( Gtk::Stock::DELETE, Gtk::AccelKey( GDK_Delete, Gdk::BUTTON1_MASK ), sigc::mem_fun(*this, &Win_GParted::activate_delete) ) ); - menu_partition .items( ) .push_back( Gtk::Menu_Helpers::SeparatorElem( ) ); + menu_partition .items() .push_back( + Gtk::Menu_Helpers::StockMenuElem( Gtk::Stock::NEW, + sigc::mem_fun(*this, &Win_GParted::activate_new) ) ); + menu_partition .items() .push_back( + Gtk::Menu_Helpers::StockMenuElem( Gtk::Stock::DELETE, + Gtk::AccelKey( GDK_Delete, Gdk::BUTTON1_MASK ), + sigc::mem_fun(*this, &Win_GParted::activate_delete) ) ); + + menu_partition .items() .push_back( Gtk::Menu_Helpers::SeparatorElem() ); + image = manage( new Gtk::Image( Gtk::Stock::GOTO_LAST, Gtk::ICON_SIZE_MENU ) ); - menu_partition .items( ) .push_back( Gtk::Menu_Helpers::ImageMenuElem( _("Resize/Move"), *image, sigc::mem_fun(*this, &Win_GParted::activate_resize) ) ); - menu_partition .items( ) .push_back( Gtk::Menu_Helpers::SeparatorElem( ) ); - menu_partition .items( ) .push_back( Gtk::Menu_Helpers::StockMenuElem( Gtk::Stock::COPY, sigc::mem_fun(*this, &Win_GParted::activate_copy) ) ); - menu_partition .items( ) .push_back( Gtk::Menu_Helpers::StockMenuElem( Gtk::Stock::PASTE, sigc::mem_fun(*this, &Win_GParted::activate_paste) ) ); - menu_partition .items( ) .push_back( Gtk::Menu_Helpers::SeparatorElem( ) ); + menu_partition .items() .push_back( + Gtk::Menu_Helpers::ImageMenuElem( _("Resize/Move"), + *image, + sigc::mem_fun(*this, &Win_GParted::activate_resize) ) ); + + menu_partition .items() .push_back( Gtk::Menu_Helpers::SeparatorElem() ); + + menu_partition .items() .push_back( + Gtk::Menu_Helpers::StockMenuElem( Gtk::Stock::COPY, + sigc::mem_fun(*this, &Win_GParted::activate_copy) ) ); + + menu_partition .items() .push_back( + Gtk::Menu_Helpers::StockMenuElem( Gtk::Stock::PASTE, + sigc::mem_fun(*this, &Win_GParted::activate_paste) ) ); + + menu_partition .items() .push_back( Gtk::Menu_Helpers::SeparatorElem() ); + image = manage( new Gtk::Image( Gtk::Stock::CONVERT, Gtk::ICON_SIZE_MENU ) ); /*TO TRANSLATORS: menuitem which holds a submenu with filesystems.. */ - menu_partition .items( ) .push_back( Gtk::Menu_Helpers::ImageMenuElem( _("_Convert to"), *image, menu_convert ) ) ; - menu_partition .items( ) .push_back( Gtk::Menu_Helpers::SeparatorElem( ) ); - menu_partition .items( ) .push_back( Gtk::Menu_Helpers::MenuElem( _("Unmount"), sigc::mem_fun( *this, &Win_GParted::activate_unmount ) ) ); - menu_partition .items( ) .push_back( Gtk::Menu_Helpers::SeparatorElem( ) ); - menu_partition .items( ) .push_back( Gtk::Menu_Helpers::StockMenuElem( Gtk::Stock::DIALOG_INFO, sigc::mem_fun(*this, &Win_GParted::activate_info) ) ); - init_convert_menu( ) ; + menu_partition .items() .push_back( + Gtk::Menu_Helpers::ImageMenuElem( _("_Format to"), + *image, + * create_format_menu() ) ) ; + + menu_partition .items() .push_back( Gtk::Menu_Helpers::SeparatorElem() ); + + menu_partition .items() .push_back( + Gtk::Menu_Helpers::MenuElem( _("Unmount"), + sigc::mem_fun( *this, &Win_GParted::activate_unmount ) ) ); + + menu_partition .items() .push_back( Gtk::Menu_Helpers::SeparatorElem() ); + + menu_partition .items() .push_back( + Gtk::Menu_Helpers::StockMenuElem( Gtk::Stock::DIALOG_INFO, + sigc::mem_fun(*this, &Win_GParted::activate_info) ) ); menu_partition .accelerate( *this ) ; } -void Win_GParted::init_convert_menu() +Gtk::Menu * Win_GParted::create_format_menu() { - for ( unsigned int t=0; t < gparted_core .get_filesystems( ) .size( ) -1 ; t++ ) + menu = manage( new Gtk::Menu() ) ; + + for ( unsigned int t =0; t < gparted_core .get_filesystems() .size() -1 ; t++ ) { - hbox = manage( new Gtk::HBox( ) ); + hbox = manage( new Gtk::HBox() ); //the colored square - image = manage( new Gtk::Image( Utils::get_color_as_pixbuf( gparted_core .get_filesystems()[ t ] .filesystem, 16, 16 ) ) ) ; - hbox ->pack_start( *image, Gtk::PACK_SHRINK ); + hbox ->pack_start( * manage( new Gtk::Image( + Utils::get_color_as_pixbuf( + gparted_core .get_filesystems()[ t ] .filesystem, 16, 16 ) ) ), + Gtk::PACK_SHRINK ) ; //the label... - hbox ->pack_start( * Utils::mk_label( " " + Utils::Get_Filesystem_String( gparted_core .get_filesystems( )[ t ] .filesystem ) ), Gtk::PACK_SHRINK ); + hbox ->pack_start( * Utils::mk_label( + " " + + Utils::Get_Filesystem_String( gparted_core .get_filesystems()[ t ] .filesystem ) ), + Gtk::PACK_SHRINK ); - menu_item = manage( new Gtk::MenuItem( *hbox ) ) ; - menu_convert.items( ) .push_back( *menu_item ); - menu_convert.items( ) .back( ) .signal_activate( ) .connect( sigc::bind(sigc::mem_fun(*this, &Win_GParted::activate_convert), gparted_core .get_filesystems( )[ t ] .filesystem ) ) ; + menu ->items() .push_back( * manage( new Gtk::MenuItem( *hbox ) ) ); + if ( gparted_core .get_filesystems()[ t ] .create ) + menu ->items() .back() .signal_activate() .connect( + sigc::bind(sigc::mem_fun(*this, &Win_GParted::activate_format), + gparted_core .get_filesystems()[ t ] .filesystem ) ) ; + else + menu ->items() .back() .set_sensitive( false ) ; } - menu_convert.show_all_children() ; + return menu ; } void Win_GParted::init_device_info() @@ -486,19 +526,24 @@ void Win_GParted::Refresh_Visual( ) switch ( operations[ t ] .operationtype ) { case GParted::DELETE : - treerow[ treeview_operations_columns.operation_icon ] =render_icon(Gtk::Stock::DELETE, Gtk::ICON_SIZE_MENU); + treerow[ treeview_operations_columns.operation_icon ] = + render_icon( Gtk::Stock::DELETE, Gtk::ICON_SIZE_MENU ); break; case GParted::CREATE : - treerow[ treeview_operations_columns.operation_icon ] =render_icon(Gtk::Stock::NEW, Gtk::ICON_SIZE_MENU); + treerow[ treeview_operations_columns.operation_icon ] = + render_icon( Gtk::Stock::NEW, Gtk::ICON_SIZE_MENU ); break; case GParted::RESIZE_MOVE: - treerow[ treeview_operations_columns.operation_icon ] =render_icon(Gtk::Stock::GOTO_LAST, Gtk::ICON_SIZE_MENU); + treerow[ treeview_operations_columns.operation_icon ] = + render_icon( Gtk::Stock::GOTO_LAST, Gtk::ICON_SIZE_MENU ); break; - case GParted::CONVERT : - treerow[ treeview_operations_columns.operation_icon ] =render_icon(Gtk::Stock::CONVERT, Gtk::ICON_SIZE_MENU); + case GParted::FORMAT : + treerow[ treeview_operations_columns.operation_icon ] = + render_icon( Gtk::Stock::CONVERT, Gtk::ICON_SIZE_MENU ); break; case GParted::COPY : - treerow[ treeview_operations_columns.operation_icon ] =render_icon(Gtk::Stock::COPY, Gtk::ICON_SIZE_MENU); + treerow[ treeview_operations_columns.operation_icon ] = + render_icon( Gtk::Stock::COPY, Gtk::ICON_SIZE_MENU ); break; } } @@ -577,7 +622,7 @@ bool Win_GParted::Quit_Check_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 ) ; allow_info( false ) ; + allow_paste( false ); allow_format( false ); allow_unmount( false ) ; allow_info( false ) ; //no partition selected... if ( selected_partition .partition .empty( ) ) @@ -630,7 +675,7 @@ void Win_GParted::Set_Valid_Operations( ) fs = gparted_core .get_fs( selected_partition .filesystem ) ; allow_delete( true ) ; - allow_convert( true ) ; + allow_format( true ) ; //find out if resizing/moving is possible if ( (fs .grow || fs .shrink ) && ! devices[ current_device ] .readonly ) @@ -644,18 +689,6 @@ void Win_GParted::Set_Valid_Operations( ) } } -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++ ) - { - if ( gparted_core .get_filesystems( )[ t ] .filesystem == selected_partition .filesystem || ! gparted_core .get_filesystems( )[ t ] .create ) - menu_convert .items( )[ t ] .set_sensitive( false ) ; - else - menu_convert .items( )[ t ] .set_sensitive( true ) ; - } -} - void Win_GParted::open_operationslist( ) { hbox_operations .show( ) ; @@ -800,11 +833,16 @@ void Win_GParted::menu_gparted_filesystems( ) Dialog_Filesystems dialog ; dialog .set_transient_for( *this ) ; - dialog .Load_Filesystems( gparted_core .get_filesystems( ) ) ; - while ( dialog .run( ) == Gtk::RESPONSE_OK ) + dialog .Load_Filesystems( gparted_core .get_filesystems() ) ; + while ( dialog .run() == Gtk::RESPONSE_OK ) { - gparted_core .find_supported_filesystems( ) ; - dialog .Load_Filesystems( gparted_core .get_filesystems( ) ) ; + gparted_core .find_supported_filesystems() ; + dialog .Load_Filesystems( gparted_core .get_filesystems() ) ; + + //recreate format menu... + menu_partition .items()[ 8 ] .remove_submenu() ; + menu_partition .items()[ 8 ] .set_submenu( * create_format_menu() ) ; + menu_partition .show_all_children() ; } } @@ -1051,116 +1089,119 @@ void Win_GParted::activate_new( ) } } -void Win_GParted::activate_delete( ) +void Win_GParted::activate_delete() { - //since logicals are *always* numbered from 5 to there can be a shift in numbers after deletion. - //e.g. consider /dev/hda5 /dev/hda6 /dev/hda7. Now after removal of /dev/hda6, /dev/hda7 is renumbered to /dev/hda6 - //the new situation is now /dev/hda5 /dev/hda6. If /dev/hda7 was mounted the OS cannot find /dev/hda7 anymore and the results aren't that pretty - //it seems best to check for this and prohibit deletion with some explanation to the user. - if ( selected_partition .type == GParted::TYPE_LOGICAL && + /* since logicals are *always* numbered from 5 to there can be a shift + * in numbers after deletion. + * e.g. consider /dev/hda5 /dev/hda6 /dev/hda7. Now after removal of /dev/hda6, + * /dev/hda7 is renumbered to /dev/hda6 + * the new situation is now /dev/hda5 /dev/hda6. If /dev/hda7 was mounted + * the OS cannot find /dev/hda7 anymore and the results aren't that pretty. + * It seems best to check for this and prohibit deletion with some explanation to the user.*/ + if ( selected_partition .type == GParted::TYPE_LOGICAL && 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 = "" ; str_temp += _( "Unable to delete partition!") ; str_temp += "\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( ) ; + dialog .run() ; return; } - str_temp = "" ; - str_temp += String::ucompose( _( "Are you sure you want to delete %1?"), selected_partition .partition ) + "" ; + //if partition is on the clipboard... if ( selected_partition .partition == copied_partition .partition ) { - str_temp += "\n\n" ; + str_temp = "" ; + str_temp += String::ucompose( _( "Are you sure you want to delete %1?"), + selected_partition .partition ) + "\n\n" ; str_temp += _( "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 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 .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) - //if deleted partition was on the clipboard we erase it... - if ( selected_partition .partition == copied_partition .partition ) - copied_partition .Reset( ) ; - - //if deleted one is NEW, it doesn't make sense to add it to the operationslist, we erase its creation - //and possible modifications like resize etc.. from the operationslist. Calling Refresh_Visual will wipe every memory of its existence ;-) - if ( selected_partition .status == GParted::STAT_NEW ) - { - //remove all operations done on this new partition (this includes creation) - for ( int t = 0 ; t < static_cast ( 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 ; - - new_count += 1 ; - - Refresh_Visual( ); - - 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" + 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 .show_all_children() ; + + if ( dialog .run() != Gtk::RESPONSE_OK ) + return ; } + + //if deleted partition was on the clipboard we erase it... + if ( selected_partition .partition == copied_partition .partition ) + copied_partition .Reset() ; + + /* if deleted one is NEW, it doesn't make sense to add it to the operationslist, + * we erase its creation and possible modifications like resize etc.. from the operationslist. + * Calling Refresh_Visual will wipe every memory of its existence ;-)*/ + if ( selected_partition .status == GParted::STAT_NEW ) + { + //remove all operations done on this new partition (this includes creation) + for ( int t = 0 ; t < static_cast( operations .size() ) ; t++ ) + 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 ; + + new_count += 1 ; + + Refresh_Visual(); + + if ( ! operations .size() ) + close_operationslist() ; + } + else //deletion of a real partition...(now selected_partition is just a dummy) + Add_Operation( GParted::DELETE, selected_partition ); } void Win_GParted::activate_info( ) { Dialog_Partition_Info dialog( selected_partition ); dialog .set_transient_for( *this ); - dialog .run( ); + dialog .run(); } -void Win_GParted::activate_convert( GParted::FILESYSTEM new_fs ) +void Win_GParted::activate_format( GParted::FILESYSTEM new_fs ) { - //standard warning.. - str_temp = "" ; - str_temp += String::ucompose( _("Are you sure you want to convert this filesystem to %1?"), Utils::Get_Filesystem_String( new_fs ) ) + "\n\n" ; - str_temp += String::ucompose( _("This operation will destroy all data on %1"), selected_partition .partition ) ; - - Gtk::MessageDialog dialog( *this, str_temp, true, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_CANCEL, true ); - - dialog. add_button( Gtk::Stock::CONVERT, Gtk::RESPONSE_OK ) ; - dialog. show_all_children( ) ; - - if ( dialog .run( ) == Gtk::RESPONSE_CANCEL ) - return ; - - dialog .hide( ) ;//i want to be sure the dialog is gone _before_ operationslist shows up (only matters if first operation) - //check for some limits... fs = gparted_core .get_fs( new_fs ) ; - if ( selected_partition .Get_Length_MB( ) < fs .MIN || ( fs .MAX && selected_partition .Get_Length_MB( ) > fs .MAX ) ) + if ( selected_partition .Get_Length_MB() < fs .MIN || + fs .MAX && selected_partition .Get_Length_MB() > fs .MAX ) { str_temp = "" ; - str_temp += String::ucompose( _("Can not convert this filesystem to %1."), Utils::Get_Filesystem_String( new_fs ) ) ; + str_temp += String::ucompose( + _("Can not format this filesystem to %1."), + Utils::Get_Filesystem_String( new_fs ) ) ; str_temp += "\n\n" ; if ( selected_partition .Get_Length_MB( ) < fs .MIN ) - str_temp += String::ucompose( _( "A %1 filesystem requires a partition of at least %2 MB."), Utils::Get_Filesystem_String( new_fs ), fs .MIN ) ; + str_temp += String::ucompose( + _( "A %1 filesystem requires a partition of at least %2 MB."), + Utils::Get_Filesystem_String( new_fs ), + fs .MIN ) ; else - str_temp += String::ucompose( _( "A partition with a %1 filesystem has a maximum size of %2 MB."), Utils::Get_Filesystem_String( new_fs ), fs .MAX ) ; - + str_temp += String::ucompose( + _( "A partition with a %1 filesystem has a maximum size of %2 MB."), + Utils::Get_Filesystem_String( new_fs ), + fs .MAX ) ; Gtk::MessageDialog dialog( *this, str_temp, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true ); - dialog .run( ) ; + dialog .run() ; return ; } @@ -1176,17 +1217,19 @@ void Win_GParted::activate_convert( GParted::FILESYSTEM new_fs ) false ) ; - //if selected_partition is NEW we simply remove the NEW operation from the list and add it again with the new filesystem - if ( selected_partition .status == GParted::STAT_NEW ) + //if selected_partition is NEW we simply remove the NEW operation from the list and + //add it again with the new filesystem + 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 ) { - 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) + //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 ); @@ -1194,8 +1237,8 @@ void Win_GParted::activate_convert( GParted::FILESYSTEM new_fs ) } } } - else//normal converting of an existing partition - Add_Operation( GParted::CONVERT, part_temp ) ; + else//normal formatting of an existing partition + Add_Operation( GParted::FORMAT, part_temp ) ; } void Win_GParted::activate_unmount( )