[gparted] Report this LUKS passphrase request reason as resize (#59)



commit 5752682c129a2e1c431a7642ef2fd576a95412cb
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Fri Apr 2 11:33:37 2021 +0100

    Report this LUKS passphrase request reason as resize (#59)
    
    So far when prompting for the LUKS passphrase the dialog always looks
    like this:
    
        +------------------------------------------------+
        |           LUKS Passphrase /dev/sdb1            |
        +------------------------------------------------+
        | Enter LUKS passphrase to open /dev/sdb1        |
        | Passphrase:    [                             ] |
        |                                                |
        |                                                |
        |                          [ Cancel ] [ Unlock ] |
        +------------------------------------------------+
    
    Specifically the first line of the dialog says the reason to provide the
    passphrase is to open the encryption mapping.  Now the passphrase may
    also be requested when resizing the encryption mapping, as part of a
    resize of check operation, show the appropriate reason in the password
    dialog.
    
    Closes #59 - Resize of LUKS2 encrypted file system fails with "Nothing
                 to read on input"

 include/DialogPasswordEntry.h |  2 +-
 src/DialogPasswordEntry.cc    |  8 +++-----
 src/Win_GParted.cc            | 12 ++++++++++--
 3 files changed, 14 insertions(+), 8 deletions(-)
---
diff --git a/include/DialogPasswordEntry.h b/include/DialogPasswordEntry.h
index fbd60378..b97cae0d 100644
--- a/include/DialogPasswordEntry.h
+++ b/include/DialogPasswordEntry.h
@@ -30,7 +30,7 @@ namespace GParted
 class DialogPasswordEntry : public Gtk::Dialog
 {
 public:
-       DialogPasswordEntry( const Partition & partition );
+       DialogPasswordEntry(const Partition& partition, const Glib::ustring& reason);
        ~DialogPasswordEntry();
        const char * get_password();
        void set_error_message( const Glib::ustring & message );
diff --git a/src/DialogPasswordEntry.cc b/src/DialogPasswordEntry.cc
index 7e143679..1cbfbb81 100644
--- a/src/DialogPasswordEntry.cc
+++ b/src/DialogPasswordEntry.cc
@@ -27,7 +27,7 @@
 namespace GParted
 {
 
-DialogPasswordEntry::DialogPasswordEntry( const Partition & partition )
+DialogPasswordEntry::DialogPasswordEntry(const Partition& partition, const Glib::ustring& reason)
 {
        this->set_resizable( false );
        this->set_size_request( 400, -1 );
@@ -41,10 +41,8 @@ DialogPasswordEntry::DialogPasswordEntry( const Partition & partition )
        vbox->set_spacing( 5 );
        get_vbox()->pack_start( *vbox, Gtk::PACK_SHRINK );
 
-       // Line 1: "Enter LUKS passphrase to open /dev/sda1"
-       vbox->pack_start( *Utils::mk_label(
-                       Glib::ustring::compose( _("Enter LUKS passphrase to open %1"), partition.get_path() ) 
),
-                       Gtk::PACK_SHRINK );
+       // Line 1: Reason message, e.g. "Enter LUKS passphrase to open /dev/sda1"
+       vbox->pack_start(*Utils::mk_label(reason), Gtk::PACK_SHRINK);
 
        // Line 2: "Passphrase: [              ]"
        // (Horizontal box holding prompt and entry box)
diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc
index cbe9d0b7..f15d29f4 100644
--- a/src/Win_GParted.cc
+++ b/src/Win_GParted.cc
@@ -2137,7 +2137,10 @@ bool Win_GParted::ask_for_password_for_encrypted_resize_as_required(const Partit
                // correct and don't re-prompt when it will be correct 99.9% of the time.
                return true;
 
-       DialogPasswordEntry dialog(partition);
+       DialogPasswordEntry dialog(partition,
+                                  /* TO TRANSLATORS: looks like   Enter LUKS passphrase to resize /dev/sda1 
*/
+                                  Glib::ustring::compose(_("Enter LUKS passphrase to resize %1"),
+                                                         partition.get_path()));
        dialog.set_transient_for(*this);
        bool success = false;
        do
@@ -2781,7 +2784,12 @@ void Win_GParted::toggle_crypt_busy_state()
                                break;
 
                        // Open password dialog and attempt to unlock LUKS mapping.
-                       DialogPasswordEntry dialog( *selected_partition_ptr );
+                       DialogPasswordEntry dialog(*selected_partition_ptr,
+                                                  /* TO TRANSLATORS: looks like
+                                                   * Enter LUKS passphrase to open /dev/sda1
+                                                   */
+                                                  Glib::ustring::compose(_("Enter LUKS passphrase to open 
%1"),
+                                                                         
selected_partition_ptr->get_path()));
                        dialog.set_transient_for( *this );
                        do
                        {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]