From e00e9cfa6176d286c31785a2a3e162fc5a582601 Mon Sep 17 00:00:00 2001 From: Bart Hakvoort Date: Thu, 26 Jan 2006 22:49:37 +0000 Subject: [PATCH] deal correctly with the progressdialog's delete_event. * include/Dialog_Progress.h, src/Dialog_Progress.cc, src/Win_GParted.cc: deal correctly with the progressdialog's delete_event. --- ChangeLog | 7 ++++++ include/Dialog_Progress.h | 2 ++ src/Dialog_Progress.cc | 53 +++++++++++++++++++++++---------------- src/Win_GParted.cc | 2 +- 4 files changed, 42 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index bf0ec43a..9a5e2a44 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-01-26 Bart Hakvoort + + * include/Dialog_Progress.h, + src/Dialog_Progress.cc, + src/Win_GParted.cc: deal correctly with the progressdialog's + delete_event. + 2006-01-26 Bart Hakvoort * include/Dialog_Partition_Info.h, diff --git a/include/Dialog_Progress.h b/include/Dialog_Progress.h index 91cdb88c..2bcff4cf 100644 --- a/include/Dialog_Progress.h +++ b/include/Dialog_Progress.h @@ -45,8 +45,10 @@ private: void on_signal_show() ; void on_expander_changed() ; static void *static_pthread_apply_operation( void * p_dialog_progress ) ; + void on_cancel() ; void on_response( int response_id ) ; + bool on_delete_event( GdkEventAny * event ) ; Gtk::Label label_current ; Gtk::ProgressBar progressbar_all, progressbar_current ; diff --git a/src/Dialog_Progress.cc b/src/Dialog_Progress.cc index b16b1987..d7c77e1d 100644 --- a/src/Dialog_Progress.cc +++ b/src/Dialog_Progress.cc @@ -252,32 +252,43 @@ void * Dialog_Progress::static_pthread_apply_operation( void * p_dialog_progress return NULL ; } +void Dialog_Progress::on_cancel() +{ + Gtk::MessageDialog dialog( *this, + _("Are you sure you want to cancel the current operation?"), + false, + Gtk::MESSAGE_QUESTION, + Gtk::BUTTONS_NONE, + true ) ; + + dialog .set_secondary_text( _("Canceling an operation may cause SEVERE filesystem damage.") ) ; + + dialog .add_button( _("Continue Operation"), Gtk::RESPONSE_NONE ) ; + dialog .add_button( _("Cancel Operation"), Gtk::RESPONSE_CANCEL ) ; + + if ( dialog .run() == Gtk::RESPONSE_CANCEL ) + { + pthread_cancel( pthread ) ; + cancel = true ; + pulse = false ; + succes = false ; + } +} + void Dialog_Progress::on_response( int response_id ) { if ( response_id == Gtk::RESPONSE_CANCEL ) - { - Gtk::MessageDialog dialog( *this, - _("Are you sure you want to cancel the current operation?"), - false, - Gtk::MESSAGE_QUESTION, - Gtk::BUTTONS_NONE, - true ) ; - - dialog .set_secondary_text( _("Canceling an operation may cause SEVERE filesystem damage.") ) ; - - dialog .add_button( _("Continue Operation"), Gtk::RESPONSE_NONE ) ; - dialog .add_button( _("Cancel Operation"), Gtk::RESPONSE_CANCEL ) ; - - if ( dialog .run() == Gtk::RESPONSE_CANCEL ) - { - pthread_cancel( pthread ) ; - cancel = true ; - pulse = false ; - succes = false ; - } - } + on_cancel() ; } +bool Dialog_Progress::on_delete_event( GdkEventAny * event ) +{ + //it seems this get only called at runtime + on_cancel() ; + return true ; +} + + Dialog_Progress::~Dialog_Progress() { } diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc index e165d4ed..5f5d52b9 100644 --- a/src/Win_GParted.cc +++ b/src/Win_GParted.cc @@ -1394,7 +1394,7 @@ void Win_GParted::activate_apply( ) dialog_progress .signal_apply_operation .connect( sigc::mem_fun(gparted_core, &GParted_Core::apply_operation_to_disk) ) ; - for ( ; dialog_progress .run() != Gtk::RESPONSE_OK ; ) {} + for ( ; dialog_progress .run() == Gtk::RESPONSE_CANCEL ; ) {} dialog_progress .hide() ; //find out if any of the involved devices is busy