From 98cd693818e22e4758074848759b547c8fef4997 Mon Sep 17 00:00:00 2001 From: Mike Fleetwood Date: Thu, 10 Oct 2013 09:31:32 +0100 Subject: [PATCH] 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 3c4e3465..f38cfe9e 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("" + partition .messages[t] + "", 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 += "" + partition .messages[ t ] .substr( 0, take ) + "" ; + } } + 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 dc19f5bf..a0046dc0 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 & 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 d046035c..15fc1a4f 100644 --- a/src/LVM2_PV_Info.cc +++ b/src/LVM2_PV_Info.cc @@ -192,7 +192,6 @@ std::vector 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 ) ; }