From a2af9d4a34cb7f33c852bd14c713eeea2b2ebeb3 Mon Sep 17 00:00:00 2001 From: Mike Fleetwood Date: Sat, 26 May 2018 08:53:50 +0100 Subject: [PATCH] Clear previous LUKS unlock failure error before next attempt (#795617) After a failed LUKS unlock attempt the password entry dialog shows the error "Failed to open LUKS encryption". Improve the user experience by clearing that error message at the start of the next attempt to avoid contradictory information with the main windows status of "Opening encryption on $PARTITION" whilst performing the next unlock attempt. Bug 795617 - Implement opening and closing of LUKS mappings --- include/DialogPasswordEntry.h | 2 ++ src/DialogPasswordEntry.cc | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/DialogPasswordEntry.h b/include/DialogPasswordEntry.h index 1936eaf8..fbd60378 100644 --- a/include/DialogPasswordEntry.h +++ b/include/DialogPasswordEntry.h @@ -36,6 +36,8 @@ public: void set_error_message( const Glib::ustring & message ); private: + void on_button_unlock(); + Gtk::Entry *entry; Gtk::Label *error_message; }; diff --git a/src/DialogPasswordEntry.cc b/src/DialogPasswordEntry.cc index a531d54b..a95ff34f 100644 --- a/src/DialogPasswordEntry.cc +++ b/src/DialogPasswordEntry.cc @@ -20,6 +20,7 @@ #include #include #include +#include #include namespace GParted @@ -65,7 +66,8 @@ DialogPasswordEntry::DialogPasswordEntry( const Partition & partition ) vbox->pack_start( *error_message ); this->add_button( Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL ); - this->add_button( _("Unlock"), Gtk::RESPONSE_OK ); + Gtk::Button *unlock_button = this->add_button( _("Unlock"), Gtk::RESPONSE_OK ); + unlock_button->signal_clicked().connect( sigc::mem_fun( *this, &DialogPasswordEntry::on_button_unlock ) ); this->set_default_response( Gtk::RESPONSE_OK ); this->show_all_children(); } @@ -91,4 +93,12 @@ void DialogPasswordEntry::set_error_message( const Glib::ustring & message ) entry->grab_focus(); } +// Private methods + +void DialogPasswordEntry::on_button_unlock() +{ + // Clear any previous unlock failure message before starting new attempt. + error_message->set_label( "" ); +} + } //GParted