[gparted] Add LVM2 VG member details to the Information dialog (#670171)
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Add LVM2 VG member details to the Information dialog (#670171)
- Date: Sat, 1 Sep 2012 17:04:03 +0000 (UTC)
commit 307f489177bf7216c7458e88cc0ed445698ffa7a
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date: Sun Jul 1 09:57:52 2012 +0100
Add LVM2 VG member details to the Information dialog (#670171)
For LVM2 Physical Volumes display the Volume Group name and all the
members in the Information dialog.
Bug #670171 - Add LVM PV read-write support
include/LVM2_PV_Info.h | 1 +
src/Dialog_Partition_Info.cc | 48 ++++++++++++++++++++++++++++++++++++++++-
src/LVM2_PV_Info.cc | 31 +++++++++++++++++++++++++++
3 files changed, 78 insertions(+), 2 deletions(-)
---
diff --git a/include/LVM2_PV_Info.h b/include/LVM2_PV_Info.h
index 126585a..30b8813 100644
--- a/include/LVM2_PV_Info.h
+++ b/include/LVM2_PV_Info.h
@@ -43,6 +43,7 @@ public:
Byte_Value get_free_bytes( const Glib::ustring & path ) ;
bool has_active_lvs( const Glib::ustring & path ) ;
bool is_vg_exported( const Glib::ustring & vgname ) ;
+ std::vector<Glib::ustring> get_vg_members( const Glib::ustring & vgname ) ;
std::vector<Glib::ustring> get_error_messages( const Glib::ustring & path ) ;
private:
void initialize_if_required() ;
diff --git a/src/Dialog_Partition_Info.cc b/src/Dialog_Partition_Info.cc
index cf61131..be44fd0 100644
--- a/src/Dialog_Partition_Info.cc
+++ b/src/Dialog_Partition_Info.cc
@@ -19,6 +19,8 @@
#include "../include/Dialog_Partition_Info.h"
#include "../include/LVM2_PV_Info.h"
+#include <gtkmm/separator.h>
+
namespace GParted
{
@@ -171,7 +173,8 @@ void Dialog_Partition_Info::Display_Info()
{
int top = 0, bottom = 1 ;
Sector ptn_sectors = partition .get_sector_length() ;
-
+ LVM2_PV_Info lvm2_pv_info ;
+
Gtk::Table* table(manage(new Gtk::Table()));
table ->set_border_width( 5 ) ;
@@ -340,7 +343,6 @@ void Dialog_Partition_Info::Display_Info()
}
else if ( partition .filesystem == FS_LVM2_PV )
{
- LVM2_PV_Info lvm2_pv_info ;
Glib::ustring mount_point = partition .get_mountpoint() ;
if ( mount_point .empty() )
/* TO TRANSLATORS: Not active (Not a member of any volume group)
@@ -433,6 +435,48 @@ void Dialog_Partition_Info::Display_Info()
1, 2,
top++, bottom++,
Gtk::FILL ) ;
+
+ if ( partition .filesystem == FS_LVM2_PV )
+ {
+ //one blank line
+ table ->attach( * Utils::mk_label( "" ), 1, 2, top++, bottom++, Gtk::FILL ) ;
+
+ //horizontal separator
+ Gtk::HSeparator * hsep( manage( new Gtk::HSeparator() ) ) ;
+ table ->attach( * hsep, 0, 2, top++, bottom++, Gtk::FILL ) ;
+
+ //one blank line
+ table ->attach( * Utils::mk_label( "" ), 1, 2, top++, bottom++, Gtk::FILL ) ;
+
+ //Volume Group
+ Glib::ustring vgname = lvm2_pv_info .get_vg_name( partition .get_path() ) ;
+ table ->attach( * Utils::mk_label( "<b>" + Glib::ustring( _("Volume Group:") ) + "</b>"),
+ 0, 1, top, bottom, Gtk::FILL ) ;
+ table ->attach( * Utils::mk_label( vgname, true, Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false, true ),
+ 1, 2, top++, bottom++, Gtk::FILL ) ;
+
+ //Members
+ table ->attach( * Utils::mk_label( "<b>" + Glib::ustring( _("Members:") ) + "</b>"),
+ 0, 1, top, bottom, Gtk::FILL ) ;
+
+ std::vector<Glib::ustring> members ;
+ if ( ! vgname .empty() )
+ members = lvm2_pv_info .get_vg_members( vgname ) ;
+
+ if ( members .empty() )
+ table ->attach( * Utils::mk_label( "" ), 1, 2, top++, bottom++, Gtk::FILL ) ;
+ else
+ {
+ table ->attach( * Utils::mk_label( members [0], true, Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false, true ),
+ 1, 2, top++, bottom++, Gtk::FILL ) ;
+ for ( unsigned int i = 1 ; i < members .size() ; i ++ )
+ {
+ table ->attach( * Utils::mk_label( "" ), 0, 1, top, bottom, Gtk::FILL) ;
+ table ->attach( * Utils::mk_label( members [i], true, Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false, true ),
+ 1, 2, top++, bottom++, Gtk::FILL ) ;
+ }
+ }
+ }
}
Dialog_Partition_Info::~Dialog_Partition_Info()
diff --git a/src/LVM2_PV_Info.cc b/src/LVM2_PV_Info.cc
index 6365d84..2485606 100644
--- a/src/LVM2_PV_Info.cc
+++ b/src/LVM2_PV_Info.cc
@@ -158,6 +158,37 @@ bool LVM2_PV_Info::is_vg_exported( const Glib::ustring & vgname )
return false ;
}
+//Return vector of PVs which are members of the VG. Passing "" returns all empty PVs.
+std::vector<Glib::ustring> LVM2_PV_Info::get_vg_members( const Glib::ustring & vgname )
+{
+ initialize_if_required() ;
+ std::vector<Glib::ustring> members ;
+
+ //Generate array of unique PV member names of a VG
+ for ( unsigned int i = 0 ; i < lvm2_pv_cache .size() ; i ++ )
+ {
+ if ( vgname == get_pv_attr_by_row( i, PVATTR_VG_NAME ) )
+ {
+ bool already_added = false ;
+ Glib::ustring pvname = get_pv_attr_by_row( i, PVATTR_PV_NAME ) ;
+ for ( unsigned int j = 0 ; j < members .size() ; j ++ )
+ {
+ if ( pvname == members[ j ] )
+ {
+ already_added = true ;
+ break ;
+ }
+ }
+ if ( ! already_added )
+ {
+ members .push_back( get_pv_attr_by_row( i, PVATTR_PV_NAME ) ) ;
+ }
+ }
+ }
+
+ return members ;
+}
+
std::vector<Glib::ustring> LVM2_PV_Info::get_error_messages( const Glib::ustring & path )
{
initialize_if_required() ;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]