[gparted] Provide virtual Partition::get_filesystem_string() method (#774818)



commit bd6fc67afb772ffa11ac904e3a7130f2253daa66
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Fri Sep 2 07:53:19 2016 +0100

    Provide virtual Partition::get_filesystem_string() method (#774818)
    
    Provide and use a single interface for getting the file system string
    for display, regardless of whether the partition is encrypted or the
    encryption mapping is active or not.
    
    Example return values for get_filesystem_string() for different types
    and states of Partition objects:
    1)  Plain ext4 file system:          -> "ext4"
    2)  Closed encrypted:                -> "[Encrypted]"
    3)  Open encrypted ext4 file system: -> "[Encrypted] ext4"
    
    This simplifies the code in TreeView_Detail::create_row() which sets the
    file system type displayed in the main window.  The same method will
    then also be used when setting the operation description as each
    operation is updated to handle encrypted file systems.
    
    Bug 774818 - Implement LUKS read-write actions NOT requiring a
                 passphrase

 include/Partition.h     |    3 +++
 include/PartitionLUKS.h |    2 ++
 src/PartitionLUKS.cc    |    9 +++++++++
 src/TreeView_Detail.cc  |   16 +---------------
 4 files changed, 15 insertions(+), 15 deletions(-)
---
diff --git a/include/Partition.h b/include/Partition.h
index 8078dd1..1b49f6e 100644
--- a/include/Partition.h
+++ b/include/Partition.h
@@ -135,6 +135,9 @@ public:
        // file system.  Will be overridden in derived PartitionLUKS.
        virtual const Partition & get_filesystem_partition() const     { return *this; };
 
+       virtual const Glib::ustring get_filesystem_string() const
+                                       { return Utils::get_filesystem_string( filesystem ); };
+
        bool operator==( const Partition & partition ) const ;
        bool operator!=( const Partition & partition ) const ;
                
diff --git a/include/PartitionLUKS.h b/include/PartitionLUKS.h
index 65c4277..3e2cf63 100644
--- a/include/PartitionLUKS.h
+++ b/include/PartitionLUKS.h
@@ -54,6 +54,8 @@ public:
 
        virtual const Partition & get_filesystem_partition() const;
 
+       virtual const Glib::ustring get_filesystem_string() const;
+
 private:
        Partition encrypted;
        Sector header_size;  // Size of the LUKS header (everything up to the start of the mapping)
diff --git a/src/PartitionLUKS.cc b/src/PartitionLUKS.cc
index 72c45bb..2038d5f 100644
--- a/src/PartitionLUKS.cc
+++ b/src/PartitionLUKS.cc
@@ -200,4 +200,13 @@ const Partition & PartitionLUKS::get_filesystem_partition() const
        return *this;
 }
 
+const Glib::ustring PartitionLUKS::get_filesystem_string() const
+{
+       /* TO TRANSLATORS: means that this is an encrypted file system */
+       Glib::ustring fs_str = "[" + Glib::ustring( _("Encrypted") ) + "]";
+       if ( busy )
+               fs_str += " " + Utils::get_filesystem_string( encrypted.filesystem );
+       return fs_str;
+}
+
 } //GParted
diff --git a/src/TreeView_Detail.cc b/src/TreeView_Detail.cc
index e71c809..ffa96a1 100644
--- a/src/TreeView_Detail.cc
+++ b/src/TreeView_Detail.cc
@@ -184,21 +184,7 @@ void TreeView_Detail::create_row( const Gtk::TreeRow & treerow,
 
        // file system
        treerow[treeview_detail_columns.color] = Utils::get_color_as_pixbuf( filesystem_ptn.filesystem, 16, 
16 );
-       if ( partition.filesystem == FS_LUKS && partition.busy )
-       {
-               const Partition & encrypted = dynamic_cast<const PartitionLUKS *>( &partition 
)->get_encrypted();
-               /* TO TRANSLATORS: means that this is an encrypted file system */
-               treerow[treeview_detail_columns.filesystem] = "[" + Glib::ustring( _("Encrypted") ) + "] " +
-                                                             Utils::get_filesystem_string( 
encrypted.filesystem );
-       }
-       else if ( partition.filesystem == FS_LUKS && ! partition.busy )
-       {
-               treerow[treeview_detail_columns.filesystem] = "[" + Glib::ustring( _("Encrypted") ) + "]";
-       }
-       else
-       {
-               treerow[treeview_detail_columns.filesystem] = Utils::get_filesystem_string( 
partition.filesystem );
-       }
+       treerow[treeview_detail_columns.filesystem] = partition.get_filesystem_string();
 
        // mount point
        std::vector<Glib::ustring> temp_mountpoints = filesystem_ptn.get_mountpoints();


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