catch libparted exceptions and display them in the operationdetails if an
* include/GParted_Core.h, src/GParted_Core.cc: catch libparted exceptions and display them in the operationdetails if an operation has failed. * src/Dialog_Progress.cc: small cosmetic change to the errordialog.
This commit is contained in:
parent
29a7744fe2
commit
896c5e275e
|
@ -1,3 +1,10 @@
|
|||
2006-02-25 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||
|
||||
* include/GParted_Core.h,
|
||||
src/GParted_Core.cc: catch libparted exceptions and display them in
|
||||
the operationdetails if an operation has failed.
|
||||
* src/Dialog_Progress.cc: small cosmetic change to the errordialog.
|
||||
|
||||
2006-02-25 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||
|
||||
* improved errorhandling in Set_Used_Sectors() in the filesystemclasses
|
||||
|
|
|
@ -107,6 +107,8 @@ private:
|
|||
void close_device_and_disk() ;
|
||||
bool commit() ;
|
||||
|
||||
static PedExceptionOption ped_exception_handler( PedException * e ) ;
|
||||
|
||||
std::vector<FS> FILESYSTEMS ;
|
||||
FileSystem * p_filesystem ;
|
||||
std::vector<PedPartitionFlag> flags;
|
||||
|
|
|
@ -232,9 +232,9 @@ void Dialog_Progress::on_signal_show()
|
|||
Gtk::BUTTONS_OK,
|
||||
true ) ;
|
||||
str_temp = _("The following operation could not be applied to disk:") ;
|
||||
str_temp += "\n<i>" ;
|
||||
str_temp += "\n\n<i>" ;
|
||||
str_temp += label_current .get_text() ;
|
||||
str_temp += "</i>\n\n" ;
|
||||
str_temp += "</i>\n" ;
|
||||
str_temp += _("See the details for more information") ;
|
||||
|
||||
dialog .set_secondary_text( str_temp, true ) ;
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include <sys/statvfs.h>
|
||||
|
||||
Glib::ustring ped_error ; //see e.g. ped_exception_handler()
|
||||
|
||||
namespace GParted
|
||||
{
|
||||
|
||||
|
@ -12,8 +14,13 @@ GParted_Core::GParted_Core( )
|
|||
lp_partition = NULL ;
|
||||
p_filesystem = NULL ;
|
||||
|
||||
ped_exception_set_handler( ped_exception_handler ) ;
|
||||
|
||||
|
||||
//get valid flags ...
|
||||
for ( PedPartitionFlag flag = ped_partition_flag_next( (PedPartitionFlag) NULL ) ; flag ; flag = ped_partition_flag_next( flag ) )
|
||||
for ( PedPartitionFlag flag = ped_partition_flag_next( static_cast<PedPartitionFlag>( NULL ) ) ;
|
||||
flag ;
|
||||
flag = ped_partition_flag_next( flag ) )
|
||||
flags .push_back( flag ) ;
|
||||
|
||||
//throw libpartedversion to the stdout to see which version is actually used.
|
||||
|
@ -773,6 +780,7 @@ int GParted_Core::create_empty_partition( Partition & new_partition,
|
|||
operation_details .push_back( OperationDetails( _("create empty partition") ) ) ;
|
||||
|
||||
new_partition .partition_number = 0 ;
|
||||
ped_error .clear() ;
|
||||
|
||||
if ( open_device_and_disk( new_partition .device_path ) )
|
||||
{
|
||||
|
@ -848,22 +856,28 @@ int GParted_Core::create_empty_partition( Partition & new_partition,
|
|||
close_device_and_disk() ;
|
||||
}
|
||||
|
||||
if ( new_partition .type == GParted::TYPE_EXTENDED ||
|
||||
if ( new_partition .partition_number > 0 &&
|
||||
(
|
||||
new_partition .type == GParted::TYPE_EXTENDED ||
|
||||
(
|
||||
new_partition .partition_number > 0 &&
|
||||
wait_for_node( new_partition .partition ) &&
|
||||
erase_filesystem_signatures( new_partition )
|
||||
)
|
||||
)
|
||||
)
|
||||
{
|
||||
operation_details .back() .status = new_partition .partition_number > 0 ?
|
||||
OperationDetails::SUCCES : OperationDetails::ERROR ;
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
|
||||
return new_partition .partition_number ;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( ! ped_error .empty() )
|
||||
operation_details .back() .sub_details .push_back(
|
||||
OperationDetails( "<i>" + ped_error + "</i>", OperationDetails::NONE ) ) ;
|
||||
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
}
|
||||
|
@ -888,6 +902,7 @@ bool GParted_Core::resize_container_partition( const Partition & partition_old,
|
|||
|
||||
PedConstraint *constraint = NULL ;
|
||||
lp_partition = NULL ;
|
||||
ped_error .clear() ;
|
||||
|
||||
if ( open_device_and_disk( partition_old .device_path ) )
|
||||
{
|
||||
|
@ -949,6 +964,9 @@ bool GParted_Core::resize_container_partition( const Partition & partition_old,
|
|||
"</i>",
|
||||
OperationDetails::NONE ) ) ;
|
||||
}
|
||||
else if ( ! ped_error .empty() )
|
||||
operation_details .back() .sub_details .push_back(
|
||||
OperationDetails( "<i>" + ped_error + "</i>", OperationDetails::NONE ) ) ;
|
||||
|
||||
if ( partition_old .type == GParted::TYPE_EXTENDED )
|
||||
{
|
||||
|
@ -975,6 +993,7 @@ bool GParted_Core::resize_normal_using_libparted( const Partition & partition_ol
|
|||
PedFileSystem *fs = NULL ;
|
||||
PedConstraint *constraint = NULL ;
|
||||
lp_partition = NULL ;
|
||||
ped_error .clear() ;
|
||||
|
||||
if ( open_device_and_disk( partition_old .device_path ) )
|
||||
{
|
||||
|
@ -1010,6 +1029,11 @@ bool GParted_Core::resize_normal_using_libparted( const Partition & partition_ol
|
|||
}
|
||||
|
||||
operation_details .back() .status = return_value ? OperationDetails::SUCCES : OperationDetails::ERROR ;
|
||||
|
||||
if ( ! return_value && ! ped_error .empty() )
|
||||
operation_details .back() .sub_details .push_back(
|
||||
OperationDetails( "<i>" + ped_error + "</i>", OperationDetails::NONE ) ) ;
|
||||
|
||||
return return_value ;
|
||||
}
|
||||
|
||||
|
@ -1168,5 +1192,13 @@ bool GParted_Core::commit()
|
|||
return return_value ;
|
||||
}
|
||||
|
||||
PedExceptionOption GParted_Core::ped_exception_handler( PedException * e )
|
||||
{
|
||||
std::cout << e ->message << std::endl ;
|
||||
ped_error = e ->message ;
|
||||
|
||||
return PED_EXCEPTION_UNHANDLED ;
|
||||
}
|
||||
|
||||
|
||||
} //GParted
|
||||
|
|
Loading…
Reference in New Issue