mirror of
https://gitlab.gnome.org/GNOME/gparted
synced 2024-08-27 11:40:03 +00:00
Add mechanism to capture exception messages into an OperationDetail (#790842)
All code implementing a step of an operation follows this pattern: od.add_child(OperationDetail("Step heading")); od.get_last_child().add_child(OperationDetail("More details")); // Do step success = ... od.get_last_child().set_status(success ? STATUS_SUCCESS : STATUS_ERROR); At this point any libparted messages reported via exceptions need to be added into the OperationDetail tree. Also adding further children into the tree after collecting those errors needs to be prohibited (as much as the previous patch prohibited it). Add a new method which will replace the final set_status() call above like this which set the status, captures the errors and flags that further children shouldn't be added: ... od.get_last_child().set_success_and_capture_errors(status); It emits a callback to capture the errors to provide flexibility and so that the OperationDetail class doesn't have to get into the details of how GParted_Core saves libparted exception messages. Bug 790842 - Report libparted messages into operation details at the point at which they occur
This commit is contained in:
parent
f8f9a72de6
commit
2ed7feb2f5
|
@ -60,6 +60,7 @@ public:
|
|||
void set_description( const Glib::ustring & description, Font font = FONT_NORMAL ) ;
|
||||
Glib::ustring get_description() const ;
|
||||
void set_status( OperationDetailStatus status ) ;
|
||||
void set_success_and_capture_errors( bool success );
|
||||
OperationDetailStatus get_status() const ;
|
||||
void set_treepath( const Glib::ustring & treepath ) ;
|
||||
Glib::ustring get_treepath() const ;
|
||||
|
@ -74,6 +75,7 @@ public:
|
|||
|
||||
sigc::signal< void, const OperationDetail & > signal_update ;
|
||||
sigc::signal< void, bool > signal_cancel;
|
||||
sigc::signal< void, OperationDetail & > signal_capture_errors;
|
||||
char cancelflag;
|
||||
|
||||
private:
|
||||
|
|
|
@ -106,6 +106,13 @@ void OperationDetail::set_status( OperationDetailStatus status )
|
|||
}
|
||||
}
|
||||
|
||||
void OperationDetail::set_success_and_capture_errors( bool success )
|
||||
{
|
||||
set_status( success ? STATUS_SUCCES : STATUS_ERROR );
|
||||
signal_capture_errors.emit( *this );
|
||||
no_more_children = true;
|
||||
}
|
||||
|
||||
OperationDetailStatus OperationDetail::get_status() const
|
||||
{
|
||||
return status ;
|
||||
|
|
Loading…
Reference in a new issue