[gparted] Make Partition Information dialog warnings selectable (#705596)



commit 98cd693818e22e4758074848759b547c8fef4997
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Thu Oct 10 09:31:32 2013 +0100

    Make Partition Information dialog warnings selectable (#705596)
    
    Allow all partition warning messages to be selectable and copied.  Merge
    all the messages into a single Gtk::Label widget so that they can be
    selected together.
    
    Use a blank line between individual messages so that each message can be
    distinguished. Therefore each message should be formatted as one or more
    non-blank lines, with an optional trailing new line.  This is true of
    GParted internal messages and probably all external messages and errors
    from libparted and executed commands too.
    
    Bug #705596 - Partition Information Dialog - let user copy warnings

 src/Dialog_Partition_Info.cc |   29 +++++++++++++++++++++--------
 src/GParted_Core.cc          |    3 +--
 src/LVM2_PV_Info.cc          |    1 -
 3 files changed, 22 insertions(+), 11 deletions(-)
---
diff --git a/src/Dialog_Partition_Info.cc b/src/Dialog_Partition_Info.cc
index 3c4e346..f38cfe9 100644
--- a/src/Dialog_Partition_Info.cc
+++ b/src/Dialog_Partition_Info.cc
@@ -58,17 +58,30 @@ Dialog_Partition_Info::Dialog_Partition_Info( const Partition & partition )
 
                frame ->set_label_widget( *hbox ) ;
 
-               //FIXME: for more clarity we should add a listview here with alternating rowcolors..
-               //that way it's easier to tell messages apart..
+               //Merge all messages for display so that they can be selected together.
+               //  Use a blank line between individual messages so that each message can be
+               //  distinguished. Therefore each message should have been formatted as one
+               //  or more non-blank lines, with an optional trailing new line.  This is
+               //  true of GParted internal messages and probably all external messages and
+               //  errors from libparted and executed commands too.
+               Glib::ustring all_messages ;
+               for ( unsigned int t = 0; t < partition .messages .size(); t ++ )
                {
-                       Gtk::VBox* vbox(manage(new Gtk::VBox(false,4)));
-                       vbox->set_border_width(5);
+                       if ( all_messages .size() > 0 )
+                               all_messages += "\n\n" ;
 
-                       for (unsigned int t = 0; t < partition.messages.size(); ++t)
-                               vbox->pack_start(*Utils::mk_label("<i>" + partition .messages[t] + "</i>", 
true, true),
-                                                Gtk::PACK_SHRINK);
-                       frame->add(*vbox);
+                       Glib::ustring::size_type take = partition .messages[ t ] .size() ;
+                       if ( take > 0 )
+                       {
+                               if ( partition .messages[ t ][ take-1 ] == '\n' )
+                                       take -- ;  //Skip optional trailing new line
+                               all_messages += "<i>" + partition .messages[ t ] .substr( 0, take ) + "</i>" ;
+                       }
                }
+               Gtk::VBox *vbox( manage( new Gtk::VBox() ) ) ;
+               vbox ->set_border_width( 5 ) ;
+               vbox ->pack_start( *Utils::mk_label( all_messages, true, true, true ), Gtk::PACK_SHRINK ) ;
+               frame ->add( *vbox ) ;
 
                this ->get_vbox() ->pack_start( *frame, Gtk::PACK_SHRINK ) ;
        }
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index dc19f5b..a0046dc 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -1194,7 +1194,6 @@ GParted::FILESYSTEM GParted_Core::get_filesystem( PedDevice* lp_device, PedParti
                {
                        Glib::ustring temp ;
                        temp = _( "Linux Unified Key Setup encryption is not yet supported." ) ;
-                       temp += "\n" ;
                        messages .push_back( temp ) ;
                        return GParted::FS_LUKS ;
                }
@@ -1604,7 +1603,7 @@ void GParted_Core::set_used_sectors( std::vector<Partition> & partitions, PedDis
                                        temp += _("Because of this some operations may be unavailable.") ;
                                        if ( ! Utils::get_filesystem_software( partitions[ t ] .filesystem ) 
.empty() )
                                        {
-                                               temp += "\n\n" ;
+                                               temp += "\n" ;
                                                temp += _( "The cause might be a missing software package.") ;
                                                temp += "\n" ;
                                                /*TO TRANSLATORS: looks like The following list of software 
packages is required for NTFS file system support:  ntfsprogs. */
diff --git a/src/LVM2_PV_Info.cc b/src/LVM2_PV_Info.cc
index d046035..15fc1a4 100644
--- a/src/LVM2_PV_Info.cc
+++ b/src/LVM2_PV_Info.cc
@@ -192,7 +192,6 @@ std::vector<Glib::ustring> LVM2_PV_Info::get_error_messages( const Glib::ustring
        if ( bit_set( get_vg_attr_by_name( vgname, VGATTR_VG_BITS ), VGBIT_PARTIAL ) )
        {
                temp = _("One or more Physical Volumes belonging to the Volume Group is missing.") ;
-               temp += "\n" ;
                partition_specific_messages .push_back ( temp ) ;
        }
 


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